blob: 476ef0596203ca23db2f726054b966c97b2a79ff [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 }
paul718e3742002-12-13 20:15:29 +0000899
900 /* If we're a CONFED we need to loop check the CONFED ID too */
901 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
902 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700903 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
paul718e3742002-12-13 20:15:29 +0000904 {
905 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000906 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400907 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000908 peer->host,
909 bgp->confed_id);
910 return 0;
911 }
912 }
Thorvald Natvig95509a62016-09-29 10:25:35 -0700913#endif /* BGP_SEND_ASPATH_CHECK */
paul718e3742002-12-13 20:15:29 +0000914
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 {
Timo Teräse3443a22016-10-19 16:02:34 +03002342 if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 &&
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002343 ! 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 {
Timo Teräse3443a22016-10-19 16:02:34 +03002394 if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 &&
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002395 ! 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))
Daniel Walton4d48bb32016-11-29 12:47:12 -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))
Daniel Walton4d48bb32016-11-29 12:47:12 -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;
Christian Frankec8e80972016-06-14 20:07:01 +02009431 int i, rv;
paul718e3742002-12-13 20:15:29 +00009432 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
Christian Frankec8e80972016-06-14 20:07:01 +02009482 rv = bgp_show (vty, bgp, afi, safi,
9483 (exact ? bgp_show_type_community_exact :
9484 bgp_show_type_community), com);
9485 community_free(com);
9486 return rv;
paul718e3742002-12-13 20:15:29 +00009487}
9488
Lou Bergerf9b6c392016-01-12 13:42:09 -05009489DEFUN (show_ip_bgp_community,
9490 show_ip_bgp_community_cmd,
9491 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9492 SHOW_STR
9493 IP_STR
9494 BGP_STR
9495 "Display routes matching the communities\n"
9496 "community number\n"
9497 "Do not send outside local AS (well-known community)\n"
9498 "Do not advertise to any peer (well-known community)\n"
9499 "Do not export to next AS (well-known community)\n")
9500{
9501 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9502}
9503
9504ALIAS (show_ip_bgp_community,
9505 show_ip_bgp_community2_cmd,
9506 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9507 SHOW_STR
9508 IP_STR
9509 BGP_STR
9510 "Display routes matching the communities\n"
9511 "community number\n"
9512 "Do not send outside local AS (well-known community)\n"
9513 "Do not advertise to any peer (well-known community)\n"
9514 "Do not export to next AS (well-known community)\n"
9515 "community number\n"
9516 "Do not send outside local AS (well-known community)\n"
9517 "Do not advertise to any peer (well-known community)\n"
9518 "Do not export to next AS (well-known community)\n")
9519
9520ALIAS (show_ip_bgp_community,
9521 show_ip_bgp_community3_cmd,
9522 "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)",
9523 SHOW_STR
9524 IP_STR
9525 BGP_STR
9526 "Display routes matching the communities\n"
9527 "community number\n"
9528 "Do not send outside local AS (well-known community)\n"
9529 "Do not advertise to any peer (well-known community)\n"
9530 "Do not export to next AS (well-known community)\n"
9531 "community number\n"
9532 "Do not send outside local AS (well-known community)\n"
9533 "Do not advertise to any peer (well-known community)\n"
9534 "Do not export to next AS (well-known community)\n"
9535 "community number\n"
9536 "Do not send outside local AS (well-known community)\n"
9537 "Do not advertise to any peer (well-known community)\n"
9538 "Do not export to next AS (well-known community)\n")
9539
9540ALIAS (show_ip_bgp_community,
9541 show_ip_bgp_community4_cmd,
9542 "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)",
9543 SHOW_STR
9544 IP_STR
9545 BGP_STR
9546 "Display routes matching the communities\n"
9547 "community number\n"
9548 "Do not send outside local AS (well-known community)\n"
9549 "Do not advertise to any peer (well-known community)\n"
9550 "Do not export to next AS (well-known community)\n"
9551 "community number\n"
9552 "Do not send outside local AS (well-known community)\n"
9553 "Do not advertise to any peer (well-known community)\n"
9554 "Do not export to next AS (well-known community)\n"
9555 "community number\n"
9556 "Do not send outside local AS (well-known community)\n"
9557 "Do not advertise to any peer (well-known community)\n"
9558 "Do not export to next AS (well-known community)\n"
9559 "community number\n"
9560 "Do not send outside local AS (well-known community)\n"
9561 "Do not advertise to any peer (well-known community)\n"
9562 "Do not export to next AS (well-known community)\n")
9563
9564DEFUN (show_ip_bgp_ipv4_community,
9565 show_ip_bgp_ipv4_community_cmd,
9566 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9567 SHOW_STR
9568 IP_STR
9569 BGP_STR
9570 "Address family\n"
9571 "Address Family modifier\n"
9572 "Address Family modifier\n"
9573 "Display routes matching the communities\n"
9574 "community number\n"
9575 "Do not send outside local AS (well-known community)\n"
9576 "Do not advertise to any peer (well-known community)\n"
9577 "Do not export to next AS (well-known community)\n")
9578{
9579 if (strncmp (argv[0], "m", 1) == 0)
9580 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9581
9582 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9583}
9584
9585ALIAS (show_ip_bgp_ipv4_community,
9586 show_ip_bgp_ipv4_community2_cmd,
9587 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9588 SHOW_STR
9589 IP_STR
9590 BGP_STR
9591 "Address family\n"
9592 "Address Family modifier\n"
9593 "Address Family modifier\n"
9594 "Display routes matching the communities\n"
9595 "community number\n"
9596 "Do not send outside local AS (well-known community)\n"
9597 "Do not advertise to any peer (well-known community)\n"
9598 "Do not export to next AS (well-known community)\n"
9599 "community number\n"
9600 "Do not send outside local AS (well-known community)\n"
9601 "Do not advertise to any peer (well-known community)\n"
9602 "Do not export to next AS (well-known community)\n")
9603
9604ALIAS (show_ip_bgp_ipv4_community,
9605 show_ip_bgp_ipv4_community3_cmd,
9606 "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)",
9607 SHOW_STR
9608 IP_STR
9609 BGP_STR
9610 "Address family\n"
9611 "Address Family modifier\n"
9612 "Address Family modifier\n"
9613 "Display routes matching the communities\n"
9614 "community number\n"
9615 "Do not send outside local AS (well-known community)\n"
9616 "Do not advertise to any peer (well-known community)\n"
9617 "Do not export to next AS (well-known community)\n"
9618 "community number\n"
9619 "Do not send outside local AS (well-known community)\n"
9620 "Do not advertise to any peer (well-known community)\n"
9621 "Do not export to next AS (well-known community)\n"
9622 "community number\n"
9623 "Do not send outside local AS (well-known community)\n"
9624 "Do not advertise to any peer (well-known community)\n"
9625 "Do not export to next AS (well-known community)\n")
9626
9627ALIAS (show_ip_bgp_ipv4_community,
9628 show_ip_bgp_ipv4_community4_cmd,
9629 "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)",
9630 SHOW_STR
9631 IP_STR
9632 BGP_STR
9633 "Address family\n"
9634 "Address Family modifier\n"
9635 "Address Family modifier\n"
9636 "Display routes matching the communities\n"
9637 "community number\n"
9638 "Do not send outside local AS (well-known community)\n"
9639 "Do not advertise to any peer (well-known community)\n"
9640 "Do not export to next AS (well-known community)\n"
9641 "community number\n"
9642 "Do not send outside local AS (well-known community)\n"
9643 "Do not advertise to any peer (well-known community)\n"
9644 "Do not export to next AS (well-known community)\n"
9645 "community number\n"
9646 "Do not send outside local AS (well-known community)\n"
9647 "Do not advertise to any peer (well-known community)\n"
9648 "Do not export to next AS (well-known community)\n"
9649 "community number\n"
9650 "Do not send outside local AS (well-known community)\n"
9651 "Do not advertise to any peer (well-known community)\n"
9652 "Do not export to next AS (well-known community)\n")
9653
9654DEFUN (show_ip_bgp_community_exact,
9655 show_ip_bgp_community_exact_cmd,
9656 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9657 SHOW_STR
9658 IP_STR
9659 BGP_STR
9660 "Display routes matching the communities\n"
9661 "community number\n"
9662 "Do not send outside local AS (well-known community)\n"
9663 "Do not advertise to any peer (well-known community)\n"
9664 "Do not export to next AS (well-known community)\n"
9665 "Exact match of the communities")
9666{
9667 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9668}
9669
9670ALIAS (show_ip_bgp_community_exact,
9671 show_ip_bgp_community2_exact_cmd,
9672 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9673 SHOW_STR
9674 IP_STR
9675 BGP_STR
9676 "Display routes matching the communities\n"
9677 "community number\n"
9678 "Do not send outside local AS (well-known community)\n"
9679 "Do not advertise to any peer (well-known community)\n"
9680 "Do not export to next AS (well-known community)\n"
9681 "community number\n"
9682 "Do not send outside local AS (well-known community)\n"
9683 "Do not advertise to any peer (well-known community)\n"
9684 "Do not export to next AS (well-known community)\n"
9685 "Exact match of the communities")
9686
9687ALIAS (show_ip_bgp_community_exact,
9688 show_ip_bgp_community3_exact_cmd,
9689 "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",
9690 SHOW_STR
9691 IP_STR
9692 BGP_STR
9693 "Display routes matching the communities\n"
9694 "community number\n"
9695 "Do not send outside local AS (well-known community)\n"
9696 "Do not advertise to any peer (well-known community)\n"
9697 "Do not export to next AS (well-known community)\n"
9698 "community number\n"
9699 "Do not send outside local AS (well-known community)\n"
9700 "Do not advertise to any peer (well-known community)\n"
9701 "Do not export to next AS (well-known community)\n"
9702 "community number\n"
9703 "Do not send outside local AS (well-known community)\n"
9704 "Do not advertise to any peer (well-known community)\n"
9705 "Do not export to next AS (well-known community)\n"
9706 "Exact match of the communities")
9707
9708ALIAS (show_ip_bgp_community_exact,
9709 show_ip_bgp_community4_exact_cmd,
9710 "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",
9711 SHOW_STR
9712 IP_STR
9713 BGP_STR
9714 "Display routes matching the communities\n"
9715 "community number\n"
9716 "Do not send outside local AS (well-known community)\n"
9717 "Do not advertise to any peer (well-known community)\n"
9718 "Do not export to next AS (well-known community)\n"
9719 "community number\n"
9720 "Do not send outside local AS (well-known community)\n"
9721 "Do not advertise to any peer (well-known community)\n"
9722 "Do not export to next AS (well-known community)\n"
9723 "community number\n"
9724 "Do not send outside local AS (well-known community)\n"
9725 "Do not advertise to any peer (well-known community)\n"
9726 "Do not export to next AS (well-known community)\n"
9727 "community number\n"
9728 "Do not send outside local AS (well-known community)\n"
9729 "Do not advertise to any peer (well-known community)\n"
9730 "Do not export to next AS (well-known community)\n"
9731 "Exact match of the communities")
9732
9733DEFUN (show_ip_bgp_ipv4_community_exact,
9734 show_ip_bgp_ipv4_community_exact_cmd,
9735 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9736 SHOW_STR
9737 IP_STR
9738 BGP_STR
9739 "Address family\n"
9740 "Address Family modifier\n"
9741 "Address Family modifier\n"
9742 "Display routes matching the communities\n"
9743 "community number\n"
9744 "Do not send outside local AS (well-known community)\n"
9745 "Do not advertise to any peer (well-known community)\n"
9746 "Do not export to next AS (well-known community)\n"
9747 "Exact match of the communities")
9748{
9749 if (strncmp (argv[0], "m", 1) == 0)
9750 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9751
9752 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9753}
9754
9755ALIAS (show_ip_bgp_ipv4_community_exact,
9756 show_ip_bgp_ipv4_community2_exact_cmd,
9757 "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",
9758 SHOW_STR
9759 IP_STR
9760 BGP_STR
9761 "Address family\n"
9762 "Address Family modifier\n"
9763 "Address Family modifier\n"
9764 "Display routes matching the communities\n"
9765 "community number\n"
9766 "Do not send outside local AS (well-known community)\n"
9767 "Do not advertise to any peer (well-known community)\n"
9768 "Do not export to next AS (well-known community)\n"
9769 "community number\n"
9770 "Do not send outside local AS (well-known community)\n"
9771 "Do not advertise to any peer (well-known community)\n"
9772 "Do not export to next AS (well-known community)\n"
9773 "Exact match of the communities")
9774
9775ALIAS (show_ip_bgp_ipv4_community_exact,
9776 show_ip_bgp_ipv4_community3_exact_cmd,
9777 "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",
9778 SHOW_STR
9779 IP_STR
9780 BGP_STR
9781 "Address family\n"
9782 "Address Family modifier\n"
9783 "Address Family modifier\n"
9784 "Display routes matching the communities\n"
9785 "community number\n"
9786 "Do not send outside local AS (well-known community)\n"
9787 "Do not advertise to any peer (well-known community)\n"
9788 "Do not export to next AS (well-known community)\n"
9789 "community number\n"
9790 "Do not send outside local AS (well-known community)\n"
9791 "Do not advertise to any peer (well-known community)\n"
9792 "Do not export to next AS (well-known community)\n"
9793 "community number\n"
9794 "Do not send outside local AS (well-known community)\n"
9795 "Do not advertise to any peer (well-known community)\n"
9796 "Do not export to next AS (well-known community)\n"
9797 "Exact match of the communities")
9798
9799ALIAS (show_ip_bgp_ipv4_community_exact,
9800 show_ip_bgp_ipv4_community4_exact_cmd,
9801 "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",
9802 SHOW_STR
9803 IP_STR
9804 BGP_STR
9805 "Address family\n"
9806 "Address Family modifier\n"
9807 "Address Family modifier\n"
9808 "Display routes matching the communities\n"
9809 "community number\n"
9810 "Do not send outside local AS (well-known community)\n"
9811 "Do not advertise to any peer (well-known community)\n"
9812 "Do not export to next AS (well-known community)\n"
9813 "community number\n"
9814 "Do not send outside local AS (well-known community)\n"
9815 "Do not advertise to any peer (well-known community)\n"
9816 "Do not export to next AS (well-known community)\n"
9817 "community number\n"
9818 "Do not send outside local AS (well-known community)\n"
9819 "Do not advertise to any peer (well-known community)\n"
9820 "Do not export to next AS (well-known community)\n"
9821 "community number\n"
9822 "Do not send outside local AS (well-known community)\n"
9823 "Do not advertise to any peer (well-known community)\n"
9824 "Do not export to next AS (well-known community)\n"
9825 "Exact match of the communities")
9826
Lou Bergerf9b6c392016-01-12 13:42:09 -05009827DEFUN (show_bgp_community,
9828 show_bgp_community_cmd,
9829 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9830 SHOW_STR
9831 BGP_STR
9832 "Display routes matching the communities\n"
9833 "community number\n"
9834 "Do not send outside local AS (well-known community)\n"
9835 "Do not advertise to any peer (well-known community)\n"
9836 "Do not export to next AS (well-known community)\n")
9837{
9838 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9839}
9840
9841ALIAS (show_bgp_community,
9842 show_bgp_ipv6_community_cmd,
9843 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9844 SHOW_STR
9845 BGP_STR
9846 "Address family\n"
9847 "Display routes matching the communities\n"
9848 "community number\n"
9849 "Do not send outside local AS (well-known community)\n"
9850 "Do not advertise to any peer (well-known community)\n"
9851 "Do not export to next AS (well-known community)\n")
9852
9853ALIAS (show_bgp_community,
9854 show_bgp_community2_cmd,
9855 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9856 SHOW_STR
9857 BGP_STR
9858 "Display routes matching the communities\n"
9859 "community number\n"
9860 "Do not send outside local AS (well-known community)\n"
9861 "Do not advertise to any peer (well-known community)\n"
9862 "Do not export to next AS (well-known community)\n"
9863 "community number\n"
9864 "Do not send outside local AS (well-known community)\n"
9865 "Do not advertise to any peer (well-known community)\n"
9866 "Do not export to next AS (well-known community)\n")
9867
9868ALIAS (show_bgp_community,
9869 show_bgp_ipv6_community2_cmd,
9870 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9871 SHOW_STR
9872 BGP_STR
9873 "Address family\n"
9874 "Display routes matching the communities\n"
9875 "community number\n"
9876 "Do not send outside local AS (well-known community)\n"
9877 "Do not advertise to any peer (well-known community)\n"
9878 "Do not export to next AS (well-known community)\n"
9879 "community number\n"
9880 "Do not send outside local AS (well-known community)\n"
9881 "Do not advertise to any peer (well-known community)\n"
9882 "Do not export to next AS (well-known community)\n")
9883
9884ALIAS (show_bgp_community,
9885 show_bgp_community3_cmd,
9886 "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)",
9887 SHOW_STR
9888 BGP_STR
9889 "Display routes matching the communities\n"
9890 "community number\n"
9891 "Do not send outside local AS (well-known community)\n"
9892 "Do not advertise to any peer (well-known community)\n"
9893 "Do not export to next AS (well-known community)\n"
9894 "community number\n"
9895 "Do not send outside local AS (well-known community)\n"
9896 "Do not advertise to any peer (well-known community)\n"
9897 "Do not export to next AS (well-known community)\n"
9898 "community number\n"
9899 "Do not send outside local AS (well-known community)\n"
9900 "Do not advertise to any peer (well-known community)\n"
9901 "Do not export to next AS (well-known community)\n")
9902
9903ALIAS (show_bgp_community,
9904 show_bgp_ipv6_community3_cmd,
9905 "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)",
9906 SHOW_STR
9907 BGP_STR
9908 "Address family\n"
9909 "Display routes matching the communities\n"
9910 "community number\n"
9911 "Do not send outside local AS (well-known community)\n"
9912 "Do not advertise to any peer (well-known community)\n"
9913 "Do not export to next AS (well-known community)\n"
9914 "community number\n"
9915 "Do not send outside local AS (well-known community)\n"
9916 "Do not advertise to any peer (well-known community)\n"
9917 "Do not export to next AS (well-known community)\n"
9918 "community number\n"
9919 "Do not send outside local AS (well-known community)\n"
9920 "Do not advertise to any peer (well-known community)\n"
9921 "Do not export to next AS (well-known community)\n")
9922
9923ALIAS (show_bgp_community,
9924 show_bgp_community4_cmd,
9925 "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)",
9926 SHOW_STR
9927 BGP_STR
9928 "Display routes matching the communities\n"
9929 "community number\n"
9930 "Do not send outside local AS (well-known community)\n"
9931 "Do not advertise to any peer (well-known community)\n"
9932 "Do not export to next AS (well-known community)\n"
9933 "community number\n"
9934 "Do not send outside local AS (well-known community)\n"
9935 "Do not advertise to any peer (well-known community)\n"
9936 "Do not export to next AS (well-known community)\n"
9937 "community number\n"
9938 "Do not send outside local AS (well-known community)\n"
9939 "Do not advertise to any peer (well-known community)\n"
9940 "Do not export to next AS (well-known community)\n"
9941 "community number\n"
9942 "Do not send outside local AS (well-known community)\n"
9943 "Do not advertise to any peer (well-known community)\n"
9944 "Do not export to next AS (well-known community)\n")
9945
9946ALIAS (show_bgp_community,
9947 show_bgp_ipv6_community4_cmd,
9948 "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)",
9949 SHOW_STR
9950 BGP_STR
9951 "Address family\n"
9952 "Display routes matching the communities\n"
9953 "community number\n"
9954 "Do not send outside local AS (well-known community)\n"
9955 "Do not advertise to any peer (well-known community)\n"
9956 "Do not export to next AS (well-known community)\n"
9957 "community number\n"
9958 "Do not send outside local AS (well-known community)\n"
9959 "Do not advertise to any peer (well-known community)\n"
9960 "Do not export to next AS (well-known community)\n"
9961 "community number\n"
9962 "Do not send outside local AS (well-known community)\n"
9963 "Do not advertise to any peer (well-known community)\n"
9964 "Do not export to next AS (well-known community)\n"
9965 "community number\n"
9966 "Do not send outside local AS (well-known community)\n"
9967 "Do not advertise to any peer (well-known community)\n"
9968 "Do not export to next AS (well-known community)\n")
9969
9970/* old command */
9971DEFUN (show_ipv6_bgp_community,
9972 show_ipv6_bgp_community_cmd,
9973 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9974 SHOW_STR
9975 IPV6_STR
9976 BGP_STR
9977 "Display routes matching the communities\n"
9978 "community number\n"
9979 "Do not send outside local AS (well-known community)\n"
9980 "Do not advertise to any peer (well-known community)\n"
9981 "Do not export to next AS (well-known community)\n")
9982{
9983 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9984}
9985
9986/* old command */
9987ALIAS (show_ipv6_bgp_community,
9988 show_ipv6_bgp_community2_cmd,
9989 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9990 SHOW_STR
9991 IPV6_STR
9992 BGP_STR
9993 "Display routes matching the communities\n"
9994 "community number\n"
9995 "Do not send outside local AS (well-known community)\n"
9996 "Do not advertise to any peer (well-known community)\n"
9997 "Do not export to next AS (well-known community)\n"
9998 "community number\n"
9999 "Do not send outside local AS (well-known community)\n"
10000 "Do not advertise to any peer (well-known community)\n"
10001 "Do not export to next AS (well-known community)\n")
10002
10003/* old command */
10004ALIAS (show_ipv6_bgp_community,
10005 show_ipv6_bgp_community3_cmd,
10006 "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)",
10007 SHOW_STR
10008 IPV6_STR
10009 BGP_STR
10010 "Display routes matching the communities\n"
10011 "community number\n"
10012 "Do not send outside local AS (well-known community)\n"
10013 "Do not advertise to any peer (well-known community)\n"
10014 "Do not export to next AS (well-known community)\n"
10015 "community number\n"
10016 "Do not send outside local AS (well-known community)\n"
10017 "Do not advertise to any peer (well-known community)\n"
10018 "Do not export to next AS (well-known community)\n"
10019 "community number\n"
10020 "Do not send outside local AS (well-known community)\n"
10021 "Do not advertise to any peer (well-known community)\n"
10022 "Do not export to next AS (well-known community)\n")
10023
10024/* old command */
10025ALIAS (show_ipv6_bgp_community,
10026 show_ipv6_bgp_community4_cmd,
10027 "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)",
10028 SHOW_STR
10029 IPV6_STR
10030 BGP_STR
10031 "Display routes matching the communities\n"
10032 "community number\n"
10033 "Do not send outside local AS (well-known community)\n"
10034 "Do not advertise to any peer (well-known community)\n"
10035 "Do not export to next AS (well-known community)\n"
10036 "community number\n"
10037 "Do not send outside local AS (well-known community)\n"
10038 "Do not advertise to any peer (well-known community)\n"
10039 "Do not export to next AS (well-known community)\n"
10040 "community number\n"
10041 "Do not send outside local AS (well-known community)\n"
10042 "Do not advertise to any peer (well-known community)\n"
10043 "Do not export to next AS (well-known community)\n"
10044 "community number\n"
10045 "Do not send outside local AS (well-known community)\n"
10046 "Do not advertise to any peer (well-known community)\n"
10047 "Do not export to next AS (well-known community)\n")
10048
10049DEFUN (show_bgp_community_exact,
10050 show_bgp_community_exact_cmd,
10051 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10052 SHOW_STR
10053 BGP_STR
10054 "Display routes matching the communities\n"
10055 "community number\n"
10056 "Do not send outside local AS (well-known community)\n"
10057 "Do not advertise to any peer (well-known community)\n"
10058 "Do not export to next AS (well-known community)\n"
10059 "Exact match of the communities")
10060{
10061 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10062}
10063
10064ALIAS (show_bgp_community_exact,
10065 show_bgp_ipv6_community_exact_cmd,
10066 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10067 SHOW_STR
10068 BGP_STR
10069 "Address family\n"
10070 "Display routes matching the communities\n"
10071 "community number\n"
10072 "Do not send outside local AS (well-known community)\n"
10073 "Do not advertise to any peer (well-known community)\n"
10074 "Do not export to next AS (well-known community)\n"
10075 "Exact match of the communities")
10076
10077ALIAS (show_bgp_community_exact,
10078 show_bgp_community2_exact_cmd,
10079 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10080 SHOW_STR
10081 BGP_STR
10082 "Display routes matching the communities\n"
10083 "community number\n"
10084 "Do not send outside local AS (well-known community)\n"
10085 "Do not advertise to any peer (well-known community)\n"
10086 "Do not export to next AS (well-known community)\n"
10087 "community number\n"
10088 "Do not send outside local AS (well-known community)\n"
10089 "Do not advertise to any peer (well-known community)\n"
10090 "Do not export to next AS (well-known community)\n"
10091 "Exact match of the communities")
10092
10093ALIAS (show_bgp_community_exact,
10094 show_bgp_ipv6_community2_exact_cmd,
10095 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10096 SHOW_STR
10097 BGP_STR
10098 "Address family\n"
10099 "Display routes matching the communities\n"
10100 "community number\n"
10101 "Do not send outside local AS (well-known community)\n"
10102 "Do not advertise to any peer (well-known community)\n"
10103 "Do not export to next AS (well-known community)\n"
10104 "community number\n"
10105 "Do not send outside local AS (well-known community)\n"
10106 "Do not advertise to any peer (well-known community)\n"
10107 "Do not export to next AS (well-known community)\n"
10108 "Exact match of the communities")
10109
10110ALIAS (show_bgp_community_exact,
10111 show_bgp_community3_exact_cmd,
10112 "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",
10113 SHOW_STR
10114 BGP_STR
10115 "Display routes matching the communities\n"
10116 "community number\n"
10117 "Do not send outside local AS (well-known community)\n"
10118 "Do not advertise to any peer (well-known community)\n"
10119 "Do not export to next AS (well-known community)\n"
10120 "community number\n"
10121 "Do not send outside local AS (well-known community)\n"
10122 "Do not advertise to any peer (well-known community)\n"
10123 "Do not export to next AS (well-known community)\n"
10124 "community number\n"
10125 "Do not send outside local AS (well-known community)\n"
10126 "Do not advertise to any peer (well-known community)\n"
10127 "Do not export to next AS (well-known community)\n"
10128 "Exact match of the communities")
10129
10130ALIAS (show_bgp_community_exact,
10131 show_bgp_ipv6_community3_exact_cmd,
10132 "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",
10133 SHOW_STR
10134 BGP_STR
10135 "Address family\n"
10136 "Display routes matching the communities\n"
10137 "community number\n"
10138 "Do not send outside local AS (well-known community)\n"
10139 "Do not advertise to any peer (well-known community)\n"
10140 "Do not export to next AS (well-known community)\n"
10141 "community number\n"
10142 "Do not send outside local AS (well-known community)\n"
10143 "Do not advertise to any peer (well-known community)\n"
10144 "Do not export to next AS (well-known community)\n"
10145 "community number\n"
10146 "Do not send outside local AS (well-known community)\n"
10147 "Do not advertise to any peer (well-known community)\n"
10148 "Do not export to next AS (well-known community)\n"
10149 "Exact match of the communities")
10150
10151ALIAS (show_bgp_community_exact,
10152 show_bgp_community4_exact_cmd,
10153 "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",
10154 SHOW_STR
10155 BGP_STR
10156 "Display routes matching the communities\n"
10157 "community number\n"
10158 "Do not send outside local AS (well-known community)\n"
10159 "Do not advertise to any peer (well-known community)\n"
10160 "Do not export to next AS (well-known community)\n"
10161 "community number\n"
10162 "Do not send outside local AS (well-known community)\n"
10163 "Do not advertise to any peer (well-known community)\n"
10164 "Do not export to next AS (well-known community)\n"
10165 "community number\n"
10166 "Do not send outside local AS (well-known community)\n"
10167 "Do not advertise to any peer (well-known community)\n"
10168 "Do not export to next AS (well-known community)\n"
10169 "community number\n"
10170 "Do not send outside local AS (well-known community)\n"
10171 "Do not advertise to any peer (well-known community)\n"
10172 "Do not export to next AS (well-known community)\n"
10173 "Exact match of the communities")
10174
10175ALIAS (show_bgp_community_exact,
10176 show_bgp_ipv6_community4_exact_cmd,
10177 "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",
10178 SHOW_STR
10179 BGP_STR
10180 "Address family\n"
10181 "Display routes matching the communities\n"
10182 "community number\n"
10183 "Do not send outside local AS (well-known community)\n"
10184 "Do not advertise to any peer (well-known community)\n"
10185 "Do not export to next AS (well-known community)\n"
10186 "community number\n"
10187 "Do not send outside local AS (well-known community)\n"
10188 "Do not advertise to any peer (well-known community)\n"
10189 "Do not export to next AS (well-known community)\n"
10190 "community number\n"
10191 "Do not send outside local AS (well-known community)\n"
10192 "Do not advertise to any peer (well-known community)\n"
10193 "Do not export to next AS (well-known community)\n"
10194 "community number\n"
10195 "Do not send outside local AS (well-known community)\n"
10196 "Do not advertise to any peer (well-known community)\n"
10197 "Do not export to next AS (well-known community)\n"
10198 "Exact match of the communities")
10199
10200/* old command */
10201DEFUN (show_ipv6_bgp_community_exact,
10202 show_ipv6_bgp_community_exact_cmd,
10203 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10204 SHOW_STR
10205 IPV6_STR
10206 BGP_STR
10207 "Display routes matching the communities\n"
10208 "community number\n"
10209 "Do not send outside local AS (well-known community)\n"
10210 "Do not advertise to any peer (well-known community)\n"
10211 "Do not export to next AS (well-known community)\n"
10212 "Exact match of the communities")
10213{
10214 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10215}
10216
10217/* old command */
10218ALIAS (show_ipv6_bgp_community_exact,
10219 show_ipv6_bgp_community2_exact_cmd,
10220 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10221 SHOW_STR
10222 IPV6_STR
10223 BGP_STR
10224 "Display routes matching the communities\n"
10225 "community number\n"
10226 "Do not send outside local AS (well-known community)\n"
10227 "Do not advertise to any peer (well-known community)\n"
10228 "Do not export to next AS (well-known community)\n"
10229 "community number\n"
10230 "Do not send outside local AS (well-known community)\n"
10231 "Do not advertise to any peer (well-known community)\n"
10232 "Do not export to next AS (well-known community)\n"
10233 "Exact match of the communities")
10234
10235/* old command */
10236ALIAS (show_ipv6_bgp_community_exact,
10237 show_ipv6_bgp_community3_exact_cmd,
10238 "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",
10239 SHOW_STR
10240 IPV6_STR
10241 BGP_STR
10242 "Display routes matching the communities\n"
10243 "community number\n"
10244 "Do not send outside local AS (well-known community)\n"
10245 "Do not advertise to any peer (well-known community)\n"
10246 "Do not export to next AS (well-known community)\n"
10247 "community number\n"
10248 "Do not send outside local AS (well-known community)\n"
10249 "Do not advertise to any peer (well-known community)\n"
10250 "Do not export to next AS (well-known community)\n"
10251 "community number\n"
10252 "Do not send outside local AS (well-known community)\n"
10253 "Do not advertise to any peer (well-known community)\n"
10254 "Do not export to next AS (well-known community)\n"
10255 "Exact match of the communities")
10256
10257/* old command */
10258ALIAS (show_ipv6_bgp_community_exact,
10259 show_ipv6_bgp_community4_exact_cmd,
10260 "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",
10261 SHOW_STR
10262 IPV6_STR
10263 BGP_STR
10264 "Display routes matching the communities\n"
10265 "community number\n"
10266 "Do not send outside local AS (well-known community)\n"
10267 "Do not advertise to any peer (well-known community)\n"
10268 "Do not export to next AS (well-known community)\n"
10269 "community number\n"
10270 "Do not send outside local AS (well-known community)\n"
10271 "Do not advertise to any peer (well-known community)\n"
10272 "Do not export to next AS (well-known community)\n"
10273 "community number\n"
10274 "Do not send outside local AS (well-known community)\n"
10275 "Do not advertise to any peer (well-known community)\n"
10276 "Do not export to next AS (well-known community)\n"
10277 "community number\n"
10278 "Do not send outside local AS (well-known community)\n"
10279 "Do not advertise to any peer (well-known community)\n"
10280 "Do not export to next AS (well-known community)\n"
10281 "Exact match of the communities")
10282
10283/* old command */
10284DEFUN (show_ipv6_mbgp_community,
10285 show_ipv6_mbgp_community_cmd,
10286 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10287 SHOW_STR
10288 IPV6_STR
10289 MBGP_STR
10290 "Display routes matching the communities\n"
10291 "community number\n"
10292 "Do not send outside local AS (well-known community)\n"
10293 "Do not advertise to any peer (well-known community)\n"
10294 "Do not export to next AS (well-known community)\n")
10295{
10296 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
10297}
10298
10299/* old command */
10300ALIAS (show_ipv6_mbgp_community,
10301 show_ipv6_mbgp_community2_cmd,
10302 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10303 SHOW_STR
10304 IPV6_STR
10305 MBGP_STR
10306 "Display routes matching the communities\n"
10307 "community number\n"
10308 "Do not send outside local AS (well-known community)\n"
10309 "Do not advertise to any peer (well-known community)\n"
10310 "Do not export to next AS (well-known community)\n"
10311 "community number\n"
10312 "Do not send outside local AS (well-known community)\n"
10313 "Do not advertise to any peer (well-known community)\n"
10314 "Do not export to next AS (well-known community)\n")
10315
10316/* old command */
10317ALIAS (show_ipv6_mbgp_community,
10318 show_ipv6_mbgp_community3_cmd,
10319 "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)",
10320 SHOW_STR
10321 IPV6_STR
10322 MBGP_STR
10323 "Display routes matching the communities\n"
10324 "community number\n"
10325 "Do not send outside local AS (well-known community)\n"
10326 "Do not advertise to any peer (well-known community)\n"
10327 "Do not export to next AS (well-known community)\n"
10328 "community number\n"
10329 "Do not send outside local AS (well-known community)\n"
10330 "Do not advertise to any peer (well-known community)\n"
10331 "Do not export to next AS (well-known community)\n"
10332 "community number\n"
10333 "Do not send outside local AS (well-known community)\n"
10334 "Do not advertise to any peer (well-known community)\n"
10335 "Do not export to next AS (well-known community)\n")
10336
10337/* old command */
10338ALIAS (show_ipv6_mbgp_community,
10339 show_ipv6_mbgp_community4_cmd,
10340 "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)",
10341 SHOW_STR
10342 IPV6_STR
10343 MBGP_STR
10344 "Display routes matching the communities\n"
10345 "community number\n"
10346 "Do not send outside local AS (well-known community)\n"
10347 "Do not advertise to any peer (well-known community)\n"
10348 "Do not export to next AS (well-known community)\n"
10349 "community number\n"
10350 "Do not send outside local AS (well-known community)\n"
10351 "Do not advertise to any peer (well-known community)\n"
10352 "Do not export to next AS (well-known community)\n"
10353 "community number\n"
10354 "Do not send outside local AS (well-known community)\n"
10355 "Do not advertise to any peer (well-known community)\n"
10356 "Do not export to next AS (well-known community)\n"
10357 "community number\n"
10358 "Do not send outside local AS (well-known community)\n"
10359 "Do not advertise to any peer (well-known community)\n"
10360 "Do not export to next AS (well-known community)\n")
10361
10362/* old command */
10363DEFUN (show_ipv6_mbgp_community_exact,
10364 show_ipv6_mbgp_community_exact_cmd,
10365 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10366 SHOW_STR
10367 IPV6_STR
10368 MBGP_STR
10369 "Display routes matching the communities\n"
10370 "community number\n"
10371 "Do not send outside local AS (well-known community)\n"
10372 "Do not advertise to any peer (well-known community)\n"
10373 "Do not export to next AS (well-known community)\n"
10374 "Exact match of the communities")
10375{
10376 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10377}
10378
10379/* old command */
10380ALIAS (show_ipv6_mbgp_community_exact,
10381 show_ipv6_mbgp_community2_exact_cmd,
10382 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10383 SHOW_STR
10384 IPV6_STR
10385 MBGP_STR
10386 "Display routes matching the communities\n"
10387 "community number\n"
10388 "Do not send outside local AS (well-known community)\n"
10389 "Do not advertise to any peer (well-known community)\n"
10390 "Do not export to next AS (well-known community)\n"
10391 "community number\n"
10392 "Do not send outside local AS (well-known community)\n"
10393 "Do not advertise to any peer (well-known community)\n"
10394 "Do not export to next AS (well-known community)\n"
10395 "Exact match of the communities")
10396
10397/* old command */
10398ALIAS (show_ipv6_mbgp_community_exact,
10399 show_ipv6_mbgp_community3_exact_cmd,
10400 "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",
10401 SHOW_STR
10402 IPV6_STR
10403 MBGP_STR
10404 "Display routes matching the communities\n"
10405 "community number\n"
10406 "Do not send outside local AS (well-known community)\n"
10407 "Do not advertise to any peer (well-known community)\n"
10408 "Do not export to next AS (well-known community)\n"
10409 "community number\n"
10410 "Do not send outside local AS (well-known community)\n"
10411 "Do not advertise to any peer (well-known community)\n"
10412 "Do not export to next AS (well-known community)\n"
10413 "community number\n"
10414 "Do not send outside local AS (well-known community)\n"
10415 "Do not advertise to any peer (well-known community)\n"
10416 "Do not export to next AS (well-known community)\n"
10417 "Exact match of the communities")
10418
10419/* old command */
10420ALIAS (show_ipv6_mbgp_community_exact,
10421 show_ipv6_mbgp_community4_exact_cmd,
10422 "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",
10423 SHOW_STR
10424 IPV6_STR
10425 MBGP_STR
10426 "Display routes matching the communities\n"
10427 "community number\n"
10428 "Do not send outside local AS (well-known community)\n"
10429 "Do not advertise to any peer (well-known community)\n"
10430 "Do not export to next AS (well-known community)\n"
10431 "community number\n"
10432 "Do not send outside local AS (well-known community)\n"
10433 "Do not advertise to any peer (well-known community)\n"
10434 "Do not export to next AS (well-known community)\n"
10435 "community number\n"
10436 "Do not send outside local AS (well-known community)\n"
10437 "Do not advertise to any peer (well-known community)\n"
10438 "Do not export to next AS (well-known community)\n"
10439 "community number\n"
10440 "Do not send outside local AS (well-known community)\n"
10441 "Do not advertise to any peer (well-known community)\n"
10442 "Do not export to next AS (well-known community)\n"
10443 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010444
Lou Berger651b4022016-01-12 13:42:07 -050010445DEFUN (show_bgp_ipv4_community,
10446 show_bgp_ipv4_community_cmd,
10447 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010448 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010449 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010450 IP_STR
paul718e3742002-12-13 20:15:29 +000010451 "Display routes matching the communities\n"
10452 "community number\n"
10453 "Do not send outside local AS (well-known community)\n"
10454 "Do not advertise to any peer (well-known community)\n"
10455 "Do not export to next AS (well-known community)\n")
10456{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010457 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010458}
10459
Lou Berger651b4022016-01-12 13:42:07 -050010460ALIAS (show_bgp_ipv4_community,
10461 show_bgp_ipv4_community2_cmd,
10462 "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 +000010463 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010464 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010465 IP_STR
paul718e3742002-12-13 20:15:29 +000010466 "Display routes matching the communities\n"
10467 "community number\n"
10468 "Do not send outside local AS (well-known community)\n"
10469 "Do not advertise to any peer (well-known community)\n"
10470 "Do not export to next AS (well-known community)\n"
10471 "community number\n"
10472 "Do not send outside local AS (well-known community)\n"
10473 "Do not advertise to any peer (well-known community)\n"
10474 "Do not export to next AS (well-known community)\n")
10475
Lou Berger651b4022016-01-12 13:42:07 -050010476ALIAS (show_bgp_ipv4_community,
10477 show_bgp_ipv4_community3_cmd,
10478 "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 +000010479 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010480 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010481 IP_STR
paul718e3742002-12-13 20:15:29 +000010482 "Display routes matching the communities\n"
10483 "community number\n"
10484 "Do not send outside local AS (well-known community)\n"
10485 "Do not advertise to any peer (well-known community)\n"
10486 "Do not export to next AS (well-known community)\n"
10487 "community number\n"
10488 "Do not send outside local AS (well-known community)\n"
10489 "Do not advertise to any peer (well-known community)\n"
10490 "Do not export to next AS (well-known community)\n"
10491 "community number\n"
10492 "Do not send outside local AS (well-known community)\n"
10493 "Do not advertise to any peer (well-known community)\n"
10494 "Do not export to next AS (well-known community)\n")
10495
Lou Berger651b4022016-01-12 13:42:07 -050010496ALIAS (show_bgp_ipv4_community,
10497 show_bgp_ipv4_community4_cmd,
10498 "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 +000010499 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010500 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010501 IP_STR
paul718e3742002-12-13 20:15:29 +000010502 "Display routes matching the communities\n"
10503 "community number\n"
10504 "Do not send outside local AS (well-known community)\n"
10505 "Do not advertise to any peer (well-known community)\n"
10506 "Do not export to next AS (well-known community)\n"
10507 "community number\n"
10508 "Do not send outside local AS (well-known community)\n"
10509 "Do not advertise to any peer (well-known community)\n"
10510 "Do not export to next AS (well-known community)\n"
10511 "community number\n"
10512 "Do not send outside local AS (well-known community)\n"
10513 "Do not advertise to any peer (well-known community)\n"
10514 "Do not export to next AS (well-known community)\n"
10515 "community number\n"
10516 "Do not send outside local AS (well-known community)\n"
10517 "Do not advertise to any peer (well-known community)\n"
10518 "Do not export to next AS (well-known community)\n")
10519
Lou Berger651b4022016-01-12 13:42:07 -050010520DEFUN (show_bgp_ipv4_safi_community,
10521 show_bgp_ipv4_safi_community_cmd,
10522 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010523 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010524 BGP_STR
10525 "Address family\n"
10526 "Address Family modifier\n"
10527 "Address Family modifier\n"
10528 "Display routes matching the communities\n"
10529 "community number\n"
10530 "Do not send outside local AS (well-known community)\n"
10531 "Do not advertise to any peer (well-known community)\n"
10532 "Do not export to next AS (well-known community)\n")
10533{
10534 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010535 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010536
Michael Lambert95cbbd22010-07-23 14:43:04 -040010537 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010538}
10539
Lou Berger651b4022016-01-12 13:42:07 -050010540ALIAS (show_bgp_ipv4_safi_community,
10541 show_bgp_ipv4_safi_community2_cmd,
10542 "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 +000010543 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010544 BGP_STR
10545 "Address family\n"
10546 "Address Family modifier\n"
10547 "Address Family modifier\n"
10548 "Display routes matching the communities\n"
10549 "community number\n"
10550 "Do not send outside local AS (well-known community)\n"
10551 "Do not advertise to any peer (well-known community)\n"
10552 "Do not export to next AS (well-known community)\n"
10553 "community number\n"
10554 "Do not send outside local AS (well-known community)\n"
10555 "Do not advertise to any peer (well-known community)\n"
10556 "Do not export to next AS (well-known community)\n")
10557
Lou Berger651b4022016-01-12 13:42:07 -050010558ALIAS (show_bgp_ipv4_safi_community,
10559 show_bgp_ipv4_safi_community3_cmd,
10560 "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 +000010561 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010562 BGP_STR
10563 "Address family\n"
10564 "Address Family modifier\n"
10565 "Address Family modifier\n"
10566 "Display routes matching the communities\n"
10567 "community number\n"
10568 "Do not send outside local AS (well-known community)\n"
10569 "Do not advertise to any peer (well-known community)\n"
10570 "Do not export to next AS (well-known community)\n"
10571 "community number\n"
10572 "Do not send outside local AS (well-known community)\n"
10573 "Do not advertise to any peer (well-known community)\n"
10574 "Do not export to next AS (well-known community)\n"
10575 "community number\n"
10576 "Do not send outside local AS (well-known community)\n"
10577 "Do not advertise to any peer (well-known community)\n"
10578 "Do not export to next AS (well-known community)\n")
10579
Lou Berger651b4022016-01-12 13:42:07 -050010580ALIAS (show_bgp_ipv4_safi_community,
10581 show_bgp_ipv4_safi_community4_cmd,
10582 "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 +000010583 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010584 BGP_STR
10585 "Address family\n"
10586 "Address Family modifier\n"
10587 "Address Family modifier\n"
10588 "Display routes matching the communities\n"
10589 "community number\n"
10590 "Do not send outside local AS (well-known community)\n"
10591 "Do not advertise to any peer (well-known community)\n"
10592 "Do not export to next AS (well-known community)\n"
10593 "community number\n"
10594 "Do not send outside local AS (well-known community)\n"
10595 "Do not advertise to any peer (well-known community)\n"
10596 "Do not export to next AS (well-known community)\n"
10597 "community number\n"
10598 "Do not send outside local AS (well-known community)\n"
10599 "Do not advertise to any peer (well-known community)\n"
10600 "Do not export to next AS (well-known community)\n"
10601 "community number\n"
10602 "Do not send outside local AS (well-known community)\n"
10603 "Do not advertise to any peer (well-known community)\n"
10604 "Do not export to next AS (well-known community)\n")
10605
Michael Lambert95cbbd22010-07-23 14:43:04 -040010606DEFUN (show_bgp_view_afi_safi_community_all,
10607 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010608 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010609 SHOW_STR
10610 BGP_STR
10611 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010612 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010613 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010614 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010615 "Address Family modifier\n"
10616 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010617 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010618{
10619 int afi;
10620 int safi;
10621 struct bgp *bgp;
10622
10623 /* BGP structure lookup. */
10624 bgp = bgp_lookup_by_name (argv[0]);
10625 if (bgp == NULL)
10626 {
10627 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10628 return CMD_WARNING;
10629 }
10630
Michael Lambert95cbbd22010-07-23 14:43:04 -040010631 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10632 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010633 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10634}
10635
10636DEFUN (show_bgp_view_afi_safi_community,
10637 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010638 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010639 SHOW_STR
10640 BGP_STR
10641 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010642 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010643 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010644 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010645 "Address family modifier\n"
10646 "Address family modifier\n"
10647 "Display routes matching the communities\n"
10648 "community number\n"
10649 "Do not send outside local AS (well-known community)\n"
10650 "Do not advertise to any peer (well-known community)\n"
10651 "Do not export to next AS (well-known community)\n")
10652{
10653 int afi;
10654 int safi;
10655
Michael Lambert95cbbd22010-07-23 14:43:04 -040010656 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10657 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10658 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010659}
10660
10661ALIAS (show_bgp_view_afi_safi_community,
10662 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010663 "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 -040010664 SHOW_STR
10665 BGP_STR
10666 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010667 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010668 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010669 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010670 "Address family modifier\n"
10671 "Address family modifier\n"
10672 "Display routes matching the communities\n"
10673 "community number\n"
10674 "Do not send outside local AS (well-known community)\n"
10675 "Do not advertise to any peer (well-known community)\n"
10676 "Do not export to next AS (well-known community)\n"
10677 "community number\n"
10678 "Do not send outside local AS (well-known community)\n"
10679 "Do not advertise to any peer (well-known community)\n"
10680 "Do not export to next AS (well-known community)\n")
10681
10682ALIAS (show_bgp_view_afi_safi_community,
10683 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010684 "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 -040010685 SHOW_STR
10686 BGP_STR
10687 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010688 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010689 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010690 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010691 "Address family modifier\n"
10692 "Address family modifier\n"
10693 "Display routes matching the communities\n"
10694 "community number\n"
10695 "Do not send outside local AS (well-known community)\n"
10696 "Do not advertise to any peer (well-known community)\n"
10697 "Do not export to next AS (well-known community)\n"
10698 "community number\n"
10699 "Do not send outside local AS (well-known community)\n"
10700 "Do not advertise to any peer (well-known community)\n"
10701 "Do not export to next AS (well-known community)\n"
10702 "community number\n"
10703 "Do not send outside local AS (well-known community)\n"
10704 "Do not advertise to any peer (well-known community)\n"
10705 "Do not export to next AS (well-known community)\n")
10706
10707ALIAS (show_bgp_view_afi_safi_community,
10708 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010709 "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 -040010710 SHOW_STR
10711 BGP_STR
10712 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010713 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010714 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010715 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010716 "Address family modifier\n"
10717 "Address family modifier\n"
10718 "Display routes matching the communities\n"
10719 "community number\n"
10720 "Do not send outside local AS (well-known community)\n"
10721 "Do not advertise to any peer (well-known community)\n"
10722 "Do not export to next AS (well-known community)\n"
10723 "community number\n"
10724 "Do not send outside local AS (well-known community)\n"
10725 "Do not advertise to any peer (well-known community)\n"
10726 "Do not export to next AS (well-known community)\n"
10727 "community number\n"
10728 "Do not send outside local AS (well-known community)\n"
10729 "Do not advertise to any peer (well-known community)\n"
10730 "Do not export to next AS (well-known community)\n"
10731 "community number\n"
10732 "Do not send outside local AS (well-known community)\n"
10733 "Do not advertise to any peer (well-known community)\n"
10734 "Do not export to next AS (well-known community)\n")
10735
Lou Berger651b4022016-01-12 13:42:07 -050010736DEFUN (show_bgp_ipv4_community_exact,
10737 show_bgp_ipv4_community_exact_cmd,
10738 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010739 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010740 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010741 IP_STR
paul718e3742002-12-13 20:15:29 +000010742 "Display routes matching the communities\n"
10743 "community number\n"
10744 "Do not send outside local AS (well-known community)\n"
10745 "Do not advertise to any peer (well-known community)\n"
10746 "Do not export to next AS (well-known community)\n"
10747 "Exact match of the communities")
10748{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010749 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010750}
10751
Lou Berger651b4022016-01-12 13:42:07 -050010752ALIAS (show_bgp_ipv4_community_exact,
10753 show_bgp_ipv4_community2_exact_cmd,
10754 "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 +000010755 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010756 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010757 IP_STR
paul718e3742002-12-13 20:15:29 +000010758 "Display routes matching the communities\n"
10759 "community number\n"
10760 "Do not send outside local AS (well-known community)\n"
10761 "Do not advertise to any peer (well-known community)\n"
10762 "Do not export to next AS (well-known community)\n"
10763 "community number\n"
10764 "Do not send outside local AS (well-known community)\n"
10765 "Do not advertise to any peer (well-known community)\n"
10766 "Do not export to next AS (well-known community)\n"
10767 "Exact match of the communities")
10768
Lou Berger651b4022016-01-12 13:42:07 -050010769ALIAS (show_bgp_ipv4_community_exact,
10770 show_bgp_ipv4_community3_exact_cmd,
10771 "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 +000010772 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010773 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010774 IP_STR
paul718e3742002-12-13 20:15:29 +000010775 "Display routes matching the communities\n"
10776 "community number\n"
10777 "Do not send outside local AS (well-known community)\n"
10778 "Do not advertise to any peer (well-known community)\n"
10779 "Do not export to next AS (well-known community)\n"
10780 "community number\n"
10781 "Do not send outside local AS (well-known community)\n"
10782 "Do not advertise to any peer (well-known community)\n"
10783 "Do not export to next AS (well-known community)\n"
10784 "community number\n"
10785 "Do not send outside local AS (well-known community)\n"
10786 "Do not advertise to any peer (well-known community)\n"
10787 "Do not export to next AS (well-known community)\n"
10788 "Exact match of the communities")
10789
Lou Berger651b4022016-01-12 13:42:07 -050010790ALIAS (show_bgp_ipv4_community_exact,
10791 show_bgp_ipv4_community4_exact_cmd,
10792 "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 +000010793 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010794 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010795 IP_STR
paul718e3742002-12-13 20:15:29 +000010796 "Display routes matching the communities\n"
10797 "community number\n"
10798 "Do not send outside local AS (well-known community)\n"
10799 "Do not advertise to any peer (well-known community)\n"
10800 "Do not export to next AS (well-known community)\n"
10801 "community number\n"
10802 "Do not send outside local AS (well-known community)\n"
10803 "Do not advertise to any peer (well-known community)\n"
10804 "Do not export to next AS (well-known community)\n"
10805 "community number\n"
10806 "Do not send outside local AS (well-known community)\n"
10807 "Do not advertise to any peer (well-known community)\n"
10808 "Do not export to next AS (well-known community)\n"
10809 "community number\n"
10810 "Do not send outside local AS (well-known community)\n"
10811 "Do not advertise to any peer (well-known community)\n"
10812 "Do not export to next AS (well-known community)\n"
10813 "Exact match of the communities")
10814
Lou Berger651b4022016-01-12 13:42:07 -050010815DEFUN (show_bgp_ipv4_safi_community4_exact,
10816 show_bgp_ipv4_safi_community_exact_cmd,
10817 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010818 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010819 BGP_STR
10820 "Address family\n"
10821 "Address Family modifier\n"
10822 "Address Family modifier\n"
10823 "Display routes matching the communities\n"
10824 "community number\n"
10825 "Do not send outside local AS (well-known community)\n"
10826 "Do not advertise to any peer (well-known community)\n"
10827 "Do not export to next AS (well-known community)\n"
10828 "Exact match of the communities")
10829{
10830 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010831 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010832
Michael Lambert95cbbd22010-07-23 14:43:04 -040010833 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010834}
10835
Lou Berger651b4022016-01-12 13:42:07 -050010836ALIAS (show_bgp_ipv4_safi_community4_exact,
10837 show_bgp_ipv4_safi_community2_exact_cmd,
10838 "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 +000010839 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010840 BGP_STR
10841 "Address family\n"
10842 "Address Family modifier\n"
10843 "Address Family modifier\n"
10844 "Display routes matching the communities\n"
10845 "community number\n"
10846 "Do not send outside local AS (well-known community)\n"
10847 "Do not advertise to any peer (well-known community)\n"
10848 "Do not export to next AS (well-known community)\n"
10849 "community number\n"
10850 "Do not send outside local AS (well-known community)\n"
10851 "Do not advertise to any peer (well-known community)\n"
10852 "Do not export to next AS (well-known community)\n"
10853 "Exact match of the communities")
10854
Lou Berger651b4022016-01-12 13:42:07 -050010855ALIAS (show_bgp_ipv4_safi_community4_exact,
10856 show_bgp_ipv4_safi_community3_exact_cmd,
10857 "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 +000010858 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010859 BGP_STR
10860 "Address family\n"
10861 "Address Family modifier\n"
10862 "Address Family modifier\n"
10863 "Display routes matching the communities\n"
10864 "community number\n"
10865 "Do not send outside local AS (well-known community)\n"
10866 "Do not advertise to any peer (well-known community)\n"
10867 "Do not export to next AS (well-known community)\n"
10868 "community number\n"
10869 "Do not send outside local AS (well-known community)\n"
10870 "Do not advertise to any peer (well-known community)\n"
10871 "Do not export to next AS (well-known community)\n"
10872 "community number\n"
10873 "Do not send outside local AS (well-known community)\n"
10874 "Do not advertise to any peer (well-known community)\n"
10875 "Do not export to next AS (well-known community)\n"
10876 "Exact match of the communities")
10877
Lou Berger651b4022016-01-12 13:42:07 -050010878ALIAS (show_bgp_ipv4_safi_community4_exact,
10879 show_bgp_ipv4_safi_community4_exact_cmd,
10880 "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 +000010881 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010882 BGP_STR
10883 "Address family\n"
10884 "Address Family modifier\n"
10885 "Address Family modifier\n"
10886 "Display routes matching the communities\n"
10887 "community number\n"
10888 "Do not send outside local AS (well-known community)\n"
10889 "Do not advertise to any peer (well-known community)\n"
10890 "Do not export to next AS (well-known community)\n"
10891 "community number\n"
10892 "Do not send outside local AS (well-known community)\n"
10893 "Do not advertise to any peer (well-known community)\n"
10894 "Do not export to next AS (well-known community)\n"
10895 "community number\n"
10896 "Do not send outside local AS (well-known community)\n"
10897 "Do not advertise to any peer (well-known community)\n"
10898 "Do not export to next AS (well-known community)\n"
10899 "community number\n"
10900 "Do not send outside local AS (well-known community)\n"
10901 "Do not advertise to any peer (well-known community)\n"
10902 "Do not export to next AS (well-known community)\n"
10903 "Exact match of the communities")
10904
Lou Bergerf9b6c392016-01-12 13:42:09 -050010905DEFUN (show_bgp_ipv6_safi_community,
10906 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010907 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010908 SHOW_STR
10909 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010910 "Address family\n"
10911 "Address family modifier\n"
10912 "Address family modifier\n"
10913 "Address family modifier\n"
10914 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010915 "Display routes matching the communities\n"
10916 "community number\n"
10917 "Do not send outside local AS (well-known community)\n"
10918 "Do not advertise to any peer (well-known community)\n"
10919 "Do not export to next AS (well-known community)\n")
10920{
Lou Berger651b4022016-01-12 13:42:07 -050010921 safi_t safi;
10922
10923 if (bgp_parse_safi(argv[0], &safi)) {
10924 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10925 return CMD_WARNING;
10926 }
10927 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010928}
10929
Lou Bergerf9b6c392016-01-12 13:42:09 -050010930ALIAS (show_bgp_ipv6_safi_community,
10931 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010932 "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 +000010933 SHOW_STR
10934 BGP_STR
10935 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010936 "Address family modifier\n"
10937 "Address family modifier\n"
10938 "Address family modifier\n"
10939 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010940 "Display routes matching the communities\n"
10941 "community number\n"
10942 "Do not send outside local AS (well-known community)\n"
10943 "Do not advertise to any peer (well-known community)\n"
10944 "Do not export to next AS (well-known community)\n"
10945 "community number\n"
10946 "Do not send outside local AS (well-known community)\n"
10947 "Do not advertise to any peer (well-known community)\n"
10948 "Do not export to next AS (well-known community)\n")
10949
Lou Bergerf9b6c392016-01-12 13:42:09 -050010950ALIAS (show_bgp_ipv6_safi_community,
10951 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010952 "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 +000010953 SHOW_STR
10954 BGP_STR
10955 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010956 "Address family modifier\n"
10957 "Address family modifier\n"
10958 "Address family modifier\n"
10959 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010960 "Display routes matching the communities\n"
10961 "community number\n"
10962 "Do not send outside local AS (well-known community)\n"
10963 "Do not advertise to any peer (well-known community)\n"
10964 "Do not export to next AS (well-known community)\n"
10965 "community number\n"
10966 "Do not send outside local AS (well-known community)\n"
10967 "Do not advertise to any peer (well-known community)\n"
10968 "Do not export to next AS (well-known community)\n"
10969 "community number\n"
10970 "Do not send outside local AS (well-known community)\n"
10971 "Do not advertise to any peer (well-known community)\n"
10972 "Do not export to next AS (well-known community)\n")
10973
Lou Bergerf9b6c392016-01-12 13:42:09 -050010974ALIAS (show_bgp_ipv6_safi_community,
10975 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010976 "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 +000010977 SHOW_STR
10978 BGP_STR
10979 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010980 "Address family modifier\n"
10981 "Address family modifier\n"
10982 "Address family modifier\n"
10983 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010984 "Display routes matching the communities\n"
10985 "community number\n"
10986 "Do not send outside local AS (well-known community)\n"
10987 "Do not advertise to any peer (well-known community)\n"
10988 "Do not export to next AS (well-known community)\n"
10989 "community number\n"
10990 "Do not send outside local AS (well-known community)\n"
10991 "Do not advertise to any peer (well-known community)\n"
10992 "Do not export to next AS (well-known community)\n"
10993 "community number\n"
10994 "Do not send outside local AS (well-known community)\n"
10995 "Do not advertise to any peer (well-known community)\n"
10996 "Do not export to next AS (well-known community)\n"
10997 "community number\n"
10998 "Do not send outside local AS (well-known community)\n"
10999 "Do not advertise to any peer (well-known community)\n"
11000 "Do not export to next AS (well-known community)\n")
11001
paul718e3742002-12-13 20:15:29 +000011002
Lou Bergerf9b6c392016-01-12 13:42:09 -050011003DEFUN (show_bgp_ipv6_safi_community_exact,
11004 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011005 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000011006 SHOW_STR
11007 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011008 "Address family\n"
11009 "Address family modifier\n"
11010 "Address family modifier\n"
11011 "Address family modifier\n"
11012 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011013 "Display routes matching the communities\n"
11014 "community number\n"
11015 "Do not send outside local AS (well-known community)\n"
11016 "Do not advertise to any peer (well-known community)\n"
11017 "Do not export to next AS (well-known community)\n"
11018 "Exact match of the communities")
11019{
Lou Berger651b4022016-01-12 13:42:07 -050011020 safi_t safi;
11021
11022 if (bgp_parse_safi(argv[0], &safi)) {
11023 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11024 return CMD_WARNING;
11025 }
11026 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011027}
11028
paul718e3742002-12-13 20:15:29 +000011029
11030ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011031 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011032 "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 +000011033 SHOW_STR
11034 BGP_STR
11035 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011036 "Address family modifier\n"
11037 "Address family modifier\n"
11038 "Address family modifier\n"
11039 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011040 "Display routes matching the communities\n"
11041 "community number\n"
11042 "Do not send outside local AS (well-known community)\n"
11043 "Do not advertise to any peer (well-known community)\n"
11044 "Do not export to next AS (well-known community)\n"
11045 "community number\n"
11046 "Do not send outside local AS (well-known community)\n"
11047 "Do not advertise to any peer (well-known community)\n"
11048 "Do not export to next AS (well-known community)\n"
11049 "Exact match of the communities")
11050
11051ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011052 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011053 "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 +000011054 SHOW_STR
11055 BGP_STR
11056 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011057 "Address family modifier\n"
11058 "Address family modifier\n"
11059 "Address family modifier\n"
11060 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011061 "Display routes matching the communities\n"
11062 "community number\n"
11063 "Do not send outside local AS (well-known community)\n"
11064 "Do not advertise to any peer (well-known community)\n"
11065 "Do not export to next AS (well-known community)\n"
11066 "community number\n"
11067 "Do not send outside local AS (well-known community)\n"
11068 "Do not advertise to any peer (well-known community)\n"
11069 "Do not export to next AS (well-known community)\n"
11070 "community number\n"
11071 "Do not send outside local AS (well-known community)\n"
11072 "Do not advertise to any peer (well-known community)\n"
11073 "Do not export to next AS (well-known community)\n"
11074 "Exact match of the communities")
11075
11076ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011077 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011078 "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 +000011079 SHOW_STR
11080 BGP_STR
11081 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011082 "Address family modifier\n"
11083 "Address family modifier\n"
11084 "Address family modifier\n"
11085 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011086 "Display routes matching the communities\n"
11087 "community number\n"
11088 "Do not send outside local AS (well-known community)\n"
11089 "Do not advertise to any peer (well-known community)\n"
11090 "Do not export to next AS (well-known community)\n"
11091 "community number\n"
11092 "Do not send outside local AS (well-known community)\n"
11093 "Do not advertise to any peer (well-known community)\n"
11094 "Do not export to next AS (well-known community)\n"
11095 "community number\n"
11096 "Do not send outside local AS (well-known community)\n"
11097 "Do not advertise to any peer (well-known community)\n"
11098 "Do not export to next AS (well-known community)\n"
11099 "community number\n"
11100 "Do not send outside local AS (well-known community)\n"
11101 "Do not advertise to any peer (well-known community)\n"
11102 "Do not export to next AS (well-known community)\n"
11103 "Exact match of the communities")
11104
paul94f2b392005-06-28 12:44:16 +000011105static int
paulfd79ac92004-10-13 05:06:08 +000011106bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040011107 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000011108{
11109 struct community_list *list;
11110
hassofee6e4e2005-02-02 16:29:31 +000011111 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000011112 if (list == NULL)
11113 {
11114 vty_out (vty, "%% %s is not a valid community-list name%s", com,
11115 VTY_NEWLINE);
11116 return CMD_WARNING;
11117 }
11118
ajs5a646652004-11-05 01:25:55 +000011119 return bgp_show (vty, NULL, afi, safi,
11120 (exact ? bgp_show_type_community_list_exact :
11121 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000011122}
11123
Lou Bergerf9b6c392016-01-12 13:42:09 -050011124DEFUN (show_ip_bgp_community_list,
11125 show_ip_bgp_community_list_cmd,
11126 "show ip bgp community-list (<1-500>|WORD)",
11127 SHOW_STR
11128 IP_STR
11129 BGP_STR
11130 "Display routes matching the community-list\n"
11131 "community-list number\n"
11132 "community-list name\n")
11133{
11134 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11135}
11136
11137DEFUN (show_ip_bgp_ipv4_community_list,
11138 show_ip_bgp_ipv4_community_list_cmd,
11139 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11140 SHOW_STR
11141 IP_STR
11142 BGP_STR
11143 "Address family\n"
11144 "Address Family modifier\n"
11145 "Address Family modifier\n"
11146 "Display routes matching the community-list\n"
11147 "community-list number\n"
11148 "community-list name\n")
11149{
11150 if (strncmp (argv[0], "m", 1) == 0)
11151 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11152
11153 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11154}
11155
11156DEFUN (show_ip_bgp_community_list_exact,
11157 show_ip_bgp_community_list_exact_cmd,
11158 "show ip bgp community-list (<1-500>|WORD) exact-match",
11159 SHOW_STR
11160 IP_STR
11161 BGP_STR
11162 "Display routes matching the community-list\n"
11163 "community-list number\n"
11164 "community-list name\n"
11165 "Exact match of the communities\n")
11166{
11167 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11168}
11169
11170DEFUN (show_ip_bgp_ipv4_community_list_exact,
11171 show_ip_bgp_ipv4_community_list_exact_cmd,
11172 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11173 SHOW_STR
11174 IP_STR
11175 BGP_STR
11176 "Address family\n"
11177 "Address Family modifier\n"
11178 "Address Family modifier\n"
11179 "Display routes matching the community-list\n"
11180 "community-list number\n"
11181 "community-list name\n"
11182 "Exact match of the communities\n")
11183{
11184 if (strncmp (argv[0], "m", 1) == 0)
11185 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11186
11187 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11188}
11189
Lou Bergerf9b6c392016-01-12 13:42:09 -050011190DEFUN (show_bgp_community_list,
11191 show_bgp_community_list_cmd,
11192 "show bgp community-list (<1-500>|WORD)",
11193 SHOW_STR
11194 BGP_STR
11195 "Display routes matching the community-list\n"
11196 "community-list number\n"
11197 "community-list name\n")
11198{
11199 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11200}
11201
11202ALIAS (show_bgp_community_list,
11203 show_bgp_ipv6_community_list_cmd,
11204 "show bgp ipv6 community-list (<1-500>|WORD)",
11205 SHOW_STR
11206 BGP_STR
11207 "Address family\n"
11208 "Display routes matching the community-list\n"
11209 "community-list number\n"
11210 "community-list name\n")
11211
11212/* old command */
11213DEFUN (show_ipv6_bgp_community_list,
11214 show_ipv6_bgp_community_list_cmd,
11215 "show ipv6 bgp community-list WORD",
11216 SHOW_STR
11217 IPV6_STR
11218 BGP_STR
11219 "Display routes matching the community-list\n"
11220 "community-list name\n")
11221{
11222 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11223}
11224
11225/* old command */
11226DEFUN (show_ipv6_mbgp_community_list,
11227 show_ipv6_mbgp_community_list_cmd,
11228 "show ipv6 mbgp community-list WORD",
11229 SHOW_STR
11230 IPV6_STR
11231 MBGP_STR
11232 "Display routes matching the community-list\n"
11233 "community-list name\n")
11234{
11235 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
11236}
11237
11238DEFUN (show_bgp_community_list_exact,
11239 show_bgp_community_list_exact_cmd,
11240 "show bgp community-list (<1-500>|WORD) exact-match",
11241 SHOW_STR
11242 BGP_STR
11243 "Display routes matching the community-list\n"
11244 "community-list number\n"
11245 "community-list name\n"
11246 "Exact match of the communities\n")
11247{
11248 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11249}
11250
11251ALIAS (show_bgp_community_list_exact,
11252 show_bgp_ipv6_community_list_exact_cmd,
11253 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11254 SHOW_STR
11255 BGP_STR
11256 "Address family\n"
11257 "Display routes matching the community-list\n"
11258 "community-list number\n"
11259 "community-list name\n"
11260 "Exact match of the communities\n")
11261
11262/* old command */
11263DEFUN (show_ipv6_bgp_community_list_exact,
11264 show_ipv6_bgp_community_list_exact_cmd,
11265 "show ipv6 bgp community-list WORD exact-match",
11266 SHOW_STR
11267 IPV6_STR
11268 BGP_STR
11269 "Display routes matching the community-list\n"
11270 "community-list name\n"
11271 "Exact match of the communities\n")
11272{
11273 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11274}
11275
11276/* old command */
11277DEFUN (show_ipv6_mbgp_community_list_exact,
11278 show_ipv6_mbgp_community_list_exact_cmd,
11279 "show ipv6 mbgp community-list WORD exact-match",
11280 SHOW_STR
11281 IPV6_STR
11282 MBGP_STR
11283 "Display routes matching the community-list\n"
11284 "community-list name\n"
11285 "Exact match of the communities\n")
11286{
11287 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
11288}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011289
Lou Berger651b4022016-01-12 13:42:07 -050011290DEFUN (show_bgp_ipv4_community_list,
11291 show_bgp_ipv4_community_list_cmd,
11292 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011293 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011294 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011295 IP_STR
paul718e3742002-12-13 20:15:29 +000011296 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011297 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011298 "community-list name\n")
11299{
11300 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11301}
11302
Lou Berger651b4022016-01-12 13:42:07 -050011303DEFUN (show_bgp_ipv4_safi_community_list,
11304 show_bgp_ipv4_safi_community_list_cmd,
11305 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011306 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011307 BGP_STR
11308 "Address family\n"
11309 "Address Family modifier\n"
11310 "Address Family modifier\n"
11311 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011312 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011313 "community-list name\n")
11314{
11315 if (strncmp (argv[0], "m", 1) == 0)
11316 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11317
11318 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11319}
11320
Lou Berger651b4022016-01-12 13:42:07 -050011321DEFUN (show_bgp_ipv4_community_list_exact,
11322 show_bgp_ipv4_community_list_exact_cmd,
11323 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011324 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011325 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011326 IP_STR
paul718e3742002-12-13 20:15:29 +000011327 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011328 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011329 "community-list name\n"
11330 "Exact match of the communities\n")
11331{
11332 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11333}
11334
Lou Berger651b4022016-01-12 13:42:07 -050011335DEFUN (show_bgp_ipv4_safi_community_list_exact,
11336 show_bgp_ipv4_safi_community_list_exact_cmd,
11337 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011338 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011339 BGP_STR
11340 "Address family\n"
11341 "Address Family modifier\n"
11342 "Address Family modifier\n"
11343 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011344 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011345 "community-list name\n"
11346 "Exact match of the communities\n")
11347{
11348 if (strncmp (argv[0], "m", 1) == 0)
11349 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11350
11351 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11352}
11353
Lou Bergerf9b6c392016-01-12 13:42:09 -050011354DEFUN (show_bgp_ipv6_safi_community_list,
11355 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011356 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011357 SHOW_STR
11358 BGP_STR
11359 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011360 "Address family modifier\n"
11361 "Address family modifier\n"
11362 "Address family modifier\n"
11363 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011364 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011365 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011366 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011367{
Lou Berger651b4022016-01-12 13:42:07 -050011368 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011369
Lou Berger651b4022016-01-12 13:42:07 -050011370 if (bgp_parse_safi(argv[0], &safi)) {
11371 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11372 return CMD_WARNING;
11373 }
11374 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011375}
11376
Lou Bergerf9b6c392016-01-12 13:42:09 -050011377DEFUN (show_bgp_ipv6_safi_community_list_exact,
11378 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011379 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011380 SHOW_STR
11381 BGP_STR
11382 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011383 "Address family modifier\n"
11384 "Address family modifier\n"
11385 "Address family modifier\n"
11386 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011387 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011388 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011389 "community-list name\n"
11390 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011391{
Lou Berger651b4022016-01-12 13:42:07 -050011392 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011393
Lou Berger651b4022016-01-12 13:42:07 -050011394 if (bgp_parse_safi(argv[0], &safi)) {
11395 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11396 return CMD_WARNING;
11397 }
11398 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011399}
David Lamparter6b0655a2014-06-04 06:53:35 +020011400
paul94f2b392005-06-28 12:44:16 +000011401static int
paulfd79ac92004-10-13 05:06:08 +000011402bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011403 safi_t safi, enum bgp_show_type type)
11404{
11405 int ret;
11406 struct prefix *p;
11407
11408 p = prefix_new();
11409
11410 ret = str2prefix (prefix, p);
11411 if (! ret)
11412 {
11413 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11414 return CMD_WARNING;
11415 }
11416
ajs5a646652004-11-05 01:25:55 +000011417 ret = bgp_show (vty, NULL, afi, safi, type, p);
11418 prefix_free(p);
11419 return ret;
paul718e3742002-12-13 20:15:29 +000011420}
11421
Lou Bergerf9b6c392016-01-12 13:42:09 -050011422DEFUN (show_ip_bgp_prefix_longer,
11423 show_ip_bgp_prefix_longer_cmd,
11424 "show ip bgp A.B.C.D/M longer-prefixes",
11425 SHOW_STR
11426 IP_STR
11427 BGP_STR
11428 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11429 "Display route and more specific routes\n")
11430{
11431 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11432 bgp_show_type_prefix_longer);
11433}
11434
11435DEFUN (show_ip_bgp_flap_prefix_longer,
11436 show_ip_bgp_flap_prefix_longer_cmd,
11437 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11438 SHOW_STR
11439 IP_STR
11440 BGP_STR
11441 "Display flap statistics of routes\n"
11442 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11443 "Display route and more specific routes\n")
11444{
11445 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11446 bgp_show_type_flap_prefix_longer);
11447}
11448
11449ALIAS (show_ip_bgp_flap_prefix_longer,
11450 show_ip_bgp_damp_flap_prefix_longer_cmd,
11451 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11452 SHOW_STR
11453 IP_STR
11454 BGP_STR
11455 "Display detailed information about dampening\n"
11456 "Display flap statistics of routes\n"
11457 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11458 "Display route and more specific routes\n")
11459
11460DEFUN (show_ip_bgp_ipv4_prefix_longer,
11461 show_ip_bgp_ipv4_prefix_longer_cmd,
11462 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11463 SHOW_STR
11464 IP_STR
11465 BGP_STR
11466 "Address family\n"
11467 "Address Family modifier\n"
11468 "Address Family modifier\n"
11469 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11470 "Display route and more specific routes\n")
11471{
11472 if (strncmp (argv[0], "m", 1) == 0)
11473 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11474 bgp_show_type_prefix_longer);
11475
11476 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11477 bgp_show_type_prefix_longer);
11478}
11479
11480DEFUN (show_ip_bgp_flap_address,
11481 show_ip_bgp_flap_address_cmd,
11482 "show ip bgp flap-statistics A.B.C.D",
11483 SHOW_STR
11484 IP_STR
11485 BGP_STR
11486 "Display flap statistics of routes\n"
11487 "Network in the BGP routing table to display\n")
11488{
11489 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11490 bgp_show_type_flap_address);
11491}
11492
11493ALIAS (show_ip_bgp_flap_address,
11494 show_ip_bgp_damp_flap_address_cmd,
11495 "show ip bgp dampening flap-statistics A.B.C.D",
11496 SHOW_STR
11497 IP_STR
11498 BGP_STR
11499 "Display detailed information about dampening\n"
11500 "Display flap statistics of routes\n"
11501 "Network in the BGP routing table to display\n")
11502
11503DEFUN (show_ip_bgp_flap_prefix,
11504 show_ip_bgp_flap_prefix_cmd,
11505 "show ip bgp flap-statistics A.B.C.D/M",
11506 SHOW_STR
11507 IP_STR
11508 BGP_STR
11509 "Display flap statistics of routes\n"
11510 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11511{
11512 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11513 bgp_show_type_flap_prefix);
11514}
11515
11516ALIAS (show_ip_bgp_flap_prefix,
11517 show_ip_bgp_damp_flap_prefix_cmd,
11518 "show ip bgp dampening flap-statistics A.B.C.D/M",
11519 SHOW_STR
11520 IP_STR
11521 BGP_STR
11522 "Display detailed information about dampening\n"
11523 "Display flap statistics of routes\n"
11524 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11525
Lou Bergerf9b6c392016-01-12 13:42:09 -050011526DEFUN (show_bgp_prefix_longer,
11527 show_bgp_prefix_longer_cmd,
11528 "show bgp X:X::X:X/M longer-prefixes",
11529 SHOW_STR
11530 BGP_STR
11531 "IPv6 prefix <network>/<length>\n"
11532 "Display route and more specific routes\n")
11533{
11534 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11535 bgp_show_type_prefix_longer);
11536}
11537
11538/* old command */
11539DEFUN (show_ipv6_bgp_prefix_longer,
11540 show_ipv6_bgp_prefix_longer_cmd,
11541 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11542 SHOW_STR
11543 IPV6_STR
11544 BGP_STR
11545 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11546 "Display route and more specific routes\n")
11547{
11548 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11549 bgp_show_type_prefix_longer);
11550}
11551
11552/* old command */
11553DEFUN (show_ipv6_mbgp_prefix_longer,
11554 show_ipv6_mbgp_prefix_longer_cmd,
11555 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11556 SHOW_STR
11557 IPV6_STR
11558 MBGP_STR
11559 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11560 "Display route and more specific routes\n")
11561{
11562 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
11563 bgp_show_type_prefix_longer);
11564}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011565
Lou Berger651b4022016-01-12 13:42:07 -050011566DEFUN (show_bgp_ipv4_prefix_longer,
11567 show_bgp_ipv4_prefix_longer_cmd,
11568 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011569 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011570 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011571 IP_STR
paul718e3742002-12-13 20:15:29 +000011572 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11573 "Display route and more specific routes\n")
11574{
11575 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11576 bgp_show_type_prefix_longer);
11577}
11578
Lou Berger651b4022016-01-12 13:42:07 -050011579DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11580 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11581 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011582 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011583 BGP_STR
11584 "Address family\n"
11585 "Address Family modifier\n"
11586 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011587 "Address Family modifier\n"
11588 "Address Family modifier\n"
11589 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011590 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11591 "Display route and more specific routes\n")
11592{
Lou Berger651b4022016-01-12 13:42:07 -050011593 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011594
Lou Berger651b4022016-01-12 13:42:07 -050011595 if (bgp_parse_safi(argv[0], &safi)) {
11596 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11597 return CMD_WARNING;
11598 }
11599 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11600 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011601}
11602
Lou Berger651b4022016-01-12 13:42:07 -050011603ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11604 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11605 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011606 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011607 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011608 "Address family\n"
11609 "Address Family modifier\n"
11610 "Address Family modifier\n"
11611 "Address Family modifier\n"
11612 "Address Family modifier\n"
11613 "Display detailed information about dampening\n"
11614 "Display flap statistics of routes\n"
11615 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11616 "Display route and more specific routes\n")
11617
Lou Berger651b4022016-01-12 13:42:07 -050011618DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11619 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11620 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11621 SHOW_STR
11622 BGP_STR
11623 "Address family\n"
11624 "Address Family modifier\n"
11625 "Address Family modifier\n"
11626 "Address Family modifier\n"
11627 "Address Family modifier\n"
11628 "Display flap statistics of routes\n"
11629 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11630 "Display route and more specific routes\n")
11631{
11632 safi_t safi;
11633
11634 if (bgp_parse_safi(argv[0], &safi)) {
11635 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11636 return CMD_WARNING;
11637 }
11638 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11639 bgp_show_type_flap_prefix_longer);
11640}
11641ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11642 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11643 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11644 SHOW_STR
11645 BGP_STR
11646 "Address family\n"
11647 "Address Family modifier\n"
11648 "Address Family modifier\n"
11649 "Address Family modifier\n"
11650 "Address Family modifier\n"
11651 "Display detailed information about dampening\n"
11652 "Display flap statistics of routes\n"
11653 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11654 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011655
11656DEFUN (show_bgp_ipv4_safi_prefix_longer,
11657 show_bgp_ipv4_safi_prefix_longer_cmd,
11658 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11659 SHOW_STR
11660 BGP_STR
11661 "Address family\n"
11662 "Address Family modifier\n"
11663 "Address Family modifier\n"
11664 "Address Family modifier\n"
11665 "Address Family modifier\n"
11666 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11667 "Display route and more specific routes\n")
11668{
11669 safi_t safi;
11670
11671 if (bgp_parse_safi(argv[0], &safi)) {
11672 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11673 return CMD_WARNING;
11674 }
11675
11676 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11677 bgp_show_type_prefix_longer);
11678}
11679
Lou Berger651b4022016-01-12 13:42:07 -050011680DEFUN (show_bgp_ipv6_safi_prefix_longer,
11681 show_bgp_ipv6_safi_prefix_longer_cmd,
11682 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11683 SHOW_STR
11684 BGP_STR
11685 "Address family\n"
11686 "Address Family modifier\n"
11687 "Address Family modifier\n"
11688 "Address Family modifier\n"
11689 "Address Family modifier\n"
11690 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11691 "Display route and more specific routes\n")
11692{
11693 safi_t safi;
11694
11695 if (bgp_parse_safi(argv[0], &safi)) {
11696 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11697 return CMD_WARNING;
11698 }
11699
11700 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11701 bgp_show_type_prefix_longer);
11702}
Lou Berger651b4022016-01-12 13:42:07 -050011703
11704DEFUN (show_bgp_ipv4_safi_flap_address,
11705 show_bgp_ipv4_safi_flap_address_cmd,
11706 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11707 SHOW_STR
11708 BGP_STR
11709 "Address family\n"
11710 "Address Family modifier\n"
11711 "Address Family modifier\n"
11712 "Address Family modifier\n"
11713 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011714 "Display flap statistics of routes\n"
11715 "Network in the BGP routing table to display\n")
11716{
Lou Berger651b4022016-01-12 13:42:07 -050011717 safi_t safi;
11718
11719 if (bgp_parse_safi(argv[0], &safi)) {
11720 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11721 return CMD_WARNING;
11722 }
11723 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011724 bgp_show_type_flap_address);
11725}
Lou Berger651b4022016-01-12 13:42:07 -050011726ALIAS (show_bgp_ipv4_safi_flap_address,
11727 show_bgp_ipv4_safi_damp_flap_address_cmd,
11728 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011729 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011730 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011731 "Address family\n"
11732 "Address Family modifier\n"
11733 "Address Family modifier\n"
11734 "Address Family modifier\n"
11735 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011736 "Display detailed information about dampening\n"
11737 "Display flap statistics of routes\n"
11738 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011739
Lou Berger651b4022016-01-12 13:42:07 -050011740DEFUN (show_bgp_ipv6_flap_address,
11741 show_bgp_ipv6_flap_address_cmd,
11742 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011743 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011744 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011745 "Address family\n"
11746 "Address Family modifier\n"
11747 "Address Family modifier\n"
11748 "Address Family modifier\n"
11749 "Address Family modifier\n"
11750 "Display flap statistics of routes\n"
11751 "Network in the BGP routing table to display\n")
11752{
11753 safi_t safi;
11754
11755 if (bgp_parse_safi(argv[0], &safi)) {
11756 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11757 return CMD_WARNING;
11758 }
11759 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11760 bgp_show_type_flap_address);
11761}
11762ALIAS (show_bgp_ipv6_flap_address,
11763 show_bgp_ipv6_damp_flap_address_cmd,
11764 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11765 SHOW_STR
11766 BGP_STR
11767 "Address family\n"
11768 "Address Family modifier\n"
11769 "Address Family modifier\n"
11770 "Address Family modifier\n"
11771 "Address Family modifier\n"
11772 "Display detailed information about dampening\n"
11773 "Display flap statistics of routes\n"
11774 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011775
11776DEFUN (show_bgp_ipv4_safi_flap_prefix,
11777 show_bgp_ipv4_safi_flap_prefix_cmd,
11778 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
11779 SHOW_STR
11780 BGP_STR
11781 "Address family\n"
11782 "Address Family modifier\n"
11783 "Address Family modifier\n"
11784 "Address Family modifier\n"
11785 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011786 "Display flap statistics of routes\n"
11787 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11788{
Lou Berger651b4022016-01-12 13:42:07 -050011789 safi_t safi;
11790
11791 if (bgp_parse_safi(argv[0], &safi)) {
11792 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11793 return CMD_WARNING;
11794 }
11795 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011796 bgp_show_type_flap_prefix);
11797}
Balaji3921cc52015-05-16 23:12:17 +053011798
Lou Berger651b4022016-01-12 13:42:07 -050011799ALIAS (show_bgp_ipv4_safi_flap_prefix,
11800 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11801 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011802 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011803 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011804 "Address family\n"
11805 "Address Family modifier\n"
11806 "Address Family modifier\n"
11807 "Address Family modifier\n"
11808 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011809 "Display detailed information about dampening\n"
11810 "Display flap statistics of routes\n"
11811 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11812
Lou Berger651b4022016-01-12 13:42:07 -050011813DEFUN (show_bgp_ipv6_safi_flap_prefix,
11814 show_bgp_ipv6_safi_flap_prefix_cmd,
11815 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011816 SHOW_STR
11817 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011818 "Address family\n"
11819 "Address Family modifier\n"
11820 "Address Family modifier\n"
11821 "Address Family modifier\n"
11822 "Address Family modifier\n"
11823 "Display flap statistics of routes\n"
11824 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011825{
Lou Berger651b4022016-01-12 13:42:07 -050011826 safi_t safi;
11827
11828 if (bgp_parse_safi(argv[0], &safi)) {
11829 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11830 return CMD_WARNING;
11831 }
11832 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11833 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011834}
11835
Lou Berger651b4022016-01-12 13:42:07 -050011836ALIAS (show_bgp_ipv6_safi_flap_prefix,
11837 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11838 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11839 SHOW_STR
11840 BGP_STR
11841 "Address family\n"
11842 "Address Family modifier\n"
11843 "Address Family modifier\n"
11844 "Address Family modifier\n"
11845 "Address Family modifier\n"
11846 "Display detailed information about dampening\n"
11847 "Display flap statistics of routes\n"
11848 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11849
11850DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011851 show_bgp_ipv6_prefix_longer_cmd,
11852 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11853 SHOW_STR
11854 BGP_STR
11855 "Address family\n"
11856 "IPv6 prefix <network>/<length>\n"
11857 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011858{
11859 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11860 bgp_show_type_prefix_longer);
11861}
11862
paul94f2b392005-06-28 12:44:16 +000011863static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011864peer_lookup_in_view (struct vty *vty, const char *view_name,
11865 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011866{
11867 int ret;
11868 struct bgp *bgp;
11869 struct peer *peer;
11870 union sockunion su;
11871
11872 /* BGP structure lookup. */
11873 if (view_name)
11874 {
11875 bgp = bgp_lookup_by_name (view_name);
11876 if (! bgp)
11877 {
11878 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11879 return NULL;
11880 }
11881 }
paul5228ad22004-06-04 17:58:18 +000011882 else
paulbb46e942003-10-24 19:02:03 +000011883 {
11884 bgp = bgp_get_default ();
11885 if (! bgp)
11886 {
11887 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11888 return NULL;
11889 }
11890 }
11891
11892 /* Get peer sockunion. */
11893 ret = str2sockunion (ip_str, &su);
11894 if (ret < 0)
11895 {
11896 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11897 return NULL;
11898 }
11899
11900 /* Peer structure lookup. */
11901 peer = peer_lookup (bgp, &su);
11902 if (! peer)
11903 {
11904 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11905 return NULL;
11906 }
11907
11908 return peer;
11909}
David Lamparter6b0655a2014-06-04 06:53:35 +020011910
Paul Jakma2815e612006-09-14 02:56:07 +000011911enum bgp_stats
11912{
11913 BGP_STATS_MAXBITLEN = 0,
11914 BGP_STATS_RIB,
11915 BGP_STATS_PREFIXES,
11916 BGP_STATS_TOTPLEN,
11917 BGP_STATS_UNAGGREGATEABLE,
11918 BGP_STATS_MAX_AGGREGATEABLE,
11919 BGP_STATS_AGGREGATES,
11920 BGP_STATS_SPACE,
11921 BGP_STATS_ASPATH_COUNT,
11922 BGP_STATS_ASPATH_MAXHOPS,
11923 BGP_STATS_ASPATH_TOTHOPS,
11924 BGP_STATS_ASPATH_MAXSIZE,
11925 BGP_STATS_ASPATH_TOTSIZE,
11926 BGP_STATS_ASN_HIGHEST,
11927 BGP_STATS_MAX,
11928};
paulbb46e942003-10-24 19:02:03 +000011929
Paul Jakma2815e612006-09-14 02:56:07 +000011930static const char *table_stats_strs[] =
11931{
11932 [BGP_STATS_PREFIXES] = "Total Prefixes",
11933 [BGP_STATS_TOTPLEN] = "Average prefix length",
11934 [BGP_STATS_RIB] = "Total Advertisements",
11935 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11936 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11937 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11938 [BGP_STATS_SPACE] = "Address space advertised",
11939 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11940 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11941 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11942 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11943 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11944 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11945 [BGP_STATS_MAX] = NULL,
11946};
11947
11948struct bgp_table_stats
11949{
11950 struct bgp_table *table;
11951 unsigned long long counts[BGP_STATS_MAX];
11952};
11953
11954#if 0
11955#define TALLY_SIGFIG 100000
11956static unsigned long
11957ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11958{
11959 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11960 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11961 unsigned long ret = newtot / count;
11962
11963 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11964 return ret + 1;
11965 else
11966 return ret;
11967}
11968#endif
11969
11970static int
11971bgp_table_stats_walker (struct thread *t)
11972{
11973 struct bgp_node *rn;
11974 struct bgp_node *top;
11975 struct bgp_table_stats *ts = THREAD_ARG (t);
11976 unsigned int space = 0;
11977
Paul Jakma53d9f672006-10-15 23:41:16 +000011978 if (!(top = bgp_table_top (ts->table)))
11979 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011980
11981 switch (top->p.family)
11982 {
11983 case AF_INET:
11984 space = IPV4_MAX_BITLEN;
11985 break;
11986 case AF_INET6:
11987 space = IPV6_MAX_BITLEN;
11988 break;
11989 }
11990
11991 ts->counts[BGP_STATS_MAXBITLEN] = space;
11992
11993 for (rn = top; rn; rn = bgp_route_next (rn))
11994 {
11995 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011996 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000011997 unsigned int rinum = 0;
11998
11999 if (rn == top)
12000 continue;
12001
12002 if (!rn->info)
12003 continue;
12004
12005 ts->counts[BGP_STATS_PREFIXES]++;
12006 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
12007
12008#if 0
12009 ts->counts[BGP_STATS_AVGPLEN]
12010 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
12011 ts->counts[BGP_STATS_AVGPLEN],
12012 rn->p.prefixlen);
12013#endif
12014
12015 /* check if the prefix is included by any other announcements */
12016 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070012017 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000012018
12019 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000012020 {
12021 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
12022 /* announced address space */
12023 if (space)
12024 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
12025 }
Paul Jakma2815e612006-09-14 02:56:07 +000012026 else if (prn->info)
12027 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
12028
Paul Jakma2815e612006-09-14 02:56:07 +000012029 for (ri = rn->info; ri; ri = ri->next)
12030 {
12031 rinum++;
12032 ts->counts[BGP_STATS_RIB]++;
12033
12034 if (ri->attr &&
12035 (CHECK_FLAG (ri->attr->flag,
12036 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
12037 ts->counts[BGP_STATS_AGGREGATES]++;
12038
12039 /* as-path stats */
12040 if (ri->attr && ri->attr->aspath)
12041 {
12042 unsigned int hops = aspath_count_hops (ri->attr->aspath);
12043 unsigned int size = aspath_size (ri->attr->aspath);
12044 as_t highest = aspath_highest (ri->attr->aspath);
12045
12046 ts->counts[BGP_STATS_ASPATH_COUNT]++;
12047
12048 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
12049 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
12050
12051 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
12052 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
12053
12054 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
12055 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
12056#if 0
12057 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
12058 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12059 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
12060 hops);
12061 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
12062 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12063 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
12064 size);
12065#endif
12066 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
12067 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
12068 }
12069 }
12070 }
12071 return 0;
12072}
12073
12074static int
12075bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
12076{
12077 struct bgp_table_stats ts;
12078 unsigned int i;
12079
12080 if (!bgp->rib[afi][safi])
12081 {
Donald Sharp3c964042016-01-25 23:38:53 -050012082 vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s",
12083 afi, safi, VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000012084 return CMD_WARNING;
12085 }
12086
12087 memset (&ts, 0, sizeof (ts));
12088 ts.table = bgp->rib[afi][safi];
12089 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
12090
12091 vty_out (vty, "BGP %s RIB statistics%s%s",
12092 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
12093
12094 for (i = 0; i < BGP_STATS_MAX; i++)
12095 {
12096 if (!table_stats_strs[i])
12097 continue;
12098
12099 switch (i)
12100 {
12101#if 0
12102 case BGP_STATS_ASPATH_AVGHOPS:
12103 case BGP_STATS_ASPATH_AVGSIZE:
12104 case BGP_STATS_AVGPLEN:
12105 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12106 vty_out (vty, "%12.2f",
12107 (float)ts.counts[i] / (float)TALLY_SIGFIG);
12108 break;
12109#endif
12110 case BGP_STATS_ASPATH_TOTHOPS:
12111 case BGP_STATS_ASPATH_TOTSIZE:
12112 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12113 vty_out (vty, "%12.2f",
12114 ts.counts[i] ?
12115 (float)ts.counts[i] /
12116 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
12117 : 0);
12118 break;
12119 case BGP_STATS_TOTPLEN:
12120 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12121 vty_out (vty, "%12.2f",
12122 ts.counts[i] ?
12123 (float)ts.counts[i] /
12124 (float)ts.counts[BGP_STATS_PREFIXES]
12125 : 0);
12126 break;
12127 case BGP_STATS_SPACE:
12128 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12129 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
12130 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
12131 break;
Paul Jakma30a22312008-08-15 14:05:22 +010012132 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000012133 vty_out (vty, "%12.2f%s",
12134 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000012135 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000012136 VTY_NEWLINE);
12137 vty_out (vty, "%30s: ", "/8 equivalent ");
12138 vty_out (vty, "%12.2f%s",
12139 (float)ts.counts[BGP_STATS_SPACE] /
12140 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
12141 VTY_NEWLINE);
12142 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
12143 break;
12144 vty_out (vty, "%30s: ", "/24 equivalent ");
12145 vty_out (vty, "%12.2f",
12146 (float)ts.counts[BGP_STATS_SPACE] /
12147 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
12148 break;
12149 default:
12150 vty_out (vty, "%-30s: ", table_stats_strs[i]);
12151 vty_out (vty, "%12llu", ts.counts[i]);
12152 }
12153
12154 vty_out (vty, "%s", VTY_NEWLINE);
12155 }
12156 return CMD_SUCCESS;
12157}
12158
12159static int
12160bgp_table_stats_vty (struct vty *vty, const char *name,
12161 const char *afi_str, const char *safi_str)
12162{
12163 struct bgp *bgp;
12164 afi_t afi;
12165 safi_t safi;
12166
12167 if (name)
12168 bgp = bgp_lookup_by_name (name);
12169 else
12170 bgp = bgp_get_default ();
12171
12172 if (!bgp)
12173 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050012174 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000012175 return CMD_WARNING;
12176 }
12177 if (strncmp (afi_str, "ipv", 3) == 0)
12178 {
12179 if (strncmp (afi_str, "ipv4", 4) == 0)
12180 afi = AFI_IP;
12181 else if (strncmp (afi_str, "ipv6", 4) == 0)
12182 afi = AFI_IP6;
12183 else
12184 {
12185 vty_out (vty, "%% Invalid address family %s%s",
12186 afi_str, VTY_NEWLINE);
12187 return CMD_WARNING;
12188 }
Lou Berger298cc2f2016-01-12 13:42:02 -050012189 switch (safi_str[0]) {
12190 case 'm':
12191 safi = SAFI_MULTICAST;
12192 break;
12193 case 'u':
12194 safi = SAFI_UNICAST;
12195 break;
12196 case 'v':
Donald Sharp3c964042016-01-25 23:38:53 -050012197 safi = SAFI_MPLS_VPN;
Lou Berger298cc2f2016-01-12 13:42:02 -050012198 break;
12199 case 'e':
12200 safi = SAFI_ENCAP;
12201 break;
12202 default:
12203 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000012204 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050012205 return CMD_WARNING;
12206 }
Paul Jakma2815e612006-09-14 02:56:07 +000012207 }
12208 else
12209 {
Lou Berger298cc2f2016-01-12 13:42:02 -050012210 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000012211 afi_str, VTY_NEWLINE);
12212 return CMD_WARNING;
12213 }
12214
Paul Jakma2815e612006-09-14 02:56:07 +000012215 return bgp_table_stats (vty, bgp, afi, safi);
12216}
12217
12218DEFUN (show_bgp_statistics,
12219 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050012220 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012221 SHOW_STR
12222 BGP_STR
12223 "Address family\n"
12224 "Address family\n"
12225 "Address Family modifier\n"
12226 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050012227 "Address Family modifier\n"
12228 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000012229 "BGP RIB advertisement statistics\n")
12230{
12231 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
12232}
12233
Lou Bergerf9b6c392016-01-12 13:42:09 -050012234ALIAS (show_bgp_statistics,
12235 show_bgp_statistics_vpnv4_cmd,
12236 "show bgp (ipv4) (vpnv4) statistics",
12237 SHOW_STR
12238 BGP_STR
12239 "Address family\n"
12240 "Address Family modifier\n"
12241 "BGP RIB advertisement statistics\n")
12242
Paul Jakma2815e612006-09-14 02:56:07 +000012243DEFUN (show_bgp_statistics_view,
12244 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050012245 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012246 SHOW_STR
12247 BGP_STR
12248 "BGP view\n"
12249 "Address family\n"
12250 "Address family\n"
12251 "Address Family modifier\n"
12252 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050012253 "Address Family modifier\n"
12254 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000012255 "BGP RIB advertisement statistics\n")
12256{
12257 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
12258}
12259
12260ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050012261 show_bgp_statistics_view_vpnv4_cmd,
12262 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000012263 SHOW_STR
12264 BGP_STR
12265 "BGP view\n"
12266 "Address family\n"
12267 "Address Family modifier\n"
12268 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020012269
Paul Jakmaff7924f2006-09-04 01:10:36 +000012270enum bgp_pcounts
12271{
12272 PCOUNT_ADJ_IN = 0,
12273 PCOUNT_DAMPED,
12274 PCOUNT_REMOVED,
12275 PCOUNT_HISTORY,
12276 PCOUNT_STALE,
12277 PCOUNT_VALID,
12278 PCOUNT_ALL,
12279 PCOUNT_COUNTED,
12280 PCOUNT_PFCNT, /* the figure we display to users */
12281 PCOUNT_MAX,
12282};
12283
12284static const char *pcount_strs[] =
12285{
12286 [PCOUNT_ADJ_IN] = "Adj-in",
12287 [PCOUNT_DAMPED] = "Damped",
12288 [PCOUNT_REMOVED] = "Removed",
12289 [PCOUNT_HISTORY] = "History",
12290 [PCOUNT_STALE] = "Stale",
12291 [PCOUNT_VALID] = "Valid",
12292 [PCOUNT_ALL] = "All RIB",
12293 [PCOUNT_COUNTED] = "PfxCt counted",
12294 [PCOUNT_PFCNT] = "Useable",
12295 [PCOUNT_MAX] = NULL,
12296};
12297
Paul Jakma2815e612006-09-14 02:56:07 +000012298struct peer_pcounts
12299{
12300 unsigned int count[PCOUNT_MAX];
12301 const struct peer *peer;
12302 const struct bgp_table *table;
12303};
12304
Paul Jakmaff7924f2006-09-04 01:10:36 +000012305static int
Paul Jakma2815e612006-09-14 02:56:07 +000012306bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000012307{
12308 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000012309 struct peer_pcounts *pc = THREAD_ARG (t);
12310 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012311
Paul Jakma2815e612006-09-14 02:56:07 +000012312 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012313 {
12314 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000012315 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012316
12317 for (ain = rn->adj_in; ain; ain = ain->next)
12318 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000012319 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012320
Paul Jakmaff7924f2006-09-04 01:10:36 +000012321 for (ri = rn->info; ri; ri = ri->next)
12322 {
12323 char buf[SU_ADDRSTRLEN];
12324
12325 if (ri->peer != peer)
12326 continue;
12327
Paul Jakma2815e612006-09-14 02:56:07 +000012328 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012329
12330 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000012331 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012332 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000012333 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012334 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000012335 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012336 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000012337 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012338 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000012339 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012340 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000012341 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012342
12343 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
12344 {
Paul Jakma2815e612006-09-14 02:56:07 +000012345 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012346 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012347 plog_warn (peer->log,
12348 "%s [pcount] %s/%d is counted but flags 0x%x",
12349 peer->host,
12350 inet_ntop(rn->p.family, &rn->p.u.prefix,
12351 buf, SU_ADDRSTRLEN),
12352 rn->p.prefixlen,
12353 ri->flags);
12354 }
12355 else
12356 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012357 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012358 plog_warn (peer->log,
12359 "%s [pcount] %s/%d not counted but flags 0x%x",
12360 peer->host,
12361 inet_ntop(rn->p.family, &rn->p.u.prefix,
12362 buf, SU_ADDRSTRLEN),
12363 rn->p.prefixlen,
12364 ri->flags);
12365 }
12366 }
12367 }
Paul Jakma2815e612006-09-14 02:56:07 +000012368 return 0;
12369}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012370
Paul Jakma2815e612006-09-14 02:56:07 +000012371static int
12372bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12373{
12374 struct peer_pcounts pcounts = { .peer = peer };
12375 unsigned int i;
12376
12377 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12378 || !peer->bgp->rib[afi][safi])
12379 {
12380 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12381 return CMD_WARNING;
12382 }
12383
12384 memset (&pcounts, 0, sizeof(pcounts));
12385 pcounts.peer = peer;
12386 pcounts.table = peer->bgp->rib[afi][safi];
12387
12388 /* in-place call via thread subsystem so as to record execution time
12389 * stats for the thread-walk (i.e. ensure this can't be blamed on
12390 * on just vty_read()).
12391 */
12392 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12393
Paul Jakmaff7924f2006-09-04 01:10:36 +000012394 vty_out (vty, "Prefix counts for %s, %s%s",
12395 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12396 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12397 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12398 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12399
12400 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012401 vty_out (vty, "%20s: %-10d%s",
12402 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012403
Paul Jakma2815e612006-09-14 02:56:07 +000012404 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012405 {
12406 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12407 peer->host, VTY_NEWLINE);
12408 vty_out (vty, "Please report this bug, with the above command output%s",
12409 VTY_NEWLINE);
12410 }
12411
12412 return CMD_SUCCESS;
12413}
12414
Lou Bergerf9b6c392016-01-12 13:42:09 -050012415DEFUN (show_ip_bgp_neighbor_prefix_counts,
12416 show_ip_bgp_neighbor_prefix_counts_cmd,
12417 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12418 SHOW_STR
12419 IP_STR
12420 BGP_STR
12421 "Detailed information on TCP and BGP neighbor connections\n"
12422 "Neighbor to display information about\n"
12423 "Neighbor to display information about\n"
12424 "Display detailed prefix count information\n")
12425{
12426 struct peer *peer;
12427
12428 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12429 if (! peer)
12430 return CMD_WARNING;
12431
12432 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12433}
12434
Paul Jakmaff7924f2006-09-04 01:10:36 +000012435DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12436 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12437 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12438 SHOW_STR
12439 BGP_STR
12440 "Address family\n"
12441 "Detailed information on TCP and BGP neighbor connections\n"
12442 "Neighbor to display information about\n"
12443 "Neighbor to display information about\n"
12444 "Display detailed prefix count information\n")
12445{
12446 struct peer *peer;
12447
12448 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12449 if (! peer)
12450 return CMD_WARNING;
12451
12452 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12453}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012454
12455DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12456 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12457 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12458 SHOW_STR
12459 IP_STR
12460 BGP_STR
12461 "Address family\n"
12462 "Address Family modifier\n"
12463 "Address Family modifier\n"
12464 "Detailed information on TCP and BGP neighbor connections\n"
12465 "Neighbor to display information about\n"
12466 "Neighbor to display information about\n"
12467 "Display detailed prefix count information\n")
12468{
12469 struct peer *peer;
12470
12471 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12472 if (! peer)
12473 return CMD_WARNING;
12474
12475 if (strncmp (argv[0], "m", 1) == 0)
12476 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12477
12478 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12479}
12480
12481DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12482 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12483 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12484 SHOW_STR
12485 IP_STR
12486 BGP_STR
12487 "Address family\n"
12488 "Address Family modifier\n"
12489 "Address Family modifier\n"
12490 "Detailed information on TCP and BGP neighbor connections\n"
12491 "Neighbor to display information about\n"
12492 "Neighbor to display information about\n"
12493 "Display detailed prefix count information\n")
12494{
12495 struct peer *peer;
12496
12497 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12498 if (! peer)
12499 return CMD_WARNING;
12500
12501 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12502}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012503
Lou Berger651b4022016-01-12 13:42:07 -050012504DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12505 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12506 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012507 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012508 BGP_STR
12509 "Address family\n"
12510 "Address Family modifier\n"
12511 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012512 "Address Family modifier\n"
12513 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012514 "Detailed information on TCP and BGP neighbor connections\n"
12515 "Neighbor to display information about\n"
12516 "Neighbor to display information about\n"
12517 "Display detailed prefix count information\n")
12518{
12519 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012520 safi_t safi;
12521
12522 if (bgp_parse_safi(argv[0], &safi)) {
12523 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12524 return CMD_WARNING;
12525 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012526
12527 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12528 if (! peer)
12529 return CMD_WARNING;
12530
Lou Berger651b4022016-01-12 13:42:07 -050012531 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012532}
Lou Berger205e6742016-01-12 13:42:11 -050012533
Lou Berger651b4022016-01-12 13:42:07 -050012534DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12535 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12536 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12537 SHOW_STR
12538 BGP_STR
12539 "Address family\n"
12540 "Address Family modifier\n"
12541 "Address Family modifier\n"
12542 "Address Family modifier\n"
12543 "Address Family modifier\n"
12544 "Detailed information on TCP and BGP neighbor connections\n"
12545 "Neighbor to display information about\n"
12546 "Neighbor to display information about\n"
12547 "Display detailed prefix count information\n")
12548{
12549 struct peer *peer;
12550 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012551
Lou Berger651b4022016-01-12 13:42:07 -050012552 if (bgp_parse_safi(argv[0], &safi)) {
12553 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12554 return CMD_WARNING;
12555 }
12556
12557 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12558 if (! peer)
12559 return CMD_WARNING;
12560
12561 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12562}
Lou Berger651b4022016-01-12 13:42:07 -050012563
12564DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12565 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12566 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012567 SHOW_STR
12568 IP_STR
12569 BGP_STR
12570 "Address family\n"
12571 "Address Family modifier\n"
12572 "Address Family modifier\n"
12573 "Detailed information on TCP and BGP neighbor connections\n"
12574 "Neighbor to display information about\n"
12575 "Neighbor to display information about\n"
12576 "Display detailed prefix count information\n")
12577{
12578 struct peer *peer;
12579
12580 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12581 if (! peer)
12582 return CMD_WARNING;
12583
Lou Berger651b4022016-01-12 13:42:07 -050012584 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012585}
12586
12587
paul94f2b392005-06-28 12:44:16 +000012588static void
paul718e3742002-12-13 20:15:29 +000012589show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12590 int in)
12591{
12592 struct bgp_table *table;
12593 struct bgp_adj_in *ain;
12594 struct bgp_adj_out *adj;
12595 unsigned long output_count;
12596 struct bgp_node *rn;
12597 int header1 = 1;
12598 struct bgp *bgp;
12599 int header2 = 1;
12600
paulbb46e942003-10-24 19:02:03 +000012601 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012602
12603 if (! bgp)
12604 return;
12605
12606 table = bgp->rib[afi][safi];
12607
12608 output_count = 0;
12609
12610 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12611 PEER_STATUS_DEFAULT_ORIGINATE))
12612 {
12613 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 +000012614 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12615 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012616
12617 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12618 VTY_NEWLINE, VTY_NEWLINE);
12619 header1 = 0;
12620 }
12621
12622 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12623 if (in)
12624 {
12625 for (ain = rn->adj_in; ain; ain = ain->next)
12626 if (ain->peer == peer)
12627 {
12628 if (header1)
12629 {
12630 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 +000012631 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12632 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012633 header1 = 0;
12634 }
12635 if (header2)
12636 {
12637 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12638 header2 = 0;
12639 }
12640 if (ain->attr)
12641 {
12642 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12643 output_count++;
12644 }
12645 }
12646 }
12647 else
12648 {
12649 for (adj = rn->adj_out; adj; adj = adj->next)
12650 if (adj->peer == peer)
12651 {
12652 if (header1)
12653 {
12654 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 +000012655 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12656 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012657 header1 = 0;
12658 }
12659 if (header2)
12660 {
12661 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12662 header2 = 0;
12663 }
12664 if (adj->attr)
12665 {
12666 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12667 output_count++;
12668 }
12669 }
12670 }
12671
12672 if (output_count != 0)
12673 vty_out (vty, "%sTotal number of prefixes %ld%s",
12674 VTY_NEWLINE, output_count, VTY_NEWLINE);
12675}
12676
paul94f2b392005-06-28 12:44:16 +000012677static int
paulbb46e942003-10-24 19:02:03 +000012678peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12679{
paul718e3742002-12-13 20:15:29 +000012680 if (! peer || ! peer->afc[afi][safi])
12681 {
12682 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12683 return CMD_WARNING;
12684 }
12685
12686 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12687 {
12688 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12689 VTY_NEWLINE);
12690 return CMD_WARNING;
12691 }
12692
12693 show_adj_route (vty, peer, afi, safi, in);
12694
12695 return CMD_SUCCESS;
12696}
12697
Lou Bergerf9b6c392016-01-12 13:42:09 -050012698DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12699 show_ip_bgp_view_neighbor_advertised_route_cmd,
12700 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12701 SHOW_STR
12702 IP_STR
12703 BGP_STR
12704 "BGP view\n"
12705 "View name\n"
12706 "Detailed information on TCP and BGP neighbor connections\n"
12707 "Neighbor to display information about\n"
12708 "Neighbor to display information about\n"
12709 "Display the routes advertised to a BGP neighbor\n")
12710{
12711 struct peer *peer;
12712
12713 if (argc == 2)
12714 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12715 else
12716 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12717
12718 if (! peer)
12719 return CMD_WARNING;
12720
12721 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12722}
12723
12724ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12725 show_ip_bgp_neighbor_advertised_route_cmd,
12726 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12727 SHOW_STR
12728 IP_STR
12729 BGP_STR
12730 "Detailed information on TCP and BGP neighbor connections\n"
12731 "Neighbor to display information about\n"
12732 "Neighbor to display information about\n"
12733 "Display the routes advertised to a BGP neighbor\n")
12734
12735DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12736 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12737 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12738 SHOW_STR
12739 IP_STR
12740 BGP_STR
12741 "Address family\n"
12742 "Address Family modifier\n"
12743 "Address Family modifier\n"
12744 "Detailed information on TCP and BGP neighbor connections\n"
12745 "Neighbor to display information about\n"
12746 "Neighbor to display information about\n"
12747 "Display the routes advertised to a BGP neighbor\n")
12748{
12749 struct peer *peer;
12750
12751 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12752 if (! peer)
12753 return CMD_WARNING;
12754
12755 if (strncmp (argv[0], "m", 1) == 0)
12756 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12757
12758 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12759}
12760
Lou Bergerf9b6c392016-01-12 13:42:09 -050012761DEFUN (show_bgp_view_neighbor_advertised_route,
12762 show_bgp_view_neighbor_advertised_route_cmd,
12763 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12764 SHOW_STR
12765 BGP_STR
12766 "BGP view\n"
12767 "View name\n"
12768 "Detailed information on TCP and BGP neighbor connections\n"
12769 "Neighbor to display information about\n"
12770 "Neighbor to display information about\n"
12771 "Display the routes advertised to a BGP neighbor\n")
12772{
12773 struct peer *peer;
12774
12775 if (argc == 2)
12776 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12777 else
12778 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12779
12780 if (! peer)
12781 return CMD_WARNING;
12782
12783 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12784}
12785
12786DEFUN (show_bgp_view_neighbor_received_routes,
12787 show_bgp_view_neighbor_received_routes_cmd,
12788 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12789 SHOW_STR
12790 BGP_STR
12791 "BGP view\n"
12792 "View name\n"
12793 "Detailed information on TCP and BGP neighbor connections\n"
12794 "Neighbor to display information about\n"
12795 "Neighbor to display information about\n"
12796 "Display the received routes from neighbor\n")
12797{
12798 struct peer *peer;
12799
12800 if (argc == 2)
12801 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12802 else
12803 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12804
12805 if (! peer)
12806 return CMD_WARNING;
12807
12808 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12809}
12810
12811ALIAS (show_bgp_view_neighbor_advertised_route,
12812 show_bgp_neighbor_advertised_route_cmd,
12813 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12814 SHOW_STR
12815 BGP_STR
12816 "Detailed information on TCP and BGP neighbor connections\n"
12817 "Neighbor to display information about\n"
12818 "Neighbor to display information about\n"
12819 "Display the routes advertised to a BGP neighbor\n")
12820
12821ALIAS (show_bgp_view_neighbor_advertised_route,
12822 show_bgp_ipv6_neighbor_advertised_route_cmd,
12823 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12824 SHOW_STR
12825 BGP_STR
12826 "Address family\n"
12827 "Detailed information on TCP and BGP neighbor connections\n"
12828 "Neighbor to display information about\n"
12829 "Neighbor to display information about\n"
12830 "Display the routes advertised to a BGP neighbor\n")
12831
12832/* old command */
12833ALIAS (show_bgp_view_neighbor_advertised_route,
12834 ipv6_bgp_neighbor_advertised_route_cmd,
12835 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12836 SHOW_STR
12837 IPV6_STR
12838 BGP_STR
12839 "Detailed information on TCP and BGP neighbor connections\n"
12840 "Neighbor to display information about\n"
12841 "Neighbor to display information about\n"
12842 "Display the routes advertised to a BGP neighbor\n")
12843
12844/* old command */
12845DEFUN (ipv6_mbgp_neighbor_advertised_route,
12846 ipv6_mbgp_neighbor_advertised_route_cmd,
12847 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12848 SHOW_STR
12849 IPV6_STR
12850 MBGP_STR
12851 "Detailed information on TCP and BGP neighbor connections\n"
12852 "Neighbor to display information about\n"
12853 "Neighbor to display information about\n"
12854 "Display the routes advertised to a BGP neighbor\n")
12855{
12856 struct peer *peer;
12857
12858 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12859 if (! peer)
12860 return CMD_WARNING;
12861
12862 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12863}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012864
12865DEFUN (show_ip_bgp_view_neighbor_received_routes,
12866 show_ip_bgp_view_neighbor_received_routes_cmd,
12867 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12868 SHOW_STR
12869 IP_STR
12870 BGP_STR
12871 "BGP view\n"
12872 "View name\n"
12873 "Detailed information on TCP and BGP neighbor connections\n"
12874 "Neighbor to display information about\n"
12875 "Neighbor to display information about\n"
12876 "Display the received routes from neighbor\n")
12877{
12878 struct peer *peer;
12879
12880 if (argc == 2)
12881 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12882 else
12883 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12884
12885 if (! peer)
12886 return CMD_WARNING;
12887
12888 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12889}
12890
12891ALIAS (show_ip_bgp_view_neighbor_received_routes,
12892 show_ip_bgp_neighbor_received_routes_cmd,
12893 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12894 SHOW_STR
12895 IP_STR
12896 BGP_STR
12897 "Detailed information on TCP and BGP neighbor connections\n"
12898 "Neighbor to display information about\n"
12899 "Neighbor to display information about\n"
12900 "Display the received routes from neighbor\n")
12901
12902ALIAS (show_bgp_view_neighbor_received_routes,
12903 show_bgp_ipv6_neighbor_received_routes_cmd,
12904 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12905 SHOW_STR
12906 BGP_STR
12907 "Address family\n"
12908 "Detailed information on TCP and BGP neighbor connections\n"
12909 "Neighbor to display information about\n"
12910 "Neighbor to display information about\n"
12911 "Display the received routes from neighbor\n")
12912
12913DEFUN (show_bgp_neighbor_received_prefix_filter,
12914 show_bgp_neighbor_received_prefix_filter_cmd,
12915 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12916 SHOW_STR
12917 BGP_STR
12918 "Detailed information on TCP and BGP neighbor connections\n"
12919 "Neighbor to display information about\n"
12920 "Neighbor to display information about\n"
12921 "Display information received from a BGP neighbor\n"
12922 "Display the prefixlist filter\n")
12923{
12924 char name[BUFSIZ];
12925 union sockunion su;
12926 struct peer *peer;
12927 int count, ret;
12928
12929 ret = str2sockunion (argv[0], &su);
12930 if (ret < 0)
12931 {
12932 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12933 return CMD_WARNING;
12934 }
12935
12936 peer = peer_lookup (NULL, &su);
12937 if (! peer)
12938 return CMD_WARNING;
12939
12940 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12941 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12942 if (count)
12943 {
12944 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12945 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12946 }
12947
12948 return CMD_SUCCESS;
12949}
12950
12951/* old command */
12952ALIAS (show_bgp_view_neighbor_received_routes,
12953 ipv6_bgp_neighbor_received_routes_cmd,
12954 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12955 SHOW_STR
12956 IPV6_STR
12957 BGP_STR
12958 "Detailed information on TCP and BGP neighbor connections\n"
12959 "Neighbor to display information about\n"
12960 "Neighbor to display information about\n"
12961 "Display the received routes from neighbor\n")
12962
12963/* old command */
12964DEFUN (ipv6_mbgp_neighbor_received_routes,
12965 ipv6_mbgp_neighbor_received_routes_cmd,
12966 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12967 SHOW_STR
12968 IPV6_STR
12969 MBGP_STR
12970 "Detailed information on TCP and BGP neighbor connections\n"
12971 "Neighbor to display information about\n"
12972 "Neighbor to display information about\n"
12973 "Display the received routes from neighbor\n")
12974{
12975 struct peer *peer;
12976
12977 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12978 if (! peer)
12979 return CMD_WARNING;
12980
12981 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12982}
12983
12984DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12985 show_bgp_view_neighbor_received_prefix_filter_cmd,
12986 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12987 SHOW_STR
12988 BGP_STR
12989 "BGP view\n"
12990 "View name\n"
12991 "Detailed information on TCP and BGP neighbor connections\n"
12992 "Neighbor to display information about\n"
12993 "Neighbor to display information about\n"
12994 "Display information received from a BGP neighbor\n"
12995 "Display the prefixlist filter\n")
12996{
12997 char name[BUFSIZ];
12998 union sockunion su;
12999 struct peer *peer;
13000 struct bgp *bgp;
13001 int count, ret;
13002
13003 /* BGP structure lookup. */
13004 bgp = bgp_lookup_by_name (argv[0]);
13005 if (bgp == NULL)
13006 {
13007 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13008 return CMD_WARNING;
13009 }
13010
13011 ret = str2sockunion (argv[1], &su);
13012 if (ret < 0)
13013 {
13014 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13015 return CMD_WARNING;
13016 }
13017
13018 peer = peer_lookup (bgp, &su);
13019 if (! peer)
13020 return CMD_WARNING;
13021
13022 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13023 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13024 if (count)
13025 {
13026 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13027 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13028 }
13029
13030 return CMD_SUCCESS;
13031}
13032
13033
13034DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
13035 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
13036 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
13037 SHOW_STR
13038 IP_STR
13039 BGP_STR
13040 "Address family\n"
13041 "Address Family modifier\n"
13042 "Address Family modifier\n"
13043 "Detailed information on TCP and BGP neighbor connections\n"
13044 "Neighbor to display information about\n"
13045 "Neighbor to display information about\n"
13046 "Display the received routes from neighbor\n")
13047{
13048 struct peer *peer;
13049
13050 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13051 if (! peer)
13052 return CMD_WARNING;
13053
13054 if (strncmp (argv[0], "m", 1) == 0)
13055 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
13056
13057 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
13058}
13059
Lou Berger651b4022016-01-12 13:42:07 -050013060DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
13061 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
13062 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013063 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013064 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013065 "Address Family modifier\n"
13066 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013067 "Detailed information on TCP and BGP neighbor connections\n"
13068 "Neighbor to display information about\n"
13069 "Neighbor to display information about\n"
13070 "Display the routes advertised to a BGP neighbor\n")
13071{
13072 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013073 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013074
Lou Berger651b4022016-01-12 13:42:07 -050013075 if (bgp_parse_safi(argv[0], &safi)) {
13076 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013077 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013078 }
paul718e3742002-12-13 20:15:29 +000013079
paulbb46e942003-10-24 19:02:03 +000013080 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13081 if (! peer)
13082 return CMD_WARNING;
13083
Lou Berger651b4022016-01-12 13:42:07 -050013084 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
13085}
Lou Berger205e6742016-01-12 13:42:11 -050013086
Lou Berger651b4022016-01-12 13:42:07 -050013087DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
13088 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
13089 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13090 SHOW_STR
13091 BGP_STR
13092 "Address Family modifier\n"
13093 "Address Family modifier\n"
13094 "Address Family modifier\n"
13095 "Detailed information on TCP and BGP neighbor connections\n"
13096 "Neighbor to display information about\n"
13097 "Neighbor to display information about\n"
13098 "Display the routes advertised to a BGP neighbor\n")
13099{
13100 struct peer *peer;
13101 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013102
Lou Berger651b4022016-01-12 13:42:07 -050013103 if (bgp_parse_safi(argv[0], &safi)) {
13104 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13105 return CMD_WARNING;
13106 }
13107
13108 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13109 if (! peer)
13110 return CMD_WARNING;
13111
13112 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000013113}
13114
Lou Bergerf9b6c392016-01-12 13:42:09 -050013115DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050013116 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
13117 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000013118 SHOW_STR
13119 BGP_STR
13120 "BGP view\n"
13121 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013122 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013123 "Detailed information on TCP and BGP neighbor connections\n"
13124 "Neighbor to display information about\n"
13125 "Neighbor to display information about\n"
13126 "Display the routes advertised to a BGP neighbor\n")
13127{
13128 struct peer *peer;
13129
13130 if (argc == 2)
13131 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13132 else
13133 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13134
13135 if (! peer)
13136 return CMD_WARNING;
13137
13138 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
13139}
13140
Lou Bergerf9b6c392016-01-12 13:42:09 -050013141DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013142 show_bgp_view_ipv6_neighbor_received_routes_cmd,
13143 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000013144 SHOW_STR
13145 BGP_STR
13146 "BGP view\n"
13147 "View name\n"
13148 "Address family\n"
13149 "Detailed information on TCP and BGP neighbor connections\n"
13150 "Neighbor to display information about\n"
13151 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000013152 "Display the received routes from neighbor\n")
13153{
13154 struct peer *peer;
13155
13156 if (argc == 2)
13157 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13158 else
13159 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13160
13161 if (! peer)
13162 return CMD_WARNING;
13163
13164 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
13165}
Lou Berger651b4022016-01-12 13:42:07 -050013166
13167DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
13168 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
13169 "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 +010013170 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013171 BGP_STR
13172 "Address family\n"
13173 "Address Family modifier\n"
13174 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050013175 "Address Family modifier\n"
13176 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013177 "Detailed information on TCP and BGP neighbor connections\n"
13178 "Neighbor to display information about\n"
13179 "Neighbor to display information about\n"
13180 "Display the received routes from neighbor\n")
13181{
paulbb46e942003-10-24 19:02:03 +000013182 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013183 safi_t safi;
13184
13185 if (bgp_parse_safi(argv[0], &safi)) {
13186 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13187 return CMD_WARNING;
13188 }
paul718e3742002-12-13 20:15:29 +000013189
paulbb46e942003-10-24 19:02:03 +000013190 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13191 if (! peer)
13192 return CMD_WARNING;
13193
Lou Berger651b4022016-01-12 13:42:07 -050013194 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000013195}
Lou Berger205e6742016-01-12 13:42:11 -050013196
Lou Berger651b4022016-01-12 13:42:07 -050013197DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
13198 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
13199 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
13200 SHOW_STR
13201 BGP_STR
13202 "Address family\n"
13203 "Address Family modifier\n"
13204 "Address Family modifier\n"
13205 "Address Family modifier\n"
13206 "Address Family modifier\n"
13207 "Detailed information on TCP and BGP neighbor connections\n"
13208 "Neighbor to display information about\n"
13209 "Neighbor to display information about\n"
13210 "Display the received routes from neighbor\n")
13211{
13212 struct peer *peer;
13213 safi_t safi;
13214
13215 if (bgp_parse_safi(argv[0], &safi)) {
13216 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13217 return CMD_WARNING;
13218 }
13219
13220 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13221 if (! peer)
13222 return CMD_WARNING;
13223
13224 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
13225}
paul718e3742002-12-13 20:15:29 +000013226
Michael Lambert95cbbd22010-07-23 14:43:04 -040013227DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
13228 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040013229 "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 -040013230 SHOW_STR
13231 BGP_STR
13232 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013233 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013234 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013235 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013236 "Address family modifier\n"
13237 "Address family modifier\n"
13238 "Detailed information on TCP and BGP neighbor connections\n"
13239 "Neighbor to display information about\n"
13240 "Neighbor to display information about\n"
13241 "Display the advertised routes to neighbor\n"
13242 "Display the received routes from neighbor\n")
13243{
13244 int afi;
13245 int safi;
13246 int in;
13247 struct peer *peer;
13248
David Lamparter94bad672015-03-03 08:52:22 +010013249 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040013250
13251 if (! peer)
13252 return CMD_WARNING;
13253
Michael Lambert95cbbd22010-07-23 14:43:04 -040013254 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
13255 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13256 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040013257
13258 return peer_adj_routes (vty, peer, afi, safi, in);
13259}
13260
Lou Bergerf9b6c392016-01-12 13:42:09 -050013261DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
13262 show_ip_bgp_neighbor_received_prefix_filter_cmd,
13263 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13264 SHOW_STR
13265 IP_STR
13266 BGP_STR
13267 "Detailed information on TCP and BGP neighbor connections\n"
13268 "Neighbor to display information about\n"
13269 "Neighbor to display information about\n"
13270 "Display information received from a BGP neighbor\n"
13271 "Display the prefixlist filter\n")
13272{
13273 char name[BUFSIZ];
13274 union sockunion su;
13275 struct peer *peer;
13276 int count, ret;
13277
13278 ret = str2sockunion (argv[0], &su);
13279 if (ret < 0)
13280 {
13281 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13282 return CMD_WARNING;
13283 }
13284
13285 peer = peer_lookup (NULL, &su);
13286 if (! peer)
13287 return CMD_WARNING;
13288
13289 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13290 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13291 if (count)
13292 {
13293 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13294 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13295 }
13296
13297 return CMD_SUCCESS;
13298}
13299
13300DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
13301 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
13302 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13303 SHOW_STR
13304 IP_STR
13305 BGP_STR
13306 "Address family\n"
13307 "Address Family modifier\n"
13308 "Address Family modifier\n"
13309 "Detailed information on TCP and BGP neighbor connections\n"
13310 "Neighbor to display information about\n"
13311 "Neighbor to display information about\n"
13312 "Display information received from a BGP neighbor\n"
13313 "Display the prefixlist filter\n")
13314{
13315 char name[BUFSIZ];
13316 union sockunion su;
13317 struct peer *peer;
13318 int count, ret;
13319
13320 ret = str2sockunion (argv[1], &su);
13321 if (ret < 0)
13322 {
13323 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13324 return CMD_WARNING;
13325 }
13326
13327 peer = peer_lookup (NULL, &su);
13328 if (! peer)
13329 return CMD_WARNING;
13330
13331 if (strncmp (argv[0], "m", 1) == 0)
13332 {
13333 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
13334 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13335 if (count)
13336 {
13337 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
13338 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13339 }
13340 }
13341 else
13342 {
13343 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13344 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13345 if (count)
13346 {
13347 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13348 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13349 }
13350 }
13351
13352 return CMD_SUCCESS;
13353}
13354
13355ALIAS (show_bgp_view_neighbor_received_routes,
13356 show_bgp_neighbor_received_routes_cmd,
13357 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13358 SHOW_STR
13359 BGP_STR
13360 "Detailed information on TCP and BGP neighbor connections\n"
13361 "Neighbor to display information about\n"
13362 "Neighbor to display information about\n"
13363 "Display the received routes from neighbor\n")
13364
Lou Berger651b4022016-01-12 13:42:07 -050013365DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13366 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13367 "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 +000013368 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013369 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013370 IP_STR
13371 "Address Family modifier\n"
13372 "Address Family modifier\n"
13373 "Address Family modifier\n"
13374 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013375 "Detailed information on TCP and BGP neighbor connections\n"
13376 "Neighbor to display information about\n"
13377 "Neighbor to display information about\n"
13378 "Display information received from a BGP neighbor\n"
13379 "Display the prefixlist filter\n")
13380{
13381 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013382 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013383 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013384 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013385 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013386
Lou Berger651b4022016-01-12 13:42:07 -050013387 if (bgp_parse_safi(argv[0], &safi)) {
13388 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013389 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013390 }
paul718e3742002-12-13 20:15:29 +000013391
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013392 ret = str2sockunion (argv[1], &su);
13393 if (ret < 0)
13394 {
13395 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13396 return CMD_WARNING;
13397 }
paul718e3742002-12-13 20:15:29 +000013398
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013399 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013400 if (! peer)
13401 return CMD_WARNING;
13402
Lou Berger651b4022016-01-12 13:42:07 -050013403 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13404 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13405 if (count) {
13406 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13407 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13408 }
paul718e3742002-12-13 20:15:29 +000013409
13410 return CMD_SUCCESS;
13411}
Lou Berger205e6742016-01-12 13:42:11 -050013412
Lou Berger651b4022016-01-12 13:42:07 -050013413DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13414 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13415 "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 +000013416 SHOW_STR
13417 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013418 IP_STR
13419 "Address Family modifier\n"
13420 "Address Family modifier\n"
13421 "Address Family modifier\n"
13422 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013423 "Detailed information on TCP and BGP neighbor connections\n"
13424 "Neighbor to display information about\n"
13425 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013426 "Display information received from a BGP neighbor\n"
13427 "Display the prefixlist filter\n")
13428{
13429 char name[BUFSIZ];
13430 union sockunion su;
13431 struct peer *peer;
13432 int count, ret;
13433 safi_t safi;
13434
13435 if (bgp_parse_safi(argv[0], &safi)) {
13436 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13437 return CMD_WARNING;
13438 }
13439
13440 ret = str2sockunion (argv[1], &su);
13441 if (ret < 0)
13442 {
13443 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13444 return CMD_WARNING;
13445 }
13446
13447 peer = peer_lookup (NULL, &su);
13448 if (! peer)
13449 return CMD_WARNING;
13450
13451 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13452 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13453 if (count) {
13454 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13455 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13456 }
13457
13458 return CMD_SUCCESS;
13459}
paul718e3742002-12-13 20:15:29 +000013460
Lou Bergerf9b6c392016-01-12 13:42:09 -050013461DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013462 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13463 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013464 SHOW_STR
13465 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013466 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013467 "Detailed information on TCP and BGP neighbor connections\n"
13468 "Neighbor to display information about\n"
13469 "Neighbor to display information about\n"
13470 "Display information received from a BGP neighbor\n"
13471 "Display the prefixlist filter\n")
13472{
13473 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013474 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013475 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013476 int count, ret;
paul718e3742002-12-13 20:15:29 +000013477
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013478 ret = str2sockunion (argv[0], &su);
13479 if (ret < 0)
13480 {
13481 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13482 return CMD_WARNING;
13483 }
paul718e3742002-12-13 20:15:29 +000013484
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013485 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013486 if (! peer)
13487 return CMD_WARNING;
13488
13489 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13490 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13491 if (count)
13492 {
13493 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13494 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13495 }
13496
13497 return CMD_SUCCESS;
13498}
13499
Lou Bergerf9b6c392016-01-12 13:42:09 -050013500DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013501 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13502 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013503 SHOW_STR
13504 BGP_STR
13505 "BGP view\n"
13506 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013507 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013508 "Detailed information on TCP and BGP neighbor connections\n"
13509 "Neighbor to display information about\n"
13510 "Neighbor to display information about\n"
13511 "Display information received from a BGP neighbor\n"
13512 "Display the prefixlist filter\n")
13513{
13514 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013515 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013516 struct peer *peer;
13517 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013518 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013519
13520 /* BGP structure lookup. */
13521 bgp = bgp_lookup_by_name (argv[0]);
13522 if (bgp == NULL)
13523 {
13524 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13525 return CMD_WARNING;
13526 }
13527
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013528 ret = str2sockunion (argv[1], &su);
13529 if (ret < 0)
13530 {
13531 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13532 return CMD_WARNING;
13533 }
paulbb46e942003-10-24 19:02:03 +000013534
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013535 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013536 if (! peer)
13537 return CMD_WARNING;
13538
13539 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13540 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13541 if (count)
13542 {
13543 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13544 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13545 }
13546
13547 return CMD_SUCCESS;
13548}
David Lamparter6b0655a2014-06-04 06:53:35 +020013549
paul94f2b392005-06-28 12:44:16 +000013550static int
paulbb46e942003-10-24 19:02:03 +000013551bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013552 safi_t safi, enum bgp_show_type type)
13553{
paul718e3742002-12-13 20:15:29 +000013554 if (! peer || ! peer->afc[afi][safi])
13555 {
13556 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013557 return CMD_WARNING;
13558 }
13559
ajs5a646652004-11-05 01:25:55 +000013560 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013561}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013562DEFUN (show_ip_bgp_neighbor_routes,
13563 show_ip_bgp_neighbor_routes_cmd,
13564 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13565 SHOW_STR
13566 IP_STR
13567 BGP_STR
13568 "Detailed information on TCP and BGP neighbor connections\n"
13569 "Neighbor to display information about\n"
13570 "Neighbor to display information about\n"
13571 "Display routes learned from neighbor\n")
13572{
13573 struct peer *peer;
13574
13575 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13576 if (! peer)
13577 return CMD_WARNING;
13578
13579 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13580 bgp_show_type_neighbor);
13581}
13582
13583DEFUN (show_ip_bgp_neighbor_flap,
13584 show_ip_bgp_neighbor_flap_cmd,
13585 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13586 SHOW_STR
13587 IP_STR
13588 BGP_STR
13589 "Detailed information on TCP and BGP neighbor connections\n"
13590 "Neighbor to display information about\n"
13591 "Neighbor to display information about\n"
13592 "Display flap statistics of the routes learned from neighbor\n")
13593{
13594 struct peer *peer;
13595
13596 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13597 if (! peer)
13598 return CMD_WARNING;
13599
13600 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13601 bgp_show_type_flap_neighbor);
13602}
13603
13604DEFUN (show_ip_bgp_neighbor_damp,
13605 show_ip_bgp_neighbor_damp_cmd,
13606 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13607 SHOW_STR
13608 IP_STR
13609 BGP_STR
13610 "Detailed information on TCP and BGP neighbor connections\n"
13611 "Neighbor to display information about\n"
13612 "Neighbor to display information about\n"
13613 "Display the dampened routes received from neighbor\n")
13614{
13615 struct peer *peer;
13616
13617 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13618 if (! peer)
13619 return CMD_WARNING;
13620
13621 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13622 bgp_show_type_damp_neighbor);
13623}
13624
13625DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13626 show_ip_bgp_ipv4_neighbor_routes_cmd,
13627 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13628 SHOW_STR
13629 IP_STR
13630 BGP_STR
13631 "Address family\n"
13632 "Address Family modifier\n"
13633 "Address Family modifier\n"
13634 "Detailed information on TCP and BGP neighbor connections\n"
13635 "Neighbor to display information about\n"
13636 "Neighbor to display information about\n"
13637 "Display routes learned from neighbor\n")
13638{
13639 struct peer *peer;
13640
13641 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13642 if (! peer)
13643 return CMD_WARNING;
13644
13645 if (strncmp (argv[0], "m", 1) == 0)
13646 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13647 bgp_show_type_neighbor);
13648
13649 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13650 bgp_show_type_neighbor);
13651}
13652
13653DEFUN (show_ip_bgp_view_rsclient,
13654 show_ip_bgp_view_rsclient_cmd,
13655 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13656 SHOW_STR
13657 IP_STR
13658 BGP_STR
13659 "BGP view\n"
13660 "View name\n"
13661 "Information about Route Server Client\n"
13662 NEIGHBOR_ADDR_STR)
13663{
13664 struct bgp_table *table;
13665 struct peer *peer;
13666
13667 if (argc == 2)
13668 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13669 else
13670 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13671
13672 if (! peer)
13673 return CMD_WARNING;
13674
13675 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13676 {
13677 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13678 VTY_NEWLINE);
13679 return CMD_WARNING;
13680 }
13681
13682 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13683 PEER_FLAG_RSERVER_CLIENT))
13684 {
13685 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13686 VTY_NEWLINE);
13687 return CMD_WARNING;
13688 }
13689
13690 table = peer->rib[AFI_IP][SAFI_UNICAST];
13691
13692 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13693}
13694
13695ALIAS (show_ip_bgp_view_rsclient,
13696 show_ip_bgp_rsclient_cmd,
13697 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13698 SHOW_STR
13699 IP_STR
13700 BGP_STR
13701 "Information about Route Server Client\n"
13702 NEIGHBOR_ADDR_STR)
13703
13704DEFUN (show_bgp_view_ipv4_safi_rsclient,
13705 show_bgp_view_ipv4_safi_rsclient_cmd,
13706 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13707 SHOW_STR
13708 BGP_STR
13709 "BGP view\n"
13710 "View name\n"
13711 "Address family\n"
13712 "Address Family modifier\n"
13713 "Address Family modifier\n"
13714 "Information about Route Server Client\n"
13715 NEIGHBOR_ADDR_STR)
13716{
13717 struct bgp_table *table;
13718 struct peer *peer;
13719 safi_t safi;
13720
13721 if (argc == 3) {
13722 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13723 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13724 } else {
13725 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13726 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13727 }
13728
13729 if (! peer)
13730 return CMD_WARNING;
13731
13732 if (! peer->afc[AFI_IP][safi])
13733 {
13734 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13735 VTY_NEWLINE);
13736 return CMD_WARNING;
13737 }
13738
13739 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13740 PEER_FLAG_RSERVER_CLIENT))
13741 {
13742 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13743 VTY_NEWLINE);
13744 return CMD_WARNING;
13745 }
13746
13747 table = peer->rib[AFI_IP][safi];
13748
13749 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13750}
13751
13752ALIAS (show_bgp_view_ipv4_safi_rsclient,
13753 show_bgp_ipv4_safi_rsclient_cmd,
13754 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13755 SHOW_STR
13756 BGP_STR
13757 "Address family\n"
13758 "Address Family modifier\n"
13759 "Address Family modifier\n"
13760 "Information about Route Server Client\n"
13761 NEIGHBOR_ADDR_STR)
13762
13763DEFUN (show_ip_bgp_view_rsclient_route,
13764 show_ip_bgp_view_rsclient_route_cmd,
13765 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13766 SHOW_STR
13767 IP_STR
13768 BGP_STR
13769 "BGP view\n"
13770 "View name\n"
13771 "Information about Route Server Client\n"
13772 NEIGHBOR_ADDR_STR
13773 "Network in the BGP routing table to display\n")
13774{
13775 struct bgp *bgp;
13776 struct peer *peer;
13777
13778 /* BGP structure lookup. */
13779 if (argc == 3)
13780 {
13781 bgp = bgp_lookup_by_name (argv[0]);
13782 if (bgp == NULL)
13783 {
13784 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13785 return CMD_WARNING;
13786 }
13787 }
13788 else
13789 {
13790 bgp = bgp_get_default ();
13791 if (bgp == NULL)
13792 {
13793 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13794 return CMD_WARNING;
13795 }
13796 }
13797
13798 if (argc == 3)
13799 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13800 else
13801 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13802
13803 if (! peer)
13804 return CMD_WARNING;
13805
13806 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13807 {
13808 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13809 VTY_NEWLINE);
13810 return CMD_WARNING;
13811}
13812
13813 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13814 PEER_FLAG_RSERVER_CLIENT))
13815 {
13816 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13817 VTY_NEWLINE);
13818 return CMD_WARNING;
13819 }
13820
13821 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13822 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070013823 AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050013824}
13825
13826ALIAS (show_ip_bgp_view_rsclient_route,
13827 show_ip_bgp_rsclient_route_cmd,
13828 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13829 SHOW_STR
13830 IP_STR
13831 BGP_STR
13832 "Information about Route Server Client\n"
13833 NEIGHBOR_ADDR_STR
13834 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013835
Lou Berger651b4022016-01-12 13:42:07 -050013836DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13837 show_bgp_ipv4_safi_neighbor_flap_cmd,
13838 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013839 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013840 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013841 "Address Family Modifier\n"
13842 "Address Family Modifier\n"
13843 "Address Family Modifier\n"
13844 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013845 "Detailed information on TCP and BGP neighbor connections\n"
13846 "Neighbor to display information about\n"
13847 "Neighbor to display information about\n"
13848 "Display flap statistics of the routes learned from neighbor\n")
13849{
paulbb46e942003-10-24 19:02:03 +000013850 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013851 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013852
Lou Berger651b4022016-01-12 13:42:07 -050013853 if (bgp_parse_safi(argv[0], &safi)) {
13854 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13855 return CMD_WARNING;
13856 }
13857
13858 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013859 if (! peer)
13860 return CMD_WARNING;
13861
Lou Berger651b4022016-01-12 13:42:07 -050013862 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013863 bgp_show_type_flap_neighbor);
13864}
Lou Berger205e6742016-01-12 13:42:11 -050013865
Lou Berger651b4022016-01-12 13:42:07 -050013866DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13867 show_bgp_ipv6_safi_neighbor_flap_cmd,
13868 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013869 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013870 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013871 "Address Family Modifier\n"
13872 "Address Family Modifier\n"
13873 "Address Family Modifier\n"
13874 "Address Family Modifier\n"
13875 "Detailed information on TCP and BGP neighbor connections\n"
13876 "Neighbor to display information about\n"
13877 "Neighbor to display information about\n"
13878 "Display flap statistics of the routes learned from neighbor\n")
13879{
13880 struct peer *peer;
13881 safi_t safi;
13882
13883 if (bgp_parse_safi(argv[0], &safi)) {
13884 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13885 return CMD_WARNING;
13886 }
13887
13888 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13889 if (! peer)
13890 return CMD_WARNING;
13891
13892 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13893 bgp_show_type_flap_neighbor);
13894}
Lou Berger651b4022016-01-12 13:42:07 -050013895
13896DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13897 show_bgp_ipv4_safi_neighbor_damp_cmd,
13898 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13899 SHOW_STR
13900 BGP_STR
13901 "Address Family Modifier\n"
13902 "Address Family Modifier\n"
13903 "Address Family Modifier\n"
13904 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013905 "Detailed information on TCP and BGP neighbor connections\n"
13906 "Neighbor to display information about\n"
13907 "Neighbor to display information about\n"
13908 "Display the dampened routes received from neighbor\n")
13909{
paulbb46e942003-10-24 19:02:03 +000013910 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013911 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013912
Lou Berger651b4022016-01-12 13:42:07 -050013913 if (bgp_parse_safi(argv[0], &safi)) {
13914 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13915 return CMD_WARNING;
13916 }
13917
13918 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013919 if (! peer)
13920 return CMD_WARNING;
13921
Lou Berger651b4022016-01-12 13:42:07 -050013922 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013923 bgp_show_type_damp_neighbor);
13924}
Lou Berger205e6742016-01-12 13:42:11 -050013925
Lou Berger651b4022016-01-12 13:42:07 -050013926DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13927 show_bgp_ipv6_safi_neighbor_damp_cmd,
13928 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013929 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013930 BGP_STR
13931 "Address Family Modifier\n"
13932 "Address Family Modifier\n"
13933 "Address Family Modifier\n"
13934 "Address Family Modifier\n"
13935 "Detailed information on TCP and BGP neighbor connections\n"
13936 "Neighbor to display information about\n"
13937 "Neighbor to display information about\n"
13938 "Display the dampened routes received from neighbor\n")
13939{
13940 struct peer *peer;
13941 safi_t safi;
13942
13943 if (bgp_parse_safi(argv[0], &safi)) {
13944 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13945 return CMD_WARNING;
13946 }
13947
13948 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13949 if (! peer)
13950 return CMD_WARNING;
13951
13952 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13953 bgp_show_type_damp_neighbor);
13954}
Lou Berger651b4022016-01-12 13:42:07 -050013955
13956DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13957 show_bgp_ipv4_safi_neighbor_routes_cmd,
13958 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13959 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013960 BGP_STR
13961 "Address family\n"
13962 "Address Family modifier\n"
13963 "Address Family modifier\n"
13964 "Detailed information on TCP and BGP neighbor connections\n"
13965 "Neighbor to display information about\n"
13966 "Neighbor to display information about\n"
13967 "Display routes learned from neighbor\n")
13968{
paulbb46e942003-10-24 19:02:03 +000013969 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013970 safi_t safi;
13971
13972 if (bgp_parse_safi(argv[0], &safi)) {
13973 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13974 return CMD_WARNING;
13975 }
paulbb46e942003-10-24 19:02:03 +000013976
13977 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13978 if (! peer)
13979 return CMD_WARNING;
13980
Lou Berger651b4022016-01-12 13:42:07 -050013981 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013982 bgp_show_type_neighbor);
13983}
Lou Berger205e6742016-01-12 13:42:11 -050013984
Lou Berger651b4022016-01-12 13:42:07 -050013985DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13986 show_bgp_ipv6_safi_neighbor_routes_cmd,
13987 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013988 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013989 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013990 "Address family\n"
13991 "Address Family modifier\n"
13992 "Address Family modifier\n"
13993 "Detailed information on TCP and BGP neighbor connections\n"
13994 NEIGHBOR_ADDR_STR
13995 NEIGHBOR_ADDR_STR
13996 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000013997{
paulfee0f4c2004-09-13 05:12:46 +000013998 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013999 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000014000
Lou Berger651b4022016-01-12 13:42:07 -050014001 if (bgp_parse_safi(argv[0], &safi)) {
14002 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14003 return CMD_WARNING;
14004 }
paulfee0f4c2004-09-13 05:12:46 +000014005
Lou Berger651b4022016-01-12 13:42:07 -050014006 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000014007 if (! peer)
14008 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050014009
14010 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14011 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000014012}
paulfee0f4c2004-09-13 05:12:46 +000014013
Michael Lambert95cbbd22010-07-23 14:43:04 -040014014DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
14015 show_bgp_view_ipv4_safi_rsclient_route_cmd,
14016 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14017 SHOW_STR
14018 BGP_STR
14019 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014020 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014021 "Address family\n"
14022 "Address Family modifier\n"
14023 "Address Family modifier\n"
14024 "Information about Route Server Client\n"
14025 NEIGHBOR_ADDR_STR
14026 "Network in the BGP routing table to display\n")
14027{
14028 struct bgp *bgp;
14029 struct peer *peer;
14030 safi_t safi;
14031
14032 /* BGP structure lookup. */
14033 if (argc == 4)
14034 {
14035 bgp = bgp_lookup_by_name (argv[0]);
14036 if (bgp == NULL)
14037 {
14038 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14039 return CMD_WARNING;
14040 }
14041 }
14042 else
14043 {
14044 bgp = bgp_get_default ();
14045 if (bgp == NULL)
14046 {
14047 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14048 return CMD_WARNING;
14049 }
14050 }
14051
14052 if (argc == 4) {
14053 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14054 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14055 } else {
14056 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14057 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14058 }
14059
14060 if (! peer)
14061 return CMD_WARNING;
14062
14063 if (! peer->afc[AFI_IP][safi])
14064 {
14065 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14066 VTY_NEWLINE);
14067 return CMD_WARNING;
14068}
14069
14070 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14071 PEER_FLAG_RSERVER_CLIENT))
14072 {
14073 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14074 VTY_NEWLINE);
14075 return CMD_WARNING;
14076 }
14077
14078 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
14079 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014080 AFI_IP, safi, NULL, 0, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014081}
14082
14083ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
14084 show_bgp_ipv4_safi_rsclient_route_cmd,
14085 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14086 SHOW_STR
14087 BGP_STR
14088 "Address family\n"
14089 "Address Family modifier\n"
14090 "Address Family modifier\n"
14091 "Information about Route Server Client\n"
14092 NEIGHBOR_ADDR_STR
14093 "Network in the BGP routing table to display\n")
14094
paulfee0f4c2004-09-13 05:12:46 +000014095
Michael Lambert95cbbd22010-07-23 14:43:04 -040014096DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
14097 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
14098 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14099 SHOW_STR
14100 BGP_STR
14101 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014102 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014103 "Address family\n"
14104 "Address Family modifier\n"
14105 "Address Family modifier\n"
14106 "Information about Route Server Client\n"
14107 NEIGHBOR_ADDR_STR
14108 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14109{
14110 struct bgp *bgp;
14111 struct peer *peer;
14112 safi_t safi;
14113
14114 /* BGP structure lookup. */
14115 if (argc == 4)
14116 {
14117 bgp = bgp_lookup_by_name (argv[0]);
14118 if (bgp == NULL)
14119 {
14120 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14121 return CMD_WARNING;
14122 }
14123 }
14124 else
14125 {
14126 bgp = bgp_get_default ();
14127 if (bgp == NULL)
14128 {
14129 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14130 return CMD_WARNING;
14131 }
14132 }
14133
14134 if (argc == 4) {
14135 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14136 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14137 } else {
14138 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14139 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14140 }
14141
14142 if (! peer)
14143 return CMD_WARNING;
14144
14145 if (! peer->afc[AFI_IP][safi])
14146 {
14147 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14148 VTY_NEWLINE);
14149 return CMD_WARNING;
14150}
14151
14152 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14153 PEER_FLAG_RSERVER_CLIENT))
14154{
14155 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14156 VTY_NEWLINE);
14157 return CMD_WARNING;
14158 }
14159
14160 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
14161 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014162 AFI_IP, safi, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014163}
14164
Lou Bergerf9b6c392016-01-12 13:42:09 -050014165DEFUN (show_ip_bgp_view_rsclient_prefix,
14166 show_ip_bgp_view_rsclient_prefix_cmd,
14167 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14168 SHOW_STR
14169 IP_STR
14170 BGP_STR
14171 "BGP view\n"
14172 "View name\n"
14173 "Information about Route Server Client\n"
14174 NEIGHBOR_ADDR_STR
14175 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14176{
14177 struct bgp *bgp;
14178 struct peer *peer;
14179
14180 /* BGP structure lookup. */
14181 if (argc == 3)
14182 {
14183 bgp = bgp_lookup_by_name (argv[0]);
14184 if (bgp == NULL)
14185 {
14186 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14187 return CMD_WARNING;
14188 }
14189 }
14190 else
14191 {
14192 bgp = bgp_get_default ();
14193 if (bgp == NULL)
14194 {
14195 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14196 return CMD_WARNING;
14197 }
14198 }
14199
14200 if (argc == 3)
14201 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14202 else
14203 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14204
14205 if (! peer)
14206 return CMD_WARNING;
14207
14208 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14209 {
14210 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14211 VTY_NEWLINE);
14212 return CMD_WARNING;
14213}
14214
14215 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14216 PEER_FLAG_RSERVER_CLIENT))
14217{
14218 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14219 VTY_NEWLINE);
14220 return CMD_WARNING;
14221 }
14222
14223 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
14224 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014225 AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050014226}
14227
14228ALIAS (show_ip_bgp_view_rsclient_prefix,
14229 show_ip_bgp_rsclient_prefix_cmd,
14230 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14231 SHOW_STR
14232 IP_STR
14233 BGP_STR
14234 "Information about Route Server Client\n"
14235 NEIGHBOR_ADDR_STR
14236 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14237
Michael Lambert95cbbd22010-07-23 14:43:04 -040014238ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
14239 show_bgp_ipv4_safi_rsclient_prefix_cmd,
14240 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
14241 SHOW_STR
14242 BGP_STR
14243 "Address family\n"
14244 "Address Family modifier\n"
14245 "Address Family modifier\n"
14246 "Information about Route Server Client\n"
14247 NEIGHBOR_ADDR_STR
14248 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000014249
Lou Bergerf9b6c392016-01-12 13:42:09 -050014250DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050014251 show_bgp_view_ipv6_neighbor_routes_cmd,
14252 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000014253 SHOW_STR
14254 BGP_STR
14255 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014256 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014257 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000014258 "Detailed information on TCP and BGP neighbor connections\n"
14259 "Neighbor to display information about\n"
14260 "Neighbor to display information about\n"
14261 "Display routes learned from neighbor\n")
14262{
14263 struct peer *peer;
14264
14265 if (argc == 2)
14266 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14267 else
14268 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14269
14270 if (! peer)
14271 return CMD_WARNING;
14272
14273 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14274 bgp_show_type_neighbor);
14275}
14276
Lou Berger651b4022016-01-12 13:42:07 -050014277DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014278 show_bgp_view_neighbor_damp_cmd,
14279 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14280 SHOW_STR
14281 BGP_STR
14282 "BGP view\n"
14283 "View name\n"
14284 "Detailed information on TCP and BGP neighbor connections\n"
14285 "Neighbor to display information about\n"
14286 "Neighbor to display information about\n"
14287 "Display the dampened routes received from neighbor\n")
14288{
14289 struct peer *peer;
14290
14291 if (argc == 2)
14292 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14293 else
14294 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14295
14296 if (! peer)
14297 return CMD_WARNING;
14298
14299 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14300 bgp_show_type_damp_neighbor);
14301}
14302
14303DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050014304 show_bgp_view_ipv6_neighbor_damp_cmd,
14305 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000014306 SHOW_STR
14307 BGP_STR
14308 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014309 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014310 "Address family\n"
14311 "Detailed information on TCP and BGP neighbor connections\n"
14312 "Neighbor to display information about\n"
14313 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000014314 "Display the dampened routes received from neighbor\n")
14315{
14316 struct peer *peer;
14317
14318 if (argc == 2)
14319 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14320 else
14321 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14322
14323 if (! peer)
14324 return CMD_WARNING;
14325
14326 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14327 bgp_show_type_damp_neighbor);
14328}
14329
Lou Bergerf9b6c392016-01-12 13:42:09 -050014330DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050014331 show_bgp_view_ipv6_neighbor_flap_cmd,
14332 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000014333 SHOW_STR
14334 BGP_STR
14335 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014336 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014337 "Address family\n"
14338 "Detailed information on TCP and BGP neighbor connections\n"
14339 "Neighbor to display information about\n"
14340 "Neighbor to display information about\n"
14341 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000014342{
14343 struct peer *peer;
14344
14345 if (argc == 2)
14346 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14347 else
14348 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14349
14350 if (! peer)
14351 return CMD_WARNING;
14352
14353 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14354 bgp_show_type_flap_neighbor);
14355}
14356
Lou Bergerf9b6c392016-01-12 13:42:09 -050014357DEFUN (show_bgp_view_neighbor_flap,
14358 show_bgp_view_neighbor_flap_cmd,
14359 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14360 SHOW_STR
14361 BGP_STR
14362 "BGP view\n"
14363 "View name\n"
14364 "Detailed information on TCP and BGP neighbor connections\n"
14365 "Neighbor to display information about\n"
14366 "Neighbor to display information about\n"
14367 "Display flap statistics of the routes learned from neighbor\n")
14368{
14369 struct peer *peer;
14370
14371 if (argc == 2)
14372 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14373 else
14374 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14375
14376 if (! peer)
14377 return CMD_WARNING;
14378
14379 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14380 bgp_show_type_flap_neighbor);
14381}
14382
14383ALIAS (show_bgp_view_neighbor_flap,
14384 show_bgp_neighbor_flap_cmd,
14385 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14386 SHOW_STR
14387 BGP_STR
14388 "Detailed information on TCP and BGP neighbor connections\n"
14389 "Neighbor to display information about\n"
14390 "Neighbor to display information about\n"
14391 "Display flap statistics of the routes learned from neighbor\n")
14392
14393ALIAS (show_bgp_view_neighbor_damp,
14394 show_bgp_neighbor_damp_cmd,
14395 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14396 SHOW_STR
14397 BGP_STR
14398 "Detailed information on TCP and BGP neighbor connections\n"
14399 "Neighbor to display information about\n"
14400 "Neighbor to display information about\n"
14401 "Display the dampened routes received from neighbor\n")
14402
14403DEFUN (show_bgp_view_neighbor_routes,
14404 show_bgp_view_neighbor_routes_cmd,
14405 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
14406 SHOW_STR
14407 BGP_STR
14408 "BGP view\n"
14409 "View name\n"
14410 "Detailed information on TCP and BGP neighbor connections\n"
14411 "Neighbor to display information about\n"
14412 "Neighbor to display information about\n"
14413 "Display routes learned from neighbor\n")
14414{
14415 struct peer *peer;
14416
14417 if (argc == 2)
14418 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14419 else
14420 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14421
14422 if (! peer)
14423 return CMD_WARNING;
14424
14425 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14426 bgp_show_type_neighbor);
14427}
14428
14429ALIAS (show_bgp_view_neighbor_routes,
14430 show_bgp_neighbor_routes_cmd,
14431 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
14432 SHOW_STR
14433 BGP_STR
14434 "Detailed information on TCP and BGP neighbor connections\n"
14435 "Neighbor to display information about\n"
14436 "Neighbor to display information about\n"
14437 "Display routes learned from neighbor\n")
14438
paulbb46e942003-10-24 19:02:03 +000014439ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014440 show_bgp_ipv6_neighbor_routes_cmd,
14441 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14442 SHOW_STR
14443 BGP_STR
14444 "Address family\n"
14445 "Detailed information on TCP and BGP neighbor connections\n"
14446 "Neighbor to display information about\n"
14447 "Neighbor to display information about\n"
14448 "Display routes learned from neighbor\n")
14449
Lou Bergerf9b6c392016-01-12 13:42:09 -050014450/* old command */
14451ALIAS (show_bgp_view_neighbor_routes,
14452 ipv6_bgp_neighbor_routes_cmd,
14453 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14454 SHOW_STR
14455 IPV6_STR
14456 BGP_STR
14457 "Detailed information on TCP and BGP neighbor connections\n"
14458 "Neighbor to display information about\n"
14459 "Neighbor to display information about\n"
14460 "Display routes learned from neighbor\n")
14461
14462/* old command */
14463DEFUN (ipv6_mbgp_neighbor_routes,
14464 ipv6_mbgp_neighbor_routes_cmd,
14465 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14466 SHOW_STR
14467 IPV6_STR
14468 MBGP_STR
14469 "Detailed information on TCP and BGP neighbor connections\n"
14470 "Neighbor to display information about\n"
14471 "Neighbor to display information about\n"
14472 "Display routes learned from neighbor\n")
14473{
14474 struct peer *peer;
14475
14476 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14477 if (! peer)
14478 return CMD_WARNING;
14479
14480 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14481 bgp_show_type_neighbor);
14482}
14483
paulbb46e942003-10-24 19:02:03 +000014484ALIAS (show_bgp_view_neighbor_flap,
14485 show_bgp_ipv6_neighbor_flap_cmd,
14486 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14487 SHOW_STR
14488 BGP_STR
14489 "Address family\n"
14490 "Detailed information on TCP and BGP neighbor connections\n"
14491 "Neighbor to display information about\n"
14492 "Neighbor to display information about\n"
14493 "Display flap statistics of the routes learned from neighbor\n")
14494
14495ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014496 show_bgp_ipv6_neighbor_damp_cmd,
14497 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14498 SHOW_STR
14499 BGP_STR
14500 "Address family\n"
14501 "Detailed information on TCP and BGP neighbor connections\n"
14502 "Neighbor to display information about\n"
14503 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014504 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014505
Lou Bergerf9b6c392016-01-12 13:42:09 -050014506DEFUN (show_bgp_view_rsclient,
14507 show_bgp_view_rsclient_cmd,
14508 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14509 SHOW_STR
14510 BGP_STR
14511 "BGP view\n"
14512 "View name\n"
14513 "Information about Route Server Client\n"
14514 NEIGHBOR_ADDR_STR)
14515{
14516 struct bgp_table *table;
14517 struct peer *peer;
14518
14519 if (argc == 2)
14520 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14521 else
14522 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14523
14524 if (! peer)
14525 return CMD_WARNING;
14526
14527 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14528 {
14529 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14530 VTY_NEWLINE);
14531 return CMD_WARNING;
14532 }
14533
14534 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14535 PEER_FLAG_RSERVER_CLIENT))
14536 {
14537 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14538 VTY_NEWLINE);
14539 return CMD_WARNING;
14540 }
14541
14542 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14543
14544 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14545}
14546
14547ALIAS (show_bgp_view_rsclient,
14548 show_bgp_rsclient_cmd,
14549 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14550 SHOW_STR
14551 BGP_STR
14552 "Information about Route Server Client\n"
14553 NEIGHBOR_ADDR_STR)
14554
Lou Berger651b4022016-01-12 13:42:07 -050014555DEFUN (show_bgp_view_ipv4_rsclient,
14556 show_bgp_view_ipv4_rsclient_cmd,
14557 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014558 SHOW_STR
14559 BGP_STR
14560 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014561 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014562 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014563 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014564 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014565{
Lou Berger651b4022016-01-12 13:42:07 -050014566 struct bgp_table *table;
14567 struct peer *peer;
14568
14569 if (argc == 2)
14570 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14571 else
14572 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14573
14574 if (! peer)
14575 return CMD_WARNING;
14576
14577 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14578 {
14579 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14580 VTY_NEWLINE);
14581 return CMD_WARNING;
14582 }
14583
14584 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14585 PEER_FLAG_RSERVER_CLIENT))
14586 {
14587 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14588 VTY_NEWLINE);
14589 return CMD_WARNING;
14590 }
14591
14592 table = peer->rib[AFI_IP][SAFI_UNICAST];
14593
14594 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14595}
14596DEFUN (show_bgp_view_ipv6_rsclient,
14597 show_bgp_view_ipv6_rsclient_cmd,
14598 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14599 SHOW_STR
14600 BGP_STR
14601 "BGP view\n"
14602 "BGP view name\n"
14603 "Address Family\n"
14604 "Information about Route Server Client\n"
14605 NEIGHBOR_ADDR_STR2)
14606{
14607 struct bgp_table *table;
14608 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014609
14610 if (argc == 2)
14611 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14612 else
14613 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14614
14615 if (! peer)
14616 return CMD_WARNING;
14617
14618 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14619 {
14620 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14621 VTY_NEWLINE);
14622 return CMD_WARNING;
14623 }
14624
14625 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14626 PEER_FLAG_RSERVER_CLIENT))
14627 {
14628 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14629 VTY_NEWLINE);
14630 return CMD_WARNING;
14631 }
14632
14633 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14634
ajs5a646652004-11-05 01:25:55 +000014635 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014636}
14637
Lou Berger651b4022016-01-12 13:42:07 -050014638ALIAS (show_bgp_view_ipv4_rsclient,
14639 show_bgp_ipv4_rsclient_cmd,
14640 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014641 SHOW_STR
14642 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014643 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014644 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014645 NEIGHBOR_ADDR_STR2)
14646
Lou Berger651b4022016-01-12 13:42:07 -050014647ALIAS (show_bgp_view_ipv6_rsclient,
14648 show_bgp_ipv6_rsclient_cmd,
14649 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14650 SHOW_STR
14651 BGP_STR
14652 "Address Family\n"
14653 "Information about Route Server Client\n"
14654 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014655
Michael Lambert95cbbd22010-07-23 14:43:04 -040014656DEFUN (show_bgp_view_ipv6_safi_rsclient,
14657 show_bgp_view_ipv6_safi_rsclient_cmd,
14658 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14659 SHOW_STR
14660 BGP_STR
14661 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014662 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014663 "Address family\n"
14664 "Address Family modifier\n"
14665 "Address Family modifier\n"
14666 "Information about Route Server Client\n"
14667 NEIGHBOR_ADDR_STR)
14668{
14669 struct bgp_table *table;
14670 struct peer *peer;
14671 safi_t safi;
14672
14673 if (argc == 3) {
14674 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14675 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14676 } else {
14677 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14678 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14679 }
14680
14681 if (! peer)
14682 return CMD_WARNING;
14683
14684 if (! peer->afc[AFI_IP6][safi])
14685 {
14686 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14687 VTY_NEWLINE);
14688 return CMD_WARNING;
14689 }
14690
14691 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14692 PEER_FLAG_RSERVER_CLIENT))
14693 {
14694 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14695 VTY_NEWLINE);
14696 return CMD_WARNING;
14697 }
14698
14699 table = peer->rib[AFI_IP6][safi];
14700
14701 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14702}
14703
14704ALIAS (show_bgp_view_ipv6_safi_rsclient,
14705 show_bgp_ipv6_safi_rsclient_cmd,
14706 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14707 SHOW_STR
14708 BGP_STR
14709 "Address family\n"
14710 "Address Family modifier\n"
14711 "Address Family modifier\n"
14712 "Information about Route Server Client\n"
14713 NEIGHBOR_ADDR_STR)
14714
paulfee0f4c2004-09-13 05:12:46 +000014715DEFUN (show_bgp_view_rsclient_route,
14716 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014717 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14718 SHOW_STR
14719 BGP_STR
14720 "BGP view\n"
14721 "View name\n"
14722 "Information about Route Server Client\n"
14723 NEIGHBOR_ADDR_STR
14724 "Network in the BGP routing table to display\n")
14725{
14726 struct bgp *bgp;
14727 struct peer *peer;
14728
14729 /* BGP structure lookup. */
14730 if (argc == 3)
14731 {
14732 bgp = bgp_lookup_by_name (argv[0]);
14733 if (bgp == NULL)
14734 {
14735 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14736 return CMD_WARNING;
14737 }
14738 }
14739 else
14740 {
14741 bgp = bgp_get_default ();
14742 if (bgp == NULL)
14743 {
14744 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14745 return CMD_WARNING;
14746 }
14747 }
14748
14749 if (argc == 3)
14750 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14751 else
14752 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14753
14754 if (! peer)
14755 return CMD_WARNING;
14756
14757 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14758 {
14759 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14760 VTY_NEWLINE);
14761 return CMD_WARNING;
14762 }
14763
14764 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14765 PEER_FLAG_RSERVER_CLIENT))
14766 {
14767 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14768 VTY_NEWLINE);
14769 return CMD_WARNING;
14770 }
14771
14772 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14773 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014774 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050014775}
14776
14777DEFUN (show_bgp_view_ipv6_rsclient_route,
14778 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014779 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014780 SHOW_STR
14781 BGP_STR
14782 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014783 "BGP view name\n"
14784 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014785 "Information about Route Server Client\n"
14786 NEIGHBOR_ADDR_STR
14787 "Network in the BGP routing table to display\n")
14788{
14789 struct bgp *bgp;
14790 struct peer *peer;
14791
14792 /* BGP structure lookup. */
14793 if (argc == 3)
14794 {
14795 bgp = bgp_lookup_by_name (argv[0]);
14796 if (bgp == NULL)
14797 {
14798 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14799 return CMD_WARNING;
14800 }
14801 }
14802 else
14803 {
14804 bgp = bgp_get_default ();
14805 if (bgp == NULL)
14806 {
14807 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14808 return CMD_WARNING;
14809 }
14810 }
14811
14812 if (argc == 3)
14813 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14814 else
14815 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14816
14817 if (! peer)
14818 return CMD_WARNING;
14819
14820 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14821 {
14822 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14823 VTY_NEWLINE);
14824 return CMD_WARNING;
14825 }
14826
14827 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14828 PEER_FLAG_RSERVER_CLIENT))
14829 {
14830 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14831 VTY_NEWLINE);
14832 return CMD_WARNING;
14833 }
14834
14835 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14836 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014837 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paulfee0f4c2004-09-13 05:12:46 +000014838}
14839
Lou Bergerf9b6c392016-01-12 13:42:09 -050014840ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014841 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014842 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14843 SHOW_STR
14844 BGP_STR
14845 "Information about Route Server Client\n"
14846 NEIGHBOR_ADDR_STR
14847 "Network in the BGP routing table to display\n")
14848
14849ALIAS (show_bgp_view_ipv6_rsclient_route,
14850 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014851 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014852 SHOW_STR
14853 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014854 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014855 "Information about Route Server Client\n"
14856 NEIGHBOR_ADDR_STR
14857 "Network in the BGP routing table to display\n")
14858
Michael Lambert95cbbd22010-07-23 14:43:04 -040014859DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14860 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14861 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14862 SHOW_STR
14863 BGP_STR
14864 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014865 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014866 "Address family\n"
14867 "Address Family modifier\n"
14868 "Address Family modifier\n"
14869 "Information about Route Server Client\n"
14870 NEIGHBOR_ADDR_STR
14871 "Network in the BGP routing table to display\n")
14872{
14873 struct bgp *bgp;
14874 struct peer *peer;
14875 safi_t safi;
14876
14877 /* BGP structure lookup. */
14878 if (argc == 4)
14879 {
14880 bgp = bgp_lookup_by_name (argv[0]);
14881 if (bgp == NULL)
14882 {
14883 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14884 return CMD_WARNING;
14885 }
14886 }
14887 else
14888 {
14889 bgp = bgp_get_default ();
14890 if (bgp == NULL)
14891 {
14892 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14893 return CMD_WARNING;
14894 }
14895 }
14896
14897 if (argc == 4) {
14898 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14899 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14900 } else {
14901 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14902 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14903 }
14904
14905 if (! peer)
14906 return CMD_WARNING;
14907
14908 if (! peer->afc[AFI_IP6][safi])
14909 {
14910 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14911 VTY_NEWLINE);
14912 return CMD_WARNING;
14913}
14914
14915 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14916 PEER_FLAG_RSERVER_CLIENT))
14917 {
14918 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14919 VTY_NEWLINE);
14920 return CMD_WARNING;
14921 }
14922
14923 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14924 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014925 AFI_IP6, safi, NULL, 0, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014926}
14927
14928ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14929 show_bgp_ipv6_safi_rsclient_route_cmd,
14930 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14931 SHOW_STR
14932 BGP_STR
14933 "Address family\n"
14934 "Address Family modifier\n"
14935 "Address Family modifier\n"
14936 "Information about Route Server Client\n"
14937 NEIGHBOR_ADDR_STR
14938 "Network in the BGP routing table to display\n")
14939
Lou Berger651b4022016-01-12 13:42:07 -050014940
paulfee0f4c2004-09-13 05:12:46 +000014941DEFUN (show_bgp_view_rsclient_prefix,
14942 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014943 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14944 SHOW_STR
14945 BGP_STR
14946 "BGP view\n"
14947 "View name\n"
14948 "Information about Route Server Client\n"
14949 NEIGHBOR_ADDR_STR
14950 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14951{
14952 struct bgp *bgp;
14953 struct peer *peer;
14954
14955 /* BGP structure lookup. */
14956 if (argc == 3)
14957 {
14958 bgp = bgp_lookup_by_name (argv[0]);
14959 if (bgp == NULL)
14960 {
14961 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14962 return CMD_WARNING;
14963 }
14964 }
14965 else
14966 {
14967 bgp = bgp_get_default ();
14968 if (bgp == NULL)
14969 {
14970 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14971 return CMD_WARNING;
14972 }
14973 }
14974
14975 if (argc == 3)
14976 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14977 else
14978 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14979
14980 if (! peer)
14981 return CMD_WARNING;
14982
14983 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14984 {
14985 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14986 VTY_NEWLINE);
14987 return CMD_WARNING;
14988 }
14989
14990 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14991 PEER_FLAG_RSERVER_CLIENT))
14992 {
14993 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14994 VTY_NEWLINE);
14995 return CMD_WARNING;
14996 }
14997
14998 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14999 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015000 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050015001}
15002
15003DEFUN (show_bgp_view_ipv6_rsclient_prefix,
15004 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015005 "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 +000015006 SHOW_STR
15007 BGP_STR
15008 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015009 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050015010 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000015011 "Information about Route Server Client\n"
15012 NEIGHBOR_ADDR_STR
15013 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15014{
15015 struct bgp *bgp;
15016 struct peer *peer;
15017
15018 /* BGP structure lookup. */
15019 if (argc == 3)
15020 {
15021 bgp = bgp_lookup_by_name (argv[0]);
15022 if (bgp == NULL)
15023 {
15024 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15025 return CMD_WARNING;
15026 }
15027 }
15028 else
15029 {
15030 bgp = bgp_get_default ();
15031 if (bgp == NULL)
15032 {
15033 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15034 return CMD_WARNING;
15035 }
15036 }
15037
15038 if (argc == 3)
15039 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15040 else
15041 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15042
15043 if (! peer)
15044 return CMD_WARNING;
15045
15046 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15047 {
15048 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15049 VTY_NEWLINE);
15050 return CMD_WARNING;
15051 }
15052
15053 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15054 PEER_FLAG_RSERVER_CLIENT))
15055 {
15056 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15057 VTY_NEWLINE);
15058 return CMD_WARNING;
15059 }
15060
15061 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15062 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015063 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paulfee0f4c2004-09-13 05:12:46 +000015064}
15065
Lou Bergerf9b6c392016-01-12 13:42:09 -050015066ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000015067 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050015068 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15069 SHOW_STR
15070 BGP_STR
15071 "Information about Route Server Client\n"
15072 NEIGHBOR_ADDR_STR
15073 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15074
15075ALIAS (show_bgp_view_ipv6_rsclient_prefix,
15076 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015077 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000015078 SHOW_STR
15079 BGP_STR
15080 "Information about Route Server Client\n"
15081 NEIGHBOR_ADDR_STR
15082 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15083
Michael Lambert95cbbd22010-07-23 14:43:04 -040015084DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
15085 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
15086 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15087 SHOW_STR
15088 BGP_STR
15089 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015090 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040015091 "Address family\n"
15092 "Address Family modifier\n"
15093 "Address Family modifier\n"
15094 "Information about Route Server Client\n"
15095 NEIGHBOR_ADDR_STR
15096 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
15097{
15098 struct bgp *bgp;
15099 struct peer *peer;
15100 safi_t safi;
15101
15102 /* BGP structure lookup. */
15103 if (argc == 4)
15104 {
15105 bgp = bgp_lookup_by_name (argv[0]);
15106 if (bgp == NULL)
15107 {
15108 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15109 return CMD_WARNING;
15110 }
15111 }
15112 else
15113 {
15114 bgp = bgp_get_default ();
15115 if (bgp == NULL)
15116 {
15117 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15118 return CMD_WARNING;
15119 }
15120 }
15121
15122 if (argc == 4) {
15123 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15124 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15125 } else {
15126 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15127 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15128 }
15129
15130 if (! peer)
15131 return CMD_WARNING;
15132
15133 if (! peer->afc[AFI_IP6][safi])
15134 {
15135 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15136 VTY_NEWLINE);
15137 return CMD_WARNING;
15138}
15139
15140 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
15141 PEER_FLAG_RSERVER_CLIENT))
15142{
15143 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15144 VTY_NEWLINE);
15145 return CMD_WARNING;
15146 }
15147
15148 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
15149 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015150 AFI_IP6, safi, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015151}
15152
15153ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
15154 show_bgp_ipv6_safi_rsclient_prefix_cmd,
15155 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15156 SHOW_STR
15157 BGP_STR
15158 "Address family\n"
15159 "Address Family modifier\n"
15160 "Address Family modifier\n"
15161 "Information about Route Server Client\n"
15162 NEIGHBOR_ADDR_STR
15163 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
15164
paul718e3742002-12-13 20:15:29 +000015165struct bgp_table *bgp_distance_table;
15166
15167struct bgp_distance
15168{
15169 /* Distance value for the IP source prefix. */
15170 u_char distance;
15171
15172 /* Name of the access-list to be matched. */
15173 char *access_list;
15174};
15175
paul94f2b392005-06-28 12:44:16 +000015176static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015177bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000015178{
Stephen Hemminger393deb92008-08-18 14:13:29 -070015179 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000015180}
15181
paul94f2b392005-06-28 12:44:16 +000015182static void
paul718e3742002-12-13 20:15:29 +000015183bgp_distance_free (struct bgp_distance *bdistance)
15184{
15185 XFREE (MTYPE_BGP_DISTANCE, bdistance);
15186}
15187
paul94f2b392005-06-28 12:44:16 +000015188static int
paulfd79ac92004-10-13 05:06:08 +000015189bgp_distance_set (struct vty *vty, const char *distance_str,
15190 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000015191{
15192 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015193 struct prefix p;
paul718e3742002-12-13 20:15:29 +000015194 u_char distance;
15195 struct bgp_node *rn;
15196 struct bgp_distance *bdistance;
15197
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015198 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000015199 if (ret == 0)
15200 {
15201 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
15202 return CMD_WARNING;
15203 }
15204
15205 distance = atoi (distance_str);
15206
15207 /* Get BGP distance node. */
15208 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
15209 if (rn->info)
15210 {
15211 bdistance = rn->info;
15212 bgp_unlock_node (rn);
15213 }
15214 else
15215 {
15216 bdistance = bgp_distance_new ();
15217 rn->info = bdistance;
15218 }
15219
15220 /* Set distance value. */
15221 bdistance->distance = distance;
15222
15223 /* Reset access-list configuration. */
15224 if (bdistance->access_list)
15225 {
15226 free (bdistance->access_list);
15227 bdistance->access_list = NULL;
15228 }
15229 if (access_list_str)
15230 bdistance->access_list = strdup (access_list_str);
15231
15232 return CMD_SUCCESS;
15233}
15234
paul94f2b392005-06-28 12:44:16 +000015235static int
paulfd79ac92004-10-13 05:06:08 +000015236bgp_distance_unset (struct vty *vty, const char *distance_str,
15237 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000015238{
15239 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015240 struct prefix p;
paul718e3742002-12-13 20:15:29 +000015241 u_char distance;
15242 struct bgp_node *rn;
15243 struct bgp_distance *bdistance;
15244
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015245 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000015246 if (ret == 0)
15247 {
15248 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
15249 return CMD_WARNING;
15250 }
15251
15252 distance = atoi (distance_str);
15253
15254 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
15255 if (! rn)
15256 {
15257 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
15258 return CMD_WARNING;
15259 }
15260
15261 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010015262
15263 if (bdistance->distance != distance)
15264 {
15265 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
15266 return CMD_WARNING;
15267 }
15268
paul718e3742002-12-13 20:15:29 +000015269 if (bdistance->access_list)
15270 free (bdistance->access_list);
15271 bgp_distance_free (bdistance);
15272
15273 rn->info = NULL;
15274 bgp_unlock_node (rn);
15275 bgp_unlock_node (rn);
15276
15277 return CMD_SUCCESS;
15278}
15279
paul718e3742002-12-13 20:15:29 +000015280/* Apply BGP information to distance method. */
15281u_char
15282bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
15283{
15284 struct bgp_node *rn;
15285 struct prefix_ipv4 q;
15286 struct peer *peer;
15287 struct bgp_distance *bdistance;
15288 struct access_list *alist;
15289 struct bgp_static *bgp_static;
15290
15291 if (! bgp)
15292 return 0;
15293
15294 if (p->family != AF_INET)
15295 return 0;
15296
15297 peer = rinfo->peer;
15298
15299 if (peer->su.sa.sa_family != AF_INET)
15300 return 0;
15301
15302 memset (&q, 0, sizeof (struct prefix_ipv4));
15303 q.family = AF_INET;
15304 q.prefix = peer->su.sin.sin_addr;
15305 q.prefixlen = IPV4_MAX_BITLEN;
15306
15307 /* Check source address. */
15308 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15309 if (rn)
15310 {
15311 bdistance = rn->info;
15312 bgp_unlock_node (rn);
15313
15314 if (bdistance->access_list)
15315 {
15316 alist = access_list_lookup (AFI_IP, bdistance->access_list);
15317 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15318 return bdistance->distance;
15319 }
15320 else
15321 return bdistance->distance;
15322 }
15323
15324 /* Backdoor check. */
15325 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
15326 if (rn)
15327 {
15328 bgp_static = rn->info;
15329 bgp_unlock_node (rn);
15330
15331 if (bgp_static->backdoor)
15332 {
15333 if (bgp->distance_local)
15334 return bgp->distance_local;
15335 else
15336 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15337 }
15338 }
15339
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000015340 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000015341 {
15342 if (bgp->distance_ebgp)
15343 return bgp->distance_ebgp;
15344 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15345 }
15346 else
15347 {
15348 if (bgp->distance_ibgp)
15349 return bgp->distance_ibgp;
15350 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15351 }
15352}
15353
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015354#ifdef HAVE_IPV6
15355/* Apply BGP information to ipv6 distance method. */
15356u_char
15357ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
15358{
15359 struct bgp_node *rn;
15360 struct prefix_ipv6 q;
15361 struct peer *peer;
15362 struct bgp_distance *bdistance;
15363 struct access_list *alist;
15364 struct bgp_static *bgp_static;
15365
15366 if (! bgp)
15367 return 0;
15368
15369 if (p->family != AF_INET6)
15370 return 0;
15371
15372 peer = rinfo->peer;
15373
15374 if (peer->su.sa.sa_family != AF_INET6)
15375 return 0;
15376
15377 memset (&q, 0, sizeof (struct prefix_ipv6));
15378 q.family = AF_INET;
15379 q.prefix = peer->su.sin6.sin6_addr;
15380 q.prefixlen = IPV6_MAX_BITLEN;
15381
15382 /* Check source address. */
15383 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15384 if (rn)
15385 {
15386 bdistance = rn->info;
15387 bgp_unlock_node (rn);
15388
15389 if (bdistance->access_list)
15390 {
15391 alist = access_list_lookup (AFI_IP6, bdistance->access_list);
15392 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15393 return bdistance->distance;
15394 }
15395 else
15396 return bdistance->distance;
15397 }
15398 /* Backdoor check. */
15399 rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p);
15400 if (rn)
15401 {
15402 bgp_static = rn->info;
15403 bgp_unlock_node (rn);
15404
15405 if (bgp_static->backdoor)
15406 {
15407 if (bgp->ipv6_distance_local)
15408 return bgp->ipv6_distance_local;
15409 else
15410 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15411 }
15412 }
15413
15414 if (peer_sort (peer) == BGP_PEER_EBGP)
15415 {
15416 if (bgp->ipv6_distance_ebgp)
15417 return bgp->ipv6_distance_ebgp;
15418 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15419 }
15420 else
15421 {
15422 if (bgp->ipv6_distance_ibgp)
15423 return bgp->ipv6_distance_ibgp;
15424 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15425 }
15426}
15427#endif /* HAVE_IPV6 */
15428
paul718e3742002-12-13 20:15:29 +000015429DEFUN (bgp_distance,
15430 bgp_distance_cmd,
15431 "distance bgp <1-255> <1-255> <1-255>",
15432 "Define an administrative distance\n"
15433 "BGP distance\n"
15434 "Distance for routes external to the AS\n"
15435 "Distance for routes internal to the AS\n"
15436 "Distance for local routes\n")
15437{
15438 struct bgp *bgp;
15439
15440 bgp = vty->index;
15441
15442 bgp->distance_ebgp = atoi (argv[0]);
15443 bgp->distance_ibgp = atoi (argv[1]);
15444 bgp->distance_local = atoi (argv[2]);
15445 return CMD_SUCCESS;
15446}
15447
15448DEFUN (no_bgp_distance,
15449 no_bgp_distance_cmd,
15450 "no distance bgp <1-255> <1-255> <1-255>",
15451 NO_STR
15452 "Define an administrative distance\n"
15453 "BGP distance\n"
15454 "Distance for routes external to the AS\n"
15455 "Distance for routes internal to the AS\n"
15456 "Distance for local routes\n")
15457{
15458 struct bgp *bgp;
15459
15460 bgp = vty->index;
15461
15462 bgp->distance_ebgp= 0;
15463 bgp->distance_ibgp = 0;
15464 bgp->distance_local = 0;
15465 return CMD_SUCCESS;
15466}
15467
15468ALIAS (no_bgp_distance,
15469 no_bgp_distance2_cmd,
15470 "no distance bgp",
15471 NO_STR
15472 "Define an administrative distance\n"
15473 "BGP distance\n")
15474
15475DEFUN (bgp_distance_source,
15476 bgp_distance_source_cmd,
15477 "distance <1-255> A.B.C.D/M",
15478 "Define an administrative distance\n"
15479 "Administrative distance\n"
15480 "IP source prefix\n")
15481{
15482 bgp_distance_set (vty, argv[0], argv[1], NULL);
15483 return CMD_SUCCESS;
15484}
15485
15486DEFUN (no_bgp_distance_source,
15487 no_bgp_distance_source_cmd,
15488 "no distance <1-255> A.B.C.D/M",
15489 NO_STR
15490 "Define an administrative distance\n"
15491 "Administrative distance\n"
15492 "IP source prefix\n")
15493{
15494 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15495 return CMD_SUCCESS;
15496}
15497
15498DEFUN (bgp_distance_source_access_list,
15499 bgp_distance_source_access_list_cmd,
15500 "distance <1-255> A.B.C.D/M WORD",
15501 "Define an administrative distance\n"
15502 "Administrative distance\n"
15503 "IP source prefix\n"
15504 "Access list name\n")
15505{
15506 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15507 return CMD_SUCCESS;
15508}
15509
15510DEFUN (no_bgp_distance_source_access_list,
15511 no_bgp_distance_source_access_list_cmd,
15512 "no distance <1-255> A.B.C.D/M WORD",
15513 NO_STR
15514 "Define an administrative distance\n"
15515 "Administrative distance\n"
15516 "IP source prefix\n"
15517 "Access list name\n")
15518{
15519 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15520 return CMD_SUCCESS;
15521}
David Lamparter6b0655a2014-06-04 06:53:35 +020015522
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015523#ifdef HAVE_IPV6
15524DEFUN (ipv6_bgp_distance,
15525 ipv6_bgp_distance_cmd,
15526 "distance bgp <1-255> <1-255> <1-255>",
15527 "Define an administrative distance\n"
15528 "BGP distance\n"
15529 "Distance for routes external to the AS\n"
15530 "Distance for routes internal to the AS\n"
15531 "Distance for local routes\n")
15532{
15533 struct bgp *bgp;
15534
15535 bgp = vty->index;
15536
15537 bgp->ipv6_distance_ebgp = atoi (argv[0]);
15538 bgp->ipv6_distance_ibgp = atoi (argv[1]);
15539 bgp->ipv6_distance_local = atoi (argv[2]);
15540 return CMD_SUCCESS;
15541}
15542
15543DEFUN (no_ipv6_bgp_distance,
15544 no_ipv6_bgp_distance_cmd,
15545 "no distance bgp <1-255> <1-255> <1-255>",
15546 NO_STR
15547 "Define an administrative distance\n"
15548 "BGP distance\n"
15549 "Distance for routes external to the AS\n"
15550 "Distance for routes internal to the AS\n"
15551 "Distance for local routes\n")
15552{
15553 struct bgp *bgp;
15554
15555 bgp = vty->index;
15556
15557 bgp->ipv6_distance_ebgp= 0;
15558 bgp->ipv6_distance_ibgp = 0;
15559 bgp->ipv6_distance_local = 0;
15560 return CMD_SUCCESS;
15561}
15562
15563ALIAS (no_ipv6_bgp_distance,
15564 no_ipv6_bgp_distance2_cmd,
15565 "no distance bgp",
15566 NO_STR
15567 "Define an administrative distance\n"
15568 "BGP distance\n")
15569
15570DEFUN (ipv6_bgp_distance_source,
15571 ipv6_bgp_distance_source_cmd,
15572 "distance <1-255> X:X::X:X/M",
15573 "Define an administrative distance\n"
15574 "Administrative distance\n"
15575 "IP source prefix\n")
15576{
15577 bgp_distance_set (vty, argv[0], argv[1], NULL);
15578 return CMD_SUCCESS;
15579}
15580
15581DEFUN (no_ipv6_bgp_distance_source,
15582 no_ipv6_bgp_distance_source_cmd,
15583 "no distance <1-255> X:X::X:X/M",
15584 NO_STR
15585 "Define an administrative distance\n"
15586 "Administrative distance\n"
15587 "IP source prefix\n")
15588{
15589 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15590 return CMD_SUCCESS;
15591}
15592
15593DEFUN (ipv6_bgp_distance_source_access_list,
15594 ipv6_bgp_distance_source_access_list_cmd,
15595 "distance <1-255> X:X::X:X/M WORD",
15596 "Define an administrative distance\n"
15597 "Administrative distance\n"
15598 "IP source prefix\n"
15599 "Access list name\n")
15600{
15601 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15602 return CMD_SUCCESS;
15603}
15604
15605DEFUN (no_ipv6_bgp_distance_source_access_list,
15606 no_ipv6_bgp_distance_source_access_list_cmd,
15607 "no distance <1-255> X:X::X:X/M WORD",
15608 NO_STR
15609 "Define an administrative distance\n"
15610 "Administrative distance\n"
15611 "IP source prefix\n"
15612 "Access list name\n")
15613{
15614 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15615 return CMD_SUCCESS;
15616}
15617#endif
15618
paul718e3742002-12-13 20:15:29 +000015619DEFUN (bgp_damp_set,
15620 bgp_damp_set_cmd,
15621 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15622 "BGP Specific commands\n"
15623 "Enable route-flap dampening\n"
15624 "Half-life time for the penalty\n"
15625 "Value to start reusing a route\n"
15626 "Value to start suppressing a route\n"
15627 "Maximum duration to suppress a stable route\n")
15628{
15629 struct bgp *bgp;
15630 int half = DEFAULT_HALF_LIFE * 60;
15631 int reuse = DEFAULT_REUSE;
15632 int suppress = DEFAULT_SUPPRESS;
15633 int max = 4 * half;
15634
15635 if (argc == 4)
15636 {
15637 half = atoi (argv[0]) * 60;
15638 reuse = atoi (argv[1]);
15639 suppress = atoi (argv[2]);
15640 max = atoi (argv[3]) * 60;
15641 }
15642 else if (argc == 1)
15643 {
15644 half = atoi (argv[0]) * 60;
15645 max = 4 * half;
15646 }
15647
15648 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015649
15650 if (suppress < reuse)
15651 {
15652 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15653 VTY_NEWLINE);
15654 return 0;
15655 }
15656
paul718e3742002-12-13 20:15:29 +000015657 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15658 half, reuse, suppress, max);
15659}
15660
15661ALIAS (bgp_damp_set,
15662 bgp_damp_set2_cmd,
15663 "bgp dampening <1-45>",
15664 "BGP Specific commands\n"
15665 "Enable route-flap dampening\n"
15666 "Half-life time for the penalty\n")
15667
15668ALIAS (bgp_damp_set,
15669 bgp_damp_set3_cmd,
15670 "bgp dampening",
15671 "BGP Specific commands\n"
15672 "Enable route-flap dampening\n")
15673
15674DEFUN (bgp_damp_unset,
15675 bgp_damp_unset_cmd,
15676 "no bgp dampening",
15677 NO_STR
15678 "BGP Specific commands\n"
15679 "Enable route-flap dampening\n")
15680{
15681 struct bgp *bgp;
15682
15683 bgp = vty->index;
15684 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15685}
15686
15687ALIAS (bgp_damp_unset,
15688 bgp_damp_unset2_cmd,
15689 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15690 NO_STR
15691 "BGP Specific commands\n"
15692 "Enable route-flap dampening\n"
15693 "Half-life time for the penalty\n"
15694 "Value to start reusing a route\n"
15695 "Value to start suppressing a route\n"
15696 "Maximum duration to suppress a stable route\n")
15697
Lou Bergerf9b6c392016-01-12 13:42:09 -050015698DEFUN (show_ip_bgp_dampened_paths,
15699 show_ip_bgp_dampened_paths_cmd,
15700 "show ip bgp dampened-paths",
15701 SHOW_STR
15702 IP_STR
15703 BGP_STR
15704 "Display paths suppressed due to dampening\n")
15705{
15706 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15707 NULL);
15708}
15709
15710ALIAS (show_ip_bgp_dampened_paths,
15711 show_ip_bgp_damp_dampened_paths_cmd,
15712 "show ip bgp dampening dampened-paths",
15713 SHOW_STR
15714 IP_STR
15715 BGP_STR
15716 "Display detailed information about dampening\n"
15717 "Display paths suppressed due to dampening\n")
15718
15719DEFUN (show_ip_bgp_flap_statistics,
15720 show_ip_bgp_flap_statistics_cmd,
15721 "show ip bgp flap-statistics",
15722 SHOW_STR
15723 IP_STR
15724 BGP_STR
15725 "Display flap statistics of routes\n")
15726{
15727 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15728 bgp_show_type_flap_statistics, NULL);
15729}
15730
15731ALIAS (show_ip_bgp_flap_statistics,
15732 show_ip_bgp_damp_flap_statistics_cmd,
15733 "show ip bgp dampening flap-statistics",
15734 SHOW_STR
15735 IP_STR
15736 BGP_STR
15737 "Display detailed information about dampening\n"
15738 "Display flap statistics of routes\n")
15739
Lou Berger651b4022016-01-12 13:42:07 -050015740DEFUN (show_bgp_ipv4_safi_dampened_paths,
15741 show_bgp_ipv4_safi_dampened_paths_cmd,
15742 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015743 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015744 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015745 IP_STR
15746 "Address Family modifier\n"
15747 "Address Family modifier\n"
15748 "Address Family modifier\n"
15749 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015750 "Display paths suppressed due to dampening\n")
15751{
Lou Berger651b4022016-01-12 13:42:07 -050015752 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015753
Lou Berger651b4022016-01-12 13:42:07 -050015754 if (bgp_parse_safi(argv[0], &safi)) {
15755 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15756 return CMD_WARNING;
15757 }
15758
15759 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15760}
15761ALIAS (show_bgp_ipv4_safi_dampened_paths,
15762 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15763 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015764 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015765 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015766 IP_STR
15767 "Address Family modifier\n"
15768 "Address Family modifier\n"
15769 "Address Family modifier\n"
15770 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015771 "Display detailed information about dampening\n"
15772 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015773
Lou Berger651b4022016-01-12 13:42:07 -050015774DEFUN (show_bgp_ipv6_safi_dampened_paths,
15775 show_bgp_ipv6_safi_dampened_paths_cmd,
15776 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015777 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015778 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015779 IPV6_STR
15780 "Address Family modifier\n"
15781 "Address Family modifier\n"
15782 "Address Family modifier\n"
15783 "Address Family modifier\n"
15784 "Display paths suppressed due to dampening\n")
15785{
15786 safi_t safi;
15787
15788 if (bgp_parse_safi(argv[0], &safi)) {
15789 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15790 return CMD_WARNING;
15791 }
15792
15793 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15794}
15795ALIAS (show_bgp_ipv6_safi_dampened_paths,
15796 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15797 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15798 SHOW_STR
15799 BGP_STR
15800 IPV6_STR
15801 "Address Family modifier\n"
15802 "Address Family modifier\n"
15803 "Address Family modifier\n"
15804 "Address Family modifier\n"
15805 "Display detailed information about dampening\n"
15806 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015807
15808DEFUN (show_bgp_ipv4_safi_flap_statistics,
15809 show_bgp_ipv4_safi_flap_statistics_cmd,
15810 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15811 SHOW_STR
15812 BGP_STR
15813 "Address Family\n"
15814 "Address Family modifier\n"
15815 "Address Family modifier\n"
15816 "Address Family modifier\n"
15817 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015818 "Display flap statistics of routes\n")
15819{
Lou Berger651b4022016-01-12 13:42:07 -050015820 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015821
Lou Berger651b4022016-01-12 13:42:07 -050015822 if (bgp_parse_safi(argv[0], &safi)) {
15823 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15824 return CMD_WARNING;
15825 }
15826
15827 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15828}
15829ALIAS (show_bgp_ipv4_safi_flap_statistics,
15830 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15831 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015832 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015833 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015834 "Address Family\n"
15835 "Address Family modifier\n"
15836 "Address Family modifier\n"
15837 "Address Family modifier\n"
15838 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015839 "Display detailed information about dampening\n"
15840 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015841
Lou Berger651b4022016-01-12 13:42:07 -050015842DEFUN (show_bgp_ipv6_safi_flap_statistics,
15843 show_bgp_ipv6_safi_flap_statistics_cmd,
15844 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15845 SHOW_STR
15846 BGP_STR
15847 "Address Family\n"
15848 "Address Family modifier\n"
15849 "Address Family modifier\n"
15850 "Address Family modifier\n"
15851 "Address Family modifier\n"
15852 "Display flap statistics of routes\n")
15853{
15854 safi_t safi;
15855
15856 if (bgp_parse_safi(argv[0], &safi)) {
15857 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15858 return CMD_WARNING;
15859 }
15860
15861 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15862}
15863ALIAS (show_bgp_ipv6_safi_flap_statistics,
15864 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15865 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15866 SHOW_STR
15867 BGP_STR
15868 "Address Family\n"
15869 "Address Family modifier\n"
15870 "Address Family modifier\n"
15871 "Address Family modifier\n"
15872 "Address Family modifier\n"
15873 "Display detailed information about dampening\n"
15874 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015875
paul718e3742002-12-13 20:15:29 +000015876/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015877static int
paulfd79ac92004-10-13 05:06:08 +000015878bgp_clear_damp_route (struct vty *vty, const char *view_name,
15879 const char *ip_str, afi_t afi, safi_t safi,
15880 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015881{
15882 int ret;
15883 struct prefix match;
15884 struct bgp_node *rn;
15885 struct bgp_node *rm;
15886 struct bgp_info *ri;
15887 struct bgp_info *ri_temp;
15888 struct bgp *bgp;
15889 struct bgp_table *table;
15890
15891 /* BGP structure lookup. */
15892 if (view_name)
15893 {
15894 bgp = bgp_lookup_by_name (view_name);
15895 if (bgp == NULL)
15896 {
15897 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15898 return CMD_WARNING;
15899 }
15900 }
15901 else
15902 {
15903 bgp = bgp_get_default ();
15904 if (bgp == NULL)
15905 {
15906 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15907 return CMD_WARNING;
15908 }
15909 }
15910
15911 /* Check IP address argument. */
15912 ret = str2prefix (ip_str, &match);
15913 if (! ret)
15914 {
15915 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15916 return CMD_WARNING;
15917 }
15918
15919 match.family = afi2family (afi);
15920
Lou Berger298cc2f2016-01-12 13:42:02 -050015921 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015922 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015923 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015924 {
15925 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15926 continue;
15927
15928 if ((table = rn->info) != NULL)
15929 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015930 {
15931 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15932 {
15933 ri = rm->info;
15934 while (ri)
15935 {
15936 if (ri->extra && ri->extra->damp_info)
15937 {
15938 ri_temp = ri->next;
15939 bgp_damp_info_free (ri->extra->damp_info, 1);
15940 ri = ri_temp;
15941 }
15942 else
15943 ri = ri->next;
15944 }
15945 }
15946
15947 bgp_unlock_node (rm);
15948 }
paul718e3742002-12-13 20:15:29 +000015949 }
15950 }
15951 else
15952 {
15953 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015954 {
15955 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15956 {
15957 ri = rn->info;
15958 while (ri)
15959 {
15960 if (ri->extra && ri->extra->damp_info)
15961 {
15962 ri_temp = ri->next;
15963 bgp_damp_info_free (ri->extra->damp_info, 1);
15964 ri = ri_temp;
15965 }
15966 else
15967 ri = ri->next;
15968 }
15969 }
15970
15971 bgp_unlock_node (rn);
15972 }
paul718e3742002-12-13 20:15:29 +000015973 }
15974
15975 return CMD_SUCCESS;
15976}
15977
15978DEFUN (clear_ip_bgp_dampening,
15979 clear_ip_bgp_dampening_cmd,
15980 "clear ip bgp dampening",
15981 CLEAR_STR
15982 IP_STR
15983 BGP_STR
15984 "Clear route flap dampening information\n")
15985{
15986 bgp_damp_info_clean ();
15987 return CMD_SUCCESS;
15988}
15989
15990DEFUN (clear_ip_bgp_dampening_prefix,
15991 clear_ip_bgp_dampening_prefix_cmd,
15992 "clear ip bgp dampening A.B.C.D/M",
15993 CLEAR_STR
15994 IP_STR
15995 BGP_STR
15996 "Clear route flap dampening information\n"
15997 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15998{
15999 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16000 SAFI_UNICAST, NULL, 1);
16001}
16002
16003DEFUN (clear_ip_bgp_dampening_address,
16004 clear_ip_bgp_dampening_address_cmd,
16005 "clear ip bgp dampening A.B.C.D",
16006 CLEAR_STR
16007 IP_STR
16008 BGP_STR
16009 "Clear route flap dampening information\n"
16010 "Network to clear damping information\n")
16011{
16012 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16013 SAFI_UNICAST, NULL, 0);
16014}
16015
16016DEFUN (clear_ip_bgp_dampening_address_mask,
16017 clear_ip_bgp_dampening_address_mask_cmd,
16018 "clear ip bgp dampening A.B.C.D A.B.C.D",
16019 CLEAR_STR
16020 IP_STR
16021 BGP_STR
16022 "Clear route flap dampening information\n"
16023 "Network to clear damping information\n"
16024 "Network mask\n")
16025{
16026 int ret;
16027 char prefix_str[BUFSIZ];
16028
16029 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
16030 if (! ret)
16031 {
16032 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
16033 return CMD_WARNING;
16034 }
16035
16036 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
16037 SAFI_UNICAST, NULL, 0);
16038}
David Lamparter6b0655a2014-06-04 06:53:35 +020016039
Lou Berger298cc2f2016-01-12 13:42:02 -050016040/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000016041static int
paul718e3742002-12-13 20:15:29 +000016042bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
16043 afi_t afi, safi_t safi, int *write)
16044{
16045 struct bgp_node *prn;
16046 struct bgp_node *rn;
16047 struct bgp_table *table;
16048 struct prefix *p;
16049 struct prefix_rd *prd;
16050 struct bgp_static *bgp_static;
16051 u_int32_t label;
16052 char buf[SU_ADDRSTRLEN];
16053 char rdbuf[RD_ADDRSTRLEN];
16054
16055 /* Network configuration. */
16056 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
16057 if ((table = prn->info) != NULL)
16058 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
16059 if ((bgp_static = rn->info) != NULL)
16060 {
16061 p = &rn->p;
16062 prd = (struct prefix_rd *) &prn->p;
16063
16064 /* "address-family" display. */
16065 bgp_config_write_family_header (vty, afi, safi, write);
16066
16067 /* "network" configuration display. */
16068 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
16069 label = decode_label (bgp_static->tag);
16070
16071 vty_out (vty, " network %s/%d rd %s tag %d",
16072 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16073 p->prefixlen,
16074 rdbuf, label);
16075 vty_out (vty, "%s", VTY_NEWLINE);
16076 }
16077 return 0;
16078}
16079
16080/* Configuration of static route announcement and aggregate
16081 information. */
16082int
16083bgp_config_write_network (struct vty *vty, struct bgp *bgp,
16084 afi_t afi, safi_t safi, int *write)
16085{
16086 struct bgp_node *rn;
16087 struct prefix *p;
16088 struct bgp_static *bgp_static;
16089 struct bgp_aggregate *bgp_aggregate;
16090 char buf[SU_ADDRSTRLEN];
16091
Lou Berger298cc2f2016-01-12 13:42:02 -050016092 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000016093 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
16094
16095 /* Network configuration. */
16096 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
16097 if ((bgp_static = rn->info) != NULL)
16098 {
16099 p = &rn->p;
16100
16101 /* "address-family" display. */
16102 bgp_config_write_family_header (vty, afi, safi, write);
16103
16104 /* "network" configuration display. */
16105 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
16106 {
16107 u_int32_t destination;
16108 struct in_addr netmask;
16109
16110 destination = ntohl (p->u.prefix4.s_addr);
16111 masklen2ip (p->prefixlen, &netmask);
16112 vty_out (vty, " network %s",
16113 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
16114
16115 if ((IN_CLASSC (destination) && p->prefixlen == 24)
16116 || (IN_CLASSB (destination) && p->prefixlen == 16)
16117 || (IN_CLASSA (destination) && p->prefixlen == 8)
16118 || p->u.prefix4.s_addr == 0)
16119 {
16120 /* Natural mask is not display. */
16121 }
16122 else
16123 vty_out (vty, " mask %s", inet_ntoa (netmask));
16124 }
16125 else
16126 {
16127 vty_out (vty, " network %s/%d",
16128 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16129 p->prefixlen);
16130 }
16131
16132 if (bgp_static->rmap.name)
16133 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000016134 else
16135 {
16136 if (bgp_static->backdoor)
16137 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000016138 }
paul718e3742002-12-13 20:15:29 +000016139
16140 vty_out (vty, "%s", VTY_NEWLINE);
16141 }
16142
16143 /* Aggregate-address configuration. */
16144 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
16145 if ((bgp_aggregate = rn->info) != NULL)
16146 {
16147 p = &rn->p;
16148
16149 /* "address-family" display. */
16150 bgp_config_write_family_header (vty, afi, safi, write);
16151
16152 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
16153 {
16154 struct in_addr netmask;
16155
16156 masklen2ip (p->prefixlen, &netmask);
16157 vty_out (vty, " aggregate-address %s %s",
16158 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16159 inet_ntoa (netmask));
16160 }
16161 else
16162 {
16163 vty_out (vty, " aggregate-address %s/%d",
16164 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16165 p->prefixlen);
16166 }
16167
16168 if (bgp_aggregate->as_set)
16169 vty_out (vty, " as-set");
16170
16171 if (bgp_aggregate->summary_only)
16172 vty_out (vty, " summary-only");
16173
16174 vty_out (vty, "%s", VTY_NEWLINE);
16175 }
16176
16177 return 0;
16178}
16179
16180int
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016181bgp_config_write_distance (struct vty *vty, struct bgp *bgp,
16182 afi_t afi, safi_t safi, int *write)
paul718e3742002-12-13 20:15:29 +000016183{
16184 struct bgp_node *rn;
16185 struct bgp_distance *bdistance;
16186
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016187 if (afi == AFI_IP && safi == SAFI_UNICAST)
16188 {
16189 /* Distance configuration. */
16190 if (bgp->distance_ebgp
16191 && bgp->distance_ibgp
16192 && bgp->distance_local
16193 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
16194 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
16195 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
16196 vty_out (vty, " distance bgp %d %d %d%s",
16197 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
16198 VTY_NEWLINE);
16199
16200 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
16201 if ((bdistance = rn->info) != NULL)
16202 {
16203 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
16204 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
16205 bdistance->access_list ? bdistance->access_list : "",
16206 VTY_NEWLINE);
16207 }
16208 }
16209
16210#ifdef HAVE_IPV6
16211 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
16212 {
16213 bgp_config_write_family_header (vty, afi, safi, write);
16214 if (bgp->ipv6_distance_ebgp
16215 && bgp->ipv6_distance_ibgp
16216 && bgp->ipv6_distance_local
16217 && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
16218 || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
16219 || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
16220 vty_out (vty, " distance bgp %d %d %d%s",
16221 bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local,
16222 VTY_NEWLINE);
16223
Paul Jakma5bc62ca2016-07-11 16:21:23 +010016224 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
16225 if ((bdistance = rn->info) != NULL)
16226 {
16227 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
16228 inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen,
16229 bdistance->access_list ? bdistance->access_list : "",
16230 VTY_NEWLINE);
16231 }
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016232 }
16233#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000016234
16235 return 0;
16236}
16237
16238/* Allocate routing table structure and install commands. */
16239void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080016240bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000016241{
16242 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000016243 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000016244
16245 /* IPv4 BGP commands. */
16246 install_element (BGP_NODE, &bgp_network_cmd);
16247 install_element (BGP_NODE, &bgp_network_mask_cmd);
16248 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
16249 install_element (BGP_NODE, &bgp_network_route_map_cmd);
16250 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
16251 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
16252 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
16253 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
16254 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
16255 install_element (BGP_NODE, &no_bgp_network_cmd);
16256 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
16257 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
16258 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
16259 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
16260 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
16261 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
16262 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
16263 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
16264
16265 install_element (BGP_NODE, &aggregate_address_cmd);
16266 install_element (BGP_NODE, &aggregate_address_mask_cmd);
16267 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
16268 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
16269 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
16270 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
16271 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
16272 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
16273 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
16274 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
16275 install_element (BGP_NODE, &no_aggregate_address_cmd);
16276 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
16277 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
16278 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
16279 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
16280 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
16281 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
16282 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
16283 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16284 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16285
16286 /* IPv4 unicast configuration. */
16287 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
16288 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
16289 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
16290 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
16291 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
16292 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016293 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000016294 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
16295 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
16296 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
16297 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
16298 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016299
paul718e3742002-12-13 20:15:29 +000016300 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
16301 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
16302 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
16303 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
16304 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
16305 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
16306 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
16307 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
16308 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
16309 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
16310 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
16311 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
16312 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
16313 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
16314 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
16315 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
16316 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
16317 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
16318 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16319 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16320
16321 /* IPv4 multicast configuration. */
16322 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
16323 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
16324 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
16325 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
16326 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
16327 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
16328 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
16329 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
16330 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
16331 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
16332 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
16333 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
16334 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
16335 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
16336 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
16337 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
16338 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
16339 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
16340 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
16341 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
16342 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
16343 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
16344 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
16345 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
16346 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
16347 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
16348 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
16349 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
16350 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
16351 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
16352 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16353 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16354
Michael Lambert95cbbd22010-07-23 14:43:04 -040016355 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016356 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016357 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
16358 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
16359 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16360 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16361 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
16362 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
16363 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16364 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16365 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016366 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016367 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16368 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16369 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16370 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16371 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16372 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16373 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
16374 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
16375 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16376 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
16377 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
16378 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
16379 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
16380 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
16381 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
16382 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
16383 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
16384 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
16385 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
16386 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16387 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
16388 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
16389 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
16390 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
16391 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
16392 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
16393 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
16394 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016395 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16396 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
16397 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
16398 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
16399 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016400 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
16401 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
16402 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
16403 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
16404 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16405 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16406 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16407 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16408 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
16409 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16410 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16411 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16412 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16413 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16414 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16415 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16416 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16417 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16418 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016419 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016420 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16421 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16422 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16423 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16424 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16425 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16426 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16427 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16428 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16429 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16430 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16431 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16432 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16433 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
16434 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16435 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16436 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16437 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16438 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16439 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16440 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16441 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16442 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16443 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16444 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16445 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16446 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16447 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16448 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16449 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16450 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16451 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16452 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16453 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16454 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16455 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16456 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16457 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16458 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16459 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16460 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16461 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16462 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16463 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16464 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016465 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016466 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016467 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016468 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016469 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016470 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016471
16472 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040016473 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016474 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16475 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16476 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16477 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16478 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016479 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016480 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16481 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16482 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16483 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16484 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16485 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16486 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
16487 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16488 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
16489 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
16490 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
16491 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
16492 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
16493 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
16494 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
16495 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016496 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16497 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
16498 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
16499 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
16500 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016501 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
16502 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
16503 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
16504 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
16505 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16506 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16507 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16508 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016509 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016510 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016511 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016512 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016513
Donald Sharp68b45cc2016-03-11 14:27:13 -050016514 /* BGP dampening clear commands */
paul718e3742002-12-13 20:15:29 +000016515 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16516 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16517 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16518 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16519
paul718e3742002-12-13 20:15:29 +000016520 /* New config IPv6 BGP commands. */
16521 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16522 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16523 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16524 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16525
16526 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16527 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16528 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16529 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16530
G.Balaji73bfe0b2011-09-23 22:36:20 +053016531 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16532 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16533
paul718e3742002-12-13 20:15:29 +000016534 /* Old config IPv6 BGP commands. */
16535 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16536 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16537
16538 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16539 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16540 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16541 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16542
Michael Lambert95cbbd22010-07-23 14:43:04 -040016543 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016544 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016545 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016546 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016547 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016548 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016549 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016550 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016551 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016552 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16553 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16554 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16555 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16556 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16557 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16558 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16559 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016560 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016561 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016562 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016563 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016564 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016565 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016566 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016567 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016568 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16569 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016570 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016571 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016572 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016573 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016574 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016575 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016576 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016577 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016578 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016579 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016580 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016581 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016582 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016583 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016584 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16585 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016586 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016587 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016588 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016589 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016590 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016591
16592 /* Restricted:
16593 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16594 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016595 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016596 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016597 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016598 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016599 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16600 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16601 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16602 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16603 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16604 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16605 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16606 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16607 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016608 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016609 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016610 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016611 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016612 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016613 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016614 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016615 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016616 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016617 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016618
Paul Jakma2815e612006-09-14 02:56:07 +000016619 /* Statistics */
16620 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016621 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016622
16623 install_element (BGP_NODE, &bgp_distance_cmd);
16624 install_element (BGP_NODE, &no_bgp_distance_cmd);
16625 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16626 install_element (BGP_NODE, &bgp_distance_source_cmd);
16627 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16628 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16629 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016630#ifdef HAVE_IPV6
16631 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd);
16632 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd);
16633 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd);
16634 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd);
16635 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd);
16636 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd);
16637 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd);
16638#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000016639
16640 install_element (BGP_NODE, &bgp_damp_set_cmd);
16641 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16642 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16643 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16644 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16645 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16646 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16647 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16648 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16649 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Balaji9145f0e2016-01-20 22:59:27 +053016650
16651 /* IPv4 Multicast Mode */
16652 install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd);
16653 install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd);
16654 install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd);
16655 install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd);
16656 install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd);
16657
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016658
16659 /* Deprecated AS-Pathlimit commands */
16660 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16661 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16662 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16663 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16664 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16665 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16666
16667 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16668 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16669 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16670 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16671 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16672 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16673
16674 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16675 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16676 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16677 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16678 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16679 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16680
16681 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16682 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16683 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16684 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16685 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16686 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16687
16688 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16689 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16690 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16691 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16692 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16693 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16694
16695 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16696 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16697 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16698 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16699 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16700 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016701
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016702 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16703 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016704
16705 /* old style commands */
16706 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16707 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16708 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016709 install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd);
16710 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016711 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16712 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16713 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16714 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16715 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016716 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
16717 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
16718 install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016719 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16720 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16721 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16722 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16723 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16724 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16725 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16726 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16727 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16728 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16729 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16730 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16731 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16732 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16733 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16734 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16735 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16736 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16737 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16738 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16739 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16740 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16741 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16742 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16743 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16744 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16745 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16746 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16747 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16748 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16749 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16750 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16751 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16752 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16753 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16754 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16755 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16756 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16757 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16758 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16759 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16760 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16761 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16762 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16763 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16764 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16765 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16766 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016767 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016768 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016769 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd);
16770 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016771 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16772 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16773 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16774 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16775 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16776 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16777 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16778 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16779 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16780 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16781 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16782 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16783 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16784 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16785 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16786 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16787 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16788 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16789 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16790 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16791 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16792 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16793 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16794 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16795 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16796 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16797 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016798
Lou Bergerf9b6c392016-01-12 13:42:09 -050016799 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016800 install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd);
16801 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016802 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16803 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16804 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16805 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016806 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
16807 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
16808 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016809 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16810 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16811 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16812 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16813 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16814 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16815 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16816 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16817 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16818 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16819 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16820 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16821 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16822 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16823 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16824 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16825 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16826 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16827 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16828 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16829 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16830 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16831 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16832 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016833
16834 install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16835 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16836 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016837
Lou Bergerf9b6c392016-01-12 13:42:09 -050016838 install_element (VIEW_NODE, &show_bgp_cmd);
16839 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16840 install_element (VIEW_NODE, &show_bgp_route_cmd);
16841 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016842 install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd);
16843 install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd);
16844 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
16845 install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd);
16846 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
16847 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016848 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16849 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16850 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16851 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16852 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16853 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16854 install_element (VIEW_NODE, &show_bgp_community_cmd);
16855 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16856 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16857 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16858 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16859 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16860 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16861 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16862 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16863 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16864 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16865 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16866 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16867 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16868 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16869 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16870 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16871 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16872 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16873 install_element (VIEW_NODE, &show_bgp_view_cmd);
16874 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16875 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16876 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16877 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16878 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16879 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16880 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16881 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16882 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016883
Lou Bergerf9b6c392016-01-12 13:42:09 -050016884 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16885 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016886 install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd);
16887 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd);
16888 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
16889 install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd);
16890 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
16891 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016892 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16893 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16894 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16895 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16896 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16897 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16898 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16899 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16900 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16901 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16902 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016903
Lou Bergerf9b6c392016-01-12 13:42:09 -050016904 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16905 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016906
Lou Bergerf9b6c392016-01-12 13:42:09 -050016907 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16908 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16909 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16910 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16911 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16912 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16913 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16914 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16915 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16916 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16917 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16918 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16919 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16920 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16921 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16922 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16923 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16924 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16925 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16926 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16927 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16928 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16929 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16930 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16931 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16932 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16933 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16934 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16935 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16936 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16937 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16938 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16939 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16940 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16941 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16942 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016943 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016944 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016945 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016946 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016947 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016948 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016949 /* old with name safi collision */
16950 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16951 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16952 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16953 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16954 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16955 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16956 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16957 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16958 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16959 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16960 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16961 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16962 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16963 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16964 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16965 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050016966
Lou Bergerf9b6c392016-01-12 13:42:09 -050016967 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
16968 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016969
16970 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
16971 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
16972 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
16973 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016974
16975 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
16976 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
16977 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
16978 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016979}
Chris Caputo228da422009-07-18 05:44:03 +000016980
16981void
16982bgp_route_finish (void)
16983{
16984 bgp_table_unlock (bgp_distance_table);
16985 bgp_distance_table = NULL;
16986}