blob: a88a0224f385005b66b6bc2d1cd3f40b88fb6576 [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"
Dinesh Duttd9ab53a2015-05-19 17:47:21 -070058#include "bgpd/bgp_nht.h"
paul718e3742002-12-13 20:15:29 +000059
60/* Extern from bgp_dump.c */
Stephen Hemmingerdde72582009-05-08 15:19:07 -070061extern const char *bgp_origin_str[];
62extern const char *bgp_origin_long_str[];
David Lamparter6b0655a2014-06-04 06:53:35 +020063
paul94f2b392005-06-28 12:44:16 +000064static struct bgp_node *
paulfee0f4c2004-09-13 05:12:46 +000065bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
paul718e3742002-12-13 20:15:29 +000066 struct prefix_rd *prd)
67{
68 struct bgp_node *rn;
69 struct bgp_node *prn = NULL;
Paul Jakmada5b30f2006-05-08 14:37:17 +000070
71 assert (table);
72 if (!table)
73 return NULL;
74
Lou Berger298cc2f2016-01-12 13:42:02 -050075 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000076 {
paulfee0f4c2004-09-13 05:12:46 +000077 prn = bgp_node_get (table, (struct prefix *) prd);
paul718e3742002-12-13 20:15:29 +000078
79 if (prn->info == NULL)
Paul Jakma64e580a2006-02-21 01:09:01 +000080 prn->info = bgp_table_init (afi, safi);
paul718e3742002-12-13 20:15:29 +000081 else
82 bgp_unlock_node (prn);
83 table = prn->info;
84 }
paul718e3742002-12-13 20:15:29 +000085
86 rn = bgp_node_get (table, p);
87
Lou Berger298cc2f2016-01-12 13:42:02 -050088 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000089 rn->prn = prn;
90
91 return rn;
92}
David Lamparter6b0655a2014-06-04 06:53:35 +020093
Paul Jakmafb982c22007-05-04 20:15:47 +000094/* Allocate bgp_info_extra */
95static struct bgp_info_extra *
96bgp_info_extra_new (void)
97{
98 struct bgp_info_extra *new;
99 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
100 return new;
101}
102
103static void
104bgp_info_extra_free (struct bgp_info_extra **extra)
105{
106 if (extra && *extra)
107 {
108 if ((*extra)->damp_info)
109 bgp_damp_info_free ((*extra)->damp_info, 0);
110
111 (*extra)->damp_info = NULL;
112
113 XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
114
115 *extra = NULL;
116 }
117}
118
119/* Get bgp_info extra information for the given bgp_info, lazy allocated
120 * if required.
121 */
122struct bgp_info_extra *
123bgp_info_extra_get (struct bgp_info *ri)
124{
125 if (!ri->extra)
126 ri->extra = bgp_info_extra_new();
127 return ri->extra;
128}
129
paul718e3742002-12-13 20:15:29 +0000130/* Free bgp route information. */
paul200df112005-06-01 11:17:05 +0000131static void
paul718e3742002-12-13 20:15:29 +0000132bgp_info_free (struct bgp_info *binfo)
133{
134 if (binfo->attr)
Paul Jakmaf6f434b2010-11-23 21:28:03 +0000135 bgp_attr_unintern (&binfo->attr);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -0500136
137 bgp_unlink_nexthop(binfo);
Paul Jakmafb982c22007-05-04 20:15:47 +0000138 bgp_info_extra_free (&binfo->extra);
Josh Baileyde8d5df2011-07-20 20:46:01 -0700139 bgp_info_mpath_free (&binfo->mpath);
paul718e3742002-12-13 20:15:29 +0000140
paul200df112005-06-01 11:17:05 +0000141 peer_unlock (binfo->peer); /* bgp_info peer reference */
142
paul718e3742002-12-13 20:15:29 +0000143 XFREE (MTYPE_BGP_ROUTE, binfo);
144}
145
paul200df112005-06-01 11:17:05 +0000146struct bgp_info *
147bgp_info_lock (struct bgp_info *binfo)
148{
149 binfo->lock++;
150 return binfo;
151}
152
153struct bgp_info *
154bgp_info_unlock (struct bgp_info *binfo)
155{
156 assert (binfo && binfo->lock > 0);
157 binfo->lock--;
158
159 if (binfo->lock == 0)
160 {
161#if 0
162 zlog_debug ("%s: unlocked and freeing", __func__);
163 zlog_backtrace (LOG_DEBUG);
164#endif
165 bgp_info_free (binfo);
166 return NULL;
167 }
168
169#if 0
170 if (binfo->lock == 1)
171 {
172 zlog_debug ("%s: unlocked to 1", __func__);
173 zlog_backtrace (LOG_DEBUG);
174 }
175#endif
176
177 return binfo;
178}
179
paul718e3742002-12-13 20:15:29 +0000180void
181bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
182{
183 struct bgp_info *top;
184
185 top = rn->info;
paul200df112005-06-01 11:17:05 +0000186
paul718e3742002-12-13 20:15:29 +0000187 ri->next = rn->info;
188 ri->prev = NULL;
189 if (top)
190 top->prev = ri;
191 rn->info = ri;
paul200df112005-06-01 11:17:05 +0000192
193 bgp_info_lock (ri);
194 bgp_lock_node (rn);
195 peer_lock (ri->peer); /* bgp_info peer reference */
paul718e3742002-12-13 20:15:29 +0000196}
197
paulb40d9392005-08-22 22:34:41 +0000198/* Do the actual removal of info from RIB, for use by bgp_process
199 completion callback *only* */
200static void
201bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
paul718e3742002-12-13 20:15:29 +0000202{
203 if (ri->next)
204 ri->next->prev = ri->prev;
205 if (ri->prev)
206 ri->prev->next = ri->next;
207 else
208 rn->info = ri->next;
paul200df112005-06-01 11:17:05 +0000209
Josh Baileyde8d5df2011-07-20 20:46:01 -0700210 bgp_info_mpath_dequeue (ri);
paul200df112005-06-01 11:17:05 +0000211 bgp_info_unlock (ri);
212 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +0000213}
214
paulb40d9392005-08-22 22:34:41 +0000215void
216bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
217{
Paul Jakma1a392d42006-09-07 00:24:49 +0000218 bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
219 /* set of previous already took care of pcount */
paulb40d9392005-08-22 22:34:41 +0000220 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
221}
222
Andrew J. Schorr8d452102006-11-28 19:50:46 +0000223/* undo the effects of a previous call to bgp_info_delete; typically
224 called when a route is deleted and then quickly re-added before the
225 deletion has been processed */
226static void
227bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
228{
229 bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
230 /* unset of previous already took care of pcount */
231 SET_FLAG (ri->flags, BGP_INFO_VALID);
232}
233
Paul Jakma1a392d42006-09-07 00:24:49 +0000234/* Adjust pcount as required */
235static void
236bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
237{
Avneesh Sachdev67174042012-08-17 08:19:49 -0700238 struct bgp_table *table;
239
240 assert (rn && bgp_node_table (rn));
Paul Jakma6f585442006-10-22 19:13:07 +0000241 assert (ri && ri->peer && ri->peer->bgp);
242
Avneesh Sachdev67174042012-08-17 08:19:49 -0700243 table = bgp_node_table (rn);
244
Paul Jakma1a392d42006-09-07 00:24:49 +0000245 /* Ignore 'pcount' for RS-client tables */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700246 if (table->type != BGP_TABLE_MAIN
Paul Jakma1a392d42006-09-07 00:24:49 +0000247 || ri->peer == ri->peer->bgp->peer_self)
248 return;
249
Daniel Waltone25a9742015-11-09 20:21:50 -0500250 if (!BGP_INFO_COUNTABLE (ri)
Paul Jakma1a392d42006-09-07 00:24:49 +0000251 && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
252 {
253
254 UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
255
256 /* slight hack, but more robust against errors. */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700257 if (ri->peer->pcount[table->afi][table->safi])
258 ri->peer->pcount[table->afi][table->safi]--;
Paul Jakma1a392d42006-09-07 00:24:49 +0000259 else
260 {
261 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
262 __func__, ri->peer->host);
263 zlog_backtrace (LOG_WARNING);
264 zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
265 }
266 }
Daniel Waltone25a9742015-11-09 20:21:50 -0500267 else if (BGP_INFO_COUNTABLE (ri)
Paul Jakma1a392d42006-09-07 00:24:49 +0000268 && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
269 {
270 SET_FLAG (ri->flags, BGP_INFO_COUNTED);
Avneesh Sachdev67174042012-08-17 08:19:49 -0700271 ri->peer->pcount[table->afi][table->safi]++;
Paul Jakma1a392d42006-09-07 00:24:49 +0000272 }
273}
274
275
276/* Set/unset bgp_info flags, adjusting any other state as needed.
277 * This is here primarily to keep prefix-count in check.
278 */
279void
280bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
281{
282 SET_FLAG (ri->flags, flag);
283
Daniel Waltone25a9742015-11-09 20:21:50 -0500284 /* early bath if we know it's not a flag that changes countability state */
285 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED))
Paul Jakma1a392d42006-09-07 00:24:49 +0000286 return;
287
288 bgp_pcount_adjust (rn, ri);
289}
290
291void
292bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
293{
294 UNSET_FLAG (ri->flags, flag);
295
Daniel Waltone25a9742015-11-09 20:21:50 -0500296 /* early bath if we know it's not a flag that changes countability state */
297 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED))
Paul Jakma1a392d42006-09-07 00:24:49 +0000298 return;
299
300 bgp_pcount_adjust (rn, ri);
301}
302
paul718e3742002-12-13 20:15:29 +0000303/* Get MED value. If MED value is missing and "bgp bestpath
304 missing-as-worst" is specified, treat it as the worst value. */
paul94f2b392005-06-28 12:44:16 +0000305static u_int32_t
paul718e3742002-12-13 20:15:29 +0000306bgp_med_value (struct attr *attr, struct bgp *bgp)
307{
308 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
309 return attr->med;
310 else
311 {
312 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000313 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000314 else
315 return 0;
316 }
317}
318
Paul Jakma6d4742b2015-11-25 17:14:37 +0000319/* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
320 * is preferred, or 0 if they are the same (usually will only occur if
321 * multipath is enabled */
paul94f2b392005-06-28 12:44:16 +0000322static int
Josh Bailey96450fa2011-07-20 20:45:12 -0700323bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
Paul Jakma6d4742b2015-11-25 17:14:37 +0000324 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +0000325{
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000326 struct attr *newattr, *existattr;
327 struct attr_extra *newattre, *existattre;
328 bgp_peer_sort_t new_sort;
329 bgp_peer_sort_t exist_sort;
paul718e3742002-12-13 20:15:29 +0000330 u_int32_t new_pref;
331 u_int32_t exist_pref;
332 u_int32_t new_med;
333 u_int32_t exist_med;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000334 u_int32_t new_weight;
335 u_int32_t exist_weight;
336 uint32_t newm, existm;
paul718e3742002-12-13 20:15:29 +0000337 struct in_addr new_id;
338 struct in_addr exist_id;
339 int new_cluster;
340 int exist_cluster;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000341 int internal_as_route;
342 int confed_as_route;
paul718e3742002-12-13 20:15:29 +0000343 int ret;
Josh Bailey96450fa2011-07-20 20:45:12 -0700344
paul718e3742002-12-13 20:15:29 +0000345 /* 0. Null check. */
346 if (new == NULL)
paul718e3742002-12-13 20:15:29 +0000347 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000348 if (exist == NULL)
349 return -1;
paul718e3742002-12-13 20:15:29 +0000350
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000351 newattr = new->attr;
352 existattr = exist->attr;
353 newattre = newattr->extra;
354 existattre = existattr->extra;
355
paul718e3742002-12-13 20:15:29 +0000356 /* 1. Weight check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000357 new_weight = exist_weight = 0;
358
359 if (newattre)
360 new_weight = newattre->weight;
361 if (existattre)
362 exist_weight = existattre->weight;
363
Paul Jakmafb982c22007-05-04 20:15:47 +0000364 if (new_weight > exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000365 return -1;
Paul Jakmafb982c22007-05-04 20:15:47 +0000366 if (new_weight < exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000367 return 1;
paul718e3742002-12-13 20:15:29 +0000368
369 /* 2. Local preference check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000370 new_pref = exist_pref = bgp->default_local_pref;
paul718e3742002-12-13 20:15:29 +0000371
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000372 if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
373 new_pref = newattr->local_pref;
374 if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
375 exist_pref = existattr->local_pref;
376
paul718e3742002-12-13 20:15:29 +0000377 if (new_pref > exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000378 return -1;
paul718e3742002-12-13 20:15:29 +0000379 if (new_pref < exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000380 return 1;
paul718e3742002-12-13 20:15:29 +0000381
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000382 /* 3. Local route check. We prefer:
383 * - BGP_ROUTE_STATIC
384 * - BGP_ROUTE_AGGREGATE
385 * - BGP_ROUTE_REDISTRIBUTE
386 */
387 if (! (new->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000388 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000389 if (! (exist->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000390 return 1;
paul718e3742002-12-13 20:15:29 +0000391
392 /* 4. AS path length check. */
393 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
394 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000395 int exist_hops = aspath_count_hops (existattr->aspath);
396 int exist_confeds = aspath_count_confeds (existattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000397
hasso68118452005-04-08 15:40:36 +0000398 if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
399 {
paulfe69a502005-09-10 16:55:02 +0000400 int aspath_hops;
401
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000402 aspath_hops = aspath_count_hops (newattr->aspath);
403 aspath_hops += aspath_count_confeds (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000404
405 if ( aspath_hops < (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000406 return -1;
paulfe69a502005-09-10 16:55:02 +0000407 if ( aspath_hops > (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000408 return 1;
hasso68118452005-04-08 15:40:36 +0000409 }
410 else
411 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000412 int newhops = aspath_count_hops (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000413
414 if (newhops < exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000415 return -1;
paulfe69a502005-09-10 16:55:02 +0000416 if (newhops > exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000417 return 1;
hasso68118452005-04-08 15:40:36 +0000418 }
paul718e3742002-12-13 20:15:29 +0000419 }
420
421 /* 5. Origin check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000422 if (newattr->origin < existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000423 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000424 if (newattr->origin > existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000425 return 1;
paul718e3742002-12-13 20:15:29 +0000426
427 /* 6. MED check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000428 internal_as_route = (aspath_count_hops (newattr->aspath) == 0
429 && aspath_count_hops (existattr->aspath) == 0);
430 confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
431 && aspath_count_confeds (existattr->aspath) > 0
432 && aspath_count_hops (newattr->aspath) == 0
433 && aspath_count_hops (existattr->aspath) == 0);
paul718e3742002-12-13 20:15:29 +0000434
435 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
436 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
437 && confed_as_route)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000438 || aspath_cmp_left (newattr->aspath, existattr->aspath)
439 || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
paul718e3742002-12-13 20:15:29 +0000440 || internal_as_route)
441 {
442 new_med = bgp_med_value (new->attr, bgp);
443 exist_med = bgp_med_value (exist->attr, bgp);
444
445 if (new_med < exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000446 return -1;
paul718e3742002-12-13 20:15:29 +0000447 if (new_med > exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000448 return 1;
paul718e3742002-12-13 20:15:29 +0000449 }
450
451 /* 7. Peer type check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000452 new_sort = new->peer->sort;
453 exist_sort = exist->peer->sort;
454
455 if (new_sort == BGP_PEER_EBGP
456 && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000457 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000458 if (exist_sort == BGP_PEER_EBGP
459 && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000460 return 1;
paul718e3742002-12-13 20:15:29 +0000461
462 /* 8. IGP metric check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000463 newm = existm = 0;
464
465 if (new->extra)
466 newm = new->extra->igpmetric;
467 if (exist->extra)
468 existm = exist->extra->igpmetric;
469
Josh Bailey96450fa2011-07-20 20:45:12 -0700470 if (newm < existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000471 return -1;
Josh Bailey96450fa2011-07-20 20:45:12 -0700472 if (newm > existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000473 return 1;
paul718e3742002-12-13 20:15:29 +0000474
475 /* 9. Maximum path check. */
Paul Jakma6d4742b2015-11-25 17:14:37 +0000476 if (bgp_mpath_is_configured (bgp, afi, safi))
Josh Bailey96450fa2011-07-20 20:45:12 -0700477 {
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000478 if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
479 {
Paul Jakma6d4742b2015-11-25 17:14:37 +0000480 /*
481 * For the two paths, all comparison steps till IGP metric
482 * have succeeded - including AS_PATH hop count. Since 'bgp
483 * bestpath as-path multipath-relax' knob is on, we don't need
484 * an exact match of AS_PATH. Thus, mark the paths are equal.
485 * That will trigger both these paths to get into the multipath
486 * array.
487 */
488 return 0;
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000489 }
490 else if (new->peer->sort == BGP_PEER_IBGP)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000491 {
492 if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
493 return 0;
494 }
Josh Bailey96450fa2011-07-20 20:45:12 -0700495 else if (new->peer->as == exist->peer->as)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000496 return 0;
Josh Bailey96450fa2011-07-20 20:45:12 -0700497 }
paul718e3742002-12-13 20:15:29 +0000498
499 /* 10. If both paths are external, prefer the path that was received
500 first (the oldest one). This step minimizes route-flap, since a
501 newer path won't displace an older one, even if it was the
502 preferred route based on the additional decision criteria below. */
503 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000504 && new_sort == BGP_PEER_EBGP
505 && exist_sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +0000506 {
507 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000508 return -1;
paul718e3742002-12-13 20:15:29 +0000509 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000510 return 1;
paul718e3742002-12-13 20:15:29 +0000511 }
512
vivekbd4b7f12014-09-30 15:54:45 -0700513 /* 11. Router-ID comparision. */
514 /* If one of the paths is "stale", the corresponding peer router-id will
515 * be 0 and would always win over the other path. If originator id is
516 * used for the comparision, it will decide which path is better.
517 */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000518 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
519 new_id.s_addr = newattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000520 else
521 new_id.s_addr = new->peer->remote_id.s_addr;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000522 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
523 exist_id.s_addr = existattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000524 else
525 exist_id.s_addr = exist->peer->remote_id.s_addr;
526
527 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000528 return -1;
paul718e3742002-12-13 20:15:29 +0000529 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000530 return 1;
paul718e3742002-12-13 20:15:29 +0000531
532 /* 12. Cluster length comparision. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000533 new_cluster = exist_cluster = 0;
534
535 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
536 new_cluster = newattre->cluster->length;
537 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
538 exist_cluster = existattre->cluster->length;
paul718e3742002-12-13 20:15:29 +0000539
540 if (new_cluster < exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000541 return -1;
paul718e3742002-12-13 20:15:29 +0000542 if (new_cluster > exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000543 return 1;
paul718e3742002-12-13 20:15:29 +0000544
545 /* 13. Neighbor address comparision. */
vivekbd4b7f12014-09-30 15:54:45 -0700546 /* Do this only if neither path is "stale" as stale paths do not have
547 * valid peer information (as the connection may or may not be up).
548 */
549 if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000550 return -1;
vivekbd4b7f12014-09-30 15:54:45 -0700551 if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000552 return 1;
Timo Teräs2820a012015-06-24 15:27:21 +0300553 /* locally configured routes to advertise do not have su_remote */
554 if (new->peer->su_remote == NULL)
Timo Teräs2820a012015-06-24 15:27:21 +0300555 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000556 if (exist->peer->su_remote == NULL)
557 return -1;
Timo Teräs2820a012015-06-24 15:27:21 +0300558
paul718e3742002-12-13 20:15:29 +0000559 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
560
561 if (ret == 1)
paul718e3742002-12-13 20:15:29 +0000562 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000563 if (ret == -1)
564 return -1;
paul718e3742002-12-13 20:15:29 +0000565
Paul Jakma6d4742b2015-11-25 17:14:37 +0000566 return -1;
paul718e3742002-12-13 20:15:29 +0000567}
568
paul94f2b392005-06-28 12:44:16 +0000569static enum filter_type
paul718e3742002-12-13 20:15:29 +0000570bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
571 afi_t afi, safi_t safi)
572{
573 struct bgp_filter *filter;
574
575 filter = &peer->filter[afi][safi];
576
Paul Jakma650f76c2009-06-25 18:06:31 +0100577#define FILTER_EXIST_WARN(F,f,filter) \
578 if (BGP_DEBUG (update, UPDATE_IN) \
579 && !(F ## _IN (filter))) \
580 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
581 peer->host, #f, F ## _IN_NAME(filter));
582
583 if (DISTRIBUTE_IN_NAME (filter)) {
584 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
585
paul718e3742002-12-13 20:15:29 +0000586 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
587 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100588 }
paul718e3742002-12-13 20:15:29 +0000589
Paul Jakma650f76c2009-06-25 18:06:31 +0100590 if (PREFIX_LIST_IN_NAME (filter)) {
591 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
592
paul718e3742002-12-13 20:15:29 +0000593 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
594 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100595 }
paul718e3742002-12-13 20:15:29 +0000596
Paul Jakma650f76c2009-06-25 18:06:31 +0100597 if (FILTER_LIST_IN_NAME (filter)) {
598 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
599
paul718e3742002-12-13 20:15:29 +0000600 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
601 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100602 }
603
paul718e3742002-12-13 20:15:29 +0000604 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100605#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000606}
607
paul94f2b392005-06-28 12:44:16 +0000608static enum filter_type
paul718e3742002-12-13 20:15:29 +0000609bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
610 afi_t afi, safi_t safi)
611{
612 struct bgp_filter *filter;
613
614 filter = &peer->filter[afi][safi];
615
Paul Jakma650f76c2009-06-25 18:06:31 +0100616#define FILTER_EXIST_WARN(F,f,filter) \
617 if (BGP_DEBUG (update, UPDATE_OUT) \
618 && !(F ## _OUT (filter))) \
619 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
620 peer->host, #f, F ## _OUT_NAME(filter));
621
622 if (DISTRIBUTE_OUT_NAME (filter)) {
623 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
624
paul718e3742002-12-13 20:15:29 +0000625 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
626 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100627 }
paul718e3742002-12-13 20:15:29 +0000628
Paul Jakma650f76c2009-06-25 18:06:31 +0100629 if (PREFIX_LIST_OUT_NAME (filter)) {
630 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
631
paul718e3742002-12-13 20:15:29 +0000632 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
633 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100634 }
paul718e3742002-12-13 20:15:29 +0000635
Paul Jakma650f76c2009-06-25 18:06:31 +0100636 if (FILTER_LIST_OUT_NAME (filter)) {
637 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
638
paul718e3742002-12-13 20:15:29 +0000639 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
640 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100641 }
paul718e3742002-12-13 20:15:29 +0000642
643 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100644#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000645}
646
647/* If community attribute includes no_export then return 1. */
paul94f2b392005-06-28 12:44:16 +0000648static int
paul718e3742002-12-13 20:15:29 +0000649bgp_community_filter (struct peer *peer, struct attr *attr)
650{
651 if (attr->community)
652 {
653 /* NO_ADVERTISE check. */
654 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
655 return 1;
656
657 /* NO_EXPORT check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000658 if (peer->sort == BGP_PEER_EBGP &&
paul718e3742002-12-13 20:15:29 +0000659 community_include (attr->community, COMMUNITY_NO_EXPORT))
660 return 1;
661
662 /* NO_EXPORT_SUBCONFED check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000663 if (peer->sort == BGP_PEER_EBGP
664 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000665 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
666 return 1;
667 }
668 return 0;
669}
670
671/* Route reflection loop check. */
672static int
673bgp_cluster_filter (struct peer *peer, struct attr *attr)
674{
675 struct in_addr cluster_id;
676
Paul Jakmafb982c22007-05-04 20:15:47 +0000677 if (attr->extra && attr->extra->cluster)
paul718e3742002-12-13 20:15:29 +0000678 {
679 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
680 cluster_id = peer->bgp->cluster_id;
681 else
682 cluster_id = peer->bgp->router_id;
683
Paul Jakmafb982c22007-05-04 20:15:47 +0000684 if (cluster_loop_check (attr->extra->cluster, cluster_id))
paul718e3742002-12-13 20:15:29 +0000685 return 1;
686 }
687 return 0;
688}
David Lamparter6b0655a2014-06-04 06:53:35 +0200689
paul94f2b392005-06-28 12:44:16 +0000690static int
paul718e3742002-12-13 20:15:29 +0000691bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
692 afi_t afi, safi_t safi)
693{
694 struct bgp_filter *filter;
695 struct bgp_info info;
696 route_map_result_t ret;
697
698 filter = &peer->filter[afi][safi];
699
700 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000701 if (peer->weight)
702 (bgp_attr_extra_get (attr))->weight = peer->weight;
paul718e3742002-12-13 20:15:29 +0000703
704 /* Route map apply. */
705 if (ROUTE_MAP_IN_NAME (filter))
706 {
707 /* Duplicate current value to new strucutre for modification. */
708 info.peer = peer;
709 info.attr = attr;
710
paulac41b2a2003-08-12 05:32:27 +0000711 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
712
paul718e3742002-12-13 20:15:29 +0000713 /* Apply BGP route map to the attribute. */
714 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000715
716 peer->rmap_type = 0;
717
paul718e3742002-12-13 20:15:29 +0000718 if (ret == RMAP_DENYMATCH)
David Lamparterc460e572014-06-04 00:54:58 +0200719 /* caller has multiple error paths with bgp_attr_flush() */
720 return RMAP_DENY;
paul718e3742002-12-13 20:15:29 +0000721 }
722 return RMAP_PERMIT;
723}
David Lamparter6b0655a2014-06-04 06:53:35 +0200724
paul94f2b392005-06-28 12:44:16 +0000725static int
paulfee0f4c2004-09-13 05:12:46 +0000726bgp_export_modifier (struct peer *rsclient, struct peer *peer,
727 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
728{
729 struct bgp_filter *filter;
730 struct bgp_info info;
731 route_map_result_t ret;
732
733 filter = &peer->filter[afi][safi];
734
735 /* Route map apply. */
736 if (ROUTE_MAP_EXPORT_NAME (filter))
737 {
738 /* Duplicate current value to new strucutre for modification. */
739 info.peer = rsclient;
740 info.attr = attr;
741
742 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
743
744 /* Apply BGP route map to the attribute. */
745 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
746
747 rsclient->rmap_type = 0;
748
749 if (ret == RMAP_DENYMATCH)
750 {
751 /* Free newly generated AS path and community by route-map. */
752 bgp_attr_flush (attr);
753 return RMAP_DENY;
754 }
755 }
756 return RMAP_PERMIT;
757}
758
paul94f2b392005-06-28 12:44:16 +0000759static int
paulfee0f4c2004-09-13 05:12:46 +0000760bgp_import_modifier (struct peer *rsclient, struct peer *peer,
761 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
762{
763 struct bgp_filter *filter;
764 struct bgp_info info;
765 route_map_result_t ret;
766
767 filter = &rsclient->filter[afi][safi];
768
769 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000770 if (peer->weight)
771 (bgp_attr_extra_get (attr))->weight = peer->weight;
paulfee0f4c2004-09-13 05:12:46 +0000772
773 /* Route map apply. */
774 if (ROUTE_MAP_IMPORT_NAME (filter))
775 {
776 /* Duplicate current value to new strucutre for modification. */
777 info.peer = peer;
778 info.attr = attr;
779
780 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
781
782 /* Apply BGP route map to the attribute. */
783 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
784
785 peer->rmap_type = 0;
786
787 if (ret == RMAP_DENYMATCH)
788 {
789 /* Free newly generated AS path and community by route-map. */
790 bgp_attr_flush (attr);
791 return RMAP_DENY;
792 }
793 }
794 return RMAP_PERMIT;
795}
David Lamparter6b0655a2014-06-04 06:53:35 +0200796
paul94f2b392005-06-28 12:44:16 +0000797static int
paul718e3742002-12-13 20:15:29 +0000798bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
799 struct attr *attr, afi_t afi, safi_t safi)
800{
801 int ret;
802 char buf[SU_ADDRSTRLEN];
803 struct bgp_filter *filter;
paul718e3742002-12-13 20:15:29 +0000804 struct peer *from;
805 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +0000806 int transparent;
807 int reflect;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700808 struct attr *riattr;
paul718e3742002-12-13 20:15:29 +0000809
810 from = ri->peer;
811 filter = &peer->filter[afi][safi];
812 bgp = peer->bgp;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700813 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paul718e3742002-12-13 20:15:29 +0000814
Paul Jakma750e8142008-07-22 21:11:48 +0000815 if (DISABLE_BGP_ANNOUNCE)
816 return 0;
paul718e3742002-12-13 20:15:29 +0000817
paulfee0f4c2004-09-13 05:12:46 +0000818 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
819 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
820 return 0;
821
paul718e3742002-12-13 20:15:29 +0000822 /* Do not send back route to sender. */
823 if (from == peer)
824 return 0;
825
826 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000827 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +0000828 if (! UNSUPPRESS_MAP_NAME (filter))
829 return 0;
830
831 /* Default route check. */
832 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
833 {
834 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
835 return 0;
paul718e3742002-12-13 20:15:29 +0000836 else if (p->family == AF_INET6 && p->prefixlen == 0)
837 return 0;
paul718e3742002-12-13 20:15:29 +0000838 }
839
paul286e1e72003-08-08 00:24:31 +0000840 /* Transparency check. */
841 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
842 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
843 transparent = 1;
844 else
845 transparent = 0;
846
paul718e3742002-12-13 20:15:29 +0000847 /* If community is not disabled check the no-export and local. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700848 if (! transparent && bgp_community_filter (peer, riattr))
paul718e3742002-12-13 20:15:29 +0000849 return 0;
850
851 /* If the attribute has originator-id and it is same as remote
852 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700853 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paul718e3742002-12-13 20:15:29 +0000854 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700855 if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +0000856 {
857 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000858 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000859 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
860 peer->host,
861 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
862 p->prefixlen);
863 return 0;
864 }
865 }
866
867 /* ORF prefix-list filter check */
868 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
869 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
870 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
871 if (peer->orf_plist[afi][safi])
872 {
873 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
874 return 0;
875 }
876
877 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700878 if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
paul718e3742002-12-13 20:15:29 +0000879 {
880 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000881 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000882 "%s [Update:SEND] %s/%d is filtered",
883 peer->host,
884 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
885 p->prefixlen);
886 return 0;
887 }
888
889#ifdef BGP_SEND_ASPATH_CHECK
890 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700891 if (aspath_loop_check (riattr->aspath, peer->as))
paul718e3742002-12-13 20:15:29 +0000892 {
893 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000894 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400895 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000896 peer->host, peer->as);
897 return 0;
898 }
899#endif /* BGP_SEND_ASPATH_CHECK */
900
901 /* If we're a CONFED we need to loop check the CONFED ID too */
902 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
903 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700904 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
paul718e3742002-12-13 20:15:29 +0000905 {
906 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000907 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400908 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000909 peer->host,
910 bgp->confed_id);
911 return 0;
912 }
913 }
914
915 /* Route-Reflect check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000916 if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +0000917 reflect = 1;
918 else
919 reflect = 0;
920
921 /* IBGP reflection check. */
922 if (reflect)
923 {
924 /* A route from a Client peer. */
925 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
926 {
927 /* Reflect to all the Non-Client peers and also to the
928 Client peers other than the originator. Originator check
929 is already done. So there is noting to do. */
930 /* no bgp client-to-client reflection check. */
931 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
932 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
933 return 0;
934 }
935 else
936 {
937 /* A route from a Non-client peer. Reflect to all other
938 clients. */
939 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
940 return 0;
941 }
942 }
Paul Jakma41367172007-08-06 15:24:51 +0000943
paul718e3742002-12-13 20:15:29 +0000944 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700945 bgp_attr_dup (attr, riattr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000946
paul718e3742002-12-13 20:15:29 +0000947 /* If local-preference is not set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000948 if ((peer->sort == BGP_PEER_IBGP
949 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000950 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
951 {
952 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
953 attr->local_pref = bgp->default_local_pref;
954 }
955
Pradosh Mohapatra689bb662013-09-07 07:13:37 +0000956 /* If originator-id is not set and the route is to be reflected,
957 set the originator id */
958 if (peer && from && peer->sort == BGP_PEER_IBGP &&
959 from->sort == BGP_PEER_IBGP &&
960 (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
961 {
962 attr->extra = bgp_attr_extra_get(attr);
963 IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
964 SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
965 }
966
paul718e3742002-12-13 20:15:29 +0000967 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000968 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +0000969 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
970 {
971 if (ri->peer != bgp->peer_self && ! transparent
972 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
973 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
974 }
975
Lou Berger298cc2f2016-01-12 13:42:02 -0500976
977#define NEXTHOP_IS_V4 (\
978 (safi != SAFI_ENCAP && p->family == AF_INET) || \
979 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
980
Lou Berger298cc2f2016-01-12 13:42:02 -0500981#define NEXTHOP_IS_V6 (\
982 (safi != SAFI_ENCAP && p->family == AF_INET6) || \
983 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
Lou Berger298cc2f2016-01-12 13:42:02 -0500984
paul718e3742002-12-13 20:15:29 +0000985 /* next-hop-set */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300986 if (transparent
987 || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
paul718e3742002-12-13 20:15:29 +0000988 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
Lou Berger298cc2f2016-01-12 13:42:02 -0500989 && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
Lou Berger298cc2f2016-01-12 13:42:02 -0500990 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +0000991 ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paul286e1e72003-08-08 00:24:31 +0000992 )))
paul718e3742002-12-13 20:15:29 +0000993 {
994 /* NEXT-HOP Unchanged. */
995 }
996 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
Lou Berger298cc2f2016-01-12 13:42:02 -0500997 || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
Lou Berger298cc2f2016-01-12 13:42:02 -0500998 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +0000999 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001000 || (peer->sort == BGP_PEER_EBGP
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07001001 && (bgp_multiaccess_check_v4 (attr->nexthop, peer) == 0)))
paul718e3742002-12-13 20:15:29 +00001002 {
1003 /* Set IPv4 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001004 if (NEXTHOP_IS_V4)
paul718e3742002-12-13 20:15:29 +00001005 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001006 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001007 memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
1008 IPV4_MAX_BYTELEN);
paul718e3742002-12-13 20:15:29 +00001009 else
1010 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1011 }
paul718e3742002-12-13 20:15:29 +00001012 /* Set IPv6 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001013 if (NEXTHOP_IS_V6)
paul718e3742002-12-13 20:15:29 +00001014 {
1015 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001016 memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00001017 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001018 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001019 }
paul718e3742002-12-13 20:15:29 +00001020 }
1021
Lou Berger298cc2f2016-01-12 13:42:02 -05001022 if (p->family == AF_INET6 && safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00001023 {
paulfee0f4c2004-09-13 05:12:46 +00001024 /* Left nexthop_local unchanged if so configured. */
1025 if ( CHECK_FLAG (peer->af_flags[afi][safi],
1026 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1027 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001028 if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
1029 attr->extra->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001030 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001031 attr->extra->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001032 }
1033
1034 /* Default nexthop_local treatment for non-RS-Clients */
1035 else
1036 {
paul718e3742002-12-13 20:15:29 +00001037 /* Link-local address should not be transit to different peer. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001038 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001039
1040 /* Set link-local address for shared network peer. */
1041 if (peer->shared_network
1042 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1043 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001044 memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00001045 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001046 attr->extra->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00001047 }
1048
1049 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1050 address.*/
1051 if (reflect)
Paul Jakmafb982c22007-05-04 20:15:47 +00001052 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001053
1054 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1055 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
Paul Jakmafb982c22007-05-04 20:15:47 +00001056 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001057 }
paulfee0f4c2004-09-13 05:12:46 +00001058
1059 }
paul718e3742002-12-13 20:15:29 +00001060
1061 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001062 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001063 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1064 && aspath_private_as_check (attr->aspath))
1065 attr->aspath = aspath_empty_get ();
1066
1067 /* Route map & unsuppress-map apply. */
1068 if (ROUTE_MAP_OUT_NAME (filter)
Paul Jakmafb982c22007-05-04 20:15:47 +00001069 || (ri->extra && ri->extra->suppress) )
paul718e3742002-12-13 20:15:29 +00001070 {
Paul Jakma7c7fa1b2006-02-18 10:52:09 +00001071 struct bgp_info info;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001072 struct attr dummy_attr;
1073 struct attr_extra dummy_extra;
1074
1075 dummy_attr.extra = &dummy_extra;
1076
paul718e3742002-12-13 20:15:29 +00001077 info.peer = peer;
1078 info.attr = attr;
1079
1080 /* The route reflector is not allowed to modify the attributes
Dinesh Dutt083e5e22015-11-09 20:21:54 -05001081 of the reflected IBGP routes, unless configured to allow it */
1082 if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) &&
1083 !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
paul718e3742002-12-13 20:15:29 +00001084 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001085 bgp_attr_dup (&dummy_attr, attr);
Paul Jakma9eda90c2007-08-30 13:36:17 +00001086 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00001087 }
paulac41b2a2003-08-12 05:32:27 +00001088
1089 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
1090
Paul Jakmafb982c22007-05-04 20:15:47 +00001091 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00001092 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1093 else
1094 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1095
paulac41b2a2003-08-12 05:32:27 +00001096 peer->rmap_type = 0;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001097
paul718e3742002-12-13 20:15:29 +00001098 if (ret == RMAP_DENYMATCH)
1099 {
1100 bgp_attr_flush (attr);
1101 return 0;
1102 }
1103 }
1104 return 1;
1105}
1106
paul94f2b392005-06-28 12:44:16 +00001107static int
paulfee0f4c2004-09-13 05:12:46 +00001108bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
1109 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001110{
paulfee0f4c2004-09-13 05:12:46 +00001111 int ret;
1112 char buf[SU_ADDRSTRLEN];
1113 struct bgp_filter *filter;
1114 struct bgp_info info;
1115 struct peer *from;
Josh Bailey0b597ef2011-07-20 20:49:11 -07001116 struct attr *riattr;
paulfee0f4c2004-09-13 05:12:46 +00001117
1118 from = ri->peer;
1119 filter = &rsclient->filter[afi][safi];
Josh Bailey0b597ef2011-07-20 20:49:11 -07001120 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paulfee0f4c2004-09-13 05:12:46 +00001121
Paul Jakma750e8142008-07-22 21:11:48 +00001122 if (DISABLE_BGP_ANNOUNCE)
1123 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001124
1125 /* Do not send back route to sender. */
1126 if (from == rsclient)
1127 return 0;
1128
1129 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001130 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001131 if (! UNSUPPRESS_MAP_NAME (filter))
1132 return 0;
1133
1134 /* Default route check. */
1135 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
1136 PEER_STATUS_DEFAULT_ORIGINATE))
1137 {
1138 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
1139 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001140 else if (p->family == AF_INET6 && p->prefixlen == 0)
1141 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001142 }
1143
1144 /* If the attribute has originator-id and it is same as remote
1145 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001146 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paulfee0f4c2004-09-13 05:12:46 +00001147 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001148 if (IPV4_ADDR_SAME (&rsclient->remote_id,
Josh Bailey0b597ef2011-07-20 20:49:11 -07001149 &riattr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001150 {
1151 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001152 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001153 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1154 rsclient->host,
1155 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1156 p->prefixlen);
1157 return 0;
1158 }
1159 }
1160
1161 /* ORF prefix-list filter check */
1162 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
1163 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
1164 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
1165 if (rsclient->orf_plist[afi][safi])
1166 {
1167 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
1168 return 0;
1169 }
1170
1171 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001172 if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
paulfee0f4c2004-09-13 05:12:46 +00001173 {
1174 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001175 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001176 "%s [Update:SEND] %s/%d is filtered",
1177 rsclient->host,
1178 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1179 p->prefixlen);
1180 return 0;
1181 }
1182
1183#ifdef BGP_SEND_ASPATH_CHECK
1184 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001185 if (aspath_loop_check (riattr->aspath, rsclient->as))
paulfee0f4c2004-09-13 05:12:46 +00001186 {
1187 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001188 zlog (rsclient->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001189 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paulfee0f4c2004-09-13 05:12:46 +00001190 rsclient->host, rsclient->as);
1191 return 0;
1192 }
1193#endif /* BGP_SEND_ASPATH_CHECK */
1194
1195 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001196 bgp_attr_dup (attr, riattr);
paulfee0f4c2004-09-13 05:12:46 +00001197
1198 /* next-hop-set */
1199 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
paulfee0f4c2004-09-13 05:12:46 +00001200 || (p->family == AF_INET6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001201 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paulfee0f4c2004-09-13 05:12:46 +00001202 )
1203 {
1204 /* Set IPv4 nexthop. */
1205 if (p->family == AF_INET)
1206 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001207 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001208 memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
paulfee0f4c2004-09-13 05:12:46 +00001209 IPV4_MAX_BYTELEN);
1210 else
1211 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
1212 }
paulfee0f4c2004-09-13 05:12:46 +00001213 /* Set IPv6 nexthop. */
1214 if (p->family == AF_INET6)
1215 {
1216 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001217 memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
paulfee0f4c2004-09-13 05:12:46 +00001218 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001219 attr->extra->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001220 }
paulfee0f4c2004-09-13 05:12:46 +00001221 }
1222
paulfee0f4c2004-09-13 05:12:46 +00001223 if (p->family == AF_INET6)
1224 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001225 struct attr_extra *attre = attr->extra;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001226
paulfee0f4c2004-09-13 05:12:46 +00001227 /* Left nexthop_local unchanged if so configured. */
1228 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
1229 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1230 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001231 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1232 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001233 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001234 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001235 }
1236
1237 /* Default nexthop_local treatment for RS-Clients */
1238 else
1239 {
1240 /* Announcer and RS-Client are both in the same network */
1241 if (rsclient->shared_network && from->shared_network &&
1242 (rsclient->ifindex == from->ifindex))
1243 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001244 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1245 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001246 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001247 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001248 }
1249
1250 /* Set link-local address for shared network peer. */
1251 else if (rsclient->shared_network
1252 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
1253 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001254 memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
paulfee0f4c2004-09-13 05:12:46 +00001255 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001256 attre->mp_nexthop_len = 32;
paulfee0f4c2004-09-13 05:12:46 +00001257 }
1258
1259 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001260 attre->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001261 }
1262
1263 }
paulfee0f4c2004-09-13 05:12:46 +00001264
1265 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001266 if (rsclient->sort == BGP_PEER_EBGP
paulfee0f4c2004-09-13 05:12:46 +00001267 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1268 && aspath_private_as_check (attr->aspath))
1269 attr->aspath = aspath_empty_get ();
1270
1271 /* Route map & unsuppress-map apply. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001272 if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
paulfee0f4c2004-09-13 05:12:46 +00001273 {
1274 info.peer = rsclient;
1275 info.attr = attr;
1276
1277 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1278
Paul Jakmafb982c22007-05-04 20:15:47 +00001279 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001280 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1281 else
1282 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1283
1284 rsclient->rmap_type = 0;
1285
1286 if (ret == RMAP_DENYMATCH)
1287 {
1288 bgp_attr_flush (attr);
1289 return 0;
1290 }
1291 }
1292
1293 return 1;
1294}
1295
1296struct bgp_info_pair
1297{
1298 struct bgp_info *old;
1299 struct bgp_info *new;
1300};
1301
paul94f2b392005-06-28 12:44:16 +00001302static void
Josh Bailey96450fa2011-07-20 20:45:12 -07001303bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
Paul Jakma6d4742b2015-11-25 17:14:37 +00001304 struct bgp_info_pair *result,
1305 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00001306{
paul718e3742002-12-13 20:15:29 +00001307 struct bgp_info *new_select;
1308 struct bgp_info *old_select;
paulfee0f4c2004-09-13 05:12:46 +00001309 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00001310 struct bgp_info *ri1;
1311 struct bgp_info *ri2;
paulb40d9392005-08-22 22:34:41 +00001312 struct bgp_info *nextri = NULL;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001313 int cmpret, do_mpath;
Josh Bailey96450fa2011-07-20 20:45:12 -07001314 struct list mp_list;
Paul Jakma91b9e852015-12-01 14:32:11 +00001315
1316 result->old = result->new = NULL;
1317
1318 if (rn->info == NULL)
1319 {
1320 char buf[PREFIX_STRLEN];
1321 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1322 __func__,
1323 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1324 return;
1325 }
1326
Josh Bailey96450fa2011-07-20 20:45:12 -07001327 bgp_mp_list_init (&mp_list);
Paul Jakma6d4742b2015-11-25 17:14:37 +00001328 do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001329
paul718e3742002-12-13 20:15:29 +00001330 /* bgp deterministic-med */
1331 new_select = NULL;
1332 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1333 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1334 {
1335 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1336 continue;
1337 if (BGP_INFO_HOLDDOWN (ri1))
1338 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001339 if (ri1->peer && ri1->peer != bgp->peer_self)
1340 if (ri1->peer->status != Established)
1341 continue;
paul718e3742002-12-13 20:15:29 +00001342
1343 new_select = ri1;
Josh Bailey6918e742011-07-20 20:48:20 -07001344 if (do_mpath)
1345 bgp_mp_list_add (&mp_list, ri1);
1346 old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
paul718e3742002-12-13 20:15:29 +00001347 if (ri1->next)
1348 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1349 {
1350 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1351 continue;
1352 if (BGP_INFO_HOLDDOWN (ri2))
1353 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001354 if (ri2->peer &&
1355 ri2->peer != bgp->peer_self &&
1356 !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
1357 if (ri2->peer->status != Established)
1358 continue;
paul718e3742002-12-13 20:15:29 +00001359
1360 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1361 || aspath_cmp_left_confed (ri1->attr->aspath,
1362 ri2->attr->aspath))
1363 {
Josh Bailey6918e742011-07-20 20:48:20 -07001364 if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
1365 old_select = ri2;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001366 if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
1367 == -1)
paul718e3742002-12-13 20:15:29 +00001368 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001369 bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001370 new_select = ri2;
1371 }
1372
Paul Jakma6d4742b2015-11-25 17:14:37 +00001373 if (do_mpath)
1374 {
1375 if (cmpret != 0)
1376 bgp_mp_list_clear (&mp_list);
1377
1378 if (cmpret == 0 || cmpret == -1)
1379 bgp_mp_list_add (&mp_list, ri2);
1380 }
Josh Bailey6918e742011-07-20 20:48:20 -07001381
Paul Jakma1a392d42006-09-07 00:24:49 +00001382 bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001383 }
1384 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001385 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
1386 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
Josh Bailey6918e742011-07-20 20:48:20 -07001387
Paul Jakma6d4742b2015-11-25 17:14:37 +00001388 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey6918e742011-07-20 20:48:20 -07001389 bgp_mp_list_clear (&mp_list);
paul718e3742002-12-13 20:15:29 +00001390 }
1391
1392 /* Check old selected route and new selected route. */
1393 old_select = NULL;
1394 new_select = NULL;
paulb40d9392005-08-22 22:34:41 +00001395 for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
paul718e3742002-12-13 20:15:29 +00001396 {
1397 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1398 old_select = ri;
1399
1400 if (BGP_INFO_HOLDDOWN (ri))
paulb40d9392005-08-22 22:34:41 +00001401 {
1402 /* reap REMOVED routes, if needs be
1403 * selected route must stay for a while longer though
1404 */
1405 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
1406 && (ri != old_select))
1407 bgp_info_reap (rn, ri);
1408
1409 continue;
1410 }
paul718e3742002-12-13 20:15:29 +00001411
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001412 if (ri->peer &&
1413 ri->peer != bgp->peer_self &&
1414 !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
1415 if (ri->peer->status != Established)
1416 continue;
1417
paul718e3742002-12-13 20:15:29 +00001418 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1419 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1420 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001421 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001422 continue;
1423 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001424 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1425 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001426
Paul Jakma6d4742b2015-11-25 17:14:37 +00001427 if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
Josh Bailey96450fa2011-07-20 20:45:12 -07001428 {
Josh Bailey6918e742011-07-20 20:48:20 -07001429 if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1430 bgp_mp_dmed_deselect (new_select);
1431
Josh Bailey96450fa2011-07-20 20:45:12 -07001432 new_select = ri;
Josh Bailey96450fa2011-07-20 20:45:12 -07001433 }
Paul Jakma6d4742b2015-11-25 17:14:37 +00001434 else if (cmpret == 1 && do_mpath
1435 && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Josh Bailey6918e742011-07-20 20:48:20 -07001436 bgp_mp_dmed_deselect (ri);
Josh Bailey96450fa2011-07-20 20:45:12 -07001437
Paul Jakma6d4742b2015-11-25 17:14:37 +00001438 if (do_mpath)
1439 {
1440 if (cmpret != 0)
1441 bgp_mp_list_clear (&mp_list);
1442
1443 if (cmpret == 0 || cmpret == -1)
1444 bgp_mp_list_add (&mp_list, ri);
1445 }
paul718e3742002-12-13 20:15:29 +00001446 }
paulfee0f4c2004-09-13 05:12:46 +00001447
Josh Bailey6918e742011-07-20 20:48:20 -07001448 if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Paul Jakma6d4742b2015-11-25 17:14:37 +00001449 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001450
Josh Bailey0b597ef2011-07-20 20:49:11 -07001451 bgp_info_mpath_aggregate_update (new_select, old_select);
Josh Bailey96450fa2011-07-20 20:45:12 -07001452 bgp_mp_list_clear (&mp_list);
1453
1454 result->old = old_select;
1455 result->new = new_select;
1456
1457 return;
paulfee0f4c2004-09-13 05:12:46 +00001458}
1459
paul94f2b392005-06-28 12:44:16 +00001460static int
paulfee0f4c2004-09-13 05:12:46 +00001461bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
Paul Jakma9eda90c2007-08-30 13:36:17 +00001462 struct bgp_node *rn, afi_t afi, safi_t safi)
1463{
paulfee0f4c2004-09-13 05:12:46 +00001464 struct prefix *p;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001465 struct attr attr;
1466 struct attr_extra extra;
paulfee0f4c2004-09-13 05:12:46 +00001467
Lou Berger050defe2016-01-12 13:41:59 -05001468 memset (&attr, 0, sizeof(struct attr));
1469 memset (&extra, 0, sizeof(struct attr_extra));
1470
paulfee0f4c2004-09-13 05:12:46 +00001471 p = &rn->p;
1472
Paul Jakma9eda90c2007-08-30 13:36:17 +00001473 /* Announce route to Established peer. */
1474 if (peer->status != Established)
paulfee0f4c2004-09-13 05:12:46 +00001475 return 0;
1476
Paul Jakma9eda90c2007-08-30 13:36:17 +00001477 /* Address family configuration check. */
1478 if (! peer->afc_nego[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001479 return 0;
1480
Paul Jakma9eda90c2007-08-30 13:36:17 +00001481 /* First update is deferred until ORF or ROUTE-REFRESH is received */
paulfee0f4c2004-09-13 05:12:46 +00001482 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1483 PEER_STATUS_ORF_WAIT_REFRESH))
1484 return 0;
1485
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001486 /* It's initialized in bgp_announce_[check|check_rsclient]() */
1487 attr.extra = &extra;
1488
Avneesh Sachdev67174042012-08-17 08:19:49 -07001489 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001490 {
1491 case BGP_TABLE_MAIN:
1492 /* Announcement to peer->conf. If the route is filtered,
1493 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001494 if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
1495 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
paulfee0f4c2004-09-13 05:12:46 +00001496 else
1497 bgp_adj_out_unset (rn, peer, p, afi, safi);
1498 break;
1499 case BGP_TABLE_RSCLIENT:
1500 /* Announcement to peer->conf. If the route is filtered,
1501 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001502 if (selected &&
1503 bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
1504 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1505 else
1506 bgp_adj_out_unset (rn, peer, p, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001507 break;
1508 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001509
Lou Berger050defe2016-01-12 13:41:59 -05001510 bgp_attr_flush (&attr);
paulfee0f4c2004-09-13 05:12:46 +00001511 return 0;
paul200df112005-06-01 11:17:05 +00001512}
paulfee0f4c2004-09-13 05:12:46 +00001513
paul200df112005-06-01 11:17:05 +00001514struct bgp_process_queue
paulfee0f4c2004-09-13 05:12:46 +00001515{
paul200df112005-06-01 11:17:05 +00001516 struct bgp *bgp;
1517 struct bgp_node *rn;
1518 afi_t afi;
1519 safi_t safi;
1520};
1521
1522static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001523bgp_process_rsclient (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001524{
paul0fb58d52005-11-14 14:31:49 +00001525 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001526 struct bgp *bgp = pq->bgp;
1527 struct bgp_node *rn = pq->rn;
1528 afi_t afi = pq->afi;
1529 safi_t safi = pq->safi;
paulfee0f4c2004-09-13 05:12:46 +00001530 struct bgp_info *new_select;
1531 struct bgp_info *old_select;
1532 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001533 struct listnode *node, *nnode;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001534 struct peer *rsclient = bgp_node_table (rn)->owner;
paul200df112005-06-01 11:17:05 +00001535
paulfee0f4c2004-09-13 05:12:46 +00001536 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001537 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001538 new_select = old_and_new.new;
1539 old_select = old_and_new.old;
1540
paul200df112005-06-01 11:17:05 +00001541 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
1542 {
Chris Caputo228da422009-07-18 05:44:03 +00001543 if (rsclient->group)
1544 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
1545 {
1546 /* Nothing to do. */
1547 if (old_select && old_select == new_select)
1548 if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1549 continue;
paulfee0f4c2004-09-13 05:12:46 +00001550
Chris Caputo228da422009-07-18 05:44:03 +00001551 if (old_select)
1552 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1553 if (new_select)
1554 {
1555 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1556 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001557 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1558 }
paulfee0f4c2004-09-13 05:12:46 +00001559
Chris Caputo228da422009-07-18 05:44:03 +00001560 bgp_process_announce_selected (rsclient, new_select, rn,
1561 afi, safi);
1562 }
paul200df112005-06-01 11:17:05 +00001563 }
1564 else
1565 {
hassob7395792005-08-26 12:58:38 +00001566 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001567 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hassob7395792005-08-26 12:58:38 +00001568 if (new_select)
1569 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001570 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1571 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001572 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hassob7395792005-08-26 12:58:38 +00001573 }
Paul Jakma9eda90c2007-08-30 13:36:17 +00001574 bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
paul200df112005-06-01 11:17:05 +00001575 }
paulfee0f4c2004-09-13 05:12:46 +00001576
paulb40d9392005-08-22 22:34:41 +00001577 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1578 bgp_info_reap (rn, old_select);
1579
paul200df112005-06-01 11:17:05 +00001580 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1581 return WQ_SUCCESS;
paulfee0f4c2004-09-13 05:12:46 +00001582}
1583
paul200df112005-06-01 11:17:05 +00001584static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001585bgp_process_main (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001586{
paul0fb58d52005-11-14 14:31:49 +00001587 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001588 struct bgp *bgp = pq->bgp;
1589 struct bgp_node *rn = pq->rn;
1590 afi_t afi = pq->afi;
1591 safi_t safi = pq->safi;
1592 struct prefix *p = &rn->p;
paulfee0f4c2004-09-13 05:12:46 +00001593 struct bgp_info *new_select;
1594 struct bgp_info *old_select;
1595 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001596 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00001597 struct peer *peer;
Paul Jakmafb982c22007-05-04 20:15:47 +00001598
paulfee0f4c2004-09-13 05:12:46 +00001599 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001600 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001601 old_select = old_and_new.old;
1602 new_select = old_and_new.new;
1603
1604 /* Nothing to do. */
Daniel Walton325fcfb2015-05-19 17:58:10 -07001605 if (old_select && old_select == new_select
1606 && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR))
paulfee0f4c2004-09-13 05:12:46 +00001607 {
1608 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
paul200df112005-06-01 11:17:05 +00001609 {
Josh Bailey8196f132011-07-20 20:47:07 -07001610 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
1611 CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
G.Balaji5a616c02011-11-26 21:58:42 +04001612 bgp_zebra_announce (p, old_select, bgp, safi);
paul200df112005-06-01 11:17:05 +00001613
Josh Bailey8196f132011-07-20 20:47:07 -07001614 UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
paul200df112005-06-01 11:17:05 +00001615 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1616 return WQ_SUCCESS;
1617 }
paulfee0f4c2004-09-13 05:12:46 +00001618 }
paul718e3742002-12-13 20:15:29 +00001619
Daniel Walton325fcfb2015-05-19 17:58:10 -07001620 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1621 UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
1622
hasso338b3422005-02-23 14:27:24 +00001623 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001624 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hasso338b3422005-02-23 14:27:24 +00001625 if (new_select)
1626 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001627 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1628 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001629 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hasso338b3422005-02-23 14:27:24 +00001630 }
1631
1632
paul718e3742002-12-13 20:15:29 +00001633 /* Check each BGP peer. */
paul1eb8ef22005-04-07 07:30:20 +00001634 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00001635 {
Paul Jakma9eda90c2007-08-30 13:36:17 +00001636 bgp_process_announce_selected (peer, new_select, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001637 }
1638
1639 /* FIB update. */
G.Balaji5a616c02011-11-26 21:58:42 +04001640 if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
1641 ! bgp_option_check (BGP_OPT_NO_FIB)))
paul718e3742002-12-13 20:15:29 +00001642 {
1643 if (new_select
1644 && new_select->type == ZEBRA_ROUTE_BGP
1645 && new_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001646 bgp_zebra_announce (p, new_select, bgp, safi);
paul718e3742002-12-13 20:15:29 +00001647 else
1648 {
1649 /* Withdraw the route from the kernel. */
1650 if (old_select
1651 && old_select->type == ZEBRA_ROUTE_BGP
1652 && old_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001653 bgp_zebra_withdraw (p, old_select, safi);
paul718e3742002-12-13 20:15:29 +00001654 }
1655 }
paulb40d9392005-08-22 22:34:41 +00001656
Lou Berger050defe2016-01-12 13:41:59 -05001657 /* Reap old select bgp_info, if it has been removed */
paulb40d9392005-08-22 22:34:41 +00001658 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1659 bgp_info_reap (rn, old_select);
1660
paul200df112005-06-01 11:17:05 +00001661 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1662 return WQ_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001663}
1664
paul200df112005-06-01 11:17:05 +00001665static void
paul0fb58d52005-11-14 14:31:49 +00001666bgp_processq_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001667{
paul0fb58d52005-11-14 14:31:49 +00001668 struct bgp_process_queue *pq = data;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001669 struct bgp_table *table = bgp_node_table (pq->rn);
paul0fb58d52005-11-14 14:31:49 +00001670
Chris Caputo228da422009-07-18 05:44:03 +00001671 bgp_unlock (pq->bgp);
paul200df112005-06-01 11:17:05 +00001672 bgp_unlock_node (pq->rn);
Chris Caputo228da422009-07-18 05:44:03 +00001673 bgp_table_unlock (table);
paul200df112005-06-01 11:17:05 +00001674 XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
1675}
1676
1677static void
1678bgp_process_queue_init (void)
1679{
1680 bm->process_main_queue
1681 = work_queue_new (bm->master, "process_main_queue");
1682 bm->process_rsclient_queue
1683 = work_queue_new (bm->master, "process_rsclient_queue");
1684
1685 if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
1686 {
1687 zlog_err ("%s: Failed to allocate work queue", __func__);
1688 exit (1);
1689 }
1690
1691 bm->process_main_queue->spec.workfunc = &bgp_process_main;
paul200df112005-06-01 11:17:05 +00001692 bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
Paul Jakma838bbde2010-01-08 14:05:32 +00001693 bm->process_main_queue->spec.max_retries = 0;
1694 bm->process_main_queue->spec.hold = 50;
1695
Paul Jakma838bbde2010-01-08 14:05:32 +00001696 bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
David Lamparterd43f8b32015-03-03 08:54:54 +01001697 bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
1698 bm->process_rsclient_queue->spec.max_retries = 0;
1699 bm->process_rsclient_queue->spec.hold = 50;
paul200df112005-06-01 11:17:05 +00001700}
1701
1702void
paulfee0f4c2004-09-13 05:12:46 +00001703bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1704{
paul200df112005-06-01 11:17:05 +00001705 struct bgp_process_queue *pqnode;
1706
1707 /* already scheduled for processing? */
1708 if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
1709 return;
1710
Paul Jakma91b9e852015-12-01 14:32:11 +00001711 if (rn->info == NULL)
1712 {
1713 /* XXX: Perhaps remove before next release, after we've flushed out
1714 * any obvious cases
1715 */
1716 assert (rn->info != NULL);
1717 char buf[PREFIX_STRLEN];
1718 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1719 __func__,
1720 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1721 return;
1722 }
1723
paul200df112005-06-01 11:17:05 +00001724 if ( (bm->process_main_queue == NULL) ||
1725 (bm->process_rsclient_queue == NULL) )
1726 bgp_process_queue_init ();
1727
1728 pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
1729 sizeof (struct bgp_process_queue));
1730 if (!pqnode)
1731 return;
Chris Caputo228da422009-07-18 05:44:03 +00001732
1733 /* all unlocked in bgp_processq_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07001734 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00001735 pqnode->rn = bgp_lock_node (rn);
paul200df112005-06-01 11:17:05 +00001736 pqnode->bgp = bgp;
Chris Caputo228da422009-07-18 05:44:03 +00001737 bgp_lock (bgp);
paul200df112005-06-01 11:17:05 +00001738 pqnode->afi = afi;
1739 pqnode->safi = safi;
1740
Avneesh Sachdev67174042012-08-17 08:19:49 -07001741 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001742 {
paul200df112005-06-01 11:17:05 +00001743 case BGP_TABLE_MAIN:
1744 work_queue_add (bm->process_main_queue, pqnode);
1745 break;
1746 case BGP_TABLE_RSCLIENT:
1747 work_queue_add (bm->process_rsclient_queue, pqnode);
1748 break;
paulfee0f4c2004-09-13 05:12:46 +00001749 }
paul200df112005-06-01 11:17:05 +00001750
Stephen Hemminger07ff4dc2013-01-04 22:29:20 +00001751 SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
paul200df112005-06-01 11:17:05 +00001752 return;
paulfee0f4c2004-09-13 05:12:46 +00001753}
hasso0a486e52005-02-01 20:57:17 +00001754
paul94f2b392005-06-28 12:44:16 +00001755static int
hasso0a486e52005-02-01 20:57:17 +00001756bgp_maximum_prefix_restart_timer (struct thread *thread)
1757{
1758 struct peer *peer;
1759
1760 peer = THREAD_ARG (thread);
1761 peer->t_pmax_restart = NULL;
1762
1763 if (BGP_DEBUG (events, EVENTS))
1764 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1765 peer->host);
1766
1767 peer_clear (peer);
1768
1769 return 0;
1770}
1771
paulfee0f4c2004-09-13 05:12:46 +00001772int
paul5228ad22004-06-04 17:58:18 +00001773bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1774 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001775{
hassoe0701b72004-05-20 09:19:34 +00001776 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1777 return 0;
1778
1779 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001780 {
hassoe0701b72004-05-20 09:19:34 +00001781 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1782 && ! always)
1783 return 0;
paul718e3742002-12-13 20:15:29 +00001784
hassoe0701b72004-05-20 09:19:34 +00001785 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001786 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1787 "limit %ld", afi_safi_print (afi, safi), peer->host,
1788 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001789 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001790
hassoe0701b72004-05-20 09:19:34 +00001791 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1792 return 0;
paul718e3742002-12-13 20:15:29 +00001793
hassoe0701b72004-05-20 09:19:34 +00001794 {
paul5228ad22004-06-04 17:58:18 +00001795 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001796
1797 if (safi == SAFI_MPLS_VPN)
Denis Ovsienko42e6d742011-07-14 12:36:19 +04001798 safi = SAFI_MPLS_LABELED_VPN;
paul5228ad22004-06-04 17:58:18 +00001799
1800 ndata[0] = (afi >> 8);
1801 ndata[1] = afi;
1802 ndata[2] = safi;
1803 ndata[3] = (peer->pmax[afi][safi] >> 24);
1804 ndata[4] = (peer->pmax[afi][safi] >> 16);
1805 ndata[5] = (peer->pmax[afi][safi] >> 8);
1806 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001807
1808 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1809 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1810 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1811 }
hasso0a486e52005-02-01 20:57:17 +00001812
1813 /* restart timer start */
1814 if (peer->pmax_restart[afi][safi])
1815 {
1816 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1817
1818 if (BGP_DEBUG (events, EVENTS))
1819 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1820 peer->host, peer->v_pmax_restart);
1821
1822 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1823 peer->v_pmax_restart);
1824 }
1825
hassoe0701b72004-05-20 09:19:34 +00001826 return 1;
paul718e3742002-12-13 20:15:29 +00001827 }
hassoe0701b72004-05-20 09:19:34 +00001828 else
1829 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1830
1831 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1832 {
1833 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1834 && ! always)
1835 return 0;
1836
1837 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001838 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1839 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1840 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001841 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1842 }
1843 else
1844 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001845 return 0;
1846}
1847
paulb40d9392005-08-22 22:34:41 +00001848/* Unconditionally remove the route from the RIB, without taking
1849 * damping into consideration (eg, because the session went down)
1850 */
paul94f2b392005-06-28 12:44:16 +00001851static void
paul718e3742002-12-13 20:15:29 +00001852bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1853 afi_t afi, safi_t safi)
1854{
paul902212c2006-02-05 17:51:19 +00001855 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1856
1857 if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1858 bgp_info_delete (rn, ri); /* keep historical info */
1859
paulb40d9392005-08-22 22:34:41 +00001860 bgp_process (peer->bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001861}
1862
paul94f2b392005-06-28 12:44:16 +00001863static void
paul718e3742002-12-13 20:15:29 +00001864bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
Lou Berger050defe2016-01-12 13:41:59 -05001865 afi_t afi, safi_t safi, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00001866{
paul718e3742002-12-13 20:15:29 +00001867 int status = BGP_DAMP_NONE;
1868
paulb40d9392005-08-22 22:34:41 +00001869 /* apply dampening, if result is suppressed, we'll be retaining
1870 * the bgp_info in the RIB for historical reference.
1871 */
1872 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001873 && peer->sort == BGP_PEER_EBGP)
paulb40d9392005-08-22 22:34:41 +00001874 if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0))
1875 == BGP_DAMP_SUPPRESSED)
paul902212c2006-02-05 17:51:19 +00001876 {
paul902212c2006-02-05 17:51:19 +00001877 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1878 return;
1879 }
1880
1881 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00001882}
1883
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05001884static struct bgp_info *
1885info_make (int type, int sub_type, struct peer *peer, struct attr *attr,
1886 struct bgp_node *rn)
1887{
1888 struct bgp_info *new;
1889
1890 /* Make new BGP info. */
1891 new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
1892 new->type = type;
1893 new->sub_type = sub_type;
1894 new->peer = peer;
1895 new->attr = attr;
1896 new->uptime = bgp_clock ();
1897 new->net = rn;
1898 return new;
1899}
1900
paul94f2b392005-06-28 12:44:16 +00001901static void
paulfee0f4c2004-09-13 05:12:46 +00001902bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1903 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1904 int sub_type, struct prefix_rd *prd, u_char *tag)
1905{
1906 struct bgp_node *rn;
1907 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001908 struct attr new_attr;
1909 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00001910 struct attr *attr_new;
1911 struct attr *attr_new2;
1912 struct bgp_info *ri;
1913 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001914 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001915 char buf[SU_ADDRSTRLEN];
1916
1917 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1918 if (peer == rsclient)
1919 return;
1920
1921 bgp = peer->bgp;
1922 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1923
1924 /* Check previously received route. */
1925 for (ri = rn->info; ri; ri = ri->next)
1926 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1927 break;
1928
1929 /* AS path loop check. */
Milan Kocian000e1572013-10-18 07:59:38 +00001930 if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001931 {
1932 reason = "as-path contains our own AS;";
1933 goto filtered;
1934 }
1935
1936 /* Route reflector originator ID check. */
1937 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00001938 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001939 {
1940 reason = "originator is us;";
1941 goto filtered;
1942 }
Paul Jakmafb982c22007-05-04 20:15:47 +00001943
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001944 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00001945 bgp_attr_dup (&new_attr, attr);
paulfee0f4c2004-09-13 05:12:46 +00001946
1947 /* Apply export policy. */
1948 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1949 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1950 {
1951 reason = "export-policy;";
1952 goto filtered;
1953 }
1954
1955 attr_new2 = bgp_attr_intern (&new_attr);
Paul Jakmafb982c22007-05-04 20:15:47 +00001956
paulfee0f4c2004-09-13 05:12:46 +00001957 /* Apply import policy. */
1958 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1959 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001960 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001961
1962 reason = "import-policy;";
1963 goto filtered;
1964 }
1965
1966 attr_new = bgp_attr_intern (&new_attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001967 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001968
1969 /* IPv4 unicast next hop check. */
G.Balaji5a616c02011-11-26 21:58:42 +04001970 if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
paulfee0f4c2004-09-13 05:12:46 +00001971 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001972 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
paulfee0f4c2004-09-13 05:12:46 +00001973 if (new_attr.nexthop.s_addr == 0
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001974 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
paulfee0f4c2004-09-13 05:12:46 +00001975 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001976 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00001977
1978 reason = "martian next-hop;";
1979 goto filtered;
1980 }
1981 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001982
paulfee0f4c2004-09-13 05:12:46 +00001983 /* If the update is implicit withdraw. */
1984 if (ri)
1985 {
Stephen Hemminger65957882010-01-15 16:22:10 +03001986 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00001987
1988 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00001989 if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
1990 && attrhash_cmp (ri->attr, attr_new))
paulfee0f4c2004-09-13 05:12:46 +00001991 {
1992
paulfee0f4c2004-09-13 05:12:46 +00001993
1994 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001995 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001996 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1997 peer->host,
1998 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1999 p->prefixlen, rsclient->host);
2000
Chris Caputo228da422009-07-18 05:44:03 +00002001 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002002 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002003 bgp_attr_flush(&new_attr);
Chris Caputo228da422009-07-18 05:44:03 +00002004 return;
paulfee0f4c2004-09-13 05:12:46 +00002005 }
2006
Paul Jakma16d2e242007-04-10 19:32:10 +00002007 /* Withdraw/Announce before we fully processed the withdraw */
2008 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2009 bgp_info_restore (rn, ri);
2010
paulfee0f4c2004-09-13 05:12:46 +00002011 /* Received Logging. */
2012 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002013 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002014 peer->host,
2015 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2016 p->prefixlen, rsclient->host);
2017
2018 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002019 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00002020
2021 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002022 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00002023 ri->attr = attr_new;
2024
2025 /* Update MPLS tag. */
2026 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002027 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002028
Paul Jakma1a392d42006-09-07 00:24:49 +00002029 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002030
2031 /* Process change. */
2032 bgp_process (bgp, rn, afi, safi);
2033 bgp_unlock_node (rn);
2034
2035 return;
2036 }
2037
2038 /* Received Logging. */
2039 if (BGP_DEBUG (update, UPDATE_IN))
2040 {
ajsd2c1f162004-12-08 21:10:20 +00002041 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002042 peer->host,
2043 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2044 p->prefixlen, rsclient->host);
2045 }
2046
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05002047 new = info_make(type, sub_type, peer, attr_new, rn);
paulfee0f4c2004-09-13 05:12:46 +00002048
2049 /* Update MPLS tag. */
2050 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002051 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002052
Paul Jakma1a392d42006-09-07 00:24:49 +00002053 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002054
2055 /* Register new BGP information. */
2056 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002057
2058 /* route_node_get lock */
2059 bgp_unlock_node (rn);
2060
paulfee0f4c2004-09-13 05:12:46 +00002061 /* Process change. */
2062 bgp_process (bgp, rn, afi, safi);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002063
paulfee0f4c2004-09-13 05:12:46 +00002064 return;
2065
2066 filtered:
2067
2068 /* This BGP update is filtered. Log the reason then update BGP entry. */
2069 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002070 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002071 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2072 peer->host,
2073 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2074 p->prefixlen, rsclient->host, reason);
2075
2076 if (ri)
paulb40d9392005-08-22 22:34:41 +00002077 bgp_rib_remove (rn, ri, peer, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002078
2079 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002080
paulfee0f4c2004-09-13 05:12:46 +00002081 return;
2082}
2083
paul94f2b392005-06-28 12:44:16 +00002084static void
paulfee0f4c2004-09-13 05:12:46 +00002085bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
2086 struct peer *peer, struct prefix *p, int type, int sub_type,
2087 struct prefix_rd *prd, u_char *tag)
Chris Caputo228da422009-07-18 05:44:03 +00002088{
paulfee0f4c2004-09-13 05:12:46 +00002089 struct bgp_node *rn;
2090 struct bgp_info *ri;
2091 char buf[SU_ADDRSTRLEN];
2092
2093 if (rsclient == peer)
Chris Caputo228da422009-07-18 05:44:03 +00002094 return;
paulfee0f4c2004-09-13 05:12:46 +00002095
2096 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
2097
2098 /* Lookup withdrawn route. */
2099 for (ri = rn->info; ri; ri = ri->next)
2100 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2101 break;
2102
2103 /* Withdraw specified route from routing table. */
2104 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002105 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paulfee0f4c2004-09-13 05:12:46 +00002106 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002107 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002108 "%s Can't find the route %s/%d", peer->host,
2109 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2110 p->prefixlen);
2111
2112 /* Unlock bgp_node_get() lock. */
Chris Caputo228da422009-07-18 05:44:03 +00002113 bgp_unlock_node (rn);
2114}
paulfee0f4c2004-09-13 05:12:46 +00002115
paul94f2b392005-06-28 12:44:16 +00002116static int
paulfee0f4c2004-09-13 05:12:46 +00002117bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00002118 afi_t afi, safi_t safi, int type, int sub_type,
2119 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2120{
2121 int ret;
2122 int aspath_loop_count = 0;
2123 struct bgp_node *rn;
2124 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002125 struct attr new_attr;
2126 struct attr_extra new_extra;
paul718e3742002-12-13 20:15:29 +00002127 struct attr *attr_new;
2128 struct bgp_info *ri;
2129 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00002130 const char *reason;
paul718e3742002-12-13 20:15:29 +00002131 char buf[SU_ADDRSTRLEN];
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002132 int connected = 0;
paul718e3742002-12-13 20:15:29 +00002133
Lou Berger370b7e52016-02-04 21:29:49 -05002134 memset (&new_attr, 0, sizeof(struct attr));
2135 memset (&new_extra, 0, sizeof(struct attr_extra));
2136
paul718e3742002-12-13 20:15:29 +00002137 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00002138 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
Paul Jakmafb982c22007-05-04 20:15:47 +00002139
paul718e3742002-12-13 20:15:29 +00002140 /* When peer's soft reconfiguration enabled. Record input packet in
2141 Adj-RIBs-In. */
Jorge Boncompte [DTI2]343aa822012-05-07 16:53:08 +00002142 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2143 && peer != bgp->peer_self)
paul718e3742002-12-13 20:15:29 +00002144 bgp_adj_in_set (rn, peer, attr);
2145
2146 /* Check previously received route. */
2147 for (ri = rn->info; ri; ri = ri->next)
2148 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2149 break;
2150
2151 /* AS path local-as loop check. */
2152 if (peer->change_local_as)
2153 {
2154 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2155 aspath_loop_count = 1;
2156
2157 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2158 {
2159 reason = "as-path contains our own AS;";
2160 goto filtered;
2161 }
2162 }
2163
2164 /* AS path loop check. */
2165 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2166 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2167 && aspath_loop_check(attr->aspath, bgp->confed_id)
2168 > peer->allowas_in[afi][safi]))
2169 {
2170 reason = "as-path contains our own AS;";
2171 goto filtered;
2172 }
2173
2174 /* Route reflector originator ID check. */
2175 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00002176 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +00002177 {
2178 reason = "originator is us;";
2179 goto filtered;
2180 }
2181
2182 /* Route reflector cluster ID check. */
2183 if (bgp_cluster_filter (peer, attr))
2184 {
2185 reason = "reflected from the same cluster;";
2186 goto filtered;
2187 }
2188
2189 /* Apply incoming filter. */
2190 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2191 {
2192 reason = "filter;";
2193 goto filtered;
2194 }
2195
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002196 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00002197 bgp_attr_dup (&new_attr, attr);
paul718e3742002-12-13 20:15:29 +00002198
David Lamparterc460e572014-06-04 00:54:58 +02002199 /* Apply incoming route-map.
2200 * NB: new_attr may now contain newly allocated values from route-map "set"
2201 * commands, so we need bgp_attr_flush in the error paths, until we intern
2202 * the attr (which takes over the memory references) */
paul718e3742002-12-13 20:15:29 +00002203 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2204 {
2205 reason = "route-map;";
David Lamparterc460e572014-06-04 00:54:58 +02002206 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002207 goto filtered;
2208 }
2209
2210 /* IPv4 unicast next hop check. */
2211 if (afi == AFI_IP && safi == SAFI_UNICAST)
2212 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04002213 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
paul718e3742002-12-13 20:15:29 +00002214 must not be my own address. */
Jorge Boncompte [DTI2]10f9bf32012-05-07 16:52:52 +00002215 if (new_attr.nexthop.s_addr == 0
2216 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2217 || bgp_nexthop_self (&new_attr))
paul718e3742002-12-13 20:15:29 +00002218 {
2219 reason = "martian next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002220 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002221 goto filtered;
2222 }
2223 }
2224
2225 attr_new = bgp_attr_intern (&new_attr);
2226
2227 /* If the update is implicit withdraw. */
2228 if (ri)
2229 {
Stephen Hemminger65957882010-01-15 16:22:10 +03002230 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002231
2232 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00002233 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2234 && attrhash_cmp (ri->attr, attr_new))
paul718e3742002-12-13 20:15:29 +00002235 {
paul718e3742002-12-13 20:15:29 +00002236 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. */
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002340 if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)
paul718e3742002-12-13 20:15:29 +00002341 {
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002342 if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 &&
2343 ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
2344 connected = 1;
2345 else
2346 connected = 0;
2347
2348 if (bgp_find_or_add_nexthop (afi, ri, NULL, connected))
Paul Jakma1a392d42006-09-07 00:24:49 +00002349 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002350 else
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002351 {
2352 if (BGP_DEBUG(nht, NHT))
2353 {
2354 char buf1[INET6_ADDRSTRLEN];
2355 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN);
2356 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
2357 }
2358 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
2359 }
paul718e3742002-12-13 20:15:29 +00002360 }
2361 else
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002362 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002363
Lou Berger050defe2016-01-12 13:41:59 -05002364 bgp_attr_flush (&new_attr);
2365
paul718e3742002-12-13 20:15:29 +00002366 /* Process change. */
2367 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2368
2369 bgp_process (bgp, rn, afi, safi);
2370 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002371
paul718e3742002-12-13 20:15:29 +00002372 return 0;
2373 }
2374
2375 /* Received Logging. */
2376 if (BGP_DEBUG (update, UPDATE_IN))
2377 {
ajsd2c1f162004-12-08 21:10:20 +00002378 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002379 peer->host,
2380 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2381 p->prefixlen);
2382 }
2383
paul718e3742002-12-13 20:15:29 +00002384 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05002385 new = info_make(type, sub_type, peer, attr_new, rn);
paul718e3742002-12-13 20:15:29 +00002386
2387 /* Update MPLS tag. */
2388 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002389 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002390
2391 /* Nexthop reachability check. */
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002392 if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)
paul718e3742002-12-13 20:15:29 +00002393 {
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002394 if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 &&
2395 ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
2396 connected = 1;
2397 else
2398 connected = 0;
2399
2400 if (bgp_find_or_add_nexthop (afi, new, NULL, connected))
Paul Jakma1a392d42006-09-07 00:24:49 +00002401 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002402 else
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002403 {
2404 if (BGP_DEBUG(nht, NHT))
2405 {
2406 char buf1[INET6_ADDRSTRLEN];
2407 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN);
2408 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
2409 }
2410 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
2411 }
paul718e3742002-12-13 20:15:29 +00002412 }
2413 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002414 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002415
paul902212c2006-02-05 17:51:19 +00002416 /* Increment prefix */
paul718e3742002-12-13 20:15:29 +00002417 bgp_aggregate_increment (bgp, p, new, afi, safi);
2418
2419 /* Register new BGP information. */
2420 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002421
2422 /* route_node_get lock */
2423 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002424
Lou Berger050defe2016-01-12 13:41:59 -05002425 bgp_attr_flush (&new_attr);
2426
paul718e3742002-12-13 20:15:29 +00002427 /* If maximum prefix count is configured and current prefix
2428 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00002429 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2430 return -1;
paul718e3742002-12-13 20:15:29 +00002431
2432 /* Process change. */
2433 bgp_process (bgp, rn, afi, safi);
2434
2435 return 0;
2436
2437 /* This BGP update is filtered. Log the reason then update BGP
2438 entry. */
2439 filtered:
2440 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002441 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002442 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2443 peer->host,
2444 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2445 p->prefixlen, reason);
2446
2447 if (ri)
paulb40d9392005-08-22 22:34:41 +00002448 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002449
2450 bgp_unlock_node (rn);
Lou Berger050defe2016-01-12 13:41:59 -05002451 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002452
paul718e3742002-12-13 20:15:29 +00002453 return 0;
2454}
2455
2456int
paulfee0f4c2004-09-13 05:12:46 +00002457bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2458 afi_t afi, safi_t safi, int type, int sub_type,
2459 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2460{
2461 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002462 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002463 struct bgp *bgp;
2464 int ret;
2465
2466 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2467 soft_reconfig);
2468
2469 bgp = peer->bgp;
2470
2471 /* Process the update for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002472 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002473 {
2474 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2475 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2476 sub_type, prd, tag);
2477 }
2478
2479 return ret;
2480}
2481
2482int
paul718e3742002-12-13 20:15:29 +00002483bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
paul94f2b392005-06-28 12:44:16 +00002484 afi_t afi, safi_t safi, int type, int sub_type,
2485 struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00002486{
2487 struct bgp *bgp;
2488 char buf[SU_ADDRSTRLEN];
2489 struct bgp_node *rn;
2490 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00002491 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002492 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002493
2494 bgp = peer->bgp;
2495
David Lamparter4584c232015-04-13 09:50:00 +02002496 /* Lookup node. */
2497 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2498
2499 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2500 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2501 * the iteration over all RS clients.
2502 * Since we need to remove the entry from adj_in anyway, do that first and
2503 * if there was no entry, we don't need to do anything more. */
2504 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2505 && peer != bgp->peer_self)
2506 if (!bgp_adj_in_unset (rn, peer))
2507 {
2508 if (BGP_DEBUG (update, UPDATE_IN))
2509 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2510 "not in adj-in", peer->host,
2511 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2512 p->prefixlen);
2513 bgp_unlock_node (rn);
2514 return 0;
2515 }
2516
paulfee0f4c2004-09-13 05:12:46 +00002517 /* Process the withdraw for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002518 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002519 {
2520 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2521 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2522 }
2523
paul718e3742002-12-13 20:15:29 +00002524 /* Logging. */
2525 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002526 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002527 peer->host,
2528 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2529 p->prefixlen);
2530
paul718e3742002-12-13 20:15:29 +00002531 /* Lookup withdrawn route. */
2532 for (ri = rn->info; ri; ri = ri->next)
2533 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2534 break;
2535
2536 /* Withdraw specified route from routing table. */
2537 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002538 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paul718e3742002-12-13 20:15:29 +00002539 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002540 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002541 "%s Can't find the route %s/%d", peer->host,
2542 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2543 p->prefixlen);
2544
2545 /* Unlock bgp_node_get() lock. */
2546 bgp_unlock_node (rn);
2547
2548 return 0;
2549}
David Lamparter6b0655a2014-06-04 06:53:35 +02002550
paul718e3742002-12-13 20:15:29 +00002551void
2552bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2553{
2554 struct bgp *bgp;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00002555 struct attr attr;
Jorge Boncompte [DTI2]577ac572012-05-07 16:53:06 +00002556 struct aspath *aspath;
paul718e3742002-12-13 20:15:29 +00002557 struct prefix p;
paul718e3742002-12-13 20:15:29 +00002558 struct peer *from;
Christian Frankedcab1bb2012-12-07 16:45:52 +00002559 struct bgp_node *rn;
2560 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00002561 int ret = RMAP_DENYMATCH;
Paul Jakmafb982c22007-05-04 20:15:47 +00002562
Paul Jakmab2497022007-06-14 11:17:58 +00002563 if (!(afi == AFI_IP || afi == AFI_IP6))
Paul Jakmafb982c22007-05-04 20:15:47 +00002564 return;
2565
paul718e3742002-12-13 20:15:29 +00002566 bgp = peer->bgp;
2567 from = bgp->peer_self;
Paul Jakmafb982c22007-05-04 20:15:47 +00002568
paul718e3742002-12-13 20:15:29 +00002569 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2570 aspath = attr.aspath;
2571 attr.local_pref = bgp->default_local_pref;
2572 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2573
2574 if (afi == AFI_IP)
2575 str2prefix ("0.0.0.0/0", &p);
paul718e3742002-12-13 20:15:29 +00002576 else if (afi == AFI_IP6)
2577 {
Jorge Boncompte [DTI2]6182d652012-05-07 16:53:02 +00002578 struct attr_extra *ae = attr.extra;
2579
paul718e3742002-12-13 20:15:29 +00002580 str2prefix ("::/0", &p);
2581
2582 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00002583 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00002584 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002585 ae->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00002586
2587 /* If the peer is on shared nextwork and we have link-local
2588 nexthop set it. */
2589 if (peer->shared_network
2590 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2591 {
Paul Jakmafb982c22007-05-04 20:15:47 +00002592 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00002593 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002594 ae->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00002595 }
2596 }
paul718e3742002-12-13 20:15:29 +00002597
2598 if (peer->default_rmap[afi][safi].name)
2599 {
paulfee0f4c2004-09-13 05:12:46 +00002600 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
Christian Frankedcab1bb2012-12-07 16:45:52 +00002601 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2602 {
2603 for (ri = rn->info; ri; ri = ri->next)
2604 {
2605 struct attr dummy_attr;
2606 struct attr_extra dummy_extra;
2607 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00002608
Christian Frankedcab1bb2012-12-07 16:45:52 +00002609 /* Provide dummy so the route-map can't modify the attributes */
2610 dummy_attr.extra = &dummy_extra;
2611 bgp_attr_dup(&dummy_attr, ri->attr);
2612 info.peer = ri->peer;
2613 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00002614
Christian Frankedcab1bb2012-12-07 16:45:52 +00002615 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2616 RMAP_BGP, &info);
2617
2618 /* The route map might have set attributes. If we don't flush them
2619 * here, they will be leaked. */
2620 bgp_attr_flush(&dummy_attr);
2621 if (ret != RMAP_DENYMATCH)
2622 break;
2623 }
2624 if (ret != RMAP_DENYMATCH)
2625 break;
2626 }
paulfee0f4c2004-09-13 05:12:46 +00002627 bgp->peer_self->rmap_type = 0;
2628
paul718e3742002-12-13 20:15:29 +00002629 if (ret == RMAP_DENYMATCH)
Christian Frankedcab1bb2012-12-07 16:45:52 +00002630 withdraw = 1;
paul718e3742002-12-13 20:15:29 +00002631 }
2632
2633 if (withdraw)
2634 {
2635 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2636 bgp_default_withdraw_send (peer, afi, safi);
2637 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2638 }
2639 else
2640 {
Christian Frankedcab1bb2012-12-07 16:45:52 +00002641 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2642 {
2643 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2644 bgp_default_update_send (peer, &attr, afi, safi, from);
2645 }
paul718e3742002-12-13 20:15:29 +00002646 }
Paul Jakmafb982c22007-05-04 20:15:47 +00002647
2648 bgp_attr_extra_free (&attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002649 aspath_unintern (&aspath);
paul718e3742002-12-13 20:15:29 +00002650}
David Lamparter6b0655a2014-06-04 06:53:35 +02002651
paul718e3742002-12-13 20:15:29 +00002652static void
2653bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002654 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002655{
2656 struct bgp_node *rn;
2657 struct bgp_info *ri;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002658 struct attr attr;
2659 struct attr_extra extra;
2660
Lou Berger298cc2f2016-01-12 13:42:02 -05002661 memset(&extra, 0, sizeof(extra));
2662
paul718e3742002-12-13 20:15:29 +00002663 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002664 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002665
Lou Berger298cc2f2016-01-12 13:42:02 -05002666 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00002667 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2668 bgp_default_originate (peer, afi, safi, 0);
2669
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002670 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2671 attr.extra = &extra;
2672
paul718e3742002-12-13 20:15:29 +00002673 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2674 for (ri = rn->info; ri; ri = ri->next)
2675 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2676 {
paulfee0f4c2004-09-13 05:12:46 +00002677 if ( (rsclient) ?
2678 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2679 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002680 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2681 else
2682 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2683 }
Lou Berger298cc2f2016-01-12 13:42:02 -05002684
2685 bgp_attr_flush_encap(&attr);
paul718e3742002-12-13 20:15:29 +00002686}
2687
2688void
2689bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2690{
2691 struct bgp_node *rn;
2692 struct bgp_table *table;
2693
2694 if (peer->status != Established)
2695 return;
2696
2697 if (! peer->afc_nego[afi][safi])
2698 return;
2699
2700 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2701 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2702 return;
2703
Lou Berger298cc2f2016-01-12 13:42:02 -05002704 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
paulfee0f4c2004-09-13 05:12:46 +00002705 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002706 else
2707 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2708 rn = bgp_route_next(rn))
2709 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002710 bgp_announce_table (peer, afi, safi, table, 0);
2711
2712 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2713 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002714}
2715
2716void
2717bgp_announce_route_all (struct peer *peer)
2718{
2719 afi_t afi;
2720 safi_t safi;
2721
2722 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2723 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2724 bgp_announce_route (peer, afi, safi);
2725}
David Lamparter6b0655a2014-06-04 06:53:35 +02002726
paul718e3742002-12-13 20:15:29 +00002727static void
paulfee0f4c2004-09-13 05:12:46 +00002728bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002729 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
paulfee0f4c2004-09-13 05:12:46 +00002730{
2731 struct bgp_node *rn;
2732 struct bgp_adj_in *ain;
2733
2734 if (! table)
2735 table = rsclient->bgp->rib[afi][safi];
2736
2737 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2738 for (ain = rn->adj_in; ain; ain = ain->next)
2739 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002740 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002741 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002742
paulfee0f4c2004-09-13 05:12:46 +00002743 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
Christian Franked53d8fd2013-01-28 07:14:43 +01002744 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
paulfee0f4c2004-09-13 05:12:46 +00002745 }
2746}
2747
2748void
2749bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2750{
2751 struct bgp_table *table;
2752 struct bgp_node *rn;
2753
Lou Berger298cc2f2016-01-12 13:42:02 -05002754 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002755 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
paulfee0f4c2004-09-13 05:12:46 +00002756
2757 else
2758 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2759 rn = bgp_route_next (rn))
2760 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002761 {
2762 struct prefix_rd prd;
2763 prd.family = AF_UNSPEC;
2764 prd.prefixlen = 64;
2765 memcpy(&prd.val, rn->p.u.val, 8);
2766
2767 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2768 }
paulfee0f4c2004-09-13 05:12:46 +00002769}
David Lamparter6b0655a2014-06-04 06:53:35 +02002770
paulfee0f4c2004-09-13 05:12:46 +00002771static void
paul718e3742002-12-13 20:15:29 +00002772bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002773 struct bgp_table *table, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00002774{
2775 int ret;
2776 struct bgp_node *rn;
2777 struct bgp_adj_in *ain;
2778
2779 if (! table)
2780 table = peer->bgp->rib[afi][safi];
2781
2782 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2783 for (ain = rn->adj_in; ain; ain = ain->next)
2784 {
2785 if (ain->peer == peer)
2786 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002787 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002788 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002789
paul718e3742002-12-13 20:15:29 +00002790 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2791 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
Christian Franked53d8fd2013-01-28 07:14:43 +01002792 prd, tag, 1);
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002793
paul718e3742002-12-13 20:15:29 +00002794 if (ret < 0)
2795 {
2796 bgp_unlock_node (rn);
2797 return;
2798 }
2799 continue;
2800 }
2801 }
2802}
2803
2804void
2805bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2806{
2807 struct bgp_node *rn;
2808 struct bgp_table *table;
2809
2810 if (peer->status != Established)
2811 return;
2812
Lou Berger298cc2f2016-01-12 13:42:02 -05002813 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002814 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002815 else
2816 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2817 rn = bgp_route_next (rn))
2818 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002819 {
2820 struct prefix_rd prd;
2821 prd.family = AF_UNSPEC;
2822 prd.prefixlen = 64;
2823 memcpy(&prd.val, rn->p.u.val, 8);
2824
2825 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2826 }
paul718e3742002-12-13 20:15:29 +00002827}
David Lamparter6b0655a2014-06-04 06:53:35 +02002828
Chris Caputo228da422009-07-18 05:44:03 +00002829
2830struct bgp_clear_node_queue
2831{
2832 struct bgp_node *rn;
2833 enum bgp_clear_route_type purpose;
2834};
2835
paul200df112005-06-01 11:17:05 +00002836static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00002837bgp_clear_route_node (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002838{
Chris Caputo228da422009-07-18 05:44:03 +00002839 struct bgp_clear_node_queue *cnq = data;
2840 struct bgp_node *rn = cnq->rn;
Paul Jakma64e580a2006-02-21 01:09:01 +00002841 struct peer *peer = wq->spec.data;
paul200df112005-06-01 11:17:05 +00002842 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002843 afi_t afi = bgp_node_table (rn)->afi;
2844 safi_t safi = bgp_node_table (rn)->safi;
paul200df112005-06-01 11:17:05 +00002845
Paul Jakma64e580a2006-02-21 01:09:01 +00002846 assert (rn && peer);
paul200df112005-06-01 11:17:05 +00002847
Paul Jakma64e580a2006-02-21 01:09:01 +00002848 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002849 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
paul200df112005-06-01 11:17:05 +00002850 {
2851 /* graceful restart STALE flag set. */
Paul Jakma64e580a2006-02-21 01:09:01 +00002852 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2853 && peer->nsf[afi][safi]
paul200df112005-06-01 11:17:05 +00002854 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
Paul Jakma1a392d42006-09-07 00:24:49 +00002855 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2856 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
paul200df112005-06-01 11:17:05 +00002857 else
Paul Jakma64e580a2006-02-21 01:09:01 +00002858 bgp_rib_remove (rn, ri, peer, afi, safi);
paul200df112005-06-01 11:17:05 +00002859 break;
2860 }
paul200df112005-06-01 11:17:05 +00002861 return WQ_SUCCESS;
2862}
2863
2864static void
paul0fb58d52005-11-14 14:31:49 +00002865bgp_clear_node_queue_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002866{
Chris Caputo228da422009-07-18 05:44:03 +00002867 struct bgp_clear_node_queue *cnq = data;
2868 struct bgp_node *rn = cnq->rn;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002869 struct bgp_table *table = bgp_node_table (rn);
Paul Jakma64e580a2006-02-21 01:09:01 +00002870
2871 bgp_unlock_node (rn);
Chris Caputo228da422009-07-18 05:44:03 +00002872 bgp_table_unlock (table);
2873 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
paul200df112005-06-01 11:17:05 +00002874}
2875
2876static void
paul94f2b392005-06-28 12:44:16 +00002877bgp_clear_node_complete (struct work_queue *wq)
paul200df112005-06-01 11:17:05 +00002878{
Paul Jakma64e580a2006-02-21 01:09:01 +00002879 struct peer *peer = wq->spec.data;
2880
Paul Jakma3e0c78e2006-03-06 18:06:53 +00002881 /* Tickle FSM to start moving again */
Paul Jakmaca058a32006-09-14 02:58:49 +00002882 BGP_EVENT_ADD (peer, Clearing_Completed);
Chris Caputo228da422009-07-18 05:44:03 +00002883
2884 peer_unlock (peer); /* bgp_clear_route */
paul200df112005-06-01 11:17:05 +00002885}
2886
2887static void
Paul Jakma64e580a2006-02-21 01:09:01 +00002888bgp_clear_node_queue_init (struct peer *peer)
paul200df112005-06-01 11:17:05 +00002889{
Paul Jakmaa2943652009-07-21 14:02:04 +01002890 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
Paul Jakma64e580a2006-02-21 01:09:01 +00002891
Paul Jakmaa2943652009-07-21 14:02:04 +01002892 snprintf (wname, sizeof(wname), "clear %s", peer->host);
Paul Jakma64e580a2006-02-21 01:09:01 +00002893#undef CLEAR_QUEUE_NAME_LEN
2894
2895 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
paul200df112005-06-01 11:17:05 +00002896 {
2897 zlog_err ("%s: Failed to allocate work queue", __func__);
2898 exit (1);
2899 }
Paul Jakma64e580a2006-02-21 01:09:01 +00002900 peer->clear_node_queue->spec.hold = 10;
2901 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2902 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2903 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2904 peer->clear_node_queue->spec.max_retries = 0;
2905
2906 /* we only 'lock' this peer reference when the queue is actually active */
2907 peer->clear_node_queue->spec.data = peer;
paul200df112005-06-01 11:17:05 +00002908}
2909
paul718e3742002-12-13 20:15:29 +00002910static void
2911bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
Chris Caputo228da422009-07-18 05:44:03 +00002912 struct bgp_table *table, struct peer *rsclient,
2913 enum bgp_clear_route_type purpose)
paul718e3742002-12-13 20:15:29 +00002914{
2915 struct bgp_node *rn;
paul200df112005-06-01 11:17:05 +00002916
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002917
paul718e3742002-12-13 20:15:29 +00002918 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002919 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
Paul Jakma64e580a2006-02-21 01:09:01 +00002920
hasso6cf159b2005-03-21 10:28:14 +00002921 /* If still no table => afi/safi isn't configured at all or smth. */
2922 if (! table)
2923 return;
Paul Jakma65ca75e2006-05-04 08:08:15 +00002924
2925 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2926 {
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002927 struct bgp_info *ri;
2928 struct bgp_adj_in *ain;
2929 struct bgp_adj_out *aout;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002930
2931 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2932 * queued for every clearing peer, regardless of whether it is
2933 * relevant to the peer at hand.
2934 *
2935 * Overview: There are 3 different indices which need to be
2936 * scrubbed, potentially, when a peer is removed:
2937 *
2938 * 1 peer's routes visible via the RIB (ie accepted routes)
2939 * 2 peer's routes visible by the (optional) peer's adj-in index
2940 * 3 other routes visible by the peer's adj-out index
2941 *
2942 * 3 there is no hurry in scrubbing, once the struct peer is
2943 * removed from bgp->peer, we could just GC such deleted peer's
2944 * adj-outs at our leisure.
2945 *
2946 * 1 and 2 must be 'scrubbed' in some way, at least made
2947 * invisible via RIB index before peer session is allowed to be
2948 * brought back up. So one needs to know when such a 'search' is
2949 * complete.
2950 *
2951 * Ideally:
2952 *
2953 * - there'd be a single global queue or a single RIB walker
2954 * - rather than tracking which route_nodes still need to be
2955 * examined on a peer basis, we'd track which peers still
2956 * aren't cleared
2957 *
2958 * Given that our per-peer prefix-counts now should be reliable,
2959 * this may actually be achievable. It doesn't seem to be a huge
2960 * problem at this time,
2961 */
Jorge Boncompte [DTI2]24e50f22012-05-07 15:17:33 +00002962 for (ain = rn->adj_in; ain; ain = ain->next)
2963 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2964 {
2965 bgp_adj_in_remove (rn, ain);
2966 bgp_unlock_node (rn);
2967 break;
2968 }
2969 for (aout = rn->adj_out; aout; aout = aout->next)
2970 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2971 {
2972 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2973 bgp_unlock_node (rn);
2974 break;
2975 }
2976
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002977 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002978 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002979 {
Chris Caputo228da422009-07-18 05:44:03 +00002980 struct bgp_clear_node_queue *cnq;
2981
2982 /* both unlocked in bgp_clear_node_queue_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07002983 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00002984 bgp_lock_node (rn);
2985 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2986 sizeof (struct bgp_clear_node_queue));
2987 cnq->rn = rn;
2988 cnq->purpose = purpose;
2989 work_queue_add (peer->clear_node_queue, cnq);
2990 break;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002991 }
Paul Jakma65ca75e2006-05-04 08:08:15 +00002992 }
2993 return;
2994}
2995
2996void
Chris Caputo228da422009-07-18 05:44:03 +00002997bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
2998 enum bgp_clear_route_type purpose)
Paul Jakma65ca75e2006-05-04 08:08:15 +00002999{
3000 struct bgp_node *rn;
3001 struct bgp_table *table;
3002 struct peer *rsclient;
3003 struct listnode *node, *nnode;
hasso6cf159b2005-03-21 10:28:14 +00003004
Paul Jakma64e580a2006-02-21 01:09:01 +00003005 if (peer->clear_node_queue == NULL)
3006 bgp_clear_node_queue_init (peer);
paul200df112005-06-01 11:17:05 +00003007
Paul Jakmaca058a32006-09-14 02:58:49 +00003008 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3009 * Idle until it receives a Clearing_Completed event. This protects
3010 * against peers which flap faster than we can we clear, which could
3011 * lead to:
Paul Jakma64e580a2006-02-21 01:09:01 +00003012 *
3013 * a) race with routes from the new session being installed before
3014 * clear_route_node visits the node (to delete the route of that
3015 * peer)
3016 * b) resource exhaustion, clear_route_node likely leads to an entry
3017 * on the process_main queue. Fast-flapping could cause that queue
3018 * to grow and grow.
paul200df112005-06-01 11:17:05 +00003019 */
Donald Sharp7ef42212015-03-30 06:32:52 -07003020
3021 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3022 * the unlock will happen upon work-queue completion; other wise, the
3023 * unlock happens at the end of this function.
3024 */
Paul Jakmaca058a32006-09-14 02:58:49 +00003025 if (!peer->clear_node_queue->thread)
Lou Berger050defe2016-01-12 13:41:59 -05003026 peer_lock (peer); /* bgp_clear_node_complete */
Chris Caputo228da422009-07-18 05:44:03 +00003027 switch (purpose)
paulfee0f4c2004-09-13 05:12:46 +00003028 {
Chris Caputo228da422009-07-18 05:44:03 +00003029 case BGP_CLEAR_ROUTE_NORMAL:
Lou Berger298cc2f2016-01-12 13:42:02 -05003030 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Chris Caputo228da422009-07-18 05:44:03 +00003031 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3032 else
3033 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3034 rn = bgp_route_next (rn))
3035 if ((table = rn->info) != NULL)
3036 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3037
3038 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3039 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3040 PEER_FLAG_RSERVER_CLIENT))
3041 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3042 break;
3043
3044 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
Lou Berger050defe2016-01-12 13:41:59 -05003045 /*
3046 * gpz 091009: TBD why don't we have special handling for
3047 * SAFI_MPLS_VPN here in the original quagga code?
3048 * (and, by extension, for SAFI_ENCAP)
3049 */
Chris Caputo228da422009-07-18 05:44:03 +00003050 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3051 break;
3052
3053 default:
3054 assert (0);
3055 break;
paulfee0f4c2004-09-13 05:12:46 +00003056 }
Donald Sharp7ef42212015-03-30 06:32:52 -07003057
3058 /* unlock if no nodes got added to the clear-node-queue. */
Paul Jakma65ca75e2006-05-04 08:08:15 +00003059 if (!peer->clear_node_queue->thread)
Donald Sharp7ef42212015-03-30 06:32:52 -07003060 peer_unlock (peer);
3061
paul718e3742002-12-13 20:15:29 +00003062}
3063
3064void
3065bgp_clear_route_all (struct peer *peer)
3066{
3067 afi_t afi;
3068 safi_t safi;
3069
3070 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3071 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
Chris Caputo228da422009-07-18 05:44:03 +00003072 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
paul718e3742002-12-13 20:15:29 +00003073}
3074
Lou Berger82dd7072016-01-12 13:41:57 -05003075/*
3076 * Finish freeing things when exiting
3077 */
3078static void
3079bgp_drain_workqueue_immediate (struct work_queue *wq)
3080{
3081 if (!wq)
3082 return;
3083
3084 if (!wq->thread)
3085 {
3086 /*
3087 * no thread implies no queued items
3088 */
3089 assert(!wq->items->count);
3090 return;
3091 }
3092
3093 while (wq->items->count)
3094 {
3095 if (wq->thread)
3096 thread_cancel(wq->thread);
3097 work_queue_run(wq->thread);
3098 }
3099}
3100
3101/*
3102 * Special function to process clear node queue when bgpd is exiting
3103 * and the thread scheduler is no longer running.
3104 */
3105void
3106bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3107{
3108 if (!peer)
3109 return;
3110
3111 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3112}
3113
3114/*
3115 * The work queues are not specific to a BGP instance, but the
3116 * items in them refer to BGP instances, so this should be called
3117 * before each BGP instance is deleted.
3118 */
3119void
3120bgp_process_queues_drain_immediate(void)
3121{
3122 bgp_drain_workqueue_immediate(bm->process_main_queue);
3123 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3124}
3125
paul718e3742002-12-13 20:15:29 +00003126void
3127bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3128{
3129 struct bgp_table *table;
3130 struct bgp_node *rn;
3131 struct bgp_adj_in *ain;
3132
3133 table = peer->bgp->rib[afi][safi];
3134
3135 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3136 for (ain = rn->adj_in; ain ; ain = ain->next)
3137 if (ain->peer == peer)
3138 {
3139 bgp_adj_in_remove (rn, ain);
3140 bgp_unlock_node (rn);
3141 break;
3142 }
3143}
hasso93406d82005-02-02 14:40:33 +00003144
3145void
3146bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3147{
3148 struct bgp_node *rn;
3149 struct bgp_info *ri;
3150 struct bgp_table *table;
3151
3152 table = peer->bgp->rib[afi][safi];
3153
3154 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3155 {
3156 for (ri = rn->info; ri; ri = ri->next)
3157 if (ri->peer == peer)
3158 {
3159 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3160 bgp_rib_remove (rn, ri, peer, afi, safi);
3161 break;
3162 }
3163 }
3164}
David Lamparter6b0655a2014-06-04 06:53:35 +02003165
Lou Berger82dd7072016-01-12 13:41:57 -05003166static void
3167bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3168{
3169 struct bgp_node *rn;
3170 struct bgp_info *ri;
3171 struct bgp_info *next;
3172
3173 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3174 for (ri = rn->info; ri; ri = next)
3175 {
3176 next = ri->next;
3177 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3178 && ri->type == ZEBRA_ROUTE_BGP
3179 && ri->sub_type == BGP_ROUTE_NORMAL)
3180 bgp_zebra_withdraw (&rn->p, ri, safi);
3181 }
3182}
3183
paul718e3742002-12-13 20:15:29 +00003184/* Delete all kernel routes. */
3185void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003186bgp_cleanup_routes (void)
paul718e3742002-12-13 20:15:29 +00003187{
3188 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00003189 struct listnode *node, *nnode;
Lou Berger82dd7072016-01-12 13:41:57 -05003190 afi_t afi;
paul718e3742002-12-13 20:15:29 +00003191
paul1eb8ef22005-04-07 07:30:20 +00003192 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00003193 {
Lou Berger82dd7072016-01-12 13:41:57 -05003194 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3195 {
3196 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00003197
Lou Berger82dd7072016-01-12 13:41:57 -05003198 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00003199
Lou Berger82dd7072016-01-12 13:41:57 -05003200 /*
3201 * VPN and ENCAP tables are two-level (RD is top level)
3202 */
3203 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3204 rn = bgp_route_next (rn))
Lou Berger298cc2f2016-01-12 13:42:02 -05003205 {
3206 if (rn->info)
Lou Berger82dd7072016-01-12 13:41:57 -05003207 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003208 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3209 bgp_table_finish ((struct bgp_table **)&(rn->info));
3210 rn->info = NULL;
3211 bgp_unlock_node(rn);
Lou Berger82dd7072016-01-12 13:41:57 -05003212 }
Lou Berger298cc2f2016-01-12 13:42:02 -05003213 }
3214
3215 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3216 rn = bgp_route_next (rn))
3217 {
3218 if (rn->info)
3219 {
3220 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3221 bgp_table_finish ((struct bgp_table **)&(rn->info));
3222 rn->info = NULL;
3223 bgp_unlock_node(rn);
3224 }
3225 }
Lou Berger82dd7072016-01-12 13:41:57 -05003226 }
paul718e3742002-12-13 20:15:29 +00003227 }
3228}
3229
3230void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003231bgp_reset (void)
paul718e3742002-12-13 20:15:29 +00003232{
3233 vty_reset ();
3234 bgp_zclient_reset ();
3235 access_list_reset ();
3236 prefix_list_reset ();
3237}
David Lamparter6b0655a2014-06-04 06:53:35 +02003238
paul718e3742002-12-13 20:15:29 +00003239/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3240 value. */
3241int
Paul Jakma518a4b72016-02-04 13:27:04 +00003242bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
3243 struct bgp_nlri *packet)
paul718e3742002-12-13 20:15:29 +00003244{
3245 u_char *pnt;
3246 u_char *lim;
3247 struct prefix p;
3248 int psize;
3249 int ret;
3250
3251 /* Check peer status. */
3252 if (peer->status != Established)
3253 return 0;
3254
3255 pnt = packet->nlri;
3256 lim = pnt + packet->length;
3257
Paul Jakma405e9e12016-02-04 17:00:18 +00003258 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3259 syntactic validity. If the field is syntactically incorrect,
3260 then the Error Subcode is set to Invalid Network Field. */
paul718e3742002-12-13 20:15:29 +00003261 for (; pnt < lim; pnt += psize)
3262 {
3263 /* Clear prefix structure. */
3264 memset (&p, 0, sizeof (struct prefix));
3265
3266 /* Fetch prefix length. */
3267 p.prefixlen = *pnt++;
Paul Jakma405e9e12016-02-04 17:00:18 +00003268 /* afi/safi validity already verified by caller, bgp_update_receive */
paul718e3742002-12-13 20:15:29 +00003269 p.family = afi2family (packet->afi);
3270
Paul Jakma405e9e12016-02-04 17:00:18 +00003271 /* Prefix length check. */
3272 if (p.prefixlen > prefix_blen (&p) * 8)
3273 {
3274 plog_err (peer->log,
3275 "%s [Error] Update packet error"
3276 " (wrong prefix length %u for afi %u)",
3277 peer->host, p.prefixlen, packet->afi);
3278 return -1;
3279 }
3280
paul718e3742002-12-13 20:15:29 +00003281 /* Packet size overflow check. */
3282 psize = PSIZE (p.prefixlen);
3283
3284 /* When packet overflow occur return immediately. */
3285 if (pnt + psize > lim)
Paul Jakma405e9e12016-02-04 17:00:18 +00003286 {
3287 plog_err (peer->log,
3288 "%s [Error] Update packet error"
3289 " (prefix length %u overflows packet)",
3290 peer->host, p.prefixlen);
3291 return -1;
3292 }
3293
3294 /* Defensive coding, double-check the psize fits in a struct prefix */
3295 if (psize > (ssize_t) sizeof(p.u))
3296 {
3297 plog_err (peer->log,
3298 "%s [Error] Update packet error"
3299 " (prefix length %u too large for prefix storage %zu!?!!",
3300 peer->host, p.prefixlen, sizeof(p.u));
3301 return -1;
3302 }
paul718e3742002-12-13 20:15:29 +00003303
3304 /* Fetch prefix from NLRI packet. */
3305 memcpy (&p.u.prefix, pnt, psize);
3306
3307 /* Check address. */
3308 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3309 {
3310 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3311 {
paulf5ba3872004-07-09 12:11:31 +00003312 /*
Paul Jakma405e9e12016-02-04 17:00:18 +00003313 * From RFC4271 Section 6.3:
3314 *
3315 * If a prefix in the NLRI field is semantically incorrect
3316 * (e.g., an unexpected multicast IP address), an error SHOULD
3317 * be logged locally, and the prefix SHOULD be ignored.
paulf5ba3872004-07-09 12:11:31 +00003318 */
paul718e3742002-12-13 20:15:29 +00003319 zlog (peer->log, LOG_ERR,
Paul Jakma405e9e12016-02-04 17:00:18 +00003320 "%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3321 peer->host, inet_ntoa (p.u.prefix4));
3322 continue;
paul718e3742002-12-13 20:15:29 +00003323 }
3324 }
3325
paul718e3742002-12-13 20:15:29 +00003326 /* Check address. */
3327 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3328 {
3329 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3330 {
3331 char buf[BUFSIZ];
3332
Paul Jakma405e9e12016-02-04 17:00:18 +00003333 zlog (peer->log, LOG_ERR,
3334 "%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3335 peer->host,
paul718e3742002-12-13 20:15:29 +00003336 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00003337 continue;
3338 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003339 if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6))
3340 {
3341 char buf[BUFSIZ];
3342
3343 zlog (peer->log, LOG_ERR,
3344 "%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3345 peer->host,
3346 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3347 continue;
3348 }
3349 }
paul718e3742002-12-13 20:15:29 +00003350
3351 /* Normal process. */
3352 if (attr)
3353 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3354 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3355 else
3356 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3357 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3358
3359 /* Address family configuration mismatch or maximum-prefix count
3360 overflow. */
3361 if (ret < 0)
3362 return -1;
3363 }
3364
3365 /* Packet length consistency check. */
3366 if (pnt != lim)
paul718e3742002-12-13 20:15:29 +00003367 {
3368 plog_err (peer->log,
Paul Jakma405e9e12016-02-04 17:00:18 +00003369 "%s [Error] Update packet error"
3370 " (prefix length mismatch with total length)",
3371 peer->host);
paul718e3742002-12-13 20:15:29 +00003372 return -1;
3373 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003374
paul718e3742002-12-13 20:15:29 +00003375 return 0;
3376}
David Lamparter6b0655a2014-06-04 06:53:35 +02003377
paul94f2b392005-06-28 12:44:16 +00003378static struct bgp_static *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003379bgp_static_new (void)
paul718e3742002-12-13 20:15:29 +00003380{
Stephen Hemminger393deb92008-08-18 14:13:29 -07003381 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
paul718e3742002-12-13 20:15:29 +00003382}
3383
paul94f2b392005-06-28 12:44:16 +00003384static void
paul718e3742002-12-13 20:15:29 +00003385bgp_static_free (struct bgp_static *bgp_static)
3386{
3387 if (bgp_static->rmap.name)
3388 free (bgp_static->rmap.name);
3389 XFREE (MTYPE_BGP_STATIC, bgp_static);
3390}
3391
paul94f2b392005-06-28 12:44:16 +00003392static void
paulfee0f4c2004-09-13 05:12:46 +00003393bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3394 struct prefix *p, afi_t afi, safi_t safi)
3395{
3396 struct bgp_node *rn;
3397 struct bgp_info *ri;
3398
3399 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3400
3401 /* Check selected route and self inserted route. */
3402 for (ri = rn->info; ri; ri = ri->next)
3403 if (ri->peer == bgp->peer_self
3404 && ri->type == ZEBRA_ROUTE_BGP
3405 && ri->sub_type == BGP_ROUTE_STATIC)
3406 break;
3407
3408 /* Withdraw static BGP route from routing table. */
3409 if (ri)
3410 {
paulfee0f4c2004-09-13 05:12:46 +00003411 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003412 bgp_process (bgp, rn, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003413 }
3414
3415 /* Unlock bgp_node_lookup. */
3416 bgp_unlock_node (rn);
3417}
3418
paul94f2b392005-06-28 12:44:16 +00003419static void
paulfee0f4c2004-09-13 05:12:46 +00003420bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
Paul Jakmafb982c22007-05-04 20:15:47 +00003421 struct bgp_static *bgp_static,
3422 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00003423{
3424 struct bgp_node *rn;
3425 struct bgp_info *ri;
3426 struct bgp_info *new;
3427 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00003428 struct attr *attr_new;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003429 struct attr attr;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003430 struct attr new_attr;
3431 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00003432 struct bgp *bgp;
3433 int ret;
3434 char buf[SU_ADDRSTRLEN];
3435
3436 bgp = rsclient->bgp;
3437
Paul Jakma06e110f2006-05-12 23:29:22 +00003438 assert (bgp_static);
3439 if (!bgp_static)
3440 return;
3441
paulfee0f4c2004-09-13 05:12:46 +00003442 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3443
3444 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakma06e110f2006-05-12 23:29:22 +00003445
3446 attr.nexthop = bgp_static->igpnexthop;
3447 attr.med = bgp_static->igpmetric;
3448 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Paul Jakma41367172007-08-06 15:24:51 +00003449
Paul Jakma41367172007-08-06 15:24:51 +00003450 if (bgp_static->atomic)
3451 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3452
paulfee0f4c2004-09-13 05:12:46 +00003453 /* Apply network route-map for export to this rsclient. */
3454 if (bgp_static->rmap.name)
3455 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003456 struct attr attr_tmp = attr;
paulfee0f4c2004-09-13 05:12:46 +00003457 info.peer = rsclient;
Paul Jakmafb982c22007-05-04 20:15:47 +00003458 info.attr = &attr_tmp;
3459
paulfee0f4c2004-09-13 05:12:46 +00003460 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3461 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3462
3463 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3464
3465 rsclient->rmap_type = 0;
3466
3467 if (ret == RMAP_DENYMATCH)
3468 {
3469 /* Free uninterned attribute. */
Paul Jakmafb982c22007-05-04 20:15:47 +00003470 bgp_attr_flush (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003471
3472 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003473 aspath_unintern (&attr.aspath);
paulfee0f4c2004-09-13 05:12:46 +00003474 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
Paul Jakmafb982c22007-05-04 20:15:47 +00003475 bgp_attr_extra_free (&attr);
3476
paulfee0f4c2004-09-13 05:12:46 +00003477 return;
3478 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003479 attr_new = bgp_attr_intern (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003480 }
3481 else
3482 attr_new = bgp_attr_intern (&attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003483
3484 new_attr.extra = &new_extra;
Stephen Hemminger7badc262010-08-05 10:26:31 -07003485 bgp_attr_dup(&new_attr, attr_new);
Paul Jakmafb982c22007-05-04 20:15:47 +00003486
paulfee0f4c2004-09-13 05:12:46 +00003487 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3488
Paul Jakmafb982c22007-05-04 20:15:47 +00003489 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3490 == RMAP_DENY)
3491 {
paulfee0f4c2004-09-13 05:12:46 +00003492 /* This BGP update is filtered. Log the reason then update BGP entry. */
3493 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00003494 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00003495 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3496 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3497 p->prefixlen, rsclient->host);
3498
3499 bgp->peer_self->rmap_type = 0;
3500
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003501 bgp_attr_unintern (&attr_new);
3502 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003503 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003504
3505 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3506
3507 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003508 }
paulfee0f4c2004-09-13 05:12:46 +00003509
3510 bgp->peer_self->rmap_type = 0;
3511
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003512 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00003513 attr_new = bgp_attr_intern (&new_attr);
3514
3515 for (ri = rn->info; ri; ri = ri->next)
3516 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3517 && ri->sub_type == BGP_ROUTE_STATIC)
3518 break;
3519
3520 if (ri)
3521 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003522 if (attrhash_cmp (ri->attr, attr_new) &&
3523 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paulfee0f4c2004-09-13 05:12:46 +00003524 {
3525 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003526 bgp_attr_unintern (&attr_new);
3527 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003528 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003529 return;
3530 }
3531 else
3532 {
3533 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003534 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00003535
3536 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003537 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3538 bgp_info_restore(rn, ri);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003539 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00003540 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003541 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003542
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003543 /* Nexthop reachability check. */
3544 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3545 {
3546 if (bgp_find_or_add_nexthop (afi, ri, NULL, 0))
3547 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
3548 else
3549 {
3550 if (BGP_DEBUG(nht, NHT))
3551 {
3552 char buf1[INET6_ADDRSTRLEN];
3553 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3554 buf1, INET6_ADDRSTRLEN);
3555 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3556 }
3557 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
3558 }
3559 }
paulfee0f4c2004-09-13 05:12:46 +00003560 /* Process change. */
3561 bgp_process (bgp, rn, afi, safi);
3562 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003563 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003564 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003565 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003566 }
paulfee0f4c2004-09-13 05:12:46 +00003567 }
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003568
paulfee0f4c2004-09-13 05:12:46 +00003569 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003570 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
3571 attr_new, rn);
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003572 /* Nexthop reachability check. */
3573 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3574 {
3575 if (bgp_find_or_add_nexthop (afi, new, NULL, 0))
3576 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
3577 else
3578 {
3579 if (BGP_DEBUG(nht, NHT))
3580 {
3581 char buf1[INET6_ADDRSTRLEN];
3582 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3583 buf1, INET6_ADDRSTRLEN);
3584 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3585 }
3586 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
3587 }
3588 }
3589 else
3590 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00003591
3592 /* Register new BGP information. */
3593 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003594
3595 /* route_node_get lock */
3596 bgp_unlock_node (rn);
3597
paulfee0f4c2004-09-13 05:12:46 +00003598 /* Process change. */
3599 bgp_process (bgp, rn, afi, safi);
3600
3601 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003602 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003603 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003604}
3605
paul94f2b392005-06-28 12:44:16 +00003606static void
paulfee0f4c2004-09-13 05:12:46 +00003607bgp_static_update_main (struct bgp *bgp, struct prefix *p,
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003608 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00003609{
3610 struct bgp_node *rn;
3611 struct bgp_info *ri;
3612 struct bgp_info *new;
3613 struct bgp_info info;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003614 struct attr attr;
paul718e3742002-12-13 20:15:29 +00003615 struct attr *attr_new;
3616 int ret;
3617
Paul Jakmadd8103a2006-05-12 23:27:30 +00003618 assert (bgp_static);
3619 if (!bgp_static)
3620 return;
3621
paulfee0f4c2004-09-13 05:12:46 +00003622 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003623
3624 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakmadd8103a2006-05-12 23:27:30 +00003625
3626 attr.nexthop = bgp_static->igpnexthop;
3627 attr.med = bgp_static->igpmetric;
3628 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
paul718e3742002-12-13 20:15:29 +00003629
Paul Jakma41367172007-08-06 15:24:51 +00003630 if (bgp_static->atomic)
3631 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3632
paul718e3742002-12-13 20:15:29 +00003633 /* Apply route-map. */
3634 if (bgp_static->rmap.name)
3635 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003636 struct attr attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00003637 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00003638 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00003639
paulfee0f4c2004-09-13 05:12:46 +00003640 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3641
paul718e3742002-12-13 20:15:29 +00003642 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00003643
paulfee0f4c2004-09-13 05:12:46 +00003644 bgp->peer_self->rmap_type = 0;
3645
paul718e3742002-12-13 20:15:29 +00003646 if (ret == RMAP_DENYMATCH)
3647 {
3648 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00003649 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003650
3651 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003652 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003653 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003654 bgp_static_withdraw (bgp, p, afi, safi);
3655 return;
3656 }
paul286e1e72003-08-08 00:24:31 +00003657 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003658 }
paul286e1e72003-08-08 00:24:31 +00003659 else
3660 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00003661
3662 for (ri = rn->info; ri; ri = ri->next)
3663 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3664 && ri->sub_type == BGP_ROUTE_STATIC)
3665 break;
3666
3667 if (ri)
3668 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003669 if (attrhash_cmp (ri->attr, attr_new) &&
3670 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00003671 {
3672 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003673 bgp_attr_unintern (&attr_new);
3674 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003675 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003676 return;
3677 }
3678 else
3679 {
3680 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003681 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00003682
3683 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003684 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3685 bgp_info_restore(rn, ri);
3686 else
3687 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003688 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00003689 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003690 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003691
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003692 /* Nexthop reachability check. */
3693 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3694 {
3695 if (bgp_find_or_add_nexthop (afi, ri, NULL, 0))
3696 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
3697 else
3698 {
3699 if (BGP_DEBUG(nht, NHT))
3700 {
3701 char buf1[INET6_ADDRSTRLEN];
3702 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3703 buf1, INET6_ADDRSTRLEN);
3704 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3705 }
3706 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
3707 }
3708 }
paul718e3742002-12-13 20:15:29 +00003709 /* Process change. */
3710 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3711 bgp_process (bgp, rn, afi, safi);
3712 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003713 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003714 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003715 return;
3716 }
3717 }
3718
3719 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003720 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new,
3721 rn);
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003722 /* Nexthop reachability check. */
3723 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3724 {
3725 if (bgp_find_or_add_nexthop (afi, new, NULL, 0))
3726 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
3727 else
3728 {
3729 if (BGP_DEBUG(nht, NHT))
3730 {
3731 char buf1[INET6_ADDRSTRLEN];
3732 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1,
3733 INET6_ADDRSTRLEN);
3734 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3735 }
3736 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
3737 }
3738 }
3739 else
3740 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00003741
3742 /* Aggregate address increment. */
3743 bgp_aggregate_increment (bgp, p, new, afi, safi);
3744
3745 /* Register new BGP information. */
3746 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003747
3748 /* route_node_get lock */
3749 bgp_unlock_node (rn);
3750
paul718e3742002-12-13 20:15:29 +00003751 /* Process change. */
3752 bgp_process (bgp, rn, afi, safi);
3753
3754 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003755 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003756 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003757}
3758
3759void
paulfee0f4c2004-09-13 05:12:46 +00003760bgp_static_update (struct bgp *bgp, struct prefix *p,
3761 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3762{
3763 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00003764 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00003765
3766 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3767
paul1eb8ef22005-04-07 07:30:20 +00003768 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00003769 {
Paul Jakmada5b30f2006-05-08 14:37:17 +00003770 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3771 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003772 }
3773}
3774
paul718e3742002-12-13 20:15:29 +00003775void
3776bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3777 safi_t safi)
3778{
3779 struct bgp_node *rn;
3780 struct bgp_info *ri;
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003781 struct bgp_info *new;
paul718e3742002-12-13 20:15:29 +00003782
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003783 /* Make new BGP info. */
3784 rn = bgp_node_get (bgp->rib[afi][safi], p);
3785 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
3786 bgp_attr_default_intern(BGP_ORIGIN_IGP), rn);
3787
3788 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00003789
3790 /* Check selected route and self inserted route. */
3791 for (ri = rn->info; ri; ri = ri->next)
3792 if (ri->peer == bgp->peer_self
3793 && ri->type == ZEBRA_ROUTE_BGP
3794 && ri->sub_type == BGP_ROUTE_STATIC)
3795 break;
3796
3797 /* Withdraw static BGP route from routing table. */
3798 if (ri)
3799 {
3800 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003801 bgp_unlink_nexthop(ri);
paul718e3742002-12-13 20:15:29 +00003802 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003803 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003804 }
3805
3806 /* Unlock bgp_node_lookup. */
3807 bgp_unlock_node (rn);
3808}
3809
3810void
paulfee0f4c2004-09-13 05:12:46 +00003811bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3812{
3813 struct bgp_static *bgp_static;
3814 struct bgp *bgp;
3815 struct bgp_node *rn;
3816 struct prefix *p;
3817
3818 bgp = rsclient->bgp;
3819
3820 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3821 if ((bgp_static = rn->info) != NULL)
3822 {
3823 p = &rn->p;
3824
3825 bgp_static_update_rsclient (rsclient, p, bgp_static,
3826 afi, safi);
3827 }
3828}
3829
Lou Bergera76d9ca2016-01-12 13:41:53 -05003830/*
3831 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3832 */
paul94f2b392005-06-28 12:44:16 +00003833static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003834bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3835 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003836{
3837 struct bgp_node *rn;
3838 struct bgp_info *ri;
3839
paulfee0f4c2004-09-13 05:12:46 +00003840 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003841
3842 /* Check selected route and self inserted route. */
3843 for (ri = rn->info; ri; ri = ri->next)
3844 if (ri->peer == bgp->peer_self
3845 && ri->type == ZEBRA_ROUTE_BGP
3846 && ri->sub_type == BGP_ROUTE_STATIC)
3847 break;
3848
3849 /* Withdraw static BGP route from routing table. */
3850 if (ri)
3851 {
3852 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003853 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003854 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003855 }
3856
3857 /* Unlock bgp_node_lookup. */
3858 bgp_unlock_node (rn);
3859}
3860
Lou Bergera76d9ca2016-01-12 13:41:53 -05003861static void
3862bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3863 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3864{
3865 struct bgp_node *rn;
3866 struct bgp_info *new;
3867 struct attr *attr_new;
3868 struct attr attr = { 0 };
3869 struct bgp_info *ri;
3870
3871 assert (bgp_static);
3872
3873 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3874
3875 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3876
3877 attr.nexthop = bgp_static->igpnexthop;
3878 attr.med = bgp_static->igpmetric;
3879 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3880
3881 /* Apply route-map. */
3882 if (bgp_static->rmap.name)
3883 {
3884 struct attr attr_tmp = attr;
3885 struct bgp_info info;
3886 int ret;
3887
3888 info.peer = bgp->peer_self;
3889 info.attr = &attr_tmp;
3890
3891 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3892
3893 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3894
3895 bgp->peer_self->rmap_type = 0;
3896
3897 if (ret == RMAP_DENYMATCH)
3898 {
3899 /* Free uninterned attribute. */
3900 bgp_attr_flush (&attr_tmp);
3901
3902 /* Unintern original. */
3903 aspath_unintern (&attr.aspath);
3904 bgp_attr_extra_free (&attr);
3905 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3906 bgp_static->tag);
3907 return;
3908 }
3909
3910 attr_new = bgp_attr_intern (&attr_tmp);
3911 }
3912 else
3913 {
3914 attr_new = bgp_attr_intern (&attr);
3915 }
3916
3917 for (ri = rn->info; ri; ri = ri->next)
3918 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3919 && ri->sub_type == BGP_ROUTE_STATIC)
3920 break;
3921
3922 if (ri)
3923 {
3924 if (attrhash_cmp (ri->attr, attr_new) &&
3925 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3926 {
3927 bgp_unlock_node (rn);
3928 bgp_attr_unintern (&attr_new);
3929 aspath_unintern (&attr.aspath);
3930 bgp_attr_extra_free (&attr);
3931 return;
3932 }
3933 else
3934 {
3935 /* The attribute is changed. */
3936 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3937
3938 /* Rewrite BGP route information. */
3939 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3940 bgp_info_restore(rn, ri);
3941 else
3942 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3943 bgp_attr_unintern (&ri->attr);
3944 ri->attr = attr_new;
3945 ri->uptime = bgp_clock ();
3946
3947 /* Process change. */
3948 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3949 bgp_process (bgp, rn, afi, safi);
3950 bgp_unlock_node (rn);
3951 aspath_unintern (&attr.aspath);
3952 bgp_attr_extra_free (&attr);
3953 return;
3954 }
3955 }
3956
3957
3958 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003959 new = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
3960 attr_new, rn);
Lou Bergera76d9ca2016-01-12 13:41:53 -05003961 SET_FLAG (new->flags, BGP_INFO_VALID);
Lou Bergera76d9ca2016-01-12 13:41:53 -05003962 new->extra = bgp_info_extra_new();
3963 memcpy (new->extra->tag, bgp_static->tag, 3);
3964
3965 /* Aggregate address increment. */
3966 bgp_aggregate_increment (bgp, p, new, afi, safi);
3967
3968 /* Register new BGP information. */
3969 bgp_info_add (rn, new);
3970
3971 /* route_node_get lock */
3972 bgp_unlock_node (rn);
3973
3974 /* Process change. */
3975 bgp_process (bgp, rn, afi, safi);
3976
3977 /* Unintern original. */
3978 aspath_unintern (&attr.aspath);
3979 bgp_attr_extra_free (&attr);
3980}
3981
paul718e3742002-12-13 20:15:29 +00003982/* Configure static BGP network. When user don't run zebra, static
3983 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003984static int
paulfd79ac92004-10-13 05:06:08 +00003985bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003986 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003987{
3988 int ret;
3989 struct prefix p;
3990 struct bgp_static *bgp_static;
3991 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003992 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003993
3994 /* Convert IP prefix string to struct prefix. */
3995 ret = str2prefix (ip_str, &p);
3996 if (! ret)
3997 {
3998 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3999 return CMD_WARNING;
4000 }
paul718e3742002-12-13 20:15:29 +00004001 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4002 {
4003 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4004 VTY_NEWLINE);
4005 return CMD_WARNING;
4006 }
paul718e3742002-12-13 20:15:29 +00004007
4008 apply_mask (&p);
4009
4010 /* Set BGP static route configuration. */
4011 rn = bgp_node_get (bgp->route[afi][safi], &p);
4012
4013 if (rn->info)
4014 {
4015 /* Configuration change. */
4016 bgp_static = rn->info;
4017
4018 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004019 if (bgp_static->valid && bgp_static->backdoor != backdoor)
4020 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00004021
paul718e3742002-12-13 20:15:29 +00004022 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00004023
paul718e3742002-12-13 20:15:29 +00004024 if (rmap)
4025 {
4026 if (bgp_static->rmap.name)
4027 free (bgp_static->rmap.name);
4028 bgp_static->rmap.name = strdup (rmap);
4029 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4030 }
4031 else
4032 {
4033 if (bgp_static->rmap.name)
4034 free (bgp_static->rmap.name);
4035 bgp_static->rmap.name = NULL;
4036 bgp_static->rmap.map = NULL;
4037 bgp_static->valid = 0;
4038 }
4039 bgp_unlock_node (rn);
4040 }
4041 else
4042 {
4043 /* New configuration. */
4044 bgp_static = bgp_static_new ();
4045 bgp_static->backdoor = backdoor;
4046 bgp_static->valid = 0;
4047 bgp_static->igpmetric = 0;
4048 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00004049
paul718e3742002-12-13 20:15:29 +00004050 if (rmap)
4051 {
4052 if (bgp_static->rmap.name)
4053 free (bgp_static->rmap.name);
4054 bgp_static->rmap.name = strdup (rmap);
4055 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4056 }
4057 rn->info = bgp_static;
4058 }
4059
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07004060 bgp_static->valid = 1;
4061 if (need_update)
4062 bgp_static_withdraw (bgp, &p, afi, safi);
paul718e3742002-12-13 20:15:29 +00004063
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07004064 if (! bgp_static->backdoor)
4065 bgp_static_update (bgp, &p, bgp_static, afi, safi);
paul718e3742002-12-13 20:15:29 +00004066
4067 return CMD_SUCCESS;
4068}
4069
4070/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00004071static int
paulfd79ac92004-10-13 05:06:08 +00004072bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004073 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004074{
4075 int ret;
4076 struct prefix p;
4077 struct bgp_static *bgp_static;
4078 struct bgp_node *rn;
4079
4080 /* Convert IP prefix string to struct prefix. */
4081 ret = str2prefix (ip_str, &p);
4082 if (! ret)
4083 {
4084 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4085 return CMD_WARNING;
4086 }
paul718e3742002-12-13 20:15:29 +00004087 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4088 {
4089 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4090 VTY_NEWLINE);
4091 return CMD_WARNING;
4092 }
paul718e3742002-12-13 20:15:29 +00004093
4094 apply_mask (&p);
4095
4096 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4097 if (! rn)
4098 {
4099 vty_out (vty, "%% Can't find specified static route configuration.%s",
4100 VTY_NEWLINE);
4101 return CMD_WARNING;
4102 }
4103
4104 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004105
paul718e3742002-12-13 20:15:29 +00004106 /* Update BGP RIB. */
4107 if (! bgp_static->backdoor)
4108 bgp_static_withdraw (bgp, &p, afi, safi);
4109
4110 /* Clear configuration. */
4111 bgp_static_free (bgp_static);
4112 rn->info = NULL;
4113 bgp_unlock_node (rn);
4114 bgp_unlock_node (rn);
4115
4116 return CMD_SUCCESS;
4117}
4118
4119/* Called from bgp_delete(). Delete all static routes from the BGP
4120 instance. */
4121void
4122bgp_static_delete (struct bgp *bgp)
4123{
4124 afi_t afi;
4125 safi_t safi;
4126 struct bgp_node *rn;
4127 struct bgp_node *rm;
4128 struct bgp_table *table;
4129 struct bgp_static *bgp_static;
4130
4131 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4132 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4133 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4134 if (rn->info != NULL)
4135 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004136 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004137 {
4138 table = rn->info;
4139
4140 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4141 {
4142 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004143 bgp_static_withdraw_safi (bgp, &rm->p,
4144 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004145 (struct prefix_rd *)&rn->p,
4146 bgp_static->tag);
4147 bgp_static_free (bgp_static);
4148 rn->info = NULL;
4149 bgp_unlock_node (rn);
4150 }
4151 }
4152 else
4153 {
4154 bgp_static = rn->info;
4155 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4156 bgp_static_free (bgp_static);
4157 rn->info = NULL;
4158 bgp_unlock_node (rn);
4159 }
4160 }
4161}
4162
Lou Bergera76d9ca2016-01-12 13:41:53 -05004163/*
4164 * gpz 110624
4165 * Currently this is used to set static routes for VPN and ENCAP.
4166 * I think it can probably be factored with bgp_static_set.
4167 */
paul718e3742002-12-13 20:15:29 +00004168int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004169bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4170 const char *rd_str, const char *tag_str,
4171 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004172{
4173 int ret;
4174 struct prefix p;
4175 struct prefix_rd prd;
4176 struct bgp *bgp;
4177 struct bgp_node *prn;
4178 struct bgp_node *rn;
4179 struct bgp_table *table;
4180 struct bgp_static *bgp_static;
4181 u_char tag[3];
4182
4183 bgp = vty->index;
4184
4185 ret = str2prefix (ip_str, &p);
4186 if (! ret)
4187 {
4188 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4189 return CMD_WARNING;
4190 }
4191 apply_mask (&p);
4192
4193 ret = str2prefix_rd (rd_str, &prd);
4194 if (! ret)
4195 {
4196 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4197 return CMD_WARNING;
4198 }
4199
4200 ret = str2tag (tag_str, tag);
4201 if (! ret)
4202 {
4203 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4204 return CMD_WARNING;
4205 }
4206
Lou Bergera76d9ca2016-01-12 13:41:53 -05004207 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004208 (struct prefix *)&prd);
4209 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004210 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004211 else
4212 bgp_unlock_node (prn);
4213 table = prn->info;
4214
4215 rn = bgp_node_get (table, &p);
4216
4217 if (rn->info)
4218 {
4219 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4220 bgp_unlock_node (rn);
4221 }
4222 else
4223 {
4224 /* New configuration. */
4225 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004226 bgp_static->backdoor = 0;
4227 bgp_static->valid = 0;
4228 bgp_static->igpmetric = 0;
4229 bgp_static->igpnexthop.s_addr = 0;
4230 memcpy(bgp_static->tag, tag, 3);
4231 bgp_static->prd = prd;
4232
4233 if (rmap_str)
4234 {
4235 if (bgp_static->rmap.name)
4236 free (bgp_static->rmap.name);
4237 bgp_static->rmap.name = strdup (rmap_str);
4238 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4239 }
paul718e3742002-12-13 20:15:29 +00004240 rn->info = bgp_static;
4241
Lou Bergera76d9ca2016-01-12 13:41:53 -05004242 bgp_static->valid = 1;
4243 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004244 }
4245
4246 return CMD_SUCCESS;
4247}
4248
4249/* Configure static BGP network. */
4250int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004251bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4252 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004253{
4254 int ret;
4255 struct bgp *bgp;
4256 struct prefix p;
4257 struct prefix_rd prd;
4258 struct bgp_node *prn;
4259 struct bgp_node *rn;
4260 struct bgp_table *table;
4261 struct bgp_static *bgp_static;
4262 u_char tag[3];
4263
4264 bgp = vty->index;
4265
4266 /* Convert IP prefix string to struct prefix. */
4267 ret = str2prefix (ip_str, &p);
4268 if (! ret)
4269 {
4270 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4271 return CMD_WARNING;
4272 }
4273 apply_mask (&p);
4274
4275 ret = str2prefix_rd (rd_str, &prd);
4276 if (! ret)
4277 {
4278 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4279 return CMD_WARNING;
4280 }
4281
4282 ret = str2tag (tag_str, tag);
4283 if (! ret)
4284 {
4285 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4286 return CMD_WARNING;
4287 }
4288
Lou Bergera76d9ca2016-01-12 13:41:53 -05004289 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004290 (struct prefix *)&prd);
4291 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004292 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004293 else
4294 bgp_unlock_node (prn);
4295 table = prn->info;
4296
4297 rn = bgp_node_lookup (table, &p);
4298
4299 if (rn)
4300 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004301 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004302
4303 bgp_static = rn->info;
4304 bgp_static_free (bgp_static);
4305 rn->info = NULL;
4306 bgp_unlock_node (rn);
4307 bgp_unlock_node (rn);
4308 }
4309 else
4310 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4311
4312 return CMD_SUCCESS;
4313}
David Lamparter6b0655a2014-06-04 06:53:35 +02004314
paul718e3742002-12-13 20:15:29 +00004315DEFUN (bgp_network,
4316 bgp_network_cmd,
4317 "network A.B.C.D/M",
4318 "Specify a network to announce via BGP\n"
4319 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4320{
4321 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004322 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004323}
4324
4325DEFUN (bgp_network_route_map,
4326 bgp_network_route_map_cmd,
4327 "network A.B.C.D/M route-map WORD",
4328 "Specify a network to announce via BGP\n"
4329 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4330 "Route-map to modify the attributes\n"
4331 "Name of the route map\n")
4332{
4333 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004334 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004335}
4336
4337DEFUN (bgp_network_backdoor,
4338 bgp_network_backdoor_cmd,
4339 "network A.B.C.D/M backdoor",
4340 "Specify a network to announce via BGP\n"
4341 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4342 "Specify a BGP backdoor route\n")
4343{
Paul Jakma41367172007-08-06 15:24:51 +00004344 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004345 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004346}
4347
4348DEFUN (bgp_network_mask,
4349 bgp_network_mask_cmd,
4350 "network A.B.C.D mask A.B.C.D",
4351 "Specify a network to announce via BGP\n"
4352 "Network number\n"
4353 "Network mask\n"
4354 "Network mask\n")
4355{
4356 int ret;
4357 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004358
paul718e3742002-12-13 20:15:29 +00004359 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4360 if (! ret)
4361 {
4362 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4363 return CMD_WARNING;
4364 }
4365
4366 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004367 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004368}
4369
4370DEFUN (bgp_network_mask_route_map,
4371 bgp_network_mask_route_map_cmd,
4372 "network A.B.C.D mask A.B.C.D route-map WORD",
4373 "Specify a network to announce via BGP\n"
4374 "Network number\n"
4375 "Network mask\n"
4376 "Network mask\n"
4377 "Route-map to modify the attributes\n"
4378 "Name of the route map\n")
4379{
4380 int ret;
4381 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004382
paul718e3742002-12-13 20:15:29 +00004383 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4384 if (! ret)
4385 {
4386 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4387 return CMD_WARNING;
4388 }
4389
4390 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004391 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004392}
4393
4394DEFUN (bgp_network_mask_backdoor,
4395 bgp_network_mask_backdoor_cmd,
4396 "network A.B.C.D mask A.B.C.D backdoor",
4397 "Specify a network to announce via BGP\n"
4398 "Network number\n"
4399 "Network mask\n"
4400 "Network mask\n"
4401 "Specify a BGP backdoor route\n")
4402{
4403 int ret;
4404 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004405
paul718e3742002-12-13 20:15:29 +00004406 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4407 if (! ret)
4408 {
4409 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4410 return CMD_WARNING;
4411 }
4412
Paul Jakma41367172007-08-06 15:24:51 +00004413 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004414 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004415}
4416
4417DEFUN (bgp_network_mask_natural,
4418 bgp_network_mask_natural_cmd,
4419 "network A.B.C.D",
4420 "Specify a network to announce via BGP\n"
4421 "Network number\n")
4422{
4423 int ret;
4424 char prefix_str[BUFSIZ];
4425
4426 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4427 if (! ret)
4428 {
4429 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4430 return CMD_WARNING;
4431 }
4432
4433 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004434 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004435}
4436
4437DEFUN (bgp_network_mask_natural_route_map,
4438 bgp_network_mask_natural_route_map_cmd,
4439 "network A.B.C.D route-map WORD",
4440 "Specify a network to announce via BGP\n"
4441 "Network number\n"
4442 "Route-map to modify the attributes\n"
4443 "Name of the route map\n")
4444{
4445 int ret;
4446 char prefix_str[BUFSIZ];
4447
4448 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4449 if (! ret)
4450 {
4451 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4452 return CMD_WARNING;
4453 }
4454
4455 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004456 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004457}
4458
4459DEFUN (bgp_network_mask_natural_backdoor,
4460 bgp_network_mask_natural_backdoor_cmd,
4461 "network A.B.C.D backdoor",
4462 "Specify a network to announce via BGP\n"
4463 "Network number\n"
4464 "Specify a BGP backdoor route\n")
4465{
4466 int ret;
4467 char prefix_str[BUFSIZ];
4468
4469 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4470 if (! ret)
4471 {
4472 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4473 return CMD_WARNING;
4474 }
4475
Paul Jakma41367172007-08-06 15:24:51 +00004476 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004477 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004478}
4479
4480DEFUN (no_bgp_network,
4481 no_bgp_network_cmd,
4482 "no network A.B.C.D/M",
4483 NO_STR
4484 "Specify a network to announce via BGP\n"
4485 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4486{
4487 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4488 bgp_node_safi (vty));
4489}
4490
4491ALIAS (no_bgp_network,
4492 no_bgp_network_route_map_cmd,
4493 "no network A.B.C.D/M route-map WORD",
4494 NO_STR
4495 "Specify a network to announce via BGP\n"
4496 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4497 "Route-map to modify the attributes\n"
4498 "Name of the route map\n")
4499
4500ALIAS (no_bgp_network,
4501 no_bgp_network_backdoor_cmd,
4502 "no network A.B.C.D/M backdoor",
4503 NO_STR
4504 "Specify a network to announce via BGP\n"
4505 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4506 "Specify a BGP backdoor route\n")
4507
4508DEFUN (no_bgp_network_mask,
4509 no_bgp_network_mask_cmd,
4510 "no network A.B.C.D mask A.B.C.D",
4511 NO_STR
4512 "Specify a network to announce via BGP\n"
4513 "Network number\n"
4514 "Network mask\n"
4515 "Network mask\n")
4516{
4517 int ret;
4518 char prefix_str[BUFSIZ];
4519
4520 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4521 if (! ret)
4522 {
4523 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4524 return CMD_WARNING;
4525 }
4526
4527 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4528 bgp_node_safi (vty));
4529}
4530
4531ALIAS (no_bgp_network_mask,
4532 no_bgp_network_mask_route_map_cmd,
4533 "no network A.B.C.D mask A.B.C.D route-map WORD",
4534 NO_STR
4535 "Specify a network to announce via BGP\n"
4536 "Network number\n"
4537 "Network mask\n"
4538 "Network mask\n"
4539 "Route-map to modify the attributes\n"
4540 "Name of the route map\n")
4541
4542ALIAS (no_bgp_network_mask,
4543 no_bgp_network_mask_backdoor_cmd,
4544 "no network A.B.C.D mask A.B.C.D backdoor",
4545 NO_STR
4546 "Specify a network to announce via BGP\n"
4547 "Network number\n"
4548 "Network mask\n"
4549 "Network mask\n"
4550 "Specify a BGP backdoor route\n")
4551
4552DEFUN (no_bgp_network_mask_natural,
4553 no_bgp_network_mask_natural_cmd,
4554 "no network A.B.C.D",
4555 NO_STR
4556 "Specify a network to announce via BGP\n"
4557 "Network number\n")
4558{
4559 int ret;
4560 char prefix_str[BUFSIZ];
4561
4562 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4563 if (! ret)
4564 {
4565 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4566 return CMD_WARNING;
4567 }
4568
4569 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4570 bgp_node_safi (vty));
4571}
4572
4573ALIAS (no_bgp_network_mask_natural,
4574 no_bgp_network_mask_natural_route_map_cmd,
4575 "no network A.B.C.D route-map WORD",
4576 NO_STR
4577 "Specify a network to announce via BGP\n"
4578 "Network number\n"
4579 "Route-map to modify the attributes\n"
4580 "Name of the route map\n")
4581
4582ALIAS (no_bgp_network_mask_natural,
4583 no_bgp_network_mask_natural_backdoor_cmd,
4584 "no network A.B.C.D backdoor",
4585 NO_STR
4586 "Specify a network to announce via BGP\n"
4587 "Network number\n"
4588 "Specify a BGP backdoor route\n")
4589
paul718e3742002-12-13 20:15:29 +00004590DEFUN (ipv6_bgp_network,
4591 ipv6_bgp_network_cmd,
4592 "network X:X::X:X/M",
4593 "Specify a network to announce via BGP\n"
4594 "IPv6 prefix <network>/<length>\n")
4595{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304596 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004597 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004598}
4599
4600DEFUN (ipv6_bgp_network_route_map,
4601 ipv6_bgp_network_route_map_cmd,
4602 "network X:X::X:X/M route-map WORD",
4603 "Specify a network to announce via BGP\n"
4604 "IPv6 prefix <network>/<length>\n"
4605 "Route-map to modify the attributes\n"
4606 "Name of the route map\n")
4607{
4608 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004609 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004610}
4611
4612DEFUN (no_ipv6_bgp_network,
4613 no_ipv6_bgp_network_cmd,
4614 "no network X:X::X:X/M",
4615 NO_STR
4616 "Specify a network to announce via BGP\n"
4617 "IPv6 prefix <network>/<length>\n")
4618{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304619 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004620}
4621
4622ALIAS (no_ipv6_bgp_network,
4623 no_ipv6_bgp_network_route_map_cmd,
4624 "no network X:X::X:X/M route-map WORD",
4625 NO_STR
4626 "Specify a network to announce via BGP\n"
4627 "IPv6 prefix <network>/<length>\n"
4628 "Route-map to modify the attributes\n"
4629 "Name of the route map\n")
4630
4631ALIAS (ipv6_bgp_network,
4632 old_ipv6_bgp_network_cmd,
4633 "ipv6 bgp network X:X::X:X/M",
4634 IPV6_STR
4635 BGP_STR
4636 "Specify a network to announce via BGP\n"
4637 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4638
4639ALIAS (no_ipv6_bgp_network,
4640 old_no_ipv6_bgp_network_cmd,
4641 "no ipv6 bgp network X:X::X:X/M",
4642 NO_STR
4643 IPV6_STR
4644 BGP_STR
4645 "Specify a network to announce via BGP\n"
4646 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004647
4648/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4649ALIAS_DEPRECATED (bgp_network,
4650 bgp_network_ttl_cmd,
4651 "network A.B.C.D/M pathlimit <0-255>",
4652 "Specify a network to announce via BGP\n"
4653 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4654 "AS-Path hopcount limit attribute\n"
4655 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4656ALIAS_DEPRECATED (bgp_network_backdoor,
4657 bgp_network_backdoor_ttl_cmd,
4658 "network A.B.C.D/M backdoor pathlimit <0-255>",
4659 "Specify a network to announce via BGP\n"
4660 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4661 "Specify a BGP backdoor route\n"
4662 "AS-Path hopcount limit attribute\n"
4663 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4664ALIAS_DEPRECATED (bgp_network_mask,
4665 bgp_network_mask_ttl_cmd,
4666 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4667 "Specify a network to announce via BGP\n"
4668 "Network number\n"
4669 "Network mask\n"
4670 "Network mask\n"
4671 "AS-Path hopcount limit attribute\n"
4672 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4673ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4674 bgp_network_mask_backdoor_ttl_cmd,
4675 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4676 "Specify a network to announce via BGP\n"
4677 "Network number\n"
4678 "Network mask\n"
4679 "Network mask\n"
4680 "Specify a BGP backdoor route\n"
4681 "AS-Path hopcount limit attribute\n"
4682 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4683ALIAS_DEPRECATED (bgp_network_mask_natural,
4684 bgp_network_mask_natural_ttl_cmd,
4685 "network A.B.C.D pathlimit <0-255>",
4686 "Specify a network to announce via BGP\n"
4687 "Network number\n"
4688 "AS-Path hopcount limit attribute\n"
4689 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4690ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4691 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004692 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004693 "Specify a network to announce via BGP\n"
4694 "Network number\n"
4695 "Specify a BGP backdoor route\n"
4696 "AS-Path hopcount limit attribute\n"
4697 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4698ALIAS_DEPRECATED (no_bgp_network,
4699 no_bgp_network_ttl_cmd,
4700 "no network A.B.C.D/M pathlimit <0-255>",
4701 NO_STR
4702 "Specify a network to announce via BGP\n"
4703 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4704 "AS-Path hopcount limit attribute\n"
4705 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4706ALIAS_DEPRECATED (no_bgp_network,
4707 no_bgp_network_backdoor_ttl_cmd,
4708 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4709 NO_STR
4710 "Specify a network to announce via BGP\n"
4711 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4712 "Specify a BGP backdoor route\n"
4713 "AS-Path hopcount limit attribute\n"
4714 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4715ALIAS_DEPRECATED (no_bgp_network,
4716 no_bgp_network_mask_ttl_cmd,
4717 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4718 NO_STR
4719 "Specify a network to announce via BGP\n"
4720 "Network number\n"
4721 "Network mask\n"
4722 "Network mask\n"
4723 "AS-Path hopcount limit attribute\n"
4724 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4725ALIAS_DEPRECATED (no_bgp_network_mask,
4726 no_bgp_network_mask_backdoor_ttl_cmd,
4727 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4728 NO_STR
4729 "Specify a network to announce via BGP\n"
4730 "Network number\n"
4731 "Network mask\n"
4732 "Network mask\n"
4733 "Specify a BGP backdoor route\n"
4734 "AS-Path hopcount limit attribute\n"
4735 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4736ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4737 no_bgp_network_mask_natural_ttl_cmd,
4738 "no network A.B.C.D pathlimit <0-255>",
4739 NO_STR
4740 "Specify a network to announce via BGP\n"
4741 "Network number\n"
4742 "AS-Path hopcount limit attribute\n"
4743 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4744ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4745 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4746 "no network A.B.C.D backdoor pathlimit <0-255>",
4747 NO_STR
4748 "Specify a network to announce via BGP\n"
4749 "Network number\n"
4750 "Specify a BGP backdoor route\n"
4751 "AS-Path hopcount limit attribute\n"
4752 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4753ALIAS_DEPRECATED (ipv6_bgp_network,
4754 ipv6_bgp_network_ttl_cmd,
4755 "network X:X::X:X/M pathlimit <0-255>",
4756 "Specify a network to announce via BGP\n"
4757 "IPv6 prefix <network>/<length>\n"
4758 "AS-Path hopcount limit attribute\n"
4759 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4760ALIAS_DEPRECATED (no_ipv6_bgp_network,
4761 no_ipv6_bgp_network_ttl_cmd,
4762 "no network X:X::X:X/M pathlimit <0-255>",
4763 NO_STR
4764 "Specify a network to announce via BGP\n"
4765 "IPv6 prefix <network>/<length>\n"
4766 "AS-Path hopcount limit attribute\n"
4767 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004768
paul718e3742002-12-13 20:15:29 +00004769/* Aggreagete address:
4770
4771 advertise-map Set condition to advertise attribute
4772 as-set Generate AS set path information
4773 attribute-map Set attributes of aggregate
4774 route-map Set parameters of aggregate
4775 summary-only Filter more specific routes from updates
4776 suppress-map Conditionally filter more specific routes from updates
4777 <cr>
4778 */
4779struct bgp_aggregate
4780{
4781 /* Summary-only flag. */
4782 u_char summary_only;
4783
4784 /* AS set generation. */
4785 u_char as_set;
4786
4787 /* Route-map for aggregated route. */
4788 struct route_map *map;
4789
4790 /* Suppress-count. */
4791 unsigned long count;
4792
4793 /* SAFI configuration. */
4794 safi_t safi;
4795};
4796
paul94f2b392005-06-28 12:44:16 +00004797static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004798bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004799{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004800 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004801}
4802
paul94f2b392005-06-28 12:44:16 +00004803static void
paul718e3742002-12-13 20:15:29 +00004804bgp_aggregate_free (struct bgp_aggregate *aggregate)
4805{
4806 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4807}
4808
Daniel Walton76a72802015-05-19 17:47:24 -07004809/* Update an aggregate as routes are added/removed from the BGP table */
paul94f2b392005-06-28 12:44:16 +00004810static void
paul718e3742002-12-13 20:15:29 +00004811bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4812 afi_t afi, safi_t safi, struct bgp_info *del,
4813 struct bgp_aggregate *aggregate)
4814{
4815 struct bgp_table *table;
4816 struct bgp_node *top;
4817 struct bgp_node *rn;
4818 u_char origin;
4819 struct aspath *aspath = NULL;
4820 struct aspath *asmerge = NULL;
4821 struct community *community = NULL;
4822 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004823 struct bgp_info *ri;
4824 struct bgp_info *new;
4825 int first = 1;
4826 unsigned long match = 0;
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004827 u_char atomic_aggregate = 0;
paul718e3742002-12-13 20:15:29 +00004828
paul718e3742002-12-13 20:15:29 +00004829 /* ORIGIN attribute: If at least one route among routes that are
4830 aggregated has ORIGIN with the value INCOMPLETE, then the
4831 aggregated route must have the ORIGIN attribute with the value
4832 INCOMPLETE. Otherwise, if at least one route among routes that
4833 are aggregated has ORIGIN with the value EGP, then the aggregated
4834 route must have the origin attribute with the value EGP. In all
4835 other case the value of the ORIGIN attribute of the aggregated
4836 route is INTERNAL. */
4837 origin = BGP_ORIGIN_IGP;
4838
4839 table = bgp->rib[afi][safi];
4840
4841 top = bgp_node_get (table, p);
4842 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4843 if (rn->p.prefixlen > p->prefixlen)
4844 {
4845 match = 0;
4846
4847 for (ri = rn->info; ri; ri = ri->next)
4848 {
4849 if (BGP_INFO_HOLDDOWN (ri))
4850 continue;
4851
4852 if (del && ri == del)
4853 continue;
4854
4855 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004856 first = 0;
paul718e3742002-12-13 20:15:29 +00004857
4858#ifdef AGGREGATE_NEXTHOP_CHECK
4859 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4860 || ri->attr->med != med)
4861 {
4862 if (aspath)
4863 aspath_free (aspath);
4864 if (community)
4865 community_free (community);
4866 bgp_unlock_node (rn);
4867 bgp_unlock_node (top);
4868 return;
4869 }
4870#endif /* AGGREGATE_NEXTHOP_CHECK */
4871
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004872 if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
4873 atomic_aggregate = 1;
4874
paul718e3742002-12-13 20:15:29 +00004875 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4876 {
4877 if (aggregate->summary_only)
4878 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004879 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004880 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004881 match++;
4882 }
4883
4884 aggregate->count++;
4885
Daniel Walton76a72802015-05-19 17:47:24 -07004886 if (origin < ri->attr->origin)
4887 origin = ri->attr->origin;
4888
paul718e3742002-12-13 20:15:29 +00004889 if (aggregate->as_set)
4890 {
paul718e3742002-12-13 20:15:29 +00004891 if (aspath)
4892 {
4893 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4894 aspath_free (aspath);
4895 aspath = asmerge;
4896 }
4897 else
4898 aspath = aspath_dup (ri->attr->aspath);
4899
4900 if (ri->attr->community)
4901 {
4902 if (community)
4903 {
4904 commerge = community_merge (community,
4905 ri->attr->community);
4906 community = community_uniq_sort (commerge);
4907 community_free (commerge);
4908 }
4909 else
4910 community = community_dup (ri->attr->community);
4911 }
4912 }
4913 }
4914 }
4915 if (match)
4916 bgp_process (bgp, rn, afi, safi);
4917 }
4918 bgp_unlock_node (top);
4919
4920 if (rinew)
4921 {
4922 aggregate->count++;
4923
4924 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004925 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004926
Daniel Walton76a72802015-05-19 17:47:24 -07004927 if (origin < rinew->attr->origin)
4928 origin = rinew->attr->origin;
4929
paul718e3742002-12-13 20:15:29 +00004930 if (aggregate->as_set)
4931 {
paul718e3742002-12-13 20:15:29 +00004932 if (aspath)
4933 {
4934 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4935 aspath_free (aspath);
4936 aspath = asmerge;
4937 }
4938 else
4939 aspath = aspath_dup (rinew->attr->aspath);
4940
4941 if (rinew->attr->community)
4942 {
4943 if (community)
4944 {
4945 commerge = community_merge (community,
4946 rinew->attr->community);
4947 community = community_uniq_sort (commerge);
4948 community_free (commerge);
4949 }
4950 else
4951 community = community_dup (rinew->attr->community);
4952 }
4953 }
4954 }
4955
4956 if (aggregate->count > 0)
4957 {
4958 rn = bgp_node_get (table, p);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05004959 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
4960 bgp_attr_aggregate_intern(bgp, origin, aspath, community,
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004961 aggregate->as_set,
4962 atomic_aggregate), rn);
paul718e3742002-12-13 20:15:29 +00004963 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00004964
4965 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004966 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004967 bgp_process (bgp, rn, afi, safi);
4968 }
4969 else
4970 {
4971 if (aspath)
4972 aspath_free (aspath);
4973 if (community)
4974 community_free (community);
4975 }
4976}
4977
4978void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4979 struct bgp_aggregate *);
4980
4981void
4982bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4983 struct bgp_info *ri, afi_t afi, safi_t safi)
4984{
4985 struct bgp_node *child;
4986 struct bgp_node *rn;
4987 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004988 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004989
4990 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004991 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004992 return;
4993
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004994 table = bgp->aggregate[afi][safi];
4995
4996 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004997 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004998 return;
4999
paul718e3742002-12-13 20:15:29 +00005000 if (p->prefixlen == 0)
5001 return;
5002
5003 if (BGP_INFO_HOLDDOWN (ri))
5004 return;
5005
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02005006 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00005007
5008 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005009 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005010 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5011 {
5012 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005013 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00005014 }
5015 bgp_unlock_node (child);
5016}
5017
5018void
5019bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
5020 struct bgp_info *del, afi_t afi, safi_t safi)
5021{
5022 struct bgp_node *child;
5023 struct bgp_node *rn;
5024 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005025 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00005026
5027 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05005028 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00005029 return;
5030
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005031 table = bgp->aggregate[afi][safi];
5032
5033 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005034 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005035 return;
5036
paul718e3742002-12-13 20:15:29 +00005037 if (p->prefixlen == 0)
5038 return;
5039
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02005040 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00005041
5042 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005043 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005044 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5045 {
5046 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005047 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00005048 }
5049 bgp_unlock_node (child);
5050}
5051
Daniel Walton76a72802015-05-19 17:47:24 -07005052/* Called via bgp_aggregate_set when the user configures aggregate-address */
paul94f2b392005-06-28 12:44:16 +00005053static void
paul718e3742002-12-13 20:15:29 +00005054bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
5055 struct bgp_aggregate *aggregate)
5056{
5057 struct bgp_table *table;
5058 struct bgp_node *top;
5059 struct bgp_node *rn;
5060 struct bgp_info *new;
5061 struct bgp_info *ri;
5062 unsigned long match;
5063 u_char origin = BGP_ORIGIN_IGP;
5064 struct aspath *aspath = NULL;
5065 struct aspath *asmerge = NULL;
5066 struct community *community = NULL;
5067 struct community *commerge = NULL;
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005068 u_char atomic_aggregate = 0;
paul718e3742002-12-13 20:15:29 +00005069
5070 table = bgp->rib[afi][safi];
5071
5072 /* Sanity check. */
5073 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5074 return;
5075 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5076 return;
5077
5078 /* If routes exists below this node, generate aggregate routes. */
5079 top = bgp_node_get (table, p);
5080 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5081 if (rn->p.prefixlen > p->prefixlen)
5082 {
5083 match = 0;
5084
5085 for (ri = rn->info; ri; ri = ri->next)
5086 {
5087 if (BGP_INFO_HOLDDOWN (ri))
5088 continue;
5089
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005090 if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
5091 atomic_aggregate = 1;
5092
paul718e3742002-12-13 20:15:29 +00005093 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5094 {
5095 /* summary-only aggregate route suppress aggregated
5096 route announcement. */
5097 if (aggregate->summary_only)
5098 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005099 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005100 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005101 match++;
5102 }
Daniel Walton76a72802015-05-19 17:47:24 -07005103
5104 /* If at least one route among routes that are aggregated has
5105 * ORIGIN with the value INCOMPLETE, then the aggregated route
5106 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5107 * Otherwise, if at least one route among routes that are
5108 * aggregated has ORIGIN with the value EGP, then the aggregated
5109 * route MUST have the ORIGIN attribute with the value EGP.
5110 */
5111 if (origin < ri->attr->origin)
5112 origin = ri->attr->origin;
5113
paul718e3742002-12-13 20:15:29 +00005114 /* as-set aggregate route generate origin, as path,
5115 community aggregation. */
5116 if (aggregate->as_set)
5117 {
paul718e3742002-12-13 20:15:29 +00005118 if (aspath)
5119 {
5120 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5121 aspath_free (aspath);
5122 aspath = asmerge;
5123 }
5124 else
5125 aspath = aspath_dup (ri->attr->aspath);
5126
5127 if (ri->attr->community)
5128 {
5129 if (community)
5130 {
5131 commerge = community_merge (community,
5132 ri->attr->community);
5133 community = community_uniq_sort (commerge);
5134 community_free (commerge);
5135 }
5136 else
5137 community = community_dup (ri->attr->community);
5138 }
5139 }
5140 aggregate->count++;
5141 }
5142 }
5143
5144 /* If this node is suppressed, process the change. */
5145 if (match)
5146 bgp_process (bgp, rn, afi, safi);
5147 }
5148 bgp_unlock_node (top);
5149
5150 /* Add aggregate route to BGP table. */
5151 if (aggregate->count)
5152 {
5153 rn = bgp_node_get (table, p);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005154 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
5155 bgp_attr_aggregate_intern(bgp, origin, aspath, community,
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005156 aggregate->as_set,
5157 atomic_aggregate), rn);
paul718e3742002-12-13 20:15:29 +00005158 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00005159
5160 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005161 bgp_unlock_node (rn);
5162
paul718e3742002-12-13 20:15:29 +00005163 /* Process change. */
5164 bgp_process (bgp, rn, afi, safi);
5165 }
Denil Virae2a92582015-08-11 13:34:59 -07005166 else
5167 {
5168 if (aspath)
5169 aspath_free (aspath);
5170 if (community)
5171 community_free (community);
5172 }
paul718e3742002-12-13 20:15:29 +00005173}
5174
5175void
5176bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5177 safi_t safi, struct bgp_aggregate *aggregate)
5178{
5179 struct bgp_table *table;
5180 struct bgp_node *top;
5181 struct bgp_node *rn;
5182 struct bgp_info *ri;
5183 unsigned long match;
5184
5185 table = bgp->rib[afi][safi];
5186
5187 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5188 return;
5189 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5190 return;
5191
5192 /* If routes exists below this node, generate aggregate routes. */
5193 top = bgp_node_get (table, p);
5194 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5195 if (rn->p.prefixlen > p->prefixlen)
5196 {
5197 match = 0;
5198
5199 for (ri = rn->info; ri; ri = ri->next)
5200 {
5201 if (BGP_INFO_HOLDDOWN (ri))
5202 continue;
5203
5204 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5205 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005206 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005207 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005208 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005209
Paul Jakmafb982c22007-05-04 20:15:47 +00005210 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005211 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005212 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005213 match++;
5214 }
5215 }
5216 aggregate->count--;
5217 }
5218 }
5219
Paul Jakmafb982c22007-05-04 20:15:47 +00005220 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005221 if (match)
5222 bgp_process (bgp, rn, afi, safi);
5223 }
5224 bgp_unlock_node (top);
5225
5226 /* Delete aggregate route from BGP table. */
5227 rn = bgp_node_get (table, p);
5228
5229 for (ri = rn->info; ri; ri = ri->next)
5230 if (ri->peer == bgp->peer_self
5231 && ri->type == ZEBRA_ROUTE_BGP
5232 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5233 break;
5234
5235 /* Withdraw static BGP route from routing table. */
5236 if (ri)
5237 {
paul718e3742002-12-13 20:15:29 +00005238 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005239 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005240 }
5241
5242 /* Unlock bgp_node_lookup. */
5243 bgp_unlock_node (rn);
5244}
5245
5246/* Aggregate route attribute. */
5247#define AGGREGATE_SUMMARY_ONLY 1
5248#define AGGREGATE_AS_SET 1
5249
paul94f2b392005-06-28 12:44:16 +00005250static int
Robert Baysf6269b42010-08-05 10:26:28 -07005251bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5252 afi_t afi, safi_t safi)
5253{
5254 int ret;
5255 struct prefix p;
5256 struct bgp_node *rn;
5257 struct bgp *bgp;
5258 struct bgp_aggregate *aggregate;
5259
5260 /* Convert string to prefix structure. */
5261 ret = str2prefix (prefix_str, &p);
5262 if (!ret)
5263 {
5264 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5265 return CMD_WARNING;
5266 }
5267 apply_mask (&p);
5268
5269 /* Get BGP structure. */
5270 bgp = vty->index;
5271
5272 /* Old configuration check. */
5273 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5274 if (! rn)
5275 {
5276 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5277 VTY_NEWLINE);
5278 return CMD_WARNING;
5279 }
5280
5281 aggregate = rn->info;
5282 if (aggregate->safi & SAFI_UNICAST)
5283 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5284 if (aggregate->safi & SAFI_MULTICAST)
5285 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5286
5287 /* Unlock aggregate address configuration. */
5288 rn->info = NULL;
5289 bgp_aggregate_free (aggregate);
5290 bgp_unlock_node (rn);
5291 bgp_unlock_node (rn);
5292
5293 return CMD_SUCCESS;
5294}
5295
5296static int
5297bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005298 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005299 u_char summary_only, u_char as_set)
5300{
5301 int ret;
5302 struct prefix p;
5303 struct bgp_node *rn;
5304 struct bgp *bgp;
5305 struct bgp_aggregate *aggregate;
5306
5307 /* Convert string to prefix structure. */
5308 ret = str2prefix (prefix_str, &p);
5309 if (!ret)
5310 {
5311 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5312 return CMD_WARNING;
5313 }
5314 apply_mask (&p);
5315
5316 /* Get BGP structure. */
5317 bgp = vty->index;
5318
5319 /* Old configuration check. */
5320 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5321
5322 if (rn->info)
5323 {
5324 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005325 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005326 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5327 if (ret)
5328 {
Robert Bays368473f2010-08-05 10:26:29 -07005329 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5330 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005331 return CMD_WARNING;
5332 }
paul718e3742002-12-13 20:15:29 +00005333 }
5334
5335 /* Make aggregate address structure. */
5336 aggregate = bgp_aggregate_new ();
5337 aggregate->summary_only = summary_only;
5338 aggregate->as_set = as_set;
5339 aggregate->safi = safi;
5340 rn->info = aggregate;
5341
5342 /* Aggregate address insert into BGP routing table. */
5343 if (safi & SAFI_UNICAST)
5344 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5345 if (safi & SAFI_MULTICAST)
5346 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5347
5348 return CMD_SUCCESS;
5349}
5350
paul718e3742002-12-13 20:15:29 +00005351DEFUN (aggregate_address,
5352 aggregate_address_cmd,
5353 "aggregate-address A.B.C.D/M",
5354 "Configure BGP aggregate entries\n"
5355 "Aggregate prefix\n")
5356{
5357 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5358}
5359
5360DEFUN (aggregate_address_mask,
5361 aggregate_address_mask_cmd,
5362 "aggregate-address A.B.C.D A.B.C.D",
5363 "Configure BGP aggregate entries\n"
5364 "Aggregate address\n"
5365 "Aggregate mask\n")
5366{
5367 int ret;
5368 char prefix_str[BUFSIZ];
5369
5370 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5371
5372 if (! ret)
5373 {
5374 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5375 return CMD_WARNING;
5376 }
5377
5378 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5379 0, 0);
5380}
5381
5382DEFUN (aggregate_address_summary_only,
5383 aggregate_address_summary_only_cmd,
5384 "aggregate-address A.B.C.D/M summary-only",
5385 "Configure BGP aggregate entries\n"
5386 "Aggregate prefix\n"
5387 "Filter more specific routes from updates\n")
5388{
5389 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5390 AGGREGATE_SUMMARY_ONLY, 0);
5391}
5392
5393DEFUN (aggregate_address_mask_summary_only,
5394 aggregate_address_mask_summary_only_cmd,
5395 "aggregate-address A.B.C.D A.B.C.D summary-only",
5396 "Configure BGP aggregate entries\n"
5397 "Aggregate address\n"
5398 "Aggregate mask\n"
5399 "Filter more specific routes from updates\n")
5400{
5401 int ret;
5402 char prefix_str[BUFSIZ];
5403
5404 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5405
5406 if (! ret)
5407 {
5408 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5409 return CMD_WARNING;
5410 }
5411
5412 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5413 AGGREGATE_SUMMARY_ONLY, 0);
5414}
5415
5416DEFUN (aggregate_address_as_set,
5417 aggregate_address_as_set_cmd,
5418 "aggregate-address A.B.C.D/M as-set",
5419 "Configure BGP aggregate entries\n"
5420 "Aggregate prefix\n"
5421 "Generate AS set path information\n")
5422{
5423 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5424 0, AGGREGATE_AS_SET);
5425}
5426
5427DEFUN (aggregate_address_mask_as_set,
5428 aggregate_address_mask_as_set_cmd,
5429 "aggregate-address A.B.C.D A.B.C.D as-set",
5430 "Configure BGP aggregate entries\n"
5431 "Aggregate address\n"
5432 "Aggregate mask\n"
5433 "Generate AS set path information\n")
5434{
5435 int ret;
5436 char prefix_str[BUFSIZ];
5437
5438 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5439
5440 if (! ret)
5441 {
5442 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5443 return CMD_WARNING;
5444 }
5445
5446 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5447 0, AGGREGATE_AS_SET);
5448}
5449
5450
5451DEFUN (aggregate_address_as_set_summary,
5452 aggregate_address_as_set_summary_cmd,
5453 "aggregate-address A.B.C.D/M as-set summary-only",
5454 "Configure BGP aggregate entries\n"
5455 "Aggregate prefix\n"
5456 "Generate AS set path information\n"
5457 "Filter more specific routes from updates\n")
5458{
5459 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5460 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5461}
5462
5463ALIAS (aggregate_address_as_set_summary,
5464 aggregate_address_summary_as_set_cmd,
5465 "aggregate-address A.B.C.D/M summary-only as-set",
5466 "Configure BGP aggregate entries\n"
5467 "Aggregate prefix\n"
5468 "Filter more specific routes from updates\n"
5469 "Generate AS set path information\n")
5470
5471DEFUN (aggregate_address_mask_as_set_summary,
5472 aggregate_address_mask_as_set_summary_cmd,
5473 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5474 "Configure BGP aggregate entries\n"
5475 "Aggregate address\n"
5476 "Aggregate mask\n"
5477 "Generate AS set path information\n"
5478 "Filter more specific routes from updates\n")
5479{
5480 int ret;
5481 char prefix_str[BUFSIZ];
5482
5483 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5484
5485 if (! ret)
5486 {
5487 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5488 return CMD_WARNING;
5489 }
5490
5491 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5492 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5493}
5494
5495ALIAS (aggregate_address_mask_as_set_summary,
5496 aggregate_address_mask_summary_as_set_cmd,
5497 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5498 "Configure BGP aggregate entries\n"
5499 "Aggregate address\n"
5500 "Aggregate mask\n"
5501 "Filter more specific routes from updates\n"
5502 "Generate AS set path information\n")
5503
5504DEFUN (no_aggregate_address,
5505 no_aggregate_address_cmd,
5506 "no aggregate-address A.B.C.D/M",
5507 NO_STR
5508 "Configure BGP aggregate entries\n"
5509 "Aggregate prefix\n")
5510{
5511 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5512}
5513
5514ALIAS (no_aggregate_address,
5515 no_aggregate_address_summary_only_cmd,
5516 "no aggregate-address A.B.C.D/M summary-only",
5517 NO_STR
5518 "Configure BGP aggregate entries\n"
5519 "Aggregate prefix\n"
5520 "Filter more specific routes from updates\n")
5521
5522ALIAS (no_aggregate_address,
5523 no_aggregate_address_as_set_cmd,
5524 "no aggregate-address A.B.C.D/M as-set",
5525 NO_STR
5526 "Configure BGP aggregate entries\n"
5527 "Aggregate prefix\n"
5528 "Generate AS set path information\n")
5529
5530ALIAS (no_aggregate_address,
5531 no_aggregate_address_as_set_summary_cmd,
5532 "no aggregate-address A.B.C.D/M as-set summary-only",
5533 NO_STR
5534 "Configure BGP aggregate entries\n"
5535 "Aggregate prefix\n"
5536 "Generate AS set path information\n"
5537 "Filter more specific routes from updates\n")
5538
5539ALIAS (no_aggregate_address,
5540 no_aggregate_address_summary_as_set_cmd,
5541 "no aggregate-address A.B.C.D/M summary-only as-set",
5542 NO_STR
5543 "Configure BGP aggregate entries\n"
5544 "Aggregate prefix\n"
5545 "Filter more specific routes from updates\n"
5546 "Generate AS set path information\n")
5547
5548DEFUN (no_aggregate_address_mask,
5549 no_aggregate_address_mask_cmd,
5550 "no aggregate-address A.B.C.D A.B.C.D",
5551 NO_STR
5552 "Configure BGP aggregate entries\n"
5553 "Aggregate address\n"
5554 "Aggregate mask\n")
5555{
5556 int ret;
5557 char prefix_str[BUFSIZ];
5558
5559 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5560
5561 if (! ret)
5562 {
5563 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5564 return CMD_WARNING;
5565 }
5566
5567 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5568}
5569
5570ALIAS (no_aggregate_address_mask,
5571 no_aggregate_address_mask_summary_only_cmd,
5572 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5573 NO_STR
5574 "Configure BGP aggregate entries\n"
5575 "Aggregate address\n"
5576 "Aggregate mask\n"
5577 "Filter more specific routes from updates\n")
5578
5579ALIAS (no_aggregate_address_mask,
5580 no_aggregate_address_mask_as_set_cmd,
5581 "no aggregate-address A.B.C.D A.B.C.D as-set",
5582 NO_STR
5583 "Configure BGP aggregate entries\n"
5584 "Aggregate address\n"
5585 "Aggregate mask\n"
5586 "Generate AS set path information\n")
5587
5588ALIAS (no_aggregate_address_mask,
5589 no_aggregate_address_mask_as_set_summary_cmd,
5590 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5591 NO_STR
5592 "Configure BGP aggregate entries\n"
5593 "Aggregate address\n"
5594 "Aggregate mask\n"
5595 "Generate AS set path information\n"
5596 "Filter more specific routes from updates\n")
5597
5598ALIAS (no_aggregate_address_mask,
5599 no_aggregate_address_mask_summary_as_set_cmd,
5600 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5601 NO_STR
5602 "Configure BGP aggregate entries\n"
5603 "Aggregate address\n"
5604 "Aggregate mask\n"
5605 "Filter more specific routes from updates\n"
5606 "Generate AS set path information\n")
5607
paul718e3742002-12-13 20:15:29 +00005608DEFUN (ipv6_aggregate_address,
5609 ipv6_aggregate_address_cmd,
5610 "aggregate-address X:X::X:X/M",
5611 "Configure BGP aggregate entries\n"
5612 "Aggregate prefix\n")
5613{
5614 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5615}
5616
5617DEFUN (ipv6_aggregate_address_summary_only,
5618 ipv6_aggregate_address_summary_only_cmd,
5619 "aggregate-address X:X::X:X/M summary-only",
5620 "Configure BGP aggregate entries\n"
5621 "Aggregate prefix\n"
5622 "Filter more specific routes from updates\n")
5623{
5624 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5625 AGGREGATE_SUMMARY_ONLY, 0);
5626}
5627
5628DEFUN (no_ipv6_aggregate_address,
5629 no_ipv6_aggregate_address_cmd,
5630 "no aggregate-address X:X::X:X/M",
5631 NO_STR
5632 "Configure BGP aggregate entries\n"
5633 "Aggregate prefix\n")
5634{
5635 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5636}
5637
5638DEFUN (no_ipv6_aggregate_address_summary_only,
5639 no_ipv6_aggregate_address_summary_only_cmd,
5640 "no aggregate-address X:X::X:X/M summary-only",
5641 NO_STR
5642 "Configure BGP aggregate entries\n"
5643 "Aggregate prefix\n"
5644 "Filter more specific routes from updates\n")
5645{
5646 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5647}
5648
5649ALIAS (ipv6_aggregate_address,
5650 old_ipv6_aggregate_address_cmd,
5651 "ipv6 bgp aggregate-address X:X::X:X/M",
5652 IPV6_STR
5653 BGP_STR
5654 "Configure BGP aggregate entries\n"
5655 "Aggregate prefix\n")
5656
5657ALIAS (ipv6_aggregate_address_summary_only,
5658 old_ipv6_aggregate_address_summary_only_cmd,
5659 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5660 IPV6_STR
5661 BGP_STR
5662 "Configure BGP aggregate entries\n"
5663 "Aggregate prefix\n"
5664 "Filter more specific routes from updates\n")
5665
5666ALIAS (no_ipv6_aggregate_address,
5667 old_no_ipv6_aggregate_address_cmd,
5668 "no ipv6 bgp aggregate-address X:X::X:X/M",
5669 NO_STR
5670 IPV6_STR
5671 BGP_STR
5672 "Configure BGP aggregate entries\n"
5673 "Aggregate prefix\n")
5674
5675ALIAS (no_ipv6_aggregate_address_summary_only,
5676 old_no_ipv6_aggregate_address_summary_only_cmd,
5677 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5678 NO_STR
5679 IPV6_STR
5680 BGP_STR
5681 "Configure BGP aggregate entries\n"
5682 "Aggregate prefix\n"
5683 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005684
paul718e3742002-12-13 20:15:29 +00005685/* Redistribute route treatment. */
5686void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005687bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5688 const struct in6_addr *nexthop6,
Paul Jakma96d10602016-07-01 14:23:45 +01005689 u_int32_t metric, u_char type, route_tag_t tag)
paul718e3742002-12-13 20:15:29 +00005690{
5691 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005692 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005693 struct bgp_info *new;
5694 struct bgp_info *bi;
5695 struct bgp_info info;
5696 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005697 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005698 struct attr *new_attr;
5699 afi_t afi;
5700 int ret;
5701
5702 /* Make default attribute. */
5703 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5704 if (nexthop)
5705 attr.nexthop = *nexthop;
5706
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005707 if (nexthop6)
5708 {
5709 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5710 extra->mp_nexthop_global = *nexthop6;
5711 extra->mp_nexthop_len = 16;
5712 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005713
paul718e3742002-12-13 20:15:29 +00005714 attr.med = metric;
5715 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Piotr Chytła605aa332015-12-01 10:03:54 -05005716 attr.extra->tag = tag;
paul718e3742002-12-13 20:15:29 +00005717
paul1eb8ef22005-04-07 07:30:20 +00005718 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005719 {
5720 afi = family2afi (p->family);
5721
5722 if (bgp->redist[afi][type])
5723 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005724 struct attr attr_new;
5725 struct attr_extra extra_new;
5726
paul718e3742002-12-13 20:15:29 +00005727 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005728 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005729 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005730
5731 if (bgp->redist_metric_flag[afi][type])
5732 attr_new.med = bgp->redist_metric[afi][type];
5733
5734 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005735 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005736 {
5737 info.peer = bgp->peer_self;
5738 info.attr = &attr_new;
5739
paulfee0f4c2004-09-13 05:12:46 +00005740 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5741
paul718e3742002-12-13 20:15:29 +00005742 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5743 &info);
paulfee0f4c2004-09-13 05:12:46 +00005744
5745 bgp->peer_self->rmap_type = 0;
5746
paul718e3742002-12-13 20:15:29 +00005747 if (ret == RMAP_DENYMATCH)
5748 {
5749 /* Free uninterned attribute. */
5750 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005751
paul718e3742002-12-13 20:15:29 +00005752 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005753 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005754 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005755 bgp_redistribute_delete (p, type);
5756 return;
5757 }
5758 }
5759
Paul Jakmafb982c22007-05-04 20:15:47 +00005760 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5761 afi, SAFI_UNICAST, p, NULL);
5762
paul718e3742002-12-13 20:15:29 +00005763 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005764
paul718e3742002-12-13 20:15:29 +00005765 for (bi = bn->info; bi; bi = bi->next)
5766 if (bi->peer == bgp->peer_self
5767 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5768 break;
5769
5770 if (bi)
5771 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005772 if (attrhash_cmp (bi->attr, new_attr) &&
5773 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005774 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005775 bgp_attr_unintern (&new_attr);
5776 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005777 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005778 bgp_unlock_node (bn);
5779 return;
5780 }
5781 else
5782 {
5783 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005784 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005785
5786 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005787 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5788 bgp_info_restore(bn, bi);
5789 else
5790 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005791 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005792 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005793 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005794
5795 /* Process change. */
5796 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5797 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5798 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005799 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005800 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005801 return;
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005802 }
paul718e3742002-12-13 20:15:29 +00005803 }
5804
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005805 new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self,
5806 new_attr, bn);
paul718e3742002-12-13 20:15:29 +00005807 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00005808
5809 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5810 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005811 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005812 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5813 }
5814 }
5815
5816 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005817 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005818 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005819}
5820
5821void
5822bgp_redistribute_delete (struct prefix *p, u_char type)
5823{
5824 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005825 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005826 afi_t afi;
5827 struct bgp_node *rn;
5828 struct bgp_info *ri;
5829
paul1eb8ef22005-04-07 07:30:20 +00005830 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005831 {
5832 afi = family2afi (p->family);
5833
5834 if (bgp->redist[afi][type])
5835 {
paulfee0f4c2004-09-13 05:12:46 +00005836 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005837
5838 for (ri = rn->info; ri; ri = ri->next)
5839 if (ri->peer == bgp->peer_self
5840 && ri->type == type)
5841 break;
5842
5843 if (ri)
5844 {
5845 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005846 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005847 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005848 }
5849 bgp_unlock_node (rn);
5850 }
5851 }
5852}
5853
5854/* Withdraw specified route type's route. */
5855void
5856bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5857{
5858 struct bgp_node *rn;
5859 struct bgp_info *ri;
5860 struct bgp_table *table;
5861
5862 table = bgp->rib[afi][SAFI_UNICAST];
5863
5864 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5865 {
5866 for (ri = rn->info; ri; ri = ri->next)
5867 if (ri->peer == bgp->peer_self
5868 && ri->type == type)
5869 break;
5870
5871 if (ri)
5872 {
5873 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005874 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005875 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005876 }
5877 }
5878}
David Lamparter6b0655a2014-06-04 06:53:35 +02005879
paul718e3742002-12-13 20:15:29 +00005880/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005881static void
paul718e3742002-12-13 20:15:29 +00005882route_vty_out_route (struct prefix *p, struct vty *vty)
5883{
5884 int len;
5885 u_int32_t destination;
5886 char buf[BUFSIZ];
5887
5888 if (p->family == AF_INET)
5889 {
5890 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5891 destination = ntohl (p->u.prefix4.s_addr);
5892
5893 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5894 || (IN_CLASSB (destination) && p->prefixlen == 16)
5895 || (IN_CLASSA (destination) && p->prefixlen == 8)
5896 || p->u.prefix4.s_addr == 0)
5897 {
5898 /* When mask is natural, mask is not displayed. */
5899 }
5900 else
5901 len += vty_out (vty, "/%d", p->prefixlen);
5902 }
5903 else
5904 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5905 p->prefixlen);
5906
5907 len = 17 - len;
5908 if (len < 1)
5909 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5910 else
5911 vty_out (vty, "%*s", len, " ");
5912}
5913
paul718e3742002-12-13 20:15:29 +00005914enum bgp_display_type
5915{
5916 normal_list,
5917};
5918
paulb40d9392005-08-22 22:34:41 +00005919/* Print the short form route status for a bgp_info */
5920static void
5921route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005922{
paulb40d9392005-08-22 22:34:41 +00005923 /* Route status display. */
5924 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5925 vty_out (vty, "R");
5926 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005927 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005928 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005929 vty_out (vty, "s");
Daniel Waltone2a0ebf2015-05-19 18:03:43 -07005930 else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) &&
5931 ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
paul718e3742002-12-13 20:15:29 +00005932 vty_out (vty, "*");
5933 else
5934 vty_out (vty, " ");
5935
5936 /* Selected */
5937 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5938 vty_out (vty, "h");
5939 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5940 vty_out (vty, "d");
5941 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5942 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005943 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5944 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005945 else
5946 vty_out (vty, " ");
5947
5948 /* Internal route. */
5949 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5950 vty_out (vty, "i");
5951 else
paulb40d9392005-08-22 22:34:41 +00005952 vty_out (vty, " ");
5953}
5954
5955/* called from terminal list command */
5956void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005957route_vty_out(
5958 struct vty *vty,
5959 struct prefix *p,
5960 struct bgp_info *binfo,
5961 int display,
5962 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005963{
5964 struct attr *attr;
5965
5966 /* short status lead text */
5967 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005968
5969 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005970 if (!display)
paul718e3742002-12-13 20:15:29 +00005971 route_vty_out_route (p, vty);
5972 else
5973 vty_out (vty, "%*s", 17, " ");
5974
5975 /* Print attribute */
5976 attr = binfo->attr;
5977 if (attr)
5978 {
paul718e3742002-12-13 20:15:29 +00005979
Lou Berger298cc2f2016-01-12 13:42:02 -05005980 /*
5981 * NEXTHOP start
5982 */
5983
5984 /*
5985 * For ENCAP routes, nexthop address family is not
5986 * neccessarily the same as the prefix address family.
5987 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5988 */
5989 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5990 if (attr->extra) {
5991 char buf[BUFSIZ];
5992 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5993
5994 switch (af) {
5995 case AF_INET:
5996 vty_out (vty, "%s", inet_ntop(af,
5997 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5998 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005999 case AF_INET6:
6000 vty_out (vty, "%s", inet_ntop(af,
6001 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
6002 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05006003 default:
6004 vty_out(vty, "?");
6005 }
6006 } else {
6007 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00006008 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006009 } else {
6010
6011 if (p->family == AF_INET)
6012 {
6013 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6014 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006015 else if (p->family == AF_INET6)
6016 {
6017 int len;
6018 char buf[BUFSIZ];
6019
6020 len = vty_out (vty, "%s",
6021 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6022 buf, BUFSIZ));
6023 len = 16 - len;
6024 if (len < 1)
6025 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6026 else
6027 vty_out (vty, "%*s", len, " ");
6028 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006029 else
6030 {
6031 vty_out(vty, "?");
6032 }
6033 }
6034
6035 /*
6036 * NEXTHOP end
6037 */
6038
paul718e3742002-12-13 20:15:29 +00006039
6040 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006041 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006042 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006043 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006044
6045 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006046 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006047 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006048 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006049
Paul Jakmafb982c22007-05-04 20:15:47 +00006050 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00006051
Paul Jakmab2518c12006-05-12 23:48:40 +00006052 /* Print aspath */
6053 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006054 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006055
Paul Jakmab2518c12006-05-12 23:48:40 +00006056 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006057 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006058 }
paul718e3742002-12-13 20:15:29 +00006059 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006060}
6061
6062/* called from terminal list command */
6063void
6064route_vty_out_tmp (struct vty *vty, struct prefix *p,
6065 struct attr *attr, safi_t safi)
6066{
6067 /* Route status display. */
6068 vty_out (vty, "*");
6069 vty_out (vty, ">");
6070 vty_out (vty, " ");
6071
6072 /* print prefix and mask */
6073 route_vty_out_route (p, vty);
6074
6075 /* Print attribute */
6076 if (attr)
6077 {
6078 if (p->family == AF_INET)
6079 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006080 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006081 vty_out (vty, "%-16s",
6082 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006083 else
6084 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6085 }
paul718e3742002-12-13 20:15:29 +00006086 else if (p->family == AF_INET6)
6087 {
6088 int len;
6089 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006090
6091 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006092
6093 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006094 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6095 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006096 len = 16 - len;
6097 if (len < 1)
6098 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6099 else
6100 vty_out (vty, "%*s", len, " ");
6101 }
paul718e3742002-12-13 20:15:29 +00006102
6103 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006104 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006105 else
6106 vty_out (vty, " ");
6107
6108 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006109 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006110 else
6111 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006112
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006113 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006114
Paul Jakmab2518c12006-05-12 23:48:40 +00006115 /* Print aspath */
6116 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006117 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006118
Paul Jakmab2518c12006-05-12 23:48:40 +00006119 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006120 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006121 }
paul718e3742002-12-13 20:15:29 +00006122
6123 vty_out (vty, "%s", VTY_NEWLINE);
6124}
6125
ajs5a646652004-11-05 01:25:55 +00006126void
paul718e3742002-12-13 20:15:29 +00006127route_vty_out_tag (struct vty *vty, struct prefix *p,
6128 struct bgp_info *binfo, int display, safi_t safi)
6129{
6130 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006131 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006132
6133 if (!binfo->extra)
6134 return;
6135
paulb40d9392005-08-22 22:34:41 +00006136 /* short status lead text */
6137 route_vty_short_status_out (vty, binfo);
6138
paul718e3742002-12-13 20:15:29 +00006139 /* print prefix and mask */
6140 if (! display)
6141 route_vty_out_route (p, vty);
6142 else
6143 vty_out (vty, "%*s", 17, " ");
6144
6145 /* Print attribute */
6146 attr = binfo->attr;
6147 if (attr)
6148 {
6149 if (p->family == AF_INET)
6150 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006151 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006152 vty_out (vty, "%-16s",
6153 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006154 else
6155 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6156 }
paul718e3742002-12-13 20:15:29 +00006157 else if (p->family == AF_INET6)
6158 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006159 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006160 char buf[BUFSIZ];
6161 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006162 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006163 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006164 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6165 buf, BUFSIZ));
6166 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006167 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006168 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6169 buf, BUFSIZ),
6170 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6171 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006172
6173 }
paul718e3742002-12-13 20:15:29 +00006174 }
6175
Paul Jakmafb982c22007-05-04 20:15:47 +00006176 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006177
6178 vty_out (vty, "notag/%d", label);
6179
6180 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006181}
6182
6183/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006184static void
paul718e3742002-12-13 20:15:29 +00006185damp_route_vty_out (struct vty *vty, struct prefix *p,
6186 struct bgp_info *binfo, int display, safi_t safi)
6187{
6188 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006189 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006190 char timebuf[BGP_UPTIME_LEN];
paul718e3742002-12-13 20:15:29 +00006191
paulb40d9392005-08-22 22:34:41 +00006192 /* short status lead text */
6193 route_vty_short_status_out (vty, binfo);
6194
paul718e3742002-12-13 20:15:29 +00006195 /* print prefix and mask */
6196 if (! display)
6197 route_vty_out_route (p, vty);
6198 else
6199 vty_out (vty, "%*s", 17, " ");
6200
6201 len = vty_out (vty, "%s", binfo->peer->host);
6202 len = 17 - len;
6203 if (len < 1)
6204 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6205 else
6206 vty_out (vty, "%*s", len, " ");
6207
Chris Caputo50aef6f2009-06-23 06:06:49 +00006208 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006209
6210 /* Print attribute */
6211 attr = binfo->attr;
6212 if (attr)
6213 {
6214 /* Print aspath */
6215 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006216 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006217
6218 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006219 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006220 }
6221 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006222}
6223
paul718e3742002-12-13 20:15:29 +00006224/* flap route */
ajs5a646652004-11-05 01:25:55 +00006225static void
paul718e3742002-12-13 20:15:29 +00006226flap_route_vty_out (struct vty *vty, struct prefix *p,
6227 struct bgp_info *binfo, int display, safi_t safi)
6228{
6229 struct attr *attr;
6230 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006231 char timebuf[BGP_UPTIME_LEN];
6232 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006233
6234 if (!binfo->extra)
6235 return;
6236
6237 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006238
paulb40d9392005-08-22 22:34:41 +00006239 /* short status lead text */
6240 route_vty_short_status_out (vty, binfo);
6241
paul718e3742002-12-13 20:15:29 +00006242 /* print prefix and mask */
6243 if (! display)
6244 route_vty_out_route (p, vty);
6245 else
6246 vty_out (vty, "%*s", 17, " ");
6247
6248 len = vty_out (vty, "%s", binfo->peer->host);
6249 len = 16 - len;
6250 if (len < 1)
6251 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6252 else
6253 vty_out (vty, "%*s", len, " ");
6254
6255 len = vty_out (vty, "%d", bdi->flap);
6256 len = 5 - len;
6257 if (len < 1)
6258 vty_out (vty, " ");
6259 else
6260 vty_out (vty, "%*s ", len, " ");
6261
6262 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6263 timebuf, BGP_UPTIME_LEN));
6264
6265 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6266 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006267 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006268 else
6269 vty_out (vty, "%*s ", 8, " ");
6270
6271 /* Print attribute */
6272 attr = binfo->attr;
6273 if (attr)
6274 {
6275 /* Print aspath */
6276 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006277 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006278
6279 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006280 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006281 }
6282 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006283}
6284
paul94f2b392005-06-28 12:44:16 +00006285static void
paul718e3742002-12-13 20:15:29 +00006286route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6287 struct bgp_info *binfo, afi_t afi, safi_t safi)
6288{
6289 char buf[INET6_ADDRSTRLEN];
6290 char buf1[BUFSIZ];
6291 struct attr *attr;
6292 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006293#ifdef HAVE_CLOCK_MONOTONIC
6294 time_t tbuf;
6295#endif
paul718e3742002-12-13 20:15:29 +00006296
6297 attr = binfo->attr;
6298
6299 if (attr)
6300 {
6301 /* Line1 display AS-path, Aggregator */
6302 if (attr->aspath)
6303 {
6304 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006305 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006306 vty_out (vty, "Local");
6307 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006308 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006309 }
6310
paulb40d9392005-08-22 22:34:41 +00006311 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6312 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006313 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6314 vty_out (vty, ", (stale)");
6315 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006316 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006317 attr->extra->aggregator_as,
6318 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006319 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6320 vty_out (vty, ", (Received from a RR-client)");
6321 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6322 vty_out (vty, ", (Received from a RS-client)");
6323 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6324 vty_out (vty, ", (history entry)");
6325 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6326 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006327 vty_out (vty, "%s", VTY_NEWLINE);
6328
6329 /* Line2 display Next-hop, Neighbor, Router-id */
6330 if (p->family == AF_INET)
6331 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006332 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006333 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006334 inet_ntoa (attr->nexthop));
6335 }
paul718e3742002-12-13 20:15:29 +00006336 else
6337 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006338 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006339 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006340 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006341 buf, INET6_ADDRSTRLEN));
6342 }
paul718e3742002-12-13 20:15:29 +00006343
6344 if (binfo->peer == bgp->peer_self)
6345 {
6346 vty_out (vty, " from %s ",
6347 p->family == AF_INET ? "0.0.0.0" : "::");
6348 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6349 }
6350 else
6351 {
6352 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6353 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006354 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006355 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006356 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6357 buf[0] = '?';
6358 buf[1] = 0;
6359 }
6360 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006361 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006362 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006363 else
6364 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6365 }
6366 vty_out (vty, "%s", VTY_NEWLINE);
6367
paul718e3742002-12-13 20:15:29 +00006368 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006369 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006370 {
6371 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006372 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006373 buf, INET6_ADDRSTRLEN),
6374 VTY_NEWLINE);
6375 }
paul718e3742002-12-13 20:15:29 +00006376
Piotr Chytła605aa332015-12-01 10:03:54 -05006377 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
paul718e3742002-12-13 20:15:29 +00006378 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6379
6380 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006381 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006382
6383 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006384 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006385 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006386 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006387
Paul Jakmafb982c22007-05-04 20:15:47 +00006388 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006389 vty_out (vty, ", weight %u", attr->extra->weight);
Piotr Chytła605aa332015-12-01 10:03:54 -05006390
6391 if (attr->extra && attr->extra->tag != 0)
6392 vty_out (vty, ", tag %d", attr->extra->tag);
paul718e3742002-12-13 20:15:29 +00006393
Daniel Waltone2a0ebf2015-05-19 18:03:43 -07006394 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6395 vty_out (vty, ", invalid");
6396 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
paul718e3742002-12-13 20:15:29 +00006397 vty_out (vty, ", valid");
6398
6399 if (binfo->peer != bgp->peer_self)
6400 {
6401 if (binfo->peer->as == binfo->peer->local_as)
6402 vty_out (vty, ", internal");
6403 else
6404 vty_out (vty, ", %s",
6405 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6406 }
6407 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6408 vty_out (vty, ", aggregated, local");
6409 else if (binfo->type != ZEBRA_ROUTE_BGP)
6410 vty_out (vty, ", sourced");
6411 else
6412 vty_out (vty, ", sourced, local");
6413
6414 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6415 vty_out (vty, ", atomic-aggregate");
6416
Josh Baileyde8d5df2011-07-20 20:46:01 -07006417 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6418 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6419 bgp_info_mpath_count (binfo)))
6420 vty_out (vty, ", multipath");
6421
paul718e3742002-12-13 20:15:29 +00006422 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6423 vty_out (vty, ", best");
6424
6425 vty_out (vty, "%s", VTY_NEWLINE);
6426
6427 /* Line 4 display Community */
6428 if (attr->community)
6429 vty_out (vty, " Community: %s%s", attr->community->str,
6430 VTY_NEWLINE);
6431
6432 /* Line 5 display Extended-community */
6433 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006434 vty_out (vty, " Extended Community: %s%s",
6435 attr->extra->ecommunity->str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006436
6437 /* Line 6 display Originator, Cluster-id */
6438 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6439 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6440 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006441 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006442 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006443 vty_out (vty, " Originator: %s",
6444 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006445
6446 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6447 {
6448 int i;
6449 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006450 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6451 vty_out (vty, "%s ",
6452 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006453 }
6454 vty_out (vty, "%s", VTY_NEWLINE);
6455 }
Paul Jakma41367172007-08-06 15:24:51 +00006456
Paul Jakmafb982c22007-05-04 20:15:47 +00006457 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006458 bgp_damp_info_vty (vty, binfo);
6459
6460 /* Line 7 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006461#ifdef HAVE_CLOCK_MONOTONIC
6462 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006463 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006464#else
6465 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6466#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006467 }
6468 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006469}
6470
6471#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6472 "h history, * valid, > best, = multipath,%s"\
6473 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006474#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006475#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6476#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6477#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6478
6479enum bgp_show_type
6480{
6481 bgp_show_type_normal,
6482 bgp_show_type_regexp,
6483 bgp_show_type_prefix_list,
6484 bgp_show_type_filter_list,
6485 bgp_show_type_route_map,
6486 bgp_show_type_neighbor,
6487 bgp_show_type_cidr_only,
6488 bgp_show_type_prefix_longer,
6489 bgp_show_type_community_all,
6490 bgp_show_type_community,
6491 bgp_show_type_community_exact,
6492 bgp_show_type_community_list,
6493 bgp_show_type_community_list_exact,
6494 bgp_show_type_flap_statistics,
6495 bgp_show_type_flap_address,
6496 bgp_show_type_flap_prefix,
6497 bgp_show_type_flap_cidr_only,
6498 bgp_show_type_flap_regexp,
6499 bgp_show_type_flap_filter_list,
6500 bgp_show_type_flap_prefix_list,
6501 bgp_show_type_flap_prefix_longer,
6502 bgp_show_type_flap_route_map,
6503 bgp_show_type_flap_neighbor,
6504 bgp_show_type_dampend_paths,
6505 bgp_show_type_damp_neighbor
6506};
6507
ajs5a646652004-11-05 01:25:55 +00006508static int
paulfee0f4c2004-09-13 05:12:46 +00006509bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006510 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006511{
paul718e3742002-12-13 20:15:29 +00006512 struct bgp_info *ri;
6513 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006514 int header = 1;
paul718e3742002-12-13 20:15:29 +00006515 int display;
ajs5a646652004-11-05 01:25:55 +00006516 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006517 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006518
6519 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006520 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006521 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006522
paul718e3742002-12-13 20:15:29 +00006523 /* Start processing of routes. */
6524 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6525 if (rn->info != NULL)
6526 {
6527 display = 0;
6528
6529 for (ri = rn->info; ri; ri = ri->next)
6530 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006531 total_count++;
ajs5a646652004-11-05 01:25:55 +00006532 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006533 || type == bgp_show_type_flap_address
6534 || type == bgp_show_type_flap_prefix
6535 || type == bgp_show_type_flap_cidr_only
6536 || type == bgp_show_type_flap_regexp
6537 || type == bgp_show_type_flap_filter_list
6538 || type == bgp_show_type_flap_prefix_list
6539 || type == bgp_show_type_flap_prefix_longer
6540 || type == bgp_show_type_flap_route_map
6541 || type == bgp_show_type_flap_neighbor
6542 || type == bgp_show_type_dampend_paths
6543 || type == bgp_show_type_damp_neighbor)
6544 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006545 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006546 continue;
6547 }
6548 if (type == bgp_show_type_regexp
6549 || type == bgp_show_type_flap_regexp)
6550 {
ajs5a646652004-11-05 01:25:55 +00006551 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006552
6553 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6554 continue;
6555 }
6556 if (type == bgp_show_type_prefix_list
6557 || type == bgp_show_type_flap_prefix_list)
6558 {
ajs5a646652004-11-05 01:25:55 +00006559 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006560
6561 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6562 continue;
6563 }
6564 if (type == bgp_show_type_filter_list
6565 || type == bgp_show_type_flap_filter_list)
6566 {
ajs5a646652004-11-05 01:25:55 +00006567 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006568
6569 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6570 continue;
6571 }
6572 if (type == bgp_show_type_route_map
6573 || type == bgp_show_type_flap_route_map)
6574 {
ajs5a646652004-11-05 01:25:55 +00006575 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006576 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006577 struct attr dummy_attr;
6578 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006579 int ret;
6580
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006581 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006582 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006583
paul718e3742002-12-13 20:15:29 +00006584 binfo.peer = ri->peer;
6585 binfo.attr = &dummy_attr;
6586
6587 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006588 if (ret == RMAP_DENYMATCH)
6589 continue;
6590 }
6591 if (type == bgp_show_type_neighbor
6592 || type == bgp_show_type_flap_neighbor
6593 || type == bgp_show_type_damp_neighbor)
6594 {
ajs5a646652004-11-05 01:25:55 +00006595 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006596
6597 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6598 continue;
6599 }
6600 if (type == bgp_show_type_cidr_only
6601 || type == bgp_show_type_flap_cidr_only)
6602 {
6603 u_int32_t destination;
6604
6605 destination = ntohl (rn->p.u.prefix4.s_addr);
6606 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6607 continue;
6608 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6609 continue;
6610 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6611 continue;
6612 }
6613 if (type == bgp_show_type_prefix_longer
6614 || type == bgp_show_type_flap_prefix_longer)
6615 {
ajs5a646652004-11-05 01:25:55 +00006616 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006617
6618 if (! prefix_match (p, &rn->p))
6619 continue;
6620 }
6621 if (type == bgp_show_type_community_all)
6622 {
6623 if (! ri->attr->community)
6624 continue;
6625 }
6626 if (type == bgp_show_type_community)
6627 {
ajs5a646652004-11-05 01:25:55 +00006628 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006629
6630 if (! ri->attr->community ||
6631 ! community_match (ri->attr->community, com))
6632 continue;
6633 }
6634 if (type == bgp_show_type_community_exact)
6635 {
ajs5a646652004-11-05 01:25:55 +00006636 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006637
6638 if (! ri->attr->community ||
6639 ! community_cmp (ri->attr->community, com))
6640 continue;
6641 }
6642 if (type == bgp_show_type_community_list)
6643 {
ajs5a646652004-11-05 01:25:55 +00006644 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006645
6646 if (! community_list_match (ri->attr->community, list))
6647 continue;
6648 }
6649 if (type == bgp_show_type_community_list_exact)
6650 {
ajs5a646652004-11-05 01:25:55 +00006651 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006652
6653 if (! community_list_exact_match (ri->attr->community, list))
6654 continue;
6655 }
6656 if (type == bgp_show_type_flap_address
6657 || type == bgp_show_type_flap_prefix)
6658 {
ajs5a646652004-11-05 01:25:55 +00006659 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006660
6661 if (! prefix_match (&rn->p, p))
6662 continue;
6663
6664 if (type == bgp_show_type_flap_prefix)
6665 if (p->prefixlen != rn->p.prefixlen)
6666 continue;
6667 }
6668 if (type == bgp_show_type_dampend_paths
6669 || type == bgp_show_type_damp_neighbor)
6670 {
6671 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6672 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6673 continue;
6674 }
6675
6676 if (header)
6677 {
hasso93406d82005-02-02 14:40:33 +00006678 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6679 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6680 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006681 if (type == bgp_show_type_dampend_paths
6682 || type == bgp_show_type_damp_neighbor)
6683 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6684 else if (type == bgp_show_type_flap_statistics
6685 || type == bgp_show_type_flap_address
6686 || type == bgp_show_type_flap_prefix
6687 || type == bgp_show_type_flap_cidr_only
6688 || type == bgp_show_type_flap_regexp
6689 || type == bgp_show_type_flap_filter_list
6690 || type == bgp_show_type_flap_prefix_list
6691 || type == bgp_show_type_flap_prefix_longer
6692 || type == bgp_show_type_flap_route_map
6693 || type == bgp_show_type_flap_neighbor)
6694 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6695 else
6696 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006697 header = 0;
6698 }
6699
6700 if (type == bgp_show_type_dampend_paths
6701 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006702 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006703 else if (type == bgp_show_type_flap_statistics
6704 || type == bgp_show_type_flap_address
6705 || type == bgp_show_type_flap_prefix
6706 || type == bgp_show_type_flap_cidr_only
6707 || type == bgp_show_type_flap_regexp
6708 || type == bgp_show_type_flap_filter_list
6709 || type == bgp_show_type_flap_prefix_list
6710 || type == bgp_show_type_flap_prefix_longer
6711 || type == bgp_show_type_flap_route_map
6712 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006713 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006714 else
ajs5a646652004-11-05 01:25:55 +00006715 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006716 display++;
6717 }
6718 if (display)
ajs5a646652004-11-05 01:25:55 +00006719 output_count++;
paul718e3742002-12-13 20:15:29 +00006720 }
6721
6722 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006723 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006724 {
6725 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006726 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006727 }
6728 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006729 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6730 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006731
6732 return CMD_SUCCESS;
6733}
6734
ajs5a646652004-11-05 01:25:55 +00006735static int
paulfee0f4c2004-09-13 05:12:46 +00006736bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006737 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006738{
6739 struct bgp_table *table;
6740
6741 if (bgp == NULL) {
6742 bgp = bgp_get_default ();
6743 }
6744
6745 if (bgp == NULL)
6746 {
6747 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6748 return CMD_WARNING;
6749 }
6750
6751
6752 table = bgp->rib[afi][safi];
6753
ajs5a646652004-11-05 01:25:55 +00006754 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006755}
6756
paul718e3742002-12-13 20:15:29 +00006757/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006758static void
paul718e3742002-12-13 20:15:29 +00006759route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6760 struct bgp_node *rn,
6761 struct prefix_rd *prd, afi_t afi, safi_t safi)
6762{
6763 struct bgp_info *ri;
6764 struct prefix *p;
6765 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006766 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006767 char buf1[INET6_ADDRSTRLEN];
6768 char buf2[INET6_ADDRSTRLEN];
6769 int count = 0;
6770 int best = 0;
6771 int suppress = 0;
6772 int no_export = 0;
6773 int no_advertise = 0;
6774 int local_as = 0;
6775 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006776 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006777
6778 p = &rn->p;
6779 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006780 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6781 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006782 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6783 p->prefixlen, VTY_NEWLINE);
6784
6785 for (ri = rn->info; ri; ri = ri->next)
6786 {
6787 count++;
6788 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6789 {
6790 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006791 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006792 suppress = 1;
6793 if (ri->attr->community != NULL)
6794 {
6795 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6796 no_advertise = 1;
6797 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6798 no_export = 1;
6799 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6800 local_as = 1;
6801 }
6802 }
6803 }
6804
6805 vty_out (vty, "Paths: (%d available", count);
6806 if (best)
6807 {
6808 vty_out (vty, ", best #%d", best);
6809 if (safi == SAFI_UNICAST)
6810 vty_out (vty, ", table Default-IP-Routing-Table");
6811 }
6812 else
6813 vty_out (vty, ", no best path");
6814 if (no_advertise)
6815 vty_out (vty, ", not advertised to any peer");
6816 else if (no_export)
6817 vty_out (vty, ", not advertised to EBGP peer");
6818 else if (local_as)
6819 vty_out (vty, ", not advertised outside local AS");
6820 if (suppress)
6821 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6822 vty_out (vty, ")%s", VTY_NEWLINE);
6823
6824 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006825 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006826 {
6827 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6828 {
6829 if (! first)
6830 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6831 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6832 first = 1;
6833 }
6834 }
6835 if (! first)
6836 vty_out (vty, " Not advertised to any peer");
6837 vty_out (vty, "%s", VTY_NEWLINE);
6838}
6839
6840/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006841static int
paulfee0f4c2004-09-13 05:12:46 +00006842bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006843 struct bgp_table *rib, const char *ip_str,
6844 afi_t afi, safi_t safi, struct prefix_rd *prd,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006845 int prefix_check, enum bgp_path_type pathtype)
paul718e3742002-12-13 20:15:29 +00006846{
6847 int ret;
6848 int header;
6849 int display = 0;
6850 struct prefix match;
6851 struct bgp_node *rn;
6852 struct bgp_node *rm;
6853 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006854 struct bgp_table *table;
6855
Lou Berger050defe2016-01-12 13:41:59 -05006856 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006857 /* Check IP address argument. */
6858 ret = str2prefix (ip_str, &match);
6859 if (! ret)
6860 {
6861 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6862 return CMD_WARNING;
6863 }
6864
6865 match.family = afi2family (afi);
6866
Lou Berger298cc2f2016-01-12 13:42:02 -05006867 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006868 {
paulfee0f4c2004-09-13 05:12:46 +00006869 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006870 {
6871 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6872 continue;
6873
6874 if ((table = rn->info) != NULL)
6875 {
6876 header = 1;
6877
6878 if ((rm = bgp_node_match (table, &match)) != NULL)
6879 {
6880 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006881 {
6882 bgp_unlock_node (rm);
6883 continue;
6884 }
paul718e3742002-12-13 20:15:29 +00006885
6886 for (ri = rm->info; ri; ri = ri->next)
6887 {
6888 if (header)
6889 {
6890 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006891 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006892
6893 header = 0;
6894 }
6895 display++;
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006896
6897 if (pathtype == BGP_PATH_ALL ||
6898 (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) ||
6899 (pathtype == BGP_PATH_MULTIPATH &&
6900 (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))))
6901 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006902 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006903
6904 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006905 }
6906 }
6907 }
6908 }
6909 else
6910 {
6911 header = 1;
6912
paulfee0f4c2004-09-13 05:12:46 +00006913 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006914 {
6915 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6916 {
6917 for (ri = rn->info; ri; ri = ri->next)
6918 {
6919 if (header)
6920 {
6921 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6922 header = 0;
6923 }
6924 display++;
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006925
6926 if (pathtype == BGP_PATH_ALL ||
6927 (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) ||
6928 (pathtype == BGP_PATH_MULTIPATH &&
6929 (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))))
6930 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00006931 }
6932 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006933
6934 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006935 }
6936 }
6937
6938 if (! display)
6939 {
6940 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6941 return CMD_WARNING;
6942 }
6943
6944 return CMD_SUCCESS;
6945}
6946
paulfee0f4c2004-09-13 05:12:46 +00006947/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006948static int
paulfd79ac92004-10-13 05:06:08 +00006949bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006950 afi_t afi, safi_t safi, struct prefix_rd *prd,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006951 int prefix_check, enum bgp_path_type pathtype)
paulfee0f4c2004-09-13 05:12:46 +00006952{
6953 struct bgp *bgp;
6954
6955 /* BGP structure lookup. */
6956 if (view_name)
6957 {
6958 bgp = bgp_lookup_by_name (view_name);
6959 if (bgp == NULL)
6960 {
6961 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6962 return CMD_WARNING;
6963 }
6964 }
6965 else
6966 {
6967 bgp = bgp_get_default ();
6968 if (bgp == NULL)
6969 {
6970 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6971 return CMD_WARNING;
6972 }
6973 }
6974
6975 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006976 afi, safi, prd, prefix_check, pathtype);
paulfee0f4c2004-09-13 05:12:46 +00006977}
6978
paul718e3742002-12-13 20:15:29 +00006979/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05006980DEFUN (show_ip_bgp,
6981 show_ip_bgp_cmd,
6982 "show ip bgp",
6983 SHOW_STR
6984 IP_STR
6985 BGP_STR)
6986{
6987 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6988}
6989
6990DEFUN (show_ip_bgp_ipv4,
6991 show_ip_bgp_ipv4_cmd,
6992 "show ip bgp ipv4 (unicast|multicast)",
6993 SHOW_STR
6994 IP_STR
6995 BGP_STR
6996 "Address family\n"
6997 "Address Family modifier\n"
6998 "Address Family modifier\n")
6999{
7000 if (strncmp (argv[0], "m", 1) == 0)
7001 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7002 NULL);
7003
7004 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7005}
7006
7007DEFUN (show_ip_bgp_route,
7008 show_ip_bgp_route_cmd,
7009 "show ip bgp A.B.C.D",
7010 SHOW_STR
7011 IP_STR
7012 BGP_STR
7013 "Network in the BGP routing table to display\n")
7014{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007015 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7016}
7017
7018DEFUN (show_ip_bgp_route_pathtype,
7019 show_ip_bgp_route_pathtype_cmd,
7020 "show ip bgp A.B.C.D (bestpath|multipath)",
7021 SHOW_STR
7022 IP_STR
7023 BGP_STR
7024 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7025 "Display only the bestpath\n"
7026 "Display only multipaths\n")
7027{
7028 if (strncmp (argv[1], "b", 1) == 0)
7029 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7030 else
7031 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7032}
7033
7034DEFUN (show_bgp_ipv4_safi_route_pathtype,
7035 show_bgp_ipv4_safi_route_pathtype_cmd,
7036 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath)",
7037 SHOW_STR
7038 BGP_STR
7039 "Address family\n"
7040 "Address Family modifier\n"
7041 "Address Family modifier\n"
7042 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7043 "Display only the bestpath\n"
7044 "Display only multipaths\n")
7045{
7046 if (strncmp (argv[0], "m", 1) == 0)
7047 if (strncmp (argv[2], "b", 1) == 0)
7048 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH);
7049 else
7050 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH);
7051 else
7052 if (strncmp (argv[2], "b", 1) == 0)
7053 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7054 else
7055 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007056}
7057
7058DEFUN (show_ip_bgp_ipv4_route,
7059 show_ip_bgp_ipv4_route_cmd,
7060 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
7061 SHOW_STR
7062 IP_STR
7063 BGP_STR
7064 "Address family\n"
7065 "Address Family modifier\n"
7066 "Address Family modifier\n"
7067 "Network in the BGP routing table to display\n")
7068{
7069 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007070 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007071
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007072 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007073}
7074
7075DEFUN (show_ip_bgp_vpnv4_all_route,
7076 show_ip_bgp_vpnv4_all_route_cmd,
7077 "show ip bgp vpnv4 all A.B.C.D",
7078 SHOW_STR
7079 IP_STR
7080 BGP_STR
7081 "Display VPNv4 NLRI specific information\n"
7082 "Display information about all VPNv4 NLRIs\n"
7083 "Network in the BGP routing table to display\n")
7084{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007085 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007086}
7087
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007088
Lou Bergerf9b6c392016-01-12 13:42:09 -05007089DEFUN (show_ip_bgp_vpnv4_rd_route,
7090 show_ip_bgp_vpnv4_rd_route_cmd,
7091 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
7092 SHOW_STR
7093 IP_STR
7094 BGP_STR
7095 "Display VPNv4 NLRI specific information\n"
7096 "Display information for a route distinguisher\n"
7097 "VPN Route Distinguisher\n"
7098 "Network in the BGP routing table to display\n")
7099{
7100 int ret;
7101 struct prefix_rd prd;
7102
7103 ret = str2prefix_rd (argv[0], &prd);
7104 if (! ret)
7105 {
7106 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7107 return CMD_WARNING;
7108 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007109 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007110}
7111
7112DEFUN (show_ip_bgp_prefix,
7113 show_ip_bgp_prefix_cmd,
7114 "show ip bgp A.B.C.D/M",
7115 SHOW_STR
7116 IP_STR
7117 BGP_STR
7118 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7119{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007120 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7121}
7122
7123DEFUN (show_ip_bgp_prefix_pathtype,
7124 show_ip_bgp_prefix_pathtype_cmd,
7125 "show ip bgp A.B.C.D/M (bestpath|multipath)",
7126 SHOW_STR
7127 IP_STR
7128 BGP_STR
7129 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7130 "Display only the bestpath\n"
7131 "Display only multipaths\n")
7132{
7133 if (strncmp (argv[1], "b", 1) == 0)
7134 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7135 else
7136 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007137}
7138
7139DEFUN (show_ip_bgp_ipv4_prefix,
7140 show_ip_bgp_ipv4_prefix_cmd,
7141 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
7142 SHOW_STR
7143 IP_STR
7144 BGP_STR
7145 "Address family\n"
7146 "Address Family modifier\n"
7147 "Address Family modifier\n"
7148 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7149{
7150 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007151 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007152
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007153 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007154}
7155
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007156DEFUN (show_ip_bgp_ipv4_prefix_pathtype,
7157 show_ip_bgp_ipv4_prefix_pathtype_cmd,
7158 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)",
7159 SHOW_STR
7160 IP_STR
7161 BGP_STR
7162 "Address family\n"
7163 "Address Family modifier\n"
7164 "Address Family modifier\n"
7165 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7166 "Display only the bestpath\n"
7167 "Display only multipaths\n")
7168{
7169 if (strncmp (argv[0], "m", 1) == 0)
7170 if (strncmp (argv[2], "b", 1) == 0)
7171 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH);
7172 else
7173 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH);
7174 else
7175 if (strncmp (argv[2], "b", 1) == 0)
7176 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7177 else
7178 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7179}
7180
7181ALIAS (show_ip_bgp_ipv4_prefix_pathtype,
7182 show_bgp_ipv4_safi_prefix_pathtype_cmd,
7183 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)",
7184 SHOW_STR
7185 BGP_STR
7186 "Address family\n"
7187 "Address Family modifier\n"
7188 "Address Family modifier\n"
7189 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7190 "Display only the bestpath\n"
7191 "Display only multipaths\n")
7192
Lou Bergerf9b6c392016-01-12 13:42:09 -05007193DEFUN (show_ip_bgp_vpnv4_all_prefix,
7194 show_ip_bgp_vpnv4_all_prefix_cmd,
7195 "show ip bgp vpnv4 all A.B.C.D/M",
7196 SHOW_STR
7197 IP_STR
7198 BGP_STR
7199 "Display VPNv4 NLRI specific information\n"
7200 "Display information about all VPNv4 NLRIs\n"
7201 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7202{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007203 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007204}
7205
7206DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7207 show_ip_bgp_vpnv4_rd_prefix_cmd,
7208 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7209 SHOW_STR
7210 IP_STR
7211 BGP_STR
7212 "Display VPNv4 NLRI specific information\n"
7213 "Display information for a route distinguisher\n"
7214 "VPN Route Distinguisher\n"
7215 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7216{
7217 int ret;
7218 struct prefix_rd prd;
7219
7220 ret = str2prefix_rd (argv[0], &prd);
7221 if (! ret)
7222 {
7223 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7224 return CMD_WARNING;
7225 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007226 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007227}
7228
7229DEFUN (show_ip_bgp_view,
7230 show_ip_bgp_view_cmd,
7231 "show ip bgp view WORD",
7232 SHOW_STR
7233 IP_STR
7234 BGP_STR
7235 "BGP view\n"
7236 "View name\n")
7237{
7238 struct bgp *bgp;
7239
7240 /* BGP structure lookup. */
7241 bgp = bgp_lookup_by_name (argv[0]);
7242 if (bgp == NULL)
7243 {
7244 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7245 return CMD_WARNING;
7246 }
7247
7248 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7249}
7250
7251DEFUN (show_ip_bgp_view_route,
7252 show_ip_bgp_view_route_cmd,
7253 "show ip bgp view WORD A.B.C.D",
7254 SHOW_STR
7255 IP_STR
7256 BGP_STR
7257 "BGP view\n"
7258 "View name\n"
7259 "Network in the BGP routing table to display\n")
7260{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007261 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007262}
7263
7264DEFUN (show_ip_bgp_view_prefix,
7265 show_ip_bgp_view_prefix_cmd,
7266 "show ip bgp view WORD A.B.C.D/M",
7267 SHOW_STR
7268 IP_STR
7269 BGP_STR
7270 "BGP view\n"
7271 "View name\n"
7272 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7273{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007274 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007275}
7276
7277DEFUN (show_bgp,
7278 show_bgp_cmd,
7279 "show bgp",
7280 SHOW_STR
7281 BGP_STR)
7282{
7283 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7284 NULL);
7285}
7286
7287ALIAS (show_bgp,
7288 show_bgp_ipv6_cmd,
7289 "show bgp ipv6",
7290 SHOW_STR
7291 BGP_STR
7292 "Address family\n")
7293
7294/* old command */
7295DEFUN (show_ipv6_bgp,
7296 show_ipv6_bgp_cmd,
7297 "show ipv6 bgp",
7298 SHOW_STR
7299 IP_STR
7300 BGP_STR)
7301{
7302 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7303 NULL);
7304}
7305
7306DEFUN (show_bgp_route,
7307 show_bgp_route_cmd,
7308 "show bgp X:X::X:X",
7309 SHOW_STR
7310 BGP_STR
7311 "Network in the BGP routing table to display\n")
7312{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007313 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007314}
7315
Lou Berger35c36862016-01-12 13:42:06 -05007316DEFUN (show_bgp_ipv4_safi,
7317 show_bgp_ipv4_safi_cmd,
7318 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007319 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007320 BGP_STR
7321 "Address family\n"
7322 "Address Family modifier\n"
7323 "Address Family modifier\n")
7324{
7325 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007326 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7327 NULL);
paul718e3742002-12-13 20:15:29 +00007328
ajs5a646652004-11-05 01:25:55 +00007329 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007330}
7331
Lou Berger35c36862016-01-12 13:42:06 -05007332DEFUN (show_bgp_ipv4_safi_route,
7333 show_bgp_ipv4_safi_route_cmd,
7334 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007335 SHOW_STR
7336 BGP_STR
7337 "Address family\n"
7338 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007339 "Address Family modifier\n"
7340 "Network in the BGP routing table to display\n")
7341{
7342 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007343 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007344
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007345 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7346}
7347
7348DEFUN (show_bgp_route_pathtype,
7349 show_bgp_route_pathtype_cmd,
7350 "show bgp X:X::X:X (bestpath|multipath)",
7351 SHOW_STR
7352 BGP_STR
7353 "Network in the BGP routing table to display\n"
7354 "Display only the bestpath\n"
7355 "Display only multipaths\n")
7356{
7357 if (strncmp (argv[1], "b", 1) == 0)
7358 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7359 else
7360 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7361}
7362
7363ALIAS (show_bgp_route_pathtype,
7364 show_bgp_ipv6_route_pathtype_cmd,
7365 "show bgp ipv6 X:X::X:X (bestpath|multipath)",
7366 SHOW_STR
7367 BGP_STR
7368 "Address family\n"
7369 "Network in the BGP routing table to display\n"
7370 "Display only the bestpath\n"
7371 "Display only multipaths\n")
7372
7373DEFUN (show_bgp_ipv6_safi_route_pathtype,
7374 show_bgp_ipv6_safi_route_pathtype_cmd,
7375 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath)",
7376 SHOW_STR
7377 BGP_STR
7378 "Address family\n"
7379 "Address Family modifier\n"
7380 "Address Family modifier\n"
7381 "Network in the BGP routing table to display\n"
7382 "Display only the bestpath\n"
7383 "Display only multipaths\n")
7384{
7385 if (strncmp (argv[0], "m", 1) == 0)
7386 if (strncmp (argv[2], "b", 1) == 0)
7387 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH);
7388 else
7389 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH);
7390 else
7391 if (strncmp (argv[2], "b", 1) == 0)
7392 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7393 else
7394 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
paul718e3742002-12-13 20:15:29 +00007395}
7396
Lou Berger35c36862016-01-12 13:42:06 -05007397DEFUN (show_bgp_ipv4_vpn_route,
7398 show_bgp_ipv4_vpn_route_cmd,
7399 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007400 SHOW_STR
7401 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007402 "Address Family\n"
7403 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007404 "Network in the BGP routing table to display\n")
7405{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007406 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007407}
7408
Lou Berger35c36862016-01-12 13:42:06 -05007409DEFUN (show_bgp_ipv6_vpn_route,
7410 show_bgp_ipv6_vpn_route_cmd,
7411 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007412 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007413 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007414 "Address Family\n"
7415 "Display VPN NLRI specific information\n"
7416 "Network in the BGP routing table to display\n")
7417{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007418 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL);
Lou Berger35c36862016-01-12 13:42:06 -05007419}
Lou Berger35c36862016-01-12 13:42:06 -05007420
7421DEFUN (show_bgp_ipv4_vpn_rd_route,
7422 show_bgp_ipv4_vpn_rd_route_cmd,
7423 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7424 SHOW_STR
7425 BGP_STR
7426 IP_STR
7427 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007428 "Display information for a route distinguisher\n"
7429 "VPN Route Distinguisher\n"
7430 "Network in the BGP routing table to display\n")
7431{
7432 int ret;
7433 struct prefix_rd prd;
7434
7435 ret = str2prefix_rd (argv[0], &prd);
7436 if (! ret)
7437 {
7438 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7439 return CMD_WARNING;
7440 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007441 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007442}
7443
Lou Berger35c36862016-01-12 13:42:06 -05007444DEFUN (show_bgp_ipv6_vpn_rd_route,
7445 show_bgp_ipv6_vpn_rd_route_cmd,
7446 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007447 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007448 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007449 "Address Family\n"
7450 "Display VPN NLRI specific information\n"
7451 "Display information for a route distinguisher\n"
7452 "VPN Route Distinguisher\n"
7453 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007454{
Lou Berger35c36862016-01-12 13:42:06 -05007455 int ret;
7456 struct prefix_rd prd;
7457
7458 ret = str2prefix_rd (argv[0], &prd);
7459 if (! ret)
7460 {
7461 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7462 return CMD_WARNING;
7463 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007464 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
7465}
7466
7467DEFUN (show_bgp_prefix_pathtype,
7468 show_bgp_prefix_pathtype_cmd,
7469 "show bgp X:X::X:X/M (bestpath|multipath)",
7470 SHOW_STR
7471 BGP_STR
7472 "IPv6 prefix <network>/<length>\n"
7473 "Display only the bestpath\n"
7474 "Display only multipaths\n")
7475{
7476 if (strncmp (argv[1], "b", 1) == 0)
7477 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7478 else
7479 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7480}
7481
7482ALIAS (show_bgp_prefix_pathtype,
7483 show_bgp_ipv6_prefix_pathtype_cmd,
7484 "show bgp ipv6 X:X::X:X/M (bestpath|multipath)",
7485 SHOW_STR
7486 BGP_STR
7487 "Address family\n"
7488 "IPv6 prefix <network>/<length>\n"
7489 "Display only the bestpath\n"
7490 "Display only multipaths\n")
7491
7492DEFUN (show_bgp_ipv6_safi_prefix_pathtype,
7493 show_bgp_ipv6_safi_prefix_pathtype_cmd,
7494 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath)",
7495 SHOW_STR
7496 BGP_STR
7497 "Address family\n"
7498 "Address Family modifier\n"
7499 "Address Family modifier\n"
7500 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
7501 "Display only the bestpath\n"
7502 "Display only multipaths\n")
7503{
7504 if (strncmp (argv[0], "m", 1) == 0)
7505 if (strncmp (argv[2], "b", 1) == 0)
7506 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH);
7507 else
7508 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH);
7509 else
7510 if (strncmp (argv[2], "b", 1) == 0)
7511 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7512 else
7513 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
paul718e3742002-12-13 20:15:29 +00007514}
7515
Lou Berger651b4022016-01-12 13:42:07 -05007516DEFUN (show_bgp_ipv4_encap_route,
7517 show_bgp_ipv4_encap_route_cmd,
7518 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007519 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007520 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007521 IP_STR
7522 "Display ENCAP NLRI specific information\n"
7523 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007524{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007525 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007526}
7527
Lou Berger651b4022016-01-12 13:42:07 -05007528DEFUN (show_bgp_ipv6_encap_route,
7529 show_bgp_ipv6_encap_route_cmd,
7530 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007531 SHOW_STR
7532 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007533 IP6_STR
7534 "Display ENCAP NLRI specific information\n"
7535 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007536{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007537 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007538}
7539
Lou Berger651b4022016-01-12 13:42:07 -05007540DEFUN (show_bgp_ipv4_safi_rd_route,
7541 show_bgp_ipv4_safi_rd_route_cmd,
7542 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007543 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007544 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007545 "Address Family\n"
7546 "Address Family Modifier\n"
7547 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007548 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007549 "ENCAP Route Distinguisher\n"
7550 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007551{
7552 int ret;
7553 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007554 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007555
Lou Berger651b4022016-01-12 13:42:07 -05007556 if (bgp_parse_safi(argv[0], &safi)) {
7557 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7558 return CMD_WARNING;
7559 }
7560 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007561 if (! ret)
7562 {
7563 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7564 return CMD_WARNING;
7565 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007566 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007567}
7568
Lou Berger651b4022016-01-12 13:42:07 -05007569DEFUN (show_bgp_ipv6_safi_rd_route,
7570 show_bgp_ipv6_safi_rd_route_cmd,
7571 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007572 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007573 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007574 "Address Family\n"
7575 "Address Family Modifier\n"
7576 "Address Family Modifier\n"
7577 "Display information for a route distinguisher\n"
7578 "ENCAP Route Distinguisher\n"
7579 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007580{
Lou Berger651b4022016-01-12 13:42:07 -05007581 int ret;
7582 struct prefix_rd prd;
7583 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007584
Lou Berger651b4022016-01-12 13:42:07 -05007585 if (bgp_parse_safi(argv[0], &safi)) {
7586 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7587 return CMD_WARNING;
7588 }
7589 ret = str2prefix_rd (argv[1], &prd);
7590 if (! ret)
7591 {
7592 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7593 return CMD_WARNING;
7594 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007595 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007596}
7597
Lou Berger35c36862016-01-12 13:42:06 -05007598DEFUN (show_bgp_ipv4_prefix,
7599 show_bgp_ipv4_prefix_cmd,
7600 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007601 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007602 BGP_STR
paul718e3742002-12-13 20:15:29 +00007603 IP_STR
paul718e3742002-12-13 20:15:29 +00007604 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7605{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007606 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007607}
7608
Lou Berger35c36862016-01-12 13:42:06 -05007609DEFUN (show_bgp_ipv4_safi_prefix,
7610 show_bgp_ipv4_safi_prefix_cmd,
7611 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007612 SHOW_STR
7613 BGP_STR
7614 "Address family\n"
7615 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007616 "Address Family modifier\n"
7617 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007618{
7619 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007620 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007621
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007622 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007623}
7624
Lou Berger35c36862016-01-12 13:42:06 -05007625DEFUN (show_bgp_ipv4_vpn_prefix,
7626 show_bgp_ipv4_vpn_prefix_cmd,
7627 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007628 SHOW_STR
7629 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007630 IP_STR
7631 "Display VPN NLRI specific information\n"
7632 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007633{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007634 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007635}
7636
Lou Berger35c36862016-01-12 13:42:06 -05007637DEFUN (show_bgp_ipv6_vpn_prefix,
7638 show_bgp_ipv6_vpn_prefix_cmd,
7639 "show bgp ipv6 vpn X:X::X:X/M",
7640 SHOW_STR
7641 BGP_STR
7642 "Address Family\n"
7643 "Display VPN NLRI specific information\n"
7644 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7645{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007646 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL);
Lou Berger35c36862016-01-12 13:42:06 -05007647}
Lou Berger35c36862016-01-12 13:42:06 -05007648
Lou Berger651b4022016-01-12 13:42:07 -05007649DEFUN (show_bgp_ipv4_encap_prefix,
7650 show_bgp_ipv4_encap_prefix_cmd,
7651 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007652 SHOW_STR
7653 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007654 IP_STR
7655 "Display ENCAP NLRI specific information\n"
7656 "Display information about ENCAP NLRIs\n"
7657 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7658{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007659 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007660}
paul718e3742002-12-13 20:15:29 +00007661
Lou Berger651b4022016-01-12 13:42:07 -05007662DEFUN (show_bgp_ipv6_encap_prefix,
7663 show_bgp_ipv6_encap_prefix_cmd,
7664 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007665 SHOW_STR
7666 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007667 IP_STR
7668 "Display ENCAP NLRI specific information\n"
7669 "Display information about ENCAP NLRIs\n"
7670 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7671{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007672 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007673}
Lou Berger651b4022016-01-12 13:42:07 -05007674
7675DEFUN (show_bgp_ipv4_safi_rd_prefix,
7676 show_bgp_ipv4_safi_rd_prefix_cmd,
7677 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7678 SHOW_STR
7679 BGP_STR
7680 "Address Family\n"
7681 "Address Family Modifier\n"
7682 "Address Family Modifier\n"
7683 "Display information for a route distinguisher\n"
7684 "ENCAP Route Distinguisher\n"
7685 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7686{
7687 int ret;
7688 struct prefix_rd prd;
7689 safi_t safi;
7690
7691 if (bgp_parse_safi(argv[0], &safi)) {
7692 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7693 return CMD_WARNING;
7694 }
7695
7696 ret = str2prefix_rd (argv[1], &prd);
7697 if (! ret)
7698 {
7699 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7700 return CMD_WARNING;
7701 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007702 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007703}
7704
Lou Berger651b4022016-01-12 13:42:07 -05007705DEFUN (show_bgp_ipv6_safi_rd_prefix,
7706 show_bgp_ipv6_safi_rd_prefix_cmd,
7707 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7708 SHOW_STR
7709 BGP_STR
7710 "Address Family\n"
7711 "Address Family Modifier\n"
7712 "Address Family Modifier\n"
7713 "Display information for a route distinguisher\n"
7714 "ENCAP Route Distinguisher\n"
7715 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7716{
7717 int ret;
7718 struct prefix_rd prd;
7719 safi_t safi;
7720
7721 if (bgp_parse_safi(argv[0], &safi)) {
7722 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7723 return CMD_WARNING;
7724 }
7725
7726 ret = str2prefix_rd (argv[1], &prd);
7727 if (! ret)
7728 {
7729 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7730 return CMD_WARNING;
7731 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007732 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007733}
Lou Berger651b4022016-01-12 13:42:07 -05007734
7735DEFUN (show_bgp_afi_safi_view,
7736 show_bgp_afi_safi_view_cmd,
7737 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7738 SHOW_STR
7739 BGP_STR
7740 "BGP view\n"
7741 "BGP view name\n"
7742 "Address Family\n"
7743 "Address Family\n"
7744 "Address Family Modifier\n"
7745 "Address Family Modifier\n"
7746 "Address Family Modifier\n"
7747 "Address Family Modifier\n"
7748 )
7749{
7750 struct bgp *bgp;
7751 safi_t safi;
7752 afi_t afi;
7753
7754 if (bgp_parse_afi(argv[1], &afi)) {
7755 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7756 return CMD_WARNING;
7757 }
7758 if (bgp_parse_safi(argv[2], &safi)) {
7759 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7760 return CMD_WARNING;
7761 }
7762
7763 /* BGP structure lookup. */
7764 bgp = bgp_lookup_by_name (argv[0]);
7765 if (bgp == NULL)
7766 {
7767 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7768 return CMD_WARNING;
7769 }
7770
7771 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7772}
7773
7774DEFUN (show_bgp_view_afi_safi_route,
7775 show_bgp_view_afi_safi_route_cmd,
7776 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7777 SHOW_STR
7778 BGP_STR
7779 "BGP view\n"
7780 "View name\n"
7781 "Address Family\n"
7782 "Address Family\n"
7783 "Address Family Modifier\n"
7784 "Address Family Modifier\n"
7785 "Address Family Modifier\n"
7786 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007787 "Network in the BGP routing table to display\n")
7788{
Lou Berger651b4022016-01-12 13:42:07 -05007789 safi_t safi;
7790 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007791
Lou Berger651b4022016-01-12 13:42:07 -05007792 if (bgp_parse_afi(argv[1], &afi)) {
7793 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7794 return CMD_WARNING;
7795 }
7796 if (bgp_parse_safi(argv[2], &safi)) {
7797 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7798 return CMD_WARNING;
7799 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007800 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007801}
7802
7803DEFUN (show_bgp_view_afi_safi_prefix,
7804 show_bgp_view_afi_safi_prefix_cmd,
7805 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7806 SHOW_STR
7807 BGP_STR
7808 "BGP view\n"
7809 "View name\n"
7810 "Address Family\n"
7811 "Address Family\n"
7812 "Address Family Modifier\n"
7813 "Address Family Modifier\n"
7814 "Address Family Modifier\n"
7815 "Address Family Modifier\n"
7816 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7817{
7818 safi_t safi;
7819 afi_t afi;
7820
7821 if (bgp_parse_afi(argv[1], &afi)) {
7822 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7823 return CMD_WARNING;
7824 }
7825 if (bgp_parse_safi(argv[2], &safi)) {
7826 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7827 return CMD_WARNING;
7828 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007829 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007830}
7831
7832/* new001 */
7833DEFUN (show_bgp_afi,
7834 show_bgp_afi_cmd,
7835 "show bgp (ipv4|ipv6)",
7836 SHOW_STR
7837 BGP_STR
7838 "Address family\n"
7839 "Address family\n")
7840{
7841 afi_t afi;
7842
7843 if (bgp_parse_afi(argv[0], &afi)) {
7844 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7845 return CMD_WARNING;
7846 }
7847 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7848 NULL);
7849}
7850
Lou Berger651b4022016-01-12 13:42:07 -05007851DEFUN (show_bgp_ipv6_safi,
7852 show_bgp_ipv6_safi_cmd,
7853 "show bgp ipv6 (unicast|multicast)",
7854 SHOW_STR
7855 BGP_STR
7856 "Address family\n"
7857 "Address Family modifier\n"
7858 "Address Family modifier\n")
7859{
7860 if (strncmp (argv[0], "m", 1) == 0)
7861 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7862 NULL);
7863
7864 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007865}
7866
Lou Berger35c36862016-01-12 13:42:06 -05007867DEFUN (show_bgp_ipv6_route,
7868 show_bgp_ipv6_route_cmd,
7869 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007870 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007871 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007872 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007873 "Network in the BGP routing table to display\n")
7874{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007875 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007876}
7877
Lou Berger35c36862016-01-12 13:42:06 -05007878DEFUN (show_bgp_ipv6_safi_route,
7879 show_bgp_ipv6_safi_route_cmd,
7880 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007881 SHOW_STR
7882 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007883 "Address family\n"
7884 "Address Family modifier\n"
7885 "Address Family modifier\n"
7886 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007887{
Lou Berger35c36862016-01-12 13:42:06 -05007888 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007889 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Berger35c36862016-01-12 13:42:06 -05007890
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007891 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007892}
7893
Lou Bergerf9b6c392016-01-12 13:42:09 -05007894/* old command */
7895DEFUN (show_ipv6_bgp_route,
7896 show_ipv6_bgp_route_cmd,
7897 "show ipv6 bgp X:X::X:X",
7898 SHOW_STR
7899 IP_STR
7900 BGP_STR
7901 "Network in the BGP routing table to display\n")
7902{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007903 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007904}
7905
7906DEFUN (show_bgp_prefix,
7907 show_bgp_prefix_cmd,
7908 "show bgp X:X::X:X/M",
7909 SHOW_STR
7910 BGP_STR
7911 "IPv6 prefix <network>/<length>\n")
7912{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007913 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007914}
7915
7916
Lou Berger35c36862016-01-12 13:42:06 -05007917/* new002 */
7918DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007919 show_bgp_ipv6_prefix_cmd,
7920 "show bgp ipv6 X:X::X:X/M",
7921 SHOW_STR
7922 BGP_STR
7923 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007924 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7925{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007926 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Berger35c36862016-01-12 13:42:06 -05007927}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007928DEFUN (show_bgp_ipv6_safi_prefix,
7929 show_bgp_ipv6_safi_prefix_cmd,
7930 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7931 SHOW_STR
7932 BGP_STR
7933 "Address family\n"
7934 "Address Family modifier\n"
7935 "Address Family modifier\n"
7936 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7937{
7938 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007939 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007940
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007941 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007942}
7943
Lou Bergerf9b6c392016-01-12 13:42:09 -05007944/* old command */
7945DEFUN (show_ipv6_bgp_prefix,
7946 show_ipv6_bgp_prefix_cmd,
7947 "show ipv6 bgp X:X::X:X/M",
7948 SHOW_STR
7949 IP_STR
7950 BGP_STR
7951 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7952{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007953 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007954}
7955
paulbb46e942003-10-24 19:02:03 +00007956DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007957 show_bgp_view_cmd,
7958 "show bgp view WORD",
7959 SHOW_STR
7960 BGP_STR
7961 "BGP view\n"
7962 "View name\n")
7963{
7964 struct bgp *bgp;
7965
7966 /* BGP structure lookup. */
7967 bgp = bgp_lookup_by_name (argv[0]);
7968 if (bgp == NULL)
7969 {
7970 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7971 return CMD_WARNING;
7972 }
7973
7974 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7975}
7976
7977DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05007978 show_bgp_view_ipv6_cmd,
7979 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00007980 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05007981 BGP_STR
paulbb46e942003-10-24 19:02:03 +00007982 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05007983 "View name\n"
7984 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00007985{
7986 struct bgp *bgp;
7987
7988 /* BGP structure lookup. */
7989 bgp = bgp_lookup_by_name (argv[0]);
7990 if (bgp == NULL)
7991 {
7992 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7993 return CMD_WARNING;
7994 }
7995
ajs5a646652004-11-05 01:25:55 +00007996 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00007997}
paulbb46e942003-10-24 19:02:03 +00007998
7999DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05008000 show_bgp_view_route_cmd,
8001 "show bgp view WORD X:X::X:X",
8002 SHOW_STR
8003 BGP_STR
8004 "BGP view\n"
8005 "View name\n"
8006 "Network in the BGP routing table to display\n")
8007{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008008 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05008009}
8010
8011DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00008012 show_bgp_view_ipv6_route_cmd,
8013 "show bgp view WORD ipv6 X:X::X:X",
8014 SHOW_STR
8015 BGP_STR
8016 "BGP view\n"
8017 "View name\n"
8018 "Address family\n"
8019 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00008020{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008021 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paulbb46e942003-10-24 19:02:03 +00008022}
8023
Lou Bergerf9b6c392016-01-12 13:42:09 -05008024/* old command */
8025DEFUN (show_ipv6_mbgp,
8026 show_ipv6_mbgp_cmd,
8027 "show ipv6 mbgp",
8028 SHOW_STR
8029 IP_STR
8030 MBGP_STR)
8031{
8032 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
8033 NULL);
8034}
8035
8036/* old command */
8037DEFUN (show_ipv6_mbgp_route,
8038 show_ipv6_mbgp_route_cmd,
8039 "show ipv6 mbgp X:X::X:X",
8040 SHOW_STR
8041 IP_STR
8042 MBGP_STR
8043 "Network in the MBGP routing table to display\n")
8044{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008045 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05008046}
8047
8048/* old command */
8049DEFUN (show_ipv6_mbgp_prefix,
8050 show_ipv6_mbgp_prefix_cmd,
8051 "show ipv6 mbgp X:X::X:X/M",
8052 SHOW_STR
8053 IP_STR
8054 MBGP_STR
8055 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
8056{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008057 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05008058}
8059
Lou Berger35c36862016-01-12 13:42:06 -05008060DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05008061 show_bgp_view_prefix_cmd,
8062 "show bgp view WORD X:X::X:X/M",
8063 SHOW_STR
8064 BGP_STR
8065 "BGP view\n"
8066 "View name\n"
8067 "IPv6 prefix <network>/<length>\n")
8068{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008069 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05008070}
8071
8072DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00008073 show_bgp_view_ipv6_prefix_cmd,
8074 "show bgp view WORD ipv6 X:X::X:X/M",
8075 SHOW_STR
8076 BGP_STR
8077 "BGP view\n"
8078 "View name\n"
8079 "Address family\n"
8080 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00008081{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008082 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00008083}
8084
paul94f2b392005-06-28 12:44:16 +00008085static int
paulfd79ac92004-10-13 05:06:08 +00008086bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008087 safi_t safi, enum bgp_show_type type)
8088{
8089 int i;
8090 struct buffer *b;
8091 char *regstr;
8092 int first;
8093 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00008094 int rc;
paul718e3742002-12-13 20:15:29 +00008095
8096 first = 0;
8097 b = buffer_new (1024);
8098 for (i = 0; i < argc; i++)
8099 {
8100 if (first)
8101 buffer_putc (b, ' ');
8102 else
8103 {
8104 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
8105 continue;
8106 first = 1;
8107 }
8108
8109 buffer_putstr (b, argv[i]);
8110 }
8111 buffer_putc (b, '\0');
8112
8113 regstr = buffer_getstr (b);
8114 buffer_free (b);
8115
8116 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00008117 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00008118 if (! regex)
8119 {
8120 vty_out (vty, "Can't compile regexp %s%s", argv[0],
8121 VTY_NEWLINE);
8122 return CMD_WARNING;
8123 }
8124
ajs5a646652004-11-05 01:25:55 +00008125 rc = bgp_show (vty, NULL, afi, safi, type, regex);
8126 bgp_regex_free (regex);
8127 return rc;
paul718e3742002-12-13 20:15:29 +00008128}
8129
Lou Bergerf9b6c392016-01-12 13:42:09 -05008130
8131DEFUN (show_ip_bgp_regexp,
8132 show_ip_bgp_regexp_cmd,
8133 "show ip bgp regexp .LINE",
8134 SHOW_STR
8135 IP_STR
8136 BGP_STR
8137 "Display routes matching the AS path regular expression\n"
8138 "A regular-expression to match the BGP AS paths\n")
8139{
8140 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8141 bgp_show_type_regexp);
8142}
8143
8144DEFUN (show_ip_bgp_flap_regexp,
8145 show_ip_bgp_flap_regexp_cmd,
8146 "show ip bgp flap-statistics regexp .LINE",
8147 SHOW_STR
8148 IP_STR
8149 BGP_STR
8150 "Display flap statistics of routes\n"
8151 "Display routes matching the AS path regular expression\n"
8152 "A regular-expression to match the BGP AS paths\n")
8153{
8154 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8155 bgp_show_type_flap_regexp);
8156}
8157
8158ALIAS (show_ip_bgp_flap_regexp,
8159 show_ip_bgp_damp_flap_regexp_cmd,
8160 "show ip bgp dampening flap-statistics regexp .LINE",
8161 SHOW_STR
8162 IP_STR
8163 BGP_STR
8164 "Display detailed information about dampening\n"
8165 "Display flap statistics of routes\n"
8166 "Display routes matching the AS path regular expression\n"
8167 "A regular-expression to match the BGP AS paths\n")
8168
8169DEFUN (show_ip_bgp_ipv4_regexp,
8170 show_ip_bgp_ipv4_regexp_cmd,
8171 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
8172 SHOW_STR
8173 IP_STR
8174 BGP_STR
8175 "Address family\n"
8176 "Address Family modifier\n"
8177 "Address Family modifier\n"
8178 "Display routes matching the AS path regular expression\n"
8179 "A regular-expression to match the BGP AS paths\n")
8180{
8181 if (strncmp (argv[0], "m", 1) == 0)
8182 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
8183 bgp_show_type_regexp);
8184
8185 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8186 bgp_show_type_regexp);
8187}
8188
Lou Bergerf9b6c392016-01-12 13:42:09 -05008189DEFUN (show_bgp_regexp,
8190 show_bgp_regexp_cmd,
8191 "show bgp regexp .LINE",
8192 SHOW_STR
8193 BGP_STR
8194 "Display routes matching the AS path regular expression\n"
8195 "A regular-expression to match the BGP AS paths\n")
8196{
8197 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8198 bgp_show_type_regexp);
8199}
8200
8201/* old command */
8202DEFUN (show_ipv6_bgp_regexp,
8203 show_ipv6_bgp_regexp_cmd,
8204 "show ipv6 bgp regexp .LINE",
8205 SHOW_STR
8206 IP_STR
8207 BGP_STR
8208 "Display routes matching the AS path regular expression\n"
8209 "A regular-expression to match the BGP AS paths\n")
8210{
8211 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8212 bgp_show_type_regexp);
8213}
8214
8215/* old command */
8216DEFUN (show_ipv6_mbgp_regexp,
8217 show_ipv6_mbgp_regexp_cmd,
8218 "show ipv6 mbgp regexp .LINE",
8219 SHOW_STR
8220 IP_STR
8221 BGP_STR
8222 "Display routes matching the AS path regular expression\n"
8223 "A regular-expression to match the MBGP AS paths\n")
8224{
8225 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
8226 bgp_show_type_regexp);
8227}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008228
Lou Berger651b4022016-01-12 13:42:07 -05008229DEFUN (show_bgp_ipv4_safi_flap_regexp,
8230 show_bgp_ipv4_safi_flap_regexp_cmd,
8231 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008232 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008233 BGP_STR
paul718e3742002-12-13 20:15:29 +00008234 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008235 "Address Family Modifier\n"
8236 "Address Family Modifier\n"
8237 "Address Family Modifier\n"
8238 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008239 "Display flap statistics of routes\n"
8240 "Display routes matching the AS path regular expression\n"
8241 "A regular-expression to match the BGP AS paths\n")
8242{
Lou Berger651b4022016-01-12 13:42:07 -05008243 safi_t safi;
8244
8245 if (bgp_parse_safi(argv[0], &safi)) {
8246 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8247 return CMD_WARNING;
8248 }
8249 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
8250 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00008251}
8252
Lou Berger651b4022016-01-12 13:42:07 -05008253ALIAS (show_bgp_ipv4_safi_flap_regexp,
8254 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
8255 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05308256 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308257 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008258 IP_STR
8259 "Address Family Modifier\n"
8260 "Address Family Modifier\n"
8261 "Address Family Modifier\n"
8262 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308263 "Display detailed information about dampening\n"
8264 "Display flap statistics of routes\n"
8265 "Display routes matching the AS path regular expression\n"
8266 "A regular-expression to match the BGP AS paths\n")
8267
Lou Berger651b4022016-01-12 13:42:07 -05008268DEFUN (show_bgp_ipv6_safi_flap_regexp,
8269 show_bgp_ipv6_safi_flap_regexp_cmd,
8270 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008271 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008272 BGP_STR
8273 IPV6_STR
8274 "Address Family Modifier\n"
8275 "Address Family Modifier\n"
8276 "Address Family Modifier\n"
8277 "Address Family Modifier\n"
8278 "Display flap statistics of routes\n"
8279 "Display routes matching the AS path regular expression\n"
8280 "A regular-expression to match the BGP AS paths\n")
8281{
8282 safi_t safi;
8283
8284 if (bgp_parse_safi(argv[0], &safi)) {
8285 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8286 return CMD_WARNING;
8287 }
8288 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8289 bgp_show_type_flap_regexp);
8290}
8291
8292ALIAS (show_bgp_ipv6_safi_flap_regexp,
8293 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8294 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8295 SHOW_STR
8296 BGP_STR
8297 IPV6_STR
8298 "Address Family Modifier\n"
8299 "Address Family Modifier\n"
8300 "Address Family Modifier\n"
8301 "Address Family Modifier\n"
8302 "Display detailed information about dampening\n"
8303 "Display flap statistics of routes\n"
8304 "Display routes matching the AS path regular expression\n"
8305 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008306
8307DEFUN (show_bgp_ipv4_safi_regexp,
8308 show_bgp_ipv4_safi_regexp_cmd,
8309 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8310 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008311 BGP_STR
8312 "Address family\n"
8313 "Address Family modifier\n"
8314 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008315 "Address Family modifier\n"
8316 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008317 "Display routes matching the AS path regular expression\n"
8318 "A regular-expression to match the BGP AS paths\n")
8319{
Lou Berger651b4022016-01-12 13:42:07 -05008320 safi_t safi;
8321 if (bgp_parse_safi(argv[0], &safi)) {
8322 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8323 return CMD_WARNING;
8324 }
paul718e3742002-12-13 20:15:29 +00008325
Lou Berger651b4022016-01-12 13:42:07 -05008326 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008327 bgp_show_type_regexp);
8328}
Lou Berger205e6742016-01-12 13:42:11 -05008329
Lou Berger651b4022016-01-12 13:42:07 -05008330DEFUN (show_bgp_ipv6_safi_regexp,
8331 show_bgp_ipv6_safi_regexp_cmd,
8332 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008333 SHOW_STR
8334 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008335 "Address family\n"
8336 "Address Family modifier\n"
8337 "Address Family modifier\n"
8338 "Address Family modifier\n"
8339 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008340 "Display routes matching the AS path regular expression\n"
8341 "A regular-expression to match the BGP AS paths\n")
8342{
Lou Berger651b4022016-01-12 13:42:07 -05008343 safi_t safi;
8344 if (bgp_parse_safi(argv[0], &safi)) {
8345 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8346 return CMD_WARNING;
8347 }
8348
8349 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008350 bgp_show_type_regexp);
8351}
8352
Lou Berger651b4022016-01-12 13:42:07 -05008353DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008354 show_bgp_ipv6_regexp_cmd,
8355 "show bgp ipv6 regexp .LINE",
8356 SHOW_STR
8357 BGP_STR
8358 "Address family\n"
8359 "Display routes matching the AS path regular expression\n"
8360 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008361{
8362 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8363 bgp_show_type_regexp);
8364}
8365
paul94f2b392005-06-28 12:44:16 +00008366static int
paulfd79ac92004-10-13 05:06:08 +00008367bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008368 safi_t safi, enum bgp_show_type type)
8369{
8370 struct prefix_list *plist;
8371
8372 plist = prefix_list_lookup (afi, prefix_list_str);
8373 if (plist == NULL)
8374 {
8375 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8376 prefix_list_str, VTY_NEWLINE);
8377 return CMD_WARNING;
8378 }
8379
ajs5a646652004-11-05 01:25:55 +00008380 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008381}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008382DEFUN (show_ip_bgp_prefix_list,
8383 show_ip_bgp_prefix_list_cmd,
8384 "show ip bgp prefix-list WORD",
8385 SHOW_STR
8386 IP_STR
8387 BGP_STR
8388 "Display routes conforming to the prefix-list\n"
8389 "IP prefix-list name\n")
8390{
8391 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8392 bgp_show_type_prefix_list);
8393}
8394
8395DEFUN (show_ip_bgp_flap_prefix_list,
8396 show_ip_bgp_flap_prefix_list_cmd,
8397 "show ip bgp flap-statistics prefix-list WORD",
8398 SHOW_STR
8399 IP_STR
8400 BGP_STR
8401 "Display flap statistics of routes\n"
8402 "Display routes conforming to the prefix-list\n"
8403 "IP prefix-list name\n")
8404{
8405 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8406 bgp_show_type_flap_prefix_list);
8407}
8408
8409ALIAS (show_ip_bgp_flap_prefix_list,
8410 show_ip_bgp_damp_flap_prefix_list_cmd,
8411 "show ip bgp dampening flap-statistics prefix-list WORD",
8412 SHOW_STR
8413 IP_STR
8414 BGP_STR
8415 "Display detailed information about dampening\n"
8416 "Display flap statistics of routes\n"
8417 "Display routes conforming to the prefix-list\n"
8418 "IP prefix-list name\n")
8419
8420DEFUN (show_ip_bgp_ipv4_prefix_list,
8421 show_ip_bgp_ipv4_prefix_list_cmd,
8422 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8423 SHOW_STR
8424 IP_STR
8425 BGP_STR
8426 "Address family\n"
8427 "Address Family modifier\n"
8428 "Address Family modifier\n"
8429 "Display routes conforming to the prefix-list\n"
8430 "IP prefix-list name\n")
8431{
8432 if (strncmp (argv[0], "m", 1) == 0)
8433 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8434 bgp_show_type_prefix_list);
8435
8436 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8437 bgp_show_type_prefix_list);
8438}
8439
Lou Bergerf9b6c392016-01-12 13:42:09 -05008440DEFUN (show_bgp_prefix_list,
8441 show_bgp_prefix_list_cmd,
8442 "show bgp prefix-list WORD",
8443 SHOW_STR
8444 BGP_STR
8445 "Display routes conforming to the prefix-list\n"
8446 "IPv6 prefix-list name\n")
8447{
8448 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8449 bgp_show_type_prefix_list);
8450}
8451
8452ALIAS (show_bgp_prefix_list,
8453 show_bgp_ipv6_prefix_list_cmd,
8454 "show bgp ipv6 prefix-list WORD",
8455 SHOW_STR
8456 BGP_STR
8457 "Address family\n"
8458 "Display routes conforming to the prefix-list\n"
8459 "IPv6 prefix-list name\n")
8460
8461/* old command */
8462DEFUN (show_ipv6_bgp_prefix_list,
8463 show_ipv6_bgp_prefix_list_cmd,
8464 "show ipv6 bgp prefix-list WORD",
8465 SHOW_STR
8466 IPV6_STR
8467 BGP_STR
8468 "Display routes matching the prefix-list\n"
8469 "IPv6 prefix-list name\n")
8470{
8471 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8472 bgp_show_type_prefix_list);
8473}
8474
8475/* old command */
8476DEFUN (show_ipv6_mbgp_prefix_list,
8477 show_ipv6_mbgp_prefix_list_cmd,
8478 "show ipv6 mbgp prefix-list WORD",
8479 SHOW_STR
8480 IPV6_STR
8481 MBGP_STR
8482 "Display routes matching the prefix-list\n"
8483 "IPv6 prefix-list name\n")
8484{
8485 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8486 bgp_show_type_prefix_list);
8487}
paul718e3742002-12-13 20:15:29 +00008488
Lou Berger35c36862016-01-12 13:42:06 -05008489DEFUN (show_bgp_ipv4_prefix_list,
8490 show_bgp_ipv4_prefix_list_cmd,
8491 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008492 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008493 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008494 IP_STR
paul718e3742002-12-13 20:15:29 +00008495 "Display routes conforming to the prefix-list\n"
8496 "IP prefix-list name\n")
8497{
8498 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8499 bgp_show_type_prefix_list);
8500}
8501
Lou Berger651b4022016-01-12 13:42:07 -05008502DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8503 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8504 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008505 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008506 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008507 IP_STR
8508 "Address Family Modifier\n"
8509 "Address Family Modifier\n"
8510 "Address Family Modifier\n"
8511 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008512 "Display flap statistics of routes\n"
8513 "Display routes conforming to the prefix-list\n"
8514 "IP prefix-list name\n")
8515{
Lou Berger651b4022016-01-12 13:42:07 -05008516 safi_t safi;
8517 if (bgp_parse_safi(argv[0], &safi)) {
8518 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8519 return CMD_WARNING;
8520 }
8521 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008522 bgp_show_type_flap_prefix_list);
8523}
8524
Lou Berger651b4022016-01-12 13:42:07 -05008525ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8526 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8527 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308528 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308529 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008530 IP_STR
8531 "Address Family Modifier\n"
8532 "Address Family Modifier\n"
8533 "Address Family Modifier\n"
8534 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308535 "Display detailed information about dampening\n"
8536 "Display flap statistics of routes\n"
8537 "Display routes conforming to the prefix-list\n"
8538 "IP prefix-list name\n")
8539
Lou Berger651b4022016-01-12 13:42:07 -05008540DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8541 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8542 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008543 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008544 BGP_STR
8545 IPV6_STR
8546 "Address Family Modifier\n"
8547 "Address Family Modifier\n"
8548 "Address Family Modifier\n"
8549 "Address Family Modifier\n"
8550 "Display flap statistics of routes\n"
8551 "Display routes conforming to the prefix-list\n"
8552 "IP prefix-list name\n")
8553{
8554 safi_t safi;
8555 if (bgp_parse_safi(argv[0], &safi)) {
8556 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8557 return CMD_WARNING;
8558 }
8559 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8560 bgp_show_type_flap_prefix_list);
8561}
8562ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8563 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8564 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8565 SHOW_STR
8566 BGP_STR
8567 IPV6_STR
8568 "Address Family Modifier\n"
8569 "Address Family Modifier\n"
8570 "Address Family Modifier\n"
8571 "Address Family Modifier\n"
8572 "Display detailed information about dampening\n"
8573 "Display flap statistics of routes\n"
8574 "Display routes conforming to the prefix-list\n"
8575 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008576
8577DEFUN (show_bgp_ipv4_safi_prefix_list,
8578 show_bgp_ipv4_safi_prefix_list_cmd,
8579 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8580 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008581 BGP_STR
8582 "Address family\n"
8583 "Address Family modifier\n"
8584 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008585 "Address Family modifier\n"
8586 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008587 "Display routes conforming to the prefix-list\n"
8588 "IP prefix-list name\n")
8589{
Lou Berger651b4022016-01-12 13:42:07 -05008590 safi_t safi;
8591 if (bgp_parse_safi(argv[0], &safi)) {
8592 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8593 return CMD_WARNING;
8594 }
8595 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008596 bgp_show_type_prefix_list);
8597}
Lou Berger205e6742016-01-12 13:42:11 -05008598
Lou Berger651b4022016-01-12 13:42:07 -05008599DEFUN (show_bgp_ipv6_safi_prefix_list,
8600 show_bgp_ipv6_safi_prefix_list_cmd,
8601 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008602 SHOW_STR
8603 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008604 "Address family\n"
8605 "Address Family modifier\n"
8606 "Address Family modifier\n"
8607 "Address Family modifier\n"
8608 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008609 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008610 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008611{
Lou Berger651b4022016-01-12 13:42:07 -05008612 safi_t safi;
8613 if (bgp_parse_safi(argv[0], &safi)) {
8614 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8615 return CMD_WARNING;
8616 }
8617 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008618 bgp_show_type_prefix_list);
8619}
8620
paul94f2b392005-06-28 12:44:16 +00008621static int
paulfd79ac92004-10-13 05:06:08 +00008622bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008623 safi_t safi, enum bgp_show_type type)
8624{
8625 struct as_list *as_list;
8626
8627 as_list = as_list_lookup (filter);
8628 if (as_list == NULL)
8629 {
8630 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8631 return CMD_WARNING;
8632 }
8633
ajs5a646652004-11-05 01:25:55 +00008634 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008635}
8636
Lou Bergerf9b6c392016-01-12 13:42:09 -05008637DEFUN (show_ip_bgp_filter_list,
8638 show_ip_bgp_filter_list_cmd,
8639 "show ip bgp filter-list WORD",
8640 SHOW_STR
8641 IP_STR
8642 BGP_STR
8643 "Display routes conforming to the filter-list\n"
8644 "Regular expression access list name\n")
8645{
8646 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8647 bgp_show_type_filter_list);
8648}
8649
8650DEFUN (show_ip_bgp_flap_filter_list,
8651 show_ip_bgp_flap_filter_list_cmd,
8652 "show ip bgp flap-statistics filter-list WORD",
8653 SHOW_STR
8654 IP_STR
8655 BGP_STR
8656 "Display flap statistics of routes\n"
8657 "Display routes conforming to the filter-list\n"
8658 "Regular expression access list name\n")
8659{
8660 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8661 bgp_show_type_flap_filter_list);
8662}
8663
8664ALIAS (show_ip_bgp_flap_filter_list,
8665 show_ip_bgp_damp_flap_filter_list_cmd,
8666 "show ip bgp dampening flap-statistics filter-list WORD",
8667 SHOW_STR
8668 IP_STR
8669 BGP_STR
8670 "Display detailed information about dampening\n"
8671 "Display flap statistics of routes\n"
8672 "Display routes conforming to the filter-list\n"
8673 "Regular expression access list name\n")
8674
8675DEFUN (show_ip_bgp_ipv4_filter_list,
8676 show_ip_bgp_ipv4_filter_list_cmd,
8677 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8678 SHOW_STR
8679 IP_STR
8680 BGP_STR
8681 "Address family\n"
8682 "Address Family modifier\n"
8683 "Address Family modifier\n"
8684 "Display routes conforming to the filter-list\n"
8685 "Regular expression access list name\n")
8686{
8687 if (strncmp (argv[0], "m", 1) == 0)
8688 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8689 bgp_show_type_filter_list);
8690
8691 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8692 bgp_show_type_filter_list);
8693}
8694
Lou Bergerf9b6c392016-01-12 13:42:09 -05008695DEFUN (show_bgp_filter_list,
8696 show_bgp_filter_list_cmd,
8697 "show bgp filter-list WORD",
8698 SHOW_STR
8699 BGP_STR
8700 "Display routes conforming to the filter-list\n"
8701 "Regular expression access list name\n")
8702{
8703 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8704 bgp_show_type_filter_list);
8705}
8706
8707/* old command */
8708DEFUN (show_ipv6_bgp_filter_list,
8709 show_ipv6_bgp_filter_list_cmd,
8710 "show ipv6 bgp filter-list WORD",
8711 SHOW_STR
8712 IPV6_STR
8713 BGP_STR
8714 "Display routes conforming to the filter-list\n"
8715 "Regular expression access list name\n")
8716{
8717 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8718 bgp_show_type_filter_list);
8719}
8720
8721/* old command */
8722DEFUN (show_ipv6_mbgp_filter_list,
8723 show_ipv6_mbgp_filter_list_cmd,
8724 "show ipv6 mbgp filter-list WORD",
8725 SHOW_STR
8726 IPV6_STR
8727 MBGP_STR
8728 "Display routes conforming to the filter-list\n"
8729 "Regular expression access list name\n")
8730{
8731 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8732 bgp_show_type_filter_list);
8733}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008734
8735DEFUN (show_ip_bgp_dampening_info,
8736 show_ip_bgp_dampening_params_cmd,
8737 "show ip bgp dampening parameters",
8738 SHOW_STR
8739 IP_STR
8740 BGP_STR
8741 "Display detailed information about dampening\n"
8742 "Display detail of configured dampening parameters\n")
8743{
8744 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8745}
8746
Lou Berger651b4022016-01-12 13:42:07 -05008747DEFUN (show_bgp_ipv4_filter_list,
8748 show_bgp_ipv4_filter_list_cmd,
8749 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008750 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008751 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008752 IP_STR
paul718e3742002-12-13 20:15:29 +00008753 "Display routes conforming to the filter-list\n"
8754 "Regular expression access list name\n")
8755{
8756 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8757 bgp_show_type_filter_list);
8758}
8759
Lou Berger651b4022016-01-12 13:42:07 -05008760DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8761 show_bgp_ipv4_safi_flap_filter_list_cmd,
8762 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008763 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008764 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008765 IP_STR
8766 "Address Family modifier\n"
8767 "Address Family modifier\n"
8768 "Address Family modifier\n"
8769 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008770 "Display flap statistics of routes\n"
8771 "Display routes conforming to the filter-list\n"
8772 "Regular expression access list name\n")
8773{
Lou Berger651b4022016-01-12 13:42:07 -05008774 safi_t safi;
8775
8776 if (bgp_parse_safi(argv[0], &safi)) {
8777 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8778 return CMD_WARNING;
8779 }
8780 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008781 bgp_show_type_flap_filter_list);
8782}
8783
Lou Berger651b4022016-01-12 13:42:07 -05008784ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8785 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8786 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308787 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308788 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008789 IP_STR
8790 "Address Family modifier\n"
8791 "Address Family modifier\n"
8792 "Address Family modifier\n"
8793 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308794 "Display detailed information about dampening\n"
8795 "Display flap statistics of routes\n"
8796 "Display routes conforming to the filter-list\n"
8797 "Regular expression access list name\n")
8798
Lou Berger651b4022016-01-12 13:42:07 -05008799DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8800 show_bgp_ipv6_safi_flap_filter_list_cmd,
8801 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008802 SHOW_STR
8803 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008804 IPV6_STR
8805 "Address Family modifier\n"
8806 "Address Family modifier\n"
8807 "Address Family modifier\n"
8808 "Address Family modifier\n"
8809 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008810 "Display routes conforming to the filter-list\n"
8811 "Regular expression access list name\n")
8812{
Lou Berger651b4022016-01-12 13:42:07 -05008813 safi_t safi;
8814
8815 if (bgp_parse_safi(argv[0], &safi)) {
8816 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8817 return CMD_WARNING;
8818 }
8819 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8820 bgp_show_type_flap_filter_list);
8821}
8822ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8823 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8824 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8825 SHOW_STR
8826 BGP_STR
8827 IPV6_STR
8828 "Address Family modifier\n"
8829 "Address Family modifier\n"
8830 "Address Family modifier\n"
8831 "Address Family modifier\n"
8832 "Display detailed information about dampening\n"
8833 "Display flap statistics of routes\n"
8834 "Display routes conforming to the filter-list\n"
8835 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008836
8837DEFUN (show_bgp_ipv4_safi_filter_list,
8838 show_bgp_ipv4_safi_filter_list_cmd,
8839 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8840 SHOW_STR
8841 BGP_STR
8842 "Address Family modifier\n"
8843 "Address Family modifier\n"
8844 "Address Family modifier\n"
8845 "Address Family modifier\n"
8846 "Display routes conforming to the filter-list\n"
8847 "Regular expression access list name\n")
8848{
8849 safi_t safi;
8850
8851 if (bgp_parse_safi(argv[0], &safi)) {
8852 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8853 return CMD_WARNING;
8854 }
8855 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8856 bgp_show_type_filter_list);
8857}
Lou Berger205e6742016-01-12 13:42:11 -05008858
Lou Berger651b4022016-01-12 13:42:07 -05008859DEFUN (show_bgp_ipv6_safi_filter_list,
8860 show_bgp_ipv6_safi_filter_list_cmd,
8861 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8862 SHOW_STR
8863 BGP_STR
8864 "Address Family modifier\n"
8865 "Address Family modifier\n"
8866 "Address Family modifier\n"
8867 "Address Family modifier\n"
8868 "Display routes conforming to the filter-list\n"
8869 "Regular expression access list name\n")
8870{
8871 safi_t safi;
8872
8873 if (bgp_parse_safi(argv[0], &safi)) {
8874 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8875 return CMD_WARNING;
8876 }
8877 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8878 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008879}
8880
Lou Bergerf9b6c392016-01-12 13:42:09 -05008881DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008882 show_bgp_ipv6_filter_list_cmd,
8883 "show bgp ipv6 filter-list WORD",
8884 SHOW_STR
8885 BGP_STR
8886 "Address family\n"
8887 "Display routes conforming to the filter-list\n"
8888 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008889{
8890 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8891 bgp_show_type_filter_list);
8892}
8893
Balaji9c52cae2016-01-20 22:59:26 +05308894
8895DEFUN (show_ip_bgp_ipv4_dampening_parameters,
8896 show_ip_bgp_ipv4_dampening_parameters_cmd,
8897 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
8898 SHOW_STR
8899 IP_STR
8900 BGP_STR
8901 "Address family\n"
8902 "Address Family modifier\n"
8903 "Address Family modifier\n"
8904 "Display detailed information about dampening\n"
8905 "Display detail of configured dampening parameters\n")
8906{
8907 if (strncmp(argv[0], "m", 1) == 0)
8908 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST);
8909
8910 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8911}
8912
8913
8914DEFUN (show_ip_bgp_ipv4_dampening_flap_stats,
8915 show_ip_bgp_ipv4_dampening_flap_stats_cmd,
8916 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
8917 SHOW_STR
8918 IP_STR
8919 BGP_STR
8920 "Address family\n"
8921 "Address Family modifier\n"
8922 "Address Family modifier\n"
8923 "Display detailed information about dampening\n"
8924 "Display flap statistics of routes\n")
8925{
8926 if (strncmp(argv[0], "m", 1) == 0)
8927 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8928 bgp_show_type_flap_statistics, NULL);
8929
8930 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8931 bgp_show_type_flap_statistics, NULL);
8932}
8933
8934DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths,
8935 show_ip_bgp_ipv4_dampening_dampd_paths_cmd,
8936 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
8937 SHOW_STR
8938 IP_STR
8939 BGP_STR
8940 "Address family\n"
8941 "Address Family modifier\n"
8942 "Address Family modifier\n"
8943 "Display detailed information about dampening\n"
8944 "Display paths suppressed due to dampening\n")
8945{
8946 if (strncmp(argv[0], "m", 1) == 0)
8947 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8948 bgp_show_type_dampend_paths, NULL);
8949
8950 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8951 bgp_show_type_dampend_paths, NULL);
8952}
8953
paul94f2b392005-06-28 12:44:16 +00008954static int
paulfd79ac92004-10-13 05:06:08 +00008955bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008956 safi_t safi, enum bgp_show_type type)
8957{
8958 struct route_map *rmap;
8959
8960 rmap = route_map_lookup_by_name (rmap_str);
8961 if (! rmap)
8962 {
8963 vty_out (vty, "%% %s is not a valid route-map name%s",
8964 rmap_str, VTY_NEWLINE);
8965 return CMD_WARNING;
8966 }
8967
ajs5a646652004-11-05 01:25:55 +00008968 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00008969}
8970
Lou Bergerf9b6c392016-01-12 13:42:09 -05008971DEFUN (show_ip_bgp_route_map,
8972 show_ip_bgp_route_map_cmd,
8973 "show ip bgp route-map WORD",
8974 SHOW_STR
8975 IP_STR
8976 BGP_STR
8977 "Display routes matching the route-map\n"
8978 "A route-map to match on\n")
8979{
8980 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8981 bgp_show_type_route_map);
8982}
8983
8984DEFUN (show_ip_bgp_flap_route_map,
8985 show_ip_bgp_flap_route_map_cmd,
8986 "show ip bgp flap-statistics route-map WORD",
8987 SHOW_STR
8988 IP_STR
8989 BGP_STR
8990 "Display flap statistics of routes\n"
8991 "Display routes matching the route-map\n"
8992 "A route-map to match on\n")
8993{
8994 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8995 bgp_show_type_flap_route_map);
8996}
8997
8998ALIAS (show_ip_bgp_flap_route_map,
8999 show_ip_bgp_damp_flap_route_map_cmd,
9000 "show ip bgp dampening flap-statistics route-map WORD",
9001 SHOW_STR
9002 IP_STR
9003 BGP_STR
9004 "Display detailed information about dampening\n"
9005 "Display flap statistics of routes\n"
9006 "Display routes matching the route-map\n"
9007 "A route-map to match on\n")
9008
9009DEFUN (show_ip_bgp_ipv4_route_map,
9010 show_ip_bgp_ipv4_route_map_cmd,
9011 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9012 SHOW_STR
9013 IP_STR
9014 BGP_STR
9015 "Address family\n"
9016 "Address Family modifier\n"
9017 "Address Family modifier\n"
9018 "Display routes matching the route-map\n"
9019 "A route-map to match on\n")
9020{
9021 if (strncmp (argv[0], "m", 1) == 0)
9022 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
9023 bgp_show_type_route_map);
9024
9025 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
9026 bgp_show_type_route_map);
9027}
9028
9029DEFUN (show_bgp_route_map,
9030 show_bgp_route_map_cmd,
9031 "show bgp route-map WORD",
9032 SHOW_STR
9033 BGP_STR
9034 "Display routes matching the route-map\n"
9035 "A route-map to match on\n")
9036{
9037 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9038 bgp_show_type_route_map);
9039}
9040
9041DEFUN (show_ip_bgp_cidr_only,
9042 show_ip_bgp_cidr_only_cmd,
9043 "show ip bgp cidr-only",
9044 SHOW_STR
9045 IP_STR
9046 BGP_STR
9047 "Display only routes with non-natural netmasks\n")
9048{
9049 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9050 bgp_show_type_cidr_only, NULL);
9051}
9052
9053DEFUN (show_ip_bgp_flap_cidr_only,
9054 show_ip_bgp_flap_cidr_only_cmd,
9055 "show ip bgp flap-statistics cidr-only",
9056 SHOW_STR
9057 IP_STR
9058 BGP_STR
9059 "Display flap statistics of routes\n"
9060 "Display only routes with non-natural netmasks\n")
9061{
9062 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9063 bgp_show_type_flap_cidr_only, NULL);
9064}
9065
9066ALIAS (show_ip_bgp_flap_cidr_only,
9067 show_ip_bgp_damp_flap_cidr_only_cmd,
9068 "show ip bgp dampening flap-statistics cidr-only",
9069 SHOW_STR
9070 IP_STR
9071 BGP_STR
9072 "Display detailed information about dampening\n"
9073 "Display flap statistics of routes\n"
9074 "Display only routes with non-natural netmasks\n")
9075
9076DEFUN (show_ip_bgp_ipv4_cidr_only,
9077 show_ip_bgp_ipv4_cidr_only_cmd,
9078 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9079 SHOW_STR
9080 IP_STR
9081 BGP_STR
9082 "Address family\n"
9083 "Address Family modifier\n"
9084 "Address Family modifier\n"
9085 "Display only routes with non-natural netmasks\n")
9086{
9087 if (strncmp (argv[0], "m", 1) == 0)
9088 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9089 bgp_show_type_cidr_only, NULL);
9090
9091 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9092 bgp_show_type_cidr_only, NULL);
9093}
9094
9095DEFUN (show_ip_bgp_community_all,
9096 show_ip_bgp_community_all_cmd,
9097 "show ip bgp community",
9098 SHOW_STR
9099 IP_STR
9100 BGP_STR
9101 "Display routes matching the communities\n")
9102{
9103 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9104 bgp_show_type_community_all, NULL);
9105}
9106
9107DEFUN (show_ip_bgp_ipv4_community_all,
9108 show_ip_bgp_ipv4_community_all_cmd,
9109 "show ip bgp ipv4 (unicast|multicast) community",
9110 SHOW_STR
9111 IP_STR
9112 BGP_STR
9113 "Address family\n"
9114 "Address Family modifier\n"
9115 "Address Family modifier\n"
9116 "Display routes matching the communities\n")
9117{
9118 if (strncmp (argv[0], "m", 1) == 0)
9119 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9120 bgp_show_type_community_all, NULL);
9121
9122 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9123 bgp_show_type_community_all, NULL);
9124}
9125
Lou Bergerf9b6c392016-01-12 13:42:09 -05009126DEFUN (show_bgp_community_all,
9127 show_bgp_community_all_cmd,
9128 "show bgp community",
9129 SHOW_STR
9130 BGP_STR
9131 "Display routes matching the communities\n")
9132{
9133 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9134 bgp_show_type_community_all, NULL);
9135}
9136
9137ALIAS (show_bgp_community_all,
9138 show_bgp_ipv6_community_all_cmd,
9139 "show bgp ipv6 community",
9140 SHOW_STR
9141 BGP_STR
9142 "Address family\n"
9143 "Display routes matching the communities\n")
9144
9145/* old command */
9146DEFUN (show_ipv6_bgp_community_all,
9147 show_ipv6_bgp_community_all_cmd,
9148 "show ipv6 bgp community",
9149 SHOW_STR
9150 IPV6_STR
9151 BGP_STR
9152 "Display routes matching the communities\n")
9153{
9154 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9155 bgp_show_type_community_all, NULL);
9156}
9157
9158/* old command */
9159DEFUN (show_ipv6_mbgp_community_all,
9160 show_ipv6_mbgp_community_all_cmd,
9161 "show ipv6 mbgp community",
9162 SHOW_STR
9163 IPV6_STR
9164 MBGP_STR
9165 "Display routes matching the communities\n")
9166{
9167 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
9168 bgp_show_type_community_all, NULL);
9169}
Lou Bergerf9b6c392016-01-12 13:42:09 -05009170
Lou Berger651b4022016-01-12 13:42:07 -05009171DEFUN (show_bgp_ipv4_route_map,
9172 show_bgp_ipv4_route_map_cmd,
9173 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00009174 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009175 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009176 IP_STR
paul718e3742002-12-13 20:15:29 +00009177 "Display routes matching the route-map\n"
9178 "A route-map to match on\n")
9179{
9180 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
9181 bgp_show_type_route_map);
9182}
9183
Lou Berger651b4022016-01-12 13:42:07 -05009184DEFUN (show_bgp_ipv4_safi_flap_route_map,
9185 show_bgp_ipv4_safi_flap_route_map_cmd,
9186 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00009187 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009188 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009189 IP_STR
9190 "Address Family Modifier\n"
9191 "Address Family Modifier\n"
9192 "Address Family Modifier\n"
9193 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009194 "Display flap statistics of routes\n"
9195 "Display routes matching the route-map\n"
9196 "A route-map to match on\n")
9197{
Lou Berger651b4022016-01-12 13:42:07 -05009198 safi_t safi;
9199 if (bgp_parse_safi(argv[0], &safi)) {
9200 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9201 return CMD_WARNING;
9202 }
9203 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00009204 bgp_show_type_flap_route_map);
9205}
9206
Lou Berger651b4022016-01-12 13:42:07 -05009207ALIAS (show_bgp_ipv4_safi_flap_route_map,
9208 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
9209 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05309210 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309211 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009212 IP_STR
9213 "Address Family Modifier\n"
9214 "Address Family Modifier\n"
9215 "Address Family Modifier\n"
9216 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309217 "Display detailed information about dampening\n"
9218 "Display flap statistics of routes\n"
9219 "Display routes matching the route-map\n"
9220 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05009221
Lou Berger651b4022016-01-12 13:42:07 -05009222DEFUN (show_bgp_ipv6_safi_flap_route_map,
9223 show_bgp_ipv6_safi_flap_route_map_cmd,
9224 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00009225 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05009226 BGP_STR
9227 IPV6_STR
9228 "Address Family Modifier\n"
9229 "Address Family Modifier\n"
9230 "Address Family Modifier\n"
9231 "Address Family Modifier\n"
9232 "Display flap statistics of routes\n"
9233 "Display routes matching the route-map\n"
9234 "A route-map to match on\n")
9235{
9236 safi_t safi;
9237 if (bgp_parse_safi(argv[0], &safi)) {
9238 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9239 return CMD_WARNING;
9240 }
9241 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
9242 bgp_show_type_flap_route_map);
9243}
9244ALIAS (show_bgp_ipv6_safi_flap_route_map,
9245 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
9246 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
9247 SHOW_STR
9248 BGP_STR
9249 IPV6_STR
9250 "Address Family Modifier\n"
9251 "Address Family Modifier\n"
9252 "Address Family Modifier\n"
9253 "Address Family Modifier\n"
9254 "Display detailed information about dampening\n"
9255 "Display flap statistics of routes\n"
9256 "Display routes matching the route-map\n"
9257 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009258
9259DEFUN (show_bgp_ipv4_safi_route_map,
9260 show_bgp_ipv4_safi_route_map_cmd,
9261 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
9262 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009263 BGP_STR
9264 "Address family\n"
9265 "Address Family modifier\n"
9266 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05009267 "Address Family modifier\n"
9268 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009269 "Display routes matching the route-map\n"
9270 "A route-map to match on\n")
9271{
Lou Berger651b4022016-01-12 13:42:07 -05009272 safi_t safi;
9273 if (bgp_parse_safi(argv[0], &safi)) {
9274 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9275 return CMD_WARNING;
9276 }
9277 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00009278 bgp_show_type_route_map);
9279}
Lou Berger205e6742016-01-12 13:42:11 -05009280
Lou Berger651b4022016-01-12 13:42:07 -05009281DEFUN (show_bgp_ipv6_safi_route_map,
9282 show_bgp_ipv6_safi_route_map_cmd,
9283 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00009284 SHOW_STR
9285 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009286 "Address family\n"
9287 "Address Family modifier\n"
9288 "Address Family modifier\n"
9289 "Address Family modifier\n"
9290 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009291 "Display routes matching the route-map\n"
9292 "A route-map to match on\n")
9293{
Lou Berger651b4022016-01-12 13:42:07 -05009294 safi_t safi;
9295 if (bgp_parse_safi(argv[0], &safi)) {
9296 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9297 return CMD_WARNING;
9298 }
9299 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00009300 bgp_show_type_route_map);
9301}
9302
Lou Berger651b4022016-01-12 13:42:07 -05009303DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00009304 show_bgp_ipv6_route_map_cmd,
9305 "show bgp ipv6 route-map WORD",
9306 SHOW_STR
9307 BGP_STR
9308 "Address family\n"
9309 "Display routes matching the route-map\n"
9310 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009311{
9312 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9313 bgp_show_type_route_map);
9314}
David Lamparter6b0655a2014-06-04 06:53:35 +02009315
Lou Berger651b4022016-01-12 13:42:07 -05009316DEFUN (show_bgp_ipv4_cidr_only,
9317 show_bgp_ipv4_cidr_only_cmd,
9318 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00009319 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009320 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009321 IP_STR
paul718e3742002-12-13 20:15:29 +00009322 "Display only routes with non-natural netmasks\n")
9323{
9324 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009325 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009326}
9327
Lou Berger651b4022016-01-12 13:42:07 -05009328DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
9329 show_bgp_ipv4_safi_flap_cidr_only_cmd,
9330 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00009331 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009332 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009333 "Address Family\n"
9334 "Address Family Modifier\n"
9335 "Address Family Modifier\n"
9336 "Address Family Modifier\n"
9337 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009338 "Display flap statistics of routes\n"
9339 "Display only routes with non-natural netmasks\n")
9340{
Lou Berger651b4022016-01-12 13:42:07 -05009341 safi_t safi;
9342
9343 if (bgp_parse_safi(argv[0], &safi)) {
9344 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9345 return CMD_WARNING;
9346 }
9347 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009348}
9349
Lou Berger651b4022016-01-12 13:42:07 -05009350ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9351 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9352 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309353 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309354 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009355 "Address Family\n"
9356 "Address Family Modifier\n"
9357 "Address Family Modifier\n"
9358 "Address Family Modifier\n"
9359 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309360 "Display detailed information about dampening\n"
9361 "Display flap statistics of routes\n"
9362 "Display only routes with non-natural netmasks\n")
9363
Lou Berger651b4022016-01-12 13:42:07 -05009364DEFUN (show_bgp_ipv4_safi_cidr_only,
9365 show_bgp_ipv4_safi_cidr_only_cmd,
9366 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009367 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009368 BGP_STR
9369 "Address family\n"
9370 "Address Family modifier\n"
9371 "Address Family modifier\n"
9372 "Display only routes with non-natural netmasks\n")
9373{
9374 if (strncmp (argv[0], "m", 1) == 0)
9375 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009376 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009377
9378 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009379 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009380}
David Lamparter6b0655a2014-06-04 06:53:35 +02009381
Lou Berger651b4022016-01-12 13:42:07 -05009382/* new046 */
9383DEFUN (show_bgp_afi_safi_community_all,
9384 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009385 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009386 SHOW_STR
9387 BGP_STR
9388 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009389 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009390 "Address Family modifier\n"
9391 "Address Family modifier\n"
9392 "Address Family modifier\n"
9393 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009394 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009395{
9396 safi_t safi;
9397 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009398
Lou Berger651b4022016-01-12 13:42:07 -05009399 if (bgp_parse_afi(argv[0], &afi)) {
9400 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9401 return CMD_WARNING;
9402 }
9403 if (bgp_parse_safi(argv[1], &safi)) {
9404 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9405 return CMD_WARNING;
9406 }
9407
9408 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9409}
9410DEFUN (show_bgp_afi_community_all,
9411 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009412 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009413 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009414 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009415 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009416 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009417 "Display routes matching the communities\n")
9418{
Lou Berger651b4022016-01-12 13:42:07 -05009419 afi_t afi;
9420 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009421
Lou Berger651b4022016-01-12 13:42:07 -05009422 if (bgp_parse_afi(argv[0], &afi)) {
9423 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9424 return CMD_WARNING;
9425 }
9426 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009427}
David Lamparter6b0655a2014-06-04 06:53:35 +02009428
paul94f2b392005-06-28 12:44:16 +00009429static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009430bgp_show_community (struct vty *vty, const char *view_name, int argc,
9431 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009432{
9433 struct community *com;
9434 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009435 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +00009436 int i;
9437 char *str;
9438 int first = 0;
9439
Michael Lambert95cbbd22010-07-23 14:43:04 -04009440 /* BGP structure lookup */
9441 if (view_name)
9442 {
9443 bgp = bgp_lookup_by_name (view_name);
9444 if (bgp == NULL)
9445 {
9446 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9447 return CMD_WARNING;
9448 }
9449 }
9450 else
9451 {
9452 bgp = bgp_get_default ();
9453 if (bgp == NULL)
9454 {
9455 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9456 return CMD_WARNING;
9457 }
9458 }
9459
paul718e3742002-12-13 20:15:29 +00009460 b = buffer_new (1024);
9461 for (i = 0; i < argc; i++)
9462 {
9463 if (first)
9464 buffer_putc (b, ' ');
9465 else
9466 {
9467 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9468 continue;
9469 first = 1;
9470 }
9471
9472 buffer_putstr (b, argv[i]);
9473 }
9474 buffer_putc (b, '\0');
9475
9476 str = buffer_getstr (b);
9477 buffer_free (b);
9478
9479 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009480 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009481 if (! com)
9482 {
9483 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9484 return CMD_WARNING;
9485 }
9486
Michael Lambert95cbbd22010-07-23 14:43:04 -04009487 return bgp_show (vty, bgp, afi, safi,
ajs5a646652004-11-05 01:25:55 +00009488 (exact ? bgp_show_type_community_exact :
9489 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00009490}
9491
Lou Bergerf9b6c392016-01-12 13:42:09 -05009492DEFUN (show_ip_bgp_community,
9493 show_ip_bgp_community_cmd,
9494 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9495 SHOW_STR
9496 IP_STR
9497 BGP_STR
9498 "Display routes matching the communities\n"
9499 "community number\n"
9500 "Do not send outside local AS (well-known community)\n"
9501 "Do not advertise to any peer (well-known community)\n"
9502 "Do not export to next AS (well-known community)\n")
9503{
9504 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9505}
9506
9507ALIAS (show_ip_bgp_community,
9508 show_ip_bgp_community2_cmd,
9509 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9510 SHOW_STR
9511 IP_STR
9512 BGP_STR
9513 "Display routes matching the communities\n"
9514 "community number\n"
9515 "Do not send outside local AS (well-known community)\n"
9516 "Do not advertise to any peer (well-known community)\n"
9517 "Do not export to next AS (well-known community)\n"
9518 "community number\n"
9519 "Do not send outside local AS (well-known community)\n"
9520 "Do not advertise to any peer (well-known community)\n"
9521 "Do not export to next AS (well-known community)\n")
9522
9523ALIAS (show_ip_bgp_community,
9524 show_ip_bgp_community3_cmd,
9525 "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)",
9526 SHOW_STR
9527 IP_STR
9528 BGP_STR
9529 "Display routes matching the communities\n"
9530 "community number\n"
9531 "Do not send outside local AS (well-known community)\n"
9532 "Do not advertise to any peer (well-known community)\n"
9533 "Do not export to next AS (well-known community)\n"
9534 "community number\n"
9535 "Do not send outside local AS (well-known community)\n"
9536 "Do not advertise to any peer (well-known community)\n"
9537 "Do not export to next AS (well-known community)\n"
9538 "community number\n"
9539 "Do not send outside local AS (well-known community)\n"
9540 "Do not advertise to any peer (well-known community)\n"
9541 "Do not export to next AS (well-known community)\n")
9542
9543ALIAS (show_ip_bgp_community,
9544 show_ip_bgp_community4_cmd,
9545 "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)",
9546 SHOW_STR
9547 IP_STR
9548 BGP_STR
9549 "Display routes matching the communities\n"
9550 "community number\n"
9551 "Do not send outside local AS (well-known community)\n"
9552 "Do not advertise to any peer (well-known community)\n"
9553 "Do not export to next AS (well-known community)\n"
9554 "community number\n"
9555 "Do not send outside local AS (well-known community)\n"
9556 "Do not advertise to any peer (well-known community)\n"
9557 "Do not export to next AS (well-known community)\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
9567DEFUN (show_ip_bgp_ipv4_community,
9568 show_ip_bgp_ipv4_community_cmd,
9569 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9570 SHOW_STR
9571 IP_STR
9572 BGP_STR
9573 "Address family\n"
9574 "Address Family modifier\n"
9575 "Address Family modifier\n"
9576 "Display routes matching the communities\n"
9577 "community number\n"
9578 "Do not send outside local AS (well-known community)\n"
9579 "Do not advertise to any peer (well-known community)\n"
9580 "Do not export to next AS (well-known community)\n")
9581{
9582 if (strncmp (argv[0], "m", 1) == 0)
9583 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9584
9585 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9586}
9587
9588ALIAS (show_ip_bgp_ipv4_community,
9589 show_ip_bgp_ipv4_community2_cmd,
9590 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9591 SHOW_STR
9592 IP_STR
9593 BGP_STR
9594 "Address family\n"
9595 "Address Family modifier\n"
9596 "Address Family modifier\n"
9597 "Display routes matching the communities\n"
9598 "community number\n"
9599 "Do not send outside local AS (well-known community)\n"
9600 "Do not advertise to any peer (well-known community)\n"
9601 "Do not export to next AS (well-known community)\n"
9602 "community number\n"
9603 "Do not send outside local AS (well-known community)\n"
9604 "Do not advertise to any peer (well-known community)\n"
9605 "Do not export to next AS (well-known community)\n")
9606
9607ALIAS (show_ip_bgp_ipv4_community,
9608 show_ip_bgp_ipv4_community3_cmd,
9609 "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)",
9610 SHOW_STR
9611 IP_STR
9612 BGP_STR
9613 "Address family\n"
9614 "Address Family modifier\n"
9615 "Address Family modifier\n"
9616 "Display routes matching the communities\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 "community number\n"
9622 "Do not send outside local AS (well-known community)\n"
9623 "Do not advertise to any peer (well-known community)\n"
9624 "Do not export to next AS (well-known community)\n"
9625 "community number\n"
9626 "Do not send outside local AS (well-known community)\n"
9627 "Do not advertise to any peer (well-known community)\n"
9628 "Do not export to next AS (well-known community)\n")
9629
9630ALIAS (show_ip_bgp_ipv4_community,
9631 show_ip_bgp_ipv4_community4_cmd,
9632 "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)",
9633 SHOW_STR
9634 IP_STR
9635 BGP_STR
9636 "Address family\n"
9637 "Address Family modifier\n"
9638 "Address Family modifier\n"
9639 "Display routes matching the communities\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 "community number\n"
9645 "Do not send outside local AS (well-known community)\n"
9646 "Do not advertise to any peer (well-known community)\n"
9647 "Do not export to next AS (well-known community)\n"
9648 "community number\n"
9649 "Do not send outside local AS (well-known community)\n"
9650 "Do not advertise to any peer (well-known community)\n"
9651 "Do not export to next AS (well-known community)\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
9657DEFUN (show_ip_bgp_community_exact,
9658 show_ip_bgp_community_exact_cmd,
9659 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9660 SHOW_STR
9661 IP_STR
9662 BGP_STR
9663 "Display routes matching the communities\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 "Exact match of the communities")
9669{
9670 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9671}
9672
9673ALIAS (show_ip_bgp_community_exact,
9674 show_ip_bgp_community2_exact_cmd,
9675 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9676 SHOW_STR
9677 IP_STR
9678 BGP_STR
9679 "Display routes matching the communities\n"
9680 "community number\n"
9681 "Do not send outside local AS (well-known community)\n"
9682 "Do not advertise to any peer (well-known community)\n"
9683 "Do not export to next AS (well-known community)\n"
9684 "community number\n"
9685 "Do not send outside local AS (well-known community)\n"
9686 "Do not advertise to any peer (well-known community)\n"
9687 "Do not export to next AS (well-known community)\n"
9688 "Exact match of the communities")
9689
9690ALIAS (show_ip_bgp_community_exact,
9691 show_ip_bgp_community3_exact_cmd,
9692 "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",
9693 SHOW_STR
9694 IP_STR
9695 BGP_STR
9696 "Display routes matching the communities\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 "community number\n"
9702 "Do not send outside local AS (well-known community)\n"
9703 "Do not advertise to any peer (well-known community)\n"
9704 "Do not export to next AS (well-known community)\n"
9705 "community number\n"
9706 "Do not send outside local AS (well-known community)\n"
9707 "Do not advertise to any peer (well-known community)\n"
9708 "Do not export to next AS (well-known community)\n"
9709 "Exact match of the communities")
9710
9711ALIAS (show_ip_bgp_community_exact,
9712 show_ip_bgp_community4_exact_cmd,
9713 "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",
9714 SHOW_STR
9715 IP_STR
9716 BGP_STR
9717 "Display routes matching the communities\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 "community number\n"
9723 "Do not send outside local AS (well-known community)\n"
9724 "Do not advertise to any peer (well-known community)\n"
9725 "Do not export to next AS (well-known community)\n"
9726 "community number\n"
9727 "Do not send outside local AS (well-known community)\n"
9728 "Do not advertise to any peer (well-known community)\n"
9729 "Do not export to next AS (well-known community)\n"
9730 "community number\n"
9731 "Do not send outside local AS (well-known community)\n"
9732 "Do not advertise to any peer (well-known community)\n"
9733 "Do not export to next AS (well-known community)\n"
9734 "Exact match of the communities")
9735
9736DEFUN (show_ip_bgp_ipv4_community_exact,
9737 show_ip_bgp_ipv4_community_exact_cmd,
9738 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9739 SHOW_STR
9740 IP_STR
9741 BGP_STR
9742 "Address family\n"
9743 "Address Family modifier\n"
9744 "Address Family modifier\n"
9745 "Display routes matching the communities\n"
9746 "community number\n"
9747 "Do not send outside local AS (well-known community)\n"
9748 "Do not advertise to any peer (well-known community)\n"
9749 "Do not export to next AS (well-known community)\n"
9750 "Exact match of the communities")
9751{
9752 if (strncmp (argv[0], "m", 1) == 0)
9753 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9754
9755 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9756}
9757
9758ALIAS (show_ip_bgp_ipv4_community_exact,
9759 show_ip_bgp_ipv4_community2_exact_cmd,
9760 "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",
9761 SHOW_STR
9762 IP_STR
9763 BGP_STR
9764 "Address family\n"
9765 "Address Family modifier\n"
9766 "Address Family modifier\n"
9767 "Display routes matching the communities\n"
9768 "community number\n"
9769 "Do not send outside local AS (well-known community)\n"
9770 "Do not advertise to any peer (well-known community)\n"
9771 "Do not export to next AS (well-known community)\n"
9772 "community number\n"
9773 "Do not send outside local AS (well-known community)\n"
9774 "Do not advertise to any peer (well-known community)\n"
9775 "Do not export to next AS (well-known community)\n"
9776 "Exact match of the communities")
9777
9778ALIAS (show_ip_bgp_ipv4_community_exact,
9779 show_ip_bgp_ipv4_community3_exact_cmd,
9780 "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",
9781 SHOW_STR
9782 IP_STR
9783 BGP_STR
9784 "Address family\n"
9785 "Address Family modifier\n"
9786 "Address Family modifier\n"
9787 "Display routes matching the communities\n"
9788 "community number\n"
9789 "Do not send outside local AS (well-known community)\n"
9790 "Do not advertise to any peer (well-known community)\n"
9791 "Do not export to next AS (well-known community)\n"
9792 "community number\n"
9793 "Do not send outside local AS (well-known community)\n"
9794 "Do not advertise to any peer (well-known community)\n"
9795 "Do not export to next AS (well-known community)\n"
9796 "community number\n"
9797 "Do not send outside local AS (well-known community)\n"
9798 "Do not advertise to any peer (well-known community)\n"
9799 "Do not export to next AS (well-known community)\n"
9800 "Exact match of the communities")
9801
9802ALIAS (show_ip_bgp_ipv4_community_exact,
9803 show_ip_bgp_ipv4_community4_exact_cmd,
9804 "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",
9805 SHOW_STR
9806 IP_STR
9807 BGP_STR
9808 "Address family\n"
9809 "Address Family modifier\n"
9810 "Address Family modifier\n"
9811 "Display routes matching the communities\n"
9812 "community number\n"
9813 "Do not send outside local AS (well-known community)\n"
9814 "Do not advertise to any peer (well-known community)\n"
9815 "Do not export to next AS (well-known community)\n"
9816 "community number\n"
9817 "Do not send outside local AS (well-known community)\n"
9818 "Do not advertise to any peer (well-known community)\n"
9819 "Do not export to next AS (well-known community)\n"
9820 "community number\n"
9821 "Do not send outside local AS (well-known community)\n"
9822 "Do not advertise to any peer (well-known community)\n"
9823 "Do not export to next AS (well-known community)\n"
9824 "community number\n"
9825 "Do not send outside local AS (well-known community)\n"
9826 "Do not advertise to any peer (well-known community)\n"
9827 "Do not export to next AS (well-known community)\n"
9828 "Exact match of the communities")
9829
Lou Bergerf9b6c392016-01-12 13:42:09 -05009830DEFUN (show_bgp_community,
9831 show_bgp_community_cmd,
9832 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9833 SHOW_STR
9834 BGP_STR
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{
9841 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9842}
9843
9844ALIAS (show_bgp_community,
9845 show_bgp_ipv6_community_cmd,
9846 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9847 SHOW_STR
9848 BGP_STR
9849 "Address family\n"
9850 "Display routes matching the communities\n"
9851 "community number\n"
9852 "Do not send outside local AS (well-known community)\n"
9853 "Do not advertise to any peer (well-known community)\n"
9854 "Do not export to next AS (well-known community)\n")
9855
9856ALIAS (show_bgp_community,
9857 show_bgp_community2_cmd,
9858 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9859 SHOW_STR
9860 BGP_STR
9861 "Display routes matching the communities\n"
9862 "community number\n"
9863 "Do not send outside local AS (well-known community)\n"
9864 "Do not advertise to any peer (well-known community)\n"
9865 "Do not export to next AS (well-known community)\n"
9866 "community number\n"
9867 "Do not send outside local AS (well-known community)\n"
9868 "Do not advertise to any peer (well-known community)\n"
9869 "Do not export to next AS (well-known community)\n")
9870
9871ALIAS (show_bgp_community,
9872 show_bgp_ipv6_community2_cmd,
9873 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9874 SHOW_STR
9875 BGP_STR
9876 "Address family\n"
9877 "Display routes matching the communities\n"
9878 "community number\n"
9879 "Do not send outside local AS (well-known community)\n"
9880 "Do not advertise to any peer (well-known community)\n"
9881 "Do not export to next AS (well-known community)\n"
9882 "community number\n"
9883 "Do not send outside local AS (well-known community)\n"
9884 "Do not advertise to any peer (well-known community)\n"
9885 "Do not export to next AS (well-known community)\n")
9886
9887ALIAS (show_bgp_community,
9888 show_bgp_community3_cmd,
9889 "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)",
9890 SHOW_STR
9891 BGP_STR
9892 "Display routes matching the communities\n"
9893 "community number\n"
9894 "Do not send outside local AS (well-known community)\n"
9895 "Do not advertise to any peer (well-known community)\n"
9896 "Do not export to next AS (well-known community)\n"
9897 "community number\n"
9898 "Do not send outside local AS (well-known community)\n"
9899 "Do not advertise to any peer (well-known community)\n"
9900 "Do not export to next AS (well-known community)\n"
9901 "community number\n"
9902 "Do not send outside local AS (well-known community)\n"
9903 "Do not advertise to any peer (well-known community)\n"
9904 "Do not export to next AS (well-known community)\n")
9905
9906ALIAS (show_bgp_community,
9907 show_bgp_ipv6_community3_cmd,
9908 "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)",
9909 SHOW_STR
9910 BGP_STR
9911 "Address family\n"
9912 "Display routes matching the communities\n"
9913 "community number\n"
9914 "Do not send outside local AS (well-known community)\n"
9915 "Do not advertise to any peer (well-known community)\n"
9916 "Do not export to next AS (well-known community)\n"
9917 "community number\n"
9918 "Do not send outside local AS (well-known community)\n"
9919 "Do not advertise to any peer (well-known community)\n"
9920 "Do not export to next AS (well-known community)\n"
9921 "community number\n"
9922 "Do not send outside local AS (well-known community)\n"
9923 "Do not advertise to any peer (well-known community)\n"
9924 "Do not export to next AS (well-known community)\n")
9925
9926ALIAS (show_bgp_community,
9927 show_bgp_community4_cmd,
9928 "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)",
9929 SHOW_STR
9930 BGP_STR
9931 "Display routes matching the communities\n"
9932 "community number\n"
9933 "Do not send outside local AS (well-known community)\n"
9934 "Do not advertise to any peer (well-known community)\n"
9935 "Do not export to next AS (well-known community)\n"
9936 "community number\n"
9937 "Do not send outside local AS (well-known community)\n"
9938 "Do not advertise to any peer (well-known community)\n"
9939 "Do not export to next AS (well-known community)\n"
9940 "community number\n"
9941 "Do not send outside local AS (well-known community)\n"
9942 "Do not advertise to any peer (well-known community)\n"
9943 "Do not export to next AS (well-known community)\n"
9944 "community number\n"
9945 "Do not send outside local AS (well-known community)\n"
9946 "Do not advertise to any peer (well-known community)\n"
9947 "Do not export to next AS (well-known community)\n")
9948
9949ALIAS (show_bgp_community,
9950 show_bgp_ipv6_community4_cmd,
9951 "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)",
9952 SHOW_STR
9953 BGP_STR
9954 "Address family\n"
9955 "Display routes matching the communities\n"
9956 "community number\n"
9957 "Do not send outside local AS (well-known community)\n"
9958 "Do not advertise to any peer (well-known community)\n"
9959 "Do not export to next AS (well-known community)\n"
9960 "community number\n"
9961 "Do not send outside local AS (well-known community)\n"
9962 "Do not advertise to any peer (well-known community)\n"
9963 "Do not export to next AS (well-known community)\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
9973/* old command */
9974DEFUN (show_ipv6_bgp_community,
9975 show_ipv6_bgp_community_cmd,
9976 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9977 SHOW_STR
9978 IPV6_STR
9979 BGP_STR
9980 "Display routes matching the communities\n"
9981 "community number\n"
9982 "Do not send outside local AS (well-known community)\n"
9983 "Do not advertise to any peer (well-known community)\n"
9984 "Do not export to next AS (well-known community)\n")
9985{
9986 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9987}
9988
9989/* old command */
9990ALIAS (show_ipv6_bgp_community,
9991 show_ipv6_bgp_community2_cmd,
9992 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9993 SHOW_STR
9994 IPV6_STR
9995 BGP_STR
9996 "Display routes matching the communities\n"
9997 "community number\n"
9998 "Do not send outside local AS (well-known community)\n"
9999 "Do not advertise to any peer (well-known community)\n"
10000 "Do not export to next AS (well-known community)\n"
10001 "community number\n"
10002 "Do not send outside local AS (well-known community)\n"
10003 "Do not advertise to any peer (well-known community)\n"
10004 "Do not export to next AS (well-known community)\n")
10005
10006/* old command */
10007ALIAS (show_ipv6_bgp_community,
10008 show_ipv6_bgp_community3_cmd,
10009 "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)",
10010 SHOW_STR
10011 IPV6_STR
10012 BGP_STR
10013 "Display routes matching the communities\n"
10014 "community number\n"
10015 "Do not send outside local AS (well-known community)\n"
10016 "Do not advertise to any peer (well-known community)\n"
10017 "Do not export to next AS (well-known community)\n"
10018 "community number\n"
10019 "Do not send outside local AS (well-known community)\n"
10020 "Do not advertise to any peer (well-known community)\n"
10021 "Do not export to next AS (well-known community)\n"
10022 "community number\n"
10023 "Do not send outside local AS (well-known community)\n"
10024 "Do not advertise to any peer (well-known community)\n"
10025 "Do not export to next AS (well-known community)\n")
10026
10027/* old command */
10028ALIAS (show_ipv6_bgp_community,
10029 show_ipv6_bgp_community4_cmd,
10030 "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)",
10031 SHOW_STR
10032 IPV6_STR
10033 BGP_STR
10034 "Display routes matching the communities\n"
10035 "community number\n"
10036 "Do not send outside local AS (well-known community)\n"
10037 "Do not advertise to any peer (well-known community)\n"
10038 "Do not export to next AS (well-known community)\n"
10039 "community number\n"
10040 "Do not send outside local AS (well-known community)\n"
10041 "Do not advertise to any peer (well-known community)\n"
10042 "Do not export to next AS (well-known community)\n"
10043 "community number\n"
10044 "Do not send outside local AS (well-known community)\n"
10045 "Do not advertise to any peer (well-known community)\n"
10046 "Do not export to next AS (well-known community)\n"
10047 "community number\n"
10048 "Do not send outside local AS (well-known community)\n"
10049 "Do not advertise to any peer (well-known community)\n"
10050 "Do not export to next AS (well-known community)\n")
10051
10052DEFUN (show_bgp_community_exact,
10053 show_bgp_community_exact_cmd,
10054 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10055 SHOW_STR
10056 BGP_STR
10057 "Display routes matching the communities\n"
10058 "community number\n"
10059 "Do not send outside local AS (well-known community)\n"
10060 "Do not advertise to any peer (well-known community)\n"
10061 "Do not export to next AS (well-known community)\n"
10062 "Exact match of the communities")
10063{
10064 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10065}
10066
10067ALIAS (show_bgp_community_exact,
10068 show_bgp_ipv6_community_exact_cmd,
10069 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10070 SHOW_STR
10071 BGP_STR
10072 "Address family\n"
10073 "Display routes matching the communities\n"
10074 "community number\n"
10075 "Do not send outside local AS (well-known community)\n"
10076 "Do not advertise to any peer (well-known community)\n"
10077 "Do not export to next AS (well-known community)\n"
10078 "Exact match of the communities")
10079
10080ALIAS (show_bgp_community_exact,
10081 show_bgp_community2_exact_cmd,
10082 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10083 SHOW_STR
10084 BGP_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
10096ALIAS (show_bgp_community_exact,
10097 show_bgp_ipv6_community2_exact_cmd,
10098 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10099 SHOW_STR
10100 BGP_STR
10101 "Address family\n"
10102 "Display routes matching the communities\n"
10103 "community number\n"
10104 "Do not send outside local AS (well-known community)\n"
10105 "Do not advertise to any peer (well-known community)\n"
10106 "Do not export to next AS (well-known community)\n"
10107 "community number\n"
10108 "Do not send outside local AS (well-known community)\n"
10109 "Do not advertise to any peer (well-known community)\n"
10110 "Do not export to next AS (well-known community)\n"
10111 "Exact match of the communities")
10112
10113ALIAS (show_bgp_community_exact,
10114 show_bgp_community3_exact_cmd,
10115 "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",
10116 SHOW_STR
10117 BGP_STR
10118 "Display routes matching the communities\n"
10119 "community number\n"
10120 "Do not send outside local AS (well-known community)\n"
10121 "Do not advertise to any peer (well-known community)\n"
10122 "Do not export to next AS (well-known community)\n"
10123 "community number\n"
10124 "Do not send outside local AS (well-known community)\n"
10125 "Do not advertise to any peer (well-known community)\n"
10126 "Do not export to next AS (well-known community)\n"
10127 "community number\n"
10128 "Do not send outside local AS (well-known community)\n"
10129 "Do not advertise to any peer (well-known community)\n"
10130 "Do not export to next AS (well-known community)\n"
10131 "Exact match of the communities")
10132
10133ALIAS (show_bgp_community_exact,
10134 show_bgp_ipv6_community3_exact_cmd,
10135 "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",
10136 SHOW_STR
10137 BGP_STR
10138 "Address family\n"
10139 "Display routes matching the communities\n"
10140 "community number\n"
10141 "Do not send outside local AS (well-known community)\n"
10142 "Do not advertise to any peer (well-known community)\n"
10143 "Do not export to next AS (well-known community)\n"
10144 "community number\n"
10145 "Do not send outside local AS (well-known community)\n"
10146 "Do not advertise to any peer (well-known community)\n"
10147 "Do not export to next AS (well-known community)\n"
10148 "community number\n"
10149 "Do not send outside local AS (well-known community)\n"
10150 "Do not advertise to any peer (well-known community)\n"
10151 "Do not export to next AS (well-known community)\n"
10152 "Exact match of the communities")
10153
10154ALIAS (show_bgp_community_exact,
10155 show_bgp_community4_exact_cmd,
10156 "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",
10157 SHOW_STR
10158 BGP_STR
10159 "Display routes matching the communities\n"
10160 "community number\n"
10161 "Do not send outside local AS (well-known community)\n"
10162 "Do not advertise to any peer (well-known community)\n"
10163 "Do not export to next AS (well-known community)\n"
10164 "community number\n"
10165 "Do not send outside local AS (well-known community)\n"
10166 "Do not advertise to any peer (well-known community)\n"
10167 "Do not export to next AS (well-known community)\n"
10168 "community number\n"
10169 "Do not send outside local AS (well-known community)\n"
10170 "Do not advertise to any peer (well-known community)\n"
10171 "Do not export to next AS (well-known community)\n"
10172 "community number\n"
10173 "Do not send outside local AS (well-known community)\n"
10174 "Do not advertise to any peer (well-known community)\n"
10175 "Do not export to next AS (well-known community)\n"
10176 "Exact match of the communities")
10177
10178ALIAS (show_bgp_community_exact,
10179 show_bgp_ipv6_community4_exact_cmd,
10180 "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",
10181 SHOW_STR
10182 BGP_STR
10183 "Address family\n"
10184 "Display routes matching the communities\n"
10185 "community number\n"
10186 "Do not send outside local AS (well-known community)\n"
10187 "Do not advertise to any peer (well-known community)\n"
10188 "Do not export to next AS (well-known community)\n"
10189 "community number\n"
10190 "Do not send outside local AS (well-known community)\n"
10191 "Do not advertise to any peer (well-known community)\n"
10192 "Do not export to next AS (well-known community)\n"
10193 "community number\n"
10194 "Do not send outside local AS (well-known community)\n"
10195 "Do not advertise to any peer (well-known community)\n"
10196 "Do not export to next AS (well-known community)\n"
10197 "community number\n"
10198 "Do not send outside local AS (well-known community)\n"
10199 "Do not advertise to any peer (well-known community)\n"
10200 "Do not export to next AS (well-known community)\n"
10201 "Exact match of the communities")
10202
10203/* old command */
10204DEFUN (show_ipv6_bgp_community_exact,
10205 show_ipv6_bgp_community_exact_cmd,
10206 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10207 SHOW_STR
10208 IPV6_STR
10209 BGP_STR
10210 "Display routes matching the communities\n"
10211 "community number\n"
10212 "Do not send outside local AS (well-known community)\n"
10213 "Do not advertise to any peer (well-known community)\n"
10214 "Do not export to next AS (well-known community)\n"
10215 "Exact match of the communities")
10216{
10217 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10218}
10219
10220/* old command */
10221ALIAS (show_ipv6_bgp_community_exact,
10222 show_ipv6_bgp_community2_exact_cmd,
10223 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10224 SHOW_STR
10225 IPV6_STR
10226 BGP_STR
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 "community number\n"
10233 "Do not send outside local AS (well-known community)\n"
10234 "Do not advertise to any peer (well-known community)\n"
10235 "Do not export to next AS (well-known community)\n"
10236 "Exact match of the communities")
10237
10238/* old command */
10239ALIAS (show_ipv6_bgp_community_exact,
10240 show_ipv6_bgp_community3_exact_cmd,
10241 "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",
10242 SHOW_STR
10243 IPV6_STR
10244 BGP_STR
10245 "Display routes matching the communities\n"
10246 "community number\n"
10247 "Do not send outside local AS (well-known community)\n"
10248 "Do not advertise to any peer (well-known community)\n"
10249 "Do not export to next AS (well-known community)\n"
10250 "community number\n"
10251 "Do not send outside local AS (well-known community)\n"
10252 "Do not advertise to any peer (well-known community)\n"
10253 "Do not export to next AS (well-known community)\n"
10254 "community number\n"
10255 "Do not send outside local AS (well-known community)\n"
10256 "Do not advertise to any peer (well-known community)\n"
10257 "Do not export to next AS (well-known community)\n"
10258 "Exact match of the communities")
10259
10260/* old command */
10261ALIAS (show_ipv6_bgp_community_exact,
10262 show_ipv6_bgp_community4_exact_cmd,
10263 "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",
10264 SHOW_STR
10265 IPV6_STR
10266 BGP_STR
10267 "Display routes matching the communities\n"
10268 "community number\n"
10269 "Do not send outside local AS (well-known community)\n"
10270 "Do not advertise to any peer (well-known community)\n"
10271 "Do not export to next AS (well-known community)\n"
10272 "community number\n"
10273 "Do not send outside local AS (well-known community)\n"
10274 "Do not advertise to any peer (well-known community)\n"
10275 "Do not export to next AS (well-known community)\n"
10276 "community number\n"
10277 "Do not send outside local AS (well-known community)\n"
10278 "Do not advertise to any peer (well-known community)\n"
10279 "Do not export to next AS (well-known community)\n"
10280 "community number\n"
10281 "Do not send outside local AS (well-known community)\n"
10282 "Do not advertise to any peer (well-known community)\n"
10283 "Do not export to next AS (well-known community)\n"
10284 "Exact match of the communities")
10285
10286/* old command */
10287DEFUN (show_ipv6_mbgp_community,
10288 show_ipv6_mbgp_community_cmd,
10289 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10290 SHOW_STR
10291 IPV6_STR
10292 MBGP_STR
10293 "Display routes matching the communities\n"
10294 "community number\n"
10295 "Do not send outside local AS (well-known community)\n"
10296 "Do not advertise to any peer (well-known community)\n"
10297 "Do not export to next AS (well-known community)\n")
10298{
10299 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
10300}
10301
10302/* old command */
10303ALIAS (show_ipv6_mbgp_community,
10304 show_ipv6_mbgp_community2_cmd,
10305 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10306 SHOW_STR
10307 IPV6_STR
10308 MBGP_STR
10309 "Display routes matching the communities\n"
10310 "community number\n"
10311 "Do not send outside local AS (well-known community)\n"
10312 "Do not advertise to any peer (well-known community)\n"
10313 "Do not export to next AS (well-known community)\n"
10314 "community number\n"
10315 "Do not send outside local AS (well-known community)\n"
10316 "Do not advertise to any peer (well-known community)\n"
10317 "Do not export to next AS (well-known community)\n")
10318
10319/* old command */
10320ALIAS (show_ipv6_mbgp_community,
10321 show_ipv6_mbgp_community3_cmd,
10322 "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)",
10323 SHOW_STR
10324 IPV6_STR
10325 MBGP_STR
10326 "Display routes matching the communities\n"
10327 "community number\n"
10328 "Do not send outside local AS (well-known community)\n"
10329 "Do not advertise to any peer (well-known community)\n"
10330 "Do not export to next AS (well-known community)\n"
10331 "community number\n"
10332 "Do not send outside local AS (well-known community)\n"
10333 "Do not advertise to any peer (well-known community)\n"
10334 "Do not export to next AS (well-known community)\n"
10335 "community number\n"
10336 "Do not send outside local AS (well-known community)\n"
10337 "Do not advertise to any peer (well-known community)\n"
10338 "Do not export to next AS (well-known community)\n")
10339
10340/* old command */
10341ALIAS (show_ipv6_mbgp_community,
10342 show_ipv6_mbgp_community4_cmd,
10343 "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)",
10344 SHOW_STR
10345 IPV6_STR
10346 MBGP_STR
10347 "Display routes matching the communities\n"
10348 "community number\n"
10349 "Do not send outside local AS (well-known community)\n"
10350 "Do not advertise to any peer (well-known community)\n"
10351 "Do not export to next AS (well-known community)\n"
10352 "community number\n"
10353 "Do not send outside local AS (well-known community)\n"
10354 "Do not advertise to any peer (well-known community)\n"
10355 "Do not export to next AS (well-known community)\n"
10356 "community number\n"
10357 "Do not send outside local AS (well-known community)\n"
10358 "Do not advertise to any peer (well-known community)\n"
10359 "Do not export to next AS (well-known community)\n"
10360 "community number\n"
10361 "Do not send outside local AS (well-known community)\n"
10362 "Do not advertise to any peer (well-known community)\n"
10363 "Do not export to next AS (well-known community)\n")
10364
10365/* old command */
10366DEFUN (show_ipv6_mbgp_community_exact,
10367 show_ipv6_mbgp_community_exact_cmd,
10368 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10369 SHOW_STR
10370 IPV6_STR
10371 MBGP_STR
10372 "Display routes matching the communities\n"
10373 "community number\n"
10374 "Do not send outside local AS (well-known community)\n"
10375 "Do not advertise to any peer (well-known community)\n"
10376 "Do not export to next AS (well-known community)\n"
10377 "Exact match of the communities")
10378{
10379 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10380}
10381
10382/* old command */
10383ALIAS (show_ipv6_mbgp_community_exact,
10384 show_ipv6_mbgp_community2_exact_cmd,
10385 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10386 SHOW_STR
10387 IPV6_STR
10388 MBGP_STR
10389 "Display routes matching the communities\n"
10390 "community number\n"
10391 "Do not send outside local AS (well-known community)\n"
10392 "Do not advertise to any peer (well-known community)\n"
10393 "Do not export to next AS (well-known community)\n"
10394 "community number\n"
10395 "Do not send outside local AS (well-known community)\n"
10396 "Do not advertise to any peer (well-known community)\n"
10397 "Do not export to next AS (well-known community)\n"
10398 "Exact match of the communities")
10399
10400/* old command */
10401ALIAS (show_ipv6_mbgp_community_exact,
10402 show_ipv6_mbgp_community3_exact_cmd,
10403 "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",
10404 SHOW_STR
10405 IPV6_STR
10406 MBGP_STR
10407 "Display routes matching the communities\n"
10408 "community number\n"
10409 "Do not send outside local AS (well-known community)\n"
10410 "Do not advertise to any peer (well-known community)\n"
10411 "Do not export to next AS (well-known community)\n"
10412 "community number\n"
10413 "Do not send outside local AS (well-known community)\n"
10414 "Do not advertise to any peer (well-known community)\n"
10415 "Do not export to next AS (well-known community)\n"
10416 "community number\n"
10417 "Do not send outside local AS (well-known community)\n"
10418 "Do not advertise to any peer (well-known community)\n"
10419 "Do not export to next AS (well-known community)\n"
10420 "Exact match of the communities")
10421
10422/* old command */
10423ALIAS (show_ipv6_mbgp_community_exact,
10424 show_ipv6_mbgp_community4_exact_cmd,
10425 "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",
10426 SHOW_STR
10427 IPV6_STR
10428 MBGP_STR
10429 "Display routes matching the communities\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 "community number\n"
10435 "Do not send outside local AS (well-known community)\n"
10436 "Do not advertise to any peer (well-known community)\n"
10437 "Do not export to next AS (well-known community)\n"
10438 "community number\n"
10439 "Do not send outside local AS (well-known community)\n"
10440 "Do not advertise to any peer (well-known community)\n"
10441 "Do not export to next AS (well-known community)\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")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010447
Lou Berger651b4022016-01-12 13:42:07 -050010448DEFUN (show_bgp_ipv4_community,
10449 show_bgp_ipv4_community_cmd,
10450 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010451 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010452 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010453 IP_STR
paul718e3742002-12-13 20:15:29 +000010454 "Display routes matching the communities\n"
10455 "community number\n"
10456 "Do not send outside local AS (well-known community)\n"
10457 "Do not advertise to any peer (well-known community)\n"
10458 "Do not export to next AS (well-known community)\n")
10459{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010460 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010461}
10462
Lou Berger651b4022016-01-12 13:42:07 -050010463ALIAS (show_bgp_ipv4_community,
10464 show_bgp_ipv4_community2_cmd,
10465 "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 +000010466 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010467 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010468 IP_STR
paul718e3742002-12-13 20:15:29 +000010469 "Display routes matching the communities\n"
10470 "community number\n"
10471 "Do not send outside local AS (well-known community)\n"
10472 "Do not advertise to any peer (well-known community)\n"
10473 "Do not export to next AS (well-known community)\n"
10474 "community number\n"
10475 "Do not send outside local AS (well-known community)\n"
10476 "Do not advertise to any peer (well-known community)\n"
10477 "Do not export to next AS (well-known community)\n")
10478
Lou Berger651b4022016-01-12 13:42:07 -050010479ALIAS (show_bgp_ipv4_community,
10480 show_bgp_ipv4_community3_cmd,
10481 "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 +000010482 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010483 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010484 IP_STR
paul718e3742002-12-13 20:15:29 +000010485 "Display routes matching the communities\n"
10486 "community number\n"
10487 "Do not send outside local AS (well-known community)\n"
10488 "Do not advertise to any peer (well-known community)\n"
10489 "Do not export to next AS (well-known community)\n"
10490 "community number\n"
10491 "Do not send outside local AS (well-known community)\n"
10492 "Do not advertise to any peer (well-known community)\n"
10493 "Do not export to next AS (well-known community)\n"
10494 "community number\n"
10495 "Do not send outside local AS (well-known community)\n"
10496 "Do not advertise to any peer (well-known community)\n"
10497 "Do not export to next AS (well-known community)\n")
10498
Lou Berger651b4022016-01-12 13:42:07 -050010499ALIAS (show_bgp_ipv4_community,
10500 show_bgp_ipv4_community4_cmd,
10501 "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 +000010502 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010503 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010504 IP_STR
paul718e3742002-12-13 20:15:29 +000010505 "Display routes matching the communities\n"
10506 "community number\n"
10507 "Do not send outside local AS (well-known community)\n"
10508 "Do not advertise to any peer (well-known community)\n"
10509 "Do not export to next AS (well-known community)\n"
10510 "community number\n"
10511 "Do not send outside local AS (well-known community)\n"
10512 "Do not advertise to any peer (well-known community)\n"
10513 "Do not export to next AS (well-known community)\n"
10514 "community number\n"
10515 "Do not send outside local AS (well-known community)\n"
10516 "Do not advertise to any peer (well-known community)\n"
10517 "Do not export to next AS (well-known community)\n"
10518 "community number\n"
10519 "Do not send outside local AS (well-known community)\n"
10520 "Do not advertise to any peer (well-known community)\n"
10521 "Do not export to next AS (well-known community)\n")
10522
Lou Berger651b4022016-01-12 13:42:07 -050010523DEFUN (show_bgp_ipv4_safi_community,
10524 show_bgp_ipv4_safi_community_cmd,
10525 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010526 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010527 BGP_STR
10528 "Address family\n"
10529 "Address Family modifier\n"
10530 "Address Family modifier\n"
10531 "Display routes matching the communities\n"
10532 "community number\n"
10533 "Do not send outside local AS (well-known community)\n"
10534 "Do not advertise to any peer (well-known community)\n"
10535 "Do not export to next AS (well-known community)\n")
10536{
10537 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010538 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010539
Michael Lambert95cbbd22010-07-23 14:43:04 -040010540 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010541}
10542
Lou Berger651b4022016-01-12 13:42:07 -050010543ALIAS (show_bgp_ipv4_safi_community,
10544 show_bgp_ipv4_safi_community2_cmd,
10545 "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 +000010546 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010547 BGP_STR
10548 "Address family\n"
10549 "Address Family modifier\n"
10550 "Address Family modifier\n"
10551 "Display routes matching the communities\n"
10552 "community number\n"
10553 "Do not send outside local AS (well-known community)\n"
10554 "Do not advertise to any peer (well-known community)\n"
10555 "Do not export to next AS (well-known community)\n"
10556 "community number\n"
10557 "Do not send outside local AS (well-known community)\n"
10558 "Do not advertise to any peer (well-known community)\n"
10559 "Do not export to next AS (well-known community)\n")
10560
Lou Berger651b4022016-01-12 13:42:07 -050010561ALIAS (show_bgp_ipv4_safi_community,
10562 show_bgp_ipv4_safi_community3_cmd,
10563 "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 +000010564 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010565 BGP_STR
10566 "Address family\n"
10567 "Address Family modifier\n"
10568 "Address Family modifier\n"
10569 "Display routes matching the communities\n"
10570 "community number\n"
10571 "Do not send outside local AS (well-known community)\n"
10572 "Do not advertise to any peer (well-known community)\n"
10573 "Do not export to next AS (well-known community)\n"
10574 "community number\n"
10575 "Do not send outside local AS (well-known community)\n"
10576 "Do not advertise to any peer (well-known community)\n"
10577 "Do not export to next AS (well-known community)\n"
10578 "community number\n"
10579 "Do not send outside local AS (well-known community)\n"
10580 "Do not advertise to any peer (well-known community)\n"
10581 "Do not export to next AS (well-known community)\n")
10582
Lou Berger651b4022016-01-12 13:42:07 -050010583ALIAS (show_bgp_ipv4_safi_community,
10584 show_bgp_ipv4_safi_community4_cmd,
10585 "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 +000010586 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010587 BGP_STR
10588 "Address family\n"
10589 "Address Family modifier\n"
10590 "Address Family modifier\n"
10591 "Display routes matching the communities\n"
10592 "community number\n"
10593 "Do not send outside local AS (well-known community)\n"
10594 "Do not advertise to any peer (well-known community)\n"
10595 "Do not export to next AS (well-known community)\n"
10596 "community number\n"
10597 "Do not send outside local AS (well-known community)\n"
10598 "Do not advertise to any peer (well-known community)\n"
10599 "Do not export to next AS (well-known community)\n"
10600 "community number\n"
10601 "Do not send outside local AS (well-known community)\n"
10602 "Do not advertise to any peer (well-known community)\n"
10603 "Do not export to next AS (well-known community)\n"
10604 "community number\n"
10605 "Do not send outside local AS (well-known community)\n"
10606 "Do not advertise to any peer (well-known community)\n"
10607 "Do not export to next AS (well-known community)\n")
10608
Michael Lambert95cbbd22010-07-23 14:43:04 -040010609DEFUN (show_bgp_view_afi_safi_community_all,
10610 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010611 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010612 SHOW_STR
10613 BGP_STR
10614 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010615 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010616 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010617 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010618 "Address Family modifier\n"
10619 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010620 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010621{
10622 int afi;
10623 int safi;
10624 struct bgp *bgp;
10625
10626 /* BGP structure lookup. */
10627 bgp = bgp_lookup_by_name (argv[0]);
10628 if (bgp == NULL)
10629 {
10630 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10631 return CMD_WARNING;
10632 }
10633
Michael Lambert95cbbd22010-07-23 14:43:04 -040010634 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10635 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010636 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10637}
10638
10639DEFUN (show_bgp_view_afi_safi_community,
10640 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010641 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010642 SHOW_STR
10643 BGP_STR
10644 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010645 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010646 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010647 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010648 "Address family modifier\n"
10649 "Address family modifier\n"
10650 "Display routes matching the communities\n"
10651 "community number\n"
10652 "Do not send outside local AS (well-known community)\n"
10653 "Do not advertise to any peer (well-known community)\n"
10654 "Do not export to next AS (well-known community)\n")
10655{
10656 int afi;
10657 int safi;
10658
Michael Lambert95cbbd22010-07-23 14:43:04 -040010659 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10660 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10661 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010662}
10663
10664ALIAS (show_bgp_view_afi_safi_community,
10665 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010666 "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 -040010667 SHOW_STR
10668 BGP_STR
10669 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010670 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010671 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010672 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010673 "Address family modifier\n"
10674 "Address family modifier\n"
10675 "Display routes matching the communities\n"
10676 "community number\n"
10677 "Do not send outside local AS (well-known community)\n"
10678 "Do not advertise to any peer (well-known community)\n"
10679 "Do not export to next AS (well-known community)\n"
10680 "community number\n"
10681 "Do not send outside local AS (well-known community)\n"
10682 "Do not advertise to any peer (well-known community)\n"
10683 "Do not export to next AS (well-known community)\n")
10684
10685ALIAS (show_bgp_view_afi_safi_community,
10686 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010687 "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 -040010688 SHOW_STR
10689 BGP_STR
10690 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010691 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010692 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010693 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010694 "Address family modifier\n"
10695 "Address family modifier\n"
10696 "Display routes matching the communities\n"
10697 "community number\n"
10698 "Do not send outside local AS (well-known community)\n"
10699 "Do not advertise to any peer (well-known community)\n"
10700 "Do not export to next AS (well-known community)\n"
10701 "community number\n"
10702 "Do not send outside local AS (well-known community)\n"
10703 "Do not advertise to any peer (well-known community)\n"
10704 "Do not export to next AS (well-known community)\n"
10705 "community number\n"
10706 "Do not send outside local AS (well-known community)\n"
10707 "Do not advertise to any peer (well-known community)\n"
10708 "Do not export to next AS (well-known community)\n")
10709
10710ALIAS (show_bgp_view_afi_safi_community,
10711 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010712 "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 -040010713 SHOW_STR
10714 BGP_STR
10715 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010716 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010717 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010718 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010719 "Address family modifier\n"
10720 "Address family modifier\n"
10721 "Display routes matching the communities\n"
10722 "community number\n"
10723 "Do not send outside local AS (well-known community)\n"
10724 "Do not advertise to any peer (well-known community)\n"
10725 "Do not export to next AS (well-known community)\n"
10726 "community number\n"
10727 "Do not send outside local AS (well-known community)\n"
10728 "Do not advertise to any peer (well-known community)\n"
10729 "Do not export to next AS (well-known community)\n"
10730 "community number\n"
10731 "Do not send outside local AS (well-known community)\n"
10732 "Do not advertise to any peer (well-known community)\n"
10733 "Do not export to next AS (well-known community)\n"
10734 "community number\n"
10735 "Do not send outside local AS (well-known community)\n"
10736 "Do not advertise to any peer (well-known community)\n"
10737 "Do not export to next AS (well-known community)\n")
10738
Lou Berger651b4022016-01-12 13:42:07 -050010739DEFUN (show_bgp_ipv4_community_exact,
10740 show_bgp_ipv4_community_exact_cmd,
10741 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010742 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010743 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010744 IP_STR
paul718e3742002-12-13 20:15:29 +000010745 "Display routes matching the communities\n"
10746 "community number\n"
10747 "Do not send outside local AS (well-known community)\n"
10748 "Do not advertise to any peer (well-known community)\n"
10749 "Do not export to next AS (well-known community)\n"
10750 "Exact match of the communities")
10751{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010752 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010753}
10754
Lou Berger651b4022016-01-12 13:42:07 -050010755ALIAS (show_bgp_ipv4_community_exact,
10756 show_bgp_ipv4_community2_exact_cmd,
10757 "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 +000010758 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010759 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010760 IP_STR
paul718e3742002-12-13 20:15:29 +000010761 "Display routes matching the communities\n"
10762 "community number\n"
10763 "Do not send outside local AS (well-known community)\n"
10764 "Do not advertise to any peer (well-known community)\n"
10765 "Do not export to next AS (well-known community)\n"
10766 "community number\n"
10767 "Do not send outside local AS (well-known community)\n"
10768 "Do not advertise to any peer (well-known community)\n"
10769 "Do not export to next AS (well-known community)\n"
10770 "Exact match of the communities")
10771
Lou Berger651b4022016-01-12 13:42:07 -050010772ALIAS (show_bgp_ipv4_community_exact,
10773 show_bgp_ipv4_community3_exact_cmd,
10774 "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 +000010775 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010776 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010777 IP_STR
paul718e3742002-12-13 20:15:29 +000010778 "Display routes matching the communities\n"
10779 "community number\n"
10780 "Do not send outside local AS (well-known community)\n"
10781 "Do not advertise to any peer (well-known community)\n"
10782 "Do not export to next AS (well-known community)\n"
10783 "community number\n"
10784 "Do not send outside local AS (well-known community)\n"
10785 "Do not advertise to any peer (well-known community)\n"
10786 "Do not export to next AS (well-known community)\n"
10787 "community number\n"
10788 "Do not send outside local AS (well-known community)\n"
10789 "Do not advertise to any peer (well-known community)\n"
10790 "Do not export to next AS (well-known community)\n"
10791 "Exact match of the communities")
10792
Lou Berger651b4022016-01-12 13:42:07 -050010793ALIAS (show_bgp_ipv4_community_exact,
10794 show_bgp_ipv4_community4_exact_cmd,
10795 "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 +000010796 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010797 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010798 IP_STR
paul718e3742002-12-13 20:15:29 +000010799 "Display routes matching the communities\n"
10800 "community number\n"
10801 "Do not send outside local AS (well-known community)\n"
10802 "Do not advertise to any peer (well-known community)\n"
10803 "Do not export to next AS (well-known community)\n"
10804 "community number\n"
10805 "Do not send outside local AS (well-known community)\n"
10806 "Do not advertise to any peer (well-known community)\n"
10807 "Do not export to next AS (well-known community)\n"
10808 "community number\n"
10809 "Do not send outside local AS (well-known community)\n"
10810 "Do not advertise to any peer (well-known community)\n"
10811 "Do not export to next AS (well-known community)\n"
10812 "community number\n"
10813 "Do not send outside local AS (well-known community)\n"
10814 "Do not advertise to any peer (well-known community)\n"
10815 "Do not export to next AS (well-known community)\n"
10816 "Exact match of the communities")
10817
Lou Berger651b4022016-01-12 13:42:07 -050010818DEFUN (show_bgp_ipv4_safi_community4_exact,
10819 show_bgp_ipv4_safi_community_exact_cmd,
10820 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010821 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010822 BGP_STR
10823 "Address family\n"
10824 "Address Family modifier\n"
10825 "Address Family modifier\n"
10826 "Display routes matching the communities\n"
10827 "community number\n"
10828 "Do not send outside local AS (well-known community)\n"
10829 "Do not advertise to any peer (well-known community)\n"
10830 "Do not export to next AS (well-known community)\n"
10831 "Exact match of the communities")
10832{
10833 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010834 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010835
Michael Lambert95cbbd22010-07-23 14:43:04 -040010836 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010837}
10838
Lou Berger651b4022016-01-12 13:42:07 -050010839ALIAS (show_bgp_ipv4_safi_community4_exact,
10840 show_bgp_ipv4_safi_community2_exact_cmd,
10841 "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 +000010842 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010843 BGP_STR
10844 "Address family\n"
10845 "Address Family modifier\n"
10846 "Address Family modifier\n"
10847 "Display routes matching the communities\n"
10848 "community number\n"
10849 "Do not send outside local AS (well-known community)\n"
10850 "Do not advertise to any peer (well-known community)\n"
10851 "Do not export to next AS (well-known community)\n"
10852 "community number\n"
10853 "Do not send outside local AS (well-known community)\n"
10854 "Do not advertise to any peer (well-known community)\n"
10855 "Do not export to next AS (well-known community)\n"
10856 "Exact match of the communities")
10857
Lou Berger651b4022016-01-12 13:42:07 -050010858ALIAS (show_bgp_ipv4_safi_community4_exact,
10859 show_bgp_ipv4_safi_community3_exact_cmd,
10860 "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 +000010861 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010862 BGP_STR
10863 "Address family\n"
10864 "Address Family modifier\n"
10865 "Address Family modifier\n"
10866 "Display routes matching the communities\n"
10867 "community number\n"
10868 "Do not send outside local AS (well-known community)\n"
10869 "Do not advertise to any peer (well-known community)\n"
10870 "Do not export to next AS (well-known community)\n"
10871 "community number\n"
10872 "Do not send outside local AS (well-known community)\n"
10873 "Do not advertise to any peer (well-known community)\n"
10874 "Do not export to next AS (well-known community)\n"
10875 "community number\n"
10876 "Do not send outside local AS (well-known community)\n"
10877 "Do not advertise to any peer (well-known community)\n"
10878 "Do not export to next AS (well-known community)\n"
10879 "Exact match of the communities")
10880
Lou Berger651b4022016-01-12 13:42:07 -050010881ALIAS (show_bgp_ipv4_safi_community4_exact,
10882 show_bgp_ipv4_safi_community4_exact_cmd,
10883 "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 +000010884 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010885 BGP_STR
10886 "Address family\n"
10887 "Address Family modifier\n"
10888 "Address Family modifier\n"
10889 "Display routes matching the communities\n"
10890 "community number\n"
10891 "Do not send outside local AS (well-known community)\n"
10892 "Do not advertise to any peer (well-known community)\n"
10893 "Do not export to next AS (well-known community)\n"
10894 "community number\n"
10895 "Do not send outside local AS (well-known community)\n"
10896 "Do not advertise to any peer (well-known community)\n"
10897 "Do not export to next AS (well-known community)\n"
10898 "community number\n"
10899 "Do not send outside local AS (well-known community)\n"
10900 "Do not advertise to any peer (well-known community)\n"
10901 "Do not export to next AS (well-known community)\n"
10902 "community number\n"
10903 "Do not send outside local AS (well-known community)\n"
10904 "Do not advertise to any peer (well-known community)\n"
10905 "Do not export to next AS (well-known community)\n"
10906 "Exact match of the communities")
10907
Lou Bergerf9b6c392016-01-12 13:42:09 -050010908DEFUN (show_bgp_ipv6_safi_community,
10909 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010910 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010911 SHOW_STR
10912 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010913 "Address family\n"
10914 "Address family modifier\n"
10915 "Address family modifier\n"
10916 "Address family modifier\n"
10917 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010918 "Display routes matching the communities\n"
10919 "community number\n"
10920 "Do not send outside local AS (well-known community)\n"
10921 "Do not advertise to any peer (well-known community)\n"
10922 "Do not export to next AS (well-known community)\n")
10923{
Lou Berger651b4022016-01-12 13:42:07 -050010924 safi_t safi;
10925
10926 if (bgp_parse_safi(argv[0], &safi)) {
10927 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10928 return CMD_WARNING;
10929 }
10930 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010931}
10932
Lou Bergerf9b6c392016-01-12 13:42:09 -050010933ALIAS (show_bgp_ipv6_safi_community,
10934 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010935 "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 +000010936 SHOW_STR
10937 BGP_STR
10938 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010939 "Address family modifier\n"
10940 "Address family modifier\n"
10941 "Address family modifier\n"
10942 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010943 "Display routes matching the communities\n"
10944 "community number\n"
10945 "Do not send outside local AS (well-known community)\n"
10946 "Do not advertise to any peer (well-known community)\n"
10947 "Do not export to next AS (well-known community)\n"
10948 "community number\n"
10949 "Do not send outside local AS (well-known community)\n"
10950 "Do not advertise to any peer (well-known community)\n"
10951 "Do not export to next AS (well-known community)\n")
10952
Lou Bergerf9b6c392016-01-12 13:42:09 -050010953ALIAS (show_bgp_ipv6_safi_community,
10954 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010955 "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 +000010956 SHOW_STR
10957 BGP_STR
10958 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010959 "Address family modifier\n"
10960 "Address family modifier\n"
10961 "Address family modifier\n"
10962 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010963 "Display routes matching the communities\n"
10964 "community number\n"
10965 "Do not send outside local AS (well-known community)\n"
10966 "Do not advertise to any peer (well-known community)\n"
10967 "Do not export to next AS (well-known community)\n"
10968 "community number\n"
10969 "Do not send outside local AS (well-known community)\n"
10970 "Do not advertise to any peer (well-known community)\n"
10971 "Do not export to next AS (well-known community)\n"
10972 "community number\n"
10973 "Do not send outside local AS (well-known community)\n"
10974 "Do not advertise to any peer (well-known community)\n"
10975 "Do not export to next AS (well-known community)\n")
10976
Lou Bergerf9b6c392016-01-12 13:42:09 -050010977ALIAS (show_bgp_ipv6_safi_community,
10978 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010979 "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 +000010980 SHOW_STR
10981 BGP_STR
10982 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010983 "Address family modifier\n"
10984 "Address family modifier\n"
10985 "Address family modifier\n"
10986 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010987 "Display routes matching the communities\n"
10988 "community number\n"
10989 "Do not send outside local AS (well-known community)\n"
10990 "Do not advertise to any peer (well-known community)\n"
10991 "Do not export to next AS (well-known community)\n"
10992 "community number\n"
10993 "Do not send outside local AS (well-known community)\n"
10994 "Do not advertise to any peer (well-known community)\n"
10995 "Do not export to next AS (well-known community)\n"
10996 "community number\n"
10997 "Do not send outside local AS (well-known community)\n"
10998 "Do not advertise to any peer (well-known community)\n"
10999 "Do not export to next AS (well-known community)\n"
11000 "community number\n"
11001 "Do not send outside local AS (well-known community)\n"
11002 "Do not advertise to any peer (well-known community)\n"
11003 "Do not export to next AS (well-known community)\n")
11004
paul718e3742002-12-13 20:15:29 +000011005
Lou Bergerf9b6c392016-01-12 13:42:09 -050011006DEFUN (show_bgp_ipv6_safi_community_exact,
11007 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011008 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000011009 SHOW_STR
11010 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011011 "Address family\n"
11012 "Address family modifier\n"
11013 "Address family modifier\n"
11014 "Address family modifier\n"
11015 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011016 "Display routes matching the communities\n"
11017 "community number\n"
11018 "Do not send outside local AS (well-known community)\n"
11019 "Do not advertise to any peer (well-known community)\n"
11020 "Do not export to next AS (well-known community)\n"
11021 "Exact match of the communities")
11022{
Lou Berger651b4022016-01-12 13:42:07 -050011023 safi_t safi;
11024
11025 if (bgp_parse_safi(argv[0], &safi)) {
11026 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11027 return CMD_WARNING;
11028 }
11029 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011030}
11031
paul718e3742002-12-13 20:15:29 +000011032
11033ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011034 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011035 "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 +000011036 SHOW_STR
11037 BGP_STR
11038 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011039 "Address family modifier\n"
11040 "Address family modifier\n"
11041 "Address family modifier\n"
11042 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011043 "Display routes matching the communities\n"
11044 "community number\n"
11045 "Do not send outside local AS (well-known community)\n"
11046 "Do not advertise to any peer (well-known community)\n"
11047 "Do not export to next AS (well-known community)\n"
11048 "community number\n"
11049 "Do not send outside local AS (well-known community)\n"
11050 "Do not advertise to any peer (well-known community)\n"
11051 "Do not export to next AS (well-known community)\n"
11052 "Exact match of the communities")
11053
11054ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011055 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011056 "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 +000011057 SHOW_STR
11058 BGP_STR
11059 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011060 "Address family modifier\n"
11061 "Address family modifier\n"
11062 "Address family modifier\n"
11063 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011064 "Display routes matching the communities\n"
11065 "community number\n"
11066 "Do not send outside local AS (well-known community)\n"
11067 "Do not advertise to any peer (well-known community)\n"
11068 "Do not export to next AS (well-known community)\n"
11069 "community number\n"
11070 "Do not send outside local AS (well-known community)\n"
11071 "Do not advertise to any peer (well-known community)\n"
11072 "Do not export to next AS (well-known community)\n"
11073 "community number\n"
11074 "Do not send outside local AS (well-known community)\n"
11075 "Do not advertise to any peer (well-known community)\n"
11076 "Do not export to next AS (well-known community)\n"
11077 "Exact match of the communities")
11078
11079ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011080 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011081 "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 +000011082 SHOW_STR
11083 BGP_STR
11084 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011085 "Address family modifier\n"
11086 "Address family modifier\n"
11087 "Address family modifier\n"
11088 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011089 "Display routes matching the communities\n"
11090 "community number\n"
11091 "Do not send outside local AS (well-known community)\n"
11092 "Do not advertise to any peer (well-known community)\n"
11093 "Do not export to next AS (well-known community)\n"
11094 "community number\n"
11095 "Do not send outside local AS (well-known community)\n"
11096 "Do not advertise to any peer (well-known community)\n"
11097 "Do not export to next AS (well-known community)\n"
11098 "community number\n"
11099 "Do not send outside local AS (well-known community)\n"
11100 "Do not advertise to any peer (well-known community)\n"
11101 "Do not export to next AS (well-known community)\n"
11102 "community number\n"
11103 "Do not send outside local AS (well-known community)\n"
11104 "Do not advertise to any peer (well-known community)\n"
11105 "Do not export to next AS (well-known community)\n"
11106 "Exact match of the communities")
11107
paul94f2b392005-06-28 12:44:16 +000011108static int
paulfd79ac92004-10-13 05:06:08 +000011109bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040011110 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000011111{
11112 struct community_list *list;
11113
hassofee6e4e2005-02-02 16:29:31 +000011114 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000011115 if (list == NULL)
11116 {
11117 vty_out (vty, "%% %s is not a valid community-list name%s", com,
11118 VTY_NEWLINE);
11119 return CMD_WARNING;
11120 }
11121
ajs5a646652004-11-05 01:25:55 +000011122 return bgp_show (vty, NULL, afi, safi,
11123 (exact ? bgp_show_type_community_list_exact :
11124 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000011125}
11126
Lou Bergerf9b6c392016-01-12 13:42:09 -050011127DEFUN (show_ip_bgp_community_list,
11128 show_ip_bgp_community_list_cmd,
11129 "show ip bgp community-list (<1-500>|WORD)",
11130 SHOW_STR
11131 IP_STR
11132 BGP_STR
11133 "Display routes matching the community-list\n"
11134 "community-list number\n"
11135 "community-list name\n")
11136{
11137 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11138}
11139
11140DEFUN (show_ip_bgp_ipv4_community_list,
11141 show_ip_bgp_ipv4_community_list_cmd,
11142 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11143 SHOW_STR
11144 IP_STR
11145 BGP_STR
11146 "Address family\n"
11147 "Address Family modifier\n"
11148 "Address Family modifier\n"
11149 "Display routes matching the community-list\n"
11150 "community-list number\n"
11151 "community-list name\n")
11152{
11153 if (strncmp (argv[0], "m", 1) == 0)
11154 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11155
11156 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11157}
11158
11159DEFUN (show_ip_bgp_community_list_exact,
11160 show_ip_bgp_community_list_exact_cmd,
11161 "show ip bgp community-list (<1-500>|WORD) exact-match",
11162 SHOW_STR
11163 IP_STR
11164 BGP_STR
11165 "Display routes matching the community-list\n"
11166 "community-list number\n"
11167 "community-list name\n"
11168 "Exact match of the communities\n")
11169{
11170 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11171}
11172
11173DEFUN (show_ip_bgp_ipv4_community_list_exact,
11174 show_ip_bgp_ipv4_community_list_exact_cmd,
11175 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11176 SHOW_STR
11177 IP_STR
11178 BGP_STR
11179 "Address family\n"
11180 "Address Family modifier\n"
11181 "Address Family modifier\n"
11182 "Display routes matching the community-list\n"
11183 "community-list number\n"
11184 "community-list name\n"
11185 "Exact match of the communities\n")
11186{
11187 if (strncmp (argv[0], "m", 1) == 0)
11188 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11189
11190 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11191}
11192
Lou Bergerf9b6c392016-01-12 13:42:09 -050011193DEFUN (show_bgp_community_list,
11194 show_bgp_community_list_cmd,
11195 "show bgp community-list (<1-500>|WORD)",
11196 SHOW_STR
11197 BGP_STR
11198 "Display routes matching the community-list\n"
11199 "community-list number\n"
11200 "community-list name\n")
11201{
11202 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11203}
11204
11205ALIAS (show_bgp_community_list,
11206 show_bgp_ipv6_community_list_cmd,
11207 "show bgp ipv6 community-list (<1-500>|WORD)",
11208 SHOW_STR
11209 BGP_STR
11210 "Address family\n"
11211 "Display routes matching the community-list\n"
11212 "community-list number\n"
11213 "community-list name\n")
11214
11215/* old command */
11216DEFUN (show_ipv6_bgp_community_list,
11217 show_ipv6_bgp_community_list_cmd,
11218 "show ipv6 bgp community-list WORD",
11219 SHOW_STR
11220 IPV6_STR
11221 BGP_STR
11222 "Display routes matching the community-list\n"
11223 "community-list name\n")
11224{
11225 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11226}
11227
11228/* old command */
11229DEFUN (show_ipv6_mbgp_community_list,
11230 show_ipv6_mbgp_community_list_cmd,
11231 "show ipv6 mbgp community-list WORD",
11232 SHOW_STR
11233 IPV6_STR
11234 MBGP_STR
11235 "Display routes matching the community-list\n"
11236 "community-list name\n")
11237{
11238 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
11239}
11240
11241DEFUN (show_bgp_community_list_exact,
11242 show_bgp_community_list_exact_cmd,
11243 "show bgp community-list (<1-500>|WORD) exact-match",
11244 SHOW_STR
11245 BGP_STR
11246 "Display routes matching the community-list\n"
11247 "community-list number\n"
11248 "community-list name\n"
11249 "Exact match of the communities\n")
11250{
11251 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11252}
11253
11254ALIAS (show_bgp_community_list_exact,
11255 show_bgp_ipv6_community_list_exact_cmd,
11256 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11257 SHOW_STR
11258 BGP_STR
11259 "Address family\n"
11260 "Display routes matching the community-list\n"
11261 "community-list number\n"
11262 "community-list name\n"
11263 "Exact match of the communities\n")
11264
11265/* old command */
11266DEFUN (show_ipv6_bgp_community_list_exact,
11267 show_ipv6_bgp_community_list_exact_cmd,
11268 "show ipv6 bgp community-list WORD exact-match",
11269 SHOW_STR
11270 IPV6_STR
11271 BGP_STR
11272 "Display routes matching the community-list\n"
11273 "community-list name\n"
11274 "Exact match of the communities\n")
11275{
11276 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11277}
11278
11279/* old command */
11280DEFUN (show_ipv6_mbgp_community_list_exact,
11281 show_ipv6_mbgp_community_list_exact_cmd,
11282 "show ipv6 mbgp community-list WORD exact-match",
11283 SHOW_STR
11284 IPV6_STR
11285 MBGP_STR
11286 "Display routes matching the community-list\n"
11287 "community-list name\n"
11288 "Exact match of the communities\n")
11289{
11290 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
11291}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011292
Lou Berger651b4022016-01-12 13:42:07 -050011293DEFUN (show_bgp_ipv4_community_list,
11294 show_bgp_ipv4_community_list_cmd,
11295 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011296 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011297 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011298 IP_STR
paul718e3742002-12-13 20:15:29 +000011299 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011300 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011301 "community-list name\n")
11302{
11303 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11304}
11305
Lou Berger651b4022016-01-12 13:42:07 -050011306DEFUN (show_bgp_ipv4_safi_community_list,
11307 show_bgp_ipv4_safi_community_list_cmd,
11308 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011309 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011310 BGP_STR
11311 "Address family\n"
11312 "Address Family modifier\n"
11313 "Address Family modifier\n"
11314 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011315 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011316 "community-list name\n")
11317{
11318 if (strncmp (argv[0], "m", 1) == 0)
11319 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11320
11321 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11322}
11323
Lou Berger651b4022016-01-12 13:42:07 -050011324DEFUN (show_bgp_ipv4_community_list_exact,
11325 show_bgp_ipv4_community_list_exact_cmd,
11326 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011327 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011328 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011329 IP_STR
paul718e3742002-12-13 20:15:29 +000011330 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011331 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011332 "community-list name\n"
11333 "Exact match of the communities\n")
11334{
11335 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11336}
11337
Lou Berger651b4022016-01-12 13:42:07 -050011338DEFUN (show_bgp_ipv4_safi_community_list_exact,
11339 show_bgp_ipv4_safi_community_list_exact_cmd,
11340 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011341 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011342 BGP_STR
11343 "Address family\n"
11344 "Address Family modifier\n"
11345 "Address Family modifier\n"
11346 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011347 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011348 "community-list name\n"
11349 "Exact match of the communities\n")
11350{
11351 if (strncmp (argv[0], "m", 1) == 0)
11352 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11353
11354 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11355}
11356
Lou Bergerf9b6c392016-01-12 13:42:09 -050011357DEFUN (show_bgp_ipv6_safi_community_list,
11358 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011359 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011360 SHOW_STR
11361 BGP_STR
11362 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011363 "Address family modifier\n"
11364 "Address family modifier\n"
11365 "Address family modifier\n"
11366 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011367 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011368 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011369 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011370{
Lou Berger651b4022016-01-12 13:42:07 -050011371 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011372
Lou Berger651b4022016-01-12 13:42:07 -050011373 if (bgp_parse_safi(argv[0], &safi)) {
11374 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11375 return CMD_WARNING;
11376 }
11377 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011378}
11379
Lou Bergerf9b6c392016-01-12 13:42:09 -050011380DEFUN (show_bgp_ipv6_safi_community_list_exact,
11381 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011382 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011383 SHOW_STR
11384 BGP_STR
11385 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011386 "Address family modifier\n"
11387 "Address family modifier\n"
11388 "Address family modifier\n"
11389 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011390 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011391 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011392 "community-list name\n"
11393 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011394{
Lou Berger651b4022016-01-12 13:42:07 -050011395 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011396
Lou Berger651b4022016-01-12 13:42:07 -050011397 if (bgp_parse_safi(argv[0], &safi)) {
11398 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11399 return CMD_WARNING;
11400 }
11401 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011402}
David Lamparter6b0655a2014-06-04 06:53:35 +020011403
paul94f2b392005-06-28 12:44:16 +000011404static int
paulfd79ac92004-10-13 05:06:08 +000011405bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011406 safi_t safi, enum bgp_show_type type)
11407{
11408 int ret;
11409 struct prefix *p;
11410
11411 p = prefix_new();
11412
11413 ret = str2prefix (prefix, p);
11414 if (! ret)
11415 {
11416 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11417 return CMD_WARNING;
11418 }
11419
ajs5a646652004-11-05 01:25:55 +000011420 ret = bgp_show (vty, NULL, afi, safi, type, p);
11421 prefix_free(p);
11422 return ret;
paul718e3742002-12-13 20:15:29 +000011423}
11424
Lou Bergerf9b6c392016-01-12 13:42:09 -050011425DEFUN (show_ip_bgp_prefix_longer,
11426 show_ip_bgp_prefix_longer_cmd,
11427 "show ip bgp A.B.C.D/M longer-prefixes",
11428 SHOW_STR
11429 IP_STR
11430 BGP_STR
11431 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11432 "Display route and more specific routes\n")
11433{
11434 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11435 bgp_show_type_prefix_longer);
11436}
11437
11438DEFUN (show_ip_bgp_flap_prefix_longer,
11439 show_ip_bgp_flap_prefix_longer_cmd,
11440 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11441 SHOW_STR
11442 IP_STR
11443 BGP_STR
11444 "Display flap statistics of routes\n"
11445 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11446 "Display route and more specific routes\n")
11447{
11448 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11449 bgp_show_type_flap_prefix_longer);
11450}
11451
11452ALIAS (show_ip_bgp_flap_prefix_longer,
11453 show_ip_bgp_damp_flap_prefix_longer_cmd,
11454 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11455 SHOW_STR
11456 IP_STR
11457 BGP_STR
11458 "Display detailed information about dampening\n"
11459 "Display flap statistics of routes\n"
11460 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11461 "Display route and more specific routes\n")
11462
11463DEFUN (show_ip_bgp_ipv4_prefix_longer,
11464 show_ip_bgp_ipv4_prefix_longer_cmd,
11465 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11466 SHOW_STR
11467 IP_STR
11468 BGP_STR
11469 "Address family\n"
11470 "Address Family modifier\n"
11471 "Address Family modifier\n"
11472 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11473 "Display route and more specific routes\n")
11474{
11475 if (strncmp (argv[0], "m", 1) == 0)
11476 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11477 bgp_show_type_prefix_longer);
11478
11479 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11480 bgp_show_type_prefix_longer);
11481}
11482
11483DEFUN (show_ip_bgp_flap_address,
11484 show_ip_bgp_flap_address_cmd,
11485 "show ip bgp flap-statistics A.B.C.D",
11486 SHOW_STR
11487 IP_STR
11488 BGP_STR
11489 "Display flap statistics of routes\n"
11490 "Network in the BGP routing table to display\n")
11491{
11492 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11493 bgp_show_type_flap_address);
11494}
11495
11496ALIAS (show_ip_bgp_flap_address,
11497 show_ip_bgp_damp_flap_address_cmd,
11498 "show ip bgp dampening flap-statistics A.B.C.D",
11499 SHOW_STR
11500 IP_STR
11501 BGP_STR
11502 "Display detailed information about dampening\n"
11503 "Display flap statistics of routes\n"
11504 "Network in the BGP routing table to display\n")
11505
11506DEFUN (show_ip_bgp_flap_prefix,
11507 show_ip_bgp_flap_prefix_cmd,
11508 "show ip bgp flap-statistics A.B.C.D/M",
11509 SHOW_STR
11510 IP_STR
11511 BGP_STR
11512 "Display flap statistics of routes\n"
11513 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11514{
11515 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11516 bgp_show_type_flap_prefix);
11517}
11518
11519ALIAS (show_ip_bgp_flap_prefix,
11520 show_ip_bgp_damp_flap_prefix_cmd,
11521 "show ip bgp dampening flap-statistics A.B.C.D/M",
11522 SHOW_STR
11523 IP_STR
11524 BGP_STR
11525 "Display detailed information about dampening\n"
11526 "Display flap statistics of routes\n"
11527 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11528
Lou Bergerf9b6c392016-01-12 13:42:09 -050011529DEFUN (show_bgp_prefix_longer,
11530 show_bgp_prefix_longer_cmd,
11531 "show bgp X:X::X:X/M longer-prefixes",
11532 SHOW_STR
11533 BGP_STR
11534 "IPv6 prefix <network>/<length>\n"
11535 "Display route and more specific routes\n")
11536{
11537 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11538 bgp_show_type_prefix_longer);
11539}
11540
11541/* old command */
11542DEFUN (show_ipv6_bgp_prefix_longer,
11543 show_ipv6_bgp_prefix_longer_cmd,
11544 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11545 SHOW_STR
11546 IPV6_STR
11547 BGP_STR
11548 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11549 "Display route and more specific routes\n")
11550{
11551 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11552 bgp_show_type_prefix_longer);
11553}
11554
11555/* old command */
11556DEFUN (show_ipv6_mbgp_prefix_longer,
11557 show_ipv6_mbgp_prefix_longer_cmd,
11558 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11559 SHOW_STR
11560 IPV6_STR
11561 MBGP_STR
11562 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11563 "Display route and more specific routes\n")
11564{
11565 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
11566 bgp_show_type_prefix_longer);
11567}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011568
Lou Berger651b4022016-01-12 13:42:07 -050011569DEFUN (show_bgp_ipv4_prefix_longer,
11570 show_bgp_ipv4_prefix_longer_cmd,
11571 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011572 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011573 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011574 IP_STR
paul718e3742002-12-13 20:15:29 +000011575 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11576 "Display route and more specific routes\n")
11577{
11578 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11579 bgp_show_type_prefix_longer);
11580}
11581
Lou Berger651b4022016-01-12 13:42:07 -050011582DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11583 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11584 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011585 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011586 BGP_STR
11587 "Address family\n"
11588 "Address Family modifier\n"
11589 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011590 "Address Family modifier\n"
11591 "Address Family modifier\n"
11592 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011593 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11594 "Display route and more specific routes\n")
11595{
Lou Berger651b4022016-01-12 13:42:07 -050011596 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011597
Lou Berger651b4022016-01-12 13:42:07 -050011598 if (bgp_parse_safi(argv[0], &safi)) {
11599 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11600 return CMD_WARNING;
11601 }
11602 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11603 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011604}
11605
Lou Berger651b4022016-01-12 13:42:07 -050011606ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11607 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11608 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011609 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011610 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011611 "Address family\n"
11612 "Address Family modifier\n"
11613 "Address Family modifier\n"
11614 "Address Family modifier\n"
11615 "Address Family modifier\n"
11616 "Display detailed information about dampening\n"
11617 "Display flap statistics of routes\n"
11618 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11619 "Display route and more specific routes\n")
11620
Lou Berger651b4022016-01-12 13:42:07 -050011621DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11622 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11623 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11624 SHOW_STR
11625 BGP_STR
11626 "Address family\n"
11627 "Address Family modifier\n"
11628 "Address Family modifier\n"
11629 "Address Family modifier\n"
11630 "Address Family modifier\n"
11631 "Display flap statistics of routes\n"
11632 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11633 "Display route and more specific routes\n")
11634{
11635 safi_t safi;
11636
11637 if (bgp_parse_safi(argv[0], &safi)) {
11638 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11639 return CMD_WARNING;
11640 }
11641 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11642 bgp_show_type_flap_prefix_longer);
11643}
11644ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11645 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11646 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11647 SHOW_STR
11648 BGP_STR
11649 "Address family\n"
11650 "Address Family modifier\n"
11651 "Address Family modifier\n"
11652 "Address Family modifier\n"
11653 "Address Family modifier\n"
11654 "Display detailed information about dampening\n"
11655 "Display flap statistics of routes\n"
11656 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11657 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011658
11659DEFUN (show_bgp_ipv4_safi_prefix_longer,
11660 show_bgp_ipv4_safi_prefix_longer_cmd,
11661 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11662 SHOW_STR
11663 BGP_STR
11664 "Address family\n"
11665 "Address Family modifier\n"
11666 "Address Family modifier\n"
11667 "Address Family modifier\n"
11668 "Address Family modifier\n"
11669 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11670 "Display route and more specific routes\n")
11671{
11672 safi_t safi;
11673
11674 if (bgp_parse_safi(argv[0], &safi)) {
11675 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11676 return CMD_WARNING;
11677 }
11678
11679 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11680 bgp_show_type_prefix_longer);
11681}
11682
Lou Berger651b4022016-01-12 13:42:07 -050011683DEFUN (show_bgp_ipv6_safi_prefix_longer,
11684 show_bgp_ipv6_safi_prefix_longer_cmd,
11685 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11686 SHOW_STR
11687 BGP_STR
11688 "Address family\n"
11689 "Address Family modifier\n"
11690 "Address Family modifier\n"
11691 "Address Family modifier\n"
11692 "Address Family modifier\n"
11693 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11694 "Display route and more specific routes\n")
11695{
11696 safi_t safi;
11697
11698 if (bgp_parse_safi(argv[0], &safi)) {
11699 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11700 return CMD_WARNING;
11701 }
11702
11703 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11704 bgp_show_type_prefix_longer);
11705}
Lou Berger651b4022016-01-12 13:42:07 -050011706
11707DEFUN (show_bgp_ipv4_safi_flap_address,
11708 show_bgp_ipv4_safi_flap_address_cmd,
11709 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11710 SHOW_STR
11711 BGP_STR
11712 "Address family\n"
11713 "Address Family modifier\n"
11714 "Address Family modifier\n"
11715 "Address Family modifier\n"
11716 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011717 "Display flap statistics of routes\n"
11718 "Network in the BGP routing table to display\n")
11719{
Lou Berger651b4022016-01-12 13:42:07 -050011720 safi_t safi;
11721
11722 if (bgp_parse_safi(argv[0], &safi)) {
11723 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11724 return CMD_WARNING;
11725 }
11726 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011727 bgp_show_type_flap_address);
11728}
Lou Berger651b4022016-01-12 13:42:07 -050011729ALIAS (show_bgp_ipv4_safi_flap_address,
11730 show_bgp_ipv4_safi_damp_flap_address_cmd,
11731 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011732 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011733 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011734 "Address family\n"
11735 "Address Family modifier\n"
11736 "Address Family modifier\n"
11737 "Address Family modifier\n"
11738 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011739 "Display detailed information about dampening\n"
11740 "Display flap statistics of routes\n"
11741 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011742
Lou Berger651b4022016-01-12 13:42:07 -050011743DEFUN (show_bgp_ipv6_flap_address,
11744 show_bgp_ipv6_flap_address_cmd,
11745 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011746 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011747 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011748 "Address family\n"
11749 "Address Family modifier\n"
11750 "Address Family modifier\n"
11751 "Address Family modifier\n"
11752 "Address Family modifier\n"
11753 "Display flap statistics of routes\n"
11754 "Network in the BGP routing table to display\n")
11755{
11756 safi_t safi;
11757
11758 if (bgp_parse_safi(argv[0], &safi)) {
11759 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11760 return CMD_WARNING;
11761 }
11762 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11763 bgp_show_type_flap_address);
11764}
11765ALIAS (show_bgp_ipv6_flap_address,
11766 show_bgp_ipv6_damp_flap_address_cmd,
11767 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11768 SHOW_STR
11769 BGP_STR
11770 "Address family\n"
11771 "Address Family modifier\n"
11772 "Address Family modifier\n"
11773 "Address Family modifier\n"
11774 "Address Family modifier\n"
11775 "Display detailed information about dampening\n"
11776 "Display flap statistics of routes\n"
11777 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011778
11779DEFUN (show_bgp_ipv4_safi_flap_prefix,
11780 show_bgp_ipv4_safi_flap_prefix_cmd,
11781 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
11782 SHOW_STR
11783 BGP_STR
11784 "Address family\n"
11785 "Address Family modifier\n"
11786 "Address Family modifier\n"
11787 "Address Family modifier\n"
11788 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011789 "Display flap statistics of routes\n"
11790 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11791{
Lou Berger651b4022016-01-12 13:42:07 -050011792 safi_t safi;
11793
11794 if (bgp_parse_safi(argv[0], &safi)) {
11795 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11796 return CMD_WARNING;
11797 }
11798 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011799 bgp_show_type_flap_prefix);
11800}
Balaji3921cc52015-05-16 23:12:17 +053011801
Lou Berger651b4022016-01-12 13:42:07 -050011802ALIAS (show_bgp_ipv4_safi_flap_prefix,
11803 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11804 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011805 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011806 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011807 "Address family\n"
11808 "Address Family modifier\n"
11809 "Address Family modifier\n"
11810 "Address Family modifier\n"
11811 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011812 "Display detailed information about dampening\n"
11813 "Display flap statistics of routes\n"
11814 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11815
Lou Berger651b4022016-01-12 13:42:07 -050011816DEFUN (show_bgp_ipv6_safi_flap_prefix,
11817 show_bgp_ipv6_safi_flap_prefix_cmd,
11818 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011819 SHOW_STR
11820 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011821 "Address family\n"
11822 "Address Family modifier\n"
11823 "Address Family modifier\n"
11824 "Address Family modifier\n"
11825 "Address Family modifier\n"
11826 "Display flap statistics of routes\n"
11827 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011828{
Lou Berger651b4022016-01-12 13:42:07 -050011829 safi_t safi;
11830
11831 if (bgp_parse_safi(argv[0], &safi)) {
11832 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11833 return CMD_WARNING;
11834 }
11835 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11836 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011837}
11838
Lou Berger651b4022016-01-12 13:42:07 -050011839ALIAS (show_bgp_ipv6_safi_flap_prefix,
11840 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11841 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11842 SHOW_STR
11843 BGP_STR
11844 "Address family\n"
11845 "Address Family modifier\n"
11846 "Address Family modifier\n"
11847 "Address Family modifier\n"
11848 "Address Family modifier\n"
11849 "Display detailed information about dampening\n"
11850 "Display flap statistics of routes\n"
11851 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11852
11853DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011854 show_bgp_ipv6_prefix_longer_cmd,
11855 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11856 SHOW_STR
11857 BGP_STR
11858 "Address family\n"
11859 "IPv6 prefix <network>/<length>\n"
11860 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011861{
11862 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11863 bgp_show_type_prefix_longer);
11864}
11865
paul94f2b392005-06-28 12:44:16 +000011866static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011867peer_lookup_in_view (struct vty *vty, const char *view_name,
11868 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011869{
11870 int ret;
11871 struct bgp *bgp;
11872 struct peer *peer;
11873 union sockunion su;
11874
11875 /* BGP structure lookup. */
11876 if (view_name)
11877 {
11878 bgp = bgp_lookup_by_name (view_name);
11879 if (! bgp)
11880 {
11881 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11882 return NULL;
11883 }
11884 }
paul5228ad22004-06-04 17:58:18 +000011885 else
paulbb46e942003-10-24 19:02:03 +000011886 {
11887 bgp = bgp_get_default ();
11888 if (! bgp)
11889 {
11890 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11891 return NULL;
11892 }
11893 }
11894
11895 /* Get peer sockunion. */
11896 ret = str2sockunion (ip_str, &su);
11897 if (ret < 0)
11898 {
11899 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11900 return NULL;
11901 }
11902
11903 /* Peer structure lookup. */
11904 peer = peer_lookup (bgp, &su);
11905 if (! peer)
11906 {
11907 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11908 return NULL;
11909 }
11910
11911 return peer;
11912}
David Lamparter6b0655a2014-06-04 06:53:35 +020011913
Paul Jakma2815e612006-09-14 02:56:07 +000011914enum bgp_stats
11915{
11916 BGP_STATS_MAXBITLEN = 0,
11917 BGP_STATS_RIB,
11918 BGP_STATS_PREFIXES,
11919 BGP_STATS_TOTPLEN,
11920 BGP_STATS_UNAGGREGATEABLE,
11921 BGP_STATS_MAX_AGGREGATEABLE,
11922 BGP_STATS_AGGREGATES,
11923 BGP_STATS_SPACE,
11924 BGP_STATS_ASPATH_COUNT,
11925 BGP_STATS_ASPATH_MAXHOPS,
11926 BGP_STATS_ASPATH_TOTHOPS,
11927 BGP_STATS_ASPATH_MAXSIZE,
11928 BGP_STATS_ASPATH_TOTSIZE,
11929 BGP_STATS_ASN_HIGHEST,
11930 BGP_STATS_MAX,
11931};
paulbb46e942003-10-24 19:02:03 +000011932
Paul Jakma2815e612006-09-14 02:56:07 +000011933static const char *table_stats_strs[] =
11934{
11935 [BGP_STATS_PREFIXES] = "Total Prefixes",
11936 [BGP_STATS_TOTPLEN] = "Average prefix length",
11937 [BGP_STATS_RIB] = "Total Advertisements",
11938 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11939 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11940 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11941 [BGP_STATS_SPACE] = "Address space advertised",
11942 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11943 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11944 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11945 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11946 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11947 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11948 [BGP_STATS_MAX] = NULL,
11949};
11950
11951struct bgp_table_stats
11952{
11953 struct bgp_table *table;
11954 unsigned long long counts[BGP_STATS_MAX];
11955};
11956
11957#if 0
11958#define TALLY_SIGFIG 100000
11959static unsigned long
11960ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11961{
11962 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11963 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11964 unsigned long ret = newtot / count;
11965
11966 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11967 return ret + 1;
11968 else
11969 return ret;
11970}
11971#endif
11972
11973static int
11974bgp_table_stats_walker (struct thread *t)
11975{
11976 struct bgp_node *rn;
11977 struct bgp_node *top;
11978 struct bgp_table_stats *ts = THREAD_ARG (t);
11979 unsigned int space = 0;
11980
Paul Jakma53d9f672006-10-15 23:41:16 +000011981 if (!(top = bgp_table_top (ts->table)))
11982 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011983
11984 switch (top->p.family)
11985 {
11986 case AF_INET:
11987 space = IPV4_MAX_BITLEN;
11988 break;
11989 case AF_INET6:
11990 space = IPV6_MAX_BITLEN;
11991 break;
11992 }
11993
11994 ts->counts[BGP_STATS_MAXBITLEN] = space;
11995
11996 for (rn = top; rn; rn = bgp_route_next (rn))
11997 {
11998 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011999 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000012000 unsigned int rinum = 0;
12001
12002 if (rn == top)
12003 continue;
12004
12005 if (!rn->info)
12006 continue;
12007
12008 ts->counts[BGP_STATS_PREFIXES]++;
12009 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
12010
12011#if 0
12012 ts->counts[BGP_STATS_AVGPLEN]
12013 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
12014 ts->counts[BGP_STATS_AVGPLEN],
12015 rn->p.prefixlen);
12016#endif
12017
12018 /* check if the prefix is included by any other announcements */
12019 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070012020 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000012021
12022 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000012023 {
12024 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
12025 /* announced address space */
12026 if (space)
12027 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
12028 }
Paul Jakma2815e612006-09-14 02:56:07 +000012029 else if (prn->info)
12030 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
12031
Paul Jakma2815e612006-09-14 02:56:07 +000012032 for (ri = rn->info; ri; ri = ri->next)
12033 {
12034 rinum++;
12035 ts->counts[BGP_STATS_RIB]++;
12036
12037 if (ri->attr &&
12038 (CHECK_FLAG (ri->attr->flag,
12039 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
12040 ts->counts[BGP_STATS_AGGREGATES]++;
12041
12042 /* as-path stats */
12043 if (ri->attr && ri->attr->aspath)
12044 {
12045 unsigned int hops = aspath_count_hops (ri->attr->aspath);
12046 unsigned int size = aspath_size (ri->attr->aspath);
12047 as_t highest = aspath_highest (ri->attr->aspath);
12048
12049 ts->counts[BGP_STATS_ASPATH_COUNT]++;
12050
12051 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
12052 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
12053
12054 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
12055 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
12056
12057 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
12058 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
12059#if 0
12060 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
12061 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12062 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
12063 hops);
12064 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
12065 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12066 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
12067 size);
12068#endif
12069 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
12070 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
12071 }
12072 }
12073 }
12074 return 0;
12075}
12076
12077static int
12078bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
12079{
12080 struct bgp_table_stats ts;
12081 unsigned int i;
12082
12083 if (!bgp->rib[afi][safi])
12084 {
Donald Sharp3c964042016-01-25 23:38:53 -050012085 vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s",
12086 afi, safi, VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000012087 return CMD_WARNING;
12088 }
12089
12090 memset (&ts, 0, sizeof (ts));
12091 ts.table = bgp->rib[afi][safi];
12092 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
12093
12094 vty_out (vty, "BGP %s RIB statistics%s%s",
12095 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
12096
12097 for (i = 0; i < BGP_STATS_MAX; i++)
12098 {
12099 if (!table_stats_strs[i])
12100 continue;
12101
12102 switch (i)
12103 {
12104#if 0
12105 case BGP_STATS_ASPATH_AVGHOPS:
12106 case BGP_STATS_ASPATH_AVGSIZE:
12107 case BGP_STATS_AVGPLEN:
12108 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12109 vty_out (vty, "%12.2f",
12110 (float)ts.counts[i] / (float)TALLY_SIGFIG);
12111 break;
12112#endif
12113 case BGP_STATS_ASPATH_TOTHOPS:
12114 case BGP_STATS_ASPATH_TOTSIZE:
12115 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12116 vty_out (vty, "%12.2f",
12117 ts.counts[i] ?
12118 (float)ts.counts[i] /
12119 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
12120 : 0);
12121 break;
12122 case BGP_STATS_TOTPLEN:
12123 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12124 vty_out (vty, "%12.2f",
12125 ts.counts[i] ?
12126 (float)ts.counts[i] /
12127 (float)ts.counts[BGP_STATS_PREFIXES]
12128 : 0);
12129 break;
12130 case BGP_STATS_SPACE:
12131 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12132 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
12133 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
12134 break;
Paul Jakma30a22312008-08-15 14:05:22 +010012135 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000012136 vty_out (vty, "%12.2f%s",
12137 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000012138 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000012139 VTY_NEWLINE);
12140 vty_out (vty, "%30s: ", "/8 equivalent ");
12141 vty_out (vty, "%12.2f%s",
12142 (float)ts.counts[BGP_STATS_SPACE] /
12143 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
12144 VTY_NEWLINE);
12145 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
12146 break;
12147 vty_out (vty, "%30s: ", "/24 equivalent ");
12148 vty_out (vty, "%12.2f",
12149 (float)ts.counts[BGP_STATS_SPACE] /
12150 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
12151 break;
12152 default:
12153 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12154 vty_out (vty, "%12llu", ts.counts[i]);
12155 }
12156
12157 vty_out (vty, "%s", VTY_NEWLINE);
12158 }
12159 return CMD_SUCCESS;
12160}
12161
12162static int
12163bgp_table_stats_vty (struct vty *vty, const char *name,
12164 const char *afi_str, const char *safi_str)
12165{
12166 struct bgp *bgp;
12167 afi_t afi;
12168 safi_t safi;
12169
12170 if (name)
12171 bgp = bgp_lookup_by_name (name);
12172 else
12173 bgp = bgp_get_default ();
12174
12175 if (!bgp)
12176 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050012177 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000012178 return CMD_WARNING;
12179 }
12180 if (strncmp (afi_str, "ipv", 3) == 0)
12181 {
12182 if (strncmp (afi_str, "ipv4", 4) == 0)
12183 afi = AFI_IP;
12184 else if (strncmp (afi_str, "ipv6", 4) == 0)
12185 afi = AFI_IP6;
12186 else
12187 {
12188 vty_out (vty, "%% Invalid address family %s%s",
12189 afi_str, VTY_NEWLINE);
12190 return CMD_WARNING;
12191 }
Lou Berger298cc2f2016-01-12 13:42:02 -050012192 switch (safi_str[0]) {
12193 case 'm':
12194 safi = SAFI_MULTICAST;
12195 break;
12196 case 'u':
12197 safi = SAFI_UNICAST;
12198 break;
12199 case 'v':
Donald Sharp3c964042016-01-25 23:38:53 -050012200 safi = SAFI_MPLS_VPN;
Lou Berger298cc2f2016-01-12 13:42:02 -050012201 break;
12202 case 'e':
12203 safi = SAFI_ENCAP;
12204 break;
12205 default:
12206 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000012207 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050012208 return CMD_WARNING;
12209 }
Paul Jakma2815e612006-09-14 02:56:07 +000012210 }
12211 else
12212 {
Lou Berger298cc2f2016-01-12 13:42:02 -050012213 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000012214 afi_str, VTY_NEWLINE);
12215 return CMD_WARNING;
12216 }
12217
Paul Jakma2815e612006-09-14 02:56:07 +000012218 return bgp_table_stats (vty, bgp, afi, safi);
12219}
12220
12221DEFUN (show_bgp_statistics,
12222 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050012223 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012224 SHOW_STR
12225 BGP_STR
12226 "Address family\n"
12227 "Address family\n"
12228 "Address Family modifier\n"
12229 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050012230 "Address Family modifier\n"
12231 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000012232 "BGP RIB advertisement statistics\n")
12233{
12234 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
12235}
12236
Lou Bergerf9b6c392016-01-12 13:42:09 -050012237ALIAS (show_bgp_statistics,
12238 show_bgp_statistics_vpnv4_cmd,
12239 "show bgp (ipv4) (vpnv4) statistics",
12240 SHOW_STR
12241 BGP_STR
12242 "Address family\n"
12243 "Address Family modifier\n"
12244 "BGP RIB advertisement statistics\n")
12245
Paul Jakma2815e612006-09-14 02:56:07 +000012246DEFUN (show_bgp_statistics_view,
12247 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050012248 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012249 SHOW_STR
12250 BGP_STR
12251 "BGP view\n"
12252 "Address family\n"
12253 "Address family\n"
12254 "Address Family modifier\n"
12255 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050012256 "Address Family modifier\n"
12257 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000012258 "BGP RIB advertisement statistics\n")
12259{
12260 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
12261}
12262
12263ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050012264 show_bgp_statistics_view_vpnv4_cmd,
12265 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012266 SHOW_STR
12267 BGP_STR
12268 "BGP view\n"
12269 "Address family\n"
12270 "Address Family modifier\n"
12271 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020012272
Paul Jakmaff7924f2006-09-04 01:10:36 +000012273enum bgp_pcounts
12274{
12275 PCOUNT_ADJ_IN = 0,
12276 PCOUNT_DAMPED,
12277 PCOUNT_REMOVED,
12278 PCOUNT_HISTORY,
12279 PCOUNT_STALE,
12280 PCOUNT_VALID,
12281 PCOUNT_ALL,
12282 PCOUNT_COUNTED,
12283 PCOUNT_PFCNT, /* the figure we display to users */
12284 PCOUNT_MAX,
12285};
12286
12287static const char *pcount_strs[] =
12288{
12289 [PCOUNT_ADJ_IN] = "Adj-in",
12290 [PCOUNT_DAMPED] = "Damped",
12291 [PCOUNT_REMOVED] = "Removed",
12292 [PCOUNT_HISTORY] = "History",
12293 [PCOUNT_STALE] = "Stale",
12294 [PCOUNT_VALID] = "Valid",
12295 [PCOUNT_ALL] = "All RIB",
12296 [PCOUNT_COUNTED] = "PfxCt counted",
12297 [PCOUNT_PFCNT] = "Useable",
12298 [PCOUNT_MAX] = NULL,
12299};
12300
Paul Jakma2815e612006-09-14 02:56:07 +000012301struct peer_pcounts
12302{
12303 unsigned int count[PCOUNT_MAX];
12304 const struct peer *peer;
12305 const struct bgp_table *table;
12306};
12307
Paul Jakmaff7924f2006-09-04 01:10:36 +000012308static int
Paul Jakma2815e612006-09-14 02:56:07 +000012309bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000012310{
12311 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000012312 struct peer_pcounts *pc = THREAD_ARG (t);
12313 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012314
Paul Jakma2815e612006-09-14 02:56:07 +000012315 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012316 {
12317 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000012318 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012319
12320 for (ain = rn->adj_in; ain; ain = ain->next)
12321 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000012322 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012323
Paul Jakmaff7924f2006-09-04 01:10:36 +000012324 for (ri = rn->info; ri; ri = ri->next)
12325 {
12326 char buf[SU_ADDRSTRLEN];
12327
12328 if (ri->peer != peer)
12329 continue;
12330
Paul Jakma2815e612006-09-14 02:56:07 +000012331 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012332
12333 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000012334 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012335 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000012336 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012337 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000012338 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012339 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000012340 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012341 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000012342 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012343 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000012344 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012345
12346 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
12347 {
Paul Jakma2815e612006-09-14 02:56:07 +000012348 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012349 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012350 plog_warn (peer->log,
12351 "%s [pcount] %s/%d is counted but flags 0x%x",
12352 peer->host,
12353 inet_ntop(rn->p.family, &rn->p.u.prefix,
12354 buf, SU_ADDRSTRLEN),
12355 rn->p.prefixlen,
12356 ri->flags);
12357 }
12358 else
12359 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012360 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012361 plog_warn (peer->log,
12362 "%s [pcount] %s/%d not counted but flags 0x%x",
12363 peer->host,
12364 inet_ntop(rn->p.family, &rn->p.u.prefix,
12365 buf, SU_ADDRSTRLEN),
12366 rn->p.prefixlen,
12367 ri->flags);
12368 }
12369 }
12370 }
Paul Jakma2815e612006-09-14 02:56:07 +000012371 return 0;
12372}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012373
Paul Jakma2815e612006-09-14 02:56:07 +000012374static int
12375bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12376{
12377 struct peer_pcounts pcounts = { .peer = peer };
12378 unsigned int i;
12379
12380 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12381 || !peer->bgp->rib[afi][safi])
12382 {
12383 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12384 return CMD_WARNING;
12385 }
12386
12387 memset (&pcounts, 0, sizeof(pcounts));
12388 pcounts.peer = peer;
12389 pcounts.table = peer->bgp->rib[afi][safi];
12390
12391 /* in-place call via thread subsystem so as to record execution time
12392 * stats for the thread-walk (i.e. ensure this can't be blamed on
12393 * on just vty_read()).
12394 */
12395 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12396
Paul Jakmaff7924f2006-09-04 01:10:36 +000012397 vty_out (vty, "Prefix counts for %s, %s%s",
12398 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12399 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12400 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12401 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12402
12403 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012404 vty_out (vty, "%20s: %-10d%s",
12405 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012406
Paul Jakma2815e612006-09-14 02:56:07 +000012407 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012408 {
12409 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12410 peer->host, VTY_NEWLINE);
12411 vty_out (vty, "Please report this bug, with the above command output%s",
12412 VTY_NEWLINE);
12413 }
12414
12415 return CMD_SUCCESS;
12416}
12417
Lou Bergerf9b6c392016-01-12 13:42:09 -050012418DEFUN (show_ip_bgp_neighbor_prefix_counts,
12419 show_ip_bgp_neighbor_prefix_counts_cmd,
12420 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12421 SHOW_STR
12422 IP_STR
12423 BGP_STR
12424 "Detailed information on TCP and BGP neighbor connections\n"
12425 "Neighbor to display information about\n"
12426 "Neighbor to display information about\n"
12427 "Display detailed prefix count information\n")
12428{
12429 struct peer *peer;
12430
12431 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12432 if (! peer)
12433 return CMD_WARNING;
12434
12435 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12436}
12437
Paul Jakmaff7924f2006-09-04 01:10:36 +000012438DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12439 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12440 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12441 SHOW_STR
12442 BGP_STR
12443 "Address family\n"
12444 "Detailed information on TCP and BGP neighbor connections\n"
12445 "Neighbor to display information about\n"
12446 "Neighbor to display information about\n"
12447 "Display detailed prefix count information\n")
12448{
12449 struct peer *peer;
12450
12451 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12452 if (! peer)
12453 return CMD_WARNING;
12454
12455 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12456}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012457
12458DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12459 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12460 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12461 SHOW_STR
12462 IP_STR
12463 BGP_STR
12464 "Address family\n"
12465 "Address Family modifier\n"
12466 "Address Family modifier\n"
12467 "Detailed information on TCP and BGP neighbor connections\n"
12468 "Neighbor to display information about\n"
12469 "Neighbor to display information about\n"
12470 "Display detailed prefix count information\n")
12471{
12472 struct peer *peer;
12473
12474 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12475 if (! peer)
12476 return CMD_WARNING;
12477
12478 if (strncmp (argv[0], "m", 1) == 0)
12479 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12480
12481 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12482}
12483
12484DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12485 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12486 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12487 SHOW_STR
12488 IP_STR
12489 BGP_STR
12490 "Address family\n"
12491 "Address Family modifier\n"
12492 "Address Family modifier\n"
12493 "Detailed information on TCP and BGP neighbor connections\n"
12494 "Neighbor to display information about\n"
12495 "Neighbor to display information about\n"
12496 "Display detailed prefix count information\n")
12497{
12498 struct peer *peer;
12499
12500 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12501 if (! peer)
12502 return CMD_WARNING;
12503
12504 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12505}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012506
Lou Berger651b4022016-01-12 13:42:07 -050012507DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12508 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12509 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012510 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012511 BGP_STR
12512 "Address family\n"
12513 "Address Family modifier\n"
12514 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012515 "Address Family modifier\n"
12516 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012517 "Detailed information on TCP and BGP neighbor connections\n"
12518 "Neighbor to display information about\n"
12519 "Neighbor to display information about\n"
12520 "Display detailed prefix count information\n")
12521{
12522 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012523 safi_t safi;
12524
12525 if (bgp_parse_safi(argv[0], &safi)) {
12526 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12527 return CMD_WARNING;
12528 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012529
12530 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12531 if (! peer)
12532 return CMD_WARNING;
12533
Lou Berger651b4022016-01-12 13:42:07 -050012534 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012535}
Lou Berger205e6742016-01-12 13:42:11 -050012536
Lou Berger651b4022016-01-12 13:42:07 -050012537DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12538 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12539 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12540 SHOW_STR
12541 BGP_STR
12542 "Address family\n"
12543 "Address Family modifier\n"
12544 "Address Family modifier\n"
12545 "Address Family modifier\n"
12546 "Address Family modifier\n"
12547 "Detailed information on TCP and BGP neighbor connections\n"
12548 "Neighbor to display information about\n"
12549 "Neighbor to display information about\n"
12550 "Display detailed prefix count information\n")
12551{
12552 struct peer *peer;
12553 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012554
Lou Berger651b4022016-01-12 13:42:07 -050012555 if (bgp_parse_safi(argv[0], &safi)) {
12556 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12557 return CMD_WARNING;
12558 }
12559
12560 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12561 if (! peer)
12562 return CMD_WARNING;
12563
12564 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12565}
Lou Berger651b4022016-01-12 13:42:07 -050012566
12567DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12568 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12569 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012570 SHOW_STR
12571 IP_STR
12572 BGP_STR
12573 "Address family\n"
12574 "Address Family modifier\n"
12575 "Address Family modifier\n"
12576 "Detailed information on TCP and BGP neighbor connections\n"
12577 "Neighbor to display information about\n"
12578 "Neighbor to display information about\n"
12579 "Display detailed prefix count information\n")
12580{
12581 struct peer *peer;
12582
12583 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12584 if (! peer)
12585 return CMD_WARNING;
12586
Lou Berger651b4022016-01-12 13:42:07 -050012587 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012588}
12589
12590
paul94f2b392005-06-28 12:44:16 +000012591static void
paul718e3742002-12-13 20:15:29 +000012592show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12593 int in)
12594{
12595 struct bgp_table *table;
12596 struct bgp_adj_in *ain;
12597 struct bgp_adj_out *adj;
12598 unsigned long output_count;
12599 struct bgp_node *rn;
12600 int header1 = 1;
12601 struct bgp *bgp;
12602 int header2 = 1;
12603
paulbb46e942003-10-24 19:02:03 +000012604 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012605
12606 if (! bgp)
12607 return;
12608
12609 table = bgp->rib[afi][safi];
12610
12611 output_count = 0;
12612
12613 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12614 PEER_STATUS_DEFAULT_ORIGINATE))
12615 {
12616 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 +000012617 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12618 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012619
12620 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12621 VTY_NEWLINE, VTY_NEWLINE);
12622 header1 = 0;
12623 }
12624
12625 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12626 if (in)
12627 {
12628 for (ain = rn->adj_in; ain; ain = ain->next)
12629 if (ain->peer == peer)
12630 {
12631 if (header1)
12632 {
12633 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 +000012634 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12635 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012636 header1 = 0;
12637 }
12638 if (header2)
12639 {
12640 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12641 header2 = 0;
12642 }
12643 if (ain->attr)
12644 {
12645 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12646 output_count++;
12647 }
12648 }
12649 }
12650 else
12651 {
12652 for (adj = rn->adj_out; adj; adj = adj->next)
12653 if (adj->peer == peer)
12654 {
12655 if (header1)
12656 {
12657 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 +000012658 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12659 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012660 header1 = 0;
12661 }
12662 if (header2)
12663 {
12664 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12665 header2 = 0;
12666 }
12667 if (adj->attr)
12668 {
12669 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12670 output_count++;
12671 }
12672 }
12673 }
12674
12675 if (output_count != 0)
12676 vty_out (vty, "%sTotal number of prefixes %ld%s",
12677 VTY_NEWLINE, output_count, VTY_NEWLINE);
12678}
12679
paul94f2b392005-06-28 12:44:16 +000012680static int
paulbb46e942003-10-24 19:02:03 +000012681peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12682{
paul718e3742002-12-13 20:15:29 +000012683 if (! peer || ! peer->afc[afi][safi])
12684 {
12685 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12686 return CMD_WARNING;
12687 }
12688
12689 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12690 {
12691 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12692 VTY_NEWLINE);
12693 return CMD_WARNING;
12694 }
12695
12696 show_adj_route (vty, peer, afi, safi, in);
12697
12698 return CMD_SUCCESS;
12699}
12700
Lou Bergerf9b6c392016-01-12 13:42:09 -050012701DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12702 show_ip_bgp_view_neighbor_advertised_route_cmd,
12703 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12704 SHOW_STR
12705 IP_STR
12706 BGP_STR
12707 "BGP view\n"
12708 "View name\n"
12709 "Detailed information on TCP and BGP neighbor connections\n"
12710 "Neighbor to display information about\n"
12711 "Neighbor to display information about\n"
12712 "Display the routes advertised to a BGP neighbor\n")
12713{
12714 struct peer *peer;
12715
12716 if (argc == 2)
12717 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12718 else
12719 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12720
12721 if (! peer)
12722 return CMD_WARNING;
12723
12724 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12725}
12726
12727ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12728 show_ip_bgp_neighbor_advertised_route_cmd,
12729 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12730 SHOW_STR
12731 IP_STR
12732 BGP_STR
12733 "Detailed information on TCP and BGP neighbor connections\n"
12734 "Neighbor to display information about\n"
12735 "Neighbor to display information about\n"
12736 "Display the routes advertised to a BGP neighbor\n")
12737
12738DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12739 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12740 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12741 SHOW_STR
12742 IP_STR
12743 BGP_STR
12744 "Address family\n"
12745 "Address Family modifier\n"
12746 "Address Family modifier\n"
12747 "Detailed information on TCP and BGP neighbor connections\n"
12748 "Neighbor to display information about\n"
12749 "Neighbor to display information about\n"
12750 "Display the routes advertised to a BGP neighbor\n")
12751{
12752 struct peer *peer;
12753
12754 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12755 if (! peer)
12756 return CMD_WARNING;
12757
12758 if (strncmp (argv[0], "m", 1) == 0)
12759 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12760
12761 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12762}
12763
Lou Bergerf9b6c392016-01-12 13:42:09 -050012764DEFUN (show_bgp_view_neighbor_advertised_route,
12765 show_bgp_view_neighbor_advertised_route_cmd,
12766 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12767 SHOW_STR
12768 BGP_STR
12769 "BGP view\n"
12770 "View name\n"
12771 "Detailed information on TCP and BGP neighbor connections\n"
12772 "Neighbor to display information about\n"
12773 "Neighbor to display information about\n"
12774 "Display the routes advertised to a BGP neighbor\n")
12775{
12776 struct peer *peer;
12777
12778 if (argc == 2)
12779 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12780 else
12781 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12782
12783 if (! peer)
12784 return CMD_WARNING;
12785
12786 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12787}
12788
12789DEFUN (show_bgp_view_neighbor_received_routes,
12790 show_bgp_view_neighbor_received_routes_cmd,
12791 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12792 SHOW_STR
12793 BGP_STR
12794 "BGP view\n"
12795 "View name\n"
12796 "Detailed information on TCP and BGP neighbor connections\n"
12797 "Neighbor to display information about\n"
12798 "Neighbor to display information about\n"
12799 "Display the received routes from neighbor\n")
12800{
12801 struct peer *peer;
12802
12803 if (argc == 2)
12804 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12805 else
12806 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12807
12808 if (! peer)
12809 return CMD_WARNING;
12810
12811 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12812}
12813
12814ALIAS (show_bgp_view_neighbor_advertised_route,
12815 show_bgp_neighbor_advertised_route_cmd,
12816 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12817 SHOW_STR
12818 BGP_STR
12819 "Detailed information on TCP and BGP neighbor connections\n"
12820 "Neighbor to display information about\n"
12821 "Neighbor to display information about\n"
12822 "Display the routes advertised to a BGP neighbor\n")
12823
12824ALIAS (show_bgp_view_neighbor_advertised_route,
12825 show_bgp_ipv6_neighbor_advertised_route_cmd,
12826 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12827 SHOW_STR
12828 BGP_STR
12829 "Address family\n"
12830 "Detailed information on TCP and BGP neighbor connections\n"
12831 "Neighbor to display information about\n"
12832 "Neighbor to display information about\n"
12833 "Display the routes advertised to a BGP neighbor\n")
12834
12835/* old command */
12836ALIAS (show_bgp_view_neighbor_advertised_route,
12837 ipv6_bgp_neighbor_advertised_route_cmd,
12838 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12839 SHOW_STR
12840 IPV6_STR
12841 BGP_STR
12842 "Detailed information on TCP and BGP neighbor connections\n"
12843 "Neighbor to display information about\n"
12844 "Neighbor to display information about\n"
12845 "Display the routes advertised to a BGP neighbor\n")
12846
12847/* old command */
12848DEFUN (ipv6_mbgp_neighbor_advertised_route,
12849 ipv6_mbgp_neighbor_advertised_route_cmd,
12850 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12851 SHOW_STR
12852 IPV6_STR
12853 MBGP_STR
12854 "Detailed information on TCP and BGP neighbor connections\n"
12855 "Neighbor to display information about\n"
12856 "Neighbor to display information about\n"
12857 "Display the routes advertised to a BGP neighbor\n")
12858{
12859 struct peer *peer;
12860
12861 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12862 if (! peer)
12863 return CMD_WARNING;
12864
12865 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12866}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012867
12868DEFUN (show_ip_bgp_view_neighbor_received_routes,
12869 show_ip_bgp_view_neighbor_received_routes_cmd,
12870 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12871 SHOW_STR
12872 IP_STR
12873 BGP_STR
12874 "BGP view\n"
12875 "View name\n"
12876 "Detailed information on TCP and BGP neighbor connections\n"
12877 "Neighbor to display information about\n"
12878 "Neighbor to display information about\n"
12879 "Display the received routes from neighbor\n")
12880{
12881 struct peer *peer;
12882
12883 if (argc == 2)
12884 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12885 else
12886 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12887
12888 if (! peer)
12889 return CMD_WARNING;
12890
12891 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12892}
12893
12894ALIAS (show_ip_bgp_view_neighbor_received_routes,
12895 show_ip_bgp_neighbor_received_routes_cmd,
12896 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12897 SHOW_STR
12898 IP_STR
12899 BGP_STR
12900 "Detailed information on TCP and BGP neighbor connections\n"
12901 "Neighbor to display information about\n"
12902 "Neighbor to display information about\n"
12903 "Display the received routes from neighbor\n")
12904
12905ALIAS (show_bgp_view_neighbor_received_routes,
12906 show_bgp_ipv6_neighbor_received_routes_cmd,
12907 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12908 SHOW_STR
12909 BGP_STR
12910 "Address family\n"
12911 "Detailed information on TCP and BGP neighbor connections\n"
12912 "Neighbor to display information about\n"
12913 "Neighbor to display information about\n"
12914 "Display the received routes from neighbor\n")
12915
12916DEFUN (show_bgp_neighbor_received_prefix_filter,
12917 show_bgp_neighbor_received_prefix_filter_cmd,
12918 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12919 SHOW_STR
12920 BGP_STR
12921 "Detailed information on TCP and BGP neighbor connections\n"
12922 "Neighbor to display information about\n"
12923 "Neighbor to display information about\n"
12924 "Display information received from a BGP neighbor\n"
12925 "Display the prefixlist filter\n")
12926{
12927 char name[BUFSIZ];
12928 union sockunion su;
12929 struct peer *peer;
12930 int count, ret;
12931
12932 ret = str2sockunion (argv[0], &su);
12933 if (ret < 0)
12934 {
12935 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12936 return CMD_WARNING;
12937 }
12938
12939 peer = peer_lookup (NULL, &su);
12940 if (! peer)
12941 return CMD_WARNING;
12942
12943 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12944 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12945 if (count)
12946 {
12947 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12948 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12949 }
12950
12951 return CMD_SUCCESS;
12952}
12953
12954/* old command */
12955ALIAS (show_bgp_view_neighbor_received_routes,
12956 ipv6_bgp_neighbor_received_routes_cmd,
12957 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12958 SHOW_STR
12959 IPV6_STR
12960 BGP_STR
12961 "Detailed information on TCP and BGP neighbor connections\n"
12962 "Neighbor to display information about\n"
12963 "Neighbor to display information about\n"
12964 "Display the received routes from neighbor\n")
12965
12966/* old command */
12967DEFUN (ipv6_mbgp_neighbor_received_routes,
12968 ipv6_mbgp_neighbor_received_routes_cmd,
12969 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12970 SHOW_STR
12971 IPV6_STR
12972 MBGP_STR
12973 "Detailed information on TCP and BGP neighbor connections\n"
12974 "Neighbor to display information about\n"
12975 "Neighbor to display information about\n"
12976 "Display the received routes from neighbor\n")
12977{
12978 struct peer *peer;
12979
12980 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12981 if (! peer)
12982 return CMD_WARNING;
12983
12984 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12985}
12986
12987DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12988 show_bgp_view_neighbor_received_prefix_filter_cmd,
12989 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12990 SHOW_STR
12991 BGP_STR
12992 "BGP view\n"
12993 "View name\n"
12994 "Detailed information on TCP and BGP neighbor connections\n"
12995 "Neighbor to display information about\n"
12996 "Neighbor to display information about\n"
12997 "Display information received from a BGP neighbor\n"
12998 "Display the prefixlist filter\n")
12999{
13000 char name[BUFSIZ];
13001 union sockunion su;
13002 struct peer *peer;
13003 struct bgp *bgp;
13004 int count, ret;
13005
13006 /* BGP structure lookup. */
13007 bgp = bgp_lookup_by_name (argv[0]);
13008 if (bgp == NULL)
13009 {
13010 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13011 return CMD_WARNING;
13012 }
13013
13014 ret = str2sockunion (argv[1], &su);
13015 if (ret < 0)
13016 {
13017 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13018 return CMD_WARNING;
13019 }
13020
13021 peer = peer_lookup (bgp, &su);
13022 if (! peer)
13023 return CMD_WARNING;
13024
13025 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13026 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13027 if (count)
13028 {
13029 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13030 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13031 }
13032
13033 return CMD_SUCCESS;
13034}
13035
13036
13037DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
13038 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
13039 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
13040 SHOW_STR
13041 IP_STR
13042 BGP_STR
13043 "Address family\n"
13044 "Address Family modifier\n"
13045 "Address Family modifier\n"
13046 "Detailed information on TCP and BGP neighbor connections\n"
13047 "Neighbor to display information about\n"
13048 "Neighbor to display information about\n"
13049 "Display the received routes from neighbor\n")
13050{
13051 struct peer *peer;
13052
13053 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13054 if (! peer)
13055 return CMD_WARNING;
13056
13057 if (strncmp (argv[0], "m", 1) == 0)
13058 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
13059
13060 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
13061}
13062
Lou Berger651b4022016-01-12 13:42:07 -050013063DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
13064 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
13065 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013066 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013067 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013068 "Address Family modifier\n"
13069 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013070 "Detailed information on TCP and BGP neighbor connections\n"
13071 "Neighbor to display information about\n"
13072 "Neighbor to display information about\n"
13073 "Display the routes advertised to a BGP neighbor\n")
13074{
13075 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013076 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013077
Lou Berger651b4022016-01-12 13:42:07 -050013078 if (bgp_parse_safi(argv[0], &safi)) {
13079 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013080 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013081 }
paul718e3742002-12-13 20:15:29 +000013082
paulbb46e942003-10-24 19:02:03 +000013083 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13084 if (! peer)
13085 return CMD_WARNING;
13086
Lou Berger651b4022016-01-12 13:42:07 -050013087 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
13088}
Lou Berger205e6742016-01-12 13:42:11 -050013089
Lou Berger651b4022016-01-12 13:42:07 -050013090DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
13091 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
13092 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13093 SHOW_STR
13094 BGP_STR
13095 "Address Family modifier\n"
13096 "Address Family modifier\n"
13097 "Address Family modifier\n"
13098 "Detailed information on TCP and BGP neighbor connections\n"
13099 "Neighbor to display information about\n"
13100 "Neighbor to display information about\n"
13101 "Display the routes advertised to a BGP neighbor\n")
13102{
13103 struct peer *peer;
13104 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013105
Lou Berger651b4022016-01-12 13:42:07 -050013106 if (bgp_parse_safi(argv[0], &safi)) {
13107 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13108 return CMD_WARNING;
13109 }
13110
13111 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13112 if (! peer)
13113 return CMD_WARNING;
13114
13115 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000013116}
13117
Lou Bergerf9b6c392016-01-12 13:42:09 -050013118DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050013119 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
13120 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000013121 SHOW_STR
13122 BGP_STR
13123 "BGP view\n"
13124 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013125 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013126 "Detailed information on TCP and BGP neighbor connections\n"
13127 "Neighbor to display information about\n"
13128 "Neighbor to display information about\n"
13129 "Display the routes advertised to a BGP neighbor\n")
13130{
13131 struct peer *peer;
13132
13133 if (argc == 2)
13134 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13135 else
13136 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13137
13138 if (! peer)
13139 return CMD_WARNING;
13140
13141 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
13142}
13143
Lou Bergerf9b6c392016-01-12 13:42:09 -050013144DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013145 show_bgp_view_ipv6_neighbor_received_routes_cmd,
13146 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000013147 SHOW_STR
13148 BGP_STR
13149 "BGP view\n"
13150 "View name\n"
13151 "Address family\n"
13152 "Detailed information on TCP and BGP neighbor connections\n"
13153 "Neighbor to display information about\n"
13154 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000013155 "Display the received routes from neighbor\n")
13156{
13157 struct peer *peer;
13158
13159 if (argc == 2)
13160 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13161 else
13162 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13163
13164 if (! peer)
13165 return CMD_WARNING;
13166
13167 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
13168}
Lou Berger651b4022016-01-12 13:42:07 -050013169
13170DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
13171 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
13172 "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 +010013173 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013174 BGP_STR
13175 "Address family\n"
13176 "Address Family modifier\n"
13177 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050013178 "Address Family modifier\n"
13179 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013180 "Detailed information on TCP and BGP neighbor connections\n"
13181 "Neighbor to display information about\n"
13182 "Neighbor to display information about\n"
13183 "Display the received routes from neighbor\n")
13184{
paulbb46e942003-10-24 19:02:03 +000013185 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013186 safi_t safi;
13187
13188 if (bgp_parse_safi(argv[0], &safi)) {
13189 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13190 return CMD_WARNING;
13191 }
paul718e3742002-12-13 20:15:29 +000013192
paulbb46e942003-10-24 19:02:03 +000013193 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13194 if (! peer)
13195 return CMD_WARNING;
13196
Lou Berger651b4022016-01-12 13:42:07 -050013197 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000013198}
Lou Berger205e6742016-01-12 13:42:11 -050013199
Lou Berger651b4022016-01-12 13:42:07 -050013200DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
13201 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
13202 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
13203 SHOW_STR
13204 BGP_STR
13205 "Address family\n"
13206 "Address Family modifier\n"
13207 "Address Family modifier\n"
13208 "Address Family modifier\n"
13209 "Address Family modifier\n"
13210 "Detailed information on TCP and BGP neighbor connections\n"
13211 "Neighbor to display information about\n"
13212 "Neighbor to display information about\n"
13213 "Display the received routes from neighbor\n")
13214{
13215 struct peer *peer;
13216 safi_t safi;
13217
13218 if (bgp_parse_safi(argv[0], &safi)) {
13219 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13220 return CMD_WARNING;
13221 }
13222
13223 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13224 if (! peer)
13225 return CMD_WARNING;
13226
13227 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
13228}
paul718e3742002-12-13 20:15:29 +000013229
Michael Lambert95cbbd22010-07-23 14:43:04 -040013230DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
13231 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040013232 "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 -040013233 SHOW_STR
13234 BGP_STR
13235 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013236 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013237 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013238 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013239 "Address family modifier\n"
13240 "Address family modifier\n"
13241 "Detailed information on TCP and BGP neighbor connections\n"
13242 "Neighbor to display information about\n"
13243 "Neighbor to display information about\n"
13244 "Display the advertised routes to neighbor\n"
13245 "Display the received routes from neighbor\n")
13246{
13247 int afi;
13248 int safi;
13249 int in;
13250 struct peer *peer;
13251
David Lamparter94bad672015-03-03 08:52:22 +010013252 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040013253
13254 if (! peer)
13255 return CMD_WARNING;
13256
Michael Lambert95cbbd22010-07-23 14:43:04 -040013257 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
13258 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13259 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040013260
13261 return peer_adj_routes (vty, peer, afi, safi, in);
13262}
13263
Lou Bergerf9b6c392016-01-12 13:42:09 -050013264DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
13265 show_ip_bgp_neighbor_received_prefix_filter_cmd,
13266 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13267 SHOW_STR
13268 IP_STR
13269 BGP_STR
13270 "Detailed information on TCP and BGP neighbor connections\n"
13271 "Neighbor to display information about\n"
13272 "Neighbor to display information about\n"
13273 "Display information received from a BGP neighbor\n"
13274 "Display the prefixlist filter\n")
13275{
13276 char name[BUFSIZ];
13277 union sockunion su;
13278 struct peer *peer;
13279 int count, ret;
13280
13281 ret = str2sockunion (argv[0], &su);
13282 if (ret < 0)
13283 {
13284 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13285 return CMD_WARNING;
13286 }
13287
13288 peer = peer_lookup (NULL, &su);
13289 if (! peer)
13290 return CMD_WARNING;
13291
13292 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13293 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13294 if (count)
13295 {
13296 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13297 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13298 }
13299
13300 return CMD_SUCCESS;
13301}
13302
13303DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
13304 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
13305 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13306 SHOW_STR
13307 IP_STR
13308 BGP_STR
13309 "Address family\n"
13310 "Address Family modifier\n"
13311 "Address Family modifier\n"
13312 "Detailed information on TCP and BGP neighbor connections\n"
13313 "Neighbor to display information about\n"
13314 "Neighbor to display information about\n"
13315 "Display information received from a BGP neighbor\n"
13316 "Display the prefixlist filter\n")
13317{
13318 char name[BUFSIZ];
13319 union sockunion su;
13320 struct peer *peer;
13321 int count, ret;
13322
13323 ret = str2sockunion (argv[1], &su);
13324 if (ret < 0)
13325 {
13326 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13327 return CMD_WARNING;
13328 }
13329
13330 peer = peer_lookup (NULL, &su);
13331 if (! peer)
13332 return CMD_WARNING;
13333
13334 if (strncmp (argv[0], "m", 1) == 0)
13335 {
13336 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
13337 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13338 if (count)
13339 {
13340 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
13341 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13342 }
13343 }
13344 else
13345 {
13346 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13347 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13348 if (count)
13349 {
13350 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13351 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13352 }
13353 }
13354
13355 return CMD_SUCCESS;
13356}
13357
13358ALIAS (show_bgp_view_neighbor_received_routes,
13359 show_bgp_neighbor_received_routes_cmd,
13360 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13361 SHOW_STR
13362 BGP_STR
13363 "Detailed information on TCP and BGP neighbor connections\n"
13364 "Neighbor to display information about\n"
13365 "Neighbor to display information about\n"
13366 "Display the received routes from neighbor\n")
13367
Lou Berger651b4022016-01-12 13:42:07 -050013368DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13369 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13370 "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 +000013371 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013372 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013373 IP_STR
13374 "Address Family modifier\n"
13375 "Address Family modifier\n"
13376 "Address Family modifier\n"
13377 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013378 "Detailed information on TCP and BGP neighbor connections\n"
13379 "Neighbor to display information about\n"
13380 "Neighbor to display information about\n"
13381 "Display information received from a BGP neighbor\n"
13382 "Display the prefixlist filter\n")
13383{
13384 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013385 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013386 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013387 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013388 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013389
Lou Berger651b4022016-01-12 13:42:07 -050013390 if (bgp_parse_safi(argv[0], &safi)) {
13391 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013392 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013393 }
paul718e3742002-12-13 20:15:29 +000013394
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013395 ret = str2sockunion (argv[1], &su);
13396 if (ret < 0)
13397 {
13398 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13399 return CMD_WARNING;
13400 }
paul718e3742002-12-13 20:15:29 +000013401
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013402 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013403 if (! peer)
13404 return CMD_WARNING;
13405
Lou Berger651b4022016-01-12 13:42:07 -050013406 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13407 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13408 if (count) {
13409 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13410 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13411 }
paul718e3742002-12-13 20:15:29 +000013412
13413 return CMD_SUCCESS;
13414}
Lou Berger205e6742016-01-12 13:42:11 -050013415
Lou Berger651b4022016-01-12 13:42:07 -050013416DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13417 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13418 "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 +000013419 SHOW_STR
13420 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013421 IP_STR
13422 "Address Family modifier\n"
13423 "Address Family modifier\n"
13424 "Address Family modifier\n"
13425 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013426 "Detailed information on TCP and BGP neighbor connections\n"
13427 "Neighbor to display information about\n"
13428 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013429 "Display information received from a BGP neighbor\n"
13430 "Display the prefixlist filter\n")
13431{
13432 char name[BUFSIZ];
13433 union sockunion su;
13434 struct peer *peer;
13435 int count, ret;
13436 safi_t safi;
13437
13438 if (bgp_parse_safi(argv[0], &safi)) {
13439 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13440 return CMD_WARNING;
13441 }
13442
13443 ret = str2sockunion (argv[1], &su);
13444 if (ret < 0)
13445 {
13446 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13447 return CMD_WARNING;
13448 }
13449
13450 peer = peer_lookup (NULL, &su);
13451 if (! peer)
13452 return CMD_WARNING;
13453
13454 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13455 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13456 if (count) {
13457 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13458 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13459 }
13460
13461 return CMD_SUCCESS;
13462}
paul718e3742002-12-13 20:15:29 +000013463
Lou Bergerf9b6c392016-01-12 13:42:09 -050013464DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013465 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13466 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013467 SHOW_STR
13468 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013469 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013470 "Detailed information on TCP and BGP neighbor connections\n"
13471 "Neighbor to display information about\n"
13472 "Neighbor to display information about\n"
13473 "Display information received from a BGP neighbor\n"
13474 "Display the prefixlist filter\n")
13475{
13476 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013477 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013478 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013479 int count, ret;
paul718e3742002-12-13 20:15:29 +000013480
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013481 ret = str2sockunion (argv[0], &su);
13482 if (ret < 0)
13483 {
13484 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13485 return CMD_WARNING;
13486 }
paul718e3742002-12-13 20:15:29 +000013487
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013488 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013489 if (! peer)
13490 return CMD_WARNING;
13491
13492 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13493 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13494 if (count)
13495 {
13496 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13497 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13498 }
13499
13500 return CMD_SUCCESS;
13501}
13502
Lou Bergerf9b6c392016-01-12 13:42:09 -050013503DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013504 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13505 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013506 SHOW_STR
13507 BGP_STR
13508 "BGP view\n"
13509 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013510 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013511 "Detailed information on TCP and BGP neighbor connections\n"
13512 "Neighbor to display information about\n"
13513 "Neighbor to display information about\n"
13514 "Display information received from a BGP neighbor\n"
13515 "Display the prefixlist filter\n")
13516{
13517 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013518 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013519 struct peer *peer;
13520 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013521 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013522
13523 /* BGP structure lookup. */
13524 bgp = bgp_lookup_by_name (argv[0]);
13525 if (bgp == NULL)
13526 {
13527 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13528 return CMD_WARNING;
13529 }
13530
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013531 ret = str2sockunion (argv[1], &su);
13532 if (ret < 0)
13533 {
13534 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13535 return CMD_WARNING;
13536 }
paulbb46e942003-10-24 19:02:03 +000013537
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013538 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013539 if (! peer)
13540 return CMD_WARNING;
13541
13542 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13543 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13544 if (count)
13545 {
13546 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13547 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13548 }
13549
13550 return CMD_SUCCESS;
13551}
David Lamparter6b0655a2014-06-04 06:53:35 +020013552
paul94f2b392005-06-28 12:44:16 +000013553static int
paulbb46e942003-10-24 19:02:03 +000013554bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013555 safi_t safi, enum bgp_show_type type)
13556{
paul718e3742002-12-13 20:15:29 +000013557 if (! peer || ! peer->afc[afi][safi])
13558 {
13559 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013560 return CMD_WARNING;
13561 }
13562
ajs5a646652004-11-05 01:25:55 +000013563 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013564}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013565DEFUN (show_ip_bgp_neighbor_routes,
13566 show_ip_bgp_neighbor_routes_cmd,
13567 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13568 SHOW_STR
13569 IP_STR
13570 BGP_STR
13571 "Detailed information on TCP and BGP neighbor connections\n"
13572 "Neighbor to display information about\n"
13573 "Neighbor to display information about\n"
13574 "Display routes learned from neighbor\n")
13575{
13576 struct peer *peer;
13577
13578 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13579 if (! peer)
13580 return CMD_WARNING;
13581
13582 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13583 bgp_show_type_neighbor);
13584}
13585
13586DEFUN (show_ip_bgp_neighbor_flap,
13587 show_ip_bgp_neighbor_flap_cmd,
13588 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13589 SHOW_STR
13590 IP_STR
13591 BGP_STR
13592 "Detailed information on TCP and BGP neighbor connections\n"
13593 "Neighbor to display information about\n"
13594 "Neighbor to display information about\n"
13595 "Display flap statistics of the routes learned from neighbor\n")
13596{
13597 struct peer *peer;
13598
13599 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13600 if (! peer)
13601 return CMD_WARNING;
13602
13603 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13604 bgp_show_type_flap_neighbor);
13605}
13606
13607DEFUN (show_ip_bgp_neighbor_damp,
13608 show_ip_bgp_neighbor_damp_cmd,
13609 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13610 SHOW_STR
13611 IP_STR
13612 BGP_STR
13613 "Detailed information on TCP and BGP neighbor connections\n"
13614 "Neighbor to display information about\n"
13615 "Neighbor to display information about\n"
13616 "Display the dampened routes received from neighbor\n")
13617{
13618 struct peer *peer;
13619
13620 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13621 if (! peer)
13622 return CMD_WARNING;
13623
13624 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13625 bgp_show_type_damp_neighbor);
13626}
13627
13628DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13629 show_ip_bgp_ipv4_neighbor_routes_cmd,
13630 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13631 SHOW_STR
13632 IP_STR
13633 BGP_STR
13634 "Address family\n"
13635 "Address Family modifier\n"
13636 "Address Family modifier\n"
13637 "Detailed information on TCP and BGP neighbor connections\n"
13638 "Neighbor to display information about\n"
13639 "Neighbor to display information about\n"
13640 "Display routes learned from neighbor\n")
13641{
13642 struct peer *peer;
13643
13644 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13645 if (! peer)
13646 return CMD_WARNING;
13647
13648 if (strncmp (argv[0], "m", 1) == 0)
13649 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13650 bgp_show_type_neighbor);
13651
13652 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13653 bgp_show_type_neighbor);
13654}
13655
13656DEFUN (show_ip_bgp_view_rsclient,
13657 show_ip_bgp_view_rsclient_cmd,
13658 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13659 SHOW_STR
13660 IP_STR
13661 BGP_STR
13662 "BGP view\n"
13663 "View name\n"
13664 "Information about Route Server Client\n"
13665 NEIGHBOR_ADDR_STR)
13666{
13667 struct bgp_table *table;
13668 struct peer *peer;
13669
13670 if (argc == 2)
13671 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13672 else
13673 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13674
13675 if (! peer)
13676 return CMD_WARNING;
13677
13678 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13679 {
13680 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13681 VTY_NEWLINE);
13682 return CMD_WARNING;
13683 }
13684
13685 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13686 PEER_FLAG_RSERVER_CLIENT))
13687 {
13688 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13689 VTY_NEWLINE);
13690 return CMD_WARNING;
13691 }
13692
13693 table = peer->rib[AFI_IP][SAFI_UNICAST];
13694
13695 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13696}
13697
13698ALIAS (show_ip_bgp_view_rsclient,
13699 show_ip_bgp_rsclient_cmd,
13700 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13701 SHOW_STR
13702 IP_STR
13703 BGP_STR
13704 "Information about Route Server Client\n"
13705 NEIGHBOR_ADDR_STR)
13706
13707DEFUN (show_bgp_view_ipv4_safi_rsclient,
13708 show_bgp_view_ipv4_safi_rsclient_cmd,
13709 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13710 SHOW_STR
13711 BGP_STR
13712 "BGP view\n"
13713 "View name\n"
13714 "Address family\n"
13715 "Address Family modifier\n"
13716 "Address Family modifier\n"
13717 "Information about Route Server Client\n"
13718 NEIGHBOR_ADDR_STR)
13719{
13720 struct bgp_table *table;
13721 struct peer *peer;
13722 safi_t safi;
13723
13724 if (argc == 3) {
13725 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13726 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13727 } else {
13728 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13729 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13730 }
13731
13732 if (! peer)
13733 return CMD_WARNING;
13734
13735 if (! peer->afc[AFI_IP][safi])
13736 {
13737 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13738 VTY_NEWLINE);
13739 return CMD_WARNING;
13740 }
13741
13742 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13743 PEER_FLAG_RSERVER_CLIENT))
13744 {
13745 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13746 VTY_NEWLINE);
13747 return CMD_WARNING;
13748 }
13749
13750 table = peer->rib[AFI_IP][safi];
13751
13752 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13753}
13754
13755ALIAS (show_bgp_view_ipv4_safi_rsclient,
13756 show_bgp_ipv4_safi_rsclient_cmd,
13757 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13758 SHOW_STR
13759 BGP_STR
13760 "Address family\n"
13761 "Address Family modifier\n"
13762 "Address Family modifier\n"
13763 "Information about Route Server Client\n"
13764 NEIGHBOR_ADDR_STR)
13765
13766DEFUN (show_ip_bgp_view_rsclient_route,
13767 show_ip_bgp_view_rsclient_route_cmd,
13768 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13769 SHOW_STR
13770 IP_STR
13771 BGP_STR
13772 "BGP view\n"
13773 "View name\n"
13774 "Information about Route Server Client\n"
13775 NEIGHBOR_ADDR_STR
13776 "Network in the BGP routing table to display\n")
13777{
13778 struct bgp *bgp;
13779 struct peer *peer;
13780
13781 /* BGP structure lookup. */
13782 if (argc == 3)
13783 {
13784 bgp = bgp_lookup_by_name (argv[0]);
13785 if (bgp == NULL)
13786 {
13787 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13788 return CMD_WARNING;
13789 }
13790 }
13791 else
13792 {
13793 bgp = bgp_get_default ();
13794 if (bgp == NULL)
13795 {
13796 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13797 return CMD_WARNING;
13798 }
13799 }
13800
13801 if (argc == 3)
13802 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13803 else
13804 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13805
13806 if (! peer)
13807 return CMD_WARNING;
13808
13809 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13810 {
13811 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13812 VTY_NEWLINE);
13813 return CMD_WARNING;
13814}
13815
13816 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13817 PEER_FLAG_RSERVER_CLIENT))
13818 {
13819 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13820 VTY_NEWLINE);
13821 return CMD_WARNING;
13822 }
13823
13824 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13825 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070013826 AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050013827}
13828
13829ALIAS (show_ip_bgp_view_rsclient_route,
13830 show_ip_bgp_rsclient_route_cmd,
13831 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13832 SHOW_STR
13833 IP_STR
13834 BGP_STR
13835 "Information about Route Server Client\n"
13836 NEIGHBOR_ADDR_STR
13837 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013838
Lou Berger651b4022016-01-12 13:42:07 -050013839DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13840 show_bgp_ipv4_safi_neighbor_flap_cmd,
13841 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013842 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013843 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013844 "Address Family Modifier\n"
13845 "Address Family Modifier\n"
13846 "Address Family Modifier\n"
13847 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013848 "Detailed information on TCP and BGP neighbor connections\n"
13849 "Neighbor to display information about\n"
13850 "Neighbor to display information about\n"
13851 "Display flap statistics of the routes learned from neighbor\n")
13852{
paulbb46e942003-10-24 19:02:03 +000013853 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013854 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013855
Lou Berger651b4022016-01-12 13:42:07 -050013856 if (bgp_parse_safi(argv[0], &safi)) {
13857 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13858 return CMD_WARNING;
13859 }
13860
13861 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013862 if (! peer)
13863 return CMD_WARNING;
13864
Lou Berger651b4022016-01-12 13:42:07 -050013865 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013866 bgp_show_type_flap_neighbor);
13867}
Lou Berger205e6742016-01-12 13:42:11 -050013868
Lou Berger651b4022016-01-12 13:42:07 -050013869DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13870 show_bgp_ipv6_safi_neighbor_flap_cmd,
13871 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013872 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013873 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013874 "Address Family Modifier\n"
13875 "Address Family Modifier\n"
13876 "Address Family Modifier\n"
13877 "Address Family Modifier\n"
13878 "Detailed information on TCP and BGP neighbor connections\n"
13879 "Neighbor to display information about\n"
13880 "Neighbor to display information about\n"
13881 "Display flap statistics of the routes learned from neighbor\n")
13882{
13883 struct peer *peer;
13884 safi_t safi;
13885
13886 if (bgp_parse_safi(argv[0], &safi)) {
13887 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13888 return CMD_WARNING;
13889 }
13890
13891 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13892 if (! peer)
13893 return CMD_WARNING;
13894
13895 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13896 bgp_show_type_flap_neighbor);
13897}
Lou Berger651b4022016-01-12 13:42:07 -050013898
13899DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13900 show_bgp_ipv4_safi_neighbor_damp_cmd,
13901 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13902 SHOW_STR
13903 BGP_STR
13904 "Address Family Modifier\n"
13905 "Address Family Modifier\n"
13906 "Address Family Modifier\n"
13907 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013908 "Detailed information on TCP and BGP neighbor connections\n"
13909 "Neighbor to display information about\n"
13910 "Neighbor to display information about\n"
13911 "Display the dampened routes received from neighbor\n")
13912{
paulbb46e942003-10-24 19:02:03 +000013913 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013914 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013915
Lou Berger651b4022016-01-12 13:42:07 -050013916 if (bgp_parse_safi(argv[0], &safi)) {
13917 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13918 return CMD_WARNING;
13919 }
13920
13921 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013922 if (! peer)
13923 return CMD_WARNING;
13924
Lou Berger651b4022016-01-12 13:42:07 -050013925 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013926 bgp_show_type_damp_neighbor);
13927}
Lou Berger205e6742016-01-12 13:42:11 -050013928
Lou Berger651b4022016-01-12 13:42:07 -050013929DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13930 show_bgp_ipv6_safi_neighbor_damp_cmd,
13931 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013932 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013933 BGP_STR
13934 "Address Family Modifier\n"
13935 "Address Family Modifier\n"
13936 "Address Family Modifier\n"
13937 "Address Family Modifier\n"
13938 "Detailed information on TCP and BGP neighbor connections\n"
13939 "Neighbor to display information about\n"
13940 "Neighbor to display information about\n"
13941 "Display the dampened routes received from neighbor\n")
13942{
13943 struct peer *peer;
13944 safi_t safi;
13945
13946 if (bgp_parse_safi(argv[0], &safi)) {
13947 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13948 return CMD_WARNING;
13949 }
13950
13951 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13952 if (! peer)
13953 return CMD_WARNING;
13954
13955 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13956 bgp_show_type_damp_neighbor);
13957}
Lou Berger651b4022016-01-12 13:42:07 -050013958
13959DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13960 show_bgp_ipv4_safi_neighbor_routes_cmd,
13961 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13962 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013963 BGP_STR
13964 "Address family\n"
13965 "Address Family modifier\n"
13966 "Address Family modifier\n"
13967 "Detailed information on TCP and BGP neighbor connections\n"
13968 "Neighbor to display information about\n"
13969 "Neighbor to display information about\n"
13970 "Display routes learned from neighbor\n")
13971{
paulbb46e942003-10-24 19:02:03 +000013972 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013973 safi_t safi;
13974
13975 if (bgp_parse_safi(argv[0], &safi)) {
13976 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13977 return CMD_WARNING;
13978 }
paulbb46e942003-10-24 19:02:03 +000013979
13980 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13981 if (! peer)
13982 return CMD_WARNING;
13983
Lou Berger651b4022016-01-12 13:42:07 -050013984 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013985 bgp_show_type_neighbor);
13986}
Lou Berger205e6742016-01-12 13:42:11 -050013987
Lou Berger651b4022016-01-12 13:42:07 -050013988DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13989 show_bgp_ipv6_safi_neighbor_routes_cmd,
13990 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013991 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013992 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013993 "Address family\n"
13994 "Address Family modifier\n"
13995 "Address Family modifier\n"
13996 "Detailed information on TCP and BGP neighbor connections\n"
13997 NEIGHBOR_ADDR_STR
13998 NEIGHBOR_ADDR_STR
13999 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014000{
paulfee0f4c2004-09-13 05:12:46 +000014001 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050014002 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000014003
Lou Berger651b4022016-01-12 13:42:07 -050014004 if (bgp_parse_safi(argv[0], &safi)) {
14005 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14006 return CMD_WARNING;
14007 }
paulfee0f4c2004-09-13 05:12:46 +000014008
Lou Berger651b4022016-01-12 13:42:07 -050014009 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000014010 if (! peer)
14011 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050014012
14013 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14014 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000014015}
paulfee0f4c2004-09-13 05:12:46 +000014016
Michael Lambert95cbbd22010-07-23 14:43:04 -040014017DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
14018 show_bgp_view_ipv4_safi_rsclient_route_cmd,
14019 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14020 SHOW_STR
14021 BGP_STR
14022 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014023 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014024 "Address family\n"
14025 "Address Family modifier\n"
14026 "Address Family modifier\n"
14027 "Information about Route Server Client\n"
14028 NEIGHBOR_ADDR_STR
14029 "Network in the BGP routing table to display\n")
14030{
14031 struct bgp *bgp;
14032 struct peer *peer;
14033 safi_t safi;
14034
14035 /* BGP structure lookup. */
14036 if (argc == 4)
14037 {
14038 bgp = bgp_lookup_by_name (argv[0]);
14039 if (bgp == NULL)
14040 {
14041 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14042 return CMD_WARNING;
14043 }
14044 }
14045 else
14046 {
14047 bgp = bgp_get_default ();
14048 if (bgp == NULL)
14049 {
14050 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14051 return CMD_WARNING;
14052 }
14053 }
14054
14055 if (argc == 4) {
14056 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14057 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14058 } else {
14059 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14060 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14061 }
14062
14063 if (! peer)
14064 return CMD_WARNING;
14065
14066 if (! peer->afc[AFI_IP][safi])
14067 {
14068 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14069 VTY_NEWLINE);
14070 return CMD_WARNING;
14071}
14072
14073 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14074 PEER_FLAG_RSERVER_CLIENT))
14075 {
14076 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14077 VTY_NEWLINE);
14078 return CMD_WARNING;
14079 }
14080
14081 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
14082 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014083 AFI_IP, safi, NULL, 0, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014084}
14085
14086ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
14087 show_bgp_ipv4_safi_rsclient_route_cmd,
14088 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14089 SHOW_STR
14090 BGP_STR
14091 "Address family\n"
14092 "Address Family modifier\n"
14093 "Address Family modifier\n"
14094 "Information about Route Server Client\n"
14095 NEIGHBOR_ADDR_STR
14096 "Network in the BGP routing table to display\n")
14097
paulfee0f4c2004-09-13 05:12:46 +000014098
Michael Lambert95cbbd22010-07-23 14:43:04 -040014099DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
14100 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
14101 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14102 SHOW_STR
14103 BGP_STR
14104 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014105 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014106 "Address family\n"
14107 "Address Family modifier\n"
14108 "Address Family modifier\n"
14109 "Information about Route Server Client\n"
14110 NEIGHBOR_ADDR_STR
14111 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14112{
14113 struct bgp *bgp;
14114 struct peer *peer;
14115 safi_t safi;
14116
14117 /* BGP structure lookup. */
14118 if (argc == 4)
14119 {
14120 bgp = bgp_lookup_by_name (argv[0]);
14121 if (bgp == NULL)
14122 {
14123 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14124 return CMD_WARNING;
14125 }
14126 }
14127 else
14128 {
14129 bgp = bgp_get_default ();
14130 if (bgp == NULL)
14131 {
14132 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14133 return CMD_WARNING;
14134 }
14135 }
14136
14137 if (argc == 4) {
14138 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14139 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14140 } else {
14141 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14142 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14143 }
14144
14145 if (! peer)
14146 return CMD_WARNING;
14147
14148 if (! peer->afc[AFI_IP][safi])
14149 {
14150 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14151 VTY_NEWLINE);
14152 return CMD_WARNING;
14153}
14154
14155 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14156 PEER_FLAG_RSERVER_CLIENT))
14157{
14158 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14159 VTY_NEWLINE);
14160 return CMD_WARNING;
14161 }
14162
14163 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
14164 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014165 AFI_IP, safi, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014166}
14167
Lou Bergerf9b6c392016-01-12 13:42:09 -050014168DEFUN (show_ip_bgp_view_rsclient_prefix,
14169 show_ip_bgp_view_rsclient_prefix_cmd,
14170 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14171 SHOW_STR
14172 IP_STR
14173 BGP_STR
14174 "BGP view\n"
14175 "View name\n"
14176 "Information about Route Server Client\n"
14177 NEIGHBOR_ADDR_STR
14178 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14179{
14180 struct bgp *bgp;
14181 struct peer *peer;
14182
14183 /* BGP structure lookup. */
14184 if (argc == 3)
14185 {
14186 bgp = bgp_lookup_by_name (argv[0]);
14187 if (bgp == NULL)
14188 {
14189 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14190 return CMD_WARNING;
14191 }
14192 }
14193 else
14194 {
14195 bgp = bgp_get_default ();
14196 if (bgp == NULL)
14197 {
14198 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14199 return CMD_WARNING;
14200 }
14201 }
14202
14203 if (argc == 3)
14204 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14205 else
14206 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14207
14208 if (! peer)
14209 return CMD_WARNING;
14210
14211 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14212 {
14213 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14214 VTY_NEWLINE);
14215 return CMD_WARNING;
14216}
14217
14218 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14219 PEER_FLAG_RSERVER_CLIENT))
14220{
14221 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14222 VTY_NEWLINE);
14223 return CMD_WARNING;
14224 }
14225
14226 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
14227 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014228 AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050014229}
14230
14231ALIAS (show_ip_bgp_view_rsclient_prefix,
14232 show_ip_bgp_rsclient_prefix_cmd,
14233 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14234 SHOW_STR
14235 IP_STR
14236 BGP_STR
14237 "Information about Route Server Client\n"
14238 NEIGHBOR_ADDR_STR
14239 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14240
Michael Lambert95cbbd22010-07-23 14:43:04 -040014241ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
14242 show_bgp_ipv4_safi_rsclient_prefix_cmd,
14243 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14244 SHOW_STR
14245 BGP_STR
14246 "Address family\n"
14247 "Address Family modifier\n"
14248 "Address Family modifier\n"
14249 "Information about Route Server Client\n"
14250 NEIGHBOR_ADDR_STR
14251 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000014252
Lou Bergerf9b6c392016-01-12 13:42:09 -050014253DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050014254 show_bgp_view_ipv6_neighbor_routes_cmd,
14255 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +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"
paulbb46e942003-10-24 19:02:03 +000014261 "Detailed information on TCP and BGP neighbor connections\n"
14262 "Neighbor to display information about\n"
14263 "Neighbor to display information about\n"
14264 "Display routes learned from neighbor\n")
14265{
14266 struct peer *peer;
14267
14268 if (argc == 2)
14269 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14270 else
14271 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14272
14273 if (! peer)
14274 return CMD_WARNING;
14275
14276 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14277 bgp_show_type_neighbor);
14278}
14279
Lou Berger651b4022016-01-12 13:42:07 -050014280DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014281 show_bgp_view_neighbor_damp_cmd,
14282 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14283 SHOW_STR
14284 BGP_STR
14285 "BGP view\n"
14286 "View name\n"
14287 "Detailed information on TCP and BGP neighbor connections\n"
14288 "Neighbor to display information about\n"
14289 "Neighbor to display information about\n"
14290 "Display the dampened routes received from neighbor\n")
14291{
14292 struct peer *peer;
14293
14294 if (argc == 2)
14295 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14296 else
14297 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14298
14299 if (! peer)
14300 return CMD_WARNING;
14301
14302 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14303 bgp_show_type_damp_neighbor);
14304}
14305
14306DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050014307 show_bgp_view_ipv6_neighbor_damp_cmd,
14308 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000014309 SHOW_STR
14310 BGP_STR
14311 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014312 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014313 "Address family\n"
14314 "Detailed information on TCP and BGP neighbor connections\n"
14315 "Neighbor to display information about\n"
14316 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000014317 "Display the dampened routes received from neighbor\n")
14318{
14319 struct peer *peer;
14320
14321 if (argc == 2)
14322 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14323 else
14324 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14325
14326 if (! peer)
14327 return CMD_WARNING;
14328
14329 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14330 bgp_show_type_damp_neighbor);
14331}
14332
Lou Bergerf9b6c392016-01-12 13:42:09 -050014333DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050014334 show_bgp_view_ipv6_neighbor_flap_cmd,
14335 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000014336 SHOW_STR
14337 BGP_STR
14338 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014339 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014340 "Address family\n"
14341 "Detailed information on TCP and BGP neighbor connections\n"
14342 "Neighbor to display information about\n"
14343 "Neighbor to display information about\n"
14344 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000014345{
14346 struct peer *peer;
14347
14348 if (argc == 2)
14349 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14350 else
14351 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14352
14353 if (! peer)
14354 return CMD_WARNING;
14355
14356 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14357 bgp_show_type_flap_neighbor);
14358}
14359
Lou Bergerf9b6c392016-01-12 13:42:09 -050014360DEFUN (show_bgp_view_neighbor_flap,
14361 show_bgp_view_neighbor_flap_cmd,
14362 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14363 SHOW_STR
14364 BGP_STR
14365 "BGP view\n"
14366 "View name\n"
14367 "Detailed information on TCP and BGP neighbor connections\n"
14368 "Neighbor to display information about\n"
14369 "Neighbor to display information about\n"
14370 "Display flap statistics of the routes learned from neighbor\n")
14371{
14372 struct peer *peer;
14373
14374 if (argc == 2)
14375 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14376 else
14377 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14378
14379 if (! peer)
14380 return CMD_WARNING;
14381
14382 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14383 bgp_show_type_flap_neighbor);
14384}
14385
14386ALIAS (show_bgp_view_neighbor_flap,
14387 show_bgp_neighbor_flap_cmd,
14388 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14389 SHOW_STR
14390 BGP_STR
14391 "Detailed information on TCP and BGP neighbor connections\n"
14392 "Neighbor to display information about\n"
14393 "Neighbor to display information about\n"
14394 "Display flap statistics of the routes learned from neighbor\n")
14395
14396ALIAS (show_bgp_view_neighbor_damp,
14397 show_bgp_neighbor_damp_cmd,
14398 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14399 SHOW_STR
14400 BGP_STR
14401 "Detailed information on TCP and BGP neighbor connections\n"
14402 "Neighbor to display information about\n"
14403 "Neighbor to display information about\n"
14404 "Display the dampened routes received from neighbor\n")
14405
14406DEFUN (show_bgp_view_neighbor_routes,
14407 show_bgp_view_neighbor_routes_cmd,
14408 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
14409 SHOW_STR
14410 BGP_STR
14411 "BGP view\n"
14412 "View name\n"
14413 "Detailed information on TCP and BGP neighbor connections\n"
14414 "Neighbor to display information about\n"
14415 "Neighbor to display information about\n"
14416 "Display routes learned from neighbor\n")
14417{
14418 struct peer *peer;
14419
14420 if (argc == 2)
14421 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14422 else
14423 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14424
14425 if (! peer)
14426 return CMD_WARNING;
14427
14428 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14429 bgp_show_type_neighbor);
14430}
14431
14432ALIAS (show_bgp_view_neighbor_routes,
14433 show_bgp_neighbor_routes_cmd,
14434 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
14435 SHOW_STR
14436 BGP_STR
14437 "Detailed information on TCP and BGP neighbor connections\n"
14438 "Neighbor to display information about\n"
14439 "Neighbor to display information about\n"
14440 "Display routes learned from neighbor\n")
14441
paulbb46e942003-10-24 19:02:03 +000014442ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014443 show_bgp_ipv6_neighbor_routes_cmd,
14444 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14445 SHOW_STR
14446 BGP_STR
14447 "Address family\n"
14448 "Detailed information on TCP and BGP neighbor connections\n"
14449 "Neighbor to display information about\n"
14450 "Neighbor to display information about\n"
14451 "Display routes learned from neighbor\n")
14452
Lou Bergerf9b6c392016-01-12 13:42:09 -050014453/* old command */
14454ALIAS (show_bgp_view_neighbor_routes,
14455 ipv6_bgp_neighbor_routes_cmd,
14456 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14457 SHOW_STR
14458 IPV6_STR
14459 BGP_STR
14460 "Detailed information on TCP and BGP neighbor connections\n"
14461 "Neighbor to display information about\n"
14462 "Neighbor to display information about\n"
14463 "Display routes learned from neighbor\n")
14464
14465/* old command */
14466DEFUN (ipv6_mbgp_neighbor_routes,
14467 ipv6_mbgp_neighbor_routes_cmd,
14468 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14469 SHOW_STR
14470 IPV6_STR
14471 MBGP_STR
14472 "Detailed information on TCP and BGP neighbor connections\n"
14473 "Neighbor to display information about\n"
14474 "Neighbor to display information about\n"
14475 "Display routes learned from neighbor\n")
14476{
14477 struct peer *peer;
14478
14479 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14480 if (! peer)
14481 return CMD_WARNING;
14482
14483 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14484 bgp_show_type_neighbor);
14485}
14486
paulbb46e942003-10-24 19:02:03 +000014487ALIAS (show_bgp_view_neighbor_flap,
14488 show_bgp_ipv6_neighbor_flap_cmd,
14489 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14490 SHOW_STR
14491 BGP_STR
14492 "Address family\n"
14493 "Detailed information on TCP and BGP neighbor connections\n"
14494 "Neighbor to display information about\n"
14495 "Neighbor to display information about\n"
14496 "Display flap statistics of the routes learned from neighbor\n")
14497
14498ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014499 show_bgp_ipv6_neighbor_damp_cmd,
14500 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14501 SHOW_STR
14502 BGP_STR
14503 "Address family\n"
14504 "Detailed information on TCP and BGP neighbor connections\n"
14505 "Neighbor to display information about\n"
14506 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014507 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014508
Lou Bergerf9b6c392016-01-12 13:42:09 -050014509DEFUN (show_bgp_view_rsclient,
14510 show_bgp_view_rsclient_cmd,
14511 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14512 SHOW_STR
14513 BGP_STR
14514 "BGP view\n"
14515 "View name\n"
14516 "Information about Route Server Client\n"
14517 NEIGHBOR_ADDR_STR)
14518{
14519 struct bgp_table *table;
14520 struct peer *peer;
14521
14522 if (argc == 2)
14523 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14524 else
14525 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14526
14527 if (! peer)
14528 return CMD_WARNING;
14529
14530 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14531 {
14532 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14533 VTY_NEWLINE);
14534 return CMD_WARNING;
14535 }
14536
14537 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14538 PEER_FLAG_RSERVER_CLIENT))
14539 {
14540 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14541 VTY_NEWLINE);
14542 return CMD_WARNING;
14543 }
14544
14545 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14546
14547 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14548}
14549
14550ALIAS (show_bgp_view_rsclient,
14551 show_bgp_rsclient_cmd,
14552 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14553 SHOW_STR
14554 BGP_STR
14555 "Information about Route Server Client\n"
14556 NEIGHBOR_ADDR_STR)
14557
Lou Berger651b4022016-01-12 13:42:07 -050014558DEFUN (show_bgp_view_ipv4_rsclient,
14559 show_bgp_view_ipv4_rsclient_cmd,
14560 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014561 SHOW_STR
14562 BGP_STR
14563 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014564 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014565 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014566 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014567 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014568{
Lou Berger651b4022016-01-12 13:42:07 -050014569 struct bgp_table *table;
14570 struct peer *peer;
14571
14572 if (argc == 2)
14573 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14574 else
14575 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14576
14577 if (! peer)
14578 return CMD_WARNING;
14579
14580 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14581 {
14582 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14583 VTY_NEWLINE);
14584 return CMD_WARNING;
14585 }
14586
14587 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14588 PEER_FLAG_RSERVER_CLIENT))
14589 {
14590 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14591 VTY_NEWLINE);
14592 return CMD_WARNING;
14593 }
14594
14595 table = peer->rib[AFI_IP][SAFI_UNICAST];
14596
14597 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14598}
14599DEFUN (show_bgp_view_ipv6_rsclient,
14600 show_bgp_view_ipv6_rsclient_cmd,
14601 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14602 SHOW_STR
14603 BGP_STR
14604 "BGP view\n"
14605 "BGP view name\n"
14606 "Address Family\n"
14607 "Information about Route Server Client\n"
14608 NEIGHBOR_ADDR_STR2)
14609{
14610 struct bgp_table *table;
14611 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014612
14613 if (argc == 2)
14614 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14615 else
14616 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14617
14618 if (! peer)
14619 return CMD_WARNING;
14620
14621 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14622 {
14623 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14624 VTY_NEWLINE);
14625 return CMD_WARNING;
14626 }
14627
14628 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14629 PEER_FLAG_RSERVER_CLIENT))
14630 {
14631 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14632 VTY_NEWLINE);
14633 return CMD_WARNING;
14634 }
14635
14636 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14637
ajs5a646652004-11-05 01:25:55 +000014638 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014639}
14640
Lou Berger651b4022016-01-12 13:42:07 -050014641ALIAS (show_bgp_view_ipv4_rsclient,
14642 show_bgp_ipv4_rsclient_cmd,
14643 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014644 SHOW_STR
14645 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014646 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014647 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014648 NEIGHBOR_ADDR_STR2)
14649
Lou Berger651b4022016-01-12 13:42:07 -050014650ALIAS (show_bgp_view_ipv6_rsclient,
14651 show_bgp_ipv6_rsclient_cmd,
14652 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14653 SHOW_STR
14654 BGP_STR
14655 "Address Family\n"
14656 "Information about Route Server Client\n"
14657 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014658
Michael Lambert95cbbd22010-07-23 14:43:04 -040014659DEFUN (show_bgp_view_ipv6_safi_rsclient,
14660 show_bgp_view_ipv6_safi_rsclient_cmd,
14661 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14662 SHOW_STR
14663 BGP_STR
14664 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014665 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014666 "Address family\n"
14667 "Address Family modifier\n"
14668 "Address Family modifier\n"
14669 "Information about Route Server Client\n"
14670 NEIGHBOR_ADDR_STR)
14671{
14672 struct bgp_table *table;
14673 struct peer *peer;
14674 safi_t safi;
14675
14676 if (argc == 3) {
14677 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14678 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14679 } else {
14680 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14681 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14682 }
14683
14684 if (! peer)
14685 return CMD_WARNING;
14686
14687 if (! peer->afc[AFI_IP6][safi])
14688 {
14689 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14690 VTY_NEWLINE);
14691 return CMD_WARNING;
14692 }
14693
14694 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14695 PEER_FLAG_RSERVER_CLIENT))
14696 {
14697 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14698 VTY_NEWLINE);
14699 return CMD_WARNING;
14700 }
14701
14702 table = peer->rib[AFI_IP6][safi];
14703
14704 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14705}
14706
14707ALIAS (show_bgp_view_ipv6_safi_rsclient,
14708 show_bgp_ipv6_safi_rsclient_cmd,
14709 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14710 SHOW_STR
14711 BGP_STR
14712 "Address family\n"
14713 "Address Family modifier\n"
14714 "Address Family modifier\n"
14715 "Information about Route Server Client\n"
14716 NEIGHBOR_ADDR_STR)
14717
paulfee0f4c2004-09-13 05:12:46 +000014718DEFUN (show_bgp_view_rsclient_route,
14719 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014720 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14721 SHOW_STR
14722 BGP_STR
14723 "BGP view\n"
14724 "View name\n"
14725 "Information about Route Server Client\n"
14726 NEIGHBOR_ADDR_STR
14727 "Network in the BGP routing table to display\n")
14728{
14729 struct bgp *bgp;
14730 struct peer *peer;
14731
14732 /* BGP structure lookup. */
14733 if (argc == 3)
14734 {
14735 bgp = bgp_lookup_by_name (argv[0]);
14736 if (bgp == NULL)
14737 {
14738 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14739 return CMD_WARNING;
14740 }
14741 }
14742 else
14743 {
14744 bgp = bgp_get_default ();
14745 if (bgp == NULL)
14746 {
14747 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14748 return CMD_WARNING;
14749 }
14750 }
14751
14752 if (argc == 3)
14753 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14754 else
14755 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14756
14757 if (! peer)
14758 return CMD_WARNING;
14759
14760 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14761 {
14762 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14763 VTY_NEWLINE);
14764 return CMD_WARNING;
14765 }
14766
14767 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14768 PEER_FLAG_RSERVER_CLIENT))
14769 {
14770 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14771 VTY_NEWLINE);
14772 return CMD_WARNING;
14773 }
14774
14775 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14776 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014777 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050014778}
14779
14780DEFUN (show_bgp_view_ipv6_rsclient_route,
14781 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014782 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014783 SHOW_STR
14784 BGP_STR
14785 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014786 "BGP view name\n"
14787 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014788 "Information about Route Server Client\n"
14789 NEIGHBOR_ADDR_STR
14790 "Network in the BGP routing table to display\n")
14791{
14792 struct bgp *bgp;
14793 struct peer *peer;
14794
14795 /* BGP structure lookup. */
14796 if (argc == 3)
14797 {
14798 bgp = bgp_lookup_by_name (argv[0]);
14799 if (bgp == NULL)
14800 {
14801 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14802 return CMD_WARNING;
14803 }
14804 }
14805 else
14806 {
14807 bgp = bgp_get_default ();
14808 if (bgp == NULL)
14809 {
14810 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14811 return CMD_WARNING;
14812 }
14813 }
14814
14815 if (argc == 3)
14816 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14817 else
14818 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14819
14820 if (! peer)
14821 return CMD_WARNING;
14822
14823 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14824 {
14825 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14826 VTY_NEWLINE);
14827 return CMD_WARNING;
14828 }
14829
14830 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14831 PEER_FLAG_RSERVER_CLIENT))
14832 {
14833 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14834 VTY_NEWLINE);
14835 return CMD_WARNING;
14836 }
14837
14838 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14839 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014840 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paulfee0f4c2004-09-13 05:12:46 +000014841}
14842
Lou Bergerf9b6c392016-01-12 13:42:09 -050014843ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014844 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014845 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14846 SHOW_STR
14847 BGP_STR
14848 "Information about Route Server Client\n"
14849 NEIGHBOR_ADDR_STR
14850 "Network in the BGP routing table to display\n")
14851
14852ALIAS (show_bgp_view_ipv6_rsclient_route,
14853 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014854 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014855 SHOW_STR
14856 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014857 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014858 "Information about Route Server Client\n"
14859 NEIGHBOR_ADDR_STR
14860 "Network in the BGP routing table to display\n")
14861
Michael Lambert95cbbd22010-07-23 14:43:04 -040014862DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14863 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14864 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14865 SHOW_STR
14866 BGP_STR
14867 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014868 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014869 "Address family\n"
14870 "Address Family modifier\n"
14871 "Address Family modifier\n"
14872 "Information about Route Server Client\n"
14873 NEIGHBOR_ADDR_STR
14874 "Network in the BGP routing table to display\n")
14875{
14876 struct bgp *bgp;
14877 struct peer *peer;
14878 safi_t safi;
14879
14880 /* BGP structure lookup. */
14881 if (argc == 4)
14882 {
14883 bgp = bgp_lookup_by_name (argv[0]);
14884 if (bgp == NULL)
14885 {
14886 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14887 return CMD_WARNING;
14888 }
14889 }
14890 else
14891 {
14892 bgp = bgp_get_default ();
14893 if (bgp == NULL)
14894 {
14895 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14896 return CMD_WARNING;
14897 }
14898 }
14899
14900 if (argc == 4) {
14901 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14902 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14903 } else {
14904 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14905 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14906 }
14907
14908 if (! peer)
14909 return CMD_WARNING;
14910
14911 if (! peer->afc[AFI_IP6][safi])
14912 {
14913 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14914 VTY_NEWLINE);
14915 return CMD_WARNING;
14916}
14917
14918 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14919 PEER_FLAG_RSERVER_CLIENT))
14920 {
14921 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14922 VTY_NEWLINE);
14923 return CMD_WARNING;
14924 }
14925
14926 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14927 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014928 AFI_IP6, safi, NULL, 0, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014929}
14930
14931ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14932 show_bgp_ipv6_safi_rsclient_route_cmd,
14933 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14934 SHOW_STR
14935 BGP_STR
14936 "Address family\n"
14937 "Address Family modifier\n"
14938 "Address Family modifier\n"
14939 "Information about Route Server Client\n"
14940 NEIGHBOR_ADDR_STR
14941 "Network in the BGP routing table to display\n")
14942
Lou Berger651b4022016-01-12 13:42:07 -050014943
paulfee0f4c2004-09-13 05:12:46 +000014944DEFUN (show_bgp_view_rsclient_prefix,
14945 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014946 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14947 SHOW_STR
14948 BGP_STR
14949 "BGP view\n"
14950 "View name\n"
14951 "Information about Route Server Client\n"
14952 NEIGHBOR_ADDR_STR
14953 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14954{
14955 struct bgp *bgp;
14956 struct peer *peer;
14957
14958 /* BGP structure lookup. */
14959 if (argc == 3)
14960 {
14961 bgp = bgp_lookup_by_name (argv[0]);
14962 if (bgp == NULL)
14963 {
14964 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14965 return CMD_WARNING;
14966 }
14967 }
14968 else
14969 {
14970 bgp = bgp_get_default ();
14971 if (bgp == NULL)
14972 {
14973 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14974 return CMD_WARNING;
14975 }
14976 }
14977
14978 if (argc == 3)
14979 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14980 else
14981 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14982
14983 if (! peer)
14984 return CMD_WARNING;
14985
14986 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14987 {
14988 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14989 VTY_NEWLINE);
14990 return CMD_WARNING;
14991 }
14992
14993 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14994 PEER_FLAG_RSERVER_CLIENT))
14995 {
14996 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14997 VTY_NEWLINE);
14998 return CMD_WARNING;
14999 }
15000
15001 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15002 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015003 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050015004}
15005
15006DEFUN (show_bgp_view_ipv6_rsclient_prefix,
15007 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015008 "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 +000015009 SHOW_STR
15010 BGP_STR
15011 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015012 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050015013 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000015014 "Information about Route Server Client\n"
15015 NEIGHBOR_ADDR_STR
15016 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15017{
15018 struct bgp *bgp;
15019 struct peer *peer;
15020
15021 /* BGP structure lookup. */
15022 if (argc == 3)
15023 {
15024 bgp = bgp_lookup_by_name (argv[0]);
15025 if (bgp == NULL)
15026 {
15027 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15028 return CMD_WARNING;
15029 }
15030 }
15031 else
15032 {
15033 bgp = bgp_get_default ();
15034 if (bgp == NULL)
15035 {
15036 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15037 return CMD_WARNING;
15038 }
15039 }
15040
15041 if (argc == 3)
15042 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15043 else
15044 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15045
15046 if (! peer)
15047 return CMD_WARNING;
15048
15049 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15050 {
15051 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15052 VTY_NEWLINE);
15053 return CMD_WARNING;
15054 }
15055
15056 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15057 PEER_FLAG_RSERVER_CLIENT))
15058 {
15059 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15060 VTY_NEWLINE);
15061 return CMD_WARNING;
15062 }
15063
15064 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15065 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015066 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paulfee0f4c2004-09-13 05:12:46 +000015067}
15068
Lou Bergerf9b6c392016-01-12 13:42:09 -050015069ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000015070 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050015071 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15072 SHOW_STR
15073 BGP_STR
15074 "Information about Route Server Client\n"
15075 NEIGHBOR_ADDR_STR
15076 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15077
15078ALIAS (show_bgp_view_ipv6_rsclient_prefix,
15079 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015080 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000015081 SHOW_STR
15082 BGP_STR
15083 "Information about Route Server Client\n"
15084 NEIGHBOR_ADDR_STR
15085 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15086
Michael Lambert95cbbd22010-07-23 14:43:04 -040015087DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
15088 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
15089 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15090 SHOW_STR
15091 BGP_STR
15092 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015093 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040015094 "Address family\n"
15095 "Address Family modifier\n"
15096 "Address Family modifier\n"
15097 "Information about Route Server Client\n"
15098 NEIGHBOR_ADDR_STR
15099 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
15100{
15101 struct bgp *bgp;
15102 struct peer *peer;
15103 safi_t safi;
15104
15105 /* BGP structure lookup. */
15106 if (argc == 4)
15107 {
15108 bgp = bgp_lookup_by_name (argv[0]);
15109 if (bgp == NULL)
15110 {
15111 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15112 return CMD_WARNING;
15113 }
15114 }
15115 else
15116 {
15117 bgp = bgp_get_default ();
15118 if (bgp == NULL)
15119 {
15120 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15121 return CMD_WARNING;
15122 }
15123 }
15124
15125 if (argc == 4) {
15126 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15127 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15128 } else {
15129 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15130 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15131 }
15132
15133 if (! peer)
15134 return CMD_WARNING;
15135
15136 if (! peer->afc[AFI_IP6][safi])
15137 {
15138 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15139 VTY_NEWLINE);
15140 return CMD_WARNING;
15141}
15142
15143 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
15144 PEER_FLAG_RSERVER_CLIENT))
15145{
15146 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15147 VTY_NEWLINE);
15148 return CMD_WARNING;
15149 }
15150
15151 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
15152 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015153 AFI_IP6, safi, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015154}
15155
15156ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
15157 show_bgp_ipv6_safi_rsclient_prefix_cmd,
15158 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15159 SHOW_STR
15160 BGP_STR
15161 "Address family\n"
15162 "Address Family modifier\n"
15163 "Address Family modifier\n"
15164 "Information about Route Server Client\n"
15165 NEIGHBOR_ADDR_STR
15166 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
15167
paul718e3742002-12-13 20:15:29 +000015168struct bgp_table *bgp_distance_table;
15169
15170struct bgp_distance
15171{
15172 /* Distance value for the IP source prefix. */
15173 u_char distance;
15174
15175 /* Name of the access-list to be matched. */
15176 char *access_list;
15177};
15178
paul94f2b392005-06-28 12:44:16 +000015179static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015180bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000015181{
Stephen Hemminger393deb92008-08-18 14:13:29 -070015182 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000015183}
15184
paul94f2b392005-06-28 12:44:16 +000015185static void
paul718e3742002-12-13 20:15:29 +000015186bgp_distance_free (struct bgp_distance *bdistance)
15187{
15188 XFREE (MTYPE_BGP_DISTANCE, bdistance);
15189}
15190
paul94f2b392005-06-28 12:44:16 +000015191static int
paulfd79ac92004-10-13 05:06:08 +000015192bgp_distance_set (struct vty *vty, const char *distance_str,
15193 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000015194{
15195 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015196 struct prefix p;
paul718e3742002-12-13 20:15:29 +000015197 u_char distance;
15198 struct bgp_node *rn;
15199 struct bgp_distance *bdistance;
15200
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015201 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000015202 if (ret == 0)
15203 {
15204 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
15205 return CMD_WARNING;
15206 }
15207
15208 distance = atoi (distance_str);
15209
15210 /* Get BGP distance node. */
15211 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
15212 if (rn->info)
15213 {
15214 bdistance = rn->info;
15215 bgp_unlock_node (rn);
15216 }
15217 else
15218 {
15219 bdistance = bgp_distance_new ();
15220 rn->info = bdistance;
15221 }
15222
15223 /* Set distance value. */
15224 bdistance->distance = distance;
15225
15226 /* Reset access-list configuration. */
15227 if (bdistance->access_list)
15228 {
15229 free (bdistance->access_list);
15230 bdistance->access_list = NULL;
15231 }
15232 if (access_list_str)
15233 bdistance->access_list = strdup (access_list_str);
15234
15235 return CMD_SUCCESS;
15236}
15237
paul94f2b392005-06-28 12:44:16 +000015238static int
paulfd79ac92004-10-13 05:06:08 +000015239bgp_distance_unset (struct vty *vty, const char *distance_str,
15240 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000015241{
15242 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015243 struct prefix p;
paul718e3742002-12-13 20:15:29 +000015244 u_char distance;
15245 struct bgp_node *rn;
15246 struct bgp_distance *bdistance;
15247
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015248 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000015249 if (ret == 0)
15250 {
15251 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
15252 return CMD_WARNING;
15253 }
15254
15255 distance = atoi (distance_str);
15256
15257 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
15258 if (! rn)
15259 {
15260 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
15261 return CMD_WARNING;
15262 }
15263
15264 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010015265
15266 if (bdistance->distance != distance)
15267 {
15268 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
15269 return CMD_WARNING;
15270 }
15271
paul718e3742002-12-13 20:15:29 +000015272 if (bdistance->access_list)
15273 free (bdistance->access_list);
15274 bgp_distance_free (bdistance);
15275
15276 rn->info = NULL;
15277 bgp_unlock_node (rn);
15278 bgp_unlock_node (rn);
15279
15280 return CMD_SUCCESS;
15281}
15282
paul718e3742002-12-13 20:15:29 +000015283/* Apply BGP information to distance method. */
15284u_char
15285bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
15286{
15287 struct bgp_node *rn;
15288 struct prefix_ipv4 q;
15289 struct peer *peer;
15290 struct bgp_distance *bdistance;
15291 struct access_list *alist;
15292 struct bgp_static *bgp_static;
15293
15294 if (! bgp)
15295 return 0;
15296
15297 if (p->family != AF_INET)
15298 return 0;
15299
15300 peer = rinfo->peer;
15301
15302 if (peer->su.sa.sa_family != AF_INET)
15303 return 0;
15304
15305 memset (&q, 0, sizeof (struct prefix_ipv4));
15306 q.family = AF_INET;
15307 q.prefix = peer->su.sin.sin_addr;
15308 q.prefixlen = IPV4_MAX_BITLEN;
15309
15310 /* Check source address. */
15311 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15312 if (rn)
15313 {
15314 bdistance = rn->info;
15315 bgp_unlock_node (rn);
15316
15317 if (bdistance->access_list)
15318 {
15319 alist = access_list_lookup (AFI_IP, bdistance->access_list);
15320 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15321 return bdistance->distance;
15322 }
15323 else
15324 return bdistance->distance;
15325 }
15326
15327 /* Backdoor check. */
15328 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
15329 if (rn)
15330 {
15331 bgp_static = rn->info;
15332 bgp_unlock_node (rn);
15333
15334 if (bgp_static->backdoor)
15335 {
15336 if (bgp->distance_local)
15337 return bgp->distance_local;
15338 else
15339 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15340 }
15341 }
15342
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000015343 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000015344 {
15345 if (bgp->distance_ebgp)
15346 return bgp->distance_ebgp;
15347 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15348 }
15349 else
15350 {
15351 if (bgp->distance_ibgp)
15352 return bgp->distance_ibgp;
15353 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15354 }
15355}
15356
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015357#ifdef HAVE_IPV6
15358/* Apply BGP information to ipv6 distance method. */
15359u_char
15360ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
15361{
15362 struct bgp_node *rn;
15363 struct prefix_ipv6 q;
15364 struct peer *peer;
15365 struct bgp_distance *bdistance;
15366 struct access_list *alist;
15367 struct bgp_static *bgp_static;
15368
15369 if (! bgp)
15370 return 0;
15371
15372 if (p->family != AF_INET6)
15373 return 0;
15374
15375 peer = rinfo->peer;
15376
15377 if (peer->su.sa.sa_family != AF_INET6)
15378 return 0;
15379
15380 memset (&q, 0, sizeof (struct prefix_ipv6));
15381 q.family = AF_INET;
15382 q.prefix = peer->su.sin6.sin6_addr;
15383 q.prefixlen = IPV6_MAX_BITLEN;
15384
15385 /* Check source address. */
15386 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15387 if (rn)
15388 {
15389 bdistance = rn->info;
15390 bgp_unlock_node (rn);
15391
15392 if (bdistance->access_list)
15393 {
15394 alist = access_list_lookup (AFI_IP6, bdistance->access_list);
15395 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15396 return bdistance->distance;
15397 }
15398 else
15399 return bdistance->distance;
15400 }
15401 /* Backdoor check. */
15402 rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p);
15403 if (rn)
15404 {
15405 bgp_static = rn->info;
15406 bgp_unlock_node (rn);
15407
15408 if (bgp_static->backdoor)
15409 {
15410 if (bgp->ipv6_distance_local)
15411 return bgp->ipv6_distance_local;
15412 else
15413 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15414 }
15415 }
15416
15417 if (peer_sort (peer) == BGP_PEER_EBGP)
15418 {
15419 if (bgp->ipv6_distance_ebgp)
15420 return bgp->ipv6_distance_ebgp;
15421 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15422 }
15423 else
15424 {
15425 if (bgp->ipv6_distance_ibgp)
15426 return bgp->ipv6_distance_ibgp;
15427 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15428 }
15429}
15430#endif /* HAVE_IPV6 */
15431
paul718e3742002-12-13 20:15:29 +000015432DEFUN (bgp_distance,
15433 bgp_distance_cmd,
15434 "distance bgp <1-255> <1-255> <1-255>",
15435 "Define an administrative distance\n"
15436 "BGP distance\n"
15437 "Distance for routes external to the AS\n"
15438 "Distance for routes internal to the AS\n"
15439 "Distance for local routes\n")
15440{
15441 struct bgp *bgp;
15442
15443 bgp = vty->index;
15444
15445 bgp->distance_ebgp = atoi (argv[0]);
15446 bgp->distance_ibgp = atoi (argv[1]);
15447 bgp->distance_local = atoi (argv[2]);
15448 return CMD_SUCCESS;
15449}
15450
15451DEFUN (no_bgp_distance,
15452 no_bgp_distance_cmd,
15453 "no distance bgp <1-255> <1-255> <1-255>",
15454 NO_STR
15455 "Define an administrative distance\n"
15456 "BGP distance\n"
15457 "Distance for routes external to the AS\n"
15458 "Distance for routes internal to the AS\n"
15459 "Distance for local routes\n")
15460{
15461 struct bgp *bgp;
15462
15463 bgp = vty->index;
15464
15465 bgp->distance_ebgp= 0;
15466 bgp->distance_ibgp = 0;
15467 bgp->distance_local = 0;
15468 return CMD_SUCCESS;
15469}
15470
15471ALIAS (no_bgp_distance,
15472 no_bgp_distance2_cmd,
15473 "no distance bgp",
15474 NO_STR
15475 "Define an administrative distance\n"
15476 "BGP distance\n")
15477
15478DEFUN (bgp_distance_source,
15479 bgp_distance_source_cmd,
15480 "distance <1-255> A.B.C.D/M",
15481 "Define an administrative distance\n"
15482 "Administrative distance\n"
15483 "IP source prefix\n")
15484{
15485 bgp_distance_set (vty, argv[0], argv[1], NULL);
15486 return CMD_SUCCESS;
15487}
15488
15489DEFUN (no_bgp_distance_source,
15490 no_bgp_distance_source_cmd,
15491 "no distance <1-255> A.B.C.D/M",
15492 NO_STR
15493 "Define an administrative distance\n"
15494 "Administrative distance\n"
15495 "IP source prefix\n")
15496{
15497 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15498 return CMD_SUCCESS;
15499}
15500
15501DEFUN (bgp_distance_source_access_list,
15502 bgp_distance_source_access_list_cmd,
15503 "distance <1-255> A.B.C.D/M WORD",
15504 "Define an administrative distance\n"
15505 "Administrative distance\n"
15506 "IP source prefix\n"
15507 "Access list name\n")
15508{
15509 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15510 return CMD_SUCCESS;
15511}
15512
15513DEFUN (no_bgp_distance_source_access_list,
15514 no_bgp_distance_source_access_list_cmd,
15515 "no distance <1-255> A.B.C.D/M WORD",
15516 NO_STR
15517 "Define an administrative distance\n"
15518 "Administrative distance\n"
15519 "IP source prefix\n"
15520 "Access list name\n")
15521{
15522 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15523 return CMD_SUCCESS;
15524}
David Lamparter6b0655a2014-06-04 06:53:35 +020015525
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015526#ifdef HAVE_IPV6
15527DEFUN (ipv6_bgp_distance,
15528 ipv6_bgp_distance_cmd,
15529 "distance bgp <1-255> <1-255> <1-255>",
15530 "Define an administrative distance\n"
15531 "BGP distance\n"
15532 "Distance for routes external to the AS\n"
15533 "Distance for routes internal to the AS\n"
15534 "Distance for local routes\n")
15535{
15536 struct bgp *bgp;
15537
15538 bgp = vty->index;
15539
15540 bgp->ipv6_distance_ebgp = atoi (argv[0]);
15541 bgp->ipv6_distance_ibgp = atoi (argv[1]);
15542 bgp->ipv6_distance_local = atoi (argv[2]);
15543 return CMD_SUCCESS;
15544}
15545
15546DEFUN (no_ipv6_bgp_distance,
15547 no_ipv6_bgp_distance_cmd,
15548 "no distance bgp <1-255> <1-255> <1-255>",
15549 NO_STR
15550 "Define an administrative distance\n"
15551 "BGP distance\n"
15552 "Distance for routes external to the AS\n"
15553 "Distance for routes internal to the AS\n"
15554 "Distance for local routes\n")
15555{
15556 struct bgp *bgp;
15557
15558 bgp = vty->index;
15559
15560 bgp->ipv6_distance_ebgp= 0;
15561 bgp->ipv6_distance_ibgp = 0;
15562 bgp->ipv6_distance_local = 0;
15563 return CMD_SUCCESS;
15564}
15565
15566ALIAS (no_ipv6_bgp_distance,
15567 no_ipv6_bgp_distance2_cmd,
15568 "no distance bgp",
15569 NO_STR
15570 "Define an administrative distance\n"
15571 "BGP distance\n")
15572
15573DEFUN (ipv6_bgp_distance_source,
15574 ipv6_bgp_distance_source_cmd,
15575 "distance <1-255> X:X::X:X/M",
15576 "Define an administrative distance\n"
15577 "Administrative distance\n"
15578 "IP source prefix\n")
15579{
15580 bgp_distance_set (vty, argv[0], argv[1], NULL);
15581 return CMD_SUCCESS;
15582}
15583
15584DEFUN (no_ipv6_bgp_distance_source,
15585 no_ipv6_bgp_distance_source_cmd,
15586 "no distance <1-255> X:X::X:X/M",
15587 NO_STR
15588 "Define an administrative distance\n"
15589 "Administrative distance\n"
15590 "IP source prefix\n")
15591{
15592 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15593 return CMD_SUCCESS;
15594}
15595
15596DEFUN (ipv6_bgp_distance_source_access_list,
15597 ipv6_bgp_distance_source_access_list_cmd,
15598 "distance <1-255> X:X::X:X/M WORD",
15599 "Define an administrative distance\n"
15600 "Administrative distance\n"
15601 "IP source prefix\n"
15602 "Access list name\n")
15603{
15604 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15605 return CMD_SUCCESS;
15606}
15607
15608DEFUN (no_ipv6_bgp_distance_source_access_list,
15609 no_ipv6_bgp_distance_source_access_list_cmd,
15610 "no distance <1-255> X:X::X:X/M WORD",
15611 NO_STR
15612 "Define an administrative distance\n"
15613 "Administrative distance\n"
15614 "IP source prefix\n"
15615 "Access list name\n")
15616{
15617 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15618 return CMD_SUCCESS;
15619}
15620#endif
15621
paul718e3742002-12-13 20:15:29 +000015622DEFUN (bgp_damp_set,
15623 bgp_damp_set_cmd,
15624 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15625 "BGP Specific commands\n"
15626 "Enable route-flap dampening\n"
15627 "Half-life time for the penalty\n"
15628 "Value to start reusing a route\n"
15629 "Value to start suppressing a route\n"
15630 "Maximum duration to suppress a stable route\n")
15631{
15632 struct bgp *bgp;
15633 int half = DEFAULT_HALF_LIFE * 60;
15634 int reuse = DEFAULT_REUSE;
15635 int suppress = DEFAULT_SUPPRESS;
15636 int max = 4 * half;
15637
15638 if (argc == 4)
15639 {
15640 half = atoi (argv[0]) * 60;
15641 reuse = atoi (argv[1]);
15642 suppress = atoi (argv[2]);
15643 max = atoi (argv[3]) * 60;
15644 }
15645 else if (argc == 1)
15646 {
15647 half = atoi (argv[0]) * 60;
15648 max = 4 * half;
15649 }
15650
15651 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015652
15653 if (suppress < reuse)
15654 {
15655 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15656 VTY_NEWLINE);
15657 return 0;
15658 }
15659
paul718e3742002-12-13 20:15:29 +000015660 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15661 half, reuse, suppress, max);
15662}
15663
15664ALIAS (bgp_damp_set,
15665 bgp_damp_set2_cmd,
15666 "bgp dampening <1-45>",
15667 "BGP Specific commands\n"
15668 "Enable route-flap dampening\n"
15669 "Half-life time for the penalty\n")
15670
15671ALIAS (bgp_damp_set,
15672 bgp_damp_set3_cmd,
15673 "bgp dampening",
15674 "BGP Specific commands\n"
15675 "Enable route-flap dampening\n")
15676
15677DEFUN (bgp_damp_unset,
15678 bgp_damp_unset_cmd,
15679 "no bgp dampening",
15680 NO_STR
15681 "BGP Specific commands\n"
15682 "Enable route-flap dampening\n")
15683{
15684 struct bgp *bgp;
15685
15686 bgp = vty->index;
15687 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15688}
15689
15690ALIAS (bgp_damp_unset,
15691 bgp_damp_unset2_cmd,
15692 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15693 NO_STR
15694 "BGP Specific commands\n"
15695 "Enable route-flap dampening\n"
15696 "Half-life time for the penalty\n"
15697 "Value to start reusing a route\n"
15698 "Value to start suppressing a route\n"
15699 "Maximum duration to suppress a stable route\n")
15700
Lou Bergerf9b6c392016-01-12 13:42:09 -050015701DEFUN (show_ip_bgp_dampened_paths,
15702 show_ip_bgp_dampened_paths_cmd,
15703 "show ip bgp dampened-paths",
15704 SHOW_STR
15705 IP_STR
15706 BGP_STR
15707 "Display paths suppressed due to dampening\n")
15708{
15709 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15710 NULL);
15711}
15712
15713ALIAS (show_ip_bgp_dampened_paths,
15714 show_ip_bgp_damp_dampened_paths_cmd,
15715 "show ip bgp dampening dampened-paths",
15716 SHOW_STR
15717 IP_STR
15718 BGP_STR
15719 "Display detailed information about dampening\n"
15720 "Display paths suppressed due to dampening\n")
15721
15722DEFUN (show_ip_bgp_flap_statistics,
15723 show_ip_bgp_flap_statistics_cmd,
15724 "show ip bgp flap-statistics",
15725 SHOW_STR
15726 IP_STR
15727 BGP_STR
15728 "Display flap statistics of routes\n")
15729{
15730 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15731 bgp_show_type_flap_statistics, NULL);
15732}
15733
15734ALIAS (show_ip_bgp_flap_statistics,
15735 show_ip_bgp_damp_flap_statistics_cmd,
15736 "show ip bgp dampening flap-statistics",
15737 SHOW_STR
15738 IP_STR
15739 BGP_STR
15740 "Display detailed information about dampening\n"
15741 "Display flap statistics of routes\n")
15742
Lou Berger651b4022016-01-12 13:42:07 -050015743DEFUN (show_bgp_ipv4_safi_dampened_paths,
15744 show_bgp_ipv4_safi_dampened_paths_cmd,
15745 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015746 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015747 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015748 IP_STR
15749 "Address Family modifier\n"
15750 "Address Family modifier\n"
15751 "Address Family modifier\n"
15752 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015753 "Display paths suppressed due to dampening\n")
15754{
Lou Berger651b4022016-01-12 13:42:07 -050015755 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015756
Lou Berger651b4022016-01-12 13:42:07 -050015757 if (bgp_parse_safi(argv[0], &safi)) {
15758 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15759 return CMD_WARNING;
15760 }
15761
15762 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15763}
15764ALIAS (show_bgp_ipv4_safi_dampened_paths,
15765 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15766 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015767 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015768 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015769 IP_STR
15770 "Address Family modifier\n"
15771 "Address Family modifier\n"
15772 "Address Family modifier\n"
15773 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015774 "Display detailed information about dampening\n"
15775 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015776
Lou Berger651b4022016-01-12 13:42:07 -050015777DEFUN (show_bgp_ipv6_safi_dampened_paths,
15778 show_bgp_ipv6_safi_dampened_paths_cmd,
15779 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015780 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015781 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015782 IPV6_STR
15783 "Address Family modifier\n"
15784 "Address Family modifier\n"
15785 "Address Family modifier\n"
15786 "Address Family modifier\n"
15787 "Display paths suppressed due to dampening\n")
15788{
15789 safi_t safi;
15790
15791 if (bgp_parse_safi(argv[0], &safi)) {
15792 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15793 return CMD_WARNING;
15794 }
15795
15796 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15797}
15798ALIAS (show_bgp_ipv6_safi_dampened_paths,
15799 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15800 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15801 SHOW_STR
15802 BGP_STR
15803 IPV6_STR
15804 "Address Family modifier\n"
15805 "Address Family modifier\n"
15806 "Address Family modifier\n"
15807 "Address Family modifier\n"
15808 "Display detailed information about dampening\n"
15809 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015810
15811DEFUN (show_bgp_ipv4_safi_flap_statistics,
15812 show_bgp_ipv4_safi_flap_statistics_cmd,
15813 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15814 SHOW_STR
15815 BGP_STR
15816 "Address Family\n"
15817 "Address Family modifier\n"
15818 "Address Family modifier\n"
15819 "Address Family modifier\n"
15820 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015821 "Display flap statistics of routes\n")
15822{
Lou Berger651b4022016-01-12 13:42:07 -050015823 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015824
Lou Berger651b4022016-01-12 13:42:07 -050015825 if (bgp_parse_safi(argv[0], &safi)) {
15826 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15827 return CMD_WARNING;
15828 }
15829
15830 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15831}
15832ALIAS (show_bgp_ipv4_safi_flap_statistics,
15833 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15834 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015835 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015836 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015837 "Address Family\n"
15838 "Address Family modifier\n"
15839 "Address Family modifier\n"
15840 "Address Family modifier\n"
15841 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015842 "Display detailed information about dampening\n"
15843 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015844
Lou Berger651b4022016-01-12 13:42:07 -050015845DEFUN (show_bgp_ipv6_safi_flap_statistics,
15846 show_bgp_ipv6_safi_flap_statistics_cmd,
15847 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15848 SHOW_STR
15849 BGP_STR
15850 "Address Family\n"
15851 "Address Family modifier\n"
15852 "Address Family modifier\n"
15853 "Address Family modifier\n"
15854 "Address Family modifier\n"
15855 "Display flap statistics of routes\n")
15856{
15857 safi_t safi;
15858
15859 if (bgp_parse_safi(argv[0], &safi)) {
15860 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15861 return CMD_WARNING;
15862 }
15863
15864 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15865}
15866ALIAS (show_bgp_ipv6_safi_flap_statistics,
15867 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15868 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15869 SHOW_STR
15870 BGP_STR
15871 "Address Family\n"
15872 "Address Family modifier\n"
15873 "Address Family modifier\n"
15874 "Address Family modifier\n"
15875 "Address Family modifier\n"
15876 "Display detailed information about dampening\n"
15877 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015878
paul718e3742002-12-13 20:15:29 +000015879/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015880static int
paulfd79ac92004-10-13 05:06:08 +000015881bgp_clear_damp_route (struct vty *vty, const char *view_name,
15882 const char *ip_str, afi_t afi, safi_t safi,
15883 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015884{
15885 int ret;
15886 struct prefix match;
15887 struct bgp_node *rn;
15888 struct bgp_node *rm;
15889 struct bgp_info *ri;
15890 struct bgp_info *ri_temp;
15891 struct bgp *bgp;
15892 struct bgp_table *table;
15893
15894 /* BGP structure lookup. */
15895 if (view_name)
15896 {
15897 bgp = bgp_lookup_by_name (view_name);
15898 if (bgp == NULL)
15899 {
15900 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15901 return CMD_WARNING;
15902 }
15903 }
15904 else
15905 {
15906 bgp = bgp_get_default ();
15907 if (bgp == NULL)
15908 {
15909 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15910 return CMD_WARNING;
15911 }
15912 }
15913
15914 /* Check IP address argument. */
15915 ret = str2prefix (ip_str, &match);
15916 if (! ret)
15917 {
15918 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15919 return CMD_WARNING;
15920 }
15921
15922 match.family = afi2family (afi);
15923
Lou Berger298cc2f2016-01-12 13:42:02 -050015924 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015925 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015926 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015927 {
15928 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15929 continue;
15930
15931 if ((table = rn->info) != NULL)
15932 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015933 {
15934 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15935 {
15936 ri = rm->info;
15937 while (ri)
15938 {
15939 if (ri->extra && ri->extra->damp_info)
15940 {
15941 ri_temp = ri->next;
15942 bgp_damp_info_free (ri->extra->damp_info, 1);
15943 ri = ri_temp;
15944 }
15945 else
15946 ri = ri->next;
15947 }
15948 }
15949
15950 bgp_unlock_node (rm);
15951 }
paul718e3742002-12-13 20:15:29 +000015952 }
15953 }
15954 else
15955 {
15956 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015957 {
15958 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15959 {
15960 ri = rn->info;
15961 while (ri)
15962 {
15963 if (ri->extra && ri->extra->damp_info)
15964 {
15965 ri_temp = ri->next;
15966 bgp_damp_info_free (ri->extra->damp_info, 1);
15967 ri = ri_temp;
15968 }
15969 else
15970 ri = ri->next;
15971 }
15972 }
15973
15974 bgp_unlock_node (rn);
15975 }
paul718e3742002-12-13 20:15:29 +000015976 }
15977
15978 return CMD_SUCCESS;
15979}
15980
15981DEFUN (clear_ip_bgp_dampening,
15982 clear_ip_bgp_dampening_cmd,
15983 "clear ip bgp dampening",
15984 CLEAR_STR
15985 IP_STR
15986 BGP_STR
15987 "Clear route flap dampening information\n")
15988{
15989 bgp_damp_info_clean ();
15990 return CMD_SUCCESS;
15991}
15992
15993DEFUN (clear_ip_bgp_dampening_prefix,
15994 clear_ip_bgp_dampening_prefix_cmd,
15995 "clear ip bgp dampening A.B.C.D/M",
15996 CLEAR_STR
15997 IP_STR
15998 BGP_STR
15999 "Clear route flap dampening information\n"
16000 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
16001{
16002 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16003 SAFI_UNICAST, NULL, 1);
16004}
16005
16006DEFUN (clear_ip_bgp_dampening_address,
16007 clear_ip_bgp_dampening_address_cmd,
16008 "clear ip bgp dampening A.B.C.D",
16009 CLEAR_STR
16010 IP_STR
16011 BGP_STR
16012 "Clear route flap dampening information\n"
16013 "Network to clear damping information\n")
16014{
16015 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16016 SAFI_UNICAST, NULL, 0);
16017}
16018
16019DEFUN (clear_ip_bgp_dampening_address_mask,
16020 clear_ip_bgp_dampening_address_mask_cmd,
16021 "clear ip bgp dampening A.B.C.D A.B.C.D",
16022 CLEAR_STR
16023 IP_STR
16024 BGP_STR
16025 "Clear route flap dampening information\n"
16026 "Network to clear damping information\n"
16027 "Network mask\n")
16028{
16029 int ret;
16030 char prefix_str[BUFSIZ];
16031
16032 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
16033 if (! ret)
16034 {
16035 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
16036 return CMD_WARNING;
16037 }
16038
16039 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
16040 SAFI_UNICAST, NULL, 0);
16041}
David Lamparter6b0655a2014-06-04 06:53:35 +020016042
Lou Berger298cc2f2016-01-12 13:42:02 -050016043/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000016044static int
paul718e3742002-12-13 20:15:29 +000016045bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
16046 afi_t afi, safi_t safi, int *write)
16047{
16048 struct bgp_node *prn;
16049 struct bgp_node *rn;
16050 struct bgp_table *table;
16051 struct prefix *p;
16052 struct prefix_rd *prd;
16053 struct bgp_static *bgp_static;
16054 u_int32_t label;
16055 char buf[SU_ADDRSTRLEN];
16056 char rdbuf[RD_ADDRSTRLEN];
16057
16058 /* Network configuration. */
16059 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
16060 if ((table = prn->info) != NULL)
16061 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
16062 if ((bgp_static = rn->info) != NULL)
16063 {
16064 p = &rn->p;
16065 prd = (struct prefix_rd *) &prn->p;
16066
16067 /* "address-family" display. */
16068 bgp_config_write_family_header (vty, afi, safi, write);
16069
16070 /* "network" configuration display. */
16071 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
16072 label = decode_label (bgp_static->tag);
16073
16074 vty_out (vty, " network %s/%d rd %s tag %d",
16075 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16076 p->prefixlen,
16077 rdbuf, label);
16078 vty_out (vty, "%s", VTY_NEWLINE);
16079 }
16080 return 0;
16081}
16082
16083/* Configuration of static route announcement and aggregate
16084 information. */
16085int
16086bgp_config_write_network (struct vty *vty, struct bgp *bgp,
16087 afi_t afi, safi_t safi, int *write)
16088{
16089 struct bgp_node *rn;
16090 struct prefix *p;
16091 struct bgp_static *bgp_static;
16092 struct bgp_aggregate *bgp_aggregate;
16093 char buf[SU_ADDRSTRLEN];
16094
Lou Berger298cc2f2016-01-12 13:42:02 -050016095 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000016096 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
16097
16098 /* Network configuration. */
16099 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
16100 if ((bgp_static = rn->info) != NULL)
16101 {
16102 p = &rn->p;
16103
16104 /* "address-family" display. */
16105 bgp_config_write_family_header (vty, afi, safi, write);
16106
16107 /* "network" configuration display. */
16108 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
16109 {
16110 u_int32_t destination;
16111 struct in_addr netmask;
16112
16113 destination = ntohl (p->u.prefix4.s_addr);
16114 masklen2ip (p->prefixlen, &netmask);
16115 vty_out (vty, " network %s",
16116 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
16117
16118 if ((IN_CLASSC (destination) && p->prefixlen == 24)
16119 || (IN_CLASSB (destination) && p->prefixlen == 16)
16120 || (IN_CLASSA (destination) && p->prefixlen == 8)
16121 || p->u.prefix4.s_addr == 0)
16122 {
16123 /* Natural mask is not display. */
16124 }
16125 else
16126 vty_out (vty, " mask %s", inet_ntoa (netmask));
16127 }
16128 else
16129 {
16130 vty_out (vty, " network %s/%d",
16131 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16132 p->prefixlen);
16133 }
16134
16135 if (bgp_static->rmap.name)
16136 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000016137 else
16138 {
16139 if (bgp_static->backdoor)
16140 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000016141 }
paul718e3742002-12-13 20:15:29 +000016142
16143 vty_out (vty, "%s", VTY_NEWLINE);
16144 }
16145
16146 /* Aggregate-address configuration. */
16147 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
16148 if ((bgp_aggregate = rn->info) != NULL)
16149 {
16150 p = &rn->p;
16151
16152 /* "address-family" display. */
16153 bgp_config_write_family_header (vty, afi, safi, write);
16154
16155 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
16156 {
16157 struct in_addr netmask;
16158
16159 masklen2ip (p->prefixlen, &netmask);
16160 vty_out (vty, " aggregate-address %s %s",
16161 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16162 inet_ntoa (netmask));
16163 }
16164 else
16165 {
16166 vty_out (vty, " aggregate-address %s/%d",
16167 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16168 p->prefixlen);
16169 }
16170
16171 if (bgp_aggregate->as_set)
16172 vty_out (vty, " as-set");
16173
16174 if (bgp_aggregate->summary_only)
16175 vty_out (vty, " summary-only");
16176
16177 vty_out (vty, "%s", VTY_NEWLINE);
16178 }
16179
16180 return 0;
16181}
16182
16183int
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016184bgp_config_write_distance (struct vty *vty, struct bgp *bgp,
16185 afi_t afi, safi_t safi, int *write)
paul718e3742002-12-13 20:15:29 +000016186{
16187 struct bgp_node *rn;
16188 struct bgp_distance *bdistance;
16189
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016190 if (afi == AFI_IP && safi == SAFI_UNICAST)
16191 {
16192 /* Distance configuration. */
16193 if (bgp->distance_ebgp
16194 && bgp->distance_ibgp
16195 && bgp->distance_local
16196 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
16197 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
16198 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
16199 vty_out (vty, " distance bgp %d %d %d%s",
16200 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
16201 VTY_NEWLINE);
16202
16203 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
16204 if ((bdistance = rn->info) != NULL)
16205 {
16206 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
16207 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
16208 bdistance->access_list ? bdistance->access_list : "",
16209 VTY_NEWLINE);
16210 }
16211 }
16212
16213#ifdef HAVE_IPV6
16214 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
16215 {
16216 bgp_config_write_family_header (vty, afi, safi, write);
16217 if (bgp->ipv6_distance_ebgp
16218 && bgp->ipv6_distance_ibgp
16219 && bgp->ipv6_distance_local
16220 && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
16221 || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
16222 || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
16223 vty_out (vty, " distance bgp %d %d %d%s",
16224 bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local,
16225 VTY_NEWLINE);
16226
16227 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
16228 if ((bdistance = rn->info) != NULL)
16229 {
16230 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
16231 inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen,
16232 bdistance->access_list ? bdistance->access_list : "",
16233 VTY_NEWLINE);
16234 }
16235 }
16236#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000016237
16238 return 0;
16239}
16240
16241/* Allocate routing table structure and install commands. */
16242void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080016243bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000016244{
16245 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000016246 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000016247
16248 /* IPv4 BGP commands. */
16249 install_element (BGP_NODE, &bgp_network_cmd);
16250 install_element (BGP_NODE, &bgp_network_mask_cmd);
16251 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
16252 install_element (BGP_NODE, &bgp_network_route_map_cmd);
16253 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
16254 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
16255 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
16256 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
16257 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
16258 install_element (BGP_NODE, &no_bgp_network_cmd);
16259 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
16260 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
16261 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
16262 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
16263 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
16264 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
16265 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
16266 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
16267
16268 install_element (BGP_NODE, &aggregate_address_cmd);
16269 install_element (BGP_NODE, &aggregate_address_mask_cmd);
16270 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
16271 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
16272 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
16273 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
16274 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
16275 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
16276 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
16277 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
16278 install_element (BGP_NODE, &no_aggregate_address_cmd);
16279 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
16280 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
16281 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
16282 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
16283 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
16284 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
16285 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
16286 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16287 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16288
16289 /* IPv4 unicast configuration. */
16290 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
16291 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
16292 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
16293 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
16294 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
16295 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016296 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000016297 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
16298 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
16299 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
16300 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
16301 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016302
paul718e3742002-12-13 20:15:29 +000016303 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
16304 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
16305 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
16306 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
16307 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
16308 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
16309 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
16310 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
16311 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
16312 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
16313 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
16314 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
16315 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
16316 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
16317 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
16318 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
16319 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
16320 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
16321 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16322 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16323
16324 /* IPv4 multicast configuration. */
16325 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
16326 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
16327 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
16328 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
16329 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
16330 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
16331 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
16332 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
16333 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
16334 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
16335 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
16336 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
16337 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
16338 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
16339 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
16340 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
16341 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
16342 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
16343 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
16344 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
16345 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
16346 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
16347 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
16348 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
16349 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
16350 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
16351 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
16352 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
16353 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
16354 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
16355 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16356 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16357
Michael Lambert95cbbd22010-07-23 14:43:04 -040016358 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016359 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016360 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
16361 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
16362 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16363 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16364 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
16365 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
16366 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16367 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16368 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016369 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016370 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16371 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16372 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16373 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16374 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16375 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16376 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
16377 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
16378 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16379 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
16380 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
16381 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
16382 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
16383 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
16384 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
16385 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
16386 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
16387 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
16388 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
16389 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16390 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
16391 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
16392 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
16393 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
16394 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
16395 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
16396 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
16397 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016398 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16399 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
16400 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
16401 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
16402 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016403 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
16404 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
16405 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
16406 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
16407 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16408 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16409 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16410 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16411 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
16412 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16413 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16414 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16415 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16416 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16417 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16418 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16419 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16420 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16421 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016422 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016423 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16424 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16425 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16426 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16427 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16428 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16429 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16430 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16431 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16432 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16433 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16434 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16435 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16436 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
16437 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16438 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16439 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16440 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16441 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16442 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16443 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16444 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16445 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16446 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16447 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16448 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16449 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16450 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16451 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16452 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16453 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16454 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16455 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16456 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16457 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16458 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16459 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16460 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16461 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16462 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16463 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16464 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16465 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16466 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16467 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016468 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016469 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016470 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016471 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016472 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016473 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016474
16475 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040016476 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016477 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16478 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16479 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16480 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16481 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016482 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016483 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16484 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16485 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16486 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16487 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16488 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16489 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
16490 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16491 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
16492 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
16493 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
16494 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
16495 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
16496 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
16497 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
16498 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016499 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16500 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
16501 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
16502 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
16503 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016504 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
16505 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
16506 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
16507 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
16508 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16509 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16510 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16511 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016512 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016513 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016514 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016515 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016516
Donald Sharp68b45cc2016-03-11 14:27:13 -050016517 /* BGP dampening clear commands */
paul718e3742002-12-13 20:15:29 +000016518 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16519 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16520 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16521 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16522
paul718e3742002-12-13 20:15:29 +000016523 /* New config IPv6 BGP commands. */
16524 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16525 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16526 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16527 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16528
16529 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16530 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16531 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16532 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16533
G.Balaji73bfe0b2011-09-23 22:36:20 +053016534 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16535 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16536
paul718e3742002-12-13 20:15:29 +000016537 /* Old config IPv6 BGP commands. */
16538 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16539 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16540
16541 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16542 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16543 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16544 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16545
Michael Lambert95cbbd22010-07-23 14:43:04 -040016546 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016547 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016548 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016549 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016550 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016551 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016552 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016553 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016554 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016555 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16556 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16557 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16558 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16559 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16560 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16561 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16562 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016563 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016564 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016565 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016566 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016567 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016568 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016569 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016570 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016571 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16572 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016573 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016574 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016575 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016576 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016577 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016578 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016579 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016580 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016581 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016582 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016583 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016584 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016585 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016586 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016587 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16588 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016589 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016590 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016591 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016592 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016593 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016594
16595 /* Restricted:
16596 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16597 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016598 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016599 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016600 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016601 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016602 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16603 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16604 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16605 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16606 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16607 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16608 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16609 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16610 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016611 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016612 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016613 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016614 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016615 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016616 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016617 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016618 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016619 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016620 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016621
Paul Jakma2815e612006-09-14 02:56:07 +000016622 /* Statistics */
16623 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016624 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016625
16626 install_element (BGP_NODE, &bgp_distance_cmd);
16627 install_element (BGP_NODE, &no_bgp_distance_cmd);
16628 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16629 install_element (BGP_NODE, &bgp_distance_source_cmd);
16630 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16631 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16632 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016633#ifdef HAVE_IPV6
16634 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd);
16635 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd);
16636 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd);
16637 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd);
16638 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd);
16639 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd);
16640 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd);
16641#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000016642
16643 install_element (BGP_NODE, &bgp_damp_set_cmd);
16644 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16645 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16646 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16647 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16648 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16649 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16650 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16651 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16652 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Balaji9145f0e2016-01-20 22:59:27 +053016653
16654 /* IPv4 Multicast Mode */
16655 install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd);
16656 install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd);
16657 install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd);
16658 install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd);
16659 install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd);
16660
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016661
16662 /* Deprecated AS-Pathlimit commands */
16663 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16664 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16665 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16666 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16667 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16668 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16669
16670 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16671 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16672 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16673 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16674 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16675 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16676
16677 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16678 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16679 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16680 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16681 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16682 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16683
16684 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16685 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16686 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16687 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16688 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16689 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16690
16691 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16692 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16693 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16694 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16695 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16696 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16697
16698 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16699 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16700 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16701 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16702 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16703 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016704
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016705 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16706 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016707
16708 /* old style commands */
16709 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16710 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16711 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016712 install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd);
16713 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016714 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16715 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16716 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16717 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16718 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016719 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
16720 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
16721 install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016722 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16723 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16724 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16725 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16726 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16727 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16728 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16729 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16730 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16731 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16732 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16733 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16734 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16735 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16736 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16737 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16738 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16739 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16740 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16741 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16742 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16743 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16744 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16745 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16746 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16747 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16748 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16749 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16750 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16751 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16752 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16753 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16754 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16755 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16756 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16757 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16758 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16759 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16760 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16761 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16762 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16763 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16764 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16765 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16766 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16767 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16768 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16769 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016770 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016771 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016772 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd);
16773 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016774 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16775 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16776 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16777 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16778 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16779 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16780 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16781 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16782 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16783 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16784 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16785 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16786 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16787 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16788 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16789 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16790 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16791 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16792 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16793 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16794 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16795 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16796 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16797 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16798 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16799 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16800 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016801
Lou Bergerf9b6c392016-01-12 13:42:09 -050016802 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016803 install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd);
16804 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016805 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16806 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16807 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16808 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016809 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
16810 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
16811 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016812 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16813 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16814 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16815 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16816 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16817 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16818 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16819 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16820 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16821 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16822 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16823 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16824 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16825 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16826 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16827 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16828 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16829 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16830 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16831 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16832 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16833 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16834 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16835 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016836
16837 install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16838 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16839 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016840
Lou Bergerf9b6c392016-01-12 13:42:09 -050016841 install_element (VIEW_NODE, &show_bgp_cmd);
16842 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16843 install_element (VIEW_NODE, &show_bgp_route_cmd);
16844 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016845 install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd);
16846 install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd);
16847 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
16848 install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd);
16849 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
16850 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016851 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16852 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16853 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16854 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16855 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16856 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16857 install_element (VIEW_NODE, &show_bgp_community_cmd);
16858 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16859 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16860 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16861 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16862 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16863 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16864 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16865 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16866 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16867 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16868 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16869 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16870 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16871 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16872 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16873 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16874 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16875 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16876 install_element (VIEW_NODE, &show_bgp_view_cmd);
16877 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16878 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16879 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16880 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16881 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16882 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16883 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16884 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16885 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016886
Lou Bergerf9b6c392016-01-12 13:42:09 -050016887 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16888 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016889 install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd);
16890 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd);
16891 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
16892 install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd);
16893 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
16894 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016895 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16896 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16897 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16898 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16899 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16900 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16901 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16902 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16903 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16904 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16905 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016906
Lou Bergerf9b6c392016-01-12 13:42:09 -050016907 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16908 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016909
Lou Bergerf9b6c392016-01-12 13:42:09 -050016910 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16911 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16912 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16913 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16914 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16915 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16916 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16917 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16918 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16919 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16920 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16921 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16922 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16923 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16924 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16925 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16926 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16927 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16928 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16929 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16930 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16931 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16932 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16933 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16934 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16935 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16936 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16937 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16938 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16939 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16940 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16941 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16942 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16943 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16944 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16945 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016946 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016947 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016948 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016949 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016950 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016951 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016952 /* old with name safi collision */
16953 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16954 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16955 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16956 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16957 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16958 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16959 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16960 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16961 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16962 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16963 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16964 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16965 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16966 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16967 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16968 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016969
Lou Bergerf9b6c392016-01-12 13:42:09 -050016970 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
16971 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016972
16973 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
16974 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
16975 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
16976 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016977
16978 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
16979 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
16980 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
16981 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016982}
Chris Caputo228da422009-07-18 05:44:03 +000016983
16984void
16985bgp_route_finish (void)
16986{
16987 bgp_table_unlock (bgp_distance_table);
16988 bgp_distance_table = NULL;
16989}