blob: 4cb6c141bcdcd8fcced201403637d05b0c247192 [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;
3781
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003782 /* Make new BGP info. */
3783 rn = bgp_node_get (bgp->rib[afi][safi], p);
paul718e3742002-12-13 20:15:29 +00003784
3785 /* Check selected route and self inserted route. */
3786 for (ri = rn->info; ri; ri = ri->next)
3787 if (ri->peer == bgp->peer_self
3788 && ri->type == ZEBRA_ROUTE_BGP
3789 && ri->sub_type == BGP_ROUTE_STATIC)
3790 break;
3791
3792 /* Withdraw static BGP route from routing table. */
3793 if (ri)
3794 {
3795 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003796 bgp_unlink_nexthop(ri);
paul718e3742002-12-13 20:15:29 +00003797 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003798 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003799 }
3800
3801 /* Unlock bgp_node_lookup. */
3802 bgp_unlock_node (rn);
3803}
3804
3805void
paulfee0f4c2004-09-13 05:12:46 +00003806bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3807{
3808 struct bgp_static *bgp_static;
3809 struct bgp *bgp;
3810 struct bgp_node *rn;
3811 struct prefix *p;
3812
3813 bgp = rsclient->bgp;
3814
3815 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3816 if ((bgp_static = rn->info) != NULL)
3817 {
3818 p = &rn->p;
3819
3820 bgp_static_update_rsclient (rsclient, p, bgp_static,
3821 afi, safi);
3822 }
3823}
3824
Lou Bergera76d9ca2016-01-12 13:41:53 -05003825/*
3826 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3827 */
paul94f2b392005-06-28 12:44:16 +00003828static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003829bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3830 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003831{
3832 struct bgp_node *rn;
3833 struct bgp_info *ri;
3834
paulfee0f4c2004-09-13 05:12:46 +00003835 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003836
3837 /* Check selected route and self inserted route. */
3838 for (ri = rn->info; ri; ri = ri->next)
3839 if (ri->peer == bgp->peer_self
3840 && ri->type == ZEBRA_ROUTE_BGP
3841 && ri->sub_type == BGP_ROUTE_STATIC)
3842 break;
3843
3844 /* Withdraw static BGP route from routing table. */
3845 if (ri)
3846 {
3847 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003848 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003849 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003850 }
3851
3852 /* Unlock bgp_node_lookup. */
3853 bgp_unlock_node (rn);
3854}
3855
Lou Bergera76d9ca2016-01-12 13:41:53 -05003856static void
3857bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3858 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3859{
3860 struct bgp_node *rn;
3861 struct bgp_info *new;
3862 struct attr *attr_new;
3863 struct attr attr = { 0 };
3864 struct bgp_info *ri;
3865
3866 assert (bgp_static);
3867
3868 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3869
3870 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3871
3872 attr.nexthop = bgp_static->igpnexthop;
3873 attr.med = bgp_static->igpmetric;
3874 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3875
3876 /* Apply route-map. */
3877 if (bgp_static->rmap.name)
3878 {
3879 struct attr attr_tmp = attr;
3880 struct bgp_info info;
3881 int ret;
3882
3883 info.peer = bgp->peer_self;
3884 info.attr = &attr_tmp;
3885
3886 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3887
3888 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3889
3890 bgp->peer_self->rmap_type = 0;
3891
3892 if (ret == RMAP_DENYMATCH)
3893 {
3894 /* Free uninterned attribute. */
3895 bgp_attr_flush (&attr_tmp);
3896
3897 /* Unintern original. */
3898 aspath_unintern (&attr.aspath);
3899 bgp_attr_extra_free (&attr);
3900 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3901 bgp_static->tag);
3902 return;
3903 }
3904
3905 attr_new = bgp_attr_intern (&attr_tmp);
3906 }
3907 else
3908 {
3909 attr_new = bgp_attr_intern (&attr);
3910 }
3911
3912 for (ri = rn->info; ri; ri = ri->next)
3913 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3914 && ri->sub_type == BGP_ROUTE_STATIC)
3915 break;
3916
3917 if (ri)
3918 {
3919 if (attrhash_cmp (ri->attr, attr_new) &&
3920 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3921 {
3922 bgp_unlock_node (rn);
3923 bgp_attr_unintern (&attr_new);
3924 aspath_unintern (&attr.aspath);
3925 bgp_attr_extra_free (&attr);
3926 return;
3927 }
3928 else
3929 {
3930 /* The attribute is changed. */
3931 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3932
3933 /* Rewrite BGP route information. */
3934 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3935 bgp_info_restore(rn, ri);
3936 else
3937 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3938 bgp_attr_unintern (&ri->attr);
3939 ri->attr = attr_new;
3940 ri->uptime = bgp_clock ();
3941
3942 /* Process change. */
3943 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3944 bgp_process (bgp, rn, afi, safi);
3945 bgp_unlock_node (rn);
3946 aspath_unintern (&attr.aspath);
3947 bgp_attr_extra_free (&attr);
3948 return;
3949 }
3950 }
3951
3952
3953 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003954 new = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
3955 attr_new, rn);
Lou Bergera76d9ca2016-01-12 13:41:53 -05003956 SET_FLAG (new->flags, BGP_INFO_VALID);
Lou Bergera76d9ca2016-01-12 13:41:53 -05003957 new->extra = bgp_info_extra_new();
3958 memcpy (new->extra->tag, bgp_static->tag, 3);
3959
3960 /* Aggregate address increment. */
3961 bgp_aggregate_increment (bgp, p, new, afi, safi);
3962
3963 /* Register new BGP information. */
3964 bgp_info_add (rn, new);
3965
3966 /* route_node_get lock */
3967 bgp_unlock_node (rn);
3968
3969 /* Process change. */
3970 bgp_process (bgp, rn, afi, safi);
3971
3972 /* Unintern original. */
3973 aspath_unintern (&attr.aspath);
3974 bgp_attr_extra_free (&attr);
3975}
3976
paul718e3742002-12-13 20:15:29 +00003977/* Configure static BGP network. When user don't run zebra, static
3978 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003979static int
paulfd79ac92004-10-13 05:06:08 +00003980bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003981 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003982{
3983 int ret;
3984 struct prefix p;
3985 struct bgp_static *bgp_static;
3986 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003987 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003988
3989 /* Convert IP prefix string to struct prefix. */
3990 ret = str2prefix (ip_str, &p);
3991 if (! ret)
3992 {
3993 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3994 return CMD_WARNING;
3995 }
paul718e3742002-12-13 20:15:29 +00003996 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3997 {
3998 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3999 VTY_NEWLINE);
4000 return CMD_WARNING;
4001 }
paul718e3742002-12-13 20:15:29 +00004002
4003 apply_mask (&p);
4004
4005 /* Set BGP static route configuration. */
4006 rn = bgp_node_get (bgp->route[afi][safi], &p);
4007
4008 if (rn->info)
4009 {
4010 /* Configuration change. */
4011 bgp_static = rn->info;
4012
4013 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004014 if (bgp_static->valid && bgp_static->backdoor != backdoor)
4015 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00004016
paul718e3742002-12-13 20:15:29 +00004017 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00004018
paul718e3742002-12-13 20:15:29 +00004019 if (rmap)
4020 {
4021 if (bgp_static->rmap.name)
4022 free (bgp_static->rmap.name);
4023 bgp_static->rmap.name = strdup (rmap);
4024 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4025 }
4026 else
4027 {
4028 if (bgp_static->rmap.name)
4029 free (bgp_static->rmap.name);
4030 bgp_static->rmap.name = NULL;
4031 bgp_static->rmap.map = NULL;
4032 bgp_static->valid = 0;
4033 }
4034 bgp_unlock_node (rn);
4035 }
4036 else
4037 {
4038 /* New configuration. */
4039 bgp_static = bgp_static_new ();
4040 bgp_static->backdoor = backdoor;
4041 bgp_static->valid = 0;
4042 bgp_static->igpmetric = 0;
4043 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00004044
paul718e3742002-12-13 20:15:29 +00004045 if (rmap)
4046 {
4047 if (bgp_static->rmap.name)
4048 free (bgp_static->rmap.name);
4049 bgp_static->rmap.name = strdup (rmap);
4050 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4051 }
4052 rn->info = bgp_static;
4053 }
4054
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07004055 bgp_static->valid = 1;
4056 if (need_update)
4057 bgp_static_withdraw (bgp, &p, afi, safi);
paul718e3742002-12-13 20:15:29 +00004058
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07004059 if (! bgp_static->backdoor)
4060 bgp_static_update (bgp, &p, bgp_static, afi, safi);
paul718e3742002-12-13 20:15:29 +00004061
4062 return CMD_SUCCESS;
4063}
4064
4065/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00004066static int
paulfd79ac92004-10-13 05:06:08 +00004067bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004068 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004069{
4070 int ret;
4071 struct prefix p;
4072 struct bgp_static *bgp_static;
4073 struct bgp_node *rn;
4074
4075 /* Convert IP prefix string to struct prefix. */
4076 ret = str2prefix (ip_str, &p);
4077 if (! ret)
4078 {
4079 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4080 return CMD_WARNING;
4081 }
paul718e3742002-12-13 20:15:29 +00004082 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4083 {
4084 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4085 VTY_NEWLINE);
4086 return CMD_WARNING;
4087 }
paul718e3742002-12-13 20:15:29 +00004088
4089 apply_mask (&p);
4090
4091 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4092 if (! rn)
4093 {
4094 vty_out (vty, "%% Can't find specified static route configuration.%s",
4095 VTY_NEWLINE);
4096 return CMD_WARNING;
4097 }
4098
4099 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004100
paul718e3742002-12-13 20:15:29 +00004101 /* Update BGP RIB. */
4102 if (! bgp_static->backdoor)
4103 bgp_static_withdraw (bgp, &p, afi, safi);
4104
4105 /* Clear configuration. */
4106 bgp_static_free (bgp_static);
4107 rn->info = NULL;
4108 bgp_unlock_node (rn);
4109 bgp_unlock_node (rn);
4110
4111 return CMD_SUCCESS;
4112}
4113
4114/* Called from bgp_delete(). Delete all static routes from the BGP
4115 instance. */
4116void
4117bgp_static_delete (struct bgp *bgp)
4118{
4119 afi_t afi;
4120 safi_t safi;
4121 struct bgp_node *rn;
4122 struct bgp_node *rm;
4123 struct bgp_table *table;
4124 struct bgp_static *bgp_static;
4125
4126 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4127 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4128 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4129 if (rn->info != NULL)
4130 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004131 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004132 {
4133 table = rn->info;
4134
4135 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4136 {
4137 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004138 bgp_static_withdraw_safi (bgp, &rm->p,
4139 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004140 (struct prefix_rd *)&rn->p,
4141 bgp_static->tag);
4142 bgp_static_free (bgp_static);
4143 rn->info = NULL;
4144 bgp_unlock_node (rn);
4145 }
4146 }
4147 else
4148 {
4149 bgp_static = rn->info;
4150 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4151 bgp_static_free (bgp_static);
4152 rn->info = NULL;
4153 bgp_unlock_node (rn);
4154 }
4155 }
4156}
4157
Lou Bergera76d9ca2016-01-12 13:41:53 -05004158/*
4159 * gpz 110624
4160 * Currently this is used to set static routes for VPN and ENCAP.
4161 * I think it can probably be factored with bgp_static_set.
4162 */
paul718e3742002-12-13 20:15:29 +00004163int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004164bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4165 const char *rd_str, const char *tag_str,
4166 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004167{
4168 int ret;
4169 struct prefix p;
4170 struct prefix_rd prd;
4171 struct bgp *bgp;
4172 struct bgp_node *prn;
4173 struct bgp_node *rn;
4174 struct bgp_table *table;
4175 struct bgp_static *bgp_static;
4176 u_char tag[3];
4177
4178 bgp = vty->index;
4179
4180 ret = str2prefix (ip_str, &p);
4181 if (! ret)
4182 {
4183 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4184 return CMD_WARNING;
4185 }
4186 apply_mask (&p);
4187
4188 ret = str2prefix_rd (rd_str, &prd);
4189 if (! ret)
4190 {
4191 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4192 return CMD_WARNING;
4193 }
4194
4195 ret = str2tag (tag_str, tag);
4196 if (! ret)
4197 {
4198 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4199 return CMD_WARNING;
4200 }
4201
Lou Bergera76d9ca2016-01-12 13:41:53 -05004202 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004203 (struct prefix *)&prd);
4204 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004205 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004206 else
4207 bgp_unlock_node (prn);
4208 table = prn->info;
4209
4210 rn = bgp_node_get (table, &p);
4211
4212 if (rn->info)
4213 {
4214 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4215 bgp_unlock_node (rn);
4216 }
4217 else
4218 {
4219 /* New configuration. */
4220 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004221 bgp_static->backdoor = 0;
4222 bgp_static->valid = 0;
4223 bgp_static->igpmetric = 0;
4224 bgp_static->igpnexthop.s_addr = 0;
4225 memcpy(bgp_static->tag, tag, 3);
4226 bgp_static->prd = prd;
4227
4228 if (rmap_str)
4229 {
4230 if (bgp_static->rmap.name)
4231 free (bgp_static->rmap.name);
4232 bgp_static->rmap.name = strdup (rmap_str);
4233 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4234 }
paul718e3742002-12-13 20:15:29 +00004235 rn->info = bgp_static;
4236
Lou Bergera76d9ca2016-01-12 13:41:53 -05004237 bgp_static->valid = 1;
4238 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004239 }
4240
4241 return CMD_SUCCESS;
4242}
4243
4244/* Configure static BGP network. */
4245int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004246bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4247 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004248{
4249 int ret;
4250 struct bgp *bgp;
4251 struct prefix p;
4252 struct prefix_rd prd;
4253 struct bgp_node *prn;
4254 struct bgp_node *rn;
4255 struct bgp_table *table;
4256 struct bgp_static *bgp_static;
4257 u_char tag[3];
4258
4259 bgp = vty->index;
4260
4261 /* Convert IP prefix string to struct prefix. */
4262 ret = str2prefix (ip_str, &p);
4263 if (! ret)
4264 {
4265 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4266 return CMD_WARNING;
4267 }
4268 apply_mask (&p);
4269
4270 ret = str2prefix_rd (rd_str, &prd);
4271 if (! ret)
4272 {
4273 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4274 return CMD_WARNING;
4275 }
4276
4277 ret = str2tag (tag_str, tag);
4278 if (! ret)
4279 {
4280 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4281 return CMD_WARNING;
4282 }
4283
Lou Bergera76d9ca2016-01-12 13:41:53 -05004284 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004285 (struct prefix *)&prd);
4286 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004287 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004288 else
4289 bgp_unlock_node (prn);
4290 table = prn->info;
4291
4292 rn = bgp_node_lookup (table, &p);
4293
4294 if (rn)
4295 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004296 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004297
4298 bgp_static = rn->info;
4299 bgp_static_free (bgp_static);
4300 rn->info = NULL;
4301 bgp_unlock_node (rn);
4302 bgp_unlock_node (rn);
4303 }
4304 else
4305 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4306
4307 return CMD_SUCCESS;
4308}
David Lamparter6b0655a2014-06-04 06:53:35 +02004309
paul718e3742002-12-13 20:15:29 +00004310DEFUN (bgp_network,
4311 bgp_network_cmd,
4312 "network A.B.C.D/M",
4313 "Specify a network to announce via BGP\n"
4314 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4315{
4316 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004317 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004318}
4319
4320DEFUN (bgp_network_route_map,
4321 bgp_network_route_map_cmd,
4322 "network A.B.C.D/M route-map WORD",
4323 "Specify a network to announce via BGP\n"
4324 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4325 "Route-map to modify the attributes\n"
4326 "Name of the route map\n")
4327{
4328 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004329 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004330}
4331
4332DEFUN (bgp_network_backdoor,
4333 bgp_network_backdoor_cmd,
4334 "network A.B.C.D/M backdoor",
4335 "Specify a network to announce via BGP\n"
4336 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4337 "Specify a BGP backdoor route\n")
4338{
Paul Jakma41367172007-08-06 15:24:51 +00004339 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004340 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004341}
4342
4343DEFUN (bgp_network_mask,
4344 bgp_network_mask_cmd,
4345 "network A.B.C.D mask A.B.C.D",
4346 "Specify a network to announce via BGP\n"
4347 "Network number\n"
4348 "Network mask\n"
4349 "Network mask\n")
4350{
4351 int ret;
4352 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004353
paul718e3742002-12-13 20:15:29 +00004354 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4355 if (! ret)
4356 {
4357 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4358 return CMD_WARNING;
4359 }
4360
4361 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004362 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004363}
4364
4365DEFUN (bgp_network_mask_route_map,
4366 bgp_network_mask_route_map_cmd,
4367 "network A.B.C.D mask A.B.C.D route-map WORD",
4368 "Specify a network to announce via BGP\n"
4369 "Network number\n"
4370 "Network mask\n"
4371 "Network mask\n"
4372 "Route-map to modify the attributes\n"
4373 "Name of the route map\n")
4374{
4375 int ret;
4376 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004377
paul718e3742002-12-13 20:15:29 +00004378 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4379 if (! ret)
4380 {
4381 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4382 return CMD_WARNING;
4383 }
4384
4385 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004386 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004387}
4388
4389DEFUN (bgp_network_mask_backdoor,
4390 bgp_network_mask_backdoor_cmd,
4391 "network A.B.C.D mask A.B.C.D backdoor",
4392 "Specify a network to announce via BGP\n"
4393 "Network number\n"
4394 "Network mask\n"
4395 "Network mask\n"
4396 "Specify a BGP backdoor route\n")
4397{
4398 int ret;
4399 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004400
paul718e3742002-12-13 20:15:29 +00004401 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4402 if (! ret)
4403 {
4404 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4405 return CMD_WARNING;
4406 }
4407
Paul Jakma41367172007-08-06 15:24:51 +00004408 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004409 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004410}
4411
4412DEFUN (bgp_network_mask_natural,
4413 bgp_network_mask_natural_cmd,
4414 "network A.B.C.D",
4415 "Specify a network to announce via BGP\n"
4416 "Network number\n")
4417{
4418 int ret;
4419 char prefix_str[BUFSIZ];
4420
4421 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4422 if (! ret)
4423 {
4424 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4425 return CMD_WARNING;
4426 }
4427
4428 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004429 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004430}
4431
4432DEFUN (bgp_network_mask_natural_route_map,
4433 bgp_network_mask_natural_route_map_cmd,
4434 "network A.B.C.D route-map WORD",
4435 "Specify a network to announce via BGP\n"
4436 "Network number\n"
4437 "Route-map to modify the attributes\n"
4438 "Name of the route map\n")
4439{
4440 int ret;
4441 char prefix_str[BUFSIZ];
4442
4443 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4444 if (! ret)
4445 {
4446 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4447 return CMD_WARNING;
4448 }
4449
4450 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004451 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004452}
4453
4454DEFUN (bgp_network_mask_natural_backdoor,
4455 bgp_network_mask_natural_backdoor_cmd,
4456 "network A.B.C.D backdoor",
4457 "Specify a network to announce via BGP\n"
4458 "Network number\n"
4459 "Specify a BGP backdoor route\n")
4460{
4461 int ret;
4462 char prefix_str[BUFSIZ];
4463
4464 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4465 if (! ret)
4466 {
4467 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4468 return CMD_WARNING;
4469 }
4470
Paul Jakma41367172007-08-06 15:24:51 +00004471 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004472 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004473}
4474
4475DEFUN (no_bgp_network,
4476 no_bgp_network_cmd,
4477 "no network A.B.C.D/M",
4478 NO_STR
4479 "Specify a network to announce via BGP\n"
4480 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4481{
4482 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4483 bgp_node_safi (vty));
4484}
4485
4486ALIAS (no_bgp_network,
4487 no_bgp_network_route_map_cmd,
4488 "no network A.B.C.D/M route-map WORD",
4489 NO_STR
4490 "Specify a network to announce via BGP\n"
4491 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4492 "Route-map to modify the attributes\n"
4493 "Name of the route map\n")
4494
4495ALIAS (no_bgp_network,
4496 no_bgp_network_backdoor_cmd,
4497 "no network A.B.C.D/M backdoor",
4498 NO_STR
4499 "Specify a network to announce via BGP\n"
4500 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4501 "Specify a BGP backdoor route\n")
4502
4503DEFUN (no_bgp_network_mask,
4504 no_bgp_network_mask_cmd,
4505 "no network A.B.C.D mask A.B.C.D",
4506 NO_STR
4507 "Specify a network to announce via BGP\n"
4508 "Network number\n"
4509 "Network mask\n"
4510 "Network mask\n")
4511{
4512 int ret;
4513 char prefix_str[BUFSIZ];
4514
4515 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4516 if (! ret)
4517 {
4518 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4519 return CMD_WARNING;
4520 }
4521
4522 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4523 bgp_node_safi (vty));
4524}
4525
4526ALIAS (no_bgp_network_mask,
4527 no_bgp_network_mask_route_map_cmd,
4528 "no network A.B.C.D mask A.B.C.D route-map WORD",
4529 NO_STR
4530 "Specify a network to announce via BGP\n"
4531 "Network number\n"
4532 "Network mask\n"
4533 "Network mask\n"
4534 "Route-map to modify the attributes\n"
4535 "Name of the route map\n")
4536
4537ALIAS (no_bgp_network_mask,
4538 no_bgp_network_mask_backdoor_cmd,
4539 "no network A.B.C.D mask A.B.C.D backdoor",
4540 NO_STR
4541 "Specify a network to announce via BGP\n"
4542 "Network number\n"
4543 "Network mask\n"
4544 "Network mask\n"
4545 "Specify a BGP backdoor route\n")
4546
4547DEFUN (no_bgp_network_mask_natural,
4548 no_bgp_network_mask_natural_cmd,
4549 "no network A.B.C.D",
4550 NO_STR
4551 "Specify a network to announce via BGP\n"
4552 "Network number\n")
4553{
4554 int ret;
4555 char prefix_str[BUFSIZ];
4556
4557 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4558 if (! ret)
4559 {
4560 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4561 return CMD_WARNING;
4562 }
4563
4564 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4565 bgp_node_safi (vty));
4566}
4567
4568ALIAS (no_bgp_network_mask_natural,
4569 no_bgp_network_mask_natural_route_map_cmd,
4570 "no network A.B.C.D route-map WORD",
4571 NO_STR
4572 "Specify a network to announce via BGP\n"
4573 "Network number\n"
4574 "Route-map to modify the attributes\n"
4575 "Name of the route map\n")
4576
4577ALIAS (no_bgp_network_mask_natural,
4578 no_bgp_network_mask_natural_backdoor_cmd,
4579 "no network A.B.C.D backdoor",
4580 NO_STR
4581 "Specify a network to announce via BGP\n"
4582 "Network number\n"
4583 "Specify a BGP backdoor route\n")
4584
paul718e3742002-12-13 20:15:29 +00004585DEFUN (ipv6_bgp_network,
4586 ipv6_bgp_network_cmd,
4587 "network X:X::X:X/M",
4588 "Specify a network to announce via BGP\n"
4589 "IPv6 prefix <network>/<length>\n")
4590{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304591 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004592 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004593}
4594
4595DEFUN (ipv6_bgp_network_route_map,
4596 ipv6_bgp_network_route_map_cmd,
4597 "network X:X::X:X/M route-map WORD",
4598 "Specify a network to announce via BGP\n"
4599 "IPv6 prefix <network>/<length>\n"
4600 "Route-map to modify the attributes\n"
4601 "Name of the route map\n")
4602{
4603 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004604 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004605}
4606
4607DEFUN (no_ipv6_bgp_network,
4608 no_ipv6_bgp_network_cmd,
4609 "no network X:X::X:X/M",
4610 NO_STR
4611 "Specify a network to announce via BGP\n"
4612 "IPv6 prefix <network>/<length>\n")
4613{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304614 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004615}
4616
4617ALIAS (no_ipv6_bgp_network,
4618 no_ipv6_bgp_network_route_map_cmd,
4619 "no network X:X::X:X/M route-map WORD",
4620 NO_STR
4621 "Specify a network to announce via BGP\n"
4622 "IPv6 prefix <network>/<length>\n"
4623 "Route-map to modify the attributes\n"
4624 "Name of the route map\n")
4625
4626ALIAS (ipv6_bgp_network,
4627 old_ipv6_bgp_network_cmd,
4628 "ipv6 bgp network X:X::X:X/M",
4629 IPV6_STR
4630 BGP_STR
4631 "Specify a network to announce via BGP\n"
4632 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4633
4634ALIAS (no_ipv6_bgp_network,
4635 old_no_ipv6_bgp_network_cmd,
4636 "no ipv6 bgp network X:X::X:X/M",
4637 NO_STR
4638 IPV6_STR
4639 BGP_STR
4640 "Specify a network to announce via BGP\n"
4641 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004642
4643/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4644ALIAS_DEPRECATED (bgp_network,
4645 bgp_network_ttl_cmd,
4646 "network A.B.C.D/M pathlimit <0-255>",
4647 "Specify a network to announce via BGP\n"
4648 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4649 "AS-Path hopcount limit attribute\n"
4650 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4651ALIAS_DEPRECATED (bgp_network_backdoor,
4652 bgp_network_backdoor_ttl_cmd,
4653 "network A.B.C.D/M backdoor pathlimit <0-255>",
4654 "Specify a network to announce via BGP\n"
4655 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4656 "Specify a BGP backdoor route\n"
4657 "AS-Path hopcount limit attribute\n"
4658 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4659ALIAS_DEPRECATED (bgp_network_mask,
4660 bgp_network_mask_ttl_cmd,
4661 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4662 "Specify a network to announce via BGP\n"
4663 "Network number\n"
4664 "Network mask\n"
4665 "Network mask\n"
4666 "AS-Path hopcount limit attribute\n"
4667 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4668ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4669 bgp_network_mask_backdoor_ttl_cmd,
4670 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4671 "Specify a network to announce via BGP\n"
4672 "Network number\n"
4673 "Network mask\n"
4674 "Network mask\n"
4675 "Specify a BGP backdoor route\n"
4676 "AS-Path hopcount limit attribute\n"
4677 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4678ALIAS_DEPRECATED (bgp_network_mask_natural,
4679 bgp_network_mask_natural_ttl_cmd,
4680 "network A.B.C.D pathlimit <0-255>",
4681 "Specify a network to announce via BGP\n"
4682 "Network number\n"
4683 "AS-Path hopcount limit attribute\n"
4684 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4685ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4686 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004687 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004688 "Specify a network to announce via BGP\n"
4689 "Network number\n"
4690 "Specify a BGP backdoor route\n"
4691 "AS-Path hopcount limit attribute\n"
4692 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4693ALIAS_DEPRECATED (no_bgp_network,
4694 no_bgp_network_ttl_cmd,
4695 "no network A.B.C.D/M pathlimit <0-255>",
4696 NO_STR
4697 "Specify a network to announce via BGP\n"
4698 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4699 "AS-Path hopcount limit attribute\n"
4700 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4701ALIAS_DEPRECATED (no_bgp_network,
4702 no_bgp_network_backdoor_ttl_cmd,
4703 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4704 NO_STR
4705 "Specify a network to announce via BGP\n"
4706 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4707 "Specify a BGP backdoor route\n"
4708 "AS-Path hopcount limit attribute\n"
4709 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4710ALIAS_DEPRECATED (no_bgp_network,
4711 no_bgp_network_mask_ttl_cmd,
4712 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4713 NO_STR
4714 "Specify a network to announce via BGP\n"
4715 "Network number\n"
4716 "Network mask\n"
4717 "Network mask\n"
4718 "AS-Path hopcount limit attribute\n"
4719 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4720ALIAS_DEPRECATED (no_bgp_network_mask,
4721 no_bgp_network_mask_backdoor_ttl_cmd,
4722 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4723 NO_STR
4724 "Specify a network to announce via BGP\n"
4725 "Network number\n"
4726 "Network mask\n"
4727 "Network mask\n"
4728 "Specify a BGP backdoor route\n"
4729 "AS-Path hopcount limit attribute\n"
4730 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4731ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4732 no_bgp_network_mask_natural_ttl_cmd,
4733 "no network A.B.C.D pathlimit <0-255>",
4734 NO_STR
4735 "Specify a network to announce via BGP\n"
4736 "Network number\n"
4737 "AS-Path hopcount limit attribute\n"
4738 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4739ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4740 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4741 "no network A.B.C.D backdoor pathlimit <0-255>",
4742 NO_STR
4743 "Specify a network to announce via BGP\n"
4744 "Network number\n"
4745 "Specify a BGP backdoor route\n"
4746 "AS-Path hopcount limit attribute\n"
4747 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4748ALIAS_DEPRECATED (ipv6_bgp_network,
4749 ipv6_bgp_network_ttl_cmd,
4750 "network X:X::X:X/M pathlimit <0-255>",
4751 "Specify a network to announce via BGP\n"
4752 "IPv6 prefix <network>/<length>\n"
4753 "AS-Path hopcount limit attribute\n"
4754 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4755ALIAS_DEPRECATED (no_ipv6_bgp_network,
4756 no_ipv6_bgp_network_ttl_cmd,
4757 "no network X:X::X:X/M pathlimit <0-255>",
4758 NO_STR
4759 "Specify a network to announce via BGP\n"
4760 "IPv6 prefix <network>/<length>\n"
4761 "AS-Path hopcount limit attribute\n"
4762 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004763
paul718e3742002-12-13 20:15:29 +00004764/* Aggreagete address:
4765
4766 advertise-map Set condition to advertise attribute
4767 as-set Generate AS set path information
4768 attribute-map Set attributes of aggregate
4769 route-map Set parameters of aggregate
4770 summary-only Filter more specific routes from updates
4771 suppress-map Conditionally filter more specific routes from updates
4772 <cr>
4773 */
4774struct bgp_aggregate
4775{
4776 /* Summary-only flag. */
4777 u_char summary_only;
4778
4779 /* AS set generation. */
4780 u_char as_set;
4781
4782 /* Route-map for aggregated route. */
4783 struct route_map *map;
4784
4785 /* Suppress-count. */
4786 unsigned long count;
4787
4788 /* SAFI configuration. */
4789 safi_t safi;
4790};
4791
paul94f2b392005-06-28 12:44:16 +00004792static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004793bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004794{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004795 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004796}
4797
paul94f2b392005-06-28 12:44:16 +00004798static void
paul718e3742002-12-13 20:15:29 +00004799bgp_aggregate_free (struct bgp_aggregate *aggregate)
4800{
4801 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4802}
4803
Daniel Walton76a72802015-05-19 17:47:24 -07004804/* Update an aggregate as routes are added/removed from the BGP table */
paul94f2b392005-06-28 12:44:16 +00004805static void
paul718e3742002-12-13 20:15:29 +00004806bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4807 afi_t afi, safi_t safi, struct bgp_info *del,
4808 struct bgp_aggregate *aggregate)
4809{
4810 struct bgp_table *table;
4811 struct bgp_node *top;
4812 struct bgp_node *rn;
4813 u_char origin;
4814 struct aspath *aspath = NULL;
4815 struct aspath *asmerge = NULL;
4816 struct community *community = NULL;
4817 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004818 struct bgp_info *ri;
4819 struct bgp_info *new;
4820 int first = 1;
4821 unsigned long match = 0;
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004822 u_char atomic_aggregate = 0;
paul718e3742002-12-13 20:15:29 +00004823
paul718e3742002-12-13 20:15:29 +00004824 /* ORIGIN attribute: If at least one route among routes that are
4825 aggregated has ORIGIN with the value INCOMPLETE, then the
4826 aggregated route must have the ORIGIN attribute with the value
4827 INCOMPLETE. Otherwise, if at least one route among routes that
4828 are aggregated has ORIGIN with the value EGP, then the aggregated
4829 route must have the origin attribute with the value EGP. In all
4830 other case the value of the ORIGIN attribute of the aggregated
4831 route is INTERNAL. */
4832 origin = BGP_ORIGIN_IGP;
4833
4834 table = bgp->rib[afi][safi];
4835
4836 top = bgp_node_get (table, p);
4837 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4838 if (rn->p.prefixlen > p->prefixlen)
4839 {
4840 match = 0;
4841
4842 for (ri = rn->info; ri; ri = ri->next)
4843 {
4844 if (BGP_INFO_HOLDDOWN (ri))
4845 continue;
4846
4847 if (del && ri == del)
4848 continue;
4849
4850 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004851 first = 0;
paul718e3742002-12-13 20:15:29 +00004852
4853#ifdef AGGREGATE_NEXTHOP_CHECK
4854 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4855 || ri->attr->med != med)
4856 {
4857 if (aspath)
4858 aspath_free (aspath);
4859 if (community)
4860 community_free (community);
4861 bgp_unlock_node (rn);
4862 bgp_unlock_node (top);
4863 return;
4864 }
4865#endif /* AGGREGATE_NEXTHOP_CHECK */
4866
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004867 if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
4868 atomic_aggregate = 1;
4869
paul718e3742002-12-13 20:15:29 +00004870 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4871 {
4872 if (aggregate->summary_only)
4873 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004874 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004875 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004876 match++;
4877 }
4878
4879 aggregate->count++;
4880
Daniel Walton76a72802015-05-19 17:47:24 -07004881 if (origin < ri->attr->origin)
4882 origin = ri->attr->origin;
4883
paul718e3742002-12-13 20:15:29 +00004884 if (aggregate->as_set)
4885 {
paul718e3742002-12-13 20:15:29 +00004886 if (aspath)
4887 {
4888 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4889 aspath_free (aspath);
4890 aspath = asmerge;
4891 }
4892 else
4893 aspath = aspath_dup (ri->attr->aspath);
4894
4895 if (ri->attr->community)
4896 {
4897 if (community)
4898 {
4899 commerge = community_merge (community,
4900 ri->attr->community);
4901 community = community_uniq_sort (commerge);
4902 community_free (commerge);
4903 }
4904 else
4905 community = community_dup (ri->attr->community);
4906 }
4907 }
4908 }
4909 }
4910 if (match)
4911 bgp_process (bgp, rn, afi, safi);
4912 }
4913 bgp_unlock_node (top);
4914
4915 if (rinew)
4916 {
4917 aggregate->count++;
4918
4919 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004920 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004921
Daniel Walton76a72802015-05-19 17:47:24 -07004922 if (origin < rinew->attr->origin)
4923 origin = rinew->attr->origin;
4924
paul718e3742002-12-13 20:15:29 +00004925 if (aggregate->as_set)
4926 {
paul718e3742002-12-13 20:15:29 +00004927 if (aspath)
4928 {
4929 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4930 aspath_free (aspath);
4931 aspath = asmerge;
4932 }
4933 else
4934 aspath = aspath_dup (rinew->attr->aspath);
4935
4936 if (rinew->attr->community)
4937 {
4938 if (community)
4939 {
4940 commerge = community_merge (community,
4941 rinew->attr->community);
4942 community = community_uniq_sort (commerge);
4943 community_free (commerge);
4944 }
4945 else
4946 community = community_dup (rinew->attr->community);
4947 }
4948 }
4949 }
4950
4951 if (aggregate->count > 0)
4952 {
4953 rn = bgp_node_get (table, p);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05004954 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
4955 bgp_attr_aggregate_intern(bgp, origin, aspath, community,
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004956 aggregate->as_set,
4957 atomic_aggregate), rn);
paul718e3742002-12-13 20:15:29 +00004958 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00004959
4960 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004961 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004962 bgp_process (bgp, rn, afi, safi);
4963 }
4964 else
4965 {
4966 if (aspath)
4967 aspath_free (aspath);
4968 if (community)
4969 community_free (community);
4970 }
4971}
4972
4973void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4974 struct bgp_aggregate *);
4975
4976void
4977bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4978 struct bgp_info *ri, afi_t afi, safi_t safi)
4979{
4980 struct bgp_node *child;
4981 struct bgp_node *rn;
4982 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004983 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004984
4985 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004986 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004987 return;
4988
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004989 table = bgp->aggregate[afi][safi];
4990
4991 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004992 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004993 return;
4994
paul718e3742002-12-13 20:15:29 +00004995 if (p->prefixlen == 0)
4996 return;
4997
4998 if (BGP_INFO_HOLDDOWN (ri))
4999 return;
5000
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02005001 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00005002
5003 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005004 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005005 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5006 {
5007 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005008 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00005009 }
5010 bgp_unlock_node (child);
5011}
5012
5013void
5014bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
5015 struct bgp_info *del, afi_t afi, safi_t safi)
5016{
5017 struct bgp_node *child;
5018 struct bgp_node *rn;
5019 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005020 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00005021
5022 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05005023 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00005024 return;
5025
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005026 table = bgp->aggregate[afi][safi];
5027
5028 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005029 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005030 return;
5031
paul718e3742002-12-13 20:15:29 +00005032 if (p->prefixlen == 0)
5033 return;
5034
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02005035 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00005036
5037 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005038 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005039 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5040 {
5041 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005042 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00005043 }
5044 bgp_unlock_node (child);
5045}
5046
Daniel Walton76a72802015-05-19 17:47:24 -07005047/* Called via bgp_aggregate_set when the user configures aggregate-address */
paul94f2b392005-06-28 12:44:16 +00005048static void
paul718e3742002-12-13 20:15:29 +00005049bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
5050 struct bgp_aggregate *aggregate)
5051{
5052 struct bgp_table *table;
5053 struct bgp_node *top;
5054 struct bgp_node *rn;
5055 struct bgp_info *new;
5056 struct bgp_info *ri;
5057 unsigned long match;
5058 u_char origin = BGP_ORIGIN_IGP;
5059 struct aspath *aspath = NULL;
5060 struct aspath *asmerge = NULL;
5061 struct community *community = NULL;
5062 struct community *commerge = NULL;
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005063 u_char atomic_aggregate = 0;
paul718e3742002-12-13 20:15:29 +00005064
5065 table = bgp->rib[afi][safi];
5066
5067 /* Sanity check. */
5068 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5069 return;
5070 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5071 return;
5072
5073 /* If routes exists below this node, generate aggregate routes. */
5074 top = bgp_node_get (table, p);
5075 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5076 if (rn->p.prefixlen > p->prefixlen)
5077 {
5078 match = 0;
5079
5080 for (ri = rn->info; ri; ri = ri->next)
5081 {
5082 if (BGP_INFO_HOLDDOWN (ri))
5083 continue;
5084
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005085 if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
5086 atomic_aggregate = 1;
5087
paul718e3742002-12-13 20:15:29 +00005088 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5089 {
5090 /* summary-only aggregate route suppress aggregated
5091 route announcement. */
5092 if (aggregate->summary_only)
5093 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005094 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005095 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005096 match++;
5097 }
Daniel Walton76a72802015-05-19 17:47:24 -07005098
5099 /* If at least one route among routes that are aggregated has
5100 * ORIGIN with the value INCOMPLETE, then the aggregated route
5101 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5102 * Otherwise, if at least one route among routes that are
5103 * aggregated has ORIGIN with the value EGP, then the aggregated
5104 * route MUST have the ORIGIN attribute with the value EGP.
5105 */
5106 if (origin < ri->attr->origin)
5107 origin = ri->attr->origin;
5108
paul718e3742002-12-13 20:15:29 +00005109 /* as-set aggregate route generate origin, as path,
5110 community aggregation. */
5111 if (aggregate->as_set)
5112 {
paul718e3742002-12-13 20:15:29 +00005113 if (aspath)
5114 {
5115 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5116 aspath_free (aspath);
5117 aspath = asmerge;
5118 }
5119 else
5120 aspath = aspath_dup (ri->attr->aspath);
5121
5122 if (ri->attr->community)
5123 {
5124 if (community)
5125 {
5126 commerge = community_merge (community,
5127 ri->attr->community);
5128 community = community_uniq_sort (commerge);
5129 community_free (commerge);
5130 }
5131 else
5132 community = community_dup (ri->attr->community);
5133 }
5134 }
5135 aggregate->count++;
5136 }
5137 }
5138
5139 /* If this node is suppressed, process the change. */
5140 if (match)
5141 bgp_process (bgp, rn, afi, safi);
5142 }
5143 bgp_unlock_node (top);
5144
5145 /* Add aggregate route to BGP table. */
5146 if (aggregate->count)
5147 {
5148 rn = bgp_node_get (table, p);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005149 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
5150 bgp_attr_aggregate_intern(bgp, origin, aspath, community,
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005151 aggregate->as_set,
5152 atomic_aggregate), rn);
paul718e3742002-12-13 20:15:29 +00005153 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00005154
5155 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005156 bgp_unlock_node (rn);
5157
paul718e3742002-12-13 20:15:29 +00005158 /* Process change. */
5159 bgp_process (bgp, rn, afi, safi);
5160 }
Denil Virae2a92582015-08-11 13:34:59 -07005161 else
5162 {
5163 if (aspath)
5164 aspath_free (aspath);
5165 if (community)
5166 community_free (community);
5167 }
paul718e3742002-12-13 20:15:29 +00005168}
5169
5170void
5171bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5172 safi_t safi, struct bgp_aggregate *aggregate)
5173{
5174 struct bgp_table *table;
5175 struct bgp_node *top;
5176 struct bgp_node *rn;
5177 struct bgp_info *ri;
5178 unsigned long match;
5179
5180 table = bgp->rib[afi][safi];
5181
5182 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5183 return;
5184 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5185 return;
5186
5187 /* If routes exists below this node, generate aggregate routes. */
5188 top = bgp_node_get (table, p);
5189 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5190 if (rn->p.prefixlen > p->prefixlen)
5191 {
5192 match = 0;
5193
5194 for (ri = rn->info; ri; ri = ri->next)
5195 {
5196 if (BGP_INFO_HOLDDOWN (ri))
5197 continue;
5198
5199 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5200 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005201 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005202 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005203 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005204
Paul Jakmafb982c22007-05-04 20:15:47 +00005205 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005206 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005207 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005208 match++;
5209 }
5210 }
5211 aggregate->count--;
5212 }
5213 }
5214
Paul Jakmafb982c22007-05-04 20:15:47 +00005215 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005216 if (match)
5217 bgp_process (bgp, rn, afi, safi);
5218 }
5219 bgp_unlock_node (top);
5220
5221 /* Delete aggregate route from BGP table. */
5222 rn = bgp_node_get (table, p);
5223
5224 for (ri = rn->info; ri; ri = ri->next)
5225 if (ri->peer == bgp->peer_self
5226 && ri->type == ZEBRA_ROUTE_BGP
5227 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5228 break;
5229
5230 /* Withdraw static BGP route from routing table. */
5231 if (ri)
5232 {
paul718e3742002-12-13 20:15:29 +00005233 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005234 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005235 }
5236
5237 /* Unlock bgp_node_lookup. */
5238 bgp_unlock_node (rn);
5239}
5240
5241/* Aggregate route attribute. */
5242#define AGGREGATE_SUMMARY_ONLY 1
5243#define AGGREGATE_AS_SET 1
5244
paul94f2b392005-06-28 12:44:16 +00005245static int
Robert Baysf6269b42010-08-05 10:26:28 -07005246bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5247 afi_t afi, safi_t safi)
5248{
5249 int ret;
5250 struct prefix p;
5251 struct bgp_node *rn;
5252 struct bgp *bgp;
5253 struct bgp_aggregate *aggregate;
5254
5255 /* Convert string to prefix structure. */
5256 ret = str2prefix (prefix_str, &p);
5257 if (!ret)
5258 {
5259 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5260 return CMD_WARNING;
5261 }
5262 apply_mask (&p);
5263
5264 /* Get BGP structure. */
5265 bgp = vty->index;
5266
5267 /* Old configuration check. */
5268 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5269 if (! rn)
5270 {
5271 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5272 VTY_NEWLINE);
5273 return CMD_WARNING;
5274 }
5275
5276 aggregate = rn->info;
5277 if (aggregate->safi & SAFI_UNICAST)
5278 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5279 if (aggregate->safi & SAFI_MULTICAST)
5280 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5281
5282 /* Unlock aggregate address configuration. */
5283 rn->info = NULL;
5284 bgp_aggregate_free (aggregate);
5285 bgp_unlock_node (rn);
5286 bgp_unlock_node (rn);
5287
5288 return CMD_SUCCESS;
5289}
5290
5291static int
5292bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005293 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005294 u_char summary_only, u_char as_set)
5295{
5296 int ret;
5297 struct prefix p;
5298 struct bgp_node *rn;
5299 struct bgp *bgp;
5300 struct bgp_aggregate *aggregate;
5301
5302 /* Convert string to prefix structure. */
5303 ret = str2prefix (prefix_str, &p);
5304 if (!ret)
5305 {
5306 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5307 return CMD_WARNING;
5308 }
5309 apply_mask (&p);
5310
5311 /* Get BGP structure. */
5312 bgp = vty->index;
5313
5314 /* Old configuration check. */
5315 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5316
5317 if (rn->info)
5318 {
5319 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005320 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005321 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5322 if (ret)
5323 {
Robert Bays368473f2010-08-05 10:26:29 -07005324 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5325 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005326 return CMD_WARNING;
5327 }
paul718e3742002-12-13 20:15:29 +00005328 }
5329
5330 /* Make aggregate address structure. */
5331 aggregate = bgp_aggregate_new ();
5332 aggregate->summary_only = summary_only;
5333 aggregate->as_set = as_set;
5334 aggregate->safi = safi;
5335 rn->info = aggregate;
5336
5337 /* Aggregate address insert into BGP routing table. */
5338 if (safi & SAFI_UNICAST)
5339 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5340 if (safi & SAFI_MULTICAST)
5341 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5342
5343 return CMD_SUCCESS;
5344}
5345
paul718e3742002-12-13 20:15:29 +00005346DEFUN (aggregate_address,
5347 aggregate_address_cmd,
5348 "aggregate-address A.B.C.D/M",
5349 "Configure BGP aggregate entries\n"
5350 "Aggregate prefix\n")
5351{
5352 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5353}
5354
5355DEFUN (aggregate_address_mask,
5356 aggregate_address_mask_cmd,
5357 "aggregate-address A.B.C.D A.B.C.D",
5358 "Configure BGP aggregate entries\n"
5359 "Aggregate address\n"
5360 "Aggregate mask\n")
5361{
5362 int ret;
5363 char prefix_str[BUFSIZ];
5364
5365 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5366
5367 if (! ret)
5368 {
5369 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5370 return CMD_WARNING;
5371 }
5372
5373 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5374 0, 0);
5375}
5376
5377DEFUN (aggregate_address_summary_only,
5378 aggregate_address_summary_only_cmd,
5379 "aggregate-address A.B.C.D/M summary-only",
5380 "Configure BGP aggregate entries\n"
5381 "Aggregate prefix\n"
5382 "Filter more specific routes from updates\n")
5383{
5384 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5385 AGGREGATE_SUMMARY_ONLY, 0);
5386}
5387
5388DEFUN (aggregate_address_mask_summary_only,
5389 aggregate_address_mask_summary_only_cmd,
5390 "aggregate-address A.B.C.D A.B.C.D summary-only",
5391 "Configure BGP aggregate entries\n"
5392 "Aggregate address\n"
5393 "Aggregate mask\n"
5394 "Filter more specific routes from updates\n")
5395{
5396 int ret;
5397 char prefix_str[BUFSIZ];
5398
5399 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5400
5401 if (! ret)
5402 {
5403 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5404 return CMD_WARNING;
5405 }
5406
5407 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5408 AGGREGATE_SUMMARY_ONLY, 0);
5409}
5410
5411DEFUN (aggregate_address_as_set,
5412 aggregate_address_as_set_cmd,
5413 "aggregate-address A.B.C.D/M as-set",
5414 "Configure BGP aggregate entries\n"
5415 "Aggregate prefix\n"
5416 "Generate AS set path information\n")
5417{
5418 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5419 0, AGGREGATE_AS_SET);
5420}
5421
5422DEFUN (aggregate_address_mask_as_set,
5423 aggregate_address_mask_as_set_cmd,
5424 "aggregate-address A.B.C.D A.B.C.D as-set",
5425 "Configure BGP aggregate entries\n"
5426 "Aggregate address\n"
5427 "Aggregate mask\n"
5428 "Generate AS set path information\n")
5429{
5430 int ret;
5431 char prefix_str[BUFSIZ];
5432
5433 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5434
5435 if (! ret)
5436 {
5437 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5438 return CMD_WARNING;
5439 }
5440
5441 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5442 0, AGGREGATE_AS_SET);
5443}
5444
5445
5446DEFUN (aggregate_address_as_set_summary,
5447 aggregate_address_as_set_summary_cmd,
5448 "aggregate-address A.B.C.D/M as-set summary-only",
5449 "Configure BGP aggregate entries\n"
5450 "Aggregate prefix\n"
5451 "Generate AS set path information\n"
5452 "Filter more specific routes from updates\n")
5453{
5454 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5455 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5456}
5457
5458ALIAS (aggregate_address_as_set_summary,
5459 aggregate_address_summary_as_set_cmd,
5460 "aggregate-address A.B.C.D/M summary-only as-set",
5461 "Configure BGP aggregate entries\n"
5462 "Aggregate prefix\n"
5463 "Filter more specific routes from updates\n"
5464 "Generate AS set path information\n")
5465
5466DEFUN (aggregate_address_mask_as_set_summary,
5467 aggregate_address_mask_as_set_summary_cmd,
5468 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5469 "Configure BGP aggregate entries\n"
5470 "Aggregate address\n"
5471 "Aggregate mask\n"
5472 "Generate AS set path information\n"
5473 "Filter more specific routes from updates\n")
5474{
5475 int ret;
5476 char prefix_str[BUFSIZ];
5477
5478 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5479
5480 if (! ret)
5481 {
5482 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5483 return CMD_WARNING;
5484 }
5485
5486 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5487 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5488}
5489
5490ALIAS (aggregate_address_mask_as_set_summary,
5491 aggregate_address_mask_summary_as_set_cmd,
5492 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5493 "Configure BGP aggregate entries\n"
5494 "Aggregate address\n"
5495 "Aggregate mask\n"
5496 "Filter more specific routes from updates\n"
5497 "Generate AS set path information\n")
5498
5499DEFUN (no_aggregate_address,
5500 no_aggregate_address_cmd,
5501 "no aggregate-address A.B.C.D/M",
5502 NO_STR
5503 "Configure BGP aggregate entries\n"
5504 "Aggregate prefix\n")
5505{
5506 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5507}
5508
5509ALIAS (no_aggregate_address,
5510 no_aggregate_address_summary_only_cmd,
5511 "no aggregate-address A.B.C.D/M summary-only",
5512 NO_STR
5513 "Configure BGP aggregate entries\n"
5514 "Aggregate prefix\n"
5515 "Filter more specific routes from updates\n")
5516
5517ALIAS (no_aggregate_address,
5518 no_aggregate_address_as_set_cmd,
5519 "no aggregate-address A.B.C.D/M as-set",
5520 NO_STR
5521 "Configure BGP aggregate entries\n"
5522 "Aggregate prefix\n"
5523 "Generate AS set path information\n")
5524
5525ALIAS (no_aggregate_address,
5526 no_aggregate_address_as_set_summary_cmd,
5527 "no aggregate-address A.B.C.D/M as-set summary-only",
5528 NO_STR
5529 "Configure BGP aggregate entries\n"
5530 "Aggregate prefix\n"
5531 "Generate AS set path information\n"
5532 "Filter more specific routes from updates\n")
5533
5534ALIAS (no_aggregate_address,
5535 no_aggregate_address_summary_as_set_cmd,
5536 "no aggregate-address A.B.C.D/M summary-only as-set",
5537 NO_STR
5538 "Configure BGP aggregate entries\n"
5539 "Aggregate prefix\n"
5540 "Filter more specific routes from updates\n"
5541 "Generate AS set path information\n")
5542
5543DEFUN (no_aggregate_address_mask,
5544 no_aggregate_address_mask_cmd,
5545 "no aggregate-address A.B.C.D A.B.C.D",
5546 NO_STR
5547 "Configure BGP aggregate entries\n"
5548 "Aggregate address\n"
5549 "Aggregate mask\n")
5550{
5551 int ret;
5552 char prefix_str[BUFSIZ];
5553
5554 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5555
5556 if (! ret)
5557 {
5558 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5559 return CMD_WARNING;
5560 }
5561
5562 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5563}
5564
5565ALIAS (no_aggregate_address_mask,
5566 no_aggregate_address_mask_summary_only_cmd,
5567 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5568 NO_STR
5569 "Configure BGP aggregate entries\n"
5570 "Aggregate address\n"
5571 "Aggregate mask\n"
5572 "Filter more specific routes from updates\n")
5573
5574ALIAS (no_aggregate_address_mask,
5575 no_aggregate_address_mask_as_set_cmd,
5576 "no aggregate-address A.B.C.D A.B.C.D as-set",
5577 NO_STR
5578 "Configure BGP aggregate entries\n"
5579 "Aggregate address\n"
5580 "Aggregate mask\n"
5581 "Generate AS set path information\n")
5582
5583ALIAS (no_aggregate_address_mask,
5584 no_aggregate_address_mask_as_set_summary_cmd,
5585 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5586 NO_STR
5587 "Configure BGP aggregate entries\n"
5588 "Aggregate address\n"
5589 "Aggregate mask\n"
5590 "Generate AS set path information\n"
5591 "Filter more specific routes from updates\n")
5592
5593ALIAS (no_aggregate_address_mask,
5594 no_aggregate_address_mask_summary_as_set_cmd,
5595 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5596 NO_STR
5597 "Configure BGP aggregate entries\n"
5598 "Aggregate address\n"
5599 "Aggregate mask\n"
5600 "Filter more specific routes from updates\n"
5601 "Generate AS set path information\n")
5602
paul718e3742002-12-13 20:15:29 +00005603DEFUN (ipv6_aggregate_address,
5604 ipv6_aggregate_address_cmd,
5605 "aggregate-address X:X::X:X/M",
5606 "Configure BGP aggregate entries\n"
5607 "Aggregate prefix\n")
5608{
5609 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5610}
5611
5612DEFUN (ipv6_aggregate_address_summary_only,
5613 ipv6_aggregate_address_summary_only_cmd,
5614 "aggregate-address X:X::X:X/M summary-only",
5615 "Configure BGP aggregate entries\n"
5616 "Aggregate prefix\n"
5617 "Filter more specific routes from updates\n")
5618{
5619 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5620 AGGREGATE_SUMMARY_ONLY, 0);
5621}
5622
5623DEFUN (no_ipv6_aggregate_address,
5624 no_ipv6_aggregate_address_cmd,
5625 "no aggregate-address X:X::X:X/M",
5626 NO_STR
5627 "Configure BGP aggregate entries\n"
5628 "Aggregate prefix\n")
5629{
5630 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5631}
5632
5633DEFUN (no_ipv6_aggregate_address_summary_only,
5634 no_ipv6_aggregate_address_summary_only_cmd,
5635 "no aggregate-address X:X::X:X/M summary-only",
5636 NO_STR
5637 "Configure BGP aggregate entries\n"
5638 "Aggregate prefix\n"
5639 "Filter more specific routes from updates\n")
5640{
5641 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5642}
5643
5644ALIAS (ipv6_aggregate_address,
5645 old_ipv6_aggregate_address_cmd,
5646 "ipv6 bgp aggregate-address X:X::X:X/M",
5647 IPV6_STR
5648 BGP_STR
5649 "Configure BGP aggregate entries\n"
5650 "Aggregate prefix\n")
5651
5652ALIAS (ipv6_aggregate_address_summary_only,
5653 old_ipv6_aggregate_address_summary_only_cmd,
5654 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5655 IPV6_STR
5656 BGP_STR
5657 "Configure BGP aggregate entries\n"
5658 "Aggregate prefix\n"
5659 "Filter more specific routes from updates\n")
5660
5661ALIAS (no_ipv6_aggregate_address,
5662 old_no_ipv6_aggregate_address_cmd,
5663 "no ipv6 bgp aggregate-address X:X::X:X/M",
5664 NO_STR
5665 IPV6_STR
5666 BGP_STR
5667 "Configure BGP aggregate entries\n"
5668 "Aggregate prefix\n")
5669
5670ALIAS (no_ipv6_aggregate_address_summary_only,
5671 old_no_ipv6_aggregate_address_summary_only_cmd,
5672 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5673 NO_STR
5674 IPV6_STR
5675 BGP_STR
5676 "Configure BGP aggregate entries\n"
5677 "Aggregate prefix\n"
5678 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005679
paul718e3742002-12-13 20:15:29 +00005680/* Redistribute route treatment. */
5681void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005682bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5683 const struct in6_addr *nexthop6,
Paul Jakma96d10602016-07-01 14:23:45 +01005684 u_int32_t metric, u_char type, route_tag_t tag)
paul718e3742002-12-13 20:15:29 +00005685{
5686 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005687 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005688 struct bgp_info *new;
5689 struct bgp_info *bi;
5690 struct bgp_info info;
5691 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005692 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005693 struct attr *new_attr;
5694 afi_t afi;
5695 int ret;
5696
5697 /* Make default attribute. */
5698 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5699 if (nexthop)
5700 attr.nexthop = *nexthop;
5701
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005702 if (nexthop6)
5703 {
5704 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5705 extra->mp_nexthop_global = *nexthop6;
5706 extra->mp_nexthop_len = 16;
5707 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005708
paul718e3742002-12-13 20:15:29 +00005709 attr.med = metric;
5710 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Piotr Chytła605aa332015-12-01 10:03:54 -05005711 attr.extra->tag = tag;
paul718e3742002-12-13 20:15:29 +00005712
paul1eb8ef22005-04-07 07:30:20 +00005713 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005714 {
5715 afi = family2afi (p->family);
5716
5717 if (bgp->redist[afi][type])
5718 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005719 struct attr attr_new;
5720 struct attr_extra extra_new;
5721
paul718e3742002-12-13 20:15:29 +00005722 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005723 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005724 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005725
5726 if (bgp->redist_metric_flag[afi][type])
5727 attr_new.med = bgp->redist_metric[afi][type];
5728
5729 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005730 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005731 {
5732 info.peer = bgp->peer_self;
5733 info.attr = &attr_new;
5734
paulfee0f4c2004-09-13 05:12:46 +00005735 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5736
paul718e3742002-12-13 20:15:29 +00005737 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5738 &info);
paulfee0f4c2004-09-13 05:12:46 +00005739
5740 bgp->peer_self->rmap_type = 0;
5741
paul718e3742002-12-13 20:15:29 +00005742 if (ret == RMAP_DENYMATCH)
5743 {
5744 /* Free uninterned attribute. */
5745 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005746
paul718e3742002-12-13 20:15:29 +00005747 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005748 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005749 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005750 bgp_redistribute_delete (p, type);
5751 return;
5752 }
5753 }
5754
Paul Jakmafb982c22007-05-04 20:15:47 +00005755 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5756 afi, SAFI_UNICAST, p, NULL);
5757
paul718e3742002-12-13 20:15:29 +00005758 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005759
paul718e3742002-12-13 20:15:29 +00005760 for (bi = bn->info; bi; bi = bi->next)
5761 if (bi->peer == bgp->peer_self
5762 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5763 break;
5764
5765 if (bi)
5766 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005767 if (attrhash_cmp (bi->attr, new_attr) &&
5768 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005769 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005770 bgp_attr_unintern (&new_attr);
5771 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005772 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005773 bgp_unlock_node (bn);
5774 return;
5775 }
5776 else
5777 {
5778 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005779 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005780
5781 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005782 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5783 bgp_info_restore(bn, bi);
5784 else
5785 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005786 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005787 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005788 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005789
5790 /* Process change. */
5791 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5792 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5793 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005794 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005795 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005796 return;
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005797 }
paul718e3742002-12-13 20:15:29 +00005798 }
5799
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005800 new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self,
5801 new_attr, bn);
paul718e3742002-12-13 20:15:29 +00005802 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00005803
5804 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5805 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005806 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005807 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5808 }
5809 }
5810
5811 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005812 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005813 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005814}
5815
5816void
5817bgp_redistribute_delete (struct prefix *p, u_char type)
5818{
5819 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005820 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005821 afi_t afi;
5822 struct bgp_node *rn;
5823 struct bgp_info *ri;
5824
paul1eb8ef22005-04-07 07:30:20 +00005825 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005826 {
5827 afi = family2afi (p->family);
5828
5829 if (bgp->redist[afi][type])
5830 {
paulfee0f4c2004-09-13 05:12:46 +00005831 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005832
5833 for (ri = rn->info; ri; ri = ri->next)
5834 if (ri->peer == bgp->peer_self
5835 && ri->type == type)
5836 break;
5837
5838 if (ri)
5839 {
5840 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005841 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005842 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005843 }
5844 bgp_unlock_node (rn);
5845 }
5846 }
5847}
5848
5849/* Withdraw specified route type's route. */
5850void
5851bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5852{
5853 struct bgp_node *rn;
5854 struct bgp_info *ri;
5855 struct bgp_table *table;
5856
5857 table = bgp->rib[afi][SAFI_UNICAST];
5858
5859 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5860 {
5861 for (ri = rn->info; ri; ri = ri->next)
5862 if (ri->peer == bgp->peer_self
5863 && ri->type == type)
5864 break;
5865
5866 if (ri)
5867 {
5868 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005869 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005870 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005871 }
5872 }
5873}
David Lamparter6b0655a2014-06-04 06:53:35 +02005874
paul718e3742002-12-13 20:15:29 +00005875/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005876static void
paul718e3742002-12-13 20:15:29 +00005877route_vty_out_route (struct prefix *p, struct vty *vty)
5878{
5879 int len;
5880 u_int32_t destination;
5881 char buf[BUFSIZ];
5882
5883 if (p->family == AF_INET)
5884 {
5885 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5886 destination = ntohl (p->u.prefix4.s_addr);
5887
5888 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5889 || (IN_CLASSB (destination) && p->prefixlen == 16)
5890 || (IN_CLASSA (destination) && p->prefixlen == 8)
5891 || p->u.prefix4.s_addr == 0)
5892 {
5893 /* When mask is natural, mask is not displayed. */
5894 }
5895 else
5896 len += vty_out (vty, "/%d", p->prefixlen);
5897 }
5898 else
5899 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5900 p->prefixlen);
5901
5902 len = 17 - len;
5903 if (len < 1)
5904 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5905 else
5906 vty_out (vty, "%*s", len, " ");
5907}
5908
paul718e3742002-12-13 20:15:29 +00005909enum bgp_display_type
5910{
5911 normal_list,
5912};
5913
paulb40d9392005-08-22 22:34:41 +00005914/* Print the short form route status for a bgp_info */
5915static void
5916route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005917{
paulb40d9392005-08-22 22:34:41 +00005918 /* Route status display. */
5919 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5920 vty_out (vty, "R");
5921 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005922 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005923 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005924 vty_out (vty, "s");
Daniel Waltone2a0ebf2015-05-19 18:03:43 -07005925 else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) &&
5926 ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
paul718e3742002-12-13 20:15:29 +00005927 vty_out (vty, "*");
5928 else
5929 vty_out (vty, " ");
5930
5931 /* Selected */
5932 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5933 vty_out (vty, "h");
5934 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5935 vty_out (vty, "d");
5936 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5937 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005938 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5939 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005940 else
5941 vty_out (vty, " ");
5942
5943 /* Internal route. */
5944 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5945 vty_out (vty, "i");
5946 else
paulb40d9392005-08-22 22:34:41 +00005947 vty_out (vty, " ");
5948}
5949
5950/* called from terminal list command */
5951void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005952route_vty_out(
5953 struct vty *vty,
5954 struct prefix *p,
5955 struct bgp_info *binfo,
5956 int display,
5957 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005958{
5959 struct attr *attr;
5960
5961 /* short status lead text */
5962 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005963
5964 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005965 if (!display)
paul718e3742002-12-13 20:15:29 +00005966 route_vty_out_route (p, vty);
5967 else
5968 vty_out (vty, "%*s", 17, " ");
5969
5970 /* Print attribute */
5971 attr = binfo->attr;
5972 if (attr)
5973 {
paul718e3742002-12-13 20:15:29 +00005974
Lou Berger298cc2f2016-01-12 13:42:02 -05005975 /*
5976 * NEXTHOP start
5977 */
5978
5979 /*
5980 * For ENCAP routes, nexthop address family is not
5981 * neccessarily the same as the prefix address family.
5982 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5983 */
5984 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5985 if (attr->extra) {
5986 char buf[BUFSIZ];
5987 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5988
5989 switch (af) {
5990 case AF_INET:
5991 vty_out (vty, "%s", inet_ntop(af,
5992 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5993 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005994 case AF_INET6:
5995 vty_out (vty, "%s", inet_ntop(af,
5996 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
5997 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005998 default:
5999 vty_out(vty, "?");
6000 }
6001 } else {
6002 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00006003 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006004 } else {
6005
6006 if (p->family == AF_INET)
6007 {
6008 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6009 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006010 else if (p->family == AF_INET6)
6011 {
6012 int len;
6013 char buf[BUFSIZ];
6014
6015 len = vty_out (vty, "%s",
6016 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6017 buf, BUFSIZ));
6018 len = 16 - len;
6019 if (len < 1)
6020 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6021 else
6022 vty_out (vty, "%*s", len, " ");
6023 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006024 else
6025 {
6026 vty_out(vty, "?");
6027 }
6028 }
6029
6030 /*
6031 * NEXTHOP end
6032 */
6033
paul718e3742002-12-13 20:15:29 +00006034
6035 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006036 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006037 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006038 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006039
6040 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006041 vty_out (vty, "%7u ", attr->local_pref);
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
Paul Jakmafb982c22007-05-04 20:15:47 +00006045 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00006046
Paul Jakmab2518c12006-05-12 23:48:40 +00006047 /* Print aspath */
6048 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006049 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006050
Paul Jakmab2518c12006-05-12 23:48:40 +00006051 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006052 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006053 }
paul718e3742002-12-13 20:15:29 +00006054 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006055}
6056
6057/* called from terminal list command */
6058void
6059route_vty_out_tmp (struct vty *vty, struct prefix *p,
6060 struct attr *attr, safi_t safi)
6061{
6062 /* Route status display. */
6063 vty_out (vty, "*");
6064 vty_out (vty, ">");
6065 vty_out (vty, " ");
6066
6067 /* print prefix and mask */
6068 route_vty_out_route (p, vty);
6069
6070 /* Print attribute */
6071 if (attr)
6072 {
6073 if (p->family == AF_INET)
6074 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006075 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006076 vty_out (vty, "%-16s",
6077 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006078 else
6079 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6080 }
paul718e3742002-12-13 20:15:29 +00006081 else if (p->family == AF_INET6)
6082 {
6083 int len;
6084 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006085
6086 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006087
6088 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006089 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6090 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006091 len = 16 - len;
6092 if (len < 1)
6093 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6094 else
6095 vty_out (vty, "%*s", len, " ");
6096 }
paul718e3742002-12-13 20:15:29 +00006097
6098 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006099 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006100 else
6101 vty_out (vty, " ");
6102
6103 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006104 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006105 else
6106 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006107
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006108 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006109
Paul Jakmab2518c12006-05-12 23:48:40 +00006110 /* Print aspath */
6111 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006112 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006113
Paul Jakmab2518c12006-05-12 23:48:40 +00006114 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006115 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006116 }
paul718e3742002-12-13 20:15:29 +00006117
6118 vty_out (vty, "%s", VTY_NEWLINE);
6119}
6120
ajs5a646652004-11-05 01:25:55 +00006121void
paul718e3742002-12-13 20:15:29 +00006122route_vty_out_tag (struct vty *vty, struct prefix *p,
6123 struct bgp_info *binfo, int display, safi_t safi)
6124{
6125 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006126 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006127
6128 if (!binfo->extra)
6129 return;
6130
paulb40d9392005-08-22 22:34:41 +00006131 /* short status lead text */
6132 route_vty_short_status_out (vty, binfo);
6133
paul718e3742002-12-13 20:15:29 +00006134 /* print prefix and mask */
6135 if (! display)
6136 route_vty_out_route (p, vty);
6137 else
6138 vty_out (vty, "%*s", 17, " ");
6139
6140 /* Print attribute */
6141 attr = binfo->attr;
6142 if (attr)
6143 {
6144 if (p->family == AF_INET)
6145 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006146 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006147 vty_out (vty, "%-16s",
6148 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006149 else
6150 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6151 }
paul718e3742002-12-13 20:15:29 +00006152 else if (p->family == AF_INET6)
6153 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006154 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006155 char buf[BUFSIZ];
6156 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006157 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006158 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006159 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6160 buf, BUFSIZ));
6161 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006162 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006163 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6164 buf, BUFSIZ),
6165 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6166 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006167
6168 }
paul718e3742002-12-13 20:15:29 +00006169 }
6170
Paul Jakmafb982c22007-05-04 20:15:47 +00006171 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006172
6173 vty_out (vty, "notag/%d", label);
6174
6175 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006176}
6177
6178/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006179static void
paul718e3742002-12-13 20:15:29 +00006180damp_route_vty_out (struct vty *vty, struct prefix *p,
6181 struct bgp_info *binfo, int display, safi_t safi)
6182{
6183 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006184 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006185 char timebuf[BGP_UPTIME_LEN];
paul718e3742002-12-13 20:15:29 +00006186
paulb40d9392005-08-22 22:34:41 +00006187 /* short status lead text */
6188 route_vty_short_status_out (vty, binfo);
6189
paul718e3742002-12-13 20:15:29 +00006190 /* print prefix and mask */
6191 if (! display)
6192 route_vty_out_route (p, vty);
6193 else
6194 vty_out (vty, "%*s", 17, " ");
6195
6196 len = vty_out (vty, "%s", binfo->peer->host);
6197 len = 17 - len;
6198 if (len < 1)
6199 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6200 else
6201 vty_out (vty, "%*s", len, " ");
6202
Chris Caputo50aef6f2009-06-23 06:06:49 +00006203 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006204
6205 /* Print attribute */
6206 attr = binfo->attr;
6207 if (attr)
6208 {
6209 /* Print aspath */
6210 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006211 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006212
6213 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006214 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006215 }
6216 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006217}
6218
paul718e3742002-12-13 20:15:29 +00006219/* flap route */
ajs5a646652004-11-05 01:25:55 +00006220static void
paul718e3742002-12-13 20:15:29 +00006221flap_route_vty_out (struct vty *vty, struct prefix *p,
6222 struct bgp_info *binfo, int display, safi_t safi)
6223{
6224 struct attr *attr;
6225 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006226 char timebuf[BGP_UPTIME_LEN];
6227 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006228
6229 if (!binfo->extra)
6230 return;
6231
6232 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006233
paulb40d9392005-08-22 22:34:41 +00006234 /* short status lead text */
6235 route_vty_short_status_out (vty, binfo);
6236
paul718e3742002-12-13 20:15:29 +00006237 /* print prefix and mask */
6238 if (! display)
6239 route_vty_out_route (p, vty);
6240 else
6241 vty_out (vty, "%*s", 17, " ");
6242
6243 len = vty_out (vty, "%s", binfo->peer->host);
6244 len = 16 - len;
6245 if (len < 1)
6246 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6247 else
6248 vty_out (vty, "%*s", len, " ");
6249
6250 len = vty_out (vty, "%d", bdi->flap);
6251 len = 5 - len;
6252 if (len < 1)
6253 vty_out (vty, " ");
6254 else
6255 vty_out (vty, "%*s ", len, " ");
6256
6257 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6258 timebuf, BGP_UPTIME_LEN));
6259
6260 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6261 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006262 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006263 else
6264 vty_out (vty, "%*s ", 8, " ");
6265
6266 /* Print attribute */
6267 attr = binfo->attr;
6268 if (attr)
6269 {
6270 /* Print aspath */
6271 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006272 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006273
6274 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006275 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006276 }
6277 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006278}
6279
paul94f2b392005-06-28 12:44:16 +00006280static void
paul718e3742002-12-13 20:15:29 +00006281route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6282 struct bgp_info *binfo, afi_t afi, safi_t safi)
6283{
6284 char buf[INET6_ADDRSTRLEN];
6285 char buf1[BUFSIZ];
6286 struct attr *attr;
6287 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006288#ifdef HAVE_CLOCK_MONOTONIC
6289 time_t tbuf;
6290#endif
paul718e3742002-12-13 20:15:29 +00006291
6292 attr = binfo->attr;
6293
6294 if (attr)
6295 {
6296 /* Line1 display AS-path, Aggregator */
6297 if (attr->aspath)
6298 {
6299 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006300 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006301 vty_out (vty, "Local");
6302 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006303 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006304 }
6305
paulb40d9392005-08-22 22:34:41 +00006306 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6307 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006308 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6309 vty_out (vty, ", (stale)");
6310 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006311 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006312 attr->extra->aggregator_as,
6313 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006314 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6315 vty_out (vty, ", (Received from a RR-client)");
6316 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6317 vty_out (vty, ", (Received from a RS-client)");
6318 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6319 vty_out (vty, ", (history entry)");
6320 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6321 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006322 vty_out (vty, "%s", VTY_NEWLINE);
6323
6324 /* Line2 display Next-hop, Neighbor, Router-id */
6325 if (p->family == AF_INET)
6326 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006327 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006328 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006329 inet_ntoa (attr->nexthop));
6330 }
paul718e3742002-12-13 20:15:29 +00006331 else
6332 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006333 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006334 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006335 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006336 buf, INET6_ADDRSTRLEN));
6337 }
paul718e3742002-12-13 20:15:29 +00006338
6339 if (binfo->peer == bgp->peer_self)
6340 {
6341 vty_out (vty, " from %s ",
6342 p->family == AF_INET ? "0.0.0.0" : "::");
6343 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6344 }
6345 else
6346 {
6347 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6348 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006349 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006350 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006351 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6352 buf[0] = '?';
6353 buf[1] = 0;
6354 }
6355 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006356 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006357 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006358 else
6359 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6360 }
6361 vty_out (vty, "%s", VTY_NEWLINE);
6362
paul718e3742002-12-13 20:15:29 +00006363 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006364 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006365 {
6366 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006367 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006368 buf, INET6_ADDRSTRLEN),
6369 VTY_NEWLINE);
6370 }
paul718e3742002-12-13 20:15:29 +00006371
Piotr Chytła605aa332015-12-01 10:03:54 -05006372 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
paul718e3742002-12-13 20:15:29 +00006373 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6374
6375 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006376 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006377
6378 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006379 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006380 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006381 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006382
Paul Jakmafb982c22007-05-04 20:15:47 +00006383 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006384 vty_out (vty, ", weight %u", attr->extra->weight);
Piotr Chytła605aa332015-12-01 10:03:54 -05006385
6386 if (attr->extra && attr->extra->tag != 0)
6387 vty_out (vty, ", tag %d", attr->extra->tag);
paul718e3742002-12-13 20:15:29 +00006388
Daniel Waltone2a0ebf2015-05-19 18:03:43 -07006389 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6390 vty_out (vty, ", invalid");
6391 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
paul718e3742002-12-13 20:15:29 +00006392 vty_out (vty, ", valid");
6393
6394 if (binfo->peer != bgp->peer_self)
6395 {
6396 if (binfo->peer->as == binfo->peer->local_as)
6397 vty_out (vty, ", internal");
6398 else
6399 vty_out (vty, ", %s",
6400 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6401 }
6402 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6403 vty_out (vty, ", aggregated, local");
6404 else if (binfo->type != ZEBRA_ROUTE_BGP)
6405 vty_out (vty, ", sourced");
6406 else
6407 vty_out (vty, ", sourced, local");
6408
6409 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6410 vty_out (vty, ", atomic-aggregate");
6411
Josh Baileyde8d5df2011-07-20 20:46:01 -07006412 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6413 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6414 bgp_info_mpath_count (binfo)))
6415 vty_out (vty, ", multipath");
6416
paul718e3742002-12-13 20:15:29 +00006417 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6418 vty_out (vty, ", best");
6419
6420 vty_out (vty, "%s", VTY_NEWLINE);
6421
6422 /* Line 4 display Community */
6423 if (attr->community)
6424 vty_out (vty, " Community: %s%s", attr->community->str,
6425 VTY_NEWLINE);
6426
6427 /* Line 5 display Extended-community */
6428 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006429 vty_out (vty, " Extended Community: %s%s",
6430 attr->extra->ecommunity->str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006431
6432 /* Line 6 display Originator, Cluster-id */
6433 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6434 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6435 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006436 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006437 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006438 vty_out (vty, " Originator: %s",
6439 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006440
6441 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6442 {
6443 int i;
6444 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006445 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6446 vty_out (vty, "%s ",
6447 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006448 }
6449 vty_out (vty, "%s", VTY_NEWLINE);
6450 }
Paul Jakma41367172007-08-06 15:24:51 +00006451
Paul Jakmafb982c22007-05-04 20:15:47 +00006452 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006453 bgp_damp_info_vty (vty, binfo);
6454
6455 /* Line 7 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006456#ifdef HAVE_CLOCK_MONOTONIC
6457 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006458 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006459#else
6460 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6461#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006462 }
6463 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006464}
6465
6466#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6467 "h history, * valid, > best, = multipath,%s"\
6468 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006469#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006470#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6471#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6472#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6473
6474enum bgp_show_type
6475{
6476 bgp_show_type_normal,
6477 bgp_show_type_regexp,
6478 bgp_show_type_prefix_list,
6479 bgp_show_type_filter_list,
6480 bgp_show_type_route_map,
6481 bgp_show_type_neighbor,
6482 bgp_show_type_cidr_only,
6483 bgp_show_type_prefix_longer,
6484 bgp_show_type_community_all,
6485 bgp_show_type_community,
6486 bgp_show_type_community_exact,
6487 bgp_show_type_community_list,
6488 bgp_show_type_community_list_exact,
6489 bgp_show_type_flap_statistics,
6490 bgp_show_type_flap_address,
6491 bgp_show_type_flap_prefix,
6492 bgp_show_type_flap_cidr_only,
6493 bgp_show_type_flap_regexp,
6494 bgp_show_type_flap_filter_list,
6495 bgp_show_type_flap_prefix_list,
6496 bgp_show_type_flap_prefix_longer,
6497 bgp_show_type_flap_route_map,
6498 bgp_show_type_flap_neighbor,
6499 bgp_show_type_dampend_paths,
6500 bgp_show_type_damp_neighbor
6501};
6502
ajs5a646652004-11-05 01:25:55 +00006503static int
paulfee0f4c2004-09-13 05:12:46 +00006504bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006505 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006506{
paul718e3742002-12-13 20:15:29 +00006507 struct bgp_info *ri;
6508 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006509 int header = 1;
paul718e3742002-12-13 20:15:29 +00006510 int display;
ajs5a646652004-11-05 01:25:55 +00006511 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006512 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006513
6514 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006515 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006516 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006517
paul718e3742002-12-13 20:15:29 +00006518 /* Start processing of routes. */
6519 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6520 if (rn->info != NULL)
6521 {
6522 display = 0;
6523
6524 for (ri = rn->info; ri; ri = ri->next)
6525 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006526 total_count++;
ajs5a646652004-11-05 01:25:55 +00006527 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006528 || type == bgp_show_type_flap_address
6529 || type == bgp_show_type_flap_prefix
6530 || type == bgp_show_type_flap_cidr_only
6531 || type == bgp_show_type_flap_regexp
6532 || type == bgp_show_type_flap_filter_list
6533 || type == bgp_show_type_flap_prefix_list
6534 || type == bgp_show_type_flap_prefix_longer
6535 || type == bgp_show_type_flap_route_map
6536 || type == bgp_show_type_flap_neighbor
6537 || type == bgp_show_type_dampend_paths
6538 || type == bgp_show_type_damp_neighbor)
6539 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006540 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006541 continue;
6542 }
6543 if (type == bgp_show_type_regexp
6544 || type == bgp_show_type_flap_regexp)
6545 {
ajs5a646652004-11-05 01:25:55 +00006546 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006547
6548 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6549 continue;
6550 }
6551 if (type == bgp_show_type_prefix_list
6552 || type == bgp_show_type_flap_prefix_list)
6553 {
ajs5a646652004-11-05 01:25:55 +00006554 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006555
6556 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6557 continue;
6558 }
6559 if (type == bgp_show_type_filter_list
6560 || type == bgp_show_type_flap_filter_list)
6561 {
ajs5a646652004-11-05 01:25:55 +00006562 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006563
6564 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6565 continue;
6566 }
6567 if (type == bgp_show_type_route_map
6568 || type == bgp_show_type_flap_route_map)
6569 {
ajs5a646652004-11-05 01:25:55 +00006570 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006571 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006572 struct attr dummy_attr;
6573 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006574 int ret;
6575
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006576 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006577 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006578
paul718e3742002-12-13 20:15:29 +00006579 binfo.peer = ri->peer;
6580 binfo.attr = &dummy_attr;
6581
6582 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006583 if (ret == RMAP_DENYMATCH)
6584 continue;
6585 }
6586 if (type == bgp_show_type_neighbor
6587 || type == bgp_show_type_flap_neighbor
6588 || type == bgp_show_type_damp_neighbor)
6589 {
ajs5a646652004-11-05 01:25:55 +00006590 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006591
6592 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6593 continue;
6594 }
6595 if (type == bgp_show_type_cidr_only
6596 || type == bgp_show_type_flap_cidr_only)
6597 {
6598 u_int32_t destination;
6599
6600 destination = ntohl (rn->p.u.prefix4.s_addr);
6601 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6602 continue;
6603 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6604 continue;
6605 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6606 continue;
6607 }
6608 if (type == bgp_show_type_prefix_longer
6609 || type == bgp_show_type_flap_prefix_longer)
6610 {
ajs5a646652004-11-05 01:25:55 +00006611 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006612
6613 if (! prefix_match (p, &rn->p))
6614 continue;
6615 }
6616 if (type == bgp_show_type_community_all)
6617 {
6618 if (! ri->attr->community)
6619 continue;
6620 }
6621 if (type == bgp_show_type_community)
6622 {
ajs5a646652004-11-05 01:25:55 +00006623 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006624
6625 if (! ri->attr->community ||
6626 ! community_match (ri->attr->community, com))
6627 continue;
6628 }
6629 if (type == bgp_show_type_community_exact)
6630 {
ajs5a646652004-11-05 01:25:55 +00006631 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006632
6633 if (! ri->attr->community ||
6634 ! community_cmp (ri->attr->community, com))
6635 continue;
6636 }
6637 if (type == bgp_show_type_community_list)
6638 {
ajs5a646652004-11-05 01:25:55 +00006639 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006640
6641 if (! community_list_match (ri->attr->community, list))
6642 continue;
6643 }
6644 if (type == bgp_show_type_community_list_exact)
6645 {
ajs5a646652004-11-05 01:25:55 +00006646 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006647
6648 if (! community_list_exact_match (ri->attr->community, list))
6649 continue;
6650 }
6651 if (type == bgp_show_type_flap_address
6652 || type == bgp_show_type_flap_prefix)
6653 {
ajs5a646652004-11-05 01:25:55 +00006654 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006655
6656 if (! prefix_match (&rn->p, p))
6657 continue;
6658
6659 if (type == bgp_show_type_flap_prefix)
6660 if (p->prefixlen != rn->p.prefixlen)
6661 continue;
6662 }
6663 if (type == bgp_show_type_dampend_paths
6664 || type == bgp_show_type_damp_neighbor)
6665 {
6666 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6667 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6668 continue;
6669 }
6670
6671 if (header)
6672 {
hasso93406d82005-02-02 14:40:33 +00006673 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6674 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6675 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006676 if (type == bgp_show_type_dampend_paths
6677 || type == bgp_show_type_damp_neighbor)
6678 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6679 else if (type == bgp_show_type_flap_statistics
6680 || type == bgp_show_type_flap_address
6681 || type == bgp_show_type_flap_prefix
6682 || type == bgp_show_type_flap_cidr_only
6683 || type == bgp_show_type_flap_regexp
6684 || type == bgp_show_type_flap_filter_list
6685 || type == bgp_show_type_flap_prefix_list
6686 || type == bgp_show_type_flap_prefix_longer
6687 || type == bgp_show_type_flap_route_map
6688 || type == bgp_show_type_flap_neighbor)
6689 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6690 else
6691 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006692 header = 0;
6693 }
6694
6695 if (type == bgp_show_type_dampend_paths
6696 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006697 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006698 else if (type == bgp_show_type_flap_statistics
6699 || type == bgp_show_type_flap_address
6700 || type == bgp_show_type_flap_prefix
6701 || type == bgp_show_type_flap_cidr_only
6702 || type == bgp_show_type_flap_regexp
6703 || type == bgp_show_type_flap_filter_list
6704 || type == bgp_show_type_flap_prefix_list
6705 || type == bgp_show_type_flap_prefix_longer
6706 || type == bgp_show_type_flap_route_map
6707 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006708 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006709 else
ajs5a646652004-11-05 01:25:55 +00006710 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006711 display++;
6712 }
6713 if (display)
ajs5a646652004-11-05 01:25:55 +00006714 output_count++;
paul718e3742002-12-13 20:15:29 +00006715 }
6716
6717 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006718 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006719 {
6720 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006721 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006722 }
6723 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006724 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6725 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006726
6727 return CMD_SUCCESS;
6728}
6729
ajs5a646652004-11-05 01:25:55 +00006730static int
paulfee0f4c2004-09-13 05:12:46 +00006731bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006732 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006733{
6734 struct bgp_table *table;
6735
6736 if (bgp == NULL) {
6737 bgp = bgp_get_default ();
6738 }
6739
6740 if (bgp == NULL)
6741 {
6742 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6743 return CMD_WARNING;
6744 }
6745
6746
6747 table = bgp->rib[afi][safi];
6748
ajs5a646652004-11-05 01:25:55 +00006749 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006750}
6751
paul718e3742002-12-13 20:15:29 +00006752/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006753static void
paul718e3742002-12-13 20:15:29 +00006754route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6755 struct bgp_node *rn,
6756 struct prefix_rd *prd, afi_t afi, safi_t safi)
6757{
6758 struct bgp_info *ri;
6759 struct prefix *p;
6760 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006761 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006762 char buf1[INET6_ADDRSTRLEN];
6763 char buf2[INET6_ADDRSTRLEN];
6764 int count = 0;
6765 int best = 0;
6766 int suppress = 0;
6767 int no_export = 0;
6768 int no_advertise = 0;
6769 int local_as = 0;
6770 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006771 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006772
6773 p = &rn->p;
6774 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006775 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6776 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006777 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6778 p->prefixlen, VTY_NEWLINE);
6779
6780 for (ri = rn->info; ri; ri = ri->next)
6781 {
6782 count++;
6783 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6784 {
6785 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006786 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006787 suppress = 1;
6788 if (ri->attr->community != NULL)
6789 {
6790 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6791 no_advertise = 1;
6792 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6793 no_export = 1;
6794 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6795 local_as = 1;
6796 }
6797 }
6798 }
6799
6800 vty_out (vty, "Paths: (%d available", count);
6801 if (best)
6802 {
6803 vty_out (vty, ", best #%d", best);
6804 if (safi == SAFI_UNICAST)
6805 vty_out (vty, ", table Default-IP-Routing-Table");
6806 }
6807 else
6808 vty_out (vty, ", no best path");
6809 if (no_advertise)
6810 vty_out (vty, ", not advertised to any peer");
6811 else if (no_export)
6812 vty_out (vty, ", not advertised to EBGP peer");
6813 else if (local_as)
6814 vty_out (vty, ", not advertised outside local AS");
6815 if (suppress)
6816 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6817 vty_out (vty, ")%s", VTY_NEWLINE);
6818
6819 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006820 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006821 {
6822 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6823 {
6824 if (! first)
6825 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6826 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6827 first = 1;
6828 }
6829 }
6830 if (! first)
6831 vty_out (vty, " Not advertised to any peer");
6832 vty_out (vty, "%s", VTY_NEWLINE);
6833}
6834
6835/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006836static int
paulfee0f4c2004-09-13 05:12:46 +00006837bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006838 struct bgp_table *rib, const char *ip_str,
6839 afi_t afi, safi_t safi, struct prefix_rd *prd,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006840 int prefix_check, enum bgp_path_type pathtype)
paul718e3742002-12-13 20:15:29 +00006841{
6842 int ret;
6843 int header;
6844 int display = 0;
6845 struct prefix match;
6846 struct bgp_node *rn;
6847 struct bgp_node *rm;
6848 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006849 struct bgp_table *table;
6850
Lou Berger050defe2016-01-12 13:41:59 -05006851 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006852 /* Check IP address argument. */
6853 ret = str2prefix (ip_str, &match);
6854 if (! ret)
6855 {
6856 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6857 return CMD_WARNING;
6858 }
6859
6860 match.family = afi2family (afi);
6861
Lou Berger298cc2f2016-01-12 13:42:02 -05006862 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006863 {
paulfee0f4c2004-09-13 05:12:46 +00006864 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006865 {
6866 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6867 continue;
6868
6869 if ((table = rn->info) != NULL)
6870 {
6871 header = 1;
6872
6873 if ((rm = bgp_node_match (table, &match)) != NULL)
6874 {
6875 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006876 {
6877 bgp_unlock_node (rm);
6878 continue;
6879 }
paul718e3742002-12-13 20:15:29 +00006880
6881 for (ri = rm->info; ri; ri = ri->next)
6882 {
6883 if (header)
6884 {
6885 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006886 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006887
6888 header = 0;
6889 }
6890 display++;
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006891
6892 if (pathtype == BGP_PATH_ALL ||
6893 (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) ||
6894 (pathtype == BGP_PATH_MULTIPATH &&
6895 (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))))
6896 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006897 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006898
6899 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006900 }
6901 }
6902 }
6903 }
6904 else
6905 {
6906 header = 1;
6907
paulfee0f4c2004-09-13 05:12:46 +00006908 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006909 {
6910 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6911 {
6912 for (ri = rn->info; ri; ri = ri->next)
6913 {
6914 if (header)
6915 {
6916 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6917 header = 0;
6918 }
6919 display++;
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006920
6921 if (pathtype == BGP_PATH_ALL ||
6922 (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) ||
6923 (pathtype == BGP_PATH_MULTIPATH &&
6924 (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))))
6925 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00006926 }
6927 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006928
6929 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006930 }
6931 }
6932
6933 if (! display)
6934 {
6935 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6936 return CMD_WARNING;
6937 }
6938
6939 return CMD_SUCCESS;
6940}
6941
paulfee0f4c2004-09-13 05:12:46 +00006942/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006943static int
paulfd79ac92004-10-13 05:06:08 +00006944bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006945 afi_t afi, safi_t safi, struct prefix_rd *prd,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006946 int prefix_check, enum bgp_path_type pathtype)
paulfee0f4c2004-09-13 05:12:46 +00006947{
6948 struct bgp *bgp;
6949
6950 /* BGP structure lookup. */
6951 if (view_name)
6952 {
6953 bgp = bgp_lookup_by_name (view_name);
6954 if (bgp == NULL)
6955 {
6956 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6957 return CMD_WARNING;
6958 }
6959 }
6960 else
6961 {
6962 bgp = bgp_get_default ();
6963 if (bgp == NULL)
6964 {
6965 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6966 return CMD_WARNING;
6967 }
6968 }
6969
6970 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006971 afi, safi, prd, prefix_check, pathtype);
paulfee0f4c2004-09-13 05:12:46 +00006972}
6973
paul718e3742002-12-13 20:15:29 +00006974/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05006975DEFUN (show_ip_bgp,
6976 show_ip_bgp_cmd,
6977 "show ip bgp",
6978 SHOW_STR
6979 IP_STR
6980 BGP_STR)
6981{
6982 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6983}
6984
6985DEFUN (show_ip_bgp_ipv4,
6986 show_ip_bgp_ipv4_cmd,
6987 "show ip bgp ipv4 (unicast|multicast)",
6988 SHOW_STR
6989 IP_STR
6990 BGP_STR
6991 "Address family\n"
6992 "Address Family modifier\n"
6993 "Address Family modifier\n")
6994{
6995 if (strncmp (argv[0], "m", 1) == 0)
6996 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
6997 NULL);
6998
6999 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7000}
7001
7002DEFUN (show_ip_bgp_route,
7003 show_ip_bgp_route_cmd,
7004 "show ip bgp A.B.C.D",
7005 SHOW_STR
7006 IP_STR
7007 BGP_STR
7008 "Network in the BGP routing table to display\n")
7009{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007010 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7011}
7012
7013DEFUN (show_ip_bgp_route_pathtype,
7014 show_ip_bgp_route_pathtype_cmd,
7015 "show ip bgp A.B.C.D (bestpath|multipath)",
7016 SHOW_STR
7017 IP_STR
7018 BGP_STR
7019 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7020 "Display only the bestpath\n"
7021 "Display only multipaths\n")
7022{
7023 if (strncmp (argv[1], "b", 1) == 0)
7024 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7025 else
7026 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7027}
7028
7029DEFUN (show_bgp_ipv4_safi_route_pathtype,
7030 show_bgp_ipv4_safi_route_pathtype_cmd,
7031 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath)",
7032 SHOW_STR
7033 BGP_STR
7034 "Address family\n"
7035 "Address Family modifier\n"
7036 "Address Family modifier\n"
7037 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7038 "Display only the bestpath\n"
7039 "Display only multipaths\n")
7040{
7041 if (strncmp (argv[0], "m", 1) == 0)
7042 if (strncmp (argv[2], "b", 1) == 0)
7043 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH);
7044 else
7045 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH);
7046 else
7047 if (strncmp (argv[2], "b", 1) == 0)
7048 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7049 else
7050 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007051}
7052
7053DEFUN (show_ip_bgp_ipv4_route,
7054 show_ip_bgp_ipv4_route_cmd,
7055 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
7056 SHOW_STR
7057 IP_STR
7058 BGP_STR
7059 "Address family\n"
7060 "Address Family modifier\n"
7061 "Address Family modifier\n"
7062 "Network in the BGP routing table to display\n")
7063{
7064 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007065 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007066
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007067 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007068}
7069
7070DEFUN (show_ip_bgp_vpnv4_all_route,
7071 show_ip_bgp_vpnv4_all_route_cmd,
7072 "show ip bgp vpnv4 all A.B.C.D",
7073 SHOW_STR
7074 IP_STR
7075 BGP_STR
7076 "Display VPNv4 NLRI specific information\n"
7077 "Display information about all VPNv4 NLRIs\n"
7078 "Network in the BGP routing table to display\n")
7079{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007080 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 -05007081}
7082
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007083
Lou Bergerf9b6c392016-01-12 13:42:09 -05007084DEFUN (show_ip_bgp_vpnv4_rd_route,
7085 show_ip_bgp_vpnv4_rd_route_cmd,
7086 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
7087 SHOW_STR
7088 IP_STR
7089 BGP_STR
7090 "Display VPNv4 NLRI specific information\n"
7091 "Display information for a route distinguisher\n"
7092 "VPN Route Distinguisher\n"
7093 "Network in the BGP routing table to display\n")
7094{
7095 int ret;
7096 struct prefix_rd prd;
7097
7098 ret = str2prefix_rd (argv[0], &prd);
7099 if (! ret)
7100 {
7101 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7102 return CMD_WARNING;
7103 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007104 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 -05007105}
7106
7107DEFUN (show_ip_bgp_prefix,
7108 show_ip_bgp_prefix_cmd,
7109 "show ip bgp A.B.C.D/M",
7110 SHOW_STR
7111 IP_STR
7112 BGP_STR
7113 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7114{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007115 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7116}
7117
7118DEFUN (show_ip_bgp_prefix_pathtype,
7119 show_ip_bgp_prefix_pathtype_cmd,
7120 "show ip bgp A.B.C.D/M (bestpath|multipath)",
7121 SHOW_STR
7122 IP_STR
7123 BGP_STR
7124 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7125 "Display only the bestpath\n"
7126 "Display only multipaths\n")
7127{
7128 if (strncmp (argv[1], "b", 1) == 0)
7129 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7130 else
7131 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007132}
7133
7134DEFUN (show_ip_bgp_ipv4_prefix,
7135 show_ip_bgp_ipv4_prefix_cmd,
7136 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
7137 SHOW_STR
7138 IP_STR
7139 BGP_STR
7140 "Address family\n"
7141 "Address Family modifier\n"
7142 "Address Family modifier\n"
7143 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7144{
7145 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007146 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007147
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007148 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007149}
7150
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007151DEFUN (show_ip_bgp_ipv4_prefix_pathtype,
7152 show_ip_bgp_ipv4_prefix_pathtype_cmd,
7153 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)",
7154 SHOW_STR
7155 IP_STR
7156 BGP_STR
7157 "Address family\n"
7158 "Address Family modifier\n"
7159 "Address Family modifier\n"
7160 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7161 "Display only the bestpath\n"
7162 "Display only multipaths\n")
7163{
7164 if (strncmp (argv[0], "m", 1) == 0)
7165 if (strncmp (argv[2], "b", 1) == 0)
7166 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH);
7167 else
7168 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH);
7169 else
7170 if (strncmp (argv[2], "b", 1) == 0)
7171 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7172 else
7173 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7174}
7175
7176ALIAS (show_ip_bgp_ipv4_prefix_pathtype,
7177 show_bgp_ipv4_safi_prefix_pathtype_cmd,
7178 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)",
7179 SHOW_STR
7180 BGP_STR
7181 "Address family\n"
7182 "Address Family modifier\n"
7183 "Address Family modifier\n"
7184 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7185 "Display only the bestpath\n"
7186 "Display only multipaths\n")
7187
Lou Bergerf9b6c392016-01-12 13:42:09 -05007188DEFUN (show_ip_bgp_vpnv4_all_prefix,
7189 show_ip_bgp_vpnv4_all_prefix_cmd,
7190 "show ip bgp vpnv4 all A.B.C.D/M",
7191 SHOW_STR
7192 IP_STR
7193 BGP_STR
7194 "Display VPNv4 NLRI specific information\n"
7195 "Display information about all VPNv4 NLRIs\n"
7196 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7197{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007198 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 -05007199}
7200
7201DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7202 show_ip_bgp_vpnv4_rd_prefix_cmd,
7203 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7204 SHOW_STR
7205 IP_STR
7206 BGP_STR
7207 "Display VPNv4 NLRI specific information\n"
7208 "Display information for a route distinguisher\n"
7209 "VPN Route Distinguisher\n"
7210 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7211{
7212 int ret;
7213 struct prefix_rd prd;
7214
7215 ret = str2prefix_rd (argv[0], &prd);
7216 if (! ret)
7217 {
7218 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7219 return CMD_WARNING;
7220 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007221 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 -05007222}
7223
7224DEFUN (show_ip_bgp_view,
7225 show_ip_bgp_view_cmd,
7226 "show ip bgp view WORD",
7227 SHOW_STR
7228 IP_STR
7229 BGP_STR
7230 "BGP view\n"
7231 "View name\n")
7232{
7233 struct bgp *bgp;
7234
7235 /* BGP structure lookup. */
7236 bgp = bgp_lookup_by_name (argv[0]);
7237 if (bgp == NULL)
7238 {
7239 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7240 return CMD_WARNING;
7241 }
7242
7243 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7244}
7245
7246DEFUN (show_ip_bgp_view_route,
7247 show_ip_bgp_view_route_cmd,
7248 "show ip bgp view WORD A.B.C.D",
7249 SHOW_STR
7250 IP_STR
7251 BGP_STR
7252 "BGP view\n"
7253 "View name\n"
7254 "Network in the BGP routing table to display\n")
7255{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007256 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 -05007257}
7258
7259DEFUN (show_ip_bgp_view_prefix,
7260 show_ip_bgp_view_prefix_cmd,
7261 "show ip bgp view WORD A.B.C.D/M",
7262 SHOW_STR
7263 IP_STR
7264 BGP_STR
7265 "BGP view\n"
7266 "View name\n"
7267 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7268{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007269 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 -05007270}
7271
7272DEFUN (show_bgp,
7273 show_bgp_cmd,
7274 "show bgp",
7275 SHOW_STR
7276 BGP_STR)
7277{
7278 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7279 NULL);
7280}
7281
7282ALIAS (show_bgp,
7283 show_bgp_ipv6_cmd,
7284 "show bgp ipv6",
7285 SHOW_STR
7286 BGP_STR
7287 "Address family\n")
7288
7289/* old command */
7290DEFUN (show_ipv6_bgp,
7291 show_ipv6_bgp_cmd,
7292 "show ipv6 bgp",
7293 SHOW_STR
7294 IP_STR
7295 BGP_STR)
7296{
7297 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7298 NULL);
7299}
7300
7301DEFUN (show_bgp_route,
7302 show_bgp_route_cmd,
7303 "show bgp X:X::X:X",
7304 SHOW_STR
7305 BGP_STR
7306 "Network in the BGP routing table to display\n")
7307{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007308 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007309}
7310
Lou Berger35c36862016-01-12 13:42:06 -05007311DEFUN (show_bgp_ipv4_safi,
7312 show_bgp_ipv4_safi_cmd,
7313 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007314 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007315 BGP_STR
7316 "Address family\n"
7317 "Address Family modifier\n"
7318 "Address Family modifier\n")
7319{
7320 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007321 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7322 NULL);
paul718e3742002-12-13 20:15:29 +00007323
ajs5a646652004-11-05 01:25:55 +00007324 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007325}
7326
Lou Berger35c36862016-01-12 13:42:06 -05007327DEFUN (show_bgp_ipv4_safi_route,
7328 show_bgp_ipv4_safi_route_cmd,
7329 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007330 SHOW_STR
7331 BGP_STR
7332 "Address family\n"
7333 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007334 "Address Family modifier\n"
7335 "Network in the BGP routing table to display\n")
7336{
7337 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007338 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007339
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007340 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7341}
7342
7343DEFUN (show_bgp_route_pathtype,
7344 show_bgp_route_pathtype_cmd,
7345 "show bgp X:X::X:X (bestpath|multipath)",
7346 SHOW_STR
7347 BGP_STR
7348 "Network in the BGP routing table to display\n"
7349 "Display only the bestpath\n"
7350 "Display only multipaths\n")
7351{
7352 if (strncmp (argv[1], "b", 1) == 0)
7353 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7354 else
7355 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7356}
7357
7358ALIAS (show_bgp_route_pathtype,
7359 show_bgp_ipv6_route_pathtype_cmd,
7360 "show bgp ipv6 X:X::X:X (bestpath|multipath)",
7361 SHOW_STR
7362 BGP_STR
7363 "Address family\n"
7364 "Network in the BGP routing table to display\n"
7365 "Display only the bestpath\n"
7366 "Display only multipaths\n")
7367
7368DEFUN (show_bgp_ipv6_safi_route_pathtype,
7369 show_bgp_ipv6_safi_route_pathtype_cmd,
7370 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath)",
7371 SHOW_STR
7372 BGP_STR
7373 "Address family\n"
7374 "Address Family modifier\n"
7375 "Address Family modifier\n"
7376 "Network in the BGP routing table to display\n"
7377 "Display only the bestpath\n"
7378 "Display only multipaths\n")
7379{
7380 if (strncmp (argv[0], "m", 1) == 0)
7381 if (strncmp (argv[2], "b", 1) == 0)
7382 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH);
7383 else
7384 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH);
7385 else
7386 if (strncmp (argv[2], "b", 1) == 0)
7387 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7388 else
7389 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
paul718e3742002-12-13 20:15:29 +00007390}
7391
Lou Berger35c36862016-01-12 13:42:06 -05007392DEFUN (show_bgp_ipv4_vpn_route,
7393 show_bgp_ipv4_vpn_route_cmd,
7394 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007395 SHOW_STR
7396 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007397 "Address Family\n"
7398 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007399 "Network in the BGP routing table to display\n")
7400{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007401 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007402}
7403
Lou Berger35c36862016-01-12 13:42:06 -05007404DEFUN (show_bgp_ipv6_vpn_route,
7405 show_bgp_ipv6_vpn_route_cmd,
7406 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007407 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007408 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007409 "Address Family\n"
7410 "Display VPN NLRI specific information\n"
7411 "Network in the BGP routing table to display\n")
7412{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007413 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 -05007414}
Lou Berger35c36862016-01-12 13:42:06 -05007415
7416DEFUN (show_bgp_ipv4_vpn_rd_route,
7417 show_bgp_ipv4_vpn_rd_route_cmd,
7418 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7419 SHOW_STR
7420 BGP_STR
7421 IP_STR
7422 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007423 "Display information for a route distinguisher\n"
7424 "VPN Route Distinguisher\n"
7425 "Network in the BGP routing table to display\n")
7426{
7427 int ret;
7428 struct prefix_rd prd;
7429
7430 ret = str2prefix_rd (argv[0], &prd);
7431 if (! ret)
7432 {
7433 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7434 return CMD_WARNING;
7435 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007436 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007437}
7438
Lou Berger35c36862016-01-12 13:42:06 -05007439DEFUN (show_bgp_ipv6_vpn_rd_route,
7440 show_bgp_ipv6_vpn_rd_route_cmd,
7441 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007442 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007443 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007444 "Address Family\n"
7445 "Display VPN NLRI specific information\n"
7446 "Display information for a route distinguisher\n"
7447 "VPN Route Distinguisher\n"
7448 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007449{
Lou Berger35c36862016-01-12 13:42:06 -05007450 int ret;
7451 struct prefix_rd prd;
7452
7453 ret = str2prefix_rd (argv[0], &prd);
7454 if (! ret)
7455 {
7456 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7457 return CMD_WARNING;
7458 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007459 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
7460}
7461
7462DEFUN (show_bgp_prefix_pathtype,
7463 show_bgp_prefix_pathtype_cmd,
7464 "show bgp X:X::X:X/M (bestpath|multipath)",
7465 SHOW_STR
7466 BGP_STR
7467 "IPv6 prefix <network>/<length>\n"
7468 "Display only the bestpath\n"
7469 "Display only multipaths\n")
7470{
7471 if (strncmp (argv[1], "b", 1) == 0)
7472 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7473 else
7474 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7475}
7476
7477ALIAS (show_bgp_prefix_pathtype,
7478 show_bgp_ipv6_prefix_pathtype_cmd,
7479 "show bgp ipv6 X:X::X:X/M (bestpath|multipath)",
7480 SHOW_STR
7481 BGP_STR
7482 "Address family\n"
7483 "IPv6 prefix <network>/<length>\n"
7484 "Display only the bestpath\n"
7485 "Display only multipaths\n")
7486
7487DEFUN (show_bgp_ipv6_safi_prefix_pathtype,
7488 show_bgp_ipv6_safi_prefix_pathtype_cmd,
7489 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath)",
7490 SHOW_STR
7491 BGP_STR
7492 "Address family\n"
7493 "Address Family modifier\n"
7494 "Address Family modifier\n"
7495 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
7496 "Display only the bestpath\n"
7497 "Display only multipaths\n")
7498{
7499 if (strncmp (argv[0], "m", 1) == 0)
7500 if (strncmp (argv[2], "b", 1) == 0)
7501 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH);
7502 else
7503 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH);
7504 else
7505 if (strncmp (argv[2], "b", 1) == 0)
7506 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7507 else
7508 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
paul718e3742002-12-13 20:15:29 +00007509}
7510
Lou Berger651b4022016-01-12 13:42:07 -05007511DEFUN (show_bgp_ipv4_encap_route,
7512 show_bgp_ipv4_encap_route_cmd,
7513 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007514 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007515 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007516 IP_STR
7517 "Display ENCAP NLRI specific information\n"
7518 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007519{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007520 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007521}
7522
Lou Berger651b4022016-01-12 13:42:07 -05007523DEFUN (show_bgp_ipv6_encap_route,
7524 show_bgp_ipv6_encap_route_cmd,
7525 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007526 SHOW_STR
7527 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007528 IP6_STR
7529 "Display ENCAP NLRI specific information\n"
7530 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007531{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007532 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007533}
7534
Lou Berger651b4022016-01-12 13:42:07 -05007535DEFUN (show_bgp_ipv4_safi_rd_route,
7536 show_bgp_ipv4_safi_rd_route_cmd,
7537 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007538 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007539 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007540 "Address Family\n"
7541 "Address Family Modifier\n"
7542 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007543 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007544 "ENCAP Route Distinguisher\n"
7545 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007546{
7547 int ret;
7548 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007549 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007550
Lou Berger651b4022016-01-12 13:42:07 -05007551 if (bgp_parse_safi(argv[0], &safi)) {
7552 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7553 return CMD_WARNING;
7554 }
7555 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007556 if (! ret)
7557 {
7558 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7559 return CMD_WARNING;
7560 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007561 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007562}
7563
Lou Berger651b4022016-01-12 13:42:07 -05007564DEFUN (show_bgp_ipv6_safi_rd_route,
7565 show_bgp_ipv6_safi_rd_route_cmd,
7566 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007567 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007568 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007569 "Address Family\n"
7570 "Address Family Modifier\n"
7571 "Address Family Modifier\n"
7572 "Display information for a route distinguisher\n"
7573 "ENCAP Route Distinguisher\n"
7574 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007575{
Lou Berger651b4022016-01-12 13:42:07 -05007576 int ret;
7577 struct prefix_rd prd;
7578 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007579
Lou Berger651b4022016-01-12 13:42:07 -05007580 if (bgp_parse_safi(argv[0], &safi)) {
7581 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7582 return CMD_WARNING;
7583 }
7584 ret = str2prefix_rd (argv[1], &prd);
7585 if (! ret)
7586 {
7587 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7588 return CMD_WARNING;
7589 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007590 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007591}
7592
Lou Berger35c36862016-01-12 13:42:06 -05007593DEFUN (show_bgp_ipv4_prefix,
7594 show_bgp_ipv4_prefix_cmd,
7595 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007596 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007597 BGP_STR
paul718e3742002-12-13 20:15:29 +00007598 IP_STR
paul718e3742002-12-13 20:15:29 +00007599 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7600{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007601 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007602}
7603
Lou Berger35c36862016-01-12 13:42:06 -05007604DEFUN (show_bgp_ipv4_safi_prefix,
7605 show_bgp_ipv4_safi_prefix_cmd,
7606 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007607 SHOW_STR
7608 BGP_STR
7609 "Address family\n"
7610 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007611 "Address Family modifier\n"
7612 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007613{
7614 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007615 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007616
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007617 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007618}
7619
Lou Berger35c36862016-01-12 13:42:06 -05007620DEFUN (show_bgp_ipv4_vpn_prefix,
7621 show_bgp_ipv4_vpn_prefix_cmd,
7622 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007623 SHOW_STR
7624 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007625 IP_STR
7626 "Display VPN NLRI specific information\n"
7627 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007628{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007629 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007630}
7631
Lou Berger35c36862016-01-12 13:42:06 -05007632DEFUN (show_bgp_ipv6_vpn_prefix,
7633 show_bgp_ipv6_vpn_prefix_cmd,
7634 "show bgp ipv6 vpn X:X::X:X/M",
7635 SHOW_STR
7636 BGP_STR
7637 "Address Family\n"
7638 "Display VPN NLRI specific information\n"
7639 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7640{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007641 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 -05007642}
Lou Berger35c36862016-01-12 13:42:06 -05007643
Lou Berger651b4022016-01-12 13:42:07 -05007644DEFUN (show_bgp_ipv4_encap_prefix,
7645 show_bgp_ipv4_encap_prefix_cmd,
7646 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007647 SHOW_STR
7648 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007649 IP_STR
7650 "Display ENCAP NLRI specific information\n"
7651 "Display information about ENCAP NLRIs\n"
7652 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7653{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007654 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007655}
paul718e3742002-12-13 20:15:29 +00007656
Lou Berger651b4022016-01-12 13:42:07 -05007657DEFUN (show_bgp_ipv6_encap_prefix,
7658 show_bgp_ipv6_encap_prefix_cmd,
7659 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007660 SHOW_STR
7661 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007662 IP_STR
7663 "Display ENCAP NLRI specific information\n"
7664 "Display information about ENCAP NLRIs\n"
7665 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7666{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007667 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007668}
Lou Berger651b4022016-01-12 13:42:07 -05007669
7670DEFUN (show_bgp_ipv4_safi_rd_prefix,
7671 show_bgp_ipv4_safi_rd_prefix_cmd,
7672 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7673 SHOW_STR
7674 BGP_STR
7675 "Address Family\n"
7676 "Address Family Modifier\n"
7677 "Address Family Modifier\n"
7678 "Display information for a route distinguisher\n"
7679 "ENCAP Route Distinguisher\n"
7680 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7681{
7682 int ret;
7683 struct prefix_rd prd;
7684 safi_t safi;
7685
7686 if (bgp_parse_safi(argv[0], &safi)) {
7687 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7688 return CMD_WARNING;
7689 }
7690
7691 ret = str2prefix_rd (argv[1], &prd);
7692 if (! ret)
7693 {
7694 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7695 return CMD_WARNING;
7696 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007697 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007698}
7699
Lou Berger651b4022016-01-12 13:42:07 -05007700DEFUN (show_bgp_ipv6_safi_rd_prefix,
7701 show_bgp_ipv6_safi_rd_prefix_cmd,
7702 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7703 SHOW_STR
7704 BGP_STR
7705 "Address Family\n"
7706 "Address Family Modifier\n"
7707 "Address Family Modifier\n"
7708 "Display information for a route distinguisher\n"
7709 "ENCAP Route Distinguisher\n"
7710 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7711{
7712 int ret;
7713 struct prefix_rd prd;
7714 safi_t safi;
7715
7716 if (bgp_parse_safi(argv[0], &safi)) {
7717 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7718 return CMD_WARNING;
7719 }
7720
7721 ret = str2prefix_rd (argv[1], &prd);
7722 if (! ret)
7723 {
7724 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7725 return CMD_WARNING;
7726 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007727 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007728}
Lou Berger651b4022016-01-12 13:42:07 -05007729
7730DEFUN (show_bgp_afi_safi_view,
7731 show_bgp_afi_safi_view_cmd,
7732 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7733 SHOW_STR
7734 BGP_STR
7735 "BGP view\n"
7736 "BGP view name\n"
7737 "Address Family\n"
7738 "Address Family\n"
7739 "Address Family Modifier\n"
7740 "Address Family Modifier\n"
7741 "Address Family Modifier\n"
7742 "Address Family Modifier\n"
7743 )
7744{
7745 struct bgp *bgp;
7746 safi_t safi;
7747 afi_t afi;
7748
7749 if (bgp_parse_afi(argv[1], &afi)) {
7750 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7751 return CMD_WARNING;
7752 }
7753 if (bgp_parse_safi(argv[2], &safi)) {
7754 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7755 return CMD_WARNING;
7756 }
7757
7758 /* BGP structure lookup. */
7759 bgp = bgp_lookup_by_name (argv[0]);
7760 if (bgp == NULL)
7761 {
7762 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7763 return CMD_WARNING;
7764 }
7765
7766 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7767}
7768
7769DEFUN (show_bgp_view_afi_safi_route,
7770 show_bgp_view_afi_safi_route_cmd,
7771 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7772 SHOW_STR
7773 BGP_STR
7774 "BGP view\n"
7775 "View name\n"
7776 "Address Family\n"
7777 "Address Family\n"
7778 "Address Family Modifier\n"
7779 "Address Family Modifier\n"
7780 "Address Family Modifier\n"
7781 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007782 "Network in the BGP routing table to display\n")
7783{
Lou Berger651b4022016-01-12 13:42:07 -05007784 safi_t safi;
7785 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007786
Lou Berger651b4022016-01-12 13:42:07 -05007787 if (bgp_parse_afi(argv[1], &afi)) {
7788 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7789 return CMD_WARNING;
7790 }
7791 if (bgp_parse_safi(argv[2], &safi)) {
7792 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7793 return CMD_WARNING;
7794 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007795 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007796}
7797
7798DEFUN (show_bgp_view_afi_safi_prefix,
7799 show_bgp_view_afi_safi_prefix_cmd,
7800 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7801 SHOW_STR
7802 BGP_STR
7803 "BGP view\n"
7804 "View name\n"
7805 "Address Family\n"
7806 "Address Family\n"
7807 "Address Family Modifier\n"
7808 "Address Family Modifier\n"
7809 "Address Family Modifier\n"
7810 "Address Family Modifier\n"
7811 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7812{
7813 safi_t safi;
7814 afi_t afi;
7815
7816 if (bgp_parse_afi(argv[1], &afi)) {
7817 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7818 return CMD_WARNING;
7819 }
7820 if (bgp_parse_safi(argv[2], &safi)) {
7821 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7822 return CMD_WARNING;
7823 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007824 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007825}
7826
7827/* new001 */
7828DEFUN (show_bgp_afi,
7829 show_bgp_afi_cmd,
7830 "show bgp (ipv4|ipv6)",
7831 SHOW_STR
7832 BGP_STR
7833 "Address family\n"
7834 "Address family\n")
7835{
7836 afi_t afi;
7837
7838 if (bgp_parse_afi(argv[0], &afi)) {
7839 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7840 return CMD_WARNING;
7841 }
7842 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7843 NULL);
7844}
7845
Lou Berger651b4022016-01-12 13:42:07 -05007846DEFUN (show_bgp_ipv6_safi,
7847 show_bgp_ipv6_safi_cmd,
7848 "show bgp ipv6 (unicast|multicast)",
7849 SHOW_STR
7850 BGP_STR
7851 "Address family\n"
7852 "Address Family modifier\n"
7853 "Address Family modifier\n")
7854{
7855 if (strncmp (argv[0], "m", 1) == 0)
7856 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7857 NULL);
7858
7859 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007860}
7861
Lou Berger35c36862016-01-12 13:42:06 -05007862DEFUN (show_bgp_ipv6_route,
7863 show_bgp_ipv6_route_cmd,
7864 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007865 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007866 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007867 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007868 "Network in the BGP routing table to display\n")
7869{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007870 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007871}
7872
Lou Berger35c36862016-01-12 13:42:06 -05007873DEFUN (show_bgp_ipv6_safi_route,
7874 show_bgp_ipv6_safi_route_cmd,
7875 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007876 SHOW_STR
7877 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007878 "Address family\n"
7879 "Address Family modifier\n"
7880 "Address Family modifier\n"
7881 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007882{
Lou Berger35c36862016-01-12 13:42:06 -05007883 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007884 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Berger35c36862016-01-12 13:42:06 -05007885
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007886 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007887}
7888
Lou Bergerf9b6c392016-01-12 13:42:09 -05007889/* old command */
7890DEFUN (show_ipv6_bgp_route,
7891 show_ipv6_bgp_route_cmd,
7892 "show ipv6 bgp X:X::X:X",
7893 SHOW_STR
7894 IP_STR
7895 BGP_STR
7896 "Network in the BGP routing table to display\n")
7897{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007898 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007899}
7900
7901DEFUN (show_bgp_prefix,
7902 show_bgp_prefix_cmd,
7903 "show bgp X:X::X:X/M",
7904 SHOW_STR
7905 BGP_STR
7906 "IPv6 prefix <network>/<length>\n")
7907{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007908 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007909}
7910
7911
Lou Berger35c36862016-01-12 13:42:06 -05007912/* new002 */
7913DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007914 show_bgp_ipv6_prefix_cmd,
7915 "show bgp ipv6 X:X::X:X/M",
7916 SHOW_STR
7917 BGP_STR
7918 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007919 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7920{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007921 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Berger35c36862016-01-12 13:42:06 -05007922}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007923DEFUN (show_bgp_ipv6_safi_prefix,
7924 show_bgp_ipv6_safi_prefix_cmd,
7925 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7926 SHOW_STR
7927 BGP_STR
7928 "Address family\n"
7929 "Address Family modifier\n"
7930 "Address Family modifier\n"
7931 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7932{
7933 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007934 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007935
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007936 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007937}
7938
Lou Bergerf9b6c392016-01-12 13:42:09 -05007939/* old command */
7940DEFUN (show_ipv6_bgp_prefix,
7941 show_ipv6_bgp_prefix_cmd,
7942 "show ipv6 bgp X:X::X:X/M",
7943 SHOW_STR
7944 IP_STR
7945 BGP_STR
7946 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7947{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007948 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007949}
7950
paulbb46e942003-10-24 19:02:03 +00007951DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007952 show_bgp_view_cmd,
7953 "show bgp view WORD",
7954 SHOW_STR
7955 BGP_STR
7956 "BGP view\n"
7957 "View name\n")
7958{
7959 struct bgp *bgp;
7960
7961 /* BGP structure lookup. */
7962 bgp = bgp_lookup_by_name (argv[0]);
7963 if (bgp == NULL)
7964 {
7965 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7966 return CMD_WARNING;
7967 }
7968
7969 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7970}
7971
7972DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05007973 show_bgp_view_ipv6_cmd,
7974 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00007975 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05007976 BGP_STR
paulbb46e942003-10-24 19:02:03 +00007977 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05007978 "View name\n"
7979 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00007980{
7981 struct bgp *bgp;
7982
7983 /* BGP structure lookup. */
7984 bgp = bgp_lookup_by_name (argv[0]);
7985 if (bgp == NULL)
7986 {
7987 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7988 return CMD_WARNING;
7989 }
7990
ajs5a646652004-11-05 01:25:55 +00007991 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00007992}
paulbb46e942003-10-24 19:02:03 +00007993
7994DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007995 show_bgp_view_route_cmd,
7996 "show bgp view WORD X:X::X:X",
7997 SHOW_STR
7998 BGP_STR
7999 "BGP view\n"
8000 "View name\n"
8001 "Network in the BGP routing table to display\n")
8002{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008003 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 -05008004}
8005
8006DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00008007 show_bgp_view_ipv6_route_cmd,
8008 "show bgp view WORD ipv6 X:X::X:X",
8009 SHOW_STR
8010 BGP_STR
8011 "BGP view\n"
8012 "View name\n"
8013 "Address family\n"
8014 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00008015{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008016 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paulbb46e942003-10-24 19:02:03 +00008017}
8018
Lou Bergerf9b6c392016-01-12 13:42:09 -05008019/* old command */
8020DEFUN (show_ipv6_mbgp,
8021 show_ipv6_mbgp_cmd,
8022 "show ipv6 mbgp",
8023 SHOW_STR
8024 IP_STR
8025 MBGP_STR)
8026{
8027 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
8028 NULL);
8029}
8030
8031/* old command */
8032DEFUN (show_ipv6_mbgp_route,
8033 show_ipv6_mbgp_route_cmd,
8034 "show ipv6 mbgp X:X::X:X",
8035 SHOW_STR
8036 IP_STR
8037 MBGP_STR
8038 "Network in the MBGP routing table to display\n")
8039{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008040 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05008041}
8042
8043/* old command */
8044DEFUN (show_ipv6_mbgp_prefix,
8045 show_ipv6_mbgp_prefix_cmd,
8046 "show ipv6 mbgp X:X::X:X/M",
8047 SHOW_STR
8048 IP_STR
8049 MBGP_STR
8050 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
8051{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008052 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05008053}
8054
Lou Berger35c36862016-01-12 13:42:06 -05008055DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05008056 show_bgp_view_prefix_cmd,
8057 "show bgp view WORD X:X::X:X/M",
8058 SHOW_STR
8059 BGP_STR
8060 "BGP view\n"
8061 "View name\n"
8062 "IPv6 prefix <network>/<length>\n")
8063{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008064 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 -05008065}
8066
8067DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00008068 show_bgp_view_ipv6_prefix_cmd,
8069 "show bgp view WORD ipv6 X:X::X:X/M",
8070 SHOW_STR
8071 BGP_STR
8072 "BGP view\n"
8073 "View name\n"
8074 "Address family\n"
8075 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00008076{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008077 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00008078}
8079
paul94f2b392005-06-28 12:44:16 +00008080static int
paulfd79ac92004-10-13 05:06:08 +00008081bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008082 safi_t safi, enum bgp_show_type type)
8083{
8084 int i;
8085 struct buffer *b;
8086 char *regstr;
8087 int first;
8088 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00008089 int rc;
paul718e3742002-12-13 20:15:29 +00008090
8091 first = 0;
8092 b = buffer_new (1024);
8093 for (i = 0; i < argc; i++)
8094 {
8095 if (first)
8096 buffer_putc (b, ' ');
8097 else
8098 {
8099 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
8100 continue;
8101 first = 1;
8102 }
8103
8104 buffer_putstr (b, argv[i]);
8105 }
8106 buffer_putc (b, '\0');
8107
8108 regstr = buffer_getstr (b);
8109 buffer_free (b);
8110
8111 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00008112 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00008113 if (! regex)
8114 {
8115 vty_out (vty, "Can't compile regexp %s%s", argv[0],
8116 VTY_NEWLINE);
8117 return CMD_WARNING;
8118 }
8119
ajs5a646652004-11-05 01:25:55 +00008120 rc = bgp_show (vty, NULL, afi, safi, type, regex);
8121 bgp_regex_free (regex);
8122 return rc;
paul718e3742002-12-13 20:15:29 +00008123}
8124
Lou Bergerf9b6c392016-01-12 13:42:09 -05008125
8126DEFUN (show_ip_bgp_regexp,
8127 show_ip_bgp_regexp_cmd,
8128 "show ip bgp regexp .LINE",
8129 SHOW_STR
8130 IP_STR
8131 BGP_STR
8132 "Display routes matching the AS path regular expression\n"
8133 "A regular-expression to match the BGP AS paths\n")
8134{
8135 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8136 bgp_show_type_regexp);
8137}
8138
8139DEFUN (show_ip_bgp_flap_regexp,
8140 show_ip_bgp_flap_regexp_cmd,
8141 "show ip bgp flap-statistics regexp .LINE",
8142 SHOW_STR
8143 IP_STR
8144 BGP_STR
8145 "Display flap statistics of routes\n"
8146 "Display routes matching the AS path regular expression\n"
8147 "A regular-expression to match the BGP AS paths\n")
8148{
8149 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8150 bgp_show_type_flap_regexp);
8151}
8152
8153ALIAS (show_ip_bgp_flap_regexp,
8154 show_ip_bgp_damp_flap_regexp_cmd,
8155 "show ip bgp dampening flap-statistics regexp .LINE",
8156 SHOW_STR
8157 IP_STR
8158 BGP_STR
8159 "Display detailed information about dampening\n"
8160 "Display flap statistics of routes\n"
8161 "Display routes matching the AS path regular expression\n"
8162 "A regular-expression to match the BGP AS paths\n")
8163
8164DEFUN (show_ip_bgp_ipv4_regexp,
8165 show_ip_bgp_ipv4_regexp_cmd,
8166 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
8167 SHOW_STR
8168 IP_STR
8169 BGP_STR
8170 "Address family\n"
8171 "Address Family modifier\n"
8172 "Address Family modifier\n"
8173 "Display routes matching the AS path regular expression\n"
8174 "A regular-expression to match the BGP AS paths\n")
8175{
8176 if (strncmp (argv[0], "m", 1) == 0)
8177 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
8178 bgp_show_type_regexp);
8179
8180 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8181 bgp_show_type_regexp);
8182}
8183
Lou Bergerf9b6c392016-01-12 13:42:09 -05008184DEFUN (show_bgp_regexp,
8185 show_bgp_regexp_cmd,
8186 "show bgp regexp .LINE",
8187 SHOW_STR
8188 BGP_STR
8189 "Display routes matching the AS path regular expression\n"
8190 "A regular-expression to match the BGP AS paths\n")
8191{
8192 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8193 bgp_show_type_regexp);
8194}
8195
8196/* old command */
8197DEFUN (show_ipv6_bgp_regexp,
8198 show_ipv6_bgp_regexp_cmd,
8199 "show ipv6 bgp regexp .LINE",
8200 SHOW_STR
8201 IP_STR
8202 BGP_STR
8203 "Display routes matching the AS path regular expression\n"
8204 "A regular-expression to match the BGP AS paths\n")
8205{
8206 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8207 bgp_show_type_regexp);
8208}
8209
8210/* old command */
8211DEFUN (show_ipv6_mbgp_regexp,
8212 show_ipv6_mbgp_regexp_cmd,
8213 "show ipv6 mbgp regexp .LINE",
8214 SHOW_STR
8215 IP_STR
8216 BGP_STR
8217 "Display routes matching the AS path regular expression\n"
8218 "A regular-expression to match the MBGP AS paths\n")
8219{
8220 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
8221 bgp_show_type_regexp);
8222}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008223
Lou Berger651b4022016-01-12 13:42:07 -05008224DEFUN (show_bgp_ipv4_safi_flap_regexp,
8225 show_bgp_ipv4_safi_flap_regexp_cmd,
8226 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008227 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008228 BGP_STR
paul718e3742002-12-13 20:15:29 +00008229 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008230 "Address Family Modifier\n"
8231 "Address Family Modifier\n"
8232 "Address Family Modifier\n"
8233 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008234 "Display flap statistics of routes\n"
8235 "Display routes matching the AS path regular expression\n"
8236 "A regular-expression to match the BGP AS paths\n")
8237{
Lou Berger651b4022016-01-12 13:42:07 -05008238 safi_t safi;
8239
8240 if (bgp_parse_safi(argv[0], &safi)) {
8241 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8242 return CMD_WARNING;
8243 }
8244 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
8245 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00008246}
8247
Lou Berger651b4022016-01-12 13:42:07 -05008248ALIAS (show_bgp_ipv4_safi_flap_regexp,
8249 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
8250 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05308251 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308252 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008253 IP_STR
8254 "Address Family Modifier\n"
8255 "Address Family Modifier\n"
8256 "Address Family Modifier\n"
8257 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308258 "Display detailed information about dampening\n"
8259 "Display flap statistics of routes\n"
8260 "Display routes matching the AS path regular expression\n"
8261 "A regular-expression to match the BGP AS paths\n")
8262
Lou Berger651b4022016-01-12 13:42:07 -05008263DEFUN (show_bgp_ipv6_safi_flap_regexp,
8264 show_bgp_ipv6_safi_flap_regexp_cmd,
8265 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008266 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008267 BGP_STR
8268 IPV6_STR
8269 "Address Family Modifier\n"
8270 "Address Family Modifier\n"
8271 "Address Family Modifier\n"
8272 "Address Family Modifier\n"
8273 "Display flap statistics of routes\n"
8274 "Display routes matching the AS path regular expression\n"
8275 "A regular-expression to match the BGP AS paths\n")
8276{
8277 safi_t safi;
8278
8279 if (bgp_parse_safi(argv[0], &safi)) {
8280 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8281 return CMD_WARNING;
8282 }
8283 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8284 bgp_show_type_flap_regexp);
8285}
8286
8287ALIAS (show_bgp_ipv6_safi_flap_regexp,
8288 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8289 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8290 SHOW_STR
8291 BGP_STR
8292 IPV6_STR
8293 "Address Family Modifier\n"
8294 "Address Family Modifier\n"
8295 "Address Family Modifier\n"
8296 "Address Family Modifier\n"
8297 "Display detailed information about dampening\n"
8298 "Display flap statistics of routes\n"
8299 "Display routes matching the AS path regular expression\n"
8300 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008301
8302DEFUN (show_bgp_ipv4_safi_regexp,
8303 show_bgp_ipv4_safi_regexp_cmd,
8304 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8305 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008306 BGP_STR
8307 "Address family\n"
8308 "Address Family modifier\n"
8309 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008310 "Address Family modifier\n"
8311 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008312 "Display routes matching the AS path regular expression\n"
8313 "A regular-expression to match the BGP AS paths\n")
8314{
Lou Berger651b4022016-01-12 13:42:07 -05008315 safi_t safi;
8316 if (bgp_parse_safi(argv[0], &safi)) {
8317 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8318 return CMD_WARNING;
8319 }
paul718e3742002-12-13 20:15:29 +00008320
Lou Berger651b4022016-01-12 13:42:07 -05008321 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008322 bgp_show_type_regexp);
8323}
Lou Berger205e6742016-01-12 13:42:11 -05008324
Lou Berger651b4022016-01-12 13:42:07 -05008325DEFUN (show_bgp_ipv6_safi_regexp,
8326 show_bgp_ipv6_safi_regexp_cmd,
8327 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008328 SHOW_STR
8329 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008330 "Address family\n"
8331 "Address Family modifier\n"
8332 "Address Family modifier\n"
8333 "Address Family modifier\n"
8334 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008335 "Display routes matching the AS path regular expression\n"
8336 "A regular-expression to match the BGP AS paths\n")
8337{
Lou Berger651b4022016-01-12 13:42:07 -05008338 safi_t safi;
8339 if (bgp_parse_safi(argv[0], &safi)) {
8340 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8341 return CMD_WARNING;
8342 }
8343
8344 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008345 bgp_show_type_regexp);
8346}
8347
Lou Berger651b4022016-01-12 13:42:07 -05008348DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008349 show_bgp_ipv6_regexp_cmd,
8350 "show bgp ipv6 regexp .LINE",
8351 SHOW_STR
8352 BGP_STR
8353 "Address family\n"
8354 "Display routes matching the AS path regular expression\n"
8355 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008356{
8357 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8358 bgp_show_type_regexp);
8359}
8360
paul94f2b392005-06-28 12:44:16 +00008361static int
paulfd79ac92004-10-13 05:06:08 +00008362bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008363 safi_t safi, enum bgp_show_type type)
8364{
8365 struct prefix_list *plist;
8366
8367 plist = prefix_list_lookup (afi, prefix_list_str);
8368 if (plist == NULL)
8369 {
8370 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8371 prefix_list_str, VTY_NEWLINE);
8372 return CMD_WARNING;
8373 }
8374
ajs5a646652004-11-05 01:25:55 +00008375 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008376}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008377DEFUN (show_ip_bgp_prefix_list,
8378 show_ip_bgp_prefix_list_cmd,
8379 "show ip bgp prefix-list WORD",
8380 SHOW_STR
8381 IP_STR
8382 BGP_STR
8383 "Display routes conforming to the prefix-list\n"
8384 "IP prefix-list name\n")
8385{
8386 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8387 bgp_show_type_prefix_list);
8388}
8389
8390DEFUN (show_ip_bgp_flap_prefix_list,
8391 show_ip_bgp_flap_prefix_list_cmd,
8392 "show ip bgp flap-statistics prefix-list WORD",
8393 SHOW_STR
8394 IP_STR
8395 BGP_STR
8396 "Display flap statistics of routes\n"
8397 "Display routes conforming to the prefix-list\n"
8398 "IP prefix-list name\n")
8399{
8400 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8401 bgp_show_type_flap_prefix_list);
8402}
8403
8404ALIAS (show_ip_bgp_flap_prefix_list,
8405 show_ip_bgp_damp_flap_prefix_list_cmd,
8406 "show ip bgp dampening flap-statistics prefix-list WORD",
8407 SHOW_STR
8408 IP_STR
8409 BGP_STR
8410 "Display detailed information about dampening\n"
8411 "Display flap statistics of routes\n"
8412 "Display routes conforming to the prefix-list\n"
8413 "IP prefix-list name\n")
8414
8415DEFUN (show_ip_bgp_ipv4_prefix_list,
8416 show_ip_bgp_ipv4_prefix_list_cmd,
8417 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8418 SHOW_STR
8419 IP_STR
8420 BGP_STR
8421 "Address family\n"
8422 "Address Family modifier\n"
8423 "Address Family modifier\n"
8424 "Display routes conforming to the prefix-list\n"
8425 "IP prefix-list name\n")
8426{
8427 if (strncmp (argv[0], "m", 1) == 0)
8428 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8429 bgp_show_type_prefix_list);
8430
8431 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8432 bgp_show_type_prefix_list);
8433}
8434
Lou Bergerf9b6c392016-01-12 13:42:09 -05008435DEFUN (show_bgp_prefix_list,
8436 show_bgp_prefix_list_cmd,
8437 "show bgp prefix-list WORD",
8438 SHOW_STR
8439 BGP_STR
8440 "Display routes conforming to the prefix-list\n"
8441 "IPv6 prefix-list name\n")
8442{
8443 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8444 bgp_show_type_prefix_list);
8445}
8446
8447ALIAS (show_bgp_prefix_list,
8448 show_bgp_ipv6_prefix_list_cmd,
8449 "show bgp ipv6 prefix-list WORD",
8450 SHOW_STR
8451 BGP_STR
8452 "Address family\n"
8453 "Display routes conforming to the prefix-list\n"
8454 "IPv6 prefix-list name\n")
8455
8456/* old command */
8457DEFUN (show_ipv6_bgp_prefix_list,
8458 show_ipv6_bgp_prefix_list_cmd,
8459 "show ipv6 bgp prefix-list WORD",
8460 SHOW_STR
8461 IPV6_STR
8462 BGP_STR
8463 "Display routes matching the prefix-list\n"
8464 "IPv6 prefix-list name\n")
8465{
8466 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8467 bgp_show_type_prefix_list);
8468}
8469
8470/* old command */
8471DEFUN (show_ipv6_mbgp_prefix_list,
8472 show_ipv6_mbgp_prefix_list_cmd,
8473 "show ipv6 mbgp prefix-list WORD",
8474 SHOW_STR
8475 IPV6_STR
8476 MBGP_STR
8477 "Display routes matching the prefix-list\n"
8478 "IPv6 prefix-list name\n")
8479{
8480 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8481 bgp_show_type_prefix_list);
8482}
paul718e3742002-12-13 20:15:29 +00008483
Lou Berger35c36862016-01-12 13:42:06 -05008484DEFUN (show_bgp_ipv4_prefix_list,
8485 show_bgp_ipv4_prefix_list_cmd,
8486 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008487 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008488 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008489 IP_STR
paul718e3742002-12-13 20:15:29 +00008490 "Display routes conforming to the prefix-list\n"
8491 "IP prefix-list name\n")
8492{
8493 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8494 bgp_show_type_prefix_list);
8495}
8496
Lou Berger651b4022016-01-12 13:42:07 -05008497DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8498 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8499 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008500 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008501 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008502 IP_STR
8503 "Address Family Modifier\n"
8504 "Address Family Modifier\n"
8505 "Address Family Modifier\n"
8506 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008507 "Display flap statistics of routes\n"
8508 "Display routes conforming to the prefix-list\n"
8509 "IP prefix-list name\n")
8510{
Lou Berger651b4022016-01-12 13:42:07 -05008511 safi_t safi;
8512 if (bgp_parse_safi(argv[0], &safi)) {
8513 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8514 return CMD_WARNING;
8515 }
8516 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008517 bgp_show_type_flap_prefix_list);
8518}
8519
Lou Berger651b4022016-01-12 13:42:07 -05008520ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8521 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8522 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308523 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308524 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008525 IP_STR
8526 "Address Family Modifier\n"
8527 "Address Family Modifier\n"
8528 "Address Family Modifier\n"
8529 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308530 "Display detailed information about dampening\n"
8531 "Display flap statistics of routes\n"
8532 "Display routes conforming to the prefix-list\n"
8533 "IP prefix-list name\n")
8534
Lou Berger651b4022016-01-12 13:42:07 -05008535DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8536 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8537 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008538 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008539 BGP_STR
8540 IPV6_STR
8541 "Address Family Modifier\n"
8542 "Address Family Modifier\n"
8543 "Address Family Modifier\n"
8544 "Address Family Modifier\n"
8545 "Display flap statistics of routes\n"
8546 "Display routes conforming to the prefix-list\n"
8547 "IP prefix-list name\n")
8548{
8549 safi_t safi;
8550 if (bgp_parse_safi(argv[0], &safi)) {
8551 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8552 return CMD_WARNING;
8553 }
8554 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8555 bgp_show_type_flap_prefix_list);
8556}
8557ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8558 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8559 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8560 SHOW_STR
8561 BGP_STR
8562 IPV6_STR
8563 "Address Family Modifier\n"
8564 "Address Family Modifier\n"
8565 "Address Family Modifier\n"
8566 "Address Family Modifier\n"
8567 "Display detailed information about dampening\n"
8568 "Display flap statistics of routes\n"
8569 "Display routes conforming to the prefix-list\n"
8570 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008571
8572DEFUN (show_bgp_ipv4_safi_prefix_list,
8573 show_bgp_ipv4_safi_prefix_list_cmd,
8574 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8575 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008576 BGP_STR
8577 "Address family\n"
8578 "Address Family modifier\n"
8579 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008580 "Address Family modifier\n"
8581 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008582 "Display routes conforming to the prefix-list\n"
8583 "IP prefix-list name\n")
8584{
Lou Berger651b4022016-01-12 13:42:07 -05008585 safi_t safi;
8586 if (bgp_parse_safi(argv[0], &safi)) {
8587 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8588 return CMD_WARNING;
8589 }
8590 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008591 bgp_show_type_prefix_list);
8592}
Lou Berger205e6742016-01-12 13:42:11 -05008593
Lou Berger651b4022016-01-12 13:42:07 -05008594DEFUN (show_bgp_ipv6_safi_prefix_list,
8595 show_bgp_ipv6_safi_prefix_list_cmd,
8596 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008597 SHOW_STR
8598 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008599 "Address family\n"
8600 "Address Family modifier\n"
8601 "Address Family modifier\n"
8602 "Address Family modifier\n"
8603 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008604 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008605 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008606{
Lou Berger651b4022016-01-12 13:42:07 -05008607 safi_t safi;
8608 if (bgp_parse_safi(argv[0], &safi)) {
8609 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8610 return CMD_WARNING;
8611 }
8612 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008613 bgp_show_type_prefix_list);
8614}
8615
paul94f2b392005-06-28 12:44:16 +00008616static int
paulfd79ac92004-10-13 05:06:08 +00008617bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008618 safi_t safi, enum bgp_show_type type)
8619{
8620 struct as_list *as_list;
8621
8622 as_list = as_list_lookup (filter);
8623 if (as_list == NULL)
8624 {
8625 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8626 return CMD_WARNING;
8627 }
8628
ajs5a646652004-11-05 01:25:55 +00008629 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008630}
8631
Lou Bergerf9b6c392016-01-12 13:42:09 -05008632DEFUN (show_ip_bgp_filter_list,
8633 show_ip_bgp_filter_list_cmd,
8634 "show ip bgp filter-list WORD",
8635 SHOW_STR
8636 IP_STR
8637 BGP_STR
8638 "Display routes conforming to the filter-list\n"
8639 "Regular expression access list name\n")
8640{
8641 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8642 bgp_show_type_filter_list);
8643}
8644
8645DEFUN (show_ip_bgp_flap_filter_list,
8646 show_ip_bgp_flap_filter_list_cmd,
8647 "show ip bgp flap-statistics filter-list WORD",
8648 SHOW_STR
8649 IP_STR
8650 BGP_STR
8651 "Display flap statistics of routes\n"
8652 "Display routes conforming to the filter-list\n"
8653 "Regular expression access list name\n")
8654{
8655 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8656 bgp_show_type_flap_filter_list);
8657}
8658
8659ALIAS (show_ip_bgp_flap_filter_list,
8660 show_ip_bgp_damp_flap_filter_list_cmd,
8661 "show ip bgp dampening flap-statistics filter-list WORD",
8662 SHOW_STR
8663 IP_STR
8664 BGP_STR
8665 "Display detailed information about dampening\n"
8666 "Display flap statistics of routes\n"
8667 "Display routes conforming to the filter-list\n"
8668 "Regular expression access list name\n")
8669
8670DEFUN (show_ip_bgp_ipv4_filter_list,
8671 show_ip_bgp_ipv4_filter_list_cmd,
8672 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8673 SHOW_STR
8674 IP_STR
8675 BGP_STR
8676 "Address family\n"
8677 "Address Family modifier\n"
8678 "Address Family modifier\n"
8679 "Display routes conforming to the filter-list\n"
8680 "Regular expression access list name\n")
8681{
8682 if (strncmp (argv[0], "m", 1) == 0)
8683 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8684 bgp_show_type_filter_list);
8685
8686 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8687 bgp_show_type_filter_list);
8688}
8689
Lou Bergerf9b6c392016-01-12 13:42:09 -05008690DEFUN (show_bgp_filter_list,
8691 show_bgp_filter_list_cmd,
8692 "show bgp filter-list WORD",
8693 SHOW_STR
8694 BGP_STR
8695 "Display routes conforming to the filter-list\n"
8696 "Regular expression access list name\n")
8697{
8698 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8699 bgp_show_type_filter_list);
8700}
8701
8702/* old command */
8703DEFUN (show_ipv6_bgp_filter_list,
8704 show_ipv6_bgp_filter_list_cmd,
8705 "show ipv6 bgp filter-list WORD",
8706 SHOW_STR
8707 IPV6_STR
8708 BGP_STR
8709 "Display routes conforming to the filter-list\n"
8710 "Regular expression access list name\n")
8711{
8712 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8713 bgp_show_type_filter_list);
8714}
8715
8716/* old command */
8717DEFUN (show_ipv6_mbgp_filter_list,
8718 show_ipv6_mbgp_filter_list_cmd,
8719 "show ipv6 mbgp filter-list WORD",
8720 SHOW_STR
8721 IPV6_STR
8722 MBGP_STR
8723 "Display routes conforming to the filter-list\n"
8724 "Regular expression access list name\n")
8725{
8726 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8727 bgp_show_type_filter_list);
8728}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008729
8730DEFUN (show_ip_bgp_dampening_info,
8731 show_ip_bgp_dampening_params_cmd,
8732 "show ip bgp dampening parameters",
8733 SHOW_STR
8734 IP_STR
8735 BGP_STR
8736 "Display detailed information about dampening\n"
8737 "Display detail of configured dampening parameters\n")
8738{
8739 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8740}
8741
Lou Berger651b4022016-01-12 13:42:07 -05008742DEFUN (show_bgp_ipv4_filter_list,
8743 show_bgp_ipv4_filter_list_cmd,
8744 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008745 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008746 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008747 IP_STR
paul718e3742002-12-13 20:15:29 +00008748 "Display routes conforming to the filter-list\n"
8749 "Regular expression access list name\n")
8750{
8751 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8752 bgp_show_type_filter_list);
8753}
8754
Lou Berger651b4022016-01-12 13:42:07 -05008755DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8756 show_bgp_ipv4_safi_flap_filter_list_cmd,
8757 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008758 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008759 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008760 IP_STR
8761 "Address Family modifier\n"
8762 "Address Family modifier\n"
8763 "Address Family modifier\n"
8764 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008765 "Display flap statistics of routes\n"
8766 "Display routes conforming to the filter-list\n"
8767 "Regular expression access list name\n")
8768{
Lou Berger651b4022016-01-12 13:42:07 -05008769 safi_t safi;
8770
8771 if (bgp_parse_safi(argv[0], &safi)) {
8772 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8773 return CMD_WARNING;
8774 }
8775 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008776 bgp_show_type_flap_filter_list);
8777}
8778
Lou Berger651b4022016-01-12 13:42:07 -05008779ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8780 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8781 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308782 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308783 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008784 IP_STR
8785 "Address Family modifier\n"
8786 "Address Family modifier\n"
8787 "Address Family modifier\n"
8788 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308789 "Display detailed information about dampening\n"
8790 "Display flap statistics of routes\n"
8791 "Display routes conforming to the filter-list\n"
8792 "Regular expression access list name\n")
8793
Lou Berger651b4022016-01-12 13:42:07 -05008794DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8795 show_bgp_ipv6_safi_flap_filter_list_cmd,
8796 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008797 SHOW_STR
8798 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008799 IPV6_STR
8800 "Address Family modifier\n"
8801 "Address Family modifier\n"
8802 "Address Family modifier\n"
8803 "Address Family modifier\n"
8804 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008805 "Display routes conforming to the filter-list\n"
8806 "Regular expression access list name\n")
8807{
Lou Berger651b4022016-01-12 13:42:07 -05008808 safi_t safi;
8809
8810 if (bgp_parse_safi(argv[0], &safi)) {
8811 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8812 return CMD_WARNING;
8813 }
8814 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8815 bgp_show_type_flap_filter_list);
8816}
8817ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8818 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8819 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8820 SHOW_STR
8821 BGP_STR
8822 IPV6_STR
8823 "Address Family modifier\n"
8824 "Address Family modifier\n"
8825 "Address Family modifier\n"
8826 "Address Family modifier\n"
8827 "Display detailed information about dampening\n"
8828 "Display flap statistics of routes\n"
8829 "Display routes conforming to the filter-list\n"
8830 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008831
8832DEFUN (show_bgp_ipv4_safi_filter_list,
8833 show_bgp_ipv4_safi_filter_list_cmd,
8834 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8835 SHOW_STR
8836 BGP_STR
8837 "Address Family modifier\n"
8838 "Address Family modifier\n"
8839 "Address Family modifier\n"
8840 "Address Family modifier\n"
8841 "Display routes conforming to the filter-list\n"
8842 "Regular expression access list name\n")
8843{
8844 safi_t safi;
8845
8846 if (bgp_parse_safi(argv[0], &safi)) {
8847 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8848 return CMD_WARNING;
8849 }
8850 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8851 bgp_show_type_filter_list);
8852}
Lou Berger205e6742016-01-12 13:42:11 -05008853
Lou Berger651b4022016-01-12 13:42:07 -05008854DEFUN (show_bgp_ipv6_safi_filter_list,
8855 show_bgp_ipv6_safi_filter_list_cmd,
8856 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8857 SHOW_STR
8858 BGP_STR
8859 "Address Family modifier\n"
8860 "Address Family modifier\n"
8861 "Address Family modifier\n"
8862 "Address Family modifier\n"
8863 "Display routes conforming to the filter-list\n"
8864 "Regular expression access list name\n")
8865{
8866 safi_t safi;
8867
8868 if (bgp_parse_safi(argv[0], &safi)) {
8869 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8870 return CMD_WARNING;
8871 }
8872 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8873 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008874}
8875
Lou Bergerf9b6c392016-01-12 13:42:09 -05008876DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008877 show_bgp_ipv6_filter_list_cmd,
8878 "show bgp ipv6 filter-list WORD",
8879 SHOW_STR
8880 BGP_STR
8881 "Address family\n"
8882 "Display routes conforming to the filter-list\n"
8883 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008884{
8885 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8886 bgp_show_type_filter_list);
8887}
8888
Balaji9c52cae2016-01-20 22:59:26 +05308889
8890DEFUN (show_ip_bgp_ipv4_dampening_parameters,
8891 show_ip_bgp_ipv4_dampening_parameters_cmd,
8892 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
8893 SHOW_STR
8894 IP_STR
8895 BGP_STR
8896 "Address family\n"
8897 "Address Family modifier\n"
8898 "Address Family modifier\n"
8899 "Display detailed information about dampening\n"
8900 "Display detail of configured dampening parameters\n")
8901{
8902 if (strncmp(argv[0], "m", 1) == 0)
8903 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST);
8904
8905 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8906}
8907
8908
8909DEFUN (show_ip_bgp_ipv4_dampening_flap_stats,
8910 show_ip_bgp_ipv4_dampening_flap_stats_cmd,
8911 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
8912 SHOW_STR
8913 IP_STR
8914 BGP_STR
8915 "Address family\n"
8916 "Address Family modifier\n"
8917 "Address Family modifier\n"
8918 "Display detailed information about dampening\n"
8919 "Display flap statistics of routes\n")
8920{
8921 if (strncmp(argv[0], "m", 1) == 0)
8922 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8923 bgp_show_type_flap_statistics, NULL);
8924
8925 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8926 bgp_show_type_flap_statistics, NULL);
8927}
8928
8929DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths,
8930 show_ip_bgp_ipv4_dampening_dampd_paths_cmd,
8931 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
8932 SHOW_STR
8933 IP_STR
8934 BGP_STR
8935 "Address family\n"
8936 "Address Family modifier\n"
8937 "Address Family modifier\n"
8938 "Display detailed information about dampening\n"
8939 "Display paths suppressed due to dampening\n")
8940{
8941 if (strncmp(argv[0], "m", 1) == 0)
8942 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8943 bgp_show_type_dampend_paths, NULL);
8944
8945 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8946 bgp_show_type_dampend_paths, NULL);
8947}
8948
paul94f2b392005-06-28 12:44:16 +00008949static int
paulfd79ac92004-10-13 05:06:08 +00008950bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008951 safi_t safi, enum bgp_show_type type)
8952{
8953 struct route_map *rmap;
8954
8955 rmap = route_map_lookup_by_name (rmap_str);
8956 if (! rmap)
8957 {
8958 vty_out (vty, "%% %s is not a valid route-map name%s",
8959 rmap_str, VTY_NEWLINE);
8960 return CMD_WARNING;
8961 }
8962
ajs5a646652004-11-05 01:25:55 +00008963 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00008964}
8965
Lou Bergerf9b6c392016-01-12 13:42:09 -05008966DEFUN (show_ip_bgp_route_map,
8967 show_ip_bgp_route_map_cmd,
8968 "show ip bgp route-map WORD",
8969 SHOW_STR
8970 IP_STR
8971 BGP_STR
8972 "Display routes matching the route-map\n"
8973 "A route-map to match on\n")
8974{
8975 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8976 bgp_show_type_route_map);
8977}
8978
8979DEFUN (show_ip_bgp_flap_route_map,
8980 show_ip_bgp_flap_route_map_cmd,
8981 "show ip bgp flap-statistics route-map WORD",
8982 SHOW_STR
8983 IP_STR
8984 BGP_STR
8985 "Display flap statistics of routes\n"
8986 "Display routes matching the route-map\n"
8987 "A route-map to match on\n")
8988{
8989 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8990 bgp_show_type_flap_route_map);
8991}
8992
8993ALIAS (show_ip_bgp_flap_route_map,
8994 show_ip_bgp_damp_flap_route_map_cmd,
8995 "show ip bgp dampening flap-statistics route-map WORD",
8996 SHOW_STR
8997 IP_STR
8998 BGP_STR
8999 "Display detailed information about dampening\n"
9000 "Display flap statistics of routes\n"
9001 "Display routes matching the route-map\n"
9002 "A route-map to match on\n")
9003
9004DEFUN (show_ip_bgp_ipv4_route_map,
9005 show_ip_bgp_ipv4_route_map_cmd,
9006 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9007 SHOW_STR
9008 IP_STR
9009 BGP_STR
9010 "Address family\n"
9011 "Address Family modifier\n"
9012 "Address Family modifier\n"
9013 "Display routes matching the route-map\n"
9014 "A route-map to match on\n")
9015{
9016 if (strncmp (argv[0], "m", 1) == 0)
9017 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
9018 bgp_show_type_route_map);
9019
9020 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
9021 bgp_show_type_route_map);
9022}
9023
9024DEFUN (show_bgp_route_map,
9025 show_bgp_route_map_cmd,
9026 "show bgp route-map WORD",
9027 SHOW_STR
9028 BGP_STR
9029 "Display routes matching the route-map\n"
9030 "A route-map to match on\n")
9031{
9032 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9033 bgp_show_type_route_map);
9034}
9035
9036DEFUN (show_ip_bgp_cidr_only,
9037 show_ip_bgp_cidr_only_cmd,
9038 "show ip bgp cidr-only",
9039 SHOW_STR
9040 IP_STR
9041 BGP_STR
9042 "Display only routes with non-natural netmasks\n")
9043{
9044 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9045 bgp_show_type_cidr_only, NULL);
9046}
9047
9048DEFUN (show_ip_bgp_flap_cidr_only,
9049 show_ip_bgp_flap_cidr_only_cmd,
9050 "show ip bgp flap-statistics cidr-only",
9051 SHOW_STR
9052 IP_STR
9053 BGP_STR
9054 "Display flap statistics of routes\n"
9055 "Display only routes with non-natural netmasks\n")
9056{
9057 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9058 bgp_show_type_flap_cidr_only, NULL);
9059}
9060
9061ALIAS (show_ip_bgp_flap_cidr_only,
9062 show_ip_bgp_damp_flap_cidr_only_cmd,
9063 "show ip bgp dampening flap-statistics cidr-only",
9064 SHOW_STR
9065 IP_STR
9066 BGP_STR
9067 "Display detailed information about dampening\n"
9068 "Display flap statistics of routes\n"
9069 "Display only routes with non-natural netmasks\n")
9070
9071DEFUN (show_ip_bgp_ipv4_cidr_only,
9072 show_ip_bgp_ipv4_cidr_only_cmd,
9073 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9074 SHOW_STR
9075 IP_STR
9076 BGP_STR
9077 "Address family\n"
9078 "Address Family modifier\n"
9079 "Address Family modifier\n"
9080 "Display only routes with non-natural netmasks\n")
9081{
9082 if (strncmp (argv[0], "m", 1) == 0)
9083 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9084 bgp_show_type_cidr_only, NULL);
9085
9086 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9087 bgp_show_type_cidr_only, NULL);
9088}
9089
9090DEFUN (show_ip_bgp_community_all,
9091 show_ip_bgp_community_all_cmd,
9092 "show ip bgp community",
9093 SHOW_STR
9094 IP_STR
9095 BGP_STR
9096 "Display routes matching the communities\n")
9097{
9098 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9099 bgp_show_type_community_all, NULL);
9100}
9101
9102DEFUN (show_ip_bgp_ipv4_community_all,
9103 show_ip_bgp_ipv4_community_all_cmd,
9104 "show ip bgp ipv4 (unicast|multicast) community",
9105 SHOW_STR
9106 IP_STR
9107 BGP_STR
9108 "Address family\n"
9109 "Address Family modifier\n"
9110 "Address Family modifier\n"
9111 "Display routes matching the communities\n")
9112{
9113 if (strncmp (argv[0], "m", 1) == 0)
9114 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9115 bgp_show_type_community_all, NULL);
9116
9117 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9118 bgp_show_type_community_all, NULL);
9119}
9120
Lou Bergerf9b6c392016-01-12 13:42:09 -05009121DEFUN (show_bgp_community_all,
9122 show_bgp_community_all_cmd,
9123 "show bgp community",
9124 SHOW_STR
9125 BGP_STR
9126 "Display routes matching the communities\n")
9127{
9128 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9129 bgp_show_type_community_all, NULL);
9130}
9131
9132ALIAS (show_bgp_community_all,
9133 show_bgp_ipv6_community_all_cmd,
9134 "show bgp ipv6 community",
9135 SHOW_STR
9136 BGP_STR
9137 "Address family\n"
9138 "Display routes matching the communities\n")
9139
9140/* old command */
9141DEFUN (show_ipv6_bgp_community_all,
9142 show_ipv6_bgp_community_all_cmd,
9143 "show ipv6 bgp community",
9144 SHOW_STR
9145 IPV6_STR
9146 BGP_STR
9147 "Display routes matching the communities\n")
9148{
9149 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9150 bgp_show_type_community_all, NULL);
9151}
9152
9153/* old command */
9154DEFUN (show_ipv6_mbgp_community_all,
9155 show_ipv6_mbgp_community_all_cmd,
9156 "show ipv6 mbgp community",
9157 SHOW_STR
9158 IPV6_STR
9159 MBGP_STR
9160 "Display routes matching the communities\n")
9161{
9162 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
9163 bgp_show_type_community_all, NULL);
9164}
Lou Bergerf9b6c392016-01-12 13:42:09 -05009165
Lou Berger651b4022016-01-12 13:42:07 -05009166DEFUN (show_bgp_ipv4_route_map,
9167 show_bgp_ipv4_route_map_cmd,
9168 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00009169 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009170 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009171 IP_STR
paul718e3742002-12-13 20:15:29 +00009172 "Display routes matching the route-map\n"
9173 "A route-map to match on\n")
9174{
9175 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
9176 bgp_show_type_route_map);
9177}
9178
Lou Berger651b4022016-01-12 13:42:07 -05009179DEFUN (show_bgp_ipv4_safi_flap_route_map,
9180 show_bgp_ipv4_safi_flap_route_map_cmd,
9181 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00009182 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009183 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009184 IP_STR
9185 "Address Family Modifier\n"
9186 "Address Family Modifier\n"
9187 "Address Family Modifier\n"
9188 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009189 "Display flap statistics of routes\n"
9190 "Display routes matching the route-map\n"
9191 "A route-map to match on\n")
9192{
Lou Berger651b4022016-01-12 13:42:07 -05009193 safi_t safi;
9194 if (bgp_parse_safi(argv[0], &safi)) {
9195 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9196 return CMD_WARNING;
9197 }
9198 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00009199 bgp_show_type_flap_route_map);
9200}
9201
Lou Berger651b4022016-01-12 13:42:07 -05009202ALIAS (show_bgp_ipv4_safi_flap_route_map,
9203 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
9204 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05309205 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309206 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009207 IP_STR
9208 "Address Family Modifier\n"
9209 "Address Family Modifier\n"
9210 "Address Family Modifier\n"
9211 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309212 "Display detailed information about dampening\n"
9213 "Display flap statistics of routes\n"
9214 "Display routes matching the route-map\n"
9215 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05009216
Lou Berger651b4022016-01-12 13:42:07 -05009217DEFUN (show_bgp_ipv6_safi_flap_route_map,
9218 show_bgp_ipv6_safi_flap_route_map_cmd,
9219 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00009220 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05009221 BGP_STR
9222 IPV6_STR
9223 "Address Family Modifier\n"
9224 "Address Family Modifier\n"
9225 "Address Family Modifier\n"
9226 "Address Family Modifier\n"
9227 "Display flap statistics of routes\n"
9228 "Display routes matching the route-map\n"
9229 "A route-map to match on\n")
9230{
9231 safi_t safi;
9232 if (bgp_parse_safi(argv[0], &safi)) {
9233 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9234 return CMD_WARNING;
9235 }
9236 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
9237 bgp_show_type_flap_route_map);
9238}
9239ALIAS (show_bgp_ipv6_safi_flap_route_map,
9240 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
9241 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
9242 SHOW_STR
9243 BGP_STR
9244 IPV6_STR
9245 "Address Family Modifier\n"
9246 "Address Family Modifier\n"
9247 "Address Family Modifier\n"
9248 "Address Family Modifier\n"
9249 "Display detailed information about dampening\n"
9250 "Display flap statistics of routes\n"
9251 "Display routes matching the route-map\n"
9252 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009253
9254DEFUN (show_bgp_ipv4_safi_route_map,
9255 show_bgp_ipv4_safi_route_map_cmd,
9256 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
9257 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009258 BGP_STR
9259 "Address family\n"
9260 "Address Family modifier\n"
9261 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05009262 "Address Family modifier\n"
9263 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009264 "Display routes matching the route-map\n"
9265 "A route-map to match on\n")
9266{
Lou Berger651b4022016-01-12 13:42:07 -05009267 safi_t safi;
9268 if (bgp_parse_safi(argv[0], &safi)) {
9269 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9270 return CMD_WARNING;
9271 }
9272 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00009273 bgp_show_type_route_map);
9274}
Lou Berger205e6742016-01-12 13:42:11 -05009275
Lou Berger651b4022016-01-12 13:42:07 -05009276DEFUN (show_bgp_ipv6_safi_route_map,
9277 show_bgp_ipv6_safi_route_map_cmd,
9278 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00009279 SHOW_STR
9280 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009281 "Address family\n"
9282 "Address Family modifier\n"
9283 "Address Family modifier\n"
9284 "Address Family modifier\n"
9285 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009286 "Display routes matching the route-map\n"
9287 "A route-map to match on\n")
9288{
Lou Berger651b4022016-01-12 13:42:07 -05009289 safi_t safi;
9290 if (bgp_parse_safi(argv[0], &safi)) {
9291 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9292 return CMD_WARNING;
9293 }
9294 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00009295 bgp_show_type_route_map);
9296}
9297
Lou Berger651b4022016-01-12 13:42:07 -05009298DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00009299 show_bgp_ipv6_route_map_cmd,
9300 "show bgp ipv6 route-map WORD",
9301 SHOW_STR
9302 BGP_STR
9303 "Address family\n"
9304 "Display routes matching the route-map\n"
9305 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009306{
9307 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9308 bgp_show_type_route_map);
9309}
David Lamparter6b0655a2014-06-04 06:53:35 +02009310
Lou Berger651b4022016-01-12 13:42:07 -05009311DEFUN (show_bgp_ipv4_cidr_only,
9312 show_bgp_ipv4_cidr_only_cmd,
9313 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00009314 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009315 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009316 IP_STR
paul718e3742002-12-13 20:15:29 +00009317 "Display only routes with non-natural netmasks\n")
9318{
9319 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009320 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009321}
9322
Lou Berger651b4022016-01-12 13:42:07 -05009323DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
9324 show_bgp_ipv4_safi_flap_cidr_only_cmd,
9325 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00009326 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009327 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009328 "Address Family\n"
9329 "Address Family Modifier\n"
9330 "Address Family Modifier\n"
9331 "Address Family Modifier\n"
9332 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009333 "Display flap statistics of routes\n"
9334 "Display only routes with non-natural netmasks\n")
9335{
Lou Berger651b4022016-01-12 13:42:07 -05009336 safi_t safi;
9337
9338 if (bgp_parse_safi(argv[0], &safi)) {
9339 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9340 return CMD_WARNING;
9341 }
9342 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009343}
9344
Lou Berger651b4022016-01-12 13:42:07 -05009345ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9346 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9347 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309348 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309349 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009350 "Address Family\n"
9351 "Address Family Modifier\n"
9352 "Address Family Modifier\n"
9353 "Address Family Modifier\n"
9354 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309355 "Display detailed information about dampening\n"
9356 "Display flap statistics of routes\n"
9357 "Display only routes with non-natural netmasks\n")
9358
Lou Berger651b4022016-01-12 13:42:07 -05009359DEFUN (show_bgp_ipv4_safi_cidr_only,
9360 show_bgp_ipv4_safi_cidr_only_cmd,
9361 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009362 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009363 BGP_STR
9364 "Address family\n"
9365 "Address Family modifier\n"
9366 "Address Family modifier\n"
9367 "Display only routes with non-natural netmasks\n")
9368{
9369 if (strncmp (argv[0], "m", 1) == 0)
9370 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009371 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009372
9373 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009374 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009375}
David Lamparter6b0655a2014-06-04 06:53:35 +02009376
Lou Berger651b4022016-01-12 13:42:07 -05009377/* new046 */
9378DEFUN (show_bgp_afi_safi_community_all,
9379 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009380 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009381 SHOW_STR
9382 BGP_STR
9383 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009384 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009385 "Address Family modifier\n"
9386 "Address Family modifier\n"
9387 "Address Family modifier\n"
9388 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009389 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009390{
9391 safi_t safi;
9392 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009393
Lou Berger651b4022016-01-12 13:42:07 -05009394 if (bgp_parse_afi(argv[0], &afi)) {
9395 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9396 return CMD_WARNING;
9397 }
9398 if (bgp_parse_safi(argv[1], &safi)) {
9399 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9400 return CMD_WARNING;
9401 }
9402
9403 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9404}
9405DEFUN (show_bgp_afi_community_all,
9406 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009407 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009408 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009409 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009410 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009411 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009412 "Display routes matching the communities\n")
9413{
Lou Berger651b4022016-01-12 13:42:07 -05009414 afi_t afi;
9415 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009416
Lou Berger651b4022016-01-12 13:42:07 -05009417 if (bgp_parse_afi(argv[0], &afi)) {
9418 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9419 return CMD_WARNING;
9420 }
9421 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009422}
David Lamparter6b0655a2014-06-04 06:53:35 +02009423
paul94f2b392005-06-28 12:44:16 +00009424static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009425bgp_show_community (struct vty *vty, const char *view_name, int argc,
9426 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009427{
9428 struct community *com;
9429 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009430 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +00009431 int i;
9432 char *str;
9433 int first = 0;
9434
Michael Lambert95cbbd22010-07-23 14:43:04 -04009435 /* BGP structure lookup */
9436 if (view_name)
9437 {
9438 bgp = bgp_lookup_by_name (view_name);
9439 if (bgp == NULL)
9440 {
9441 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9442 return CMD_WARNING;
9443 }
9444 }
9445 else
9446 {
9447 bgp = bgp_get_default ();
9448 if (bgp == NULL)
9449 {
9450 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9451 return CMD_WARNING;
9452 }
9453 }
9454
paul718e3742002-12-13 20:15:29 +00009455 b = buffer_new (1024);
9456 for (i = 0; i < argc; i++)
9457 {
9458 if (first)
9459 buffer_putc (b, ' ');
9460 else
9461 {
9462 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9463 continue;
9464 first = 1;
9465 }
9466
9467 buffer_putstr (b, argv[i]);
9468 }
9469 buffer_putc (b, '\0');
9470
9471 str = buffer_getstr (b);
9472 buffer_free (b);
9473
9474 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009475 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009476 if (! com)
9477 {
9478 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9479 return CMD_WARNING;
9480 }
9481
Michael Lambert95cbbd22010-07-23 14:43:04 -04009482 return bgp_show (vty, bgp, afi, safi,
ajs5a646652004-11-05 01:25:55 +00009483 (exact ? bgp_show_type_community_exact :
9484 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00009485}
9486
Lou Bergerf9b6c392016-01-12 13:42:09 -05009487DEFUN (show_ip_bgp_community,
9488 show_ip_bgp_community_cmd,
9489 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9490 SHOW_STR
9491 IP_STR
9492 BGP_STR
9493 "Display routes matching the communities\n"
9494 "community number\n"
9495 "Do not send outside local AS (well-known community)\n"
9496 "Do not advertise to any peer (well-known community)\n"
9497 "Do not export to next AS (well-known community)\n")
9498{
9499 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9500}
9501
9502ALIAS (show_ip_bgp_community,
9503 show_ip_bgp_community2_cmd,
9504 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9505 SHOW_STR
9506 IP_STR
9507 BGP_STR
9508 "Display routes matching the communities\n"
9509 "community number\n"
9510 "Do not send outside local AS (well-known community)\n"
9511 "Do not advertise to any peer (well-known community)\n"
9512 "Do not export to next AS (well-known community)\n"
9513 "community number\n"
9514 "Do not send outside local AS (well-known community)\n"
9515 "Do not advertise to any peer (well-known community)\n"
9516 "Do not export to next AS (well-known community)\n")
9517
9518ALIAS (show_ip_bgp_community,
9519 show_ip_bgp_community3_cmd,
9520 "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)",
9521 SHOW_STR
9522 IP_STR
9523 BGP_STR
9524 "Display routes matching the communities\n"
9525 "community number\n"
9526 "Do not send outside local AS (well-known community)\n"
9527 "Do not advertise to any peer (well-known community)\n"
9528 "Do not export to next AS (well-known community)\n"
9529 "community number\n"
9530 "Do not send outside local AS (well-known community)\n"
9531 "Do not advertise to any peer (well-known community)\n"
9532 "Do not export to next AS (well-known community)\n"
9533 "community number\n"
9534 "Do not send outside local AS (well-known community)\n"
9535 "Do not advertise to any peer (well-known community)\n"
9536 "Do not export to next AS (well-known community)\n")
9537
9538ALIAS (show_ip_bgp_community,
9539 show_ip_bgp_community4_cmd,
9540 "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)",
9541 SHOW_STR
9542 IP_STR
9543 BGP_STR
9544 "Display routes matching the communities\n"
9545 "community number\n"
9546 "Do not send outside local AS (well-known community)\n"
9547 "Do not advertise to any peer (well-known community)\n"
9548 "Do not export to next AS (well-known community)\n"
9549 "community number\n"
9550 "Do not send outside local AS (well-known community)\n"
9551 "Do not advertise to any peer (well-known community)\n"
9552 "Do not export to next AS (well-known community)\n"
9553 "community number\n"
9554 "Do not send outside local AS (well-known community)\n"
9555 "Do not advertise to any peer (well-known community)\n"
9556 "Do not export to next AS (well-known community)\n"
9557 "community number\n"
9558 "Do not send outside local AS (well-known community)\n"
9559 "Do not advertise to any peer (well-known community)\n"
9560 "Do not export to next AS (well-known community)\n")
9561
9562DEFUN (show_ip_bgp_ipv4_community,
9563 show_ip_bgp_ipv4_community_cmd,
9564 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9565 SHOW_STR
9566 IP_STR
9567 BGP_STR
9568 "Address family\n"
9569 "Address Family modifier\n"
9570 "Address Family modifier\n"
9571 "Display routes matching the communities\n"
9572 "community number\n"
9573 "Do not send outside local AS (well-known community)\n"
9574 "Do not advertise to any peer (well-known community)\n"
9575 "Do not export to next AS (well-known community)\n")
9576{
9577 if (strncmp (argv[0], "m", 1) == 0)
9578 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9579
9580 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9581}
9582
9583ALIAS (show_ip_bgp_ipv4_community,
9584 show_ip_bgp_ipv4_community2_cmd,
9585 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9586 SHOW_STR
9587 IP_STR
9588 BGP_STR
9589 "Address family\n"
9590 "Address Family modifier\n"
9591 "Address Family modifier\n"
9592 "Display routes matching the communities\n"
9593 "community number\n"
9594 "Do not send outside local AS (well-known community)\n"
9595 "Do not advertise to any peer (well-known community)\n"
9596 "Do not export to next AS (well-known community)\n"
9597 "community number\n"
9598 "Do not send outside local AS (well-known community)\n"
9599 "Do not advertise to any peer (well-known community)\n"
9600 "Do not export to next AS (well-known community)\n")
9601
9602ALIAS (show_ip_bgp_ipv4_community,
9603 show_ip_bgp_ipv4_community3_cmd,
9604 "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)",
9605 SHOW_STR
9606 IP_STR
9607 BGP_STR
9608 "Address family\n"
9609 "Address Family modifier\n"
9610 "Address Family modifier\n"
9611 "Display routes matching the communities\n"
9612 "community number\n"
9613 "Do not send outside local AS (well-known community)\n"
9614 "Do not advertise to any peer (well-known community)\n"
9615 "Do not export to next AS (well-known community)\n"
9616 "community number\n"
9617 "Do not send outside local AS (well-known community)\n"
9618 "Do not advertise to any peer (well-known community)\n"
9619 "Do not export to next AS (well-known community)\n"
9620 "community number\n"
9621 "Do not send outside local AS (well-known community)\n"
9622 "Do not advertise to any peer (well-known community)\n"
9623 "Do not export to next AS (well-known community)\n")
9624
9625ALIAS (show_ip_bgp_ipv4_community,
9626 show_ip_bgp_ipv4_community4_cmd,
9627 "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)",
9628 SHOW_STR
9629 IP_STR
9630 BGP_STR
9631 "Address family\n"
9632 "Address Family modifier\n"
9633 "Address Family modifier\n"
9634 "Display routes matching the communities\n"
9635 "community number\n"
9636 "Do not send outside local AS (well-known community)\n"
9637 "Do not advertise to any peer (well-known community)\n"
9638 "Do not export to next AS (well-known community)\n"
9639 "community number\n"
9640 "Do not send outside local AS (well-known community)\n"
9641 "Do not advertise to any peer (well-known community)\n"
9642 "Do not export to next AS (well-known community)\n"
9643 "community number\n"
9644 "Do not send outside local AS (well-known community)\n"
9645 "Do not advertise to any peer (well-known community)\n"
9646 "Do not export to next AS (well-known community)\n"
9647 "community number\n"
9648 "Do not send outside local AS (well-known community)\n"
9649 "Do not advertise to any peer (well-known community)\n"
9650 "Do not export to next AS (well-known community)\n")
9651
9652DEFUN (show_ip_bgp_community_exact,
9653 show_ip_bgp_community_exact_cmd,
9654 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9655 SHOW_STR
9656 IP_STR
9657 BGP_STR
9658 "Display routes matching the communities\n"
9659 "community number\n"
9660 "Do not send outside local AS (well-known community)\n"
9661 "Do not advertise to any peer (well-known community)\n"
9662 "Do not export to next AS (well-known community)\n"
9663 "Exact match of the communities")
9664{
9665 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9666}
9667
9668ALIAS (show_ip_bgp_community_exact,
9669 show_ip_bgp_community2_exact_cmd,
9670 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9671 SHOW_STR
9672 IP_STR
9673 BGP_STR
9674 "Display routes matching the communities\n"
9675 "community number\n"
9676 "Do not send outside local AS (well-known community)\n"
9677 "Do not advertise to any peer (well-known community)\n"
9678 "Do not export to next AS (well-known community)\n"
9679 "community number\n"
9680 "Do not send outside local AS (well-known community)\n"
9681 "Do not advertise to any peer (well-known community)\n"
9682 "Do not export to next AS (well-known community)\n"
9683 "Exact match of the communities")
9684
9685ALIAS (show_ip_bgp_community_exact,
9686 show_ip_bgp_community3_exact_cmd,
9687 "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",
9688 SHOW_STR
9689 IP_STR
9690 BGP_STR
9691 "Display routes matching the communities\n"
9692 "community number\n"
9693 "Do not send outside local AS (well-known community)\n"
9694 "Do not advertise to any peer (well-known community)\n"
9695 "Do not export to next AS (well-known community)\n"
9696 "community number\n"
9697 "Do not send outside local AS (well-known community)\n"
9698 "Do not advertise to any peer (well-known community)\n"
9699 "Do not export to next AS (well-known community)\n"
9700 "community number\n"
9701 "Do not send outside local AS (well-known community)\n"
9702 "Do not advertise to any peer (well-known community)\n"
9703 "Do not export to next AS (well-known community)\n"
9704 "Exact match of the communities")
9705
9706ALIAS (show_ip_bgp_community_exact,
9707 show_ip_bgp_community4_exact_cmd,
9708 "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",
9709 SHOW_STR
9710 IP_STR
9711 BGP_STR
9712 "Display routes matching the communities\n"
9713 "community number\n"
9714 "Do not send outside local AS (well-known community)\n"
9715 "Do not advertise to any peer (well-known community)\n"
9716 "Do not export to next AS (well-known community)\n"
9717 "community number\n"
9718 "Do not send outside local AS (well-known community)\n"
9719 "Do not advertise to any peer (well-known community)\n"
9720 "Do not export to next AS (well-known community)\n"
9721 "community number\n"
9722 "Do not send outside local AS (well-known community)\n"
9723 "Do not advertise to any peer (well-known community)\n"
9724 "Do not export to next AS (well-known community)\n"
9725 "community number\n"
9726 "Do not send outside local AS (well-known community)\n"
9727 "Do not advertise to any peer (well-known community)\n"
9728 "Do not export to next AS (well-known community)\n"
9729 "Exact match of the communities")
9730
9731DEFUN (show_ip_bgp_ipv4_community_exact,
9732 show_ip_bgp_ipv4_community_exact_cmd,
9733 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9734 SHOW_STR
9735 IP_STR
9736 BGP_STR
9737 "Address family\n"
9738 "Address Family modifier\n"
9739 "Address Family modifier\n"
9740 "Display routes matching the communities\n"
9741 "community number\n"
9742 "Do not send outside local AS (well-known community)\n"
9743 "Do not advertise to any peer (well-known community)\n"
9744 "Do not export to next AS (well-known community)\n"
9745 "Exact match of the communities")
9746{
9747 if (strncmp (argv[0], "m", 1) == 0)
9748 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9749
9750 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9751}
9752
9753ALIAS (show_ip_bgp_ipv4_community_exact,
9754 show_ip_bgp_ipv4_community2_exact_cmd,
9755 "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",
9756 SHOW_STR
9757 IP_STR
9758 BGP_STR
9759 "Address family\n"
9760 "Address Family modifier\n"
9761 "Address Family modifier\n"
9762 "Display routes matching the communities\n"
9763 "community number\n"
9764 "Do not send outside local AS (well-known community)\n"
9765 "Do not advertise to any peer (well-known community)\n"
9766 "Do not export to next AS (well-known community)\n"
9767 "community number\n"
9768 "Do not send outside local AS (well-known community)\n"
9769 "Do not advertise to any peer (well-known community)\n"
9770 "Do not export to next AS (well-known community)\n"
9771 "Exact match of the communities")
9772
9773ALIAS (show_ip_bgp_ipv4_community_exact,
9774 show_ip_bgp_ipv4_community3_exact_cmd,
9775 "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",
9776 SHOW_STR
9777 IP_STR
9778 BGP_STR
9779 "Address family\n"
9780 "Address Family modifier\n"
9781 "Address Family modifier\n"
9782 "Display routes matching the communities\n"
9783 "community number\n"
9784 "Do not send outside local AS (well-known community)\n"
9785 "Do not advertise to any peer (well-known community)\n"
9786 "Do not export to next AS (well-known community)\n"
9787 "community number\n"
9788 "Do not send outside local AS (well-known community)\n"
9789 "Do not advertise to any peer (well-known community)\n"
9790 "Do not export to next AS (well-known community)\n"
9791 "community number\n"
9792 "Do not send outside local AS (well-known community)\n"
9793 "Do not advertise to any peer (well-known community)\n"
9794 "Do not export to next AS (well-known community)\n"
9795 "Exact match of the communities")
9796
9797ALIAS (show_ip_bgp_ipv4_community_exact,
9798 show_ip_bgp_ipv4_community4_exact_cmd,
9799 "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",
9800 SHOW_STR
9801 IP_STR
9802 BGP_STR
9803 "Address family\n"
9804 "Address Family modifier\n"
9805 "Address Family modifier\n"
9806 "Display routes matching the communities\n"
9807 "community number\n"
9808 "Do not send outside local AS (well-known community)\n"
9809 "Do not advertise to any peer (well-known community)\n"
9810 "Do not export to next AS (well-known community)\n"
9811 "community number\n"
9812 "Do not send outside local AS (well-known community)\n"
9813 "Do not advertise to any peer (well-known community)\n"
9814 "Do not export to next AS (well-known community)\n"
9815 "community number\n"
9816 "Do not send outside local AS (well-known community)\n"
9817 "Do not advertise to any peer (well-known community)\n"
9818 "Do not export to next AS (well-known community)\n"
9819 "community number\n"
9820 "Do not send outside local AS (well-known community)\n"
9821 "Do not advertise to any peer (well-known community)\n"
9822 "Do not export to next AS (well-known community)\n"
9823 "Exact match of the communities")
9824
Lou Bergerf9b6c392016-01-12 13:42:09 -05009825DEFUN (show_bgp_community,
9826 show_bgp_community_cmd,
9827 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9828 SHOW_STR
9829 BGP_STR
9830 "Display routes matching the communities\n"
9831 "community number\n"
9832 "Do not send outside local AS (well-known community)\n"
9833 "Do not advertise to any peer (well-known community)\n"
9834 "Do not export to next AS (well-known community)\n")
9835{
9836 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9837}
9838
9839ALIAS (show_bgp_community,
9840 show_bgp_ipv6_community_cmd,
9841 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9842 SHOW_STR
9843 BGP_STR
9844 "Address family\n"
9845 "Display routes matching the communities\n"
9846 "community number\n"
9847 "Do not send outside local AS (well-known community)\n"
9848 "Do not advertise to any peer (well-known community)\n"
9849 "Do not export to next AS (well-known community)\n")
9850
9851ALIAS (show_bgp_community,
9852 show_bgp_community2_cmd,
9853 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9854 SHOW_STR
9855 BGP_STR
9856 "Display routes matching the communities\n"
9857 "community number\n"
9858 "Do not send outside local AS (well-known community)\n"
9859 "Do not advertise to any peer (well-known community)\n"
9860 "Do not export to next AS (well-known community)\n"
9861 "community number\n"
9862 "Do not send outside local AS (well-known community)\n"
9863 "Do not advertise to any peer (well-known community)\n"
9864 "Do not export to next AS (well-known community)\n")
9865
9866ALIAS (show_bgp_community,
9867 show_bgp_ipv6_community2_cmd,
9868 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9869 SHOW_STR
9870 BGP_STR
9871 "Address family\n"
9872 "Display routes matching the communities\n"
9873 "community number\n"
9874 "Do not send outside local AS (well-known community)\n"
9875 "Do not advertise to any peer (well-known community)\n"
9876 "Do not export to next AS (well-known community)\n"
9877 "community number\n"
9878 "Do not send outside local AS (well-known community)\n"
9879 "Do not advertise to any peer (well-known community)\n"
9880 "Do not export to next AS (well-known community)\n")
9881
9882ALIAS (show_bgp_community,
9883 show_bgp_community3_cmd,
9884 "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)",
9885 SHOW_STR
9886 BGP_STR
9887 "Display routes matching the communities\n"
9888 "community number\n"
9889 "Do not send outside local AS (well-known community)\n"
9890 "Do not advertise to any peer (well-known community)\n"
9891 "Do not export to next AS (well-known community)\n"
9892 "community number\n"
9893 "Do not send outside local AS (well-known community)\n"
9894 "Do not advertise to any peer (well-known community)\n"
9895 "Do not export to next AS (well-known community)\n"
9896 "community number\n"
9897 "Do not send outside local AS (well-known community)\n"
9898 "Do not advertise to any peer (well-known community)\n"
9899 "Do not export to next AS (well-known community)\n")
9900
9901ALIAS (show_bgp_community,
9902 show_bgp_ipv6_community3_cmd,
9903 "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)",
9904 SHOW_STR
9905 BGP_STR
9906 "Address family\n"
9907 "Display routes matching the communities\n"
9908 "community number\n"
9909 "Do not send outside local AS (well-known community)\n"
9910 "Do not advertise to any peer (well-known community)\n"
9911 "Do not export to next AS (well-known community)\n"
9912 "community number\n"
9913 "Do not send outside local AS (well-known community)\n"
9914 "Do not advertise to any peer (well-known community)\n"
9915 "Do not export to next AS (well-known community)\n"
9916 "community number\n"
9917 "Do not send outside local AS (well-known community)\n"
9918 "Do not advertise to any peer (well-known community)\n"
9919 "Do not export to next AS (well-known community)\n")
9920
9921ALIAS (show_bgp_community,
9922 show_bgp_community4_cmd,
9923 "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)",
9924 SHOW_STR
9925 BGP_STR
9926 "Display routes matching the communities\n"
9927 "community number\n"
9928 "Do not send outside local AS (well-known community)\n"
9929 "Do not advertise to any peer (well-known community)\n"
9930 "Do not export to next AS (well-known community)\n"
9931 "community number\n"
9932 "Do not send outside local AS (well-known community)\n"
9933 "Do not advertise to any peer (well-known community)\n"
9934 "Do not export to next AS (well-known community)\n"
9935 "community number\n"
9936 "Do not send outside local AS (well-known community)\n"
9937 "Do not advertise to any peer (well-known community)\n"
9938 "Do not export to next AS (well-known community)\n"
9939 "community number\n"
9940 "Do not send outside local AS (well-known community)\n"
9941 "Do not advertise to any peer (well-known community)\n"
9942 "Do not export to next AS (well-known community)\n")
9943
9944ALIAS (show_bgp_community,
9945 show_bgp_ipv6_community4_cmd,
9946 "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)",
9947 SHOW_STR
9948 BGP_STR
9949 "Address family\n"
9950 "Display routes matching the communities\n"
9951 "community number\n"
9952 "Do not send outside local AS (well-known community)\n"
9953 "Do not advertise to any peer (well-known community)\n"
9954 "Do not export to next AS (well-known community)\n"
9955 "community number\n"
9956 "Do not send outside local AS (well-known community)\n"
9957 "Do not advertise to any peer (well-known community)\n"
9958 "Do not export to next AS (well-known community)\n"
9959 "community number\n"
9960 "Do not send outside local AS (well-known community)\n"
9961 "Do not advertise to any peer (well-known community)\n"
9962 "Do not export to next AS (well-known community)\n"
9963 "community number\n"
9964 "Do not send outside local AS (well-known community)\n"
9965 "Do not advertise to any peer (well-known community)\n"
9966 "Do not export to next AS (well-known community)\n")
9967
9968/* old command */
9969DEFUN (show_ipv6_bgp_community,
9970 show_ipv6_bgp_community_cmd,
9971 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9972 SHOW_STR
9973 IPV6_STR
9974 BGP_STR
9975 "Display routes matching the communities\n"
9976 "community number\n"
9977 "Do not send outside local AS (well-known community)\n"
9978 "Do not advertise to any peer (well-known community)\n"
9979 "Do not export to next AS (well-known community)\n")
9980{
9981 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9982}
9983
9984/* old command */
9985ALIAS (show_ipv6_bgp_community,
9986 show_ipv6_bgp_community2_cmd,
9987 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9988 SHOW_STR
9989 IPV6_STR
9990 BGP_STR
9991 "Display routes matching the communities\n"
9992 "community number\n"
9993 "Do not send outside local AS (well-known community)\n"
9994 "Do not advertise to any peer (well-known community)\n"
9995 "Do not export to next AS (well-known community)\n"
9996 "community number\n"
9997 "Do not send outside local AS (well-known community)\n"
9998 "Do not advertise to any peer (well-known community)\n"
9999 "Do not export to next AS (well-known community)\n")
10000
10001/* old command */
10002ALIAS (show_ipv6_bgp_community,
10003 show_ipv6_bgp_community3_cmd,
10004 "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)",
10005 SHOW_STR
10006 IPV6_STR
10007 BGP_STR
10008 "Display routes matching the communities\n"
10009 "community number\n"
10010 "Do not send outside local AS (well-known community)\n"
10011 "Do not advertise to any peer (well-known community)\n"
10012 "Do not export to next AS (well-known community)\n"
10013 "community number\n"
10014 "Do not send outside local AS (well-known community)\n"
10015 "Do not advertise to any peer (well-known community)\n"
10016 "Do not export to next AS (well-known community)\n"
10017 "community number\n"
10018 "Do not send outside local AS (well-known community)\n"
10019 "Do not advertise to any peer (well-known community)\n"
10020 "Do not export to next AS (well-known community)\n")
10021
10022/* old command */
10023ALIAS (show_ipv6_bgp_community,
10024 show_ipv6_bgp_community4_cmd,
10025 "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)",
10026 SHOW_STR
10027 IPV6_STR
10028 BGP_STR
10029 "Display routes matching the communities\n"
10030 "community number\n"
10031 "Do not send outside local AS (well-known community)\n"
10032 "Do not advertise to any peer (well-known community)\n"
10033 "Do not export to next AS (well-known community)\n"
10034 "community number\n"
10035 "Do not send outside local AS (well-known community)\n"
10036 "Do not advertise to any peer (well-known community)\n"
10037 "Do not export to next AS (well-known community)\n"
10038 "community number\n"
10039 "Do not send outside local AS (well-known community)\n"
10040 "Do not advertise to any peer (well-known community)\n"
10041 "Do not export to next AS (well-known community)\n"
10042 "community number\n"
10043 "Do not send outside local AS (well-known community)\n"
10044 "Do not advertise to any peer (well-known community)\n"
10045 "Do not export to next AS (well-known community)\n")
10046
10047DEFUN (show_bgp_community_exact,
10048 show_bgp_community_exact_cmd,
10049 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10050 SHOW_STR
10051 BGP_STR
10052 "Display routes matching the communities\n"
10053 "community number\n"
10054 "Do not send outside local AS (well-known community)\n"
10055 "Do not advertise to any peer (well-known community)\n"
10056 "Do not export to next AS (well-known community)\n"
10057 "Exact match of the communities")
10058{
10059 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10060}
10061
10062ALIAS (show_bgp_community_exact,
10063 show_bgp_ipv6_community_exact_cmd,
10064 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10065 SHOW_STR
10066 BGP_STR
10067 "Address family\n"
10068 "Display routes matching the communities\n"
10069 "community number\n"
10070 "Do not send outside local AS (well-known community)\n"
10071 "Do not advertise to any peer (well-known community)\n"
10072 "Do not export to next AS (well-known community)\n"
10073 "Exact match of the communities")
10074
10075ALIAS (show_bgp_community_exact,
10076 show_bgp_community2_exact_cmd,
10077 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10078 SHOW_STR
10079 BGP_STR
10080 "Display routes matching the communities\n"
10081 "community number\n"
10082 "Do not send outside local AS (well-known community)\n"
10083 "Do not advertise to any peer (well-known community)\n"
10084 "Do not export to next AS (well-known community)\n"
10085 "community number\n"
10086 "Do not send outside local AS (well-known community)\n"
10087 "Do not advertise to any peer (well-known community)\n"
10088 "Do not export to next AS (well-known community)\n"
10089 "Exact match of the communities")
10090
10091ALIAS (show_bgp_community_exact,
10092 show_bgp_ipv6_community2_exact_cmd,
10093 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10094 SHOW_STR
10095 BGP_STR
10096 "Address family\n"
10097 "Display routes matching the communities\n"
10098 "community number\n"
10099 "Do not send outside local AS (well-known community)\n"
10100 "Do not advertise to any peer (well-known community)\n"
10101 "Do not export to next AS (well-known community)\n"
10102 "community number\n"
10103 "Do not send outside local AS (well-known community)\n"
10104 "Do not advertise to any peer (well-known community)\n"
10105 "Do not export to next AS (well-known community)\n"
10106 "Exact match of the communities")
10107
10108ALIAS (show_bgp_community_exact,
10109 show_bgp_community3_exact_cmd,
10110 "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",
10111 SHOW_STR
10112 BGP_STR
10113 "Display routes matching the communities\n"
10114 "community number\n"
10115 "Do not send outside local AS (well-known community)\n"
10116 "Do not advertise to any peer (well-known community)\n"
10117 "Do not export to next AS (well-known community)\n"
10118 "community number\n"
10119 "Do not send outside local AS (well-known community)\n"
10120 "Do not advertise to any peer (well-known community)\n"
10121 "Do not export to next AS (well-known community)\n"
10122 "community number\n"
10123 "Do not send outside local AS (well-known community)\n"
10124 "Do not advertise to any peer (well-known community)\n"
10125 "Do not export to next AS (well-known community)\n"
10126 "Exact match of the communities")
10127
10128ALIAS (show_bgp_community_exact,
10129 show_bgp_ipv6_community3_exact_cmd,
10130 "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",
10131 SHOW_STR
10132 BGP_STR
10133 "Address family\n"
10134 "Display routes matching the communities\n"
10135 "community number\n"
10136 "Do not send outside local AS (well-known community)\n"
10137 "Do not advertise to any peer (well-known community)\n"
10138 "Do not export to next AS (well-known community)\n"
10139 "community number\n"
10140 "Do not send outside local AS (well-known community)\n"
10141 "Do not advertise to any peer (well-known community)\n"
10142 "Do not export to next AS (well-known community)\n"
10143 "community number\n"
10144 "Do not send outside local AS (well-known community)\n"
10145 "Do not advertise to any peer (well-known community)\n"
10146 "Do not export to next AS (well-known community)\n"
10147 "Exact match of the communities")
10148
10149ALIAS (show_bgp_community_exact,
10150 show_bgp_community4_exact_cmd,
10151 "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",
10152 SHOW_STR
10153 BGP_STR
10154 "Display routes matching the communities\n"
10155 "community number\n"
10156 "Do not send outside local AS (well-known community)\n"
10157 "Do not advertise to any peer (well-known community)\n"
10158 "Do not export to next AS (well-known community)\n"
10159 "community number\n"
10160 "Do not send outside local AS (well-known community)\n"
10161 "Do not advertise to any peer (well-known community)\n"
10162 "Do not export to next AS (well-known community)\n"
10163 "community number\n"
10164 "Do not send outside local AS (well-known community)\n"
10165 "Do not advertise to any peer (well-known community)\n"
10166 "Do not export to next AS (well-known community)\n"
10167 "community number\n"
10168 "Do not send outside local AS (well-known community)\n"
10169 "Do not advertise to any peer (well-known community)\n"
10170 "Do not export to next AS (well-known community)\n"
10171 "Exact match of the communities")
10172
10173ALIAS (show_bgp_community_exact,
10174 show_bgp_ipv6_community4_exact_cmd,
10175 "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",
10176 SHOW_STR
10177 BGP_STR
10178 "Address family\n"
10179 "Display routes matching the communities\n"
10180 "community number\n"
10181 "Do not send outside local AS (well-known community)\n"
10182 "Do not advertise to any peer (well-known community)\n"
10183 "Do not export to next AS (well-known community)\n"
10184 "community number\n"
10185 "Do not send outside local AS (well-known community)\n"
10186 "Do not advertise to any peer (well-known community)\n"
10187 "Do not export to next AS (well-known community)\n"
10188 "community number\n"
10189 "Do not send outside local AS (well-known community)\n"
10190 "Do not advertise to any peer (well-known community)\n"
10191 "Do not export to next AS (well-known community)\n"
10192 "community number\n"
10193 "Do not send outside local AS (well-known community)\n"
10194 "Do not advertise to any peer (well-known community)\n"
10195 "Do not export to next AS (well-known community)\n"
10196 "Exact match of the communities")
10197
10198/* old command */
10199DEFUN (show_ipv6_bgp_community_exact,
10200 show_ipv6_bgp_community_exact_cmd,
10201 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10202 SHOW_STR
10203 IPV6_STR
10204 BGP_STR
10205 "Display routes matching the communities\n"
10206 "community number\n"
10207 "Do not send outside local AS (well-known community)\n"
10208 "Do not advertise to any peer (well-known community)\n"
10209 "Do not export to next AS (well-known community)\n"
10210 "Exact match of the communities")
10211{
10212 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10213}
10214
10215/* old command */
10216ALIAS (show_ipv6_bgp_community_exact,
10217 show_ipv6_bgp_community2_exact_cmd,
10218 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10219 SHOW_STR
10220 IPV6_STR
10221 BGP_STR
10222 "Display routes matching the communities\n"
10223 "community number\n"
10224 "Do not send outside local AS (well-known community)\n"
10225 "Do not advertise to any peer (well-known community)\n"
10226 "Do not export to next AS (well-known community)\n"
10227 "community number\n"
10228 "Do not send outside local AS (well-known community)\n"
10229 "Do not advertise to any peer (well-known community)\n"
10230 "Do not export to next AS (well-known community)\n"
10231 "Exact match of the communities")
10232
10233/* old command */
10234ALIAS (show_ipv6_bgp_community_exact,
10235 show_ipv6_bgp_community3_exact_cmd,
10236 "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",
10237 SHOW_STR
10238 IPV6_STR
10239 BGP_STR
10240 "Display routes matching the communities\n"
10241 "community number\n"
10242 "Do not send outside local AS (well-known community)\n"
10243 "Do not advertise to any peer (well-known community)\n"
10244 "Do not export to next AS (well-known community)\n"
10245 "community number\n"
10246 "Do not send outside local AS (well-known community)\n"
10247 "Do not advertise to any peer (well-known community)\n"
10248 "Do not export to next AS (well-known community)\n"
10249 "community number\n"
10250 "Do not send outside local AS (well-known community)\n"
10251 "Do not advertise to any peer (well-known community)\n"
10252 "Do not export to next AS (well-known community)\n"
10253 "Exact match of the communities")
10254
10255/* old command */
10256ALIAS (show_ipv6_bgp_community_exact,
10257 show_ipv6_bgp_community4_exact_cmd,
10258 "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",
10259 SHOW_STR
10260 IPV6_STR
10261 BGP_STR
10262 "Display routes matching the communities\n"
10263 "community number\n"
10264 "Do not send outside local AS (well-known community)\n"
10265 "Do not advertise to any peer (well-known community)\n"
10266 "Do not export to next AS (well-known community)\n"
10267 "community number\n"
10268 "Do not send outside local AS (well-known community)\n"
10269 "Do not advertise to any peer (well-known community)\n"
10270 "Do not export to next AS (well-known community)\n"
10271 "community number\n"
10272 "Do not send outside local AS (well-known community)\n"
10273 "Do not advertise to any peer (well-known community)\n"
10274 "Do not export to next AS (well-known community)\n"
10275 "community number\n"
10276 "Do not send outside local AS (well-known community)\n"
10277 "Do not advertise to any peer (well-known community)\n"
10278 "Do not export to next AS (well-known community)\n"
10279 "Exact match of the communities")
10280
10281/* old command */
10282DEFUN (show_ipv6_mbgp_community,
10283 show_ipv6_mbgp_community_cmd,
10284 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10285 SHOW_STR
10286 IPV6_STR
10287 MBGP_STR
10288 "Display routes matching the communities\n"
10289 "community number\n"
10290 "Do not send outside local AS (well-known community)\n"
10291 "Do not advertise to any peer (well-known community)\n"
10292 "Do not export to next AS (well-known community)\n")
10293{
10294 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
10295}
10296
10297/* old command */
10298ALIAS (show_ipv6_mbgp_community,
10299 show_ipv6_mbgp_community2_cmd,
10300 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10301 SHOW_STR
10302 IPV6_STR
10303 MBGP_STR
10304 "Display routes matching the communities\n"
10305 "community number\n"
10306 "Do not send outside local AS (well-known community)\n"
10307 "Do not advertise to any peer (well-known community)\n"
10308 "Do not export to next AS (well-known community)\n"
10309 "community number\n"
10310 "Do not send outside local AS (well-known community)\n"
10311 "Do not advertise to any peer (well-known community)\n"
10312 "Do not export to next AS (well-known community)\n")
10313
10314/* old command */
10315ALIAS (show_ipv6_mbgp_community,
10316 show_ipv6_mbgp_community3_cmd,
10317 "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)",
10318 SHOW_STR
10319 IPV6_STR
10320 MBGP_STR
10321 "Display routes matching the communities\n"
10322 "community number\n"
10323 "Do not send outside local AS (well-known community)\n"
10324 "Do not advertise to any peer (well-known community)\n"
10325 "Do not export to next AS (well-known community)\n"
10326 "community number\n"
10327 "Do not send outside local AS (well-known community)\n"
10328 "Do not advertise to any peer (well-known community)\n"
10329 "Do not export to next AS (well-known community)\n"
10330 "community number\n"
10331 "Do not send outside local AS (well-known community)\n"
10332 "Do not advertise to any peer (well-known community)\n"
10333 "Do not export to next AS (well-known community)\n")
10334
10335/* old command */
10336ALIAS (show_ipv6_mbgp_community,
10337 show_ipv6_mbgp_community4_cmd,
10338 "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)",
10339 SHOW_STR
10340 IPV6_STR
10341 MBGP_STR
10342 "Display routes matching the communities\n"
10343 "community number\n"
10344 "Do not send outside local AS (well-known community)\n"
10345 "Do not advertise to any peer (well-known community)\n"
10346 "Do not export to next AS (well-known community)\n"
10347 "community number\n"
10348 "Do not send outside local AS (well-known community)\n"
10349 "Do not advertise to any peer (well-known community)\n"
10350 "Do not export to next AS (well-known community)\n"
10351 "community number\n"
10352 "Do not send outside local AS (well-known community)\n"
10353 "Do not advertise to any peer (well-known community)\n"
10354 "Do not export to next AS (well-known community)\n"
10355 "community number\n"
10356 "Do not send outside local AS (well-known community)\n"
10357 "Do not advertise to any peer (well-known community)\n"
10358 "Do not export to next AS (well-known community)\n")
10359
10360/* old command */
10361DEFUN (show_ipv6_mbgp_community_exact,
10362 show_ipv6_mbgp_community_exact_cmd,
10363 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10364 SHOW_STR
10365 IPV6_STR
10366 MBGP_STR
10367 "Display routes matching the communities\n"
10368 "community number\n"
10369 "Do not send outside local AS (well-known community)\n"
10370 "Do not advertise to any peer (well-known community)\n"
10371 "Do not export to next AS (well-known community)\n"
10372 "Exact match of the communities")
10373{
10374 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10375}
10376
10377/* old command */
10378ALIAS (show_ipv6_mbgp_community_exact,
10379 show_ipv6_mbgp_community2_exact_cmd,
10380 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10381 SHOW_STR
10382 IPV6_STR
10383 MBGP_STR
10384 "Display routes matching the communities\n"
10385 "community number\n"
10386 "Do not send outside local AS (well-known community)\n"
10387 "Do not advertise to any peer (well-known community)\n"
10388 "Do not export to next AS (well-known community)\n"
10389 "community number\n"
10390 "Do not send outside local AS (well-known community)\n"
10391 "Do not advertise to any peer (well-known community)\n"
10392 "Do not export to next AS (well-known community)\n"
10393 "Exact match of the communities")
10394
10395/* old command */
10396ALIAS (show_ipv6_mbgp_community_exact,
10397 show_ipv6_mbgp_community3_exact_cmd,
10398 "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",
10399 SHOW_STR
10400 IPV6_STR
10401 MBGP_STR
10402 "Display routes matching the communities\n"
10403 "community number\n"
10404 "Do not send outside local AS (well-known community)\n"
10405 "Do not advertise to any peer (well-known community)\n"
10406 "Do not export to next AS (well-known community)\n"
10407 "community number\n"
10408 "Do not send outside local AS (well-known community)\n"
10409 "Do not advertise to any peer (well-known community)\n"
10410 "Do not export to next AS (well-known community)\n"
10411 "community number\n"
10412 "Do not send outside local AS (well-known community)\n"
10413 "Do not advertise to any peer (well-known community)\n"
10414 "Do not export to next AS (well-known community)\n"
10415 "Exact match of the communities")
10416
10417/* old command */
10418ALIAS (show_ipv6_mbgp_community_exact,
10419 show_ipv6_mbgp_community4_exact_cmd,
10420 "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",
10421 SHOW_STR
10422 IPV6_STR
10423 MBGP_STR
10424 "Display routes matching the communities\n"
10425 "community number\n"
10426 "Do not send outside local AS (well-known community)\n"
10427 "Do not advertise to any peer (well-known community)\n"
10428 "Do not export to next AS (well-known community)\n"
10429 "community number\n"
10430 "Do not send outside local AS (well-known community)\n"
10431 "Do not advertise to any peer (well-known community)\n"
10432 "Do not export to next AS (well-known community)\n"
10433 "community number\n"
10434 "Do not send outside local AS (well-known community)\n"
10435 "Do not advertise to any peer (well-known community)\n"
10436 "Do not export to next AS (well-known community)\n"
10437 "community number\n"
10438 "Do not send outside local AS (well-known community)\n"
10439 "Do not advertise to any peer (well-known community)\n"
10440 "Do not export to next AS (well-known community)\n"
10441 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010442
Lou Berger651b4022016-01-12 13:42:07 -050010443DEFUN (show_bgp_ipv4_community,
10444 show_bgp_ipv4_community_cmd,
10445 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010446 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010447 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010448 IP_STR
paul718e3742002-12-13 20:15:29 +000010449 "Display routes matching the communities\n"
10450 "community number\n"
10451 "Do not send outside local AS (well-known community)\n"
10452 "Do not advertise to any peer (well-known community)\n"
10453 "Do not export to next AS (well-known community)\n")
10454{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010455 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010456}
10457
Lou Berger651b4022016-01-12 13:42:07 -050010458ALIAS (show_bgp_ipv4_community,
10459 show_bgp_ipv4_community2_cmd,
10460 "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 +000010461 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010462 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010463 IP_STR
paul718e3742002-12-13 20:15:29 +000010464 "Display routes matching the communities\n"
10465 "community number\n"
10466 "Do not send outside local AS (well-known community)\n"
10467 "Do not advertise to any peer (well-known community)\n"
10468 "Do not export to next AS (well-known community)\n"
10469 "community number\n"
10470 "Do not send outside local AS (well-known community)\n"
10471 "Do not advertise to any peer (well-known community)\n"
10472 "Do not export to next AS (well-known community)\n")
10473
Lou Berger651b4022016-01-12 13:42:07 -050010474ALIAS (show_bgp_ipv4_community,
10475 show_bgp_ipv4_community3_cmd,
10476 "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 +000010477 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010478 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010479 IP_STR
paul718e3742002-12-13 20:15:29 +000010480 "Display routes matching the communities\n"
10481 "community number\n"
10482 "Do not send outside local AS (well-known community)\n"
10483 "Do not advertise to any peer (well-known community)\n"
10484 "Do not export to next AS (well-known community)\n"
10485 "community number\n"
10486 "Do not send outside local AS (well-known community)\n"
10487 "Do not advertise to any peer (well-known community)\n"
10488 "Do not export to next AS (well-known community)\n"
10489 "community number\n"
10490 "Do not send outside local AS (well-known community)\n"
10491 "Do not advertise to any peer (well-known community)\n"
10492 "Do not export to next AS (well-known community)\n")
10493
Lou Berger651b4022016-01-12 13:42:07 -050010494ALIAS (show_bgp_ipv4_community,
10495 show_bgp_ipv4_community4_cmd,
10496 "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 +000010497 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010498 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010499 IP_STR
paul718e3742002-12-13 20:15:29 +000010500 "Display routes matching the communities\n"
10501 "community number\n"
10502 "Do not send outside local AS (well-known community)\n"
10503 "Do not advertise to any peer (well-known community)\n"
10504 "Do not export to next AS (well-known community)\n"
10505 "community number\n"
10506 "Do not send outside local AS (well-known community)\n"
10507 "Do not advertise to any peer (well-known community)\n"
10508 "Do not export to next AS (well-known community)\n"
10509 "community number\n"
10510 "Do not send outside local AS (well-known community)\n"
10511 "Do not advertise to any peer (well-known community)\n"
10512 "Do not export to next AS (well-known community)\n"
10513 "community number\n"
10514 "Do not send outside local AS (well-known community)\n"
10515 "Do not advertise to any peer (well-known community)\n"
10516 "Do not export to next AS (well-known community)\n")
10517
Lou Berger651b4022016-01-12 13:42:07 -050010518DEFUN (show_bgp_ipv4_safi_community,
10519 show_bgp_ipv4_safi_community_cmd,
10520 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010521 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010522 BGP_STR
10523 "Address family\n"
10524 "Address Family modifier\n"
10525 "Address Family modifier\n"
10526 "Display routes matching the communities\n"
10527 "community number\n"
10528 "Do not send outside local AS (well-known community)\n"
10529 "Do not advertise to any peer (well-known community)\n"
10530 "Do not export to next AS (well-known community)\n")
10531{
10532 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010533 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010534
Michael Lambert95cbbd22010-07-23 14:43:04 -040010535 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010536}
10537
Lou Berger651b4022016-01-12 13:42:07 -050010538ALIAS (show_bgp_ipv4_safi_community,
10539 show_bgp_ipv4_safi_community2_cmd,
10540 "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 +000010541 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010542 BGP_STR
10543 "Address family\n"
10544 "Address Family modifier\n"
10545 "Address Family modifier\n"
10546 "Display routes matching the communities\n"
10547 "community number\n"
10548 "Do not send outside local AS (well-known community)\n"
10549 "Do not advertise to any peer (well-known community)\n"
10550 "Do not export to next AS (well-known community)\n"
10551 "community number\n"
10552 "Do not send outside local AS (well-known community)\n"
10553 "Do not advertise to any peer (well-known community)\n"
10554 "Do not export to next AS (well-known community)\n")
10555
Lou Berger651b4022016-01-12 13:42:07 -050010556ALIAS (show_bgp_ipv4_safi_community,
10557 show_bgp_ipv4_safi_community3_cmd,
10558 "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 +000010559 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010560 BGP_STR
10561 "Address family\n"
10562 "Address Family modifier\n"
10563 "Address Family modifier\n"
10564 "Display routes matching the communities\n"
10565 "community number\n"
10566 "Do not send outside local AS (well-known community)\n"
10567 "Do not advertise to any peer (well-known community)\n"
10568 "Do not export to next AS (well-known community)\n"
10569 "community number\n"
10570 "Do not send outside local AS (well-known community)\n"
10571 "Do not advertise to any peer (well-known community)\n"
10572 "Do not export to next AS (well-known community)\n"
10573 "community number\n"
10574 "Do not send outside local AS (well-known community)\n"
10575 "Do not advertise to any peer (well-known community)\n"
10576 "Do not export to next AS (well-known community)\n")
10577
Lou Berger651b4022016-01-12 13:42:07 -050010578ALIAS (show_bgp_ipv4_safi_community,
10579 show_bgp_ipv4_safi_community4_cmd,
10580 "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 +000010581 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010582 BGP_STR
10583 "Address family\n"
10584 "Address Family modifier\n"
10585 "Address Family modifier\n"
10586 "Display routes matching the communities\n"
10587 "community number\n"
10588 "Do not send outside local AS (well-known community)\n"
10589 "Do not advertise to any peer (well-known community)\n"
10590 "Do not export to next AS (well-known community)\n"
10591 "community number\n"
10592 "Do not send outside local AS (well-known community)\n"
10593 "Do not advertise to any peer (well-known community)\n"
10594 "Do not export to next AS (well-known community)\n"
10595 "community number\n"
10596 "Do not send outside local AS (well-known community)\n"
10597 "Do not advertise to any peer (well-known community)\n"
10598 "Do not export to next AS (well-known community)\n"
10599 "community number\n"
10600 "Do not send outside local AS (well-known community)\n"
10601 "Do not advertise to any peer (well-known community)\n"
10602 "Do not export to next AS (well-known community)\n")
10603
Michael Lambert95cbbd22010-07-23 14:43:04 -040010604DEFUN (show_bgp_view_afi_safi_community_all,
10605 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010606 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010607 SHOW_STR
10608 BGP_STR
10609 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010610 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010611 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010612 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010613 "Address Family modifier\n"
10614 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010615 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010616{
10617 int afi;
10618 int safi;
10619 struct bgp *bgp;
10620
10621 /* BGP structure lookup. */
10622 bgp = bgp_lookup_by_name (argv[0]);
10623 if (bgp == NULL)
10624 {
10625 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10626 return CMD_WARNING;
10627 }
10628
Michael Lambert95cbbd22010-07-23 14:43:04 -040010629 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10630 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010631 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10632}
10633
10634DEFUN (show_bgp_view_afi_safi_community,
10635 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010636 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010637 SHOW_STR
10638 BGP_STR
10639 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010640 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010641 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010642 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010643 "Address family modifier\n"
10644 "Address family modifier\n"
10645 "Display routes matching the communities\n"
10646 "community number\n"
10647 "Do not send outside local AS (well-known community)\n"
10648 "Do not advertise to any peer (well-known community)\n"
10649 "Do not export to next AS (well-known community)\n")
10650{
10651 int afi;
10652 int safi;
10653
Michael Lambert95cbbd22010-07-23 14:43:04 -040010654 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10655 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10656 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010657}
10658
10659ALIAS (show_bgp_view_afi_safi_community,
10660 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010661 "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 -040010662 SHOW_STR
10663 BGP_STR
10664 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010665 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010666 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010667 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010668 "Address family modifier\n"
10669 "Address family modifier\n"
10670 "Display routes matching the communities\n"
10671 "community number\n"
10672 "Do not send outside local AS (well-known community)\n"
10673 "Do not advertise to any peer (well-known community)\n"
10674 "Do not export to next AS (well-known community)\n"
10675 "community number\n"
10676 "Do not send outside local AS (well-known community)\n"
10677 "Do not advertise to any peer (well-known community)\n"
10678 "Do not export to next AS (well-known community)\n")
10679
10680ALIAS (show_bgp_view_afi_safi_community,
10681 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010682 "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 -040010683 SHOW_STR
10684 BGP_STR
10685 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010686 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010687 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010688 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010689 "Address family modifier\n"
10690 "Address family modifier\n"
10691 "Display routes matching the communities\n"
10692 "community number\n"
10693 "Do not send outside local AS (well-known community)\n"
10694 "Do not advertise to any peer (well-known community)\n"
10695 "Do not export to next AS (well-known community)\n"
10696 "community number\n"
10697 "Do not send outside local AS (well-known community)\n"
10698 "Do not advertise to any peer (well-known community)\n"
10699 "Do not export to next AS (well-known community)\n"
10700 "community number\n"
10701 "Do not send outside local AS (well-known community)\n"
10702 "Do not advertise to any peer (well-known community)\n"
10703 "Do not export to next AS (well-known community)\n")
10704
10705ALIAS (show_bgp_view_afi_safi_community,
10706 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010707 "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 -040010708 SHOW_STR
10709 BGP_STR
10710 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010711 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010712 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010713 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010714 "Address family modifier\n"
10715 "Address family modifier\n"
10716 "Display routes matching the communities\n"
10717 "community number\n"
10718 "Do not send outside local AS (well-known community)\n"
10719 "Do not advertise to any peer (well-known community)\n"
10720 "Do not export to next AS (well-known community)\n"
10721 "community number\n"
10722 "Do not send outside local AS (well-known community)\n"
10723 "Do not advertise to any peer (well-known community)\n"
10724 "Do not export to next AS (well-known community)\n"
10725 "community number\n"
10726 "Do not send outside local AS (well-known community)\n"
10727 "Do not advertise to any peer (well-known community)\n"
10728 "Do not export to next AS (well-known community)\n"
10729 "community number\n"
10730 "Do not send outside local AS (well-known community)\n"
10731 "Do not advertise to any peer (well-known community)\n"
10732 "Do not export to next AS (well-known community)\n")
10733
Lou Berger651b4022016-01-12 13:42:07 -050010734DEFUN (show_bgp_ipv4_community_exact,
10735 show_bgp_ipv4_community_exact_cmd,
10736 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010737 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010738 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010739 IP_STR
paul718e3742002-12-13 20:15:29 +000010740 "Display routes matching the communities\n"
10741 "community number\n"
10742 "Do not send outside local AS (well-known community)\n"
10743 "Do not advertise to any peer (well-known community)\n"
10744 "Do not export to next AS (well-known community)\n"
10745 "Exact match of the communities")
10746{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010747 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010748}
10749
Lou Berger651b4022016-01-12 13:42:07 -050010750ALIAS (show_bgp_ipv4_community_exact,
10751 show_bgp_ipv4_community2_exact_cmd,
10752 "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 +000010753 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010754 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010755 IP_STR
paul718e3742002-12-13 20:15:29 +000010756 "Display routes matching the communities\n"
10757 "community number\n"
10758 "Do not send outside local AS (well-known community)\n"
10759 "Do not advertise to any peer (well-known community)\n"
10760 "Do not export to next AS (well-known community)\n"
10761 "community number\n"
10762 "Do not send outside local AS (well-known community)\n"
10763 "Do not advertise to any peer (well-known community)\n"
10764 "Do not export to next AS (well-known community)\n"
10765 "Exact match of the communities")
10766
Lou Berger651b4022016-01-12 13:42:07 -050010767ALIAS (show_bgp_ipv4_community_exact,
10768 show_bgp_ipv4_community3_exact_cmd,
10769 "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 +000010770 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010771 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010772 IP_STR
paul718e3742002-12-13 20:15:29 +000010773 "Display routes matching the communities\n"
10774 "community number\n"
10775 "Do not send outside local AS (well-known community)\n"
10776 "Do not advertise to any peer (well-known community)\n"
10777 "Do not export to next AS (well-known community)\n"
10778 "community number\n"
10779 "Do not send outside local AS (well-known community)\n"
10780 "Do not advertise to any peer (well-known community)\n"
10781 "Do not export to next AS (well-known community)\n"
10782 "community number\n"
10783 "Do not send outside local AS (well-known community)\n"
10784 "Do not advertise to any peer (well-known community)\n"
10785 "Do not export to next AS (well-known community)\n"
10786 "Exact match of the communities")
10787
Lou Berger651b4022016-01-12 13:42:07 -050010788ALIAS (show_bgp_ipv4_community_exact,
10789 show_bgp_ipv4_community4_exact_cmd,
10790 "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 +000010791 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010792 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010793 IP_STR
paul718e3742002-12-13 20:15:29 +000010794 "Display routes matching the communities\n"
10795 "community number\n"
10796 "Do not send outside local AS (well-known community)\n"
10797 "Do not advertise to any peer (well-known community)\n"
10798 "Do not export to next AS (well-known community)\n"
10799 "community number\n"
10800 "Do not send outside local AS (well-known community)\n"
10801 "Do not advertise to any peer (well-known community)\n"
10802 "Do not export to next AS (well-known community)\n"
10803 "community number\n"
10804 "Do not send outside local AS (well-known community)\n"
10805 "Do not advertise to any peer (well-known community)\n"
10806 "Do not export to next AS (well-known community)\n"
10807 "community number\n"
10808 "Do not send outside local AS (well-known community)\n"
10809 "Do not advertise to any peer (well-known community)\n"
10810 "Do not export to next AS (well-known community)\n"
10811 "Exact match of the communities")
10812
Lou Berger651b4022016-01-12 13:42:07 -050010813DEFUN (show_bgp_ipv4_safi_community4_exact,
10814 show_bgp_ipv4_safi_community_exact_cmd,
10815 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010816 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010817 BGP_STR
10818 "Address family\n"
10819 "Address Family modifier\n"
10820 "Address Family modifier\n"
10821 "Display routes matching the communities\n"
10822 "community number\n"
10823 "Do not send outside local AS (well-known community)\n"
10824 "Do not advertise to any peer (well-known community)\n"
10825 "Do not export to next AS (well-known community)\n"
10826 "Exact match of the communities")
10827{
10828 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010829 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010830
Michael Lambert95cbbd22010-07-23 14:43:04 -040010831 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010832}
10833
Lou Berger651b4022016-01-12 13:42:07 -050010834ALIAS (show_bgp_ipv4_safi_community4_exact,
10835 show_bgp_ipv4_safi_community2_exact_cmd,
10836 "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 +000010837 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010838 BGP_STR
10839 "Address family\n"
10840 "Address Family modifier\n"
10841 "Address Family modifier\n"
10842 "Display routes matching the communities\n"
10843 "community number\n"
10844 "Do not send outside local AS (well-known community)\n"
10845 "Do not advertise to any peer (well-known community)\n"
10846 "Do not export to next AS (well-known community)\n"
10847 "community number\n"
10848 "Do not send outside local AS (well-known community)\n"
10849 "Do not advertise to any peer (well-known community)\n"
10850 "Do not export to next AS (well-known community)\n"
10851 "Exact match of the communities")
10852
Lou Berger651b4022016-01-12 13:42:07 -050010853ALIAS (show_bgp_ipv4_safi_community4_exact,
10854 show_bgp_ipv4_safi_community3_exact_cmd,
10855 "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 +000010856 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010857 BGP_STR
10858 "Address family\n"
10859 "Address Family modifier\n"
10860 "Address Family modifier\n"
10861 "Display routes matching the communities\n"
10862 "community number\n"
10863 "Do not send outside local AS (well-known community)\n"
10864 "Do not advertise to any peer (well-known community)\n"
10865 "Do not export to next AS (well-known community)\n"
10866 "community number\n"
10867 "Do not send outside local AS (well-known community)\n"
10868 "Do not advertise to any peer (well-known community)\n"
10869 "Do not export to next AS (well-known community)\n"
10870 "community number\n"
10871 "Do not send outside local AS (well-known community)\n"
10872 "Do not advertise to any peer (well-known community)\n"
10873 "Do not export to next AS (well-known community)\n"
10874 "Exact match of the communities")
10875
Lou Berger651b4022016-01-12 13:42:07 -050010876ALIAS (show_bgp_ipv4_safi_community4_exact,
10877 show_bgp_ipv4_safi_community4_exact_cmd,
10878 "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 +000010879 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010880 BGP_STR
10881 "Address family\n"
10882 "Address Family modifier\n"
10883 "Address Family modifier\n"
10884 "Display routes matching the communities\n"
10885 "community number\n"
10886 "Do not send outside local AS (well-known community)\n"
10887 "Do not advertise to any peer (well-known community)\n"
10888 "Do not export to next AS (well-known community)\n"
10889 "community number\n"
10890 "Do not send outside local AS (well-known community)\n"
10891 "Do not advertise to any peer (well-known community)\n"
10892 "Do not export to next AS (well-known community)\n"
10893 "community number\n"
10894 "Do not send outside local AS (well-known community)\n"
10895 "Do not advertise to any peer (well-known community)\n"
10896 "Do not export to next AS (well-known community)\n"
10897 "community number\n"
10898 "Do not send outside local AS (well-known community)\n"
10899 "Do not advertise to any peer (well-known community)\n"
10900 "Do not export to next AS (well-known community)\n"
10901 "Exact match of the communities")
10902
Lou Bergerf9b6c392016-01-12 13:42:09 -050010903DEFUN (show_bgp_ipv6_safi_community,
10904 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010905 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010906 SHOW_STR
10907 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010908 "Address family\n"
10909 "Address family modifier\n"
10910 "Address family modifier\n"
10911 "Address family modifier\n"
10912 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010913 "Display routes matching the communities\n"
10914 "community number\n"
10915 "Do not send outside local AS (well-known community)\n"
10916 "Do not advertise to any peer (well-known community)\n"
10917 "Do not export to next AS (well-known community)\n")
10918{
Lou Berger651b4022016-01-12 13:42:07 -050010919 safi_t safi;
10920
10921 if (bgp_parse_safi(argv[0], &safi)) {
10922 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10923 return CMD_WARNING;
10924 }
10925 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010926}
10927
Lou Bergerf9b6c392016-01-12 13:42:09 -050010928ALIAS (show_bgp_ipv6_safi_community,
10929 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010930 "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 +000010931 SHOW_STR
10932 BGP_STR
10933 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010934 "Address family modifier\n"
10935 "Address family modifier\n"
10936 "Address family modifier\n"
10937 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010938 "Display routes matching the communities\n"
10939 "community number\n"
10940 "Do not send outside local AS (well-known community)\n"
10941 "Do not advertise to any peer (well-known community)\n"
10942 "Do not export to next AS (well-known community)\n"
10943 "community number\n"
10944 "Do not send outside local AS (well-known community)\n"
10945 "Do not advertise to any peer (well-known community)\n"
10946 "Do not export to next AS (well-known community)\n")
10947
Lou Bergerf9b6c392016-01-12 13:42:09 -050010948ALIAS (show_bgp_ipv6_safi_community,
10949 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010950 "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 +000010951 SHOW_STR
10952 BGP_STR
10953 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010954 "Address family modifier\n"
10955 "Address family modifier\n"
10956 "Address family modifier\n"
10957 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010958 "Display routes matching the communities\n"
10959 "community number\n"
10960 "Do not send outside local AS (well-known community)\n"
10961 "Do not advertise to any peer (well-known community)\n"
10962 "Do not export to next AS (well-known community)\n"
10963 "community number\n"
10964 "Do not send outside local AS (well-known community)\n"
10965 "Do not advertise to any peer (well-known community)\n"
10966 "Do not export to next AS (well-known community)\n"
10967 "community number\n"
10968 "Do not send outside local AS (well-known community)\n"
10969 "Do not advertise to any peer (well-known community)\n"
10970 "Do not export to next AS (well-known community)\n")
10971
Lou Bergerf9b6c392016-01-12 13:42:09 -050010972ALIAS (show_bgp_ipv6_safi_community,
10973 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010974 "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 +000010975 SHOW_STR
10976 BGP_STR
10977 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010978 "Address family modifier\n"
10979 "Address family modifier\n"
10980 "Address family modifier\n"
10981 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010982 "Display routes matching the communities\n"
10983 "community number\n"
10984 "Do not send outside local AS (well-known community)\n"
10985 "Do not advertise to any peer (well-known community)\n"
10986 "Do not export to next AS (well-known community)\n"
10987 "community number\n"
10988 "Do not send outside local AS (well-known community)\n"
10989 "Do not advertise to any peer (well-known community)\n"
10990 "Do not export to next AS (well-known community)\n"
10991 "community number\n"
10992 "Do not send outside local AS (well-known community)\n"
10993 "Do not advertise to any peer (well-known community)\n"
10994 "Do not export to next AS (well-known community)\n"
10995 "community number\n"
10996 "Do not send outside local AS (well-known community)\n"
10997 "Do not advertise to any peer (well-known community)\n"
10998 "Do not export to next AS (well-known community)\n")
10999
paul718e3742002-12-13 20:15:29 +000011000
Lou Bergerf9b6c392016-01-12 13:42:09 -050011001DEFUN (show_bgp_ipv6_safi_community_exact,
11002 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011003 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000011004 SHOW_STR
11005 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011006 "Address family\n"
11007 "Address family modifier\n"
11008 "Address family modifier\n"
11009 "Address family modifier\n"
11010 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011011 "Display routes matching the communities\n"
11012 "community number\n"
11013 "Do not send outside local AS (well-known community)\n"
11014 "Do not advertise to any peer (well-known community)\n"
11015 "Do not export to next AS (well-known community)\n"
11016 "Exact match of the communities")
11017{
Lou Berger651b4022016-01-12 13:42:07 -050011018 safi_t safi;
11019
11020 if (bgp_parse_safi(argv[0], &safi)) {
11021 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11022 return CMD_WARNING;
11023 }
11024 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011025}
11026
paul718e3742002-12-13 20:15:29 +000011027
11028ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011029 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011030 "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 +000011031 SHOW_STR
11032 BGP_STR
11033 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011034 "Address family modifier\n"
11035 "Address family modifier\n"
11036 "Address family modifier\n"
11037 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011038 "Display routes matching the communities\n"
11039 "community number\n"
11040 "Do not send outside local AS (well-known community)\n"
11041 "Do not advertise to any peer (well-known community)\n"
11042 "Do not export to next AS (well-known community)\n"
11043 "community number\n"
11044 "Do not send outside local AS (well-known community)\n"
11045 "Do not advertise to any peer (well-known community)\n"
11046 "Do not export to next AS (well-known community)\n"
11047 "Exact match of the communities")
11048
11049ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011050 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011051 "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 +000011052 SHOW_STR
11053 BGP_STR
11054 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011055 "Address family modifier\n"
11056 "Address family modifier\n"
11057 "Address family modifier\n"
11058 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011059 "Display routes matching the communities\n"
11060 "community number\n"
11061 "Do not send outside local AS (well-known community)\n"
11062 "Do not advertise to any peer (well-known community)\n"
11063 "Do not export to next AS (well-known community)\n"
11064 "community number\n"
11065 "Do not send outside local AS (well-known community)\n"
11066 "Do not advertise to any peer (well-known community)\n"
11067 "Do not export to next AS (well-known community)\n"
11068 "community number\n"
11069 "Do not send outside local AS (well-known community)\n"
11070 "Do not advertise to any peer (well-known community)\n"
11071 "Do not export to next AS (well-known community)\n"
11072 "Exact match of the communities")
11073
11074ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011075 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011076 "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 +000011077 SHOW_STR
11078 BGP_STR
11079 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011080 "Address family modifier\n"
11081 "Address family modifier\n"
11082 "Address family modifier\n"
11083 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011084 "Display routes matching the communities\n"
11085 "community number\n"
11086 "Do not send outside local AS (well-known community)\n"
11087 "Do not advertise to any peer (well-known community)\n"
11088 "Do not export to next AS (well-known community)\n"
11089 "community number\n"
11090 "Do not send outside local AS (well-known community)\n"
11091 "Do not advertise to any peer (well-known community)\n"
11092 "Do not export to next AS (well-known community)\n"
11093 "community number\n"
11094 "Do not send outside local AS (well-known community)\n"
11095 "Do not advertise to any peer (well-known community)\n"
11096 "Do not export to next AS (well-known community)\n"
11097 "community number\n"
11098 "Do not send outside local AS (well-known community)\n"
11099 "Do not advertise to any peer (well-known community)\n"
11100 "Do not export to next AS (well-known community)\n"
11101 "Exact match of the communities")
11102
paul94f2b392005-06-28 12:44:16 +000011103static int
paulfd79ac92004-10-13 05:06:08 +000011104bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040011105 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000011106{
11107 struct community_list *list;
11108
hassofee6e4e2005-02-02 16:29:31 +000011109 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000011110 if (list == NULL)
11111 {
11112 vty_out (vty, "%% %s is not a valid community-list name%s", com,
11113 VTY_NEWLINE);
11114 return CMD_WARNING;
11115 }
11116
ajs5a646652004-11-05 01:25:55 +000011117 return bgp_show (vty, NULL, afi, safi,
11118 (exact ? bgp_show_type_community_list_exact :
11119 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000011120}
11121
Lou Bergerf9b6c392016-01-12 13:42:09 -050011122DEFUN (show_ip_bgp_community_list,
11123 show_ip_bgp_community_list_cmd,
11124 "show ip bgp community-list (<1-500>|WORD)",
11125 SHOW_STR
11126 IP_STR
11127 BGP_STR
11128 "Display routes matching the community-list\n"
11129 "community-list number\n"
11130 "community-list name\n")
11131{
11132 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11133}
11134
11135DEFUN (show_ip_bgp_ipv4_community_list,
11136 show_ip_bgp_ipv4_community_list_cmd,
11137 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11138 SHOW_STR
11139 IP_STR
11140 BGP_STR
11141 "Address family\n"
11142 "Address Family modifier\n"
11143 "Address Family modifier\n"
11144 "Display routes matching the community-list\n"
11145 "community-list number\n"
11146 "community-list name\n")
11147{
11148 if (strncmp (argv[0], "m", 1) == 0)
11149 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11150
11151 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11152}
11153
11154DEFUN (show_ip_bgp_community_list_exact,
11155 show_ip_bgp_community_list_exact_cmd,
11156 "show ip bgp community-list (<1-500>|WORD) exact-match",
11157 SHOW_STR
11158 IP_STR
11159 BGP_STR
11160 "Display routes matching the community-list\n"
11161 "community-list number\n"
11162 "community-list name\n"
11163 "Exact match of the communities\n")
11164{
11165 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11166}
11167
11168DEFUN (show_ip_bgp_ipv4_community_list_exact,
11169 show_ip_bgp_ipv4_community_list_exact_cmd,
11170 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11171 SHOW_STR
11172 IP_STR
11173 BGP_STR
11174 "Address family\n"
11175 "Address Family modifier\n"
11176 "Address Family modifier\n"
11177 "Display routes matching the community-list\n"
11178 "community-list number\n"
11179 "community-list name\n"
11180 "Exact match of the communities\n")
11181{
11182 if (strncmp (argv[0], "m", 1) == 0)
11183 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11184
11185 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11186}
11187
Lou Bergerf9b6c392016-01-12 13:42:09 -050011188DEFUN (show_bgp_community_list,
11189 show_bgp_community_list_cmd,
11190 "show bgp community-list (<1-500>|WORD)",
11191 SHOW_STR
11192 BGP_STR
11193 "Display routes matching the community-list\n"
11194 "community-list number\n"
11195 "community-list name\n")
11196{
11197 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11198}
11199
11200ALIAS (show_bgp_community_list,
11201 show_bgp_ipv6_community_list_cmd,
11202 "show bgp ipv6 community-list (<1-500>|WORD)",
11203 SHOW_STR
11204 BGP_STR
11205 "Address family\n"
11206 "Display routes matching the community-list\n"
11207 "community-list number\n"
11208 "community-list name\n")
11209
11210/* old command */
11211DEFUN (show_ipv6_bgp_community_list,
11212 show_ipv6_bgp_community_list_cmd,
11213 "show ipv6 bgp community-list WORD",
11214 SHOW_STR
11215 IPV6_STR
11216 BGP_STR
11217 "Display routes matching the community-list\n"
11218 "community-list name\n")
11219{
11220 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11221}
11222
11223/* old command */
11224DEFUN (show_ipv6_mbgp_community_list,
11225 show_ipv6_mbgp_community_list_cmd,
11226 "show ipv6 mbgp community-list WORD",
11227 SHOW_STR
11228 IPV6_STR
11229 MBGP_STR
11230 "Display routes matching the community-list\n"
11231 "community-list name\n")
11232{
11233 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
11234}
11235
11236DEFUN (show_bgp_community_list_exact,
11237 show_bgp_community_list_exact_cmd,
11238 "show bgp community-list (<1-500>|WORD) exact-match",
11239 SHOW_STR
11240 BGP_STR
11241 "Display routes matching the community-list\n"
11242 "community-list number\n"
11243 "community-list name\n"
11244 "Exact match of the communities\n")
11245{
11246 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11247}
11248
11249ALIAS (show_bgp_community_list_exact,
11250 show_bgp_ipv6_community_list_exact_cmd,
11251 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11252 SHOW_STR
11253 BGP_STR
11254 "Address family\n"
11255 "Display routes matching the community-list\n"
11256 "community-list number\n"
11257 "community-list name\n"
11258 "Exact match of the communities\n")
11259
11260/* old command */
11261DEFUN (show_ipv6_bgp_community_list_exact,
11262 show_ipv6_bgp_community_list_exact_cmd,
11263 "show ipv6 bgp community-list WORD exact-match",
11264 SHOW_STR
11265 IPV6_STR
11266 BGP_STR
11267 "Display routes matching the community-list\n"
11268 "community-list name\n"
11269 "Exact match of the communities\n")
11270{
11271 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11272}
11273
11274/* old command */
11275DEFUN (show_ipv6_mbgp_community_list_exact,
11276 show_ipv6_mbgp_community_list_exact_cmd,
11277 "show ipv6 mbgp community-list WORD exact-match",
11278 SHOW_STR
11279 IPV6_STR
11280 MBGP_STR
11281 "Display routes matching the community-list\n"
11282 "community-list name\n"
11283 "Exact match of the communities\n")
11284{
11285 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
11286}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011287
Lou Berger651b4022016-01-12 13:42:07 -050011288DEFUN (show_bgp_ipv4_community_list,
11289 show_bgp_ipv4_community_list_cmd,
11290 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011291 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011292 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011293 IP_STR
paul718e3742002-12-13 20:15:29 +000011294 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011295 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011296 "community-list name\n")
11297{
11298 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11299}
11300
Lou Berger651b4022016-01-12 13:42:07 -050011301DEFUN (show_bgp_ipv4_safi_community_list,
11302 show_bgp_ipv4_safi_community_list_cmd,
11303 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011304 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011305 BGP_STR
11306 "Address family\n"
11307 "Address Family modifier\n"
11308 "Address Family modifier\n"
11309 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011310 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011311 "community-list name\n")
11312{
11313 if (strncmp (argv[0], "m", 1) == 0)
11314 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11315
11316 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11317}
11318
Lou Berger651b4022016-01-12 13:42:07 -050011319DEFUN (show_bgp_ipv4_community_list_exact,
11320 show_bgp_ipv4_community_list_exact_cmd,
11321 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011322 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011323 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011324 IP_STR
paul718e3742002-12-13 20:15:29 +000011325 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011326 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011327 "community-list name\n"
11328 "Exact match of the communities\n")
11329{
11330 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11331}
11332
Lou Berger651b4022016-01-12 13:42:07 -050011333DEFUN (show_bgp_ipv4_safi_community_list_exact,
11334 show_bgp_ipv4_safi_community_list_exact_cmd,
11335 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011336 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011337 BGP_STR
11338 "Address family\n"
11339 "Address Family modifier\n"
11340 "Address Family modifier\n"
11341 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011342 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011343 "community-list name\n"
11344 "Exact match of the communities\n")
11345{
11346 if (strncmp (argv[0], "m", 1) == 0)
11347 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11348
11349 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11350}
11351
Lou Bergerf9b6c392016-01-12 13:42:09 -050011352DEFUN (show_bgp_ipv6_safi_community_list,
11353 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011354 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011355 SHOW_STR
11356 BGP_STR
11357 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011358 "Address family modifier\n"
11359 "Address family modifier\n"
11360 "Address family modifier\n"
11361 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011362 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011363 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011364 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011365{
Lou Berger651b4022016-01-12 13:42:07 -050011366 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011367
Lou Berger651b4022016-01-12 13:42:07 -050011368 if (bgp_parse_safi(argv[0], &safi)) {
11369 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11370 return CMD_WARNING;
11371 }
11372 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011373}
11374
Lou Bergerf9b6c392016-01-12 13:42:09 -050011375DEFUN (show_bgp_ipv6_safi_community_list_exact,
11376 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011377 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011378 SHOW_STR
11379 BGP_STR
11380 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011381 "Address family modifier\n"
11382 "Address family modifier\n"
11383 "Address family modifier\n"
11384 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011385 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011386 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011387 "community-list name\n"
11388 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011389{
Lou Berger651b4022016-01-12 13:42:07 -050011390 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011391
Lou Berger651b4022016-01-12 13:42:07 -050011392 if (bgp_parse_safi(argv[0], &safi)) {
11393 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11394 return CMD_WARNING;
11395 }
11396 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011397}
David Lamparter6b0655a2014-06-04 06:53:35 +020011398
paul94f2b392005-06-28 12:44:16 +000011399static int
paulfd79ac92004-10-13 05:06:08 +000011400bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011401 safi_t safi, enum bgp_show_type type)
11402{
11403 int ret;
11404 struct prefix *p;
11405
11406 p = prefix_new();
11407
11408 ret = str2prefix (prefix, p);
11409 if (! ret)
11410 {
11411 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11412 return CMD_WARNING;
11413 }
11414
ajs5a646652004-11-05 01:25:55 +000011415 ret = bgp_show (vty, NULL, afi, safi, type, p);
11416 prefix_free(p);
11417 return ret;
paul718e3742002-12-13 20:15:29 +000011418}
11419
Lou Bergerf9b6c392016-01-12 13:42:09 -050011420DEFUN (show_ip_bgp_prefix_longer,
11421 show_ip_bgp_prefix_longer_cmd,
11422 "show ip bgp A.B.C.D/M longer-prefixes",
11423 SHOW_STR
11424 IP_STR
11425 BGP_STR
11426 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11427 "Display route and more specific routes\n")
11428{
11429 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11430 bgp_show_type_prefix_longer);
11431}
11432
11433DEFUN (show_ip_bgp_flap_prefix_longer,
11434 show_ip_bgp_flap_prefix_longer_cmd,
11435 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11436 SHOW_STR
11437 IP_STR
11438 BGP_STR
11439 "Display flap statistics of routes\n"
11440 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11441 "Display route and more specific routes\n")
11442{
11443 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11444 bgp_show_type_flap_prefix_longer);
11445}
11446
11447ALIAS (show_ip_bgp_flap_prefix_longer,
11448 show_ip_bgp_damp_flap_prefix_longer_cmd,
11449 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11450 SHOW_STR
11451 IP_STR
11452 BGP_STR
11453 "Display detailed information about dampening\n"
11454 "Display flap statistics of routes\n"
11455 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11456 "Display route and more specific routes\n")
11457
11458DEFUN (show_ip_bgp_ipv4_prefix_longer,
11459 show_ip_bgp_ipv4_prefix_longer_cmd,
11460 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11461 SHOW_STR
11462 IP_STR
11463 BGP_STR
11464 "Address family\n"
11465 "Address Family modifier\n"
11466 "Address Family modifier\n"
11467 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11468 "Display route and more specific routes\n")
11469{
11470 if (strncmp (argv[0], "m", 1) == 0)
11471 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11472 bgp_show_type_prefix_longer);
11473
11474 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11475 bgp_show_type_prefix_longer);
11476}
11477
11478DEFUN (show_ip_bgp_flap_address,
11479 show_ip_bgp_flap_address_cmd,
11480 "show ip bgp flap-statistics A.B.C.D",
11481 SHOW_STR
11482 IP_STR
11483 BGP_STR
11484 "Display flap statistics of routes\n"
11485 "Network in the BGP routing table to display\n")
11486{
11487 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11488 bgp_show_type_flap_address);
11489}
11490
11491ALIAS (show_ip_bgp_flap_address,
11492 show_ip_bgp_damp_flap_address_cmd,
11493 "show ip bgp dampening flap-statistics A.B.C.D",
11494 SHOW_STR
11495 IP_STR
11496 BGP_STR
11497 "Display detailed information about dampening\n"
11498 "Display flap statistics of routes\n"
11499 "Network in the BGP routing table to display\n")
11500
11501DEFUN (show_ip_bgp_flap_prefix,
11502 show_ip_bgp_flap_prefix_cmd,
11503 "show ip bgp flap-statistics A.B.C.D/M",
11504 SHOW_STR
11505 IP_STR
11506 BGP_STR
11507 "Display flap statistics of routes\n"
11508 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11509{
11510 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11511 bgp_show_type_flap_prefix);
11512}
11513
11514ALIAS (show_ip_bgp_flap_prefix,
11515 show_ip_bgp_damp_flap_prefix_cmd,
11516 "show ip bgp dampening flap-statistics A.B.C.D/M",
11517 SHOW_STR
11518 IP_STR
11519 BGP_STR
11520 "Display detailed information about dampening\n"
11521 "Display flap statistics of routes\n"
11522 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11523
Lou Bergerf9b6c392016-01-12 13:42:09 -050011524DEFUN (show_bgp_prefix_longer,
11525 show_bgp_prefix_longer_cmd,
11526 "show bgp X:X::X:X/M longer-prefixes",
11527 SHOW_STR
11528 BGP_STR
11529 "IPv6 prefix <network>/<length>\n"
11530 "Display route and more specific routes\n")
11531{
11532 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11533 bgp_show_type_prefix_longer);
11534}
11535
11536/* old command */
11537DEFUN (show_ipv6_bgp_prefix_longer,
11538 show_ipv6_bgp_prefix_longer_cmd,
11539 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11540 SHOW_STR
11541 IPV6_STR
11542 BGP_STR
11543 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11544 "Display route and more specific routes\n")
11545{
11546 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11547 bgp_show_type_prefix_longer);
11548}
11549
11550/* old command */
11551DEFUN (show_ipv6_mbgp_prefix_longer,
11552 show_ipv6_mbgp_prefix_longer_cmd,
11553 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11554 SHOW_STR
11555 IPV6_STR
11556 MBGP_STR
11557 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11558 "Display route and more specific routes\n")
11559{
11560 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
11561 bgp_show_type_prefix_longer);
11562}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011563
Lou Berger651b4022016-01-12 13:42:07 -050011564DEFUN (show_bgp_ipv4_prefix_longer,
11565 show_bgp_ipv4_prefix_longer_cmd,
11566 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011567 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011568 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011569 IP_STR
paul718e3742002-12-13 20:15:29 +000011570 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11571 "Display route and more specific routes\n")
11572{
11573 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11574 bgp_show_type_prefix_longer);
11575}
11576
Lou Berger651b4022016-01-12 13:42:07 -050011577DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11578 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11579 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011580 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011581 BGP_STR
11582 "Address family\n"
11583 "Address Family modifier\n"
11584 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011585 "Address Family modifier\n"
11586 "Address Family modifier\n"
11587 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011588 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11589 "Display route and more specific routes\n")
11590{
Lou Berger651b4022016-01-12 13:42:07 -050011591 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011592
Lou Berger651b4022016-01-12 13:42:07 -050011593 if (bgp_parse_safi(argv[0], &safi)) {
11594 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11595 return CMD_WARNING;
11596 }
11597 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11598 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011599}
11600
Lou Berger651b4022016-01-12 13:42:07 -050011601ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11602 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11603 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011604 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011605 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011606 "Address family\n"
11607 "Address Family modifier\n"
11608 "Address Family modifier\n"
11609 "Address Family modifier\n"
11610 "Address Family modifier\n"
11611 "Display detailed information about dampening\n"
11612 "Display flap statistics of routes\n"
11613 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11614 "Display route and more specific routes\n")
11615
Lou Berger651b4022016-01-12 13:42:07 -050011616DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11617 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11618 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11619 SHOW_STR
11620 BGP_STR
11621 "Address family\n"
11622 "Address Family modifier\n"
11623 "Address Family modifier\n"
11624 "Address Family modifier\n"
11625 "Address Family modifier\n"
11626 "Display flap statistics of routes\n"
11627 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11628 "Display route and more specific routes\n")
11629{
11630 safi_t safi;
11631
11632 if (bgp_parse_safi(argv[0], &safi)) {
11633 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11634 return CMD_WARNING;
11635 }
11636 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11637 bgp_show_type_flap_prefix_longer);
11638}
11639ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11640 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11641 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11642 SHOW_STR
11643 BGP_STR
11644 "Address family\n"
11645 "Address Family modifier\n"
11646 "Address Family modifier\n"
11647 "Address Family modifier\n"
11648 "Address Family modifier\n"
11649 "Display detailed information about dampening\n"
11650 "Display flap statistics of routes\n"
11651 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11652 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011653
11654DEFUN (show_bgp_ipv4_safi_prefix_longer,
11655 show_bgp_ipv4_safi_prefix_longer_cmd,
11656 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11657 SHOW_STR
11658 BGP_STR
11659 "Address family\n"
11660 "Address Family modifier\n"
11661 "Address Family modifier\n"
11662 "Address Family modifier\n"
11663 "Address Family modifier\n"
11664 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11665 "Display route and more specific routes\n")
11666{
11667 safi_t safi;
11668
11669 if (bgp_parse_safi(argv[0], &safi)) {
11670 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11671 return CMD_WARNING;
11672 }
11673
11674 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11675 bgp_show_type_prefix_longer);
11676}
11677
Lou Berger651b4022016-01-12 13:42:07 -050011678DEFUN (show_bgp_ipv6_safi_prefix_longer,
11679 show_bgp_ipv6_safi_prefix_longer_cmd,
11680 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11681 SHOW_STR
11682 BGP_STR
11683 "Address family\n"
11684 "Address Family modifier\n"
11685 "Address Family modifier\n"
11686 "Address Family modifier\n"
11687 "Address Family modifier\n"
11688 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11689 "Display route and more specific routes\n")
11690{
11691 safi_t safi;
11692
11693 if (bgp_parse_safi(argv[0], &safi)) {
11694 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11695 return CMD_WARNING;
11696 }
11697
11698 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11699 bgp_show_type_prefix_longer);
11700}
Lou Berger651b4022016-01-12 13:42:07 -050011701
11702DEFUN (show_bgp_ipv4_safi_flap_address,
11703 show_bgp_ipv4_safi_flap_address_cmd,
11704 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11705 SHOW_STR
11706 BGP_STR
11707 "Address family\n"
11708 "Address Family modifier\n"
11709 "Address Family modifier\n"
11710 "Address Family modifier\n"
11711 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011712 "Display flap statistics of routes\n"
11713 "Network in the BGP routing table to display\n")
11714{
Lou Berger651b4022016-01-12 13:42:07 -050011715 safi_t safi;
11716
11717 if (bgp_parse_safi(argv[0], &safi)) {
11718 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11719 return CMD_WARNING;
11720 }
11721 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011722 bgp_show_type_flap_address);
11723}
Lou Berger651b4022016-01-12 13:42:07 -050011724ALIAS (show_bgp_ipv4_safi_flap_address,
11725 show_bgp_ipv4_safi_damp_flap_address_cmd,
11726 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011727 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011728 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011729 "Address family\n"
11730 "Address Family modifier\n"
11731 "Address Family modifier\n"
11732 "Address Family modifier\n"
11733 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011734 "Display detailed information about dampening\n"
11735 "Display flap statistics of routes\n"
11736 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011737
Lou Berger651b4022016-01-12 13:42:07 -050011738DEFUN (show_bgp_ipv6_flap_address,
11739 show_bgp_ipv6_flap_address_cmd,
11740 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011741 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011742 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011743 "Address family\n"
11744 "Address Family modifier\n"
11745 "Address Family modifier\n"
11746 "Address Family modifier\n"
11747 "Address Family modifier\n"
11748 "Display flap statistics of routes\n"
11749 "Network in the BGP routing table to display\n")
11750{
11751 safi_t safi;
11752
11753 if (bgp_parse_safi(argv[0], &safi)) {
11754 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11755 return CMD_WARNING;
11756 }
11757 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11758 bgp_show_type_flap_address);
11759}
11760ALIAS (show_bgp_ipv6_flap_address,
11761 show_bgp_ipv6_damp_flap_address_cmd,
11762 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11763 SHOW_STR
11764 BGP_STR
11765 "Address family\n"
11766 "Address Family modifier\n"
11767 "Address Family modifier\n"
11768 "Address Family modifier\n"
11769 "Address Family modifier\n"
11770 "Display detailed information about dampening\n"
11771 "Display flap statistics of routes\n"
11772 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011773
11774DEFUN (show_bgp_ipv4_safi_flap_prefix,
11775 show_bgp_ipv4_safi_flap_prefix_cmd,
11776 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
11777 SHOW_STR
11778 BGP_STR
11779 "Address family\n"
11780 "Address Family modifier\n"
11781 "Address Family modifier\n"
11782 "Address Family modifier\n"
11783 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011784 "Display flap statistics of routes\n"
11785 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11786{
Lou Berger651b4022016-01-12 13:42:07 -050011787 safi_t safi;
11788
11789 if (bgp_parse_safi(argv[0], &safi)) {
11790 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11791 return CMD_WARNING;
11792 }
11793 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011794 bgp_show_type_flap_prefix);
11795}
Balaji3921cc52015-05-16 23:12:17 +053011796
Lou Berger651b4022016-01-12 13:42:07 -050011797ALIAS (show_bgp_ipv4_safi_flap_prefix,
11798 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11799 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011800 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011801 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011802 "Address family\n"
11803 "Address Family modifier\n"
11804 "Address Family modifier\n"
11805 "Address Family modifier\n"
11806 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011807 "Display detailed information about dampening\n"
11808 "Display flap statistics of routes\n"
11809 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11810
Lou Berger651b4022016-01-12 13:42:07 -050011811DEFUN (show_bgp_ipv6_safi_flap_prefix,
11812 show_bgp_ipv6_safi_flap_prefix_cmd,
11813 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011814 SHOW_STR
11815 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011816 "Address family\n"
11817 "Address Family modifier\n"
11818 "Address Family modifier\n"
11819 "Address Family modifier\n"
11820 "Address Family modifier\n"
11821 "Display flap statistics of routes\n"
11822 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011823{
Lou Berger651b4022016-01-12 13:42:07 -050011824 safi_t safi;
11825
11826 if (bgp_parse_safi(argv[0], &safi)) {
11827 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11828 return CMD_WARNING;
11829 }
11830 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11831 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011832}
11833
Lou Berger651b4022016-01-12 13:42:07 -050011834ALIAS (show_bgp_ipv6_safi_flap_prefix,
11835 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11836 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11837 SHOW_STR
11838 BGP_STR
11839 "Address family\n"
11840 "Address Family modifier\n"
11841 "Address Family modifier\n"
11842 "Address Family modifier\n"
11843 "Address Family modifier\n"
11844 "Display detailed information about dampening\n"
11845 "Display flap statistics of routes\n"
11846 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11847
11848DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011849 show_bgp_ipv6_prefix_longer_cmd,
11850 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11851 SHOW_STR
11852 BGP_STR
11853 "Address family\n"
11854 "IPv6 prefix <network>/<length>\n"
11855 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011856{
11857 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11858 bgp_show_type_prefix_longer);
11859}
11860
paul94f2b392005-06-28 12:44:16 +000011861static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011862peer_lookup_in_view (struct vty *vty, const char *view_name,
11863 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011864{
11865 int ret;
11866 struct bgp *bgp;
11867 struct peer *peer;
11868 union sockunion su;
11869
11870 /* BGP structure lookup. */
11871 if (view_name)
11872 {
11873 bgp = bgp_lookup_by_name (view_name);
11874 if (! bgp)
11875 {
11876 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11877 return NULL;
11878 }
11879 }
paul5228ad22004-06-04 17:58:18 +000011880 else
paulbb46e942003-10-24 19:02:03 +000011881 {
11882 bgp = bgp_get_default ();
11883 if (! bgp)
11884 {
11885 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11886 return NULL;
11887 }
11888 }
11889
11890 /* Get peer sockunion. */
11891 ret = str2sockunion (ip_str, &su);
11892 if (ret < 0)
11893 {
11894 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11895 return NULL;
11896 }
11897
11898 /* Peer structure lookup. */
11899 peer = peer_lookup (bgp, &su);
11900 if (! peer)
11901 {
11902 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11903 return NULL;
11904 }
11905
11906 return peer;
11907}
David Lamparter6b0655a2014-06-04 06:53:35 +020011908
Paul Jakma2815e612006-09-14 02:56:07 +000011909enum bgp_stats
11910{
11911 BGP_STATS_MAXBITLEN = 0,
11912 BGP_STATS_RIB,
11913 BGP_STATS_PREFIXES,
11914 BGP_STATS_TOTPLEN,
11915 BGP_STATS_UNAGGREGATEABLE,
11916 BGP_STATS_MAX_AGGREGATEABLE,
11917 BGP_STATS_AGGREGATES,
11918 BGP_STATS_SPACE,
11919 BGP_STATS_ASPATH_COUNT,
11920 BGP_STATS_ASPATH_MAXHOPS,
11921 BGP_STATS_ASPATH_TOTHOPS,
11922 BGP_STATS_ASPATH_MAXSIZE,
11923 BGP_STATS_ASPATH_TOTSIZE,
11924 BGP_STATS_ASN_HIGHEST,
11925 BGP_STATS_MAX,
11926};
paulbb46e942003-10-24 19:02:03 +000011927
Paul Jakma2815e612006-09-14 02:56:07 +000011928static const char *table_stats_strs[] =
11929{
11930 [BGP_STATS_PREFIXES] = "Total Prefixes",
11931 [BGP_STATS_TOTPLEN] = "Average prefix length",
11932 [BGP_STATS_RIB] = "Total Advertisements",
11933 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11934 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11935 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11936 [BGP_STATS_SPACE] = "Address space advertised",
11937 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11938 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11939 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11940 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11941 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11942 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11943 [BGP_STATS_MAX] = NULL,
11944};
11945
11946struct bgp_table_stats
11947{
11948 struct bgp_table *table;
11949 unsigned long long counts[BGP_STATS_MAX];
11950};
11951
11952#if 0
11953#define TALLY_SIGFIG 100000
11954static unsigned long
11955ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11956{
11957 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11958 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11959 unsigned long ret = newtot / count;
11960
11961 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11962 return ret + 1;
11963 else
11964 return ret;
11965}
11966#endif
11967
11968static int
11969bgp_table_stats_walker (struct thread *t)
11970{
11971 struct bgp_node *rn;
11972 struct bgp_node *top;
11973 struct bgp_table_stats *ts = THREAD_ARG (t);
11974 unsigned int space = 0;
11975
Paul Jakma53d9f672006-10-15 23:41:16 +000011976 if (!(top = bgp_table_top (ts->table)))
11977 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011978
11979 switch (top->p.family)
11980 {
11981 case AF_INET:
11982 space = IPV4_MAX_BITLEN;
11983 break;
11984 case AF_INET6:
11985 space = IPV6_MAX_BITLEN;
11986 break;
11987 }
11988
11989 ts->counts[BGP_STATS_MAXBITLEN] = space;
11990
11991 for (rn = top; rn; rn = bgp_route_next (rn))
11992 {
11993 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011994 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000011995 unsigned int rinum = 0;
11996
11997 if (rn == top)
11998 continue;
11999
12000 if (!rn->info)
12001 continue;
12002
12003 ts->counts[BGP_STATS_PREFIXES]++;
12004 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
12005
12006#if 0
12007 ts->counts[BGP_STATS_AVGPLEN]
12008 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
12009 ts->counts[BGP_STATS_AVGPLEN],
12010 rn->p.prefixlen);
12011#endif
12012
12013 /* check if the prefix is included by any other announcements */
12014 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070012015 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000012016
12017 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000012018 {
12019 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
12020 /* announced address space */
12021 if (space)
12022 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
12023 }
Paul Jakma2815e612006-09-14 02:56:07 +000012024 else if (prn->info)
12025 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
12026
Paul Jakma2815e612006-09-14 02:56:07 +000012027 for (ri = rn->info; ri; ri = ri->next)
12028 {
12029 rinum++;
12030 ts->counts[BGP_STATS_RIB]++;
12031
12032 if (ri->attr &&
12033 (CHECK_FLAG (ri->attr->flag,
12034 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
12035 ts->counts[BGP_STATS_AGGREGATES]++;
12036
12037 /* as-path stats */
12038 if (ri->attr && ri->attr->aspath)
12039 {
12040 unsigned int hops = aspath_count_hops (ri->attr->aspath);
12041 unsigned int size = aspath_size (ri->attr->aspath);
12042 as_t highest = aspath_highest (ri->attr->aspath);
12043
12044 ts->counts[BGP_STATS_ASPATH_COUNT]++;
12045
12046 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
12047 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
12048
12049 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
12050 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
12051
12052 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
12053 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
12054#if 0
12055 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
12056 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12057 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
12058 hops);
12059 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
12060 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12061 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
12062 size);
12063#endif
12064 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
12065 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
12066 }
12067 }
12068 }
12069 return 0;
12070}
12071
12072static int
12073bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
12074{
12075 struct bgp_table_stats ts;
12076 unsigned int i;
12077
12078 if (!bgp->rib[afi][safi])
12079 {
Donald Sharp3c964042016-01-25 23:38:53 -050012080 vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s",
12081 afi, safi, VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000012082 return CMD_WARNING;
12083 }
12084
12085 memset (&ts, 0, sizeof (ts));
12086 ts.table = bgp->rib[afi][safi];
12087 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
12088
12089 vty_out (vty, "BGP %s RIB statistics%s%s",
12090 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
12091
12092 for (i = 0; i < BGP_STATS_MAX; i++)
12093 {
12094 if (!table_stats_strs[i])
12095 continue;
12096
12097 switch (i)
12098 {
12099#if 0
12100 case BGP_STATS_ASPATH_AVGHOPS:
12101 case BGP_STATS_ASPATH_AVGSIZE:
12102 case BGP_STATS_AVGPLEN:
12103 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12104 vty_out (vty, "%12.2f",
12105 (float)ts.counts[i] / (float)TALLY_SIGFIG);
12106 break;
12107#endif
12108 case BGP_STATS_ASPATH_TOTHOPS:
12109 case BGP_STATS_ASPATH_TOTSIZE:
12110 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12111 vty_out (vty, "%12.2f",
12112 ts.counts[i] ?
12113 (float)ts.counts[i] /
12114 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
12115 : 0);
12116 break;
12117 case BGP_STATS_TOTPLEN:
12118 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12119 vty_out (vty, "%12.2f",
12120 ts.counts[i] ?
12121 (float)ts.counts[i] /
12122 (float)ts.counts[BGP_STATS_PREFIXES]
12123 : 0);
12124 break;
12125 case BGP_STATS_SPACE:
12126 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12127 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
12128 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
12129 break;
Paul Jakma30a22312008-08-15 14:05:22 +010012130 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000012131 vty_out (vty, "%12.2f%s",
12132 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000012133 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000012134 VTY_NEWLINE);
12135 vty_out (vty, "%30s: ", "/8 equivalent ");
12136 vty_out (vty, "%12.2f%s",
12137 (float)ts.counts[BGP_STATS_SPACE] /
12138 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
12139 VTY_NEWLINE);
12140 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
12141 break;
12142 vty_out (vty, "%30s: ", "/24 equivalent ");
12143 vty_out (vty, "%12.2f",
12144 (float)ts.counts[BGP_STATS_SPACE] /
12145 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
12146 break;
12147 default:
12148 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12149 vty_out (vty, "%12llu", ts.counts[i]);
12150 }
12151
12152 vty_out (vty, "%s", VTY_NEWLINE);
12153 }
12154 return CMD_SUCCESS;
12155}
12156
12157static int
12158bgp_table_stats_vty (struct vty *vty, const char *name,
12159 const char *afi_str, const char *safi_str)
12160{
12161 struct bgp *bgp;
12162 afi_t afi;
12163 safi_t safi;
12164
12165 if (name)
12166 bgp = bgp_lookup_by_name (name);
12167 else
12168 bgp = bgp_get_default ();
12169
12170 if (!bgp)
12171 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050012172 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000012173 return CMD_WARNING;
12174 }
12175 if (strncmp (afi_str, "ipv", 3) == 0)
12176 {
12177 if (strncmp (afi_str, "ipv4", 4) == 0)
12178 afi = AFI_IP;
12179 else if (strncmp (afi_str, "ipv6", 4) == 0)
12180 afi = AFI_IP6;
12181 else
12182 {
12183 vty_out (vty, "%% Invalid address family %s%s",
12184 afi_str, VTY_NEWLINE);
12185 return CMD_WARNING;
12186 }
Lou Berger298cc2f2016-01-12 13:42:02 -050012187 switch (safi_str[0]) {
12188 case 'm':
12189 safi = SAFI_MULTICAST;
12190 break;
12191 case 'u':
12192 safi = SAFI_UNICAST;
12193 break;
12194 case 'v':
Donald Sharp3c964042016-01-25 23:38:53 -050012195 safi = SAFI_MPLS_VPN;
Lou Berger298cc2f2016-01-12 13:42:02 -050012196 break;
12197 case 'e':
12198 safi = SAFI_ENCAP;
12199 break;
12200 default:
12201 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000012202 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050012203 return CMD_WARNING;
12204 }
Paul Jakma2815e612006-09-14 02:56:07 +000012205 }
12206 else
12207 {
Lou Berger298cc2f2016-01-12 13:42:02 -050012208 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000012209 afi_str, VTY_NEWLINE);
12210 return CMD_WARNING;
12211 }
12212
Paul Jakma2815e612006-09-14 02:56:07 +000012213 return bgp_table_stats (vty, bgp, afi, safi);
12214}
12215
12216DEFUN (show_bgp_statistics,
12217 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050012218 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012219 SHOW_STR
12220 BGP_STR
12221 "Address family\n"
12222 "Address family\n"
12223 "Address Family modifier\n"
12224 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050012225 "Address Family modifier\n"
12226 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000012227 "BGP RIB advertisement statistics\n")
12228{
12229 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
12230}
12231
Lou Bergerf9b6c392016-01-12 13:42:09 -050012232ALIAS (show_bgp_statistics,
12233 show_bgp_statistics_vpnv4_cmd,
12234 "show bgp (ipv4) (vpnv4) statistics",
12235 SHOW_STR
12236 BGP_STR
12237 "Address family\n"
12238 "Address Family modifier\n"
12239 "BGP RIB advertisement statistics\n")
12240
Paul Jakma2815e612006-09-14 02:56:07 +000012241DEFUN (show_bgp_statistics_view,
12242 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050012243 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012244 SHOW_STR
12245 BGP_STR
12246 "BGP view\n"
12247 "Address family\n"
12248 "Address family\n"
12249 "Address Family modifier\n"
12250 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050012251 "Address Family modifier\n"
12252 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000012253 "BGP RIB advertisement statistics\n")
12254{
12255 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
12256}
12257
12258ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050012259 show_bgp_statistics_view_vpnv4_cmd,
12260 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012261 SHOW_STR
12262 BGP_STR
12263 "BGP view\n"
12264 "Address family\n"
12265 "Address Family modifier\n"
12266 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020012267
Paul Jakmaff7924f2006-09-04 01:10:36 +000012268enum bgp_pcounts
12269{
12270 PCOUNT_ADJ_IN = 0,
12271 PCOUNT_DAMPED,
12272 PCOUNT_REMOVED,
12273 PCOUNT_HISTORY,
12274 PCOUNT_STALE,
12275 PCOUNT_VALID,
12276 PCOUNT_ALL,
12277 PCOUNT_COUNTED,
12278 PCOUNT_PFCNT, /* the figure we display to users */
12279 PCOUNT_MAX,
12280};
12281
12282static const char *pcount_strs[] =
12283{
12284 [PCOUNT_ADJ_IN] = "Adj-in",
12285 [PCOUNT_DAMPED] = "Damped",
12286 [PCOUNT_REMOVED] = "Removed",
12287 [PCOUNT_HISTORY] = "History",
12288 [PCOUNT_STALE] = "Stale",
12289 [PCOUNT_VALID] = "Valid",
12290 [PCOUNT_ALL] = "All RIB",
12291 [PCOUNT_COUNTED] = "PfxCt counted",
12292 [PCOUNT_PFCNT] = "Useable",
12293 [PCOUNT_MAX] = NULL,
12294};
12295
Paul Jakma2815e612006-09-14 02:56:07 +000012296struct peer_pcounts
12297{
12298 unsigned int count[PCOUNT_MAX];
12299 const struct peer *peer;
12300 const struct bgp_table *table;
12301};
12302
Paul Jakmaff7924f2006-09-04 01:10:36 +000012303static int
Paul Jakma2815e612006-09-14 02:56:07 +000012304bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000012305{
12306 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000012307 struct peer_pcounts *pc = THREAD_ARG (t);
12308 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012309
Paul Jakma2815e612006-09-14 02:56:07 +000012310 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012311 {
12312 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000012313 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012314
12315 for (ain = rn->adj_in; ain; ain = ain->next)
12316 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000012317 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012318
Paul Jakmaff7924f2006-09-04 01:10:36 +000012319 for (ri = rn->info; ri; ri = ri->next)
12320 {
12321 char buf[SU_ADDRSTRLEN];
12322
12323 if (ri->peer != peer)
12324 continue;
12325
Paul Jakma2815e612006-09-14 02:56:07 +000012326 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012327
12328 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000012329 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012330 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000012331 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012332 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000012333 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012334 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000012335 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012336 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000012337 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012338 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000012339 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012340
12341 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
12342 {
Paul Jakma2815e612006-09-14 02:56:07 +000012343 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012344 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012345 plog_warn (peer->log,
12346 "%s [pcount] %s/%d is counted but flags 0x%x",
12347 peer->host,
12348 inet_ntop(rn->p.family, &rn->p.u.prefix,
12349 buf, SU_ADDRSTRLEN),
12350 rn->p.prefixlen,
12351 ri->flags);
12352 }
12353 else
12354 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012355 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012356 plog_warn (peer->log,
12357 "%s [pcount] %s/%d not counted but flags 0x%x",
12358 peer->host,
12359 inet_ntop(rn->p.family, &rn->p.u.prefix,
12360 buf, SU_ADDRSTRLEN),
12361 rn->p.prefixlen,
12362 ri->flags);
12363 }
12364 }
12365 }
Paul Jakma2815e612006-09-14 02:56:07 +000012366 return 0;
12367}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012368
Paul Jakma2815e612006-09-14 02:56:07 +000012369static int
12370bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12371{
12372 struct peer_pcounts pcounts = { .peer = peer };
12373 unsigned int i;
12374
12375 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12376 || !peer->bgp->rib[afi][safi])
12377 {
12378 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12379 return CMD_WARNING;
12380 }
12381
12382 memset (&pcounts, 0, sizeof(pcounts));
12383 pcounts.peer = peer;
12384 pcounts.table = peer->bgp->rib[afi][safi];
12385
12386 /* in-place call via thread subsystem so as to record execution time
12387 * stats for the thread-walk (i.e. ensure this can't be blamed on
12388 * on just vty_read()).
12389 */
12390 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12391
Paul Jakmaff7924f2006-09-04 01:10:36 +000012392 vty_out (vty, "Prefix counts for %s, %s%s",
12393 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12394 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12395 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12396 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12397
12398 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012399 vty_out (vty, "%20s: %-10d%s",
12400 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012401
Paul Jakma2815e612006-09-14 02:56:07 +000012402 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012403 {
12404 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12405 peer->host, VTY_NEWLINE);
12406 vty_out (vty, "Please report this bug, with the above command output%s",
12407 VTY_NEWLINE);
12408 }
12409
12410 return CMD_SUCCESS;
12411}
12412
Lou Bergerf9b6c392016-01-12 13:42:09 -050012413DEFUN (show_ip_bgp_neighbor_prefix_counts,
12414 show_ip_bgp_neighbor_prefix_counts_cmd,
12415 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12416 SHOW_STR
12417 IP_STR
12418 BGP_STR
12419 "Detailed information on TCP and BGP neighbor connections\n"
12420 "Neighbor to display information about\n"
12421 "Neighbor to display information about\n"
12422 "Display detailed prefix count information\n")
12423{
12424 struct peer *peer;
12425
12426 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12427 if (! peer)
12428 return CMD_WARNING;
12429
12430 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12431}
12432
Paul Jakmaff7924f2006-09-04 01:10:36 +000012433DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12434 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12435 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12436 SHOW_STR
12437 BGP_STR
12438 "Address family\n"
12439 "Detailed information on TCP and BGP neighbor connections\n"
12440 "Neighbor to display information about\n"
12441 "Neighbor to display information about\n"
12442 "Display detailed prefix count information\n")
12443{
12444 struct peer *peer;
12445
12446 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12447 if (! peer)
12448 return CMD_WARNING;
12449
12450 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12451}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012452
12453DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12454 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12455 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12456 SHOW_STR
12457 IP_STR
12458 BGP_STR
12459 "Address family\n"
12460 "Address Family modifier\n"
12461 "Address Family modifier\n"
12462 "Detailed information on TCP and BGP neighbor connections\n"
12463 "Neighbor to display information about\n"
12464 "Neighbor to display information about\n"
12465 "Display detailed prefix count information\n")
12466{
12467 struct peer *peer;
12468
12469 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12470 if (! peer)
12471 return CMD_WARNING;
12472
12473 if (strncmp (argv[0], "m", 1) == 0)
12474 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12475
12476 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12477}
12478
12479DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12480 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12481 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12482 SHOW_STR
12483 IP_STR
12484 BGP_STR
12485 "Address family\n"
12486 "Address Family modifier\n"
12487 "Address Family modifier\n"
12488 "Detailed information on TCP and BGP neighbor connections\n"
12489 "Neighbor to display information about\n"
12490 "Neighbor to display information about\n"
12491 "Display detailed prefix count information\n")
12492{
12493 struct peer *peer;
12494
12495 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12496 if (! peer)
12497 return CMD_WARNING;
12498
12499 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12500}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012501
Lou Berger651b4022016-01-12 13:42:07 -050012502DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12503 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12504 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012505 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012506 BGP_STR
12507 "Address family\n"
12508 "Address Family modifier\n"
12509 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012510 "Address Family modifier\n"
12511 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012512 "Detailed information on TCP and BGP neighbor connections\n"
12513 "Neighbor to display information about\n"
12514 "Neighbor to display information about\n"
12515 "Display detailed prefix count information\n")
12516{
12517 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012518 safi_t safi;
12519
12520 if (bgp_parse_safi(argv[0], &safi)) {
12521 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12522 return CMD_WARNING;
12523 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012524
12525 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12526 if (! peer)
12527 return CMD_WARNING;
12528
Lou Berger651b4022016-01-12 13:42:07 -050012529 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012530}
Lou Berger205e6742016-01-12 13:42:11 -050012531
Lou Berger651b4022016-01-12 13:42:07 -050012532DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12533 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12534 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12535 SHOW_STR
12536 BGP_STR
12537 "Address family\n"
12538 "Address Family modifier\n"
12539 "Address Family modifier\n"
12540 "Address Family modifier\n"
12541 "Address Family modifier\n"
12542 "Detailed information on TCP and BGP neighbor connections\n"
12543 "Neighbor to display information about\n"
12544 "Neighbor to display information about\n"
12545 "Display detailed prefix count information\n")
12546{
12547 struct peer *peer;
12548 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012549
Lou Berger651b4022016-01-12 13:42:07 -050012550 if (bgp_parse_safi(argv[0], &safi)) {
12551 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12552 return CMD_WARNING;
12553 }
12554
12555 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12556 if (! peer)
12557 return CMD_WARNING;
12558
12559 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12560}
Lou Berger651b4022016-01-12 13:42:07 -050012561
12562DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12563 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12564 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012565 SHOW_STR
12566 IP_STR
12567 BGP_STR
12568 "Address family\n"
12569 "Address Family modifier\n"
12570 "Address Family modifier\n"
12571 "Detailed information on TCP and BGP neighbor connections\n"
12572 "Neighbor to display information about\n"
12573 "Neighbor to display information about\n"
12574 "Display detailed prefix count information\n")
12575{
12576 struct peer *peer;
12577
12578 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12579 if (! peer)
12580 return CMD_WARNING;
12581
Lou Berger651b4022016-01-12 13:42:07 -050012582 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012583}
12584
12585
paul94f2b392005-06-28 12:44:16 +000012586static void
paul718e3742002-12-13 20:15:29 +000012587show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12588 int in)
12589{
12590 struct bgp_table *table;
12591 struct bgp_adj_in *ain;
12592 struct bgp_adj_out *adj;
12593 unsigned long output_count;
12594 struct bgp_node *rn;
12595 int header1 = 1;
12596 struct bgp *bgp;
12597 int header2 = 1;
12598
paulbb46e942003-10-24 19:02:03 +000012599 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012600
12601 if (! bgp)
12602 return;
12603
12604 table = bgp->rib[afi][safi];
12605
12606 output_count = 0;
12607
12608 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12609 PEER_STATUS_DEFAULT_ORIGINATE))
12610 {
12611 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 +000012612 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12613 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012614
12615 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12616 VTY_NEWLINE, VTY_NEWLINE);
12617 header1 = 0;
12618 }
12619
12620 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12621 if (in)
12622 {
12623 for (ain = rn->adj_in; ain; ain = ain->next)
12624 if (ain->peer == peer)
12625 {
12626 if (header1)
12627 {
12628 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 +000012629 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12630 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012631 header1 = 0;
12632 }
12633 if (header2)
12634 {
12635 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12636 header2 = 0;
12637 }
12638 if (ain->attr)
12639 {
12640 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12641 output_count++;
12642 }
12643 }
12644 }
12645 else
12646 {
12647 for (adj = rn->adj_out; adj; adj = adj->next)
12648 if (adj->peer == peer)
12649 {
12650 if (header1)
12651 {
12652 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 +000012653 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12654 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012655 header1 = 0;
12656 }
12657 if (header2)
12658 {
12659 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12660 header2 = 0;
12661 }
12662 if (adj->attr)
12663 {
12664 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12665 output_count++;
12666 }
12667 }
12668 }
12669
12670 if (output_count != 0)
12671 vty_out (vty, "%sTotal number of prefixes %ld%s",
12672 VTY_NEWLINE, output_count, VTY_NEWLINE);
12673}
12674
paul94f2b392005-06-28 12:44:16 +000012675static int
paulbb46e942003-10-24 19:02:03 +000012676peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12677{
paul718e3742002-12-13 20:15:29 +000012678 if (! peer || ! peer->afc[afi][safi])
12679 {
12680 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12681 return CMD_WARNING;
12682 }
12683
12684 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12685 {
12686 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12687 VTY_NEWLINE);
12688 return CMD_WARNING;
12689 }
12690
12691 show_adj_route (vty, peer, afi, safi, in);
12692
12693 return CMD_SUCCESS;
12694}
12695
Lou Bergerf9b6c392016-01-12 13:42:09 -050012696DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12697 show_ip_bgp_view_neighbor_advertised_route_cmd,
12698 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12699 SHOW_STR
12700 IP_STR
12701 BGP_STR
12702 "BGP view\n"
12703 "View name\n"
12704 "Detailed information on TCP and BGP neighbor connections\n"
12705 "Neighbor to display information about\n"
12706 "Neighbor to display information about\n"
12707 "Display the routes advertised to a BGP neighbor\n")
12708{
12709 struct peer *peer;
12710
12711 if (argc == 2)
12712 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12713 else
12714 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12715
12716 if (! peer)
12717 return CMD_WARNING;
12718
12719 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12720}
12721
12722ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12723 show_ip_bgp_neighbor_advertised_route_cmd,
12724 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12725 SHOW_STR
12726 IP_STR
12727 BGP_STR
12728 "Detailed information on TCP and BGP neighbor connections\n"
12729 "Neighbor to display information about\n"
12730 "Neighbor to display information about\n"
12731 "Display the routes advertised to a BGP neighbor\n")
12732
12733DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12734 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12735 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12736 SHOW_STR
12737 IP_STR
12738 BGP_STR
12739 "Address family\n"
12740 "Address Family modifier\n"
12741 "Address Family modifier\n"
12742 "Detailed information on TCP and BGP neighbor connections\n"
12743 "Neighbor to display information about\n"
12744 "Neighbor to display information about\n"
12745 "Display the routes advertised to a BGP neighbor\n")
12746{
12747 struct peer *peer;
12748
12749 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12750 if (! peer)
12751 return CMD_WARNING;
12752
12753 if (strncmp (argv[0], "m", 1) == 0)
12754 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12755
12756 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12757}
12758
Lou Bergerf9b6c392016-01-12 13:42:09 -050012759DEFUN (show_bgp_view_neighbor_advertised_route,
12760 show_bgp_view_neighbor_advertised_route_cmd,
12761 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12762 SHOW_STR
12763 BGP_STR
12764 "BGP view\n"
12765 "View name\n"
12766 "Detailed information on TCP and BGP neighbor connections\n"
12767 "Neighbor to display information about\n"
12768 "Neighbor to display information about\n"
12769 "Display the routes advertised to a BGP neighbor\n")
12770{
12771 struct peer *peer;
12772
12773 if (argc == 2)
12774 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12775 else
12776 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12777
12778 if (! peer)
12779 return CMD_WARNING;
12780
12781 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12782}
12783
12784DEFUN (show_bgp_view_neighbor_received_routes,
12785 show_bgp_view_neighbor_received_routes_cmd,
12786 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12787 SHOW_STR
12788 BGP_STR
12789 "BGP view\n"
12790 "View name\n"
12791 "Detailed information on TCP and BGP neighbor connections\n"
12792 "Neighbor to display information about\n"
12793 "Neighbor to display information about\n"
12794 "Display the received routes from neighbor\n")
12795{
12796 struct peer *peer;
12797
12798 if (argc == 2)
12799 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12800 else
12801 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12802
12803 if (! peer)
12804 return CMD_WARNING;
12805
12806 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12807}
12808
12809ALIAS (show_bgp_view_neighbor_advertised_route,
12810 show_bgp_neighbor_advertised_route_cmd,
12811 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12812 SHOW_STR
12813 BGP_STR
12814 "Detailed information on TCP and BGP neighbor connections\n"
12815 "Neighbor to display information about\n"
12816 "Neighbor to display information about\n"
12817 "Display the routes advertised to a BGP neighbor\n")
12818
12819ALIAS (show_bgp_view_neighbor_advertised_route,
12820 show_bgp_ipv6_neighbor_advertised_route_cmd,
12821 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12822 SHOW_STR
12823 BGP_STR
12824 "Address family\n"
12825 "Detailed information on TCP and BGP neighbor connections\n"
12826 "Neighbor to display information about\n"
12827 "Neighbor to display information about\n"
12828 "Display the routes advertised to a BGP neighbor\n")
12829
12830/* old command */
12831ALIAS (show_bgp_view_neighbor_advertised_route,
12832 ipv6_bgp_neighbor_advertised_route_cmd,
12833 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12834 SHOW_STR
12835 IPV6_STR
12836 BGP_STR
12837 "Detailed information on TCP and BGP neighbor connections\n"
12838 "Neighbor to display information about\n"
12839 "Neighbor to display information about\n"
12840 "Display the routes advertised to a BGP neighbor\n")
12841
12842/* old command */
12843DEFUN (ipv6_mbgp_neighbor_advertised_route,
12844 ipv6_mbgp_neighbor_advertised_route_cmd,
12845 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12846 SHOW_STR
12847 IPV6_STR
12848 MBGP_STR
12849 "Detailed information on TCP and BGP neighbor connections\n"
12850 "Neighbor to display information about\n"
12851 "Neighbor to display information about\n"
12852 "Display the routes advertised to a BGP neighbor\n")
12853{
12854 struct peer *peer;
12855
12856 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12857 if (! peer)
12858 return CMD_WARNING;
12859
12860 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12861}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012862
12863DEFUN (show_ip_bgp_view_neighbor_received_routes,
12864 show_ip_bgp_view_neighbor_received_routes_cmd,
12865 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12866 SHOW_STR
12867 IP_STR
12868 BGP_STR
12869 "BGP view\n"
12870 "View name\n"
12871 "Detailed information on TCP and BGP neighbor connections\n"
12872 "Neighbor to display information about\n"
12873 "Neighbor to display information about\n"
12874 "Display the received routes from neighbor\n")
12875{
12876 struct peer *peer;
12877
12878 if (argc == 2)
12879 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12880 else
12881 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12882
12883 if (! peer)
12884 return CMD_WARNING;
12885
12886 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12887}
12888
12889ALIAS (show_ip_bgp_view_neighbor_received_routes,
12890 show_ip_bgp_neighbor_received_routes_cmd,
12891 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12892 SHOW_STR
12893 IP_STR
12894 BGP_STR
12895 "Detailed information on TCP and BGP neighbor connections\n"
12896 "Neighbor to display information about\n"
12897 "Neighbor to display information about\n"
12898 "Display the received routes from neighbor\n")
12899
12900ALIAS (show_bgp_view_neighbor_received_routes,
12901 show_bgp_ipv6_neighbor_received_routes_cmd,
12902 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12903 SHOW_STR
12904 BGP_STR
12905 "Address family\n"
12906 "Detailed information on TCP and BGP neighbor connections\n"
12907 "Neighbor to display information about\n"
12908 "Neighbor to display information about\n"
12909 "Display the received routes from neighbor\n")
12910
12911DEFUN (show_bgp_neighbor_received_prefix_filter,
12912 show_bgp_neighbor_received_prefix_filter_cmd,
12913 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12914 SHOW_STR
12915 BGP_STR
12916 "Detailed information on TCP and BGP neighbor connections\n"
12917 "Neighbor to display information about\n"
12918 "Neighbor to display information about\n"
12919 "Display information received from a BGP neighbor\n"
12920 "Display the prefixlist filter\n")
12921{
12922 char name[BUFSIZ];
12923 union sockunion su;
12924 struct peer *peer;
12925 int count, ret;
12926
12927 ret = str2sockunion (argv[0], &su);
12928 if (ret < 0)
12929 {
12930 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12931 return CMD_WARNING;
12932 }
12933
12934 peer = peer_lookup (NULL, &su);
12935 if (! peer)
12936 return CMD_WARNING;
12937
12938 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12939 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12940 if (count)
12941 {
12942 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12943 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12944 }
12945
12946 return CMD_SUCCESS;
12947}
12948
12949/* old command */
12950ALIAS (show_bgp_view_neighbor_received_routes,
12951 ipv6_bgp_neighbor_received_routes_cmd,
12952 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12953 SHOW_STR
12954 IPV6_STR
12955 BGP_STR
12956 "Detailed information on TCP and BGP neighbor connections\n"
12957 "Neighbor to display information about\n"
12958 "Neighbor to display information about\n"
12959 "Display the received routes from neighbor\n")
12960
12961/* old command */
12962DEFUN (ipv6_mbgp_neighbor_received_routes,
12963 ipv6_mbgp_neighbor_received_routes_cmd,
12964 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12965 SHOW_STR
12966 IPV6_STR
12967 MBGP_STR
12968 "Detailed information on TCP and BGP neighbor connections\n"
12969 "Neighbor to display information about\n"
12970 "Neighbor to display information about\n"
12971 "Display the received routes from neighbor\n")
12972{
12973 struct peer *peer;
12974
12975 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12976 if (! peer)
12977 return CMD_WARNING;
12978
12979 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12980}
12981
12982DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12983 show_bgp_view_neighbor_received_prefix_filter_cmd,
12984 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12985 SHOW_STR
12986 BGP_STR
12987 "BGP view\n"
12988 "View name\n"
12989 "Detailed information on TCP and BGP neighbor connections\n"
12990 "Neighbor to display information about\n"
12991 "Neighbor to display information about\n"
12992 "Display information received from a BGP neighbor\n"
12993 "Display the prefixlist filter\n")
12994{
12995 char name[BUFSIZ];
12996 union sockunion su;
12997 struct peer *peer;
12998 struct bgp *bgp;
12999 int count, ret;
13000
13001 /* BGP structure lookup. */
13002 bgp = bgp_lookup_by_name (argv[0]);
13003 if (bgp == NULL)
13004 {
13005 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13006 return CMD_WARNING;
13007 }
13008
13009 ret = str2sockunion (argv[1], &su);
13010 if (ret < 0)
13011 {
13012 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13013 return CMD_WARNING;
13014 }
13015
13016 peer = peer_lookup (bgp, &su);
13017 if (! peer)
13018 return CMD_WARNING;
13019
13020 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13021 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13022 if (count)
13023 {
13024 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13025 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13026 }
13027
13028 return CMD_SUCCESS;
13029}
13030
13031
13032DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
13033 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
13034 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
13035 SHOW_STR
13036 IP_STR
13037 BGP_STR
13038 "Address family\n"
13039 "Address Family modifier\n"
13040 "Address Family modifier\n"
13041 "Detailed information on TCP and BGP neighbor connections\n"
13042 "Neighbor to display information about\n"
13043 "Neighbor to display information about\n"
13044 "Display the received routes from neighbor\n")
13045{
13046 struct peer *peer;
13047
13048 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13049 if (! peer)
13050 return CMD_WARNING;
13051
13052 if (strncmp (argv[0], "m", 1) == 0)
13053 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
13054
13055 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
13056}
13057
Lou Berger651b4022016-01-12 13:42:07 -050013058DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
13059 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
13060 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013061 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013062 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013063 "Address Family modifier\n"
13064 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013065 "Detailed information on TCP and BGP neighbor connections\n"
13066 "Neighbor to display information about\n"
13067 "Neighbor to display information about\n"
13068 "Display the routes advertised to a BGP neighbor\n")
13069{
13070 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013071 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013072
Lou Berger651b4022016-01-12 13:42:07 -050013073 if (bgp_parse_safi(argv[0], &safi)) {
13074 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013075 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013076 }
paul718e3742002-12-13 20:15:29 +000013077
paulbb46e942003-10-24 19:02:03 +000013078 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13079 if (! peer)
13080 return CMD_WARNING;
13081
Lou Berger651b4022016-01-12 13:42:07 -050013082 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
13083}
Lou Berger205e6742016-01-12 13:42:11 -050013084
Lou Berger651b4022016-01-12 13:42:07 -050013085DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
13086 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
13087 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13088 SHOW_STR
13089 BGP_STR
13090 "Address Family modifier\n"
13091 "Address Family modifier\n"
13092 "Address Family modifier\n"
13093 "Detailed information on TCP and BGP neighbor connections\n"
13094 "Neighbor to display information about\n"
13095 "Neighbor to display information about\n"
13096 "Display the routes advertised to a BGP neighbor\n")
13097{
13098 struct peer *peer;
13099 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013100
Lou Berger651b4022016-01-12 13:42:07 -050013101 if (bgp_parse_safi(argv[0], &safi)) {
13102 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13103 return CMD_WARNING;
13104 }
13105
13106 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13107 if (! peer)
13108 return CMD_WARNING;
13109
13110 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000013111}
13112
Lou Bergerf9b6c392016-01-12 13:42:09 -050013113DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050013114 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
13115 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000013116 SHOW_STR
13117 BGP_STR
13118 "BGP view\n"
13119 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013120 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013121 "Detailed information on TCP and BGP neighbor connections\n"
13122 "Neighbor to display information about\n"
13123 "Neighbor to display information about\n"
13124 "Display the routes advertised to a BGP neighbor\n")
13125{
13126 struct peer *peer;
13127
13128 if (argc == 2)
13129 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13130 else
13131 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13132
13133 if (! peer)
13134 return CMD_WARNING;
13135
13136 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
13137}
13138
Lou Bergerf9b6c392016-01-12 13:42:09 -050013139DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013140 show_bgp_view_ipv6_neighbor_received_routes_cmd,
13141 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000013142 SHOW_STR
13143 BGP_STR
13144 "BGP view\n"
13145 "View name\n"
13146 "Address family\n"
13147 "Detailed information on TCP and BGP neighbor connections\n"
13148 "Neighbor to display information about\n"
13149 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000013150 "Display the received routes from neighbor\n")
13151{
13152 struct peer *peer;
13153
13154 if (argc == 2)
13155 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13156 else
13157 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13158
13159 if (! peer)
13160 return CMD_WARNING;
13161
13162 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
13163}
Lou Berger651b4022016-01-12 13:42:07 -050013164
13165DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
13166 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
13167 "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 +010013168 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013169 BGP_STR
13170 "Address family\n"
13171 "Address Family modifier\n"
13172 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050013173 "Address Family modifier\n"
13174 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013175 "Detailed information on TCP and BGP neighbor connections\n"
13176 "Neighbor to display information about\n"
13177 "Neighbor to display information about\n"
13178 "Display the received routes from neighbor\n")
13179{
paulbb46e942003-10-24 19:02:03 +000013180 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013181 safi_t safi;
13182
13183 if (bgp_parse_safi(argv[0], &safi)) {
13184 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13185 return CMD_WARNING;
13186 }
paul718e3742002-12-13 20:15:29 +000013187
paulbb46e942003-10-24 19:02:03 +000013188 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13189 if (! peer)
13190 return CMD_WARNING;
13191
Lou Berger651b4022016-01-12 13:42:07 -050013192 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000013193}
Lou Berger205e6742016-01-12 13:42:11 -050013194
Lou Berger651b4022016-01-12 13:42:07 -050013195DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
13196 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
13197 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
13198 SHOW_STR
13199 BGP_STR
13200 "Address family\n"
13201 "Address Family modifier\n"
13202 "Address Family modifier\n"
13203 "Address Family modifier\n"
13204 "Address Family modifier\n"
13205 "Detailed information on TCP and BGP neighbor connections\n"
13206 "Neighbor to display information about\n"
13207 "Neighbor to display information about\n"
13208 "Display the received routes from neighbor\n")
13209{
13210 struct peer *peer;
13211 safi_t safi;
13212
13213 if (bgp_parse_safi(argv[0], &safi)) {
13214 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13215 return CMD_WARNING;
13216 }
13217
13218 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13219 if (! peer)
13220 return CMD_WARNING;
13221
13222 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
13223}
paul718e3742002-12-13 20:15:29 +000013224
Michael Lambert95cbbd22010-07-23 14:43:04 -040013225DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
13226 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040013227 "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 -040013228 SHOW_STR
13229 BGP_STR
13230 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013231 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013232 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013233 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013234 "Address family modifier\n"
13235 "Address family modifier\n"
13236 "Detailed information on TCP and BGP neighbor connections\n"
13237 "Neighbor to display information about\n"
13238 "Neighbor to display information about\n"
13239 "Display the advertised routes to neighbor\n"
13240 "Display the received routes from neighbor\n")
13241{
13242 int afi;
13243 int safi;
13244 int in;
13245 struct peer *peer;
13246
David Lamparter94bad672015-03-03 08:52:22 +010013247 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040013248
13249 if (! peer)
13250 return CMD_WARNING;
13251
Michael Lambert95cbbd22010-07-23 14:43:04 -040013252 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
13253 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13254 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040013255
13256 return peer_adj_routes (vty, peer, afi, safi, in);
13257}
13258
Lou Bergerf9b6c392016-01-12 13:42:09 -050013259DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
13260 show_ip_bgp_neighbor_received_prefix_filter_cmd,
13261 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13262 SHOW_STR
13263 IP_STR
13264 BGP_STR
13265 "Detailed information on TCP and BGP neighbor connections\n"
13266 "Neighbor to display information about\n"
13267 "Neighbor to display information about\n"
13268 "Display information received from a BGP neighbor\n"
13269 "Display the prefixlist filter\n")
13270{
13271 char name[BUFSIZ];
13272 union sockunion su;
13273 struct peer *peer;
13274 int count, ret;
13275
13276 ret = str2sockunion (argv[0], &su);
13277 if (ret < 0)
13278 {
13279 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13280 return CMD_WARNING;
13281 }
13282
13283 peer = peer_lookup (NULL, &su);
13284 if (! peer)
13285 return CMD_WARNING;
13286
13287 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13288 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13289 if (count)
13290 {
13291 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13292 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13293 }
13294
13295 return CMD_SUCCESS;
13296}
13297
13298DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
13299 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
13300 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13301 SHOW_STR
13302 IP_STR
13303 BGP_STR
13304 "Address family\n"
13305 "Address Family modifier\n"
13306 "Address Family modifier\n"
13307 "Detailed information on TCP and BGP neighbor connections\n"
13308 "Neighbor to display information about\n"
13309 "Neighbor to display information about\n"
13310 "Display information received from a BGP neighbor\n"
13311 "Display the prefixlist filter\n")
13312{
13313 char name[BUFSIZ];
13314 union sockunion su;
13315 struct peer *peer;
13316 int count, ret;
13317
13318 ret = str2sockunion (argv[1], &su);
13319 if (ret < 0)
13320 {
13321 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13322 return CMD_WARNING;
13323 }
13324
13325 peer = peer_lookup (NULL, &su);
13326 if (! peer)
13327 return CMD_WARNING;
13328
13329 if (strncmp (argv[0], "m", 1) == 0)
13330 {
13331 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
13332 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13333 if (count)
13334 {
13335 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
13336 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13337 }
13338 }
13339 else
13340 {
13341 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13342 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13343 if (count)
13344 {
13345 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13346 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13347 }
13348 }
13349
13350 return CMD_SUCCESS;
13351}
13352
13353ALIAS (show_bgp_view_neighbor_received_routes,
13354 show_bgp_neighbor_received_routes_cmd,
13355 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13356 SHOW_STR
13357 BGP_STR
13358 "Detailed information on TCP and BGP neighbor connections\n"
13359 "Neighbor to display information about\n"
13360 "Neighbor to display information about\n"
13361 "Display the received routes from neighbor\n")
13362
Lou Berger651b4022016-01-12 13:42:07 -050013363DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13364 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13365 "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 +000013366 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013367 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013368 IP_STR
13369 "Address Family modifier\n"
13370 "Address Family modifier\n"
13371 "Address Family modifier\n"
13372 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013373 "Detailed information on TCP and BGP neighbor connections\n"
13374 "Neighbor to display information about\n"
13375 "Neighbor to display information about\n"
13376 "Display information received from a BGP neighbor\n"
13377 "Display the prefixlist filter\n")
13378{
13379 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013380 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013381 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013382 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013383 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013384
Lou Berger651b4022016-01-12 13:42:07 -050013385 if (bgp_parse_safi(argv[0], &safi)) {
13386 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013387 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013388 }
paul718e3742002-12-13 20:15:29 +000013389
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013390 ret = str2sockunion (argv[1], &su);
13391 if (ret < 0)
13392 {
13393 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13394 return CMD_WARNING;
13395 }
paul718e3742002-12-13 20:15:29 +000013396
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013397 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013398 if (! peer)
13399 return CMD_WARNING;
13400
Lou Berger651b4022016-01-12 13:42:07 -050013401 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13402 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13403 if (count) {
13404 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13405 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13406 }
paul718e3742002-12-13 20:15:29 +000013407
13408 return CMD_SUCCESS;
13409}
Lou Berger205e6742016-01-12 13:42:11 -050013410
Lou Berger651b4022016-01-12 13:42:07 -050013411DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13412 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13413 "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 +000013414 SHOW_STR
13415 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013416 IP_STR
13417 "Address Family modifier\n"
13418 "Address Family modifier\n"
13419 "Address Family modifier\n"
13420 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013421 "Detailed information on TCP and BGP neighbor connections\n"
13422 "Neighbor to display information about\n"
13423 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013424 "Display information received from a BGP neighbor\n"
13425 "Display the prefixlist filter\n")
13426{
13427 char name[BUFSIZ];
13428 union sockunion su;
13429 struct peer *peer;
13430 int count, ret;
13431 safi_t safi;
13432
13433 if (bgp_parse_safi(argv[0], &safi)) {
13434 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13435 return CMD_WARNING;
13436 }
13437
13438 ret = str2sockunion (argv[1], &su);
13439 if (ret < 0)
13440 {
13441 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13442 return CMD_WARNING;
13443 }
13444
13445 peer = peer_lookup (NULL, &su);
13446 if (! peer)
13447 return CMD_WARNING;
13448
13449 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13450 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13451 if (count) {
13452 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13453 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13454 }
13455
13456 return CMD_SUCCESS;
13457}
paul718e3742002-12-13 20:15:29 +000013458
Lou Bergerf9b6c392016-01-12 13:42:09 -050013459DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013460 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13461 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013462 SHOW_STR
13463 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013464 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013465 "Detailed information on TCP and BGP neighbor connections\n"
13466 "Neighbor to display information about\n"
13467 "Neighbor to display information about\n"
13468 "Display information received from a BGP neighbor\n"
13469 "Display the prefixlist filter\n")
13470{
13471 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013472 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013473 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013474 int count, ret;
paul718e3742002-12-13 20:15:29 +000013475
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013476 ret = str2sockunion (argv[0], &su);
13477 if (ret < 0)
13478 {
13479 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13480 return CMD_WARNING;
13481 }
paul718e3742002-12-13 20:15:29 +000013482
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013483 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013484 if (! peer)
13485 return CMD_WARNING;
13486
13487 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13488 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13489 if (count)
13490 {
13491 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13492 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13493 }
13494
13495 return CMD_SUCCESS;
13496}
13497
Lou Bergerf9b6c392016-01-12 13:42:09 -050013498DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013499 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13500 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013501 SHOW_STR
13502 BGP_STR
13503 "BGP view\n"
13504 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013505 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013506 "Detailed information on TCP and BGP neighbor connections\n"
13507 "Neighbor to display information about\n"
13508 "Neighbor to display information about\n"
13509 "Display information received from a BGP neighbor\n"
13510 "Display the prefixlist filter\n")
13511{
13512 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013513 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013514 struct peer *peer;
13515 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013516 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013517
13518 /* BGP structure lookup. */
13519 bgp = bgp_lookup_by_name (argv[0]);
13520 if (bgp == NULL)
13521 {
13522 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13523 return CMD_WARNING;
13524 }
13525
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013526 ret = str2sockunion (argv[1], &su);
13527 if (ret < 0)
13528 {
13529 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13530 return CMD_WARNING;
13531 }
paulbb46e942003-10-24 19:02:03 +000013532
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013533 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013534 if (! peer)
13535 return CMD_WARNING;
13536
13537 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13538 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13539 if (count)
13540 {
13541 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13542 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13543 }
13544
13545 return CMD_SUCCESS;
13546}
David Lamparter6b0655a2014-06-04 06:53:35 +020013547
paul94f2b392005-06-28 12:44:16 +000013548static int
paulbb46e942003-10-24 19:02:03 +000013549bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013550 safi_t safi, enum bgp_show_type type)
13551{
paul718e3742002-12-13 20:15:29 +000013552 if (! peer || ! peer->afc[afi][safi])
13553 {
13554 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013555 return CMD_WARNING;
13556 }
13557
ajs5a646652004-11-05 01:25:55 +000013558 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013559}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013560DEFUN (show_ip_bgp_neighbor_routes,
13561 show_ip_bgp_neighbor_routes_cmd,
13562 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13563 SHOW_STR
13564 IP_STR
13565 BGP_STR
13566 "Detailed information on TCP and BGP neighbor connections\n"
13567 "Neighbor to display information about\n"
13568 "Neighbor to display information about\n"
13569 "Display routes learned from neighbor\n")
13570{
13571 struct peer *peer;
13572
13573 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13574 if (! peer)
13575 return CMD_WARNING;
13576
13577 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13578 bgp_show_type_neighbor);
13579}
13580
13581DEFUN (show_ip_bgp_neighbor_flap,
13582 show_ip_bgp_neighbor_flap_cmd,
13583 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13584 SHOW_STR
13585 IP_STR
13586 BGP_STR
13587 "Detailed information on TCP and BGP neighbor connections\n"
13588 "Neighbor to display information about\n"
13589 "Neighbor to display information about\n"
13590 "Display flap statistics of the routes learned from neighbor\n")
13591{
13592 struct peer *peer;
13593
13594 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13595 if (! peer)
13596 return CMD_WARNING;
13597
13598 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13599 bgp_show_type_flap_neighbor);
13600}
13601
13602DEFUN (show_ip_bgp_neighbor_damp,
13603 show_ip_bgp_neighbor_damp_cmd,
13604 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13605 SHOW_STR
13606 IP_STR
13607 BGP_STR
13608 "Detailed information on TCP and BGP neighbor connections\n"
13609 "Neighbor to display information about\n"
13610 "Neighbor to display information about\n"
13611 "Display the dampened routes received from neighbor\n")
13612{
13613 struct peer *peer;
13614
13615 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13616 if (! peer)
13617 return CMD_WARNING;
13618
13619 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13620 bgp_show_type_damp_neighbor);
13621}
13622
13623DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13624 show_ip_bgp_ipv4_neighbor_routes_cmd,
13625 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13626 SHOW_STR
13627 IP_STR
13628 BGP_STR
13629 "Address family\n"
13630 "Address Family modifier\n"
13631 "Address Family modifier\n"
13632 "Detailed information on TCP and BGP neighbor connections\n"
13633 "Neighbor to display information about\n"
13634 "Neighbor to display information about\n"
13635 "Display routes learned from neighbor\n")
13636{
13637 struct peer *peer;
13638
13639 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13640 if (! peer)
13641 return CMD_WARNING;
13642
13643 if (strncmp (argv[0], "m", 1) == 0)
13644 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13645 bgp_show_type_neighbor);
13646
13647 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13648 bgp_show_type_neighbor);
13649}
13650
13651DEFUN (show_ip_bgp_view_rsclient,
13652 show_ip_bgp_view_rsclient_cmd,
13653 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13654 SHOW_STR
13655 IP_STR
13656 BGP_STR
13657 "BGP view\n"
13658 "View name\n"
13659 "Information about Route Server Client\n"
13660 NEIGHBOR_ADDR_STR)
13661{
13662 struct bgp_table *table;
13663 struct peer *peer;
13664
13665 if (argc == 2)
13666 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13667 else
13668 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13669
13670 if (! peer)
13671 return CMD_WARNING;
13672
13673 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13674 {
13675 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13676 VTY_NEWLINE);
13677 return CMD_WARNING;
13678 }
13679
13680 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13681 PEER_FLAG_RSERVER_CLIENT))
13682 {
13683 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13684 VTY_NEWLINE);
13685 return CMD_WARNING;
13686 }
13687
13688 table = peer->rib[AFI_IP][SAFI_UNICAST];
13689
13690 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13691}
13692
13693ALIAS (show_ip_bgp_view_rsclient,
13694 show_ip_bgp_rsclient_cmd,
13695 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13696 SHOW_STR
13697 IP_STR
13698 BGP_STR
13699 "Information about Route Server Client\n"
13700 NEIGHBOR_ADDR_STR)
13701
13702DEFUN (show_bgp_view_ipv4_safi_rsclient,
13703 show_bgp_view_ipv4_safi_rsclient_cmd,
13704 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13705 SHOW_STR
13706 BGP_STR
13707 "BGP view\n"
13708 "View name\n"
13709 "Address family\n"
13710 "Address Family modifier\n"
13711 "Address Family modifier\n"
13712 "Information about Route Server Client\n"
13713 NEIGHBOR_ADDR_STR)
13714{
13715 struct bgp_table *table;
13716 struct peer *peer;
13717 safi_t safi;
13718
13719 if (argc == 3) {
13720 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13721 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13722 } else {
13723 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13724 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13725 }
13726
13727 if (! peer)
13728 return CMD_WARNING;
13729
13730 if (! peer->afc[AFI_IP][safi])
13731 {
13732 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13733 VTY_NEWLINE);
13734 return CMD_WARNING;
13735 }
13736
13737 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13738 PEER_FLAG_RSERVER_CLIENT))
13739 {
13740 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13741 VTY_NEWLINE);
13742 return CMD_WARNING;
13743 }
13744
13745 table = peer->rib[AFI_IP][safi];
13746
13747 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13748}
13749
13750ALIAS (show_bgp_view_ipv4_safi_rsclient,
13751 show_bgp_ipv4_safi_rsclient_cmd,
13752 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13753 SHOW_STR
13754 BGP_STR
13755 "Address family\n"
13756 "Address Family modifier\n"
13757 "Address Family modifier\n"
13758 "Information about Route Server Client\n"
13759 NEIGHBOR_ADDR_STR)
13760
13761DEFUN (show_ip_bgp_view_rsclient_route,
13762 show_ip_bgp_view_rsclient_route_cmd,
13763 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13764 SHOW_STR
13765 IP_STR
13766 BGP_STR
13767 "BGP view\n"
13768 "View name\n"
13769 "Information about Route Server Client\n"
13770 NEIGHBOR_ADDR_STR
13771 "Network in the BGP routing table to display\n")
13772{
13773 struct bgp *bgp;
13774 struct peer *peer;
13775
13776 /* BGP structure lookup. */
13777 if (argc == 3)
13778 {
13779 bgp = bgp_lookup_by_name (argv[0]);
13780 if (bgp == NULL)
13781 {
13782 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13783 return CMD_WARNING;
13784 }
13785 }
13786 else
13787 {
13788 bgp = bgp_get_default ();
13789 if (bgp == NULL)
13790 {
13791 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13792 return CMD_WARNING;
13793 }
13794 }
13795
13796 if (argc == 3)
13797 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13798 else
13799 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13800
13801 if (! peer)
13802 return CMD_WARNING;
13803
13804 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13805 {
13806 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13807 VTY_NEWLINE);
13808 return CMD_WARNING;
13809}
13810
13811 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13812 PEER_FLAG_RSERVER_CLIENT))
13813 {
13814 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13815 VTY_NEWLINE);
13816 return CMD_WARNING;
13817 }
13818
13819 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13820 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070013821 AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050013822}
13823
13824ALIAS (show_ip_bgp_view_rsclient_route,
13825 show_ip_bgp_rsclient_route_cmd,
13826 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13827 SHOW_STR
13828 IP_STR
13829 BGP_STR
13830 "Information about Route Server Client\n"
13831 NEIGHBOR_ADDR_STR
13832 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013833
Lou Berger651b4022016-01-12 13:42:07 -050013834DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13835 show_bgp_ipv4_safi_neighbor_flap_cmd,
13836 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013837 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013838 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013839 "Address Family Modifier\n"
13840 "Address Family Modifier\n"
13841 "Address Family Modifier\n"
13842 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013843 "Detailed information on TCP and BGP neighbor connections\n"
13844 "Neighbor to display information about\n"
13845 "Neighbor to display information about\n"
13846 "Display flap statistics of the routes learned from neighbor\n")
13847{
paulbb46e942003-10-24 19:02:03 +000013848 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013849 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013850
Lou Berger651b4022016-01-12 13:42:07 -050013851 if (bgp_parse_safi(argv[0], &safi)) {
13852 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13853 return CMD_WARNING;
13854 }
13855
13856 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013857 if (! peer)
13858 return CMD_WARNING;
13859
Lou Berger651b4022016-01-12 13:42:07 -050013860 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013861 bgp_show_type_flap_neighbor);
13862}
Lou Berger205e6742016-01-12 13:42:11 -050013863
Lou Berger651b4022016-01-12 13:42:07 -050013864DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13865 show_bgp_ipv6_safi_neighbor_flap_cmd,
13866 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013867 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013868 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013869 "Address Family Modifier\n"
13870 "Address Family Modifier\n"
13871 "Address Family Modifier\n"
13872 "Address Family Modifier\n"
13873 "Detailed information on TCP and BGP neighbor connections\n"
13874 "Neighbor to display information about\n"
13875 "Neighbor to display information about\n"
13876 "Display flap statistics of the routes learned from neighbor\n")
13877{
13878 struct peer *peer;
13879 safi_t safi;
13880
13881 if (bgp_parse_safi(argv[0], &safi)) {
13882 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13883 return CMD_WARNING;
13884 }
13885
13886 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13887 if (! peer)
13888 return CMD_WARNING;
13889
13890 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13891 bgp_show_type_flap_neighbor);
13892}
Lou Berger651b4022016-01-12 13:42:07 -050013893
13894DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13895 show_bgp_ipv4_safi_neighbor_damp_cmd,
13896 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13897 SHOW_STR
13898 BGP_STR
13899 "Address Family Modifier\n"
13900 "Address Family Modifier\n"
13901 "Address Family Modifier\n"
13902 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013903 "Detailed information on TCP and BGP neighbor connections\n"
13904 "Neighbor to display information about\n"
13905 "Neighbor to display information about\n"
13906 "Display the dampened routes received from neighbor\n")
13907{
paulbb46e942003-10-24 19:02:03 +000013908 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013909 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013910
Lou Berger651b4022016-01-12 13:42:07 -050013911 if (bgp_parse_safi(argv[0], &safi)) {
13912 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13913 return CMD_WARNING;
13914 }
13915
13916 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013917 if (! peer)
13918 return CMD_WARNING;
13919
Lou Berger651b4022016-01-12 13:42:07 -050013920 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013921 bgp_show_type_damp_neighbor);
13922}
Lou Berger205e6742016-01-12 13:42:11 -050013923
Lou Berger651b4022016-01-12 13:42:07 -050013924DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13925 show_bgp_ipv6_safi_neighbor_damp_cmd,
13926 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013927 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013928 BGP_STR
13929 "Address Family Modifier\n"
13930 "Address Family Modifier\n"
13931 "Address Family Modifier\n"
13932 "Address Family Modifier\n"
13933 "Detailed information on TCP and BGP neighbor connections\n"
13934 "Neighbor to display information about\n"
13935 "Neighbor to display information about\n"
13936 "Display the dampened routes received from neighbor\n")
13937{
13938 struct peer *peer;
13939 safi_t safi;
13940
13941 if (bgp_parse_safi(argv[0], &safi)) {
13942 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13943 return CMD_WARNING;
13944 }
13945
13946 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13947 if (! peer)
13948 return CMD_WARNING;
13949
13950 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13951 bgp_show_type_damp_neighbor);
13952}
Lou Berger651b4022016-01-12 13:42:07 -050013953
13954DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13955 show_bgp_ipv4_safi_neighbor_routes_cmd,
13956 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13957 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013958 BGP_STR
13959 "Address family\n"
13960 "Address Family modifier\n"
13961 "Address Family modifier\n"
13962 "Detailed information on TCP and BGP neighbor connections\n"
13963 "Neighbor to display information about\n"
13964 "Neighbor to display information about\n"
13965 "Display routes learned from neighbor\n")
13966{
paulbb46e942003-10-24 19:02:03 +000013967 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013968 safi_t safi;
13969
13970 if (bgp_parse_safi(argv[0], &safi)) {
13971 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13972 return CMD_WARNING;
13973 }
paulbb46e942003-10-24 19:02:03 +000013974
13975 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13976 if (! peer)
13977 return CMD_WARNING;
13978
Lou Berger651b4022016-01-12 13:42:07 -050013979 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013980 bgp_show_type_neighbor);
13981}
Lou Berger205e6742016-01-12 13:42:11 -050013982
Lou Berger651b4022016-01-12 13:42:07 -050013983DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13984 show_bgp_ipv6_safi_neighbor_routes_cmd,
13985 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013986 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013987 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013988 "Address family\n"
13989 "Address Family modifier\n"
13990 "Address Family modifier\n"
13991 "Detailed information on TCP and BGP neighbor connections\n"
13992 NEIGHBOR_ADDR_STR
13993 NEIGHBOR_ADDR_STR
13994 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000013995{
paulfee0f4c2004-09-13 05:12:46 +000013996 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013997 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000013998
Lou Berger651b4022016-01-12 13:42:07 -050013999 if (bgp_parse_safi(argv[0], &safi)) {
14000 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14001 return CMD_WARNING;
14002 }
paulfee0f4c2004-09-13 05:12:46 +000014003
Lou Berger651b4022016-01-12 13:42:07 -050014004 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000014005 if (! peer)
14006 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050014007
14008 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14009 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000014010}
paulfee0f4c2004-09-13 05:12:46 +000014011
Michael Lambert95cbbd22010-07-23 14:43:04 -040014012DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
14013 show_bgp_view_ipv4_safi_rsclient_route_cmd,
14014 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14015 SHOW_STR
14016 BGP_STR
14017 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014018 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014019 "Address family\n"
14020 "Address Family modifier\n"
14021 "Address Family modifier\n"
14022 "Information about Route Server Client\n"
14023 NEIGHBOR_ADDR_STR
14024 "Network in the BGP routing table to display\n")
14025{
14026 struct bgp *bgp;
14027 struct peer *peer;
14028 safi_t safi;
14029
14030 /* BGP structure lookup. */
14031 if (argc == 4)
14032 {
14033 bgp = bgp_lookup_by_name (argv[0]);
14034 if (bgp == NULL)
14035 {
14036 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14037 return CMD_WARNING;
14038 }
14039 }
14040 else
14041 {
14042 bgp = bgp_get_default ();
14043 if (bgp == NULL)
14044 {
14045 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14046 return CMD_WARNING;
14047 }
14048 }
14049
14050 if (argc == 4) {
14051 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14052 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14053 } else {
14054 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14055 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14056 }
14057
14058 if (! peer)
14059 return CMD_WARNING;
14060
14061 if (! peer->afc[AFI_IP][safi])
14062 {
14063 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14064 VTY_NEWLINE);
14065 return CMD_WARNING;
14066}
14067
14068 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14069 PEER_FLAG_RSERVER_CLIENT))
14070 {
14071 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14072 VTY_NEWLINE);
14073 return CMD_WARNING;
14074 }
14075
14076 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
14077 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014078 AFI_IP, safi, NULL, 0, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014079}
14080
14081ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
14082 show_bgp_ipv4_safi_rsclient_route_cmd,
14083 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14084 SHOW_STR
14085 BGP_STR
14086 "Address family\n"
14087 "Address Family modifier\n"
14088 "Address Family modifier\n"
14089 "Information about Route Server Client\n"
14090 NEIGHBOR_ADDR_STR
14091 "Network in the BGP routing table to display\n")
14092
paulfee0f4c2004-09-13 05:12:46 +000014093
Michael Lambert95cbbd22010-07-23 14:43:04 -040014094DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
14095 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
14096 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14097 SHOW_STR
14098 BGP_STR
14099 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014100 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014101 "Address family\n"
14102 "Address Family modifier\n"
14103 "Address Family modifier\n"
14104 "Information about Route Server Client\n"
14105 NEIGHBOR_ADDR_STR
14106 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14107{
14108 struct bgp *bgp;
14109 struct peer *peer;
14110 safi_t safi;
14111
14112 /* BGP structure lookup. */
14113 if (argc == 4)
14114 {
14115 bgp = bgp_lookup_by_name (argv[0]);
14116 if (bgp == NULL)
14117 {
14118 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14119 return CMD_WARNING;
14120 }
14121 }
14122 else
14123 {
14124 bgp = bgp_get_default ();
14125 if (bgp == NULL)
14126 {
14127 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14128 return CMD_WARNING;
14129 }
14130 }
14131
14132 if (argc == 4) {
14133 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14134 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14135 } else {
14136 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14137 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14138 }
14139
14140 if (! peer)
14141 return CMD_WARNING;
14142
14143 if (! peer->afc[AFI_IP][safi])
14144 {
14145 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14146 VTY_NEWLINE);
14147 return CMD_WARNING;
14148}
14149
14150 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14151 PEER_FLAG_RSERVER_CLIENT))
14152{
14153 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14154 VTY_NEWLINE);
14155 return CMD_WARNING;
14156 }
14157
14158 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
14159 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014160 AFI_IP, safi, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014161}
14162
Lou Bergerf9b6c392016-01-12 13:42:09 -050014163DEFUN (show_ip_bgp_view_rsclient_prefix,
14164 show_ip_bgp_view_rsclient_prefix_cmd,
14165 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14166 SHOW_STR
14167 IP_STR
14168 BGP_STR
14169 "BGP view\n"
14170 "View name\n"
14171 "Information about Route Server Client\n"
14172 NEIGHBOR_ADDR_STR
14173 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14174{
14175 struct bgp *bgp;
14176 struct peer *peer;
14177
14178 /* BGP structure lookup. */
14179 if (argc == 3)
14180 {
14181 bgp = bgp_lookup_by_name (argv[0]);
14182 if (bgp == NULL)
14183 {
14184 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14185 return CMD_WARNING;
14186 }
14187 }
14188 else
14189 {
14190 bgp = bgp_get_default ();
14191 if (bgp == NULL)
14192 {
14193 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14194 return CMD_WARNING;
14195 }
14196 }
14197
14198 if (argc == 3)
14199 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14200 else
14201 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14202
14203 if (! peer)
14204 return CMD_WARNING;
14205
14206 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14207 {
14208 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14209 VTY_NEWLINE);
14210 return CMD_WARNING;
14211}
14212
14213 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14214 PEER_FLAG_RSERVER_CLIENT))
14215{
14216 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14217 VTY_NEWLINE);
14218 return CMD_WARNING;
14219 }
14220
14221 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
14222 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014223 AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050014224}
14225
14226ALIAS (show_ip_bgp_view_rsclient_prefix,
14227 show_ip_bgp_rsclient_prefix_cmd,
14228 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14229 SHOW_STR
14230 IP_STR
14231 BGP_STR
14232 "Information about Route Server Client\n"
14233 NEIGHBOR_ADDR_STR
14234 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14235
Michael Lambert95cbbd22010-07-23 14:43:04 -040014236ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
14237 show_bgp_ipv4_safi_rsclient_prefix_cmd,
14238 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14239 SHOW_STR
14240 BGP_STR
14241 "Address family\n"
14242 "Address Family modifier\n"
14243 "Address Family modifier\n"
14244 "Information about Route Server Client\n"
14245 NEIGHBOR_ADDR_STR
14246 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000014247
Lou Bergerf9b6c392016-01-12 13:42:09 -050014248DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050014249 show_bgp_view_ipv6_neighbor_routes_cmd,
14250 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000014251 SHOW_STR
14252 BGP_STR
14253 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014254 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014255 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000014256 "Detailed information on TCP and BGP neighbor connections\n"
14257 "Neighbor to display information about\n"
14258 "Neighbor to display information about\n"
14259 "Display routes learned from neighbor\n")
14260{
14261 struct peer *peer;
14262
14263 if (argc == 2)
14264 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14265 else
14266 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14267
14268 if (! peer)
14269 return CMD_WARNING;
14270
14271 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14272 bgp_show_type_neighbor);
14273}
14274
Lou Berger651b4022016-01-12 13:42:07 -050014275DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014276 show_bgp_view_neighbor_damp_cmd,
14277 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14278 SHOW_STR
14279 BGP_STR
14280 "BGP view\n"
14281 "View name\n"
14282 "Detailed information on TCP and BGP neighbor connections\n"
14283 "Neighbor to display information about\n"
14284 "Neighbor to display information about\n"
14285 "Display the dampened routes received from neighbor\n")
14286{
14287 struct peer *peer;
14288
14289 if (argc == 2)
14290 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14291 else
14292 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14293
14294 if (! peer)
14295 return CMD_WARNING;
14296
14297 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14298 bgp_show_type_damp_neighbor);
14299}
14300
14301DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050014302 show_bgp_view_ipv6_neighbor_damp_cmd,
14303 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000014304 SHOW_STR
14305 BGP_STR
14306 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014307 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014308 "Address family\n"
14309 "Detailed information on TCP and BGP neighbor connections\n"
14310 "Neighbor to display information about\n"
14311 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000014312 "Display the dampened routes received from neighbor\n")
14313{
14314 struct peer *peer;
14315
14316 if (argc == 2)
14317 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14318 else
14319 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14320
14321 if (! peer)
14322 return CMD_WARNING;
14323
14324 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14325 bgp_show_type_damp_neighbor);
14326}
14327
Lou Bergerf9b6c392016-01-12 13:42:09 -050014328DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050014329 show_bgp_view_ipv6_neighbor_flap_cmd,
14330 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000014331 SHOW_STR
14332 BGP_STR
14333 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014334 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014335 "Address family\n"
14336 "Detailed information on TCP and BGP neighbor connections\n"
14337 "Neighbor to display information about\n"
14338 "Neighbor to display information about\n"
14339 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000014340{
14341 struct peer *peer;
14342
14343 if (argc == 2)
14344 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14345 else
14346 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14347
14348 if (! peer)
14349 return CMD_WARNING;
14350
14351 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14352 bgp_show_type_flap_neighbor);
14353}
14354
Lou Bergerf9b6c392016-01-12 13:42:09 -050014355DEFUN (show_bgp_view_neighbor_flap,
14356 show_bgp_view_neighbor_flap_cmd,
14357 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14358 SHOW_STR
14359 BGP_STR
14360 "BGP view\n"
14361 "View name\n"
14362 "Detailed information on TCP and BGP neighbor connections\n"
14363 "Neighbor to display information about\n"
14364 "Neighbor to display information about\n"
14365 "Display flap statistics of the routes learned from neighbor\n")
14366{
14367 struct peer *peer;
14368
14369 if (argc == 2)
14370 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14371 else
14372 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14373
14374 if (! peer)
14375 return CMD_WARNING;
14376
14377 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14378 bgp_show_type_flap_neighbor);
14379}
14380
14381ALIAS (show_bgp_view_neighbor_flap,
14382 show_bgp_neighbor_flap_cmd,
14383 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14384 SHOW_STR
14385 BGP_STR
14386 "Detailed information on TCP and BGP neighbor connections\n"
14387 "Neighbor to display information about\n"
14388 "Neighbor to display information about\n"
14389 "Display flap statistics of the routes learned from neighbor\n")
14390
14391ALIAS (show_bgp_view_neighbor_damp,
14392 show_bgp_neighbor_damp_cmd,
14393 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14394 SHOW_STR
14395 BGP_STR
14396 "Detailed information on TCP and BGP neighbor connections\n"
14397 "Neighbor to display information about\n"
14398 "Neighbor to display information about\n"
14399 "Display the dampened routes received from neighbor\n")
14400
14401DEFUN (show_bgp_view_neighbor_routes,
14402 show_bgp_view_neighbor_routes_cmd,
14403 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
14404 SHOW_STR
14405 BGP_STR
14406 "BGP view\n"
14407 "View name\n"
14408 "Detailed information on TCP and BGP neighbor connections\n"
14409 "Neighbor to display information about\n"
14410 "Neighbor to display information about\n"
14411 "Display routes learned from neighbor\n")
14412{
14413 struct peer *peer;
14414
14415 if (argc == 2)
14416 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14417 else
14418 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14419
14420 if (! peer)
14421 return CMD_WARNING;
14422
14423 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14424 bgp_show_type_neighbor);
14425}
14426
14427ALIAS (show_bgp_view_neighbor_routes,
14428 show_bgp_neighbor_routes_cmd,
14429 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
14430 SHOW_STR
14431 BGP_STR
14432 "Detailed information on TCP and BGP neighbor connections\n"
14433 "Neighbor to display information about\n"
14434 "Neighbor to display information about\n"
14435 "Display routes learned from neighbor\n")
14436
paulbb46e942003-10-24 19:02:03 +000014437ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014438 show_bgp_ipv6_neighbor_routes_cmd,
14439 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14440 SHOW_STR
14441 BGP_STR
14442 "Address family\n"
14443 "Detailed information on TCP and BGP neighbor connections\n"
14444 "Neighbor to display information about\n"
14445 "Neighbor to display information about\n"
14446 "Display routes learned from neighbor\n")
14447
Lou Bergerf9b6c392016-01-12 13:42:09 -050014448/* old command */
14449ALIAS (show_bgp_view_neighbor_routes,
14450 ipv6_bgp_neighbor_routes_cmd,
14451 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14452 SHOW_STR
14453 IPV6_STR
14454 BGP_STR
14455 "Detailed information on TCP and BGP neighbor connections\n"
14456 "Neighbor to display information about\n"
14457 "Neighbor to display information about\n"
14458 "Display routes learned from neighbor\n")
14459
14460/* old command */
14461DEFUN (ipv6_mbgp_neighbor_routes,
14462 ipv6_mbgp_neighbor_routes_cmd,
14463 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14464 SHOW_STR
14465 IPV6_STR
14466 MBGP_STR
14467 "Detailed information on TCP and BGP neighbor connections\n"
14468 "Neighbor to display information about\n"
14469 "Neighbor to display information about\n"
14470 "Display routes learned from neighbor\n")
14471{
14472 struct peer *peer;
14473
14474 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14475 if (! peer)
14476 return CMD_WARNING;
14477
14478 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14479 bgp_show_type_neighbor);
14480}
14481
paulbb46e942003-10-24 19:02:03 +000014482ALIAS (show_bgp_view_neighbor_flap,
14483 show_bgp_ipv6_neighbor_flap_cmd,
14484 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14485 SHOW_STR
14486 BGP_STR
14487 "Address family\n"
14488 "Detailed information on TCP and BGP neighbor connections\n"
14489 "Neighbor to display information about\n"
14490 "Neighbor to display information about\n"
14491 "Display flap statistics of the routes learned from neighbor\n")
14492
14493ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014494 show_bgp_ipv6_neighbor_damp_cmd,
14495 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14496 SHOW_STR
14497 BGP_STR
14498 "Address family\n"
14499 "Detailed information on TCP and BGP neighbor connections\n"
14500 "Neighbor to display information about\n"
14501 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014502 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014503
Lou Bergerf9b6c392016-01-12 13:42:09 -050014504DEFUN (show_bgp_view_rsclient,
14505 show_bgp_view_rsclient_cmd,
14506 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14507 SHOW_STR
14508 BGP_STR
14509 "BGP view\n"
14510 "View name\n"
14511 "Information about Route Server Client\n"
14512 NEIGHBOR_ADDR_STR)
14513{
14514 struct bgp_table *table;
14515 struct peer *peer;
14516
14517 if (argc == 2)
14518 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14519 else
14520 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14521
14522 if (! peer)
14523 return CMD_WARNING;
14524
14525 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14526 {
14527 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14528 VTY_NEWLINE);
14529 return CMD_WARNING;
14530 }
14531
14532 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14533 PEER_FLAG_RSERVER_CLIENT))
14534 {
14535 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14536 VTY_NEWLINE);
14537 return CMD_WARNING;
14538 }
14539
14540 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14541
14542 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14543}
14544
14545ALIAS (show_bgp_view_rsclient,
14546 show_bgp_rsclient_cmd,
14547 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14548 SHOW_STR
14549 BGP_STR
14550 "Information about Route Server Client\n"
14551 NEIGHBOR_ADDR_STR)
14552
Lou Berger651b4022016-01-12 13:42:07 -050014553DEFUN (show_bgp_view_ipv4_rsclient,
14554 show_bgp_view_ipv4_rsclient_cmd,
14555 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014556 SHOW_STR
14557 BGP_STR
14558 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014559 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014560 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014561 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014562 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014563{
Lou Berger651b4022016-01-12 13:42:07 -050014564 struct bgp_table *table;
14565 struct peer *peer;
14566
14567 if (argc == 2)
14568 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14569 else
14570 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14571
14572 if (! peer)
14573 return CMD_WARNING;
14574
14575 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14576 {
14577 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14578 VTY_NEWLINE);
14579 return CMD_WARNING;
14580 }
14581
14582 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14583 PEER_FLAG_RSERVER_CLIENT))
14584 {
14585 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14586 VTY_NEWLINE);
14587 return CMD_WARNING;
14588 }
14589
14590 table = peer->rib[AFI_IP][SAFI_UNICAST];
14591
14592 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14593}
14594DEFUN (show_bgp_view_ipv6_rsclient,
14595 show_bgp_view_ipv6_rsclient_cmd,
14596 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14597 SHOW_STR
14598 BGP_STR
14599 "BGP view\n"
14600 "BGP view name\n"
14601 "Address Family\n"
14602 "Information about Route Server Client\n"
14603 NEIGHBOR_ADDR_STR2)
14604{
14605 struct bgp_table *table;
14606 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014607
14608 if (argc == 2)
14609 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14610 else
14611 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14612
14613 if (! peer)
14614 return CMD_WARNING;
14615
14616 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14617 {
14618 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14619 VTY_NEWLINE);
14620 return CMD_WARNING;
14621 }
14622
14623 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14624 PEER_FLAG_RSERVER_CLIENT))
14625 {
14626 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14627 VTY_NEWLINE);
14628 return CMD_WARNING;
14629 }
14630
14631 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14632
ajs5a646652004-11-05 01:25:55 +000014633 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014634}
14635
Lou Berger651b4022016-01-12 13:42:07 -050014636ALIAS (show_bgp_view_ipv4_rsclient,
14637 show_bgp_ipv4_rsclient_cmd,
14638 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014639 SHOW_STR
14640 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014641 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014642 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014643 NEIGHBOR_ADDR_STR2)
14644
Lou Berger651b4022016-01-12 13:42:07 -050014645ALIAS (show_bgp_view_ipv6_rsclient,
14646 show_bgp_ipv6_rsclient_cmd,
14647 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14648 SHOW_STR
14649 BGP_STR
14650 "Address Family\n"
14651 "Information about Route Server Client\n"
14652 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014653
Michael Lambert95cbbd22010-07-23 14:43:04 -040014654DEFUN (show_bgp_view_ipv6_safi_rsclient,
14655 show_bgp_view_ipv6_safi_rsclient_cmd,
14656 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14657 SHOW_STR
14658 BGP_STR
14659 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014660 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014661 "Address family\n"
14662 "Address Family modifier\n"
14663 "Address Family modifier\n"
14664 "Information about Route Server Client\n"
14665 NEIGHBOR_ADDR_STR)
14666{
14667 struct bgp_table *table;
14668 struct peer *peer;
14669 safi_t safi;
14670
14671 if (argc == 3) {
14672 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14673 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14674 } else {
14675 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14676 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14677 }
14678
14679 if (! peer)
14680 return CMD_WARNING;
14681
14682 if (! peer->afc[AFI_IP6][safi])
14683 {
14684 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14685 VTY_NEWLINE);
14686 return CMD_WARNING;
14687 }
14688
14689 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14690 PEER_FLAG_RSERVER_CLIENT))
14691 {
14692 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14693 VTY_NEWLINE);
14694 return CMD_WARNING;
14695 }
14696
14697 table = peer->rib[AFI_IP6][safi];
14698
14699 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14700}
14701
14702ALIAS (show_bgp_view_ipv6_safi_rsclient,
14703 show_bgp_ipv6_safi_rsclient_cmd,
14704 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14705 SHOW_STR
14706 BGP_STR
14707 "Address family\n"
14708 "Address Family modifier\n"
14709 "Address Family modifier\n"
14710 "Information about Route Server Client\n"
14711 NEIGHBOR_ADDR_STR)
14712
paulfee0f4c2004-09-13 05:12:46 +000014713DEFUN (show_bgp_view_rsclient_route,
14714 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014715 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14716 SHOW_STR
14717 BGP_STR
14718 "BGP view\n"
14719 "View name\n"
14720 "Information about Route Server Client\n"
14721 NEIGHBOR_ADDR_STR
14722 "Network in the BGP routing table to display\n")
14723{
14724 struct bgp *bgp;
14725 struct peer *peer;
14726
14727 /* BGP structure lookup. */
14728 if (argc == 3)
14729 {
14730 bgp = bgp_lookup_by_name (argv[0]);
14731 if (bgp == NULL)
14732 {
14733 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14734 return CMD_WARNING;
14735 }
14736 }
14737 else
14738 {
14739 bgp = bgp_get_default ();
14740 if (bgp == NULL)
14741 {
14742 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14743 return CMD_WARNING;
14744 }
14745 }
14746
14747 if (argc == 3)
14748 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14749 else
14750 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14751
14752 if (! peer)
14753 return CMD_WARNING;
14754
14755 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14756 {
14757 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14758 VTY_NEWLINE);
14759 return CMD_WARNING;
14760 }
14761
14762 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14763 PEER_FLAG_RSERVER_CLIENT))
14764 {
14765 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14766 VTY_NEWLINE);
14767 return CMD_WARNING;
14768 }
14769
14770 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14771 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014772 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050014773}
14774
14775DEFUN (show_bgp_view_ipv6_rsclient_route,
14776 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014777 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014778 SHOW_STR
14779 BGP_STR
14780 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014781 "BGP view name\n"
14782 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014783 "Information about Route Server Client\n"
14784 NEIGHBOR_ADDR_STR
14785 "Network in the BGP routing table to display\n")
14786{
14787 struct bgp *bgp;
14788 struct peer *peer;
14789
14790 /* BGP structure lookup. */
14791 if (argc == 3)
14792 {
14793 bgp = bgp_lookup_by_name (argv[0]);
14794 if (bgp == NULL)
14795 {
14796 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14797 return CMD_WARNING;
14798 }
14799 }
14800 else
14801 {
14802 bgp = bgp_get_default ();
14803 if (bgp == NULL)
14804 {
14805 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14806 return CMD_WARNING;
14807 }
14808 }
14809
14810 if (argc == 3)
14811 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14812 else
14813 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14814
14815 if (! peer)
14816 return CMD_WARNING;
14817
14818 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14819 {
14820 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14821 VTY_NEWLINE);
14822 return CMD_WARNING;
14823 }
14824
14825 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14826 PEER_FLAG_RSERVER_CLIENT))
14827 {
14828 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14829 VTY_NEWLINE);
14830 return CMD_WARNING;
14831 }
14832
14833 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14834 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014835 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paulfee0f4c2004-09-13 05:12:46 +000014836}
14837
Lou Bergerf9b6c392016-01-12 13:42:09 -050014838ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014839 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014840 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14841 SHOW_STR
14842 BGP_STR
14843 "Information about Route Server Client\n"
14844 NEIGHBOR_ADDR_STR
14845 "Network in the BGP routing table to display\n")
14846
14847ALIAS (show_bgp_view_ipv6_rsclient_route,
14848 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014849 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014850 SHOW_STR
14851 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014852 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014853 "Information about Route Server Client\n"
14854 NEIGHBOR_ADDR_STR
14855 "Network in the BGP routing table to display\n")
14856
Michael Lambert95cbbd22010-07-23 14:43:04 -040014857DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14858 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14859 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14860 SHOW_STR
14861 BGP_STR
14862 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014863 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014864 "Address family\n"
14865 "Address Family modifier\n"
14866 "Address Family modifier\n"
14867 "Information about Route Server Client\n"
14868 NEIGHBOR_ADDR_STR
14869 "Network in the BGP routing table to display\n")
14870{
14871 struct bgp *bgp;
14872 struct peer *peer;
14873 safi_t safi;
14874
14875 /* BGP structure lookup. */
14876 if (argc == 4)
14877 {
14878 bgp = bgp_lookup_by_name (argv[0]);
14879 if (bgp == NULL)
14880 {
14881 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14882 return CMD_WARNING;
14883 }
14884 }
14885 else
14886 {
14887 bgp = bgp_get_default ();
14888 if (bgp == NULL)
14889 {
14890 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14891 return CMD_WARNING;
14892 }
14893 }
14894
14895 if (argc == 4) {
14896 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14897 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14898 } else {
14899 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14900 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14901 }
14902
14903 if (! peer)
14904 return CMD_WARNING;
14905
14906 if (! peer->afc[AFI_IP6][safi])
14907 {
14908 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14909 VTY_NEWLINE);
14910 return CMD_WARNING;
14911}
14912
14913 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14914 PEER_FLAG_RSERVER_CLIENT))
14915 {
14916 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14917 VTY_NEWLINE);
14918 return CMD_WARNING;
14919 }
14920
14921 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14922 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014923 AFI_IP6, safi, NULL, 0, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014924}
14925
14926ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14927 show_bgp_ipv6_safi_rsclient_route_cmd,
14928 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14929 SHOW_STR
14930 BGP_STR
14931 "Address family\n"
14932 "Address Family modifier\n"
14933 "Address Family modifier\n"
14934 "Information about Route Server Client\n"
14935 NEIGHBOR_ADDR_STR
14936 "Network in the BGP routing table to display\n")
14937
Lou Berger651b4022016-01-12 13:42:07 -050014938
paulfee0f4c2004-09-13 05:12:46 +000014939DEFUN (show_bgp_view_rsclient_prefix,
14940 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014941 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14942 SHOW_STR
14943 BGP_STR
14944 "BGP view\n"
14945 "View name\n"
14946 "Information about Route Server Client\n"
14947 NEIGHBOR_ADDR_STR
14948 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14949{
14950 struct bgp *bgp;
14951 struct peer *peer;
14952
14953 /* BGP structure lookup. */
14954 if (argc == 3)
14955 {
14956 bgp = bgp_lookup_by_name (argv[0]);
14957 if (bgp == NULL)
14958 {
14959 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14960 return CMD_WARNING;
14961 }
14962 }
14963 else
14964 {
14965 bgp = bgp_get_default ();
14966 if (bgp == NULL)
14967 {
14968 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14969 return CMD_WARNING;
14970 }
14971 }
14972
14973 if (argc == 3)
14974 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14975 else
14976 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14977
14978 if (! peer)
14979 return CMD_WARNING;
14980
14981 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14982 {
14983 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14984 VTY_NEWLINE);
14985 return CMD_WARNING;
14986 }
14987
14988 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14989 PEER_FLAG_RSERVER_CLIENT))
14990 {
14991 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14992 VTY_NEWLINE);
14993 return CMD_WARNING;
14994 }
14995
14996 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14997 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014998 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050014999}
15000
15001DEFUN (show_bgp_view_ipv6_rsclient_prefix,
15002 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015003 "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 +000015004 SHOW_STR
15005 BGP_STR
15006 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015007 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050015008 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000015009 "Information about Route Server Client\n"
15010 NEIGHBOR_ADDR_STR
15011 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15012{
15013 struct bgp *bgp;
15014 struct peer *peer;
15015
15016 /* BGP structure lookup. */
15017 if (argc == 3)
15018 {
15019 bgp = bgp_lookup_by_name (argv[0]);
15020 if (bgp == NULL)
15021 {
15022 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15023 return CMD_WARNING;
15024 }
15025 }
15026 else
15027 {
15028 bgp = bgp_get_default ();
15029 if (bgp == NULL)
15030 {
15031 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15032 return CMD_WARNING;
15033 }
15034 }
15035
15036 if (argc == 3)
15037 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15038 else
15039 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15040
15041 if (! peer)
15042 return CMD_WARNING;
15043
15044 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15045 {
15046 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15047 VTY_NEWLINE);
15048 return CMD_WARNING;
15049 }
15050
15051 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15052 PEER_FLAG_RSERVER_CLIENT))
15053 {
15054 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15055 VTY_NEWLINE);
15056 return CMD_WARNING;
15057 }
15058
15059 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15060 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015061 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paulfee0f4c2004-09-13 05:12:46 +000015062}
15063
Lou Bergerf9b6c392016-01-12 13:42:09 -050015064ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000015065 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050015066 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15067 SHOW_STR
15068 BGP_STR
15069 "Information about Route Server Client\n"
15070 NEIGHBOR_ADDR_STR
15071 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15072
15073ALIAS (show_bgp_view_ipv6_rsclient_prefix,
15074 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015075 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000015076 SHOW_STR
15077 BGP_STR
15078 "Information about Route Server Client\n"
15079 NEIGHBOR_ADDR_STR
15080 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15081
Michael Lambert95cbbd22010-07-23 14:43:04 -040015082DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
15083 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
15084 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15085 SHOW_STR
15086 BGP_STR
15087 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015088 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040015089 "Address family\n"
15090 "Address Family modifier\n"
15091 "Address Family modifier\n"
15092 "Information about Route Server Client\n"
15093 NEIGHBOR_ADDR_STR
15094 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
15095{
15096 struct bgp *bgp;
15097 struct peer *peer;
15098 safi_t safi;
15099
15100 /* BGP structure lookup. */
15101 if (argc == 4)
15102 {
15103 bgp = bgp_lookup_by_name (argv[0]);
15104 if (bgp == NULL)
15105 {
15106 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15107 return CMD_WARNING;
15108 }
15109 }
15110 else
15111 {
15112 bgp = bgp_get_default ();
15113 if (bgp == NULL)
15114 {
15115 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15116 return CMD_WARNING;
15117 }
15118 }
15119
15120 if (argc == 4) {
15121 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15122 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15123 } else {
15124 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15125 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15126 }
15127
15128 if (! peer)
15129 return CMD_WARNING;
15130
15131 if (! peer->afc[AFI_IP6][safi])
15132 {
15133 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15134 VTY_NEWLINE);
15135 return CMD_WARNING;
15136}
15137
15138 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
15139 PEER_FLAG_RSERVER_CLIENT))
15140{
15141 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15142 VTY_NEWLINE);
15143 return CMD_WARNING;
15144 }
15145
15146 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
15147 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015148 AFI_IP6, safi, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015149}
15150
15151ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
15152 show_bgp_ipv6_safi_rsclient_prefix_cmd,
15153 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15154 SHOW_STR
15155 BGP_STR
15156 "Address family\n"
15157 "Address Family modifier\n"
15158 "Address Family modifier\n"
15159 "Information about Route Server Client\n"
15160 NEIGHBOR_ADDR_STR
15161 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
15162
paul718e3742002-12-13 20:15:29 +000015163struct bgp_table *bgp_distance_table;
15164
15165struct bgp_distance
15166{
15167 /* Distance value for the IP source prefix. */
15168 u_char distance;
15169
15170 /* Name of the access-list to be matched. */
15171 char *access_list;
15172};
15173
paul94f2b392005-06-28 12:44:16 +000015174static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015175bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000015176{
Stephen Hemminger393deb92008-08-18 14:13:29 -070015177 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000015178}
15179
paul94f2b392005-06-28 12:44:16 +000015180static void
paul718e3742002-12-13 20:15:29 +000015181bgp_distance_free (struct bgp_distance *bdistance)
15182{
15183 XFREE (MTYPE_BGP_DISTANCE, bdistance);
15184}
15185
paul94f2b392005-06-28 12:44:16 +000015186static int
paulfd79ac92004-10-13 05:06:08 +000015187bgp_distance_set (struct vty *vty, const char *distance_str,
15188 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000015189{
15190 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015191 struct prefix p;
paul718e3742002-12-13 20:15:29 +000015192 u_char distance;
15193 struct bgp_node *rn;
15194 struct bgp_distance *bdistance;
15195
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015196 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000015197 if (ret == 0)
15198 {
15199 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
15200 return CMD_WARNING;
15201 }
15202
15203 distance = atoi (distance_str);
15204
15205 /* Get BGP distance node. */
15206 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
15207 if (rn->info)
15208 {
15209 bdistance = rn->info;
15210 bgp_unlock_node (rn);
15211 }
15212 else
15213 {
15214 bdistance = bgp_distance_new ();
15215 rn->info = bdistance;
15216 }
15217
15218 /* Set distance value. */
15219 bdistance->distance = distance;
15220
15221 /* Reset access-list configuration. */
15222 if (bdistance->access_list)
15223 {
15224 free (bdistance->access_list);
15225 bdistance->access_list = NULL;
15226 }
15227 if (access_list_str)
15228 bdistance->access_list = strdup (access_list_str);
15229
15230 return CMD_SUCCESS;
15231}
15232
paul94f2b392005-06-28 12:44:16 +000015233static int
paulfd79ac92004-10-13 05:06:08 +000015234bgp_distance_unset (struct vty *vty, const char *distance_str,
15235 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000015236{
15237 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015238 struct prefix p;
paul718e3742002-12-13 20:15:29 +000015239 u_char distance;
15240 struct bgp_node *rn;
15241 struct bgp_distance *bdistance;
15242
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015243 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000015244 if (ret == 0)
15245 {
15246 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
15247 return CMD_WARNING;
15248 }
15249
15250 distance = atoi (distance_str);
15251
15252 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
15253 if (! rn)
15254 {
15255 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
15256 return CMD_WARNING;
15257 }
15258
15259 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010015260
15261 if (bdistance->distance != distance)
15262 {
15263 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
15264 return CMD_WARNING;
15265 }
15266
paul718e3742002-12-13 20:15:29 +000015267 if (bdistance->access_list)
15268 free (bdistance->access_list);
15269 bgp_distance_free (bdistance);
15270
15271 rn->info = NULL;
15272 bgp_unlock_node (rn);
15273 bgp_unlock_node (rn);
15274
15275 return CMD_SUCCESS;
15276}
15277
paul718e3742002-12-13 20:15:29 +000015278/* Apply BGP information to distance method. */
15279u_char
15280bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
15281{
15282 struct bgp_node *rn;
15283 struct prefix_ipv4 q;
15284 struct peer *peer;
15285 struct bgp_distance *bdistance;
15286 struct access_list *alist;
15287 struct bgp_static *bgp_static;
15288
15289 if (! bgp)
15290 return 0;
15291
15292 if (p->family != AF_INET)
15293 return 0;
15294
15295 peer = rinfo->peer;
15296
15297 if (peer->su.sa.sa_family != AF_INET)
15298 return 0;
15299
15300 memset (&q, 0, sizeof (struct prefix_ipv4));
15301 q.family = AF_INET;
15302 q.prefix = peer->su.sin.sin_addr;
15303 q.prefixlen = IPV4_MAX_BITLEN;
15304
15305 /* Check source address. */
15306 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15307 if (rn)
15308 {
15309 bdistance = rn->info;
15310 bgp_unlock_node (rn);
15311
15312 if (bdistance->access_list)
15313 {
15314 alist = access_list_lookup (AFI_IP, bdistance->access_list);
15315 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15316 return bdistance->distance;
15317 }
15318 else
15319 return bdistance->distance;
15320 }
15321
15322 /* Backdoor check. */
15323 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
15324 if (rn)
15325 {
15326 bgp_static = rn->info;
15327 bgp_unlock_node (rn);
15328
15329 if (bgp_static->backdoor)
15330 {
15331 if (bgp->distance_local)
15332 return bgp->distance_local;
15333 else
15334 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15335 }
15336 }
15337
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000015338 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000015339 {
15340 if (bgp->distance_ebgp)
15341 return bgp->distance_ebgp;
15342 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15343 }
15344 else
15345 {
15346 if (bgp->distance_ibgp)
15347 return bgp->distance_ibgp;
15348 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15349 }
15350}
15351
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015352#ifdef HAVE_IPV6
15353/* Apply BGP information to ipv6 distance method. */
15354u_char
15355ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
15356{
15357 struct bgp_node *rn;
15358 struct prefix_ipv6 q;
15359 struct peer *peer;
15360 struct bgp_distance *bdistance;
15361 struct access_list *alist;
15362 struct bgp_static *bgp_static;
15363
15364 if (! bgp)
15365 return 0;
15366
15367 if (p->family != AF_INET6)
15368 return 0;
15369
15370 peer = rinfo->peer;
15371
15372 if (peer->su.sa.sa_family != AF_INET6)
15373 return 0;
15374
15375 memset (&q, 0, sizeof (struct prefix_ipv6));
15376 q.family = AF_INET;
15377 q.prefix = peer->su.sin6.sin6_addr;
15378 q.prefixlen = IPV6_MAX_BITLEN;
15379
15380 /* Check source address. */
15381 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15382 if (rn)
15383 {
15384 bdistance = rn->info;
15385 bgp_unlock_node (rn);
15386
15387 if (bdistance->access_list)
15388 {
15389 alist = access_list_lookup (AFI_IP6, bdistance->access_list);
15390 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15391 return bdistance->distance;
15392 }
15393 else
15394 return bdistance->distance;
15395 }
15396 /* Backdoor check. */
15397 rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p);
15398 if (rn)
15399 {
15400 bgp_static = rn->info;
15401 bgp_unlock_node (rn);
15402
15403 if (bgp_static->backdoor)
15404 {
15405 if (bgp->ipv6_distance_local)
15406 return bgp->ipv6_distance_local;
15407 else
15408 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15409 }
15410 }
15411
15412 if (peer_sort (peer) == BGP_PEER_EBGP)
15413 {
15414 if (bgp->ipv6_distance_ebgp)
15415 return bgp->ipv6_distance_ebgp;
15416 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15417 }
15418 else
15419 {
15420 if (bgp->ipv6_distance_ibgp)
15421 return bgp->ipv6_distance_ibgp;
15422 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15423 }
15424}
15425#endif /* HAVE_IPV6 */
15426
paul718e3742002-12-13 20:15:29 +000015427DEFUN (bgp_distance,
15428 bgp_distance_cmd,
15429 "distance bgp <1-255> <1-255> <1-255>",
15430 "Define an administrative distance\n"
15431 "BGP distance\n"
15432 "Distance for routes external to the AS\n"
15433 "Distance for routes internal to the AS\n"
15434 "Distance for local routes\n")
15435{
15436 struct bgp *bgp;
15437
15438 bgp = vty->index;
15439
15440 bgp->distance_ebgp = atoi (argv[0]);
15441 bgp->distance_ibgp = atoi (argv[1]);
15442 bgp->distance_local = atoi (argv[2]);
15443 return CMD_SUCCESS;
15444}
15445
15446DEFUN (no_bgp_distance,
15447 no_bgp_distance_cmd,
15448 "no distance bgp <1-255> <1-255> <1-255>",
15449 NO_STR
15450 "Define an administrative distance\n"
15451 "BGP distance\n"
15452 "Distance for routes external to the AS\n"
15453 "Distance for routes internal to the AS\n"
15454 "Distance for local routes\n")
15455{
15456 struct bgp *bgp;
15457
15458 bgp = vty->index;
15459
15460 bgp->distance_ebgp= 0;
15461 bgp->distance_ibgp = 0;
15462 bgp->distance_local = 0;
15463 return CMD_SUCCESS;
15464}
15465
15466ALIAS (no_bgp_distance,
15467 no_bgp_distance2_cmd,
15468 "no distance bgp",
15469 NO_STR
15470 "Define an administrative distance\n"
15471 "BGP distance\n")
15472
15473DEFUN (bgp_distance_source,
15474 bgp_distance_source_cmd,
15475 "distance <1-255> A.B.C.D/M",
15476 "Define an administrative distance\n"
15477 "Administrative distance\n"
15478 "IP source prefix\n")
15479{
15480 bgp_distance_set (vty, argv[0], argv[1], NULL);
15481 return CMD_SUCCESS;
15482}
15483
15484DEFUN (no_bgp_distance_source,
15485 no_bgp_distance_source_cmd,
15486 "no distance <1-255> A.B.C.D/M",
15487 NO_STR
15488 "Define an administrative distance\n"
15489 "Administrative distance\n"
15490 "IP source prefix\n")
15491{
15492 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15493 return CMD_SUCCESS;
15494}
15495
15496DEFUN (bgp_distance_source_access_list,
15497 bgp_distance_source_access_list_cmd,
15498 "distance <1-255> A.B.C.D/M WORD",
15499 "Define an administrative distance\n"
15500 "Administrative distance\n"
15501 "IP source prefix\n"
15502 "Access list name\n")
15503{
15504 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15505 return CMD_SUCCESS;
15506}
15507
15508DEFUN (no_bgp_distance_source_access_list,
15509 no_bgp_distance_source_access_list_cmd,
15510 "no distance <1-255> A.B.C.D/M WORD",
15511 NO_STR
15512 "Define an administrative distance\n"
15513 "Administrative distance\n"
15514 "IP source prefix\n"
15515 "Access list name\n")
15516{
15517 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15518 return CMD_SUCCESS;
15519}
David Lamparter6b0655a2014-06-04 06:53:35 +020015520
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015521#ifdef HAVE_IPV6
15522DEFUN (ipv6_bgp_distance,
15523 ipv6_bgp_distance_cmd,
15524 "distance bgp <1-255> <1-255> <1-255>",
15525 "Define an administrative distance\n"
15526 "BGP distance\n"
15527 "Distance for routes external to the AS\n"
15528 "Distance for routes internal to the AS\n"
15529 "Distance for local routes\n")
15530{
15531 struct bgp *bgp;
15532
15533 bgp = vty->index;
15534
15535 bgp->ipv6_distance_ebgp = atoi (argv[0]);
15536 bgp->ipv6_distance_ibgp = atoi (argv[1]);
15537 bgp->ipv6_distance_local = atoi (argv[2]);
15538 return CMD_SUCCESS;
15539}
15540
15541DEFUN (no_ipv6_bgp_distance,
15542 no_ipv6_bgp_distance_cmd,
15543 "no distance bgp <1-255> <1-255> <1-255>",
15544 NO_STR
15545 "Define an administrative distance\n"
15546 "BGP distance\n"
15547 "Distance for routes external to the AS\n"
15548 "Distance for routes internal to the AS\n"
15549 "Distance for local routes\n")
15550{
15551 struct bgp *bgp;
15552
15553 bgp = vty->index;
15554
15555 bgp->ipv6_distance_ebgp= 0;
15556 bgp->ipv6_distance_ibgp = 0;
15557 bgp->ipv6_distance_local = 0;
15558 return CMD_SUCCESS;
15559}
15560
15561ALIAS (no_ipv6_bgp_distance,
15562 no_ipv6_bgp_distance2_cmd,
15563 "no distance bgp",
15564 NO_STR
15565 "Define an administrative distance\n"
15566 "BGP distance\n")
15567
15568DEFUN (ipv6_bgp_distance_source,
15569 ipv6_bgp_distance_source_cmd,
15570 "distance <1-255> X:X::X:X/M",
15571 "Define an administrative distance\n"
15572 "Administrative distance\n"
15573 "IP source prefix\n")
15574{
15575 bgp_distance_set (vty, argv[0], argv[1], NULL);
15576 return CMD_SUCCESS;
15577}
15578
15579DEFUN (no_ipv6_bgp_distance_source,
15580 no_ipv6_bgp_distance_source_cmd,
15581 "no distance <1-255> X:X::X:X/M",
15582 NO_STR
15583 "Define an administrative distance\n"
15584 "Administrative distance\n"
15585 "IP source prefix\n")
15586{
15587 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15588 return CMD_SUCCESS;
15589}
15590
15591DEFUN (ipv6_bgp_distance_source_access_list,
15592 ipv6_bgp_distance_source_access_list_cmd,
15593 "distance <1-255> X:X::X:X/M WORD",
15594 "Define an administrative distance\n"
15595 "Administrative distance\n"
15596 "IP source prefix\n"
15597 "Access list name\n")
15598{
15599 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15600 return CMD_SUCCESS;
15601}
15602
15603DEFUN (no_ipv6_bgp_distance_source_access_list,
15604 no_ipv6_bgp_distance_source_access_list_cmd,
15605 "no distance <1-255> X:X::X:X/M WORD",
15606 NO_STR
15607 "Define an administrative distance\n"
15608 "Administrative distance\n"
15609 "IP source prefix\n"
15610 "Access list name\n")
15611{
15612 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15613 return CMD_SUCCESS;
15614}
15615#endif
15616
paul718e3742002-12-13 20:15:29 +000015617DEFUN (bgp_damp_set,
15618 bgp_damp_set_cmd,
15619 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15620 "BGP Specific commands\n"
15621 "Enable route-flap dampening\n"
15622 "Half-life time for the penalty\n"
15623 "Value to start reusing a route\n"
15624 "Value to start suppressing a route\n"
15625 "Maximum duration to suppress a stable route\n")
15626{
15627 struct bgp *bgp;
15628 int half = DEFAULT_HALF_LIFE * 60;
15629 int reuse = DEFAULT_REUSE;
15630 int suppress = DEFAULT_SUPPRESS;
15631 int max = 4 * half;
15632
15633 if (argc == 4)
15634 {
15635 half = atoi (argv[0]) * 60;
15636 reuse = atoi (argv[1]);
15637 suppress = atoi (argv[2]);
15638 max = atoi (argv[3]) * 60;
15639 }
15640 else if (argc == 1)
15641 {
15642 half = atoi (argv[0]) * 60;
15643 max = 4 * half;
15644 }
15645
15646 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015647
15648 if (suppress < reuse)
15649 {
15650 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15651 VTY_NEWLINE);
15652 return 0;
15653 }
15654
paul718e3742002-12-13 20:15:29 +000015655 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15656 half, reuse, suppress, max);
15657}
15658
15659ALIAS (bgp_damp_set,
15660 bgp_damp_set2_cmd,
15661 "bgp dampening <1-45>",
15662 "BGP Specific commands\n"
15663 "Enable route-flap dampening\n"
15664 "Half-life time for the penalty\n")
15665
15666ALIAS (bgp_damp_set,
15667 bgp_damp_set3_cmd,
15668 "bgp dampening",
15669 "BGP Specific commands\n"
15670 "Enable route-flap dampening\n")
15671
15672DEFUN (bgp_damp_unset,
15673 bgp_damp_unset_cmd,
15674 "no bgp dampening",
15675 NO_STR
15676 "BGP Specific commands\n"
15677 "Enable route-flap dampening\n")
15678{
15679 struct bgp *bgp;
15680
15681 bgp = vty->index;
15682 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15683}
15684
15685ALIAS (bgp_damp_unset,
15686 bgp_damp_unset2_cmd,
15687 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15688 NO_STR
15689 "BGP Specific commands\n"
15690 "Enable route-flap dampening\n"
15691 "Half-life time for the penalty\n"
15692 "Value to start reusing a route\n"
15693 "Value to start suppressing a route\n"
15694 "Maximum duration to suppress a stable route\n")
15695
Lou Bergerf9b6c392016-01-12 13:42:09 -050015696DEFUN (show_ip_bgp_dampened_paths,
15697 show_ip_bgp_dampened_paths_cmd,
15698 "show ip bgp dampened-paths",
15699 SHOW_STR
15700 IP_STR
15701 BGP_STR
15702 "Display paths suppressed due to dampening\n")
15703{
15704 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15705 NULL);
15706}
15707
15708ALIAS (show_ip_bgp_dampened_paths,
15709 show_ip_bgp_damp_dampened_paths_cmd,
15710 "show ip bgp dampening dampened-paths",
15711 SHOW_STR
15712 IP_STR
15713 BGP_STR
15714 "Display detailed information about dampening\n"
15715 "Display paths suppressed due to dampening\n")
15716
15717DEFUN (show_ip_bgp_flap_statistics,
15718 show_ip_bgp_flap_statistics_cmd,
15719 "show ip bgp flap-statistics",
15720 SHOW_STR
15721 IP_STR
15722 BGP_STR
15723 "Display flap statistics of routes\n")
15724{
15725 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15726 bgp_show_type_flap_statistics, NULL);
15727}
15728
15729ALIAS (show_ip_bgp_flap_statistics,
15730 show_ip_bgp_damp_flap_statistics_cmd,
15731 "show ip bgp dampening flap-statistics",
15732 SHOW_STR
15733 IP_STR
15734 BGP_STR
15735 "Display detailed information about dampening\n"
15736 "Display flap statistics of routes\n")
15737
Lou Berger651b4022016-01-12 13:42:07 -050015738DEFUN (show_bgp_ipv4_safi_dampened_paths,
15739 show_bgp_ipv4_safi_dampened_paths_cmd,
15740 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015741 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015742 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015743 IP_STR
15744 "Address Family modifier\n"
15745 "Address Family modifier\n"
15746 "Address Family modifier\n"
15747 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015748 "Display paths suppressed due to dampening\n")
15749{
Lou Berger651b4022016-01-12 13:42:07 -050015750 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015751
Lou Berger651b4022016-01-12 13:42:07 -050015752 if (bgp_parse_safi(argv[0], &safi)) {
15753 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15754 return CMD_WARNING;
15755 }
15756
15757 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15758}
15759ALIAS (show_bgp_ipv4_safi_dampened_paths,
15760 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15761 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015762 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015763 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015764 IP_STR
15765 "Address Family modifier\n"
15766 "Address Family modifier\n"
15767 "Address Family modifier\n"
15768 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015769 "Display detailed information about dampening\n"
15770 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015771
Lou Berger651b4022016-01-12 13:42:07 -050015772DEFUN (show_bgp_ipv6_safi_dampened_paths,
15773 show_bgp_ipv6_safi_dampened_paths_cmd,
15774 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015775 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015776 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015777 IPV6_STR
15778 "Address Family modifier\n"
15779 "Address Family modifier\n"
15780 "Address Family modifier\n"
15781 "Address Family modifier\n"
15782 "Display paths suppressed due to dampening\n")
15783{
15784 safi_t safi;
15785
15786 if (bgp_parse_safi(argv[0], &safi)) {
15787 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15788 return CMD_WARNING;
15789 }
15790
15791 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15792}
15793ALIAS (show_bgp_ipv6_safi_dampened_paths,
15794 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15795 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15796 SHOW_STR
15797 BGP_STR
15798 IPV6_STR
15799 "Address Family modifier\n"
15800 "Address Family modifier\n"
15801 "Address Family modifier\n"
15802 "Address Family modifier\n"
15803 "Display detailed information about dampening\n"
15804 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015805
15806DEFUN (show_bgp_ipv4_safi_flap_statistics,
15807 show_bgp_ipv4_safi_flap_statistics_cmd,
15808 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15809 SHOW_STR
15810 BGP_STR
15811 "Address Family\n"
15812 "Address Family modifier\n"
15813 "Address Family modifier\n"
15814 "Address Family modifier\n"
15815 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015816 "Display flap statistics of routes\n")
15817{
Lou Berger651b4022016-01-12 13:42:07 -050015818 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015819
Lou Berger651b4022016-01-12 13:42:07 -050015820 if (bgp_parse_safi(argv[0], &safi)) {
15821 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15822 return CMD_WARNING;
15823 }
15824
15825 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15826}
15827ALIAS (show_bgp_ipv4_safi_flap_statistics,
15828 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15829 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015830 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015831 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015832 "Address Family\n"
15833 "Address Family modifier\n"
15834 "Address Family modifier\n"
15835 "Address Family modifier\n"
15836 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015837 "Display detailed information about dampening\n"
15838 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015839
Lou Berger651b4022016-01-12 13:42:07 -050015840DEFUN (show_bgp_ipv6_safi_flap_statistics,
15841 show_bgp_ipv6_safi_flap_statistics_cmd,
15842 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15843 SHOW_STR
15844 BGP_STR
15845 "Address Family\n"
15846 "Address Family modifier\n"
15847 "Address Family modifier\n"
15848 "Address Family modifier\n"
15849 "Address Family modifier\n"
15850 "Display flap statistics of routes\n")
15851{
15852 safi_t safi;
15853
15854 if (bgp_parse_safi(argv[0], &safi)) {
15855 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15856 return CMD_WARNING;
15857 }
15858
15859 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15860}
15861ALIAS (show_bgp_ipv6_safi_flap_statistics,
15862 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15863 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15864 SHOW_STR
15865 BGP_STR
15866 "Address Family\n"
15867 "Address Family modifier\n"
15868 "Address Family modifier\n"
15869 "Address Family modifier\n"
15870 "Address Family modifier\n"
15871 "Display detailed information about dampening\n"
15872 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015873
paul718e3742002-12-13 20:15:29 +000015874/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015875static int
paulfd79ac92004-10-13 05:06:08 +000015876bgp_clear_damp_route (struct vty *vty, const char *view_name,
15877 const char *ip_str, afi_t afi, safi_t safi,
15878 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015879{
15880 int ret;
15881 struct prefix match;
15882 struct bgp_node *rn;
15883 struct bgp_node *rm;
15884 struct bgp_info *ri;
15885 struct bgp_info *ri_temp;
15886 struct bgp *bgp;
15887 struct bgp_table *table;
15888
15889 /* BGP structure lookup. */
15890 if (view_name)
15891 {
15892 bgp = bgp_lookup_by_name (view_name);
15893 if (bgp == NULL)
15894 {
15895 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15896 return CMD_WARNING;
15897 }
15898 }
15899 else
15900 {
15901 bgp = bgp_get_default ();
15902 if (bgp == NULL)
15903 {
15904 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15905 return CMD_WARNING;
15906 }
15907 }
15908
15909 /* Check IP address argument. */
15910 ret = str2prefix (ip_str, &match);
15911 if (! ret)
15912 {
15913 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15914 return CMD_WARNING;
15915 }
15916
15917 match.family = afi2family (afi);
15918
Lou Berger298cc2f2016-01-12 13:42:02 -050015919 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015920 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015921 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015922 {
15923 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15924 continue;
15925
15926 if ((table = rn->info) != NULL)
15927 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015928 {
15929 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15930 {
15931 ri = rm->info;
15932 while (ri)
15933 {
15934 if (ri->extra && ri->extra->damp_info)
15935 {
15936 ri_temp = ri->next;
15937 bgp_damp_info_free (ri->extra->damp_info, 1);
15938 ri = ri_temp;
15939 }
15940 else
15941 ri = ri->next;
15942 }
15943 }
15944
15945 bgp_unlock_node (rm);
15946 }
paul718e3742002-12-13 20:15:29 +000015947 }
15948 }
15949 else
15950 {
15951 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015952 {
15953 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15954 {
15955 ri = rn->info;
15956 while (ri)
15957 {
15958 if (ri->extra && ri->extra->damp_info)
15959 {
15960 ri_temp = ri->next;
15961 bgp_damp_info_free (ri->extra->damp_info, 1);
15962 ri = ri_temp;
15963 }
15964 else
15965 ri = ri->next;
15966 }
15967 }
15968
15969 bgp_unlock_node (rn);
15970 }
paul718e3742002-12-13 20:15:29 +000015971 }
15972
15973 return CMD_SUCCESS;
15974}
15975
15976DEFUN (clear_ip_bgp_dampening,
15977 clear_ip_bgp_dampening_cmd,
15978 "clear ip bgp dampening",
15979 CLEAR_STR
15980 IP_STR
15981 BGP_STR
15982 "Clear route flap dampening information\n")
15983{
15984 bgp_damp_info_clean ();
15985 return CMD_SUCCESS;
15986}
15987
15988DEFUN (clear_ip_bgp_dampening_prefix,
15989 clear_ip_bgp_dampening_prefix_cmd,
15990 "clear ip bgp dampening A.B.C.D/M",
15991 CLEAR_STR
15992 IP_STR
15993 BGP_STR
15994 "Clear route flap dampening information\n"
15995 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15996{
15997 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15998 SAFI_UNICAST, NULL, 1);
15999}
16000
16001DEFUN (clear_ip_bgp_dampening_address,
16002 clear_ip_bgp_dampening_address_cmd,
16003 "clear ip bgp dampening A.B.C.D",
16004 CLEAR_STR
16005 IP_STR
16006 BGP_STR
16007 "Clear route flap dampening information\n"
16008 "Network to clear damping information\n")
16009{
16010 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16011 SAFI_UNICAST, NULL, 0);
16012}
16013
16014DEFUN (clear_ip_bgp_dampening_address_mask,
16015 clear_ip_bgp_dampening_address_mask_cmd,
16016 "clear ip bgp dampening A.B.C.D A.B.C.D",
16017 CLEAR_STR
16018 IP_STR
16019 BGP_STR
16020 "Clear route flap dampening information\n"
16021 "Network to clear damping information\n"
16022 "Network mask\n")
16023{
16024 int ret;
16025 char prefix_str[BUFSIZ];
16026
16027 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
16028 if (! ret)
16029 {
16030 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
16031 return CMD_WARNING;
16032 }
16033
16034 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
16035 SAFI_UNICAST, NULL, 0);
16036}
David Lamparter6b0655a2014-06-04 06:53:35 +020016037
Lou Berger298cc2f2016-01-12 13:42:02 -050016038/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000016039static int
paul718e3742002-12-13 20:15:29 +000016040bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
16041 afi_t afi, safi_t safi, int *write)
16042{
16043 struct bgp_node *prn;
16044 struct bgp_node *rn;
16045 struct bgp_table *table;
16046 struct prefix *p;
16047 struct prefix_rd *prd;
16048 struct bgp_static *bgp_static;
16049 u_int32_t label;
16050 char buf[SU_ADDRSTRLEN];
16051 char rdbuf[RD_ADDRSTRLEN];
16052
16053 /* Network configuration. */
16054 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
16055 if ((table = prn->info) != NULL)
16056 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
16057 if ((bgp_static = rn->info) != NULL)
16058 {
16059 p = &rn->p;
16060 prd = (struct prefix_rd *) &prn->p;
16061
16062 /* "address-family" display. */
16063 bgp_config_write_family_header (vty, afi, safi, write);
16064
16065 /* "network" configuration display. */
16066 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
16067 label = decode_label (bgp_static->tag);
16068
16069 vty_out (vty, " network %s/%d rd %s tag %d",
16070 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16071 p->prefixlen,
16072 rdbuf, label);
16073 vty_out (vty, "%s", VTY_NEWLINE);
16074 }
16075 return 0;
16076}
16077
16078/* Configuration of static route announcement and aggregate
16079 information. */
16080int
16081bgp_config_write_network (struct vty *vty, struct bgp *bgp,
16082 afi_t afi, safi_t safi, int *write)
16083{
16084 struct bgp_node *rn;
16085 struct prefix *p;
16086 struct bgp_static *bgp_static;
16087 struct bgp_aggregate *bgp_aggregate;
16088 char buf[SU_ADDRSTRLEN];
16089
Lou Berger298cc2f2016-01-12 13:42:02 -050016090 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000016091 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
16092
16093 /* Network configuration. */
16094 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
16095 if ((bgp_static = rn->info) != NULL)
16096 {
16097 p = &rn->p;
16098
16099 /* "address-family" display. */
16100 bgp_config_write_family_header (vty, afi, safi, write);
16101
16102 /* "network" configuration display. */
16103 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
16104 {
16105 u_int32_t destination;
16106 struct in_addr netmask;
16107
16108 destination = ntohl (p->u.prefix4.s_addr);
16109 masklen2ip (p->prefixlen, &netmask);
16110 vty_out (vty, " network %s",
16111 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
16112
16113 if ((IN_CLASSC (destination) && p->prefixlen == 24)
16114 || (IN_CLASSB (destination) && p->prefixlen == 16)
16115 || (IN_CLASSA (destination) && p->prefixlen == 8)
16116 || p->u.prefix4.s_addr == 0)
16117 {
16118 /* Natural mask is not display. */
16119 }
16120 else
16121 vty_out (vty, " mask %s", inet_ntoa (netmask));
16122 }
16123 else
16124 {
16125 vty_out (vty, " network %s/%d",
16126 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16127 p->prefixlen);
16128 }
16129
16130 if (bgp_static->rmap.name)
16131 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000016132 else
16133 {
16134 if (bgp_static->backdoor)
16135 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000016136 }
paul718e3742002-12-13 20:15:29 +000016137
16138 vty_out (vty, "%s", VTY_NEWLINE);
16139 }
16140
16141 /* Aggregate-address configuration. */
16142 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
16143 if ((bgp_aggregate = rn->info) != NULL)
16144 {
16145 p = &rn->p;
16146
16147 /* "address-family" display. */
16148 bgp_config_write_family_header (vty, afi, safi, write);
16149
16150 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
16151 {
16152 struct in_addr netmask;
16153
16154 masklen2ip (p->prefixlen, &netmask);
16155 vty_out (vty, " aggregate-address %s %s",
16156 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16157 inet_ntoa (netmask));
16158 }
16159 else
16160 {
16161 vty_out (vty, " aggregate-address %s/%d",
16162 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16163 p->prefixlen);
16164 }
16165
16166 if (bgp_aggregate->as_set)
16167 vty_out (vty, " as-set");
16168
16169 if (bgp_aggregate->summary_only)
16170 vty_out (vty, " summary-only");
16171
16172 vty_out (vty, "%s", VTY_NEWLINE);
16173 }
16174
16175 return 0;
16176}
16177
16178int
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016179bgp_config_write_distance (struct vty *vty, struct bgp *bgp,
16180 afi_t afi, safi_t safi, int *write)
paul718e3742002-12-13 20:15:29 +000016181{
16182 struct bgp_node *rn;
16183 struct bgp_distance *bdistance;
16184
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016185 if (afi == AFI_IP && safi == SAFI_UNICAST)
16186 {
16187 /* Distance configuration. */
16188 if (bgp->distance_ebgp
16189 && bgp->distance_ibgp
16190 && bgp->distance_local
16191 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
16192 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
16193 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
16194 vty_out (vty, " distance bgp %d %d %d%s",
16195 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
16196 VTY_NEWLINE);
16197
16198 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
16199 if ((bdistance = rn->info) != NULL)
16200 {
16201 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
16202 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
16203 bdistance->access_list ? bdistance->access_list : "",
16204 VTY_NEWLINE);
16205 }
16206 }
16207
16208#ifdef HAVE_IPV6
16209 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
16210 {
16211 bgp_config_write_family_header (vty, afi, safi, write);
16212 if (bgp->ipv6_distance_ebgp
16213 && bgp->ipv6_distance_ibgp
16214 && bgp->ipv6_distance_local
16215 && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
16216 || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
16217 || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
16218 vty_out (vty, " distance bgp %d %d %d%s",
16219 bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local,
16220 VTY_NEWLINE);
16221
16222 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
16223 if ((bdistance = rn->info) != NULL)
16224 {
16225 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
16226 inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen,
16227 bdistance->access_list ? bdistance->access_list : "",
16228 VTY_NEWLINE);
16229 }
16230 }
16231#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000016232
16233 return 0;
16234}
16235
16236/* Allocate routing table structure and install commands. */
16237void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080016238bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000016239{
16240 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000016241 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000016242
16243 /* IPv4 BGP commands. */
16244 install_element (BGP_NODE, &bgp_network_cmd);
16245 install_element (BGP_NODE, &bgp_network_mask_cmd);
16246 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
16247 install_element (BGP_NODE, &bgp_network_route_map_cmd);
16248 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
16249 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
16250 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
16251 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
16252 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
16253 install_element (BGP_NODE, &no_bgp_network_cmd);
16254 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
16255 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
16256 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
16257 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
16258 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
16259 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
16260 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
16261 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
16262
16263 install_element (BGP_NODE, &aggregate_address_cmd);
16264 install_element (BGP_NODE, &aggregate_address_mask_cmd);
16265 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
16266 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
16267 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
16268 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
16269 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
16270 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
16271 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
16272 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
16273 install_element (BGP_NODE, &no_aggregate_address_cmd);
16274 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
16275 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
16276 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
16277 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
16278 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
16279 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
16280 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
16281 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16282 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16283
16284 /* IPv4 unicast configuration. */
16285 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
16286 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
16287 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
16288 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
16289 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
16290 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016291 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000016292 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
16293 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
16294 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
16295 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
16296 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016297
paul718e3742002-12-13 20:15:29 +000016298 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
16299 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
16300 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
16301 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
16302 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
16303 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
16304 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
16305 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
16306 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
16307 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
16308 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
16309 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
16310 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
16311 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
16312 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
16313 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
16314 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
16315 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
16316 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16317 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16318
16319 /* IPv4 multicast configuration. */
16320 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
16321 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
16322 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
16323 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
16324 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
16325 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
16326 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
16327 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
16328 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
16329 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
16330 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
16331 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
16332 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
16333 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
16334 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
16335 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
16336 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
16337 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
16338 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
16339 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
16340 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
16341 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
16342 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
16343 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
16344 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
16345 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
16346 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
16347 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
16348 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
16349 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
16350 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16351 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16352
Michael Lambert95cbbd22010-07-23 14:43:04 -040016353 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016354 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016355 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
16356 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
16357 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16358 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16359 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
16360 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
16361 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16362 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16363 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016364 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016365 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16366 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16367 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16368 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16369 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16370 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16371 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
16372 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
16373 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16374 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
16375 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
16376 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
16377 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
16378 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
16379 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
16380 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
16381 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
16382 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
16383 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
16384 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16385 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
16386 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
16387 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
16388 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
16389 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
16390 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
16391 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
16392 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016393 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16394 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
16395 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
16396 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
16397 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016398 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
16399 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
16400 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
16401 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
16402 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16403 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16404 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16405 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16406 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
16407 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16408 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16409 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16410 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16411 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16412 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16413 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16414 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16415 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16416 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016417 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016418 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16419 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16420 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16421 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16422 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16423 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16424 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16425 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16426 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16427 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16428 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16429 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16430 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16431 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
16432 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16433 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16434 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16435 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16436 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16437 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16438 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16439 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16440 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16441 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16442 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16443 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16444 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16445 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16446 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16447 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16448 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16449 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16450 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16451 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16452 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16453 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16454 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16455 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16456 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16457 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16458 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16459 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16460 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16461 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16462 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016463 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016464 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016465 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016466 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016467 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016468 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016469
16470 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040016471 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016472 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16473 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16474 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16475 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16476 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016477 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016478 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16479 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16480 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16481 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16482 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16483 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16484 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
16485 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16486 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
16487 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
16488 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
16489 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
16490 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
16491 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
16492 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
16493 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016494 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16495 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
16496 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
16497 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
16498 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016499 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
16500 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
16501 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
16502 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
16503 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16504 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16505 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16506 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016507 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016508 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016509 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016510 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016511
Donald Sharp68b45cc2016-03-11 14:27:13 -050016512 /* BGP dampening clear commands */
paul718e3742002-12-13 20:15:29 +000016513 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16514 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16515 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16516 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16517
paul718e3742002-12-13 20:15:29 +000016518 /* New config IPv6 BGP commands. */
16519 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16520 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16521 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16522 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16523
16524 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16525 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16526 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16527 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16528
G.Balaji73bfe0b2011-09-23 22:36:20 +053016529 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16530 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16531
paul718e3742002-12-13 20:15:29 +000016532 /* Old config IPv6 BGP commands. */
16533 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16534 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16535
16536 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16537 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16538 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16539 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16540
Michael Lambert95cbbd22010-07-23 14:43:04 -040016541 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016542 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016543 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016544 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016545 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016546 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016547 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016548 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016549 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016550 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16551 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16552 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16553 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16554 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16555 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16556 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16557 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016558 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016559 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016560 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016561 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016562 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016563 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016564 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016565 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016566 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16567 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016568 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016569 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016570 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016571 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016572 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016573 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016574 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016575 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016576 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016577 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016578 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016579 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016580 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016581 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016582 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16583 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016584 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016585 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016586 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016587 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016588 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016589
16590 /* Restricted:
16591 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16592 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016593 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016594 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016595 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016596 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016597 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16598 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16599 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16600 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16601 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16602 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16603 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16604 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16605 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016606 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016607 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016608 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016609 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016610 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016611 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016612 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016613 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016614 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016615 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016616
Paul Jakma2815e612006-09-14 02:56:07 +000016617 /* Statistics */
16618 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016619 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016620
16621 install_element (BGP_NODE, &bgp_distance_cmd);
16622 install_element (BGP_NODE, &no_bgp_distance_cmd);
16623 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16624 install_element (BGP_NODE, &bgp_distance_source_cmd);
16625 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16626 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16627 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016628#ifdef HAVE_IPV6
16629 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd);
16630 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd);
16631 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd);
16632 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd);
16633 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd);
16634 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd);
16635 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd);
16636#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000016637
16638 install_element (BGP_NODE, &bgp_damp_set_cmd);
16639 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16640 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16641 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16642 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16643 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16644 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16645 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16646 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16647 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Balaji9145f0e2016-01-20 22:59:27 +053016648
16649 /* IPv4 Multicast Mode */
16650 install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd);
16651 install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd);
16652 install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd);
16653 install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd);
16654 install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd);
16655
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016656
16657 /* Deprecated AS-Pathlimit commands */
16658 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16659 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16660 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16661 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16662 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16663 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16664
16665 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16666 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16667 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16668 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16669 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16670 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16671
16672 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16673 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16674 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16675 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16676 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16677 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16678
16679 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16680 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16681 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16682 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16683 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16684 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16685
16686 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16687 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16688 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16689 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16690 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16691 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16692
16693 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16694 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16695 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16696 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16697 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16698 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016699
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016700 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16701 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016702
16703 /* old style commands */
16704 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16705 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16706 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016707 install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd);
16708 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016709 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16710 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16711 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16712 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16713 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016714 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
16715 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
16716 install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016717 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16718 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16719 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16720 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16721 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16722 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16723 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16724 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16725 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16726 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16727 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16728 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16729 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16730 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16731 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16732 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16733 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16734 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16735 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16736 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16737 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16738 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16739 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16740 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16741 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16742 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16743 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16744 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16745 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16746 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16747 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16748 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16749 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16750 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16751 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16752 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16753 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16754 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16755 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16756 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16757 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16758 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16759 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16760 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16761 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16762 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16763 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16764 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016765 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016766 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016767 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd);
16768 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016769 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16770 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16771 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16772 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16773 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16774 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16775 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16776 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16777 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16778 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16779 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16780 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16781 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16782 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16783 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16784 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16785 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16786 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16787 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16788 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16789 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16790 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16791 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16792 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16793 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16794 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16795 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016796
Lou Bergerf9b6c392016-01-12 13:42:09 -050016797 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016798 install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd);
16799 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016800 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16801 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16802 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16803 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016804 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
16805 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
16806 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016807 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16808 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16809 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16810 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16811 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16812 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16813 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16814 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16815 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16816 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16817 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16818 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16819 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16820 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16821 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16822 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16823 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16824 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16825 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16826 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16827 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16828 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16829 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16830 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016831
16832 install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16833 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16834 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016835
Lou Bergerf9b6c392016-01-12 13:42:09 -050016836 install_element (VIEW_NODE, &show_bgp_cmd);
16837 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16838 install_element (VIEW_NODE, &show_bgp_route_cmd);
16839 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016840 install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd);
16841 install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd);
16842 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
16843 install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd);
16844 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
16845 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016846 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16847 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16848 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16849 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16850 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16851 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16852 install_element (VIEW_NODE, &show_bgp_community_cmd);
16853 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16854 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16855 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16856 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16857 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16858 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16859 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16860 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16861 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16862 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16863 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16864 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16865 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16866 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16867 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16868 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16869 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16870 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16871 install_element (VIEW_NODE, &show_bgp_view_cmd);
16872 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16873 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16874 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16875 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16876 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16877 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16878 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16879 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16880 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016881
Lou Bergerf9b6c392016-01-12 13:42:09 -050016882 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16883 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016884 install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd);
16885 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd);
16886 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
16887 install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd);
16888 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
16889 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016890 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16891 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16892 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16893 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16894 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16895 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16896 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16897 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16898 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16899 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16900 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016901
Lou Bergerf9b6c392016-01-12 13:42:09 -050016902 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16903 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016904
Lou Bergerf9b6c392016-01-12 13:42:09 -050016905 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16906 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16907 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16908 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16909 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16910 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16911 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16912 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16913 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16914 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16915 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16916 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16917 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16918 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16919 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16920 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16921 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16922 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16923 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16924 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16925 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16926 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16927 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16928 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16929 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16930 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16931 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16932 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16933 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16934 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16935 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16936 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16937 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16938 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16939 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16940 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016941 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016942 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016943 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016944 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016945 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016946 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016947 /* old with name safi collision */
16948 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16949 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16950 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16951 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16952 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16953 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16954 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16955 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16956 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16957 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16958 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16959 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16960 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16961 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16962 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16963 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016964
Lou Bergerf9b6c392016-01-12 13:42:09 -050016965 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
16966 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016967
16968 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
16969 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
16970 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
16971 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016972
16973 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
16974 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
16975 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
16976 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016977}
Chris Caputo228da422009-07-18 05:44:03 +000016978
16979void
16980bgp_route_finish (void)
16981{
16982 bgp_table_unlock (bgp_distance_table);
16983 bgp_distance_table = NULL;
16984}