blob: 13596fbed72c46241c094538b9b134df3e085cd8 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
Job Snijders3334bab2017-01-20 14:47:12 +00003 Copyright (C) 2016 Job Snijders <job@instituut.net>
paul718e3742002-12-13 20:15:29 +00004
5This file is part of GNU Zebra.
6
7GNU Zebra is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by the
9Free Software Foundation; either version 2, or (at your option) any
10later version.
11
12GNU Zebra is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Zebra; see the file COPYING. If not, write to the Free
19Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA. */
21
22#include <zebra.h>
23
24#include "prefix.h"
25#include "linklist.h"
26#include "memory.h"
27#include "command.h"
28#include "stream.h"
29#include "filter.h"
30#include "str.h"
31#include "log.h"
32#include "routemap.h"
33#include "buffer.h"
34#include "sockunion.h"
35#include "plist.h"
36#include "thread.h"
paul200df112005-06-01 11:17:05 +000037#include "workqueue.h"
paul718e3742002-12-13 20:15:29 +000038
39#include "bgpd/bgpd.h"
40#include "bgpd/bgp_table.h"
41#include "bgpd/bgp_route.h"
42#include "bgpd/bgp_attr.h"
43#include "bgpd/bgp_debug.h"
44#include "bgpd/bgp_aspath.h"
45#include "bgpd/bgp_regex.h"
46#include "bgpd/bgp_community.h"
47#include "bgpd/bgp_ecommunity.h"
Job Snijders3334bab2017-01-20 14:47:12 +000048#include "bgpd/bgp_lcommunity.h"
paul718e3742002-12-13 20:15:29 +000049#include "bgpd/bgp_clist.h"
50#include "bgpd/bgp_packet.h"
51#include "bgpd/bgp_filter.h"
52#include "bgpd/bgp_fsm.h"
53#include "bgpd/bgp_mplsvpn.h"
54#include "bgpd/bgp_nexthop.h"
55#include "bgpd/bgp_damp.h"
56#include "bgpd/bgp_advertise.h"
57#include "bgpd/bgp_zebra.h"
hasso0a486e52005-02-01 20:57:17 +000058#include "bgpd/bgp_vty.h"
Josh Bailey96450fa2011-07-20 20:45:12 -070059#include "bgpd/bgp_mpath.h"
Dinesh Duttd9ab53a2015-05-19 17:47:21 -070060#include "bgpd/bgp_nht.h"
paul718e3742002-12-13 20:15:29 +000061
62/* Extern from bgp_dump.c */
Stephen Hemmingerdde72582009-05-08 15:19:07 -070063extern const char *bgp_origin_str[];
64extern const char *bgp_origin_long_str[];
David Lamparter6b0655a2014-06-04 06:53:35 +020065
paul94f2b392005-06-28 12:44:16 +000066static struct bgp_node *
paulfee0f4c2004-09-13 05:12:46 +000067bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
paul718e3742002-12-13 20:15:29 +000068 struct prefix_rd *prd)
69{
70 struct bgp_node *rn;
71 struct bgp_node *prn = NULL;
Paul Jakmada5b30f2006-05-08 14:37:17 +000072
73 assert (table);
74 if (!table)
75 return NULL;
76
Lou Berger298cc2f2016-01-12 13:42:02 -050077 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000078 {
paulfee0f4c2004-09-13 05:12:46 +000079 prn = bgp_node_get (table, (struct prefix *) prd);
paul718e3742002-12-13 20:15:29 +000080
81 if (prn->info == NULL)
Paul Jakma64e580a2006-02-21 01:09:01 +000082 prn->info = bgp_table_init (afi, safi);
paul718e3742002-12-13 20:15:29 +000083 else
84 bgp_unlock_node (prn);
85 table = prn->info;
86 }
paul718e3742002-12-13 20:15:29 +000087
88 rn = bgp_node_get (table, p);
89
Lou Berger298cc2f2016-01-12 13:42:02 -050090 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000091 rn->prn = prn;
92
93 return rn;
94}
David Lamparter6b0655a2014-06-04 06:53:35 +020095
Paul Jakmafb982c22007-05-04 20:15:47 +000096/* Allocate bgp_info_extra */
97static struct bgp_info_extra *
98bgp_info_extra_new (void)
99{
100 struct bgp_info_extra *new;
101 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
102 return new;
103}
104
105static void
106bgp_info_extra_free (struct bgp_info_extra **extra)
107{
108 if (extra && *extra)
109 {
110 if ((*extra)->damp_info)
111 bgp_damp_info_free ((*extra)->damp_info, 0);
112
113 (*extra)->damp_info = NULL;
114
115 XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
116
117 *extra = NULL;
118 }
119}
120
121/* Get bgp_info extra information for the given bgp_info, lazy allocated
122 * if required.
123 */
124struct bgp_info_extra *
125bgp_info_extra_get (struct bgp_info *ri)
126{
127 if (!ri->extra)
128 ri->extra = bgp_info_extra_new();
129 return ri->extra;
130}
131
paul718e3742002-12-13 20:15:29 +0000132/* Free bgp route information. */
paul200df112005-06-01 11:17:05 +0000133static void
paul718e3742002-12-13 20:15:29 +0000134bgp_info_free (struct bgp_info *binfo)
135{
136 if (binfo->attr)
Paul Jakmaf6f434b2010-11-23 21:28:03 +0000137 bgp_attr_unintern (&binfo->attr);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -0500138
Paul Jakma3dda6b32016-09-06 16:57:40 +0100139 bgp_unlink_nexthop (binfo);
Paul Jakmafb982c22007-05-04 20:15:47 +0000140 bgp_info_extra_free (&binfo->extra);
Josh Baileyde8d5df2011-07-20 20:46:01 -0700141 bgp_info_mpath_free (&binfo->mpath);
paul718e3742002-12-13 20:15:29 +0000142
paul200df112005-06-01 11:17:05 +0000143 peer_unlock (binfo->peer); /* bgp_info peer reference */
144
paul718e3742002-12-13 20:15:29 +0000145 XFREE (MTYPE_BGP_ROUTE, binfo);
146}
147
paul200df112005-06-01 11:17:05 +0000148struct bgp_info *
149bgp_info_lock (struct bgp_info *binfo)
150{
151 binfo->lock++;
152 return binfo;
153}
154
155struct bgp_info *
156bgp_info_unlock (struct bgp_info *binfo)
157{
158 assert (binfo && binfo->lock > 0);
159 binfo->lock--;
160
161 if (binfo->lock == 0)
162 {
163#if 0
164 zlog_debug ("%s: unlocked and freeing", __func__);
165 zlog_backtrace (LOG_DEBUG);
166#endif
167 bgp_info_free (binfo);
168 return NULL;
169 }
170
171#if 0
172 if (binfo->lock == 1)
173 {
174 zlog_debug ("%s: unlocked to 1", __func__);
175 zlog_backtrace (LOG_DEBUG);
176 }
177#endif
178
179 return binfo;
180}
181
paul718e3742002-12-13 20:15:29 +0000182void
183bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
184{
185 struct bgp_info *top;
186
187 top = rn->info;
paul200df112005-06-01 11:17:05 +0000188
paul718e3742002-12-13 20:15:29 +0000189 ri->next = rn->info;
190 ri->prev = NULL;
191 if (top)
192 top->prev = ri;
193 rn->info = ri;
paul200df112005-06-01 11:17:05 +0000194
195 bgp_info_lock (ri);
196 bgp_lock_node (rn);
197 peer_lock (ri->peer); /* bgp_info peer reference */
paul718e3742002-12-13 20:15:29 +0000198}
199
paulb40d9392005-08-22 22:34:41 +0000200/* Do the actual removal of info from RIB, for use by bgp_process
201 completion callback *only* */
202static void
203bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
paul718e3742002-12-13 20:15:29 +0000204{
205 if (ri->next)
206 ri->next->prev = ri->prev;
207 if (ri->prev)
208 ri->prev->next = ri->next;
209 else
210 rn->info = ri->next;
paul200df112005-06-01 11:17:05 +0000211
Josh Baileyde8d5df2011-07-20 20:46:01 -0700212 bgp_info_mpath_dequeue (ri);
paul200df112005-06-01 11:17:05 +0000213 bgp_info_unlock (ri);
214 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +0000215}
216
paulb40d9392005-08-22 22:34:41 +0000217void
218bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
219{
Paul Jakma1a392d42006-09-07 00:24:49 +0000220 bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
221 /* set of previous already took care of pcount */
paulb40d9392005-08-22 22:34:41 +0000222 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
223}
224
Andrew J. Schorr8d452102006-11-28 19:50:46 +0000225/* undo the effects of a previous call to bgp_info_delete; typically
226 called when a route is deleted and then quickly re-added before the
227 deletion has been processed */
228static void
229bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
230{
231 bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
232 /* unset of previous already took care of pcount */
233 SET_FLAG (ri->flags, BGP_INFO_VALID);
234}
235
Paul Jakma1a392d42006-09-07 00:24:49 +0000236/* Adjust pcount as required */
237static void
238bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
239{
Avneesh Sachdev67174042012-08-17 08:19:49 -0700240 struct bgp_table *table;
241
242 assert (rn && bgp_node_table (rn));
Paul Jakma6f585442006-10-22 19:13:07 +0000243 assert (ri && ri->peer && ri->peer->bgp);
244
Avneesh Sachdev67174042012-08-17 08:19:49 -0700245 table = bgp_node_table (rn);
246
Paul Jakma1a392d42006-09-07 00:24:49 +0000247 /* Ignore 'pcount' for RS-client tables */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700248 if (table->type != BGP_TABLE_MAIN
Paul Jakma1a392d42006-09-07 00:24:49 +0000249 || ri->peer == ri->peer->bgp->peer_self)
250 return;
251
Daniel Waltone25a9742015-11-09 20:21:50 -0500252 if (!BGP_INFO_COUNTABLE (ri)
Paul Jakma1a392d42006-09-07 00:24:49 +0000253 && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
254 {
255
256 UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
257
258 /* slight hack, but more robust against errors. */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700259 if (ri->peer->pcount[table->afi][table->safi])
260 ri->peer->pcount[table->afi][table->safi]--;
Paul Jakma1a392d42006-09-07 00:24:49 +0000261 else
262 {
263 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
264 __func__, ri->peer->host);
265 zlog_backtrace (LOG_WARNING);
266 zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
267 }
268 }
Daniel Waltone25a9742015-11-09 20:21:50 -0500269 else if (BGP_INFO_COUNTABLE (ri)
Paul Jakma1a392d42006-09-07 00:24:49 +0000270 && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
271 {
272 SET_FLAG (ri->flags, BGP_INFO_COUNTED);
Avneesh Sachdev67174042012-08-17 08:19:49 -0700273 ri->peer->pcount[table->afi][table->safi]++;
Paul Jakma1a392d42006-09-07 00:24:49 +0000274 }
275}
276
277
278/* Set/unset bgp_info flags, adjusting any other state as needed.
279 * This is here primarily to keep prefix-count in check.
280 */
281void
282bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
283{
284 SET_FLAG (ri->flags, flag);
285
Daniel Waltone25a9742015-11-09 20:21:50 -0500286 /* early bath if we know it's not a flag that changes countability state */
287 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED))
Paul Jakma1a392d42006-09-07 00:24:49 +0000288 return;
289
290 bgp_pcount_adjust (rn, ri);
291}
292
293void
294bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
295{
296 UNSET_FLAG (ri->flags, flag);
297
Daniel Waltone25a9742015-11-09 20:21:50 -0500298 /* early bath if we know it's not a flag that changes countability state */
299 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED))
Paul Jakma1a392d42006-09-07 00:24:49 +0000300 return;
301
302 bgp_pcount_adjust (rn, ri);
303}
304
paul718e3742002-12-13 20:15:29 +0000305/* Get MED value. If MED value is missing and "bgp bestpath
306 missing-as-worst" is specified, treat it as the worst value. */
paul94f2b392005-06-28 12:44:16 +0000307static u_int32_t
paul718e3742002-12-13 20:15:29 +0000308bgp_med_value (struct attr *attr, struct bgp *bgp)
309{
310 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
311 return attr->med;
312 else
313 {
314 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000315 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000316 else
317 return 0;
318 }
319}
320
Paul Jakma6d4742b2015-11-25 17:14:37 +0000321/* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
322 * is preferred, or 0 if they are the same (usually will only occur if
323 * multipath is enabled */
paul94f2b392005-06-28 12:44:16 +0000324static int
Josh Bailey96450fa2011-07-20 20:45:12 -0700325bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
Paul Jakma6d4742b2015-11-25 17:14:37 +0000326 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +0000327{
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000328 struct attr *newattr, *existattr;
329 struct attr_extra *newattre, *existattre;
330 bgp_peer_sort_t new_sort;
331 bgp_peer_sort_t exist_sort;
paul718e3742002-12-13 20:15:29 +0000332 u_int32_t new_pref;
333 u_int32_t exist_pref;
334 u_int32_t new_med;
335 u_int32_t exist_med;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000336 u_int32_t new_weight;
337 u_int32_t exist_weight;
338 uint32_t newm, existm;
paul718e3742002-12-13 20:15:29 +0000339 struct in_addr new_id;
340 struct in_addr exist_id;
341 int new_cluster;
342 int exist_cluster;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000343 int internal_as_route;
344 int confed_as_route;
paul718e3742002-12-13 20:15:29 +0000345 int ret;
Josh Bailey96450fa2011-07-20 20:45:12 -0700346
paul718e3742002-12-13 20:15:29 +0000347 /* 0. Null check. */
348 if (new == NULL)
paul718e3742002-12-13 20:15:29 +0000349 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000350 if (exist == NULL)
351 return -1;
paul718e3742002-12-13 20:15:29 +0000352
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000353 newattr = new->attr;
354 existattr = exist->attr;
355 newattre = newattr->extra;
356 existattre = existattr->extra;
357
paul718e3742002-12-13 20:15:29 +0000358 /* 1. Weight check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000359 new_weight = exist_weight = 0;
360
361 if (newattre)
362 new_weight = newattre->weight;
363 if (existattre)
364 exist_weight = existattre->weight;
365
Paul Jakmafb982c22007-05-04 20:15:47 +0000366 if (new_weight > exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000367 return -1;
Paul Jakmafb982c22007-05-04 20:15:47 +0000368 if (new_weight < exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000369 return 1;
paul718e3742002-12-13 20:15:29 +0000370
371 /* 2. Local preference check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000372 new_pref = exist_pref = bgp->default_local_pref;
paul718e3742002-12-13 20:15:29 +0000373
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000374 if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
375 new_pref = newattr->local_pref;
376 if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
377 exist_pref = existattr->local_pref;
378
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 if (new_pref < exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000382 return 1;
paul718e3742002-12-13 20:15:29 +0000383
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000384 /* 3. Local route check. We prefer:
385 * - BGP_ROUTE_STATIC
386 * - BGP_ROUTE_AGGREGATE
387 * - BGP_ROUTE_REDISTRIBUTE
388 */
389 if (! (new->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000390 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000391 if (! (exist->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000392 return 1;
paul718e3742002-12-13 20:15:29 +0000393
394 /* 4. AS path length check. */
395 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
396 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000397 int exist_hops = aspath_count_hops (existattr->aspath);
398 int exist_confeds = aspath_count_confeds (existattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000399
hasso68118452005-04-08 15:40:36 +0000400 if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
401 {
paulfe69a502005-09-10 16:55:02 +0000402 int aspath_hops;
403
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000404 aspath_hops = aspath_count_hops (newattr->aspath);
405 aspath_hops += aspath_count_confeds (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000406
407 if ( aspath_hops < (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000408 return -1;
paulfe69a502005-09-10 16:55:02 +0000409 if ( aspath_hops > (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000410 return 1;
hasso68118452005-04-08 15:40:36 +0000411 }
412 else
413 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000414 int newhops = aspath_count_hops (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000415
416 if (newhops < exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000417 return -1;
paulfe69a502005-09-10 16:55:02 +0000418 if (newhops > exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000419 return 1;
hasso68118452005-04-08 15:40:36 +0000420 }
paul718e3742002-12-13 20:15:29 +0000421 }
422
423 /* 5. Origin check. */
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;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000426 if (newattr->origin > existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000427 return 1;
paul718e3742002-12-13 20:15:29 +0000428
429 /* 6. MED check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000430 internal_as_route = (aspath_count_hops (newattr->aspath) == 0
431 && aspath_count_hops (existattr->aspath) == 0);
432 confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
433 && aspath_count_confeds (existattr->aspath) > 0
434 && aspath_count_hops (newattr->aspath) == 0
435 && aspath_count_hops (existattr->aspath) == 0);
paul718e3742002-12-13 20:15:29 +0000436
437 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
438 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
439 && confed_as_route)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000440 || aspath_cmp_left (newattr->aspath, existattr->aspath)
441 || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
paul718e3742002-12-13 20:15:29 +0000442 || internal_as_route)
443 {
444 new_med = bgp_med_value (new->attr, bgp);
445 exist_med = bgp_med_value (exist->attr, bgp);
446
447 if (new_med < exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000448 return -1;
paul718e3742002-12-13 20:15:29 +0000449 if (new_med > exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000450 return 1;
paul718e3742002-12-13 20:15:29 +0000451 }
452
453 /* 7. Peer type check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000454 new_sort = new->peer->sort;
455 exist_sort = exist->peer->sort;
456
457 if (new_sort == BGP_PEER_EBGP
458 && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000459 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000460 if (exist_sort == BGP_PEER_EBGP
461 && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000462 return 1;
paul718e3742002-12-13 20:15:29 +0000463
464 /* 8. IGP metric check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000465 newm = existm = 0;
466
467 if (new->extra)
468 newm = new->extra->igpmetric;
469 if (exist->extra)
470 existm = exist->extra->igpmetric;
471
Josh Bailey96450fa2011-07-20 20:45:12 -0700472 if (newm < existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000473 return -1;
Josh Bailey96450fa2011-07-20 20:45:12 -0700474 if (newm > existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000475 return 1;
paul718e3742002-12-13 20:15:29 +0000476
477 /* 9. Maximum path check. */
Paul Jakma6d4742b2015-11-25 17:14:37 +0000478 if (bgp_mpath_is_configured (bgp, afi, safi))
Josh Bailey96450fa2011-07-20 20:45:12 -0700479 {
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000480 if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
481 {
Paul Jakma6d4742b2015-11-25 17:14:37 +0000482 /*
483 * For the two paths, all comparison steps till IGP metric
484 * have succeeded - including AS_PATH hop count. Since 'bgp
485 * bestpath as-path multipath-relax' knob is on, we don't need
486 * an exact match of AS_PATH. Thus, mark the paths are equal.
487 * That will trigger both these paths to get into the multipath
488 * array.
489 */
490 return 0;
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000491 }
492 else if (new->peer->sort == BGP_PEER_IBGP)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000493 {
494 if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
495 return 0;
496 }
Josh Bailey96450fa2011-07-20 20:45:12 -0700497 else if (new->peer->as == exist->peer->as)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000498 return 0;
Josh Bailey96450fa2011-07-20 20:45:12 -0700499 }
paul718e3742002-12-13 20:15:29 +0000500
501 /* 10. If both paths are external, prefer the path that was received
502 first (the oldest one). This step minimizes route-flap, since a
503 newer path won't displace an older one, even if it was the
504 preferred route based on the additional decision criteria below. */
505 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000506 && new_sort == BGP_PEER_EBGP
507 && exist_sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +0000508 {
509 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000510 return -1;
paul718e3742002-12-13 20:15:29 +0000511 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000512 return 1;
paul718e3742002-12-13 20:15:29 +0000513 }
514
vivekbd4b7f12014-09-30 15:54:45 -0700515 /* 11. Router-ID comparision. */
516 /* If one of the paths is "stale", the corresponding peer router-id will
517 * be 0 and would always win over the other path. If originator id is
518 * used for the comparision, it will decide which path is better.
519 */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000520 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
521 new_id.s_addr = newattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000522 else
523 new_id.s_addr = new->peer->remote_id.s_addr;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000524 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
525 exist_id.s_addr = existattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000526 else
527 exist_id.s_addr = exist->peer->remote_id.s_addr;
528
529 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 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000532 return 1;
paul718e3742002-12-13 20:15:29 +0000533
534 /* 12. Cluster length comparision. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000535 new_cluster = exist_cluster = 0;
536
537 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
538 new_cluster = newattre->cluster->length;
539 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
540 exist_cluster = existattre->cluster->length;
paul718e3742002-12-13 20:15:29 +0000541
542 if (new_cluster < exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000543 return -1;
paul718e3742002-12-13 20:15:29 +0000544 if (new_cluster > exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000545 return 1;
paul718e3742002-12-13 20:15:29 +0000546
547 /* 13. Neighbor address comparision. */
vivekbd4b7f12014-09-30 15:54:45 -0700548 /* Do this only if neither path is "stale" as stale paths do not have
549 * valid peer information (as the connection may or may not be up).
550 */
551 if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000552 return -1;
vivekbd4b7f12014-09-30 15:54:45 -0700553 if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000554 return 1;
Timo Teräs2820a012015-06-24 15:27:21 +0300555 /* locally configured routes to advertise do not have su_remote */
556 if (new->peer->su_remote == NULL)
Timo Teräs2820a012015-06-24 15:27:21 +0300557 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000558 if (exist->peer->su_remote == NULL)
559 return -1;
Timo Teräs2820a012015-06-24 15:27:21 +0300560
paul718e3742002-12-13 20:15:29 +0000561 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
562
563 if (ret == 1)
paul718e3742002-12-13 20:15:29 +0000564 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000565 if (ret == -1)
566 return -1;
paul718e3742002-12-13 20:15:29 +0000567
Paul Jakma6d4742b2015-11-25 17:14:37 +0000568 return -1;
paul718e3742002-12-13 20:15:29 +0000569}
570
paul94f2b392005-06-28 12:44:16 +0000571static enum filter_type
paul718e3742002-12-13 20:15:29 +0000572bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
573 afi_t afi, safi_t safi)
574{
575 struct bgp_filter *filter;
576
577 filter = &peer->filter[afi][safi];
578
Paul Jakma650f76c2009-06-25 18:06:31 +0100579#define FILTER_EXIST_WARN(F,f,filter) \
580 if (BGP_DEBUG (update, UPDATE_IN) \
581 && !(F ## _IN (filter))) \
582 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
583 peer->host, #f, F ## _IN_NAME(filter));
584
585 if (DISTRIBUTE_IN_NAME (filter)) {
586 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
587
paul718e3742002-12-13 20:15:29 +0000588 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
589 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100590 }
paul718e3742002-12-13 20:15:29 +0000591
Paul Jakma650f76c2009-06-25 18:06:31 +0100592 if (PREFIX_LIST_IN_NAME (filter)) {
593 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
594
paul718e3742002-12-13 20:15:29 +0000595 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
596 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100597 }
paul718e3742002-12-13 20:15:29 +0000598
Paul Jakma650f76c2009-06-25 18:06:31 +0100599 if (FILTER_LIST_IN_NAME (filter)) {
600 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
601
paul718e3742002-12-13 20:15:29 +0000602 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
603 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100604 }
605
paul718e3742002-12-13 20:15:29 +0000606 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100607#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000608}
609
paul94f2b392005-06-28 12:44:16 +0000610static enum filter_type
paul718e3742002-12-13 20:15:29 +0000611bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
612 afi_t afi, safi_t safi)
613{
614 struct bgp_filter *filter;
615
616 filter = &peer->filter[afi][safi];
617
Paul Jakma650f76c2009-06-25 18:06:31 +0100618#define FILTER_EXIST_WARN(F,f,filter) \
619 if (BGP_DEBUG (update, UPDATE_OUT) \
620 && !(F ## _OUT (filter))) \
621 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
622 peer->host, #f, F ## _OUT_NAME(filter));
623
624 if (DISTRIBUTE_OUT_NAME (filter)) {
625 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
626
paul718e3742002-12-13 20:15:29 +0000627 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
628 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100629 }
paul718e3742002-12-13 20:15:29 +0000630
Paul Jakma650f76c2009-06-25 18:06:31 +0100631 if (PREFIX_LIST_OUT_NAME (filter)) {
632 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
633
paul718e3742002-12-13 20:15:29 +0000634 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
635 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100636 }
paul718e3742002-12-13 20:15:29 +0000637
Paul Jakma650f76c2009-06-25 18:06:31 +0100638 if (FILTER_LIST_OUT_NAME (filter)) {
639 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
640
paul718e3742002-12-13 20:15:29 +0000641 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
642 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100643 }
paul718e3742002-12-13 20:15:29 +0000644
645 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100646#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000647}
648
649/* If community attribute includes no_export then return 1. */
paul94f2b392005-06-28 12:44:16 +0000650static int
paul718e3742002-12-13 20:15:29 +0000651bgp_community_filter (struct peer *peer, struct attr *attr)
652{
653 if (attr->community)
654 {
655 /* NO_ADVERTISE check. */
656 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
657 return 1;
658
659 /* NO_EXPORT check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000660 if (peer->sort == BGP_PEER_EBGP &&
paul718e3742002-12-13 20:15:29 +0000661 community_include (attr->community, COMMUNITY_NO_EXPORT))
662 return 1;
663
664 /* NO_EXPORT_SUBCONFED check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000665 if (peer->sort == BGP_PEER_EBGP
666 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000667 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
668 return 1;
669 }
670 return 0;
671}
672
673/* Route reflection loop check. */
674static int
675bgp_cluster_filter (struct peer *peer, struct attr *attr)
676{
677 struct in_addr cluster_id;
678
Paul Jakmafb982c22007-05-04 20:15:47 +0000679 if (attr->extra && attr->extra->cluster)
paul718e3742002-12-13 20:15:29 +0000680 {
681 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
682 cluster_id = peer->bgp->cluster_id;
683 else
684 cluster_id = peer->bgp->router_id;
685
Paul Jakmafb982c22007-05-04 20:15:47 +0000686 if (cluster_loop_check (attr->extra->cluster, cluster_id))
paul718e3742002-12-13 20:15:29 +0000687 return 1;
688 }
689 return 0;
690}
David Lamparter6b0655a2014-06-04 06:53:35 +0200691
paul94f2b392005-06-28 12:44:16 +0000692static int
paul718e3742002-12-13 20:15:29 +0000693bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
694 afi_t afi, safi_t safi)
695{
696 struct bgp_filter *filter;
697 struct bgp_info info;
698 route_map_result_t ret;
699
700 filter = &peer->filter[afi][safi];
701
702 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000703 if (peer->weight)
704 (bgp_attr_extra_get (attr))->weight = peer->weight;
paul718e3742002-12-13 20:15:29 +0000705
706 /* Route map apply. */
707 if (ROUTE_MAP_IN_NAME (filter))
708 {
709 /* Duplicate current value to new strucutre for modification. */
710 info.peer = peer;
711 info.attr = attr;
712
paulac41b2a2003-08-12 05:32:27 +0000713 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
714
paul718e3742002-12-13 20:15:29 +0000715 /* Apply BGP route map to the attribute. */
716 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000717
718 peer->rmap_type = 0;
719
paul718e3742002-12-13 20:15:29 +0000720 if (ret == RMAP_DENYMATCH)
David Lamparterc460e572014-06-04 00:54:58 +0200721 /* caller has multiple error paths with bgp_attr_flush() */
722 return RMAP_DENY;
paul718e3742002-12-13 20:15:29 +0000723 }
724 return RMAP_PERMIT;
725}
David Lamparter6b0655a2014-06-04 06:53:35 +0200726
paul94f2b392005-06-28 12:44:16 +0000727static int
paulfee0f4c2004-09-13 05:12:46 +0000728bgp_export_modifier (struct peer *rsclient, struct peer *peer,
729 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
730{
731 struct bgp_filter *filter;
732 struct bgp_info info;
733 route_map_result_t ret;
734
735 filter = &peer->filter[afi][safi];
736
737 /* Route map apply. */
738 if (ROUTE_MAP_EXPORT_NAME (filter))
739 {
740 /* Duplicate current value to new strucutre for modification. */
741 info.peer = rsclient;
742 info.attr = attr;
743
744 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
745
746 /* Apply BGP route map to the attribute. */
747 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
748
749 rsclient->rmap_type = 0;
750
751 if (ret == RMAP_DENYMATCH)
752 {
753 /* Free newly generated AS path and community by route-map. */
754 bgp_attr_flush (attr);
755 return RMAP_DENY;
756 }
757 }
758 return RMAP_PERMIT;
759}
760
paul94f2b392005-06-28 12:44:16 +0000761static int
paulfee0f4c2004-09-13 05:12:46 +0000762bgp_import_modifier (struct peer *rsclient, struct peer *peer,
763 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
764{
765 struct bgp_filter *filter;
766 struct bgp_info info;
767 route_map_result_t ret;
768
769 filter = &rsclient->filter[afi][safi];
770
771 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000772 if (peer->weight)
773 (bgp_attr_extra_get (attr))->weight = peer->weight;
paulfee0f4c2004-09-13 05:12:46 +0000774
775 /* Route map apply. */
776 if (ROUTE_MAP_IMPORT_NAME (filter))
777 {
778 /* Duplicate current value to new strucutre for modification. */
779 info.peer = peer;
780 info.attr = attr;
781
782 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
783
784 /* Apply BGP route map to the attribute. */
785 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
786
787 peer->rmap_type = 0;
788
789 if (ret == RMAP_DENYMATCH)
790 {
791 /* Free newly generated AS path and community by route-map. */
792 bgp_attr_flush (attr);
793 return RMAP_DENY;
794 }
795 }
796 return RMAP_PERMIT;
797}
David Lamparter6b0655a2014-06-04 06:53:35 +0200798
paul94f2b392005-06-28 12:44:16 +0000799static int
paul718e3742002-12-13 20:15:29 +0000800bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
801 struct attr *attr, afi_t afi, safi_t safi)
802{
803 int ret;
804 char buf[SU_ADDRSTRLEN];
805 struct bgp_filter *filter;
paul718e3742002-12-13 20:15:29 +0000806 struct peer *from;
807 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +0000808 int transparent;
809 int reflect;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700810 struct attr *riattr;
paul718e3742002-12-13 20:15:29 +0000811
812 from = ri->peer;
813 filter = &peer->filter[afi][safi];
814 bgp = peer->bgp;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700815 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paul718e3742002-12-13 20:15:29 +0000816
Paul Jakma750e8142008-07-22 21:11:48 +0000817 if (DISABLE_BGP_ANNOUNCE)
818 return 0;
paul718e3742002-12-13 20:15:29 +0000819
paulfee0f4c2004-09-13 05:12:46 +0000820 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
821 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
822 return 0;
823
paul718e3742002-12-13 20:15:29 +0000824 /* Do not send back route to sender. */
825 if (from == peer)
826 return 0;
827
828 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000829 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +0000830 if (! UNSUPPRESS_MAP_NAME (filter))
831 return 0;
832
833 /* Default route check. */
834 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
835 {
836 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
837 return 0;
paul718e3742002-12-13 20:15:29 +0000838 else if (p->family == AF_INET6 && p->prefixlen == 0)
839 return 0;
paul718e3742002-12-13 20:15:29 +0000840 }
841
paul286e1e72003-08-08 00:24:31 +0000842 /* Transparency check. */
843 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
844 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
845 transparent = 1;
846 else
847 transparent = 0;
848
paul718e3742002-12-13 20:15:29 +0000849 /* If community is not disabled check the no-export and local. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700850 if (! transparent && bgp_community_filter (peer, riattr))
paul718e3742002-12-13 20:15:29 +0000851 return 0;
852
853 /* If the attribute has originator-id and it is same as remote
854 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700855 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paul718e3742002-12-13 20:15:29 +0000856 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700857 if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +0000858 {
859 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000860 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000861 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
862 peer->host,
863 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
864 p->prefixlen);
865 return 0;
866 }
867 }
868
869 /* ORF prefix-list filter check */
870 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
871 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
872 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
873 if (peer->orf_plist[afi][safi])
874 {
875 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
876 return 0;
877 }
878
879 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700880 if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
paul718e3742002-12-13 20:15:29 +0000881 {
882 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000883 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000884 "%s [Update:SEND] %s/%d is filtered",
885 peer->host,
886 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
887 p->prefixlen);
888 return 0;
889 }
890
891#ifdef BGP_SEND_ASPATH_CHECK
892 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700893 if (aspath_loop_check (riattr->aspath, peer->as))
paul718e3742002-12-13 20:15:29 +0000894 {
895 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000896 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400897 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000898 peer->host, peer->as);
899 return 0;
900 }
paul718e3742002-12-13 20:15:29 +0000901
902 /* If we're a CONFED we need to loop check the CONFED ID too */
903 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
904 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700905 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
paul718e3742002-12-13 20:15:29 +0000906 {
907 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000908 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400909 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000910 peer->host,
911 bgp->confed_id);
912 return 0;
913 }
914 }
Thorvald Natvig95509a62016-09-29 10:25:35 -0700915#endif /* BGP_SEND_ASPATH_CHECK */
paul718e3742002-12-13 20:15:29 +0000916
917 /* Route-Reflect check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000918 if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +0000919 reflect = 1;
920 else
921 reflect = 0;
922
923 /* IBGP reflection check. */
924 if (reflect)
925 {
926 /* A route from a Client peer. */
927 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
928 {
929 /* Reflect to all the Non-Client peers and also to the
930 Client peers other than the originator. Originator check
931 is already done. So there is noting to do. */
932 /* no bgp client-to-client reflection check. */
933 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
934 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
935 return 0;
936 }
937 else
938 {
939 /* A route from a Non-client peer. Reflect to all other
940 clients. */
941 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
942 return 0;
943 }
944 }
Paul Jakma41367172007-08-06 15:24:51 +0000945
paul718e3742002-12-13 20:15:29 +0000946 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700947 bgp_attr_dup (attr, riattr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000948
paul718e3742002-12-13 20:15:29 +0000949 /* If local-preference is not set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000950 if ((peer->sort == BGP_PEER_IBGP
951 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000952 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
953 {
954 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
955 attr->local_pref = bgp->default_local_pref;
956 }
957
Pradosh Mohapatra689bb662013-09-07 07:13:37 +0000958 /* If originator-id is not set and the route is to be reflected,
959 set the originator id */
960 if (peer && from && peer->sort == BGP_PEER_IBGP &&
961 from->sort == BGP_PEER_IBGP &&
962 (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
963 {
964 attr->extra = bgp_attr_extra_get(attr);
965 IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
966 SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
967 }
968
paul718e3742002-12-13 20:15:29 +0000969 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000970 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +0000971 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
972 {
973 if (ri->peer != bgp->peer_self && ! transparent
974 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
975 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
976 }
977
Lou Berger298cc2f2016-01-12 13:42:02 -0500978
979#define NEXTHOP_IS_V4 (\
980 (safi != SAFI_ENCAP && p->family == AF_INET) || \
981 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
982
Lou Berger298cc2f2016-01-12 13:42:02 -0500983#define NEXTHOP_IS_V6 (\
984 (safi != SAFI_ENCAP && p->family == AF_INET6) || \
985 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
Lou Berger298cc2f2016-01-12 13:42:02 -0500986
paul718e3742002-12-13 20:15:29 +0000987 /* next-hop-set */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300988 if (transparent
989 || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
paul718e3742002-12-13 20:15:29 +0000990 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
Lou Berger298cc2f2016-01-12 13:42:02 -0500991 && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
Lou Berger298cc2f2016-01-12 13:42:02 -0500992 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +0000993 ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paul286e1e72003-08-08 00:24:31 +0000994 )))
paul718e3742002-12-13 20:15:29 +0000995 {
996 /* NEXT-HOP Unchanged. */
997 }
998 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
Lou Berger298cc2f2016-01-12 13:42:02 -0500999 || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
Lou Berger298cc2f2016-01-12 13:42:02 -05001000 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001001 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001002 || (peer->sort == BGP_PEER_EBGP
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07001003 && (bgp_multiaccess_check_v4 (attr->nexthop, peer) == 0)))
paul718e3742002-12-13 20:15:29 +00001004 {
1005 /* Set IPv4 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001006 if (NEXTHOP_IS_V4)
paul718e3742002-12-13 20:15:29 +00001007 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001008 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001009 memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
1010 IPV4_MAX_BYTELEN);
paul718e3742002-12-13 20:15:29 +00001011 else
1012 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1013 }
paul718e3742002-12-13 20:15:29 +00001014 /* Set IPv6 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001015 if (NEXTHOP_IS_V6)
paul718e3742002-12-13 20:15:29 +00001016 {
1017 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001018 memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00001019 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001020 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001021 }
paul718e3742002-12-13 20:15:29 +00001022 }
1023
Lou Berger298cc2f2016-01-12 13:42:02 -05001024 if (p->family == AF_INET6 && safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00001025 {
paulfee0f4c2004-09-13 05:12:46 +00001026 /* Left nexthop_local unchanged if so configured. */
1027 if ( CHECK_FLAG (peer->af_flags[afi][safi],
1028 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1029 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001030 if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
1031 attr->extra->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001032 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001033 attr->extra->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001034 }
1035
1036 /* Default nexthop_local treatment for non-RS-Clients */
1037 else
1038 {
paul718e3742002-12-13 20:15:29 +00001039 /* Link-local address should not be transit to different peer. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001040 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001041
1042 /* Set link-local address for shared network peer. */
1043 if (peer->shared_network
1044 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1045 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001046 memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00001047 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001048 attr->extra->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00001049 }
1050
1051 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1052 address.*/
1053 if (reflect)
Paul Jakmafb982c22007-05-04 20:15:47 +00001054 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001055
1056 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1057 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
Paul Jakmafb982c22007-05-04 20:15:47 +00001058 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001059 }
paulfee0f4c2004-09-13 05:12:46 +00001060
1061 }
paul718e3742002-12-13 20:15:29 +00001062
1063 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001064 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001065 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1066 && aspath_private_as_check (attr->aspath))
1067 attr->aspath = aspath_empty_get ();
1068
1069 /* Route map & unsuppress-map apply. */
1070 if (ROUTE_MAP_OUT_NAME (filter)
Paul Jakmafb982c22007-05-04 20:15:47 +00001071 || (ri->extra && ri->extra->suppress) )
paul718e3742002-12-13 20:15:29 +00001072 {
Paul Jakma7c7fa1b2006-02-18 10:52:09 +00001073 struct bgp_info info;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001074 struct attr dummy_attr;
1075 struct attr_extra dummy_extra;
1076
1077 dummy_attr.extra = &dummy_extra;
1078
paul718e3742002-12-13 20:15:29 +00001079 info.peer = peer;
1080 info.attr = attr;
1081
1082 /* The route reflector is not allowed to modify the attributes
Dinesh Dutt083e5e22015-11-09 20:21:54 -05001083 of the reflected IBGP routes, unless configured to allow it */
1084 if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) &&
1085 !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
paul718e3742002-12-13 20:15:29 +00001086 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001087 bgp_attr_dup (&dummy_attr, attr);
Paul Jakma9eda90c2007-08-30 13:36:17 +00001088 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00001089 }
paulac41b2a2003-08-12 05:32:27 +00001090
1091 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
1092
Paul Jakmafb982c22007-05-04 20:15:47 +00001093 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00001094 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1095 else
1096 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1097
paulac41b2a2003-08-12 05:32:27 +00001098 peer->rmap_type = 0;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001099
paul718e3742002-12-13 20:15:29 +00001100 if (ret == RMAP_DENYMATCH)
1101 {
1102 bgp_attr_flush (attr);
1103 return 0;
1104 }
1105 }
1106 return 1;
1107}
1108
paul94f2b392005-06-28 12:44:16 +00001109static int
paulfee0f4c2004-09-13 05:12:46 +00001110bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
1111 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001112{
paulfee0f4c2004-09-13 05:12:46 +00001113 int ret;
1114 char buf[SU_ADDRSTRLEN];
1115 struct bgp_filter *filter;
1116 struct bgp_info info;
1117 struct peer *from;
Josh Bailey0b597ef2011-07-20 20:49:11 -07001118 struct attr *riattr;
paulfee0f4c2004-09-13 05:12:46 +00001119
1120 from = ri->peer;
1121 filter = &rsclient->filter[afi][safi];
Josh Bailey0b597ef2011-07-20 20:49:11 -07001122 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paulfee0f4c2004-09-13 05:12:46 +00001123
Paul Jakma750e8142008-07-22 21:11:48 +00001124 if (DISABLE_BGP_ANNOUNCE)
1125 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001126
1127 /* Do not send back route to sender. */
1128 if (from == rsclient)
1129 return 0;
1130
1131 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001132 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001133 if (! UNSUPPRESS_MAP_NAME (filter))
1134 return 0;
1135
1136 /* Default route check. */
1137 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
1138 PEER_STATUS_DEFAULT_ORIGINATE))
1139 {
1140 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
1141 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001142 else if (p->family == AF_INET6 && p->prefixlen == 0)
1143 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001144 }
1145
1146 /* If the attribute has originator-id and it is same as remote
1147 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001148 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paulfee0f4c2004-09-13 05:12:46 +00001149 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001150 if (IPV4_ADDR_SAME (&rsclient->remote_id,
Josh Bailey0b597ef2011-07-20 20:49:11 -07001151 &riattr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001152 {
1153 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001154 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001155 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1156 rsclient->host,
1157 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1158 p->prefixlen);
1159 return 0;
1160 }
1161 }
1162
1163 /* ORF prefix-list filter check */
1164 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
1165 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
1166 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
1167 if (rsclient->orf_plist[afi][safi])
1168 {
1169 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
1170 return 0;
1171 }
1172
1173 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001174 if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
paulfee0f4c2004-09-13 05:12:46 +00001175 {
1176 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001177 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001178 "%s [Update:SEND] %s/%d is filtered",
1179 rsclient->host,
1180 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1181 p->prefixlen);
1182 return 0;
1183 }
1184
1185#ifdef BGP_SEND_ASPATH_CHECK
1186 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001187 if (aspath_loop_check (riattr->aspath, rsclient->as))
paulfee0f4c2004-09-13 05:12:46 +00001188 {
1189 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001190 zlog (rsclient->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001191 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paulfee0f4c2004-09-13 05:12:46 +00001192 rsclient->host, rsclient->as);
1193 return 0;
1194 }
1195#endif /* BGP_SEND_ASPATH_CHECK */
1196
1197 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001198 bgp_attr_dup (attr, riattr);
paulfee0f4c2004-09-13 05:12:46 +00001199
1200 /* next-hop-set */
1201 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
paulfee0f4c2004-09-13 05:12:46 +00001202 || (p->family == AF_INET6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001203 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paulfee0f4c2004-09-13 05:12:46 +00001204 )
1205 {
1206 /* Set IPv4 nexthop. */
1207 if (p->family == AF_INET)
1208 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001209 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001210 memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
paulfee0f4c2004-09-13 05:12:46 +00001211 IPV4_MAX_BYTELEN);
1212 else
1213 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
1214 }
paulfee0f4c2004-09-13 05:12:46 +00001215 /* Set IPv6 nexthop. */
1216 if (p->family == AF_INET6)
1217 {
1218 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001219 memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
paulfee0f4c2004-09-13 05:12:46 +00001220 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001221 attr->extra->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001222 }
paulfee0f4c2004-09-13 05:12:46 +00001223 }
1224
paulfee0f4c2004-09-13 05:12:46 +00001225 if (p->family == AF_INET6)
1226 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001227 struct attr_extra *attre = attr->extra;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001228
paulfee0f4c2004-09-13 05:12:46 +00001229 /* Left nexthop_local unchanged if so configured. */
1230 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
1231 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1232 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001233 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1234 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001235 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001236 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001237 }
1238
1239 /* Default nexthop_local treatment for RS-Clients */
1240 else
1241 {
1242 /* Announcer and RS-Client are both in the same network */
1243 if (rsclient->shared_network && from->shared_network &&
1244 (rsclient->ifindex == from->ifindex))
1245 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001246 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1247 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001248 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001249 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001250 }
1251
1252 /* Set link-local address for shared network peer. */
1253 else if (rsclient->shared_network
1254 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
1255 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001256 memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
paulfee0f4c2004-09-13 05:12:46 +00001257 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001258 attre->mp_nexthop_len = 32;
paulfee0f4c2004-09-13 05:12:46 +00001259 }
1260
1261 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001262 attre->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001263 }
1264
1265 }
paulfee0f4c2004-09-13 05:12:46 +00001266
1267 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001268 if (rsclient->sort == BGP_PEER_EBGP
paulfee0f4c2004-09-13 05:12:46 +00001269 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1270 && aspath_private_as_check (attr->aspath))
1271 attr->aspath = aspath_empty_get ();
1272
1273 /* Route map & unsuppress-map apply. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001274 if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
paulfee0f4c2004-09-13 05:12:46 +00001275 {
1276 info.peer = rsclient;
1277 info.attr = attr;
1278
1279 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1280
Paul Jakmafb982c22007-05-04 20:15:47 +00001281 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001282 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1283 else
1284 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1285
1286 rsclient->rmap_type = 0;
1287
1288 if (ret == RMAP_DENYMATCH)
1289 {
1290 bgp_attr_flush (attr);
1291 return 0;
1292 }
1293 }
1294
1295 return 1;
1296}
1297
1298struct bgp_info_pair
1299{
1300 struct bgp_info *old;
1301 struct bgp_info *new;
1302};
1303
paul94f2b392005-06-28 12:44:16 +00001304static void
Josh Bailey96450fa2011-07-20 20:45:12 -07001305bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
Paul Jakma6d4742b2015-11-25 17:14:37 +00001306 struct bgp_info_pair *result,
1307 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00001308{
paul718e3742002-12-13 20:15:29 +00001309 struct bgp_info *new_select;
1310 struct bgp_info *old_select;
paulfee0f4c2004-09-13 05:12:46 +00001311 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00001312 struct bgp_info *ri1;
1313 struct bgp_info *ri2;
paulb40d9392005-08-22 22:34:41 +00001314 struct bgp_info *nextri = NULL;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001315 int cmpret, do_mpath;
Josh Bailey96450fa2011-07-20 20:45:12 -07001316 struct list mp_list;
Paul Jakma91b9e852015-12-01 14:32:11 +00001317
1318 result->old = result->new = NULL;
1319
1320 if (rn->info == NULL)
1321 {
1322 char buf[PREFIX_STRLEN];
1323 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1324 __func__,
1325 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1326 return;
1327 }
1328
Josh Bailey96450fa2011-07-20 20:45:12 -07001329 bgp_mp_list_init (&mp_list);
Paul Jakma6d4742b2015-11-25 17:14:37 +00001330 do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001331
paul718e3742002-12-13 20:15:29 +00001332 /* bgp deterministic-med */
1333 new_select = NULL;
1334 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1335 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1336 {
1337 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1338 continue;
1339 if (BGP_INFO_HOLDDOWN (ri1))
1340 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001341 if (ri1->peer && ri1->peer != bgp->peer_self)
1342 if (ri1->peer->status != Established)
1343 continue;
paul718e3742002-12-13 20:15:29 +00001344
1345 new_select = ri1;
Josh Bailey6918e742011-07-20 20:48:20 -07001346 if (do_mpath)
1347 bgp_mp_list_add (&mp_list, ri1);
1348 old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
paul718e3742002-12-13 20:15:29 +00001349 if (ri1->next)
1350 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1351 {
1352 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1353 continue;
1354 if (BGP_INFO_HOLDDOWN (ri2))
1355 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001356 if (ri2->peer &&
1357 ri2->peer != bgp->peer_self &&
1358 !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
1359 if (ri2->peer->status != Established)
1360 continue;
paul718e3742002-12-13 20:15:29 +00001361
1362 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1363 || aspath_cmp_left_confed (ri1->attr->aspath,
1364 ri2->attr->aspath))
1365 {
Josh Bailey6918e742011-07-20 20:48:20 -07001366 if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
1367 old_select = ri2;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001368 if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
1369 == -1)
paul718e3742002-12-13 20:15:29 +00001370 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001371 bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001372 new_select = ri2;
1373 }
1374
Paul Jakma6d4742b2015-11-25 17:14:37 +00001375 if (do_mpath)
1376 {
1377 if (cmpret != 0)
1378 bgp_mp_list_clear (&mp_list);
1379
1380 if (cmpret == 0 || cmpret == -1)
1381 bgp_mp_list_add (&mp_list, ri2);
1382 }
Josh Bailey6918e742011-07-20 20:48:20 -07001383
Paul Jakma1a392d42006-09-07 00:24:49 +00001384 bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001385 }
1386 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001387 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
1388 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
Josh Bailey6918e742011-07-20 20:48:20 -07001389
Paul Jakma6d4742b2015-11-25 17:14:37 +00001390 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey6918e742011-07-20 20:48:20 -07001391 bgp_mp_list_clear (&mp_list);
paul718e3742002-12-13 20:15:29 +00001392 }
1393
1394 /* Check old selected route and new selected route. */
1395 old_select = NULL;
1396 new_select = NULL;
paulb40d9392005-08-22 22:34:41 +00001397 for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
paul718e3742002-12-13 20:15:29 +00001398 {
1399 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1400 old_select = ri;
1401
1402 if (BGP_INFO_HOLDDOWN (ri))
paulb40d9392005-08-22 22:34:41 +00001403 {
1404 /* reap REMOVED routes, if needs be
1405 * selected route must stay for a while longer though
1406 */
1407 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
1408 && (ri != old_select))
1409 bgp_info_reap (rn, ri);
1410
1411 continue;
1412 }
paul718e3742002-12-13 20:15:29 +00001413
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001414 if (ri->peer &&
1415 ri->peer != bgp->peer_self &&
1416 !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
1417 if (ri->peer->status != Established)
1418 continue;
1419
paul718e3742002-12-13 20:15:29 +00001420 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1421 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1422 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001423 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001424 continue;
1425 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001426 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1427 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001428
Paul Jakma6d4742b2015-11-25 17:14:37 +00001429 if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
Josh Bailey96450fa2011-07-20 20:45:12 -07001430 {
Josh Bailey6918e742011-07-20 20:48:20 -07001431 if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1432 bgp_mp_dmed_deselect (new_select);
1433
Josh Bailey96450fa2011-07-20 20:45:12 -07001434 new_select = ri;
Josh Bailey96450fa2011-07-20 20:45:12 -07001435 }
Paul Jakma6d4742b2015-11-25 17:14:37 +00001436 else if (cmpret == 1 && do_mpath
1437 && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Josh Bailey6918e742011-07-20 20:48:20 -07001438 bgp_mp_dmed_deselect (ri);
Josh Bailey96450fa2011-07-20 20:45:12 -07001439
Paul Jakma6d4742b2015-11-25 17:14:37 +00001440 if (do_mpath)
1441 {
1442 if (cmpret != 0)
1443 bgp_mp_list_clear (&mp_list);
1444
1445 if (cmpret == 0 || cmpret == -1)
1446 bgp_mp_list_add (&mp_list, ri);
1447 }
paul718e3742002-12-13 20:15:29 +00001448 }
paulfee0f4c2004-09-13 05:12:46 +00001449
Josh Bailey6918e742011-07-20 20:48:20 -07001450 if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Paul Jakma6d4742b2015-11-25 17:14:37 +00001451 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001452
Josh Bailey0b597ef2011-07-20 20:49:11 -07001453 bgp_info_mpath_aggregate_update (new_select, old_select);
Josh Bailey96450fa2011-07-20 20:45:12 -07001454 bgp_mp_list_clear (&mp_list);
1455
1456 result->old = old_select;
1457 result->new = new_select;
1458
1459 return;
paulfee0f4c2004-09-13 05:12:46 +00001460}
1461
paul94f2b392005-06-28 12:44:16 +00001462static int
paulfee0f4c2004-09-13 05:12:46 +00001463bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
Paul Jakma9eda90c2007-08-30 13:36:17 +00001464 struct bgp_node *rn, afi_t afi, safi_t safi)
1465{
paulfee0f4c2004-09-13 05:12:46 +00001466 struct prefix *p;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001467 struct attr attr;
1468 struct attr_extra extra;
paulfee0f4c2004-09-13 05:12:46 +00001469
Lou Berger050defe2016-01-12 13:41:59 -05001470 memset (&attr, 0, sizeof(struct attr));
1471 memset (&extra, 0, sizeof(struct attr_extra));
1472
paulfee0f4c2004-09-13 05:12:46 +00001473 p = &rn->p;
1474
Paul Jakma9eda90c2007-08-30 13:36:17 +00001475 /* Announce route to Established peer. */
1476 if (peer->status != Established)
paulfee0f4c2004-09-13 05:12:46 +00001477 return 0;
1478
Paul Jakma9eda90c2007-08-30 13:36:17 +00001479 /* Address family configuration check. */
1480 if (! peer->afc_nego[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001481 return 0;
1482
Paul Jakma9eda90c2007-08-30 13:36:17 +00001483 /* First update is deferred until ORF or ROUTE-REFRESH is received */
paulfee0f4c2004-09-13 05:12:46 +00001484 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1485 PEER_STATUS_ORF_WAIT_REFRESH))
1486 return 0;
1487
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001488 /* It's initialized in bgp_announce_[check|check_rsclient]() */
1489 attr.extra = &extra;
1490
Avneesh Sachdev67174042012-08-17 08:19:49 -07001491 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001492 {
1493 case BGP_TABLE_MAIN:
1494 /* Announcement to peer->conf. If the route is filtered,
1495 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001496 if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
1497 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
paulfee0f4c2004-09-13 05:12:46 +00001498 else
1499 bgp_adj_out_unset (rn, peer, p, afi, safi);
1500 break;
1501 case BGP_TABLE_RSCLIENT:
1502 /* Announcement to peer->conf. If the route is filtered,
1503 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001504 if (selected &&
1505 bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
1506 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1507 else
1508 bgp_adj_out_unset (rn, peer, p, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001509 break;
1510 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001511
Lou Berger050defe2016-01-12 13:41:59 -05001512 bgp_attr_flush (&attr);
paulfee0f4c2004-09-13 05:12:46 +00001513 return 0;
paul200df112005-06-01 11:17:05 +00001514}
paulfee0f4c2004-09-13 05:12:46 +00001515
paul200df112005-06-01 11:17:05 +00001516struct bgp_process_queue
paulfee0f4c2004-09-13 05:12:46 +00001517{
paul200df112005-06-01 11:17:05 +00001518 struct bgp *bgp;
1519 struct bgp_node *rn;
1520 afi_t afi;
1521 safi_t safi;
1522};
1523
1524static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001525bgp_process_rsclient (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001526{
paul0fb58d52005-11-14 14:31:49 +00001527 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001528 struct bgp *bgp = pq->bgp;
1529 struct bgp_node *rn = pq->rn;
1530 afi_t afi = pq->afi;
1531 safi_t safi = pq->safi;
paulfee0f4c2004-09-13 05:12:46 +00001532 struct bgp_info *new_select;
1533 struct bgp_info *old_select;
1534 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001535 struct listnode *node, *nnode;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001536 struct peer *rsclient = bgp_node_table (rn)->owner;
paul200df112005-06-01 11:17:05 +00001537
paulfee0f4c2004-09-13 05:12:46 +00001538 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001539 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001540 new_select = old_and_new.new;
1541 old_select = old_and_new.old;
1542
paul200df112005-06-01 11:17:05 +00001543 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
1544 {
Chris Caputo228da422009-07-18 05:44:03 +00001545 if (rsclient->group)
1546 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
1547 {
1548 /* Nothing to do. */
1549 if (old_select && old_select == new_select)
1550 if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1551 continue;
paulfee0f4c2004-09-13 05:12:46 +00001552
Chris Caputo228da422009-07-18 05:44:03 +00001553 if (old_select)
1554 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1555 if (new_select)
1556 {
1557 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1558 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001559 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1560 }
paulfee0f4c2004-09-13 05:12:46 +00001561
Chris Caputo228da422009-07-18 05:44:03 +00001562 bgp_process_announce_selected (rsclient, new_select, rn,
1563 afi, safi);
1564 }
paul200df112005-06-01 11:17:05 +00001565 }
1566 else
1567 {
hassob7395792005-08-26 12:58:38 +00001568 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001569 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hassob7395792005-08-26 12:58:38 +00001570 if (new_select)
1571 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001572 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1573 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001574 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hassob7395792005-08-26 12:58:38 +00001575 }
Paul Jakma9eda90c2007-08-30 13:36:17 +00001576 bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
paul200df112005-06-01 11:17:05 +00001577 }
paulfee0f4c2004-09-13 05:12:46 +00001578
paulb40d9392005-08-22 22:34:41 +00001579 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1580 bgp_info_reap (rn, old_select);
1581
paul200df112005-06-01 11:17:05 +00001582 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1583 return WQ_SUCCESS;
paulfee0f4c2004-09-13 05:12:46 +00001584}
1585
paul200df112005-06-01 11:17:05 +00001586static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001587bgp_process_main (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001588{
paul0fb58d52005-11-14 14:31:49 +00001589 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001590 struct bgp *bgp = pq->bgp;
1591 struct bgp_node *rn = pq->rn;
1592 afi_t afi = pq->afi;
1593 safi_t safi = pq->safi;
1594 struct prefix *p = &rn->p;
paulfee0f4c2004-09-13 05:12:46 +00001595 struct bgp_info *new_select;
1596 struct bgp_info *old_select;
1597 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001598 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00001599 struct peer *peer;
Paul Jakmafb982c22007-05-04 20:15:47 +00001600
paulfee0f4c2004-09-13 05:12:46 +00001601 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001602 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001603 old_select = old_and_new.old;
1604 new_select = old_and_new.new;
1605
1606 /* Nothing to do. */
Daniel Walton325fcfb2015-05-19 17:58:10 -07001607 if (old_select && old_select == new_select
1608 && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR))
paulfee0f4c2004-09-13 05:12:46 +00001609 {
1610 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
paul200df112005-06-01 11:17:05 +00001611 {
Josh Bailey8196f132011-07-20 20:47:07 -07001612 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
1613 CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
G.Balaji5a616c02011-11-26 21:58:42 +04001614 bgp_zebra_announce (p, old_select, bgp, safi);
paul200df112005-06-01 11:17:05 +00001615
Josh Bailey8196f132011-07-20 20:47:07 -07001616 UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
paul200df112005-06-01 11:17:05 +00001617 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1618 return WQ_SUCCESS;
1619 }
paulfee0f4c2004-09-13 05:12:46 +00001620 }
paul718e3742002-12-13 20:15:29 +00001621
Daniel Walton325fcfb2015-05-19 17:58:10 -07001622 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1623 UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
1624
hasso338b3422005-02-23 14:27:24 +00001625 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001626 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hasso338b3422005-02-23 14:27:24 +00001627 if (new_select)
1628 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001629 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1630 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001631 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hasso338b3422005-02-23 14:27:24 +00001632 }
1633
1634
paul718e3742002-12-13 20:15:29 +00001635 /* Check each BGP peer. */
paul1eb8ef22005-04-07 07:30:20 +00001636 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00001637 {
Paul Jakma9eda90c2007-08-30 13:36:17 +00001638 bgp_process_announce_selected (peer, new_select, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001639 }
1640
1641 /* FIB update. */
G.Balaji5a616c02011-11-26 21:58:42 +04001642 if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
1643 ! bgp_option_check (BGP_OPT_NO_FIB)))
paul718e3742002-12-13 20:15:29 +00001644 {
1645 if (new_select
1646 && new_select->type == ZEBRA_ROUTE_BGP
1647 && new_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001648 bgp_zebra_announce (p, new_select, bgp, safi);
paul718e3742002-12-13 20:15:29 +00001649 else
1650 {
1651 /* Withdraw the route from the kernel. */
1652 if (old_select
1653 && old_select->type == ZEBRA_ROUTE_BGP
1654 && old_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001655 bgp_zebra_withdraw (p, old_select, safi);
paul718e3742002-12-13 20:15:29 +00001656 }
1657 }
paulb40d9392005-08-22 22:34:41 +00001658
Lou Berger050defe2016-01-12 13:41:59 -05001659 /* Reap old select bgp_info, if it has been removed */
paulb40d9392005-08-22 22:34:41 +00001660 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1661 bgp_info_reap (rn, old_select);
1662
paul200df112005-06-01 11:17:05 +00001663 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1664 return WQ_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001665}
1666
paul200df112005-06-01 11:17:05 +00001667static void
paul0fb58d52005-11-14 14:31:49 +00001668bgp_processq_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001669{
paul0fb58d52005-11-14 14:31:49 +00001670 struct bgp_process_queue *pq = data;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001671 struct bgp_table *table = bgp_node_table (pq->rn);
paul0fb58d52005-11-14 14:31:49 +00001672
Chris Caputo228da422009-07-18 05:44:03 +00001673 bgp_unlock (pq->bgp);
paul200df112005-06-01 11:17:05 +00001674 bgp_unlock_node (pq->rn);
Chris Caputo228da422009-07-18 05:44:03 +00001675 bgp_table_unlock (table);
paul200df112005-06-01 11:17:05 +00001676 XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
1677}
1678
1679static void
1680bgp_process_queue_init (void)
1681{
1682 bm->process_main_queue
1683 = work_queue_new (bm->master, "process_main_queue");
1684 bm->process_rsclient_queue
1685 = work_queue_new (bm->master, "process_rsclient_queue");
1686
1687 if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
1688 {
1689 zlog_err ("%s: Failed to allocate work queue", __func__);
1690 exit (1);
1691 }
1692
1693 bm->process_main_queue->spec.workfunc = &bgp_process_main;
paul200df112005-06-01 11:17:05 +00001694 bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
Paul Jakma838bbde2010-01-08 14:05:32 +00001695 bm->process_main_queue->spec.max_retries = 0;
1696 bm->process_main_queue->spec.hold = 50;
1697
Paul Jakma838bbde2010-01-08 14:05:32 +00001698 bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
David Lamparterd43f8b32015-03-03 08:54:54 +01001699 bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
1700 bm->process_rsclient_queue->spec.max_retries = 0;
1701 bm->process_rsclient_queue->spec.hold = 50;
paul200df112005-06-01 11:17:05 +00001702}
1703
1704void
paulfee0f4c2004-09-13 05:12:46 +00001705bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1706{
paul200df112005-06-01 11:17:05 +00001707 struct bgp_process_queue *pqnode;
1708
1709 /* already scheduled for processing? */
1710 if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
1711 return;
1712
Paul Jakma91b9e852015-12-01 14:32:11 +00001713 if (rn->info == NULL)
1714 {
1715 /* XXX: Perhaps remove before next release, after we've flushed out
1716 * any obvious cases
1717 */
1718 assert (rn->info != NULL);
1719 char buf[PREFIX_STRLEN];
1720 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1721 __func__,
1722 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1723 return;
1724 }
1725
paul200df112005-06-01 11:17:05 +00001726 if ( (bm->process_main_queue == NULL) ||
1727 (bm->process_rsclient_queue == NULL) )
1728 bgp_process_queue_init ();
1729
1730 pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
1731 sizeof (struct bgp_process_queue));
1732 if (!pqnode)
1733 return;
Chris Caputo228da422009-07-18 05:44:03 +00001734
1735 /* all unlocked in bgp_processq_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07001736 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00001737 pqnode->rn = bgp_lock_node (rn);
paul200df112005-06-01 11:17:05 +00001738 pqnode->bgp = bgp;
Chris Caputo228da422009-07-18 05:44:03 +00001739 bgp_lock (bgp);
paul200df112005-06-01 11:17:05 +00001740 pqnode->afi = afi;
1741 pqnode->safi = safi;
1742
Avneesh Sachdev67174042012-08-17 08:19:49 -07001743 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001744 {
paul200df112005-06-01 11:17:05 +00001745 case BGP_TABLE_MAIN:
1746 work_queue_add (bm->process_main_queue, pqnode);
1747 break;
1748 case BGP_TABLE_RSCLIENT:
1749 work_queue_add (bm->process_rsclient_queue, pqnode);
1750 break;
paulfee0f4c2004-09-13 05:12:46 +00001751 }
paul200df112005-06-01 11:17:05 +00001752
Stephen Hemminger07ff4dc2013-01-04 22:29:20 +00001753 SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
paul200df112005-06-01 11:17:05 +00001754 return;
paulfee0f4c2004-09-13 05:12:46 +00001755}
hasso0a486e52005-02-01 20:57:17 +00001756
paul94f2b392005-06-28 12:44:16 +00001757static int
hasso0a486e52005-02-01 20:57:17 +00001758bgp_maximum_prefix_restart_timer (struct thread *thread)
1759{
1760 struct peer *peer;
1761
1762 peer = THREAD_ARG (thread);
1763 peer->t_pmax_restart = NULL;
1764
1765 if (BGP_DEBUG (events, EVENTS))
1766 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1767 peer->host);
1768
1769 peer_clear (peer);
1770
1771 return 0;
1772}
1773
paulfee0f4c2004-09-13 05:12:46 +00001774int
paul5228ad22004-06-04 17:58:18 +00001775bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1776 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001777{
hassoe0701b72004-05-20 09:19:34 +00001778 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1779 return 0;
1780
1781 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001782 {
hassoe0701b72004-05-20 09:19:34 +00001783 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1784 && ! always)
1785 return 0;
paul718e3742002-12-13 20:15:29 +00001786
hassoe0701b72004-05-20 09:19:34 +00001787 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001788 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1789 "limit %ld", afi_safi_print (afi, safi), peer->host,
1790 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001791 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001792
hassoe0701b72004-05-20 09:19:34 +00001793 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1794 return 0;
paul718e3742002-12-13 20:15:29 +00001795
hassoe0701b72004-05-20 09:19:34 +00001796 {
paul5228ad22004-06-04 17:58:18 +00001797 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001798
1799 if (safi == SAFI_MPLS_VPN)
Denis Ovsienko42e6d742011-07-14 12:36:19 +04001800 safi = SAFI_MPLS_LABELED_VPN;
paul5228ad22004-06-04 17:58:18 +00001801
1802 ndata[0] = (afi >> 8);
1803 ndata[1] = afi;
1804 ndata[2] = safi;
1805 ndata[3] = (peer->pmax[afi][safi] >> 24);
1806 ndata[4] = (peer->pmax[afi][safi] >> 16);
1807 ndata[5] = (peer->pmax[afi][safi] >> 8);
1808 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001809
1810 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1811 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1812 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1813 }
hasso0a486e52005-02-01 20:57:17 +00001814
1815 /* restart timer start */
1816 if (peer->pmax_restart[afi][safi])
1817 {
1818 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1819
1820 if (BGP_DEBUG (events, EVENTS))
1821 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1822 peer->host, peer->v_pmax_restart);
1823
1824 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1825 peer->v_pmax_restart);
1826 }
1827
hassoe0701b72004-05-20 09:19:34 +00001828 return 1;
paul718e3742002-12-13 20:15:29 +00001829 }
hassoe0701b72004-05-20 09:19:34 +00001830 else
1831 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1832
1833 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1834 {
1835 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1836 && ! always)
1837 return 0;
1838
1839 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001840 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1841 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1842 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001843 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1844 }
1845 else
1846 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001847 return 0;
1848}
1849
paulb40d9392005-08-22 22:34:41 +00001850/* Unconditionally remove the route from the RIB, without taking
1851 * damping into consideration (eg, because the session went down)
1852 */
paul94f2b392005-06-28 12:44:16 +00001853static void
paul718e3742002-12-13 20:15:29 +00001854bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1855 afi_t afi, safi_t safi)
1856{
paul902212c2006-02-05 17:51:19 +00001857 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1858
1859 if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1860 bgp_info_delete (rn, ri); /* keep historical info */
1861
paulb40d9392005-08-22 22:34:41 +00001862 bgp_process (peer->bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001863}
1864
paul94f2b392005-06-28 12:44:16 +00001865static void
paul718e3742002-12-13 20:15:29 +00001866bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
Lou Berger050defe2016-01-12 13:41:59 -05001867 afi_t afi, safi_t safi, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00001868{
paul718e3742002-12-13 20:15:29 +00001869 int status = BGP_DAMP_NONE;
1870
paulb40d9392005-08-22 22:34:41 +00001871 /* apply dampening, if result is suppressed, we'll be retaining
1872 * the bgp_info in the RIB for historical reference.
1873 */
1874 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001875 && peer->sort == BGP_PEER_EBGP)
paulb40d9392005-08-22 22:34:41 +00001876 if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0))
1877 == BGP_DAMP_SUPPRESSED)
paul902212c2006-02-05 17:51:19 +00001878 {
paul902212c2006-02-05 17:51:19 +00001879 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1880 return;
1881 }
1882
1883 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00001884}
1885
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05001886static struct bgp_info *
1887info_make (int type, int sub_type, struct peer *peer, struct attr *attr,
1888 struct bgp_node *rn)
1889{
1890 struct bgp_info *new;
1891
1892 /* Make new BGP info. */
1893 new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
1894 new->type = type;
1895 new->sub_type = sub_type;
1896 new->peer = peer;
1897 new->attr = attr;
1898 new->uptime = bgp_clock ();
1899 new->net = rn;
1900 return new;
1901}
1902
paul94f2b392005-06-28 12:44:16 +00001903static void
paulfee0f4c2004-09-13 05:12:46 +00001904bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1905 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1906 int sub_type, struct prefix_rd *prd, u_char *tag)
1907{
1908 struct bgp_node *rn;
1909 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001910 struct attr new_attr;
1911 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00001912 struct attr *attr_new;
1913 struct attr *attr_new2;
1914 struct bgp_info *ri;
1915 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001916 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001917 char buf[SU_ADDRSTRLEN];
1918
1919 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1920 if (peer == rsclient)
1921 return;
1922
1923 bgp = peer->bgp;
1924 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1925
1926 /* Check previously received route. */
1927 for (ri = rn->info; ri; ri = ri->next)
1928 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1929 break;
1930
1931 /* AS path loop check. */
Milan Kocian000e1572013-10-18 07:59:38 +00001932 if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001933 {
1934 reason = "as-path contains our own AS;";
1935 goto filtered;
1936 }
1937
1938 /* Route reflector originator ID check. */
1939 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00001940 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001941 {
1942 reason = "originator is us;";
1943 goto filtered;
1944 }
Paul Jakmafb982c22007-05-04 20:15:47 +00001945
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001946 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00001947 bgp_attr_dup (&new_attr, attr);
paulfee0f4c2004-09-13 05:12:46 +00001948
1949 /* Apply export policy. */
1950 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1951 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1952 {
1953 reason = "export-policy;";
1954 goto filtered;
1955 }
1956
1957 attr_new2 = bgp_attr_intern (&new_attr);
Paul Jakmafb982c22007-05-04 20:15:47 +00001958
paulfee0f4c2004-09-13 05:12:46 +00001959 /* Apply import policy. */
1960 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1961 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001962 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001963
1964 reason = "import-policy;";
1965 goto filtered;
1966 }
1967
1968 attr_new = bgp_attr_intern (&new_attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001969 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001970
1971 /* IPv4 unicast next hop check. */
G.Balaji5a616c02011-11-26 21:58:42 +04001972 if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
paulfee0f4c2004-09-13 05:12:46 +00001973 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001974 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
paulfee0f4c2004-09-13 05:12:46 +00001975 if (new_attr.nexthop.s_addr == 0
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001976 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
paulfee0f4c2004-09-13 05:12:46 +00001977 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001978 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00001979
1980 reason = "martian next-hop;";
1981 goto filtered;
1982 }
1983 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001984
paulfee0f4c2004-09-13 05:12:46 +00001985 /* If the update is implicit withdraw. */
1986 if (ri)
1987 {
Stephen Hemminger65957882010-01-15 16:22:10 +03001988 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00001989
1990 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00001991 if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
1992 && attrhash_cmp (ri->attr, attr_new))
paulfee0f4c2004-09-13 05:12:46 +00001993 {
1994
paulfee0f4c2004-09-13 05:12:46 +00001995
1996 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001997 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001998 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1999 peer->host,
2000 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2001 p->prefixlen, rsclient->host);
2002
Chris Caputo228da422009-07-18 05:44:03 +00002003 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002004 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002005 bgp_attr_flush(&new_attr);
Chris Caputo228da422009-07-18 05:44:03 +00002006 return;
paulfee0f4c2004-09-13 05:12:46 +00002007 }
2008
Paul Jakma16d2e242007-04-10 19:32:10 +00002009 /* Withdraw/Announce before we fully processed the withdraw */
2010 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2011 bgp_info_restore (rn, ri);
2012
paulfee0f4c2004-09-13 05:12:46 +00002013 /* Received Logging. */
2014 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002015 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002016 peer->host,
2017 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2018 p->prefixlen, rsclient->host);
2019
2020 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002021 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00002022
2023 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002024 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00002025 ri->attr = attr_new;
2026
2027 /* Update MPLS tag. */
2028 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002029 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002030
Paul Jakma1a392d42006-09-07 00:24:49 +00002031 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002032
2033 /* Process change. */
2034 bgp_process (bgp, rn, afi, safi);
2035 bgp_unlock_node (rn);
2036
2037 return;
2038 }
2039
2040 /* Received Logging. */
2041 if (BGP_DEBUG (update, UPDATE_IN))
2042 {
ajsd2c1f162004-12-08 21:10:20 +00002043 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002044 peer->host,
2045 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2046 p->prefixlen, rsclient->host);
2047 }
2048
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05002049 new = info_make(type, sub_type, peer, attr_new, rn);
paulfee0f4c2004-09-13 05:12:46 +00002050
2051 /* Update MPLS tag. */
2052 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002053 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002054
Paul Jakma1a392d42006-09-07 00:24:49 +00002055 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002056
2057 /* Register new BGP information. */
2058 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002059
2060 /* route_node_get lock */
2061 bgp_unlock_node (rn);
2062
paulfee0f4c2004-09-13 05:12:46 +00002063 /* Process change. */
2064 bgp_process (bgp, rn, afi, safi);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002065
paulfee0f4c2004-09-13 05:12:46 +00002066 return;
2067
2068 filtered:
2069
2070 /* This BGP update is filtered. Log the reason then update BGP entry. */
2071 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002072 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002073 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2074 peer->host,
2075 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2076 p->prefixlen, rsclient->host, reason);
2077
2078 if (ri)
paulb40d9392005-08-22 22:34:41 +00002079 bgp_rib_remove (rn, ri, peer, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002080
2081 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002082
paulfee0f4c2004-09-13 05:12:46 +00002083 return;
2084}
2085
paul94f2b392005-06-28 12:44:16 +00002086static void
paulfee0f4c2004-09-13 05:12:46 +00002087bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
2088 struct peer *peer, struct prefix *p, int type, int sub_type,
2089 struct prefix_rd *prd, u_char *tag)
Chris Caputo228da422009-07-18 05:44:03 +00002090{
paulfee0f4c2004-09-13 05:12:46 +00002091 struct bgp_node *rn;
2092 struct bgp_info *ri;
2093 char buf[SU_ADDRSTRLEN];
2094
2095 if (rsclient == peer)
Chris Caputo228da422009-07-18 05:44:03 +00002096 return;
paulfee0f4c2004-09-13 05:12:46 +00002097
2098 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
2099
2100 /* Lookup withdrawn route. */
2101 for (ri = rn->info; ri; ri = ri->next)
2102 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2103 break;
2104
2105 /* Withdraw specified route from routing table. */
2106 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002107 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paulfee0f4c2004-09-13 05:12:46 +00002108 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002109 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002110 "%s Can't find the route %s/%d", peer->host,
2111 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2112 p->prefixlen);
2113
2114 /* Unlock bgp_node_get() lock. */
Chris Caputo228da422009-07-18 05:44:03 +00002115 bgp_unlock_node (rn);
2116}
paulfee0f4c2004-09-13 05:12:46 +00002117
paul94f2b392005-06-28 12:44:16 +00002118static int
paulfee0f4c2004-09-13 05:12:46 +00002119bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00002120 afi_t afi, safi_t safi, int type, int sub_type,
2121 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2122{
2123 int ret;
2124 int aspath_loop_count = 0;
2125 struct bgp_node *rn;
2126 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002127 struct attr new_attr;
2128 struct attr_extra new_extra;
paul718e3742002-12-13 20:15:29 +00002129 struct attr *attr_new;
2130 struct bgp_info *ri;
2131 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00002132 const char *reason;
paul718e3742002-12-13 20:15:29 +00002133 char buf[SU_ADDRSTRLEN];
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002134 int connected = 0;
paul718e3742002-12-13 20:15:29 +00002135
Lou Berger370b7e52016-02-04 21:29:49 -05002136 memset (&new_attr, 0, sizeof(struct attr));
2137 memset (&new_extra, 0, sizeof(struct attr_extra));
2138
paul718e3742002-12-13 20:15:29 +00002139 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00002140 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
Paul Jakmafb982c22007-05-04 20:15:47 +00002141
paul718e3742002-12-13 20:15:29 +00002142 /* When peer's soft reconfiguration enabled. Record input packet in
2143 Adj-RIBs-In. */
Jorge Boncompte [DTI2]343aa822012-05-07 16:53:08 +00002144 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2145 && peer != bgp->peer_self)
paul718e3742002-12-13 20:15:29 +00002146 bgp_adj_in_set (rn, peer, attr);
2147
2148 /* Check previously received route. */
2149 for (ri = rn->info; ri; ri = ri->next)
2150 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2151 break;
2152
2153 /* AS path local-as loop check. */
2154 if (peer->change_local_as)
2155 {
2156 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2157 aspath_loop_count = 1;
2158
2159 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2160 {
2161 reason = "as-path contains our own AS;";
2162 goto filtered;
2163 }
2164 }
2165
2166 /* AS path loop check. */
2167 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2168 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2169 && aspath_loop_check(attr->aspath, bgp->confed_id)
2170 > peer->allowas_in[afi][safi]))
2171 {
2172 reason = "as-path contains our own AS;";
2173 goto filtered;
2174 }
2175
2176 /* Route reflector originator ID check. */
2177 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00002178 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +00002179 {
2180 reason = "originator is us;";
2181 goto filtered;
2182 }
2183
2184 /* Route reflector cluster ID check. */
2185 if (bgp_cluster_filter (peer, attr))
2186 {
2187 reason = "reflected from the same cluster;";
2188 goto filtered;
2189 }
2190
2191 /* Apply incoming filter. */
2192 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2193 {
2194 reason = "filter;";
2195 goto filtered;
2196 }
2197
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002198 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00002199 bgp_attr_dup (&new_attr, attr);
paul718e3742002-12-13 20:15:29 +00002200
David Lamparterc460e572014-06-04 00:54:58 +02002201 /* Apply incoming route-map.
2202 * NB: new_attr may now contain newly allocated values from route-map "set"
2203 * commands, so we need bgp_attr_flush in the error paths, until we intern
2204 * the attr (which takes over the memory references) */
paul718e3742002-12-13 20:15:29 +00002205 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2206 {
2207 reason = "route-map;";
David Lamparterc460e572014-06-04 00:54:58 +02002208 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002209 goto filtered;
2210 }
2211
2212 /* IPv4 unicast next hop check. */
2213 if (afi == AFI_IP && safi == SAFI_UNICAST)
2214 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04002215 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
paul718e3742002-12-13 20:15:29 +00002216 must not be my own address. */
Jorge Boncompte [DTI2]10f9bf32012-05-07 16:52:52 +00002217 if (new_attr.nexthop.s_addr == 0
2218 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2219 || bgp_nexthop_self (&new_attr))
paul718e3742002-12-13 20:15:29 +00002220 {
2221 reason = "martian next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002222 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002223 goto filtered;
2224 }
2225 }
2226
2227 attr_new = bgp_attr_intern (&new_attr);
2228
2229 /* If the update is implicit withdraw. */
2230 if (ri)
2231 {
Stephen Hemminger65957882010-01-15 16:22:10 +03002232 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002233
2234 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00002235 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2236 && attrhash_cmp (ri->attr, attr_new))
paul718e3742002-12-13 20:15:29 +00002237 {
paul718e3742002-12-13 20:15:29 +00002238 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002239 && peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00002240 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2241 {
2242 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002243 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002244 peer->host,
2245 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2246 p->prefixlen);
2247
paul902212c2006-02-05 17:51:19 +00002248 if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
2249 {
2250 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2251 bgp_process (bgp, rn, afi, safi);
2252 }
paul718e3742002-12-13 20:15:29 +00002253 }
Paul Jakma16d2e242007-04-10 19:32:10 +00002254 else /* Duplicate - odd */
paul718e3742002-12-13 20:15:29 +00002255 {
2256 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002257 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002258 "%s rcvd %s/%d...duplicate ignored",
2259 peer->host,
2260 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2261 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00002262
2263 /* graceful restart STALE flag unset. */
2264 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2265 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002266 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
paul902212c2006-02-05 17:51:19 +00002267 bgp_process (bgp, rn, afi, safi);
hasso93406d82005-02-02 14:40:33 +00002268 }
paul718e3742002-12-13 20:15:29 +00002269 }
2270
2271 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002272 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002273 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002274
paul718e3742002-12-13 20:15:29 +00002275 return 0;
2276 }
2277
Paul Jakma16d2e242007-04-10 19:32:10 +00002278 /* Withdraw/Announce before we fully processed the withdraw */
2279 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2280 {
2281 if (BGP_DEBUG (update, UPDATE_IN))
2282 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
2283 peer->host,
2284 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2285 p->prefixlen);
2286 bgp_info_restore (rn, ri);
2287 }
2288
paul718e3742002-12-13 20:15:29 +00002289 /* Received Logging. */
2290 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002291 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002292 peer->host,
2293 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2294 p->prefixlen);
2295
hasso93406d82005-02-02 14:40:33 +00002296 /* graceful restart STALE flag unset. */
2297 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma1a392d42006-09-07 00:24:49 +00002298 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
hasso93406d82005-02-02 14:40:33 +00002299
paul718e3742002-12-13 20:15:29 +00002300 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002301 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul902212c2006-02-05 17:51:19 +00002302
2303 /* implicit withdraw, decrement aggregate and pcount here.
2304 * only if update is accepted, they'll increment below.
2305 */
paul902212c2006-02-05 17:51:19 +00002306 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2307
paul718e3742002-12-13 20:15:29 +00002308 /* Update bgp route dampening information. */
2309 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002310 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002311 {
2312 /* This is implicit withdraw so we should update dampening
2313 information. */
2314 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2315 bgp_damp_withdraw (ri, rn, afi, safi, 1);
paul718e3742002-12-13 20:15:29 +00002316 }
2317
paul718e3742002-12-13 20:15:29 +00002318 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002319 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00002320 ri->attr = attr_new;
2321
2322 /* Update MPLS tag. */
2323 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002324 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002325
Lou Berger050defe2016-01-12 13:41:59 -05002326 bgp_attr_flush (&new_attr);
2327
paul718e3742002-12-13 20:15:29 +00002328 /* Update bgp route dampening information. */
2329 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002330 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002331 {
2332 /* Now we do normal update dampening. */
2333 ret = bgp_damp_update (ri, rn, afi, safi);
2334 if (ret == BGP_DAMP_SUPPRESSED)
2335 {
2336 bgp_unlock_node (rn);
2337 return 0;
2338 }
2339 }
2340
2341 /* Nexthop reachability check. */
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002342 if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)
paul718e3742002-12-13 20:15:29 +00002343 {
Timo Teräse3443a22016-10-19 16:02:34 +03002344 if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 &&
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002345 ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
2346 connected = 1;
2347 else
2348 connected = 0;
2349
Paul Jakma3dda6b32016-09-06 16:57:40 +01002350 if (bgp_ensure_nexthop (ri, NULL, connected))
Paul Jakma1a392d42006-09-07 00:24:49 +00002351 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002352 else
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002353 {
2354 if (BGP_DEBUG(nht, NHT))
2355 {
2356 char buf1[INET6_ADDRSTRLEN];
2357 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN);
2358 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
2359 }
2360 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
2361 }
paul718e3742002-12-13 20:15:29 +00002362 }
2363 else
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002364 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002365
Lou Berger050defe2016-01-12 13:41:59 -05002366 bgp_attr_flush (&new_attr);
2367
paul718e3742002-12-13 20:15:29 +00002368 /* Process change. */
2369 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2370
2371 bgp_process (bgp, rn, afi, safi);
2372 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002373
paul718e3742002-12-13 20:15:29 +00002374 return 0;
2375 }
2376
2377 /* Received Logging. */
2378 if (BGP_DEBUG (update, UPDATE_IN))
2379 {
ajsd2c1f162004-12-08 21:10:20 +00002380 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002381 peer->host,
2382 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2383 p->prefixlen);
2384 }
2385
paul718e3742002-12-13 20:15:29 +00002386 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05002387 new = info_make(type, sub_type, peer, attr_new, rn);
paul718e3742002-12-13 20:15:29 +00002388
2389 /* Update MPLS tag. */
2390 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002391 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002392
2393 /* Nexthop reachability check. */
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002394 if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)
paul718e3742002-12-13 20:15:29 +00002395 {
Timo Teräse3443a22016-10-19 16:02:34 +03002396 if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 &&
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002397 ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
2398 connected = 1;
2399 else
2400 connected = 0;
2401
Paul Jakma3dda6b32016-09-06 16:57:40 +01002402 if (bgp_ensure_nexthop (new, NULL, connected))
Paul Jakma1a392d42006-09-07 00:24:49 +00002403 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002404 else
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07002405 {
2406 if (BGP_DEBUG(nht, NHT))
2407 {
2408 char buf1[INET6_ADDRSTRLEN];
2409 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN);
2410 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
2411 }
2412 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
2413 }
paul718e3742002-12-13 20:15:29 +00002414 }
2415 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002416 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002417
paul902212c2006-02-05 17:51:19 +00002418 /* Increment prefix */
paul718e3742002-12-13 20:15:29 +00002419 bgp_aggregate_increment (bgp, p, new, afi, safi);
2420
2421 /* Register new BGP information. */
2422 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002423
2424 /* route_node_get lock */
2425 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002426
Lou Berger050defe2016-01-12 13:41:59 -05002427 bgp_attr_flush (&new_attr);
2428
paul718e3742002-12-13 20:15:29 +00002429 /* If maximum prefix count is configured and current prefix
2430 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00002431 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2432 return -1;
paul718e3742002-12-13 20:15:29 +00002433
2434 /* Process change. */
2435 bgp_process (bgp, rn, afi, safi);
2436
2437 return 0;
2438
2439 /* This BGP update is filtered. Log the reason then update BGP
2440 entry. */
2441 filtered:
2442 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002443 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002444 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2445 peer->host,
2446 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2447 p->prefixlen, reason);
2448
2449 if (ri)
paulb40d9392005-08-22 22:34:41 +00002450 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002451
2452 bgp_unlock_node (rn);
Lou Berger050defe2016-01-12 13:41:59 -05002453 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002454
paul718e3742002-12-13 20:15:29 +00002455 return 0;
2456}
2457
2458int
paulfee0f4c2004-09-13 05:12:46 +00002459bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2460 afi_t afi, safi_t safi, int type, int sub_type,
2461 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2462{
2463 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002464 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002465 struct bgp *bgp;
2466 int ret;
2467
2468 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2469 soft_reconfig);
2470
2471 bgp = peer->bgp;
2472
2473 /* Process the update for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002474 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002475 {
2476 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2477 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2478 sub_type, prd, tag);
2479 }
2480
2481 return ret;
2482}
2483
2484int
paul718e3742002-12-13 20:15:29 +00002485bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
paul94f2b392005-06-28 12:44:16 +00002486 afi_t afi, safi_t safi, int type, int sub_type,
2487 struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00002488{
2489 struct bgp *bgp;
2490 char buf[SU_ADDRSTRLEN];
2491 struct bgp_node *rn;
2492 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00002493 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002494 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002495
2496 bgp = peer->bgp;
2497
David Lamparter4584c232015-04-13 09:50:00 +02002498 /* Lookup node. */
2499 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2500
2501 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2502 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2503 * the iteration over all RS clients.
2504 * Since we need to remove the entry from adj_in anyway, do that first and
2505 * if there was no entry, we don't need to do anything more. */
2506 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2507 && peer != bgp->peer_self)
2508 if (!bgp_adj_in_unset (rn, peer))
2509 {
2510 if (BGP_DEBUG (update, UPDATE_IN))
2511 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2512 "not in adj-in", peer->host,
2513 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2514 p->prefixlen);
2515 bgp_unlock_node (rn);
2516 return 0;
2517 }
2518
paulfee0f4c2004-09-13 05:12:46 +00002519 /* Process the withdraw for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002520 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002521 {
2522 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2523 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2524 }
2525
paul718e3742002-12-13 20:15:29 +00002526 /* Logging. */
2527 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002528 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002529 peer->host,
2530 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2531 p->prefixlen);
2532
paul718e3742002-12-13 20:15:29 +00002533 /* Lookup withdrawn route. */
2534 for (ri = rn->info; ri; ri = ri->next)
2535 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2536 break;
2537
2538 /* Withdraw specified route from routing table. */
2539 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002540 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paul718e3742002-12-13 20:15:29 +00002541 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002542 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002543 "%s Can't find the route %s/%d", peer->host,
2544 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2545 p->prefixlen);
2546
2547 /* Unlock bgp_node_get() lock. */
2548 bgp_unlock_node (rn);
2549
2550 return 0;
2551}
David Lamparter6b0655a2014-06-04 06:53:35 +02002552
paul718e3742002-12-13 20:15:29 +00002553void
2554bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2555{
2556 struct bgp *bgp;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00002557 struct attr attr;
Jorge Boncompte [DTI2]577ac572012-05-07 16:53:06 +00002558 struct aspath *aspath;
paul718e3742002-12-13 20:15:29 +00002559 struct prefix p;
paul718e3742002-12-13 20:15:29 +00002560 struct peer *from;
Christian Frankedcab1bb2012-12-07 16:45:52 +00002561 struct bgp_node *rn;
2562 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00002563 int ret = RMAP_DENYMATCH;
Paul Jakmafb982c22007-05-04 20:15:47 +00002564
Paul Jakmab2497022007-06-14 11:17:58 +00002565 if (!(afi == AFI_IP || afi == AFI_IP6))
Paul Jakmafb982c22007-05-04 20:15:47 +00002566 return;
2567
paul718e3742002-12-13 20:15:29 +00002568 bgp = peer->bgp;
2569 from = bgp->peer_self;
Paul Jakmafb982c22007-05-04 20:15:47 +00002570
paul718e3742002-12-13 20:15:29 +00002571 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2572 aspath = attr.aspath;
2573 attr.local_pref = bgp->default_local_pref;
2574 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2575
2576 if (afi == AFI_IP)
2577 str2prefix ("0.0.0.0/0", &p);
paul718e3742002-12-13 20:15:29 +00002578 else if (afi == AFI_IP6)
2579 {
Jorge Boncompte [DTI2]6182d652012-05-07 16:53:02 +00002580 struct attr_extra *ae = attr.extra;
2581
paul718e3742002-12-13 20:15:29 +00002582 str2prefix ("::/0", &p);
2583
2584 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00002585 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00002586 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002587 ae->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00002588
2589 /* If the peer is on shared nextwork and we have link-local
2590 nexthop set it. */
2591 if (peer->shared_network
2592 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2593 {
Paul Jakmafb982c22007-05-04 20:15:47 +00002594 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00002595 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002596 ae->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00002597 }
2598 }
paul718e3742002-12-13 20:15:29 +00002599
2600 if (peer->default_rmap[afi][safi].name)
2601 {
paulfee0f4c2004-09-13 05:12:46 +00002602 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
Christian Frankedcab1bb2012-12-07 16:45:52 +00002603 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2604 {
2605 for (ri = rn->info; ri; ri = ri->next)
2606 {
2607 struct attr dummy_attr;
2608 struct attr_extra dummy_extra;
2609 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00002610
Christian Frankedcab1bb2012-12-07 16:45:52 +00002611 /* Provide dummy so the route-map can't modify the attributes */
2612 dummy_attr.extra = &dummy_extra;
2613 bgp_attr_dup(&dummy_attr, ri->attr);
2614 info.peer = ri->peer;
2615 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00002616
Christian Frankedcab1bb2012-12-07 16:45:52 +00002617 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2618 RMAP_BGP, &info);
2619
2620 /* The route map might have set attributes. If we don't flush them
2621 * here, they will be leaked. */
2622 bgp_attr_flush(&dummy_attr);
2623 if (ret != RMAP_DENYMATCH)
2624 break;
2625 }
2626 if (ret != RMAP_DENYMATCH)
2627 break;
2628 }
paulfee0f4c2004-09-13 05:12:46 +00002629 bgp->peer_self->rmap_type = 0;
2630
paul718e3742002-12-13 20:15:29 +00002631 if (ret == RMAP_DENYMATCH)
Christian Frankedcab1bb2012-12-07 16:45:52 +00002632 withdraw = 1;
paul718e3742002-12-13 20:15:29 +00002633 }
2634
2635 if (withdraw)
2636 {
2637 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2638 bgp_default_withdraw_send (peer, afi, safi);
2639 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2640 }
2641 else
2642 {
Christian Frankedcab1bb2012-12-07 16:45:52 +00002643 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2644 {
2645 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2646 bgp_default_update_send (peer, &attr, afi, safi, from);
2647 }
paul718e3742002-12-13 20:15:29 +00002648 }
Paul Jakmafb982c22007-05-04 20:15:47 +00002649
2650 bgp_attr_extra_free (&attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002651 aspath_unintern (&aspath);
paul718e3742002-12-13 20:15:29 +00002652}
David Lamparter6b0655a2014-06-04 06:53:35 +02002653
paul718e3742002-12-13 20:15:29 +00002654static void
2655bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002656 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002657{
2658 struct bgp_node *rn;
2659 struct bgp_info *ri;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002660 struct attr attr;
2661 struct attr_extra extra;
2662
Lou Berger298cc2f2016-01-12 13:42:02 -05002663 memset(&extra, 0, sizeof(extra));
2664
paul718e3742002-12-13 20:15:29 +00002665 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002666 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002667
Lou Berger298cc2f2016-01-12 13:42:02 -05002668 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00002669 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2670 bgp_default_originate (peer, afi, safi, 0);
2671
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002672 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2673 attr.extra = &extra;
2674
paul718e3742002-12-13 20:15:29 +00002675 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2676 for (ri = rn->info; ri; ri = ri->next)
2677 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2678 {
paulfee0f4c2004-09-13 05:12:46 +00002679 if ( (rsclient) ?
2680 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2681 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002682 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2683 else
2684 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2685 }
Lou Berger298cc2f2016-01-12 13:42:02 -05002686
2687 bgp_attr_flush_encap(&attr);
paul718e3742002-12-13 20:15:29 +00002688}
2689
2690void
2691bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2692{
2693 struct bgp_node *rn;
2694 struct bgp_table *table;
2695
2696 if (peer->status != Established)
2697 return;
2698
2699 if (! peer->afc_nego[afi][safi])
2700 return;
2701
2702 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2703 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2704 return;
2705
Lou Berger298cc2f2016-01-12 13:42:02 -05002706 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
paulfee0f4c2004-09-13 05:12:46 +00002707 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002708 else
2709 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2710 rn = bgp_route_next(rn))
2711 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002712 bgp_announce_table (peer, afi, safi, table, 0);
2713
2714 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2715 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002716}
2717
2718void
2719bgp_announce_route_all (struct peer *peer)
2720{
2721 afi_t afi;
2722 safi_t safi;
2723
2724 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2725 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2726 bgp_announce_route (peer, afi, safi);
2727}
David Lamparter6b0655a2014-06-04 06:53:35 +02002728
paul718e3742002-12-13 20:15:29 +00002729static void
paulfee0f4c2004-09-13 05:12:46 +00002730bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002731 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
paulfee0f4c2004-09-13 05:12:46 +00002732{
2733 struct bgp_node *rn;
2734 struct bgp_adj_in *ain;
2735
2736 if (! table)
2737 table = rsclient->bgp->rib[afi][safi];
2738
2739 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2740 for (ain = rn->adj_in; ain; ain = ain->next)
2741 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002742 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002743 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002744
paulfee0f4c2004-09-13 05:12:46 +00002745 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
Christian Franked53d8fd2013-01-28 07:14:43 +01002746 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
paulfee0f4c2004-09-13 05:12:46 +00002747 }
2748}
2749
2750void
2751bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2752{
2753 struct bgp_table *table;
2754 struct bgp_node *rn;
2755
Lou Berger298cc2f2016-01-12 13:42:02 -05002756 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002757 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
paulfee0f4c2004-09-13 05:12:46 +00002758
2759 else
2760 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2761 rn = bgp_route_next (rn))
2762 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002763 {
2764 struct prefix_rd prd;
2765 prd.family = AF_UNSPEC;
2766 prd.prefixlen = 64;
2767 memcpy(&prd.val, rn->p.u.val, 8);
2768
2769 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2770 }
paulfee0f4c2004-09-13 05:12:46 +00002771}
David Lamparter6b0655a2014-06-04 06:53:35 +02002772
paulfee0f4c2004-09-13 05:12:46 +00002773static void
paul718e3742002-12-13 20:15:29 +00002774bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002775 struct bgp_table *table, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00002776{
2777 int ret;
2778 struct bgp_node *rn;
2779 struct bgp_adj_in *ain;
2780
2781 if (! table)
2782 table = peer->bgp->rib[afi][safi];
2783
2784 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2785 for (ain = rn->adj_in; ain; ain = ain->next)
2786 {
2787 if (ain->peer == peer)
2788 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002789 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002790 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002791
paul718e3742002-12-13 20:15:29 +00002792 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2793 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
Christian Franked53d8fd2013-01-28 07:14:43 +01002794 prd, tag, 1);
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002795
paul718e3742002-12-13 20:15:29 +00002796 if (ret < 0)
2797 {
2798 bgp_unlock_node (rn);
2799 return;
2800 }
2801 continue;
2802 }
2803 }
2804}
2805
2806void
2807bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2808{
2809 struct bgp_node *rn;
2810 struct bgp_table *table;
2811
2812 if (peer->status != Established)
2813 return;
2814
Lou Berger298cc2f2016-01-12 13:42:02 -05002815 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002816 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002817 else
2818 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2819 rn = bgp_route_next (rn))
2820 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002821 {
2822 struct prefix_rd prd;
2823 prd.family = AF_UNSPEC;
2824 prd.prefixlen = 64;
2825 memcpy(&prd.val, rn->p.u.val, 8);
2826
2827 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2828 }
paul718e3742002-12-13 20:15:29 +00002829}
David Lamparter6b0655a2014-06-04 06:53:35 +02002830
Chris Caputo228da422009-07-18 05:44:03 +00002831
2832struct bgp_clear_node_queue
2833{
2834 struct bgp_node *rn;
2835 enum bgp_clear_route_type purpose;
2836};
2837
paul200df112005-06-01 11:17:05 +00002838static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00002839bgp_clear_route_node (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002840{
Chris Caputo228da422009-07-18 05:44:03 +00002841 struct bgp_clear_node_queue *cnq = data;
2842 struct bgp_node *rn = cnq->rn;
Paul Jakma64e580a2006-02-21 01:09:01 +00002843 struct peer *peer = wq->spec.data;
paul200df112005-06-01 11:17:05 +00002844 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002845 afi_t afi = bgp_node_table (rn)->afi;
2846 safi_t safi = bgp_node_table (rn)->safi;
paul200df112005-06-01 11:17:05 +00002847
Paul Jakma64e580a2006-02-21 01:09:01 +00002848 assert (rn && peer);
paul200df112005-06-01 11:17:05 +00002849
Paul Jakma64e580a2006-02-21 01:09:01 +00002850 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002851 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
paul200df112005-06-01 11:17:05 +00002852 {
2853 /* graceful restart STALE flag set. */
Paul Jakma64e580a2006-02-21 01:09:01 +00002854 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2855 && peer->nsf[afi][safi]
paul200df112005-06-01 11:17:05 +00002856 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
Paul Jakma1a392d42006-09-07 00:24:49 +00002857 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2858 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
paul200df112005-06-01 11:17:05 +00002859 else
Paul Jakma64e580a2006-02-21 01:09:01 +00002860 bgp_rib_remove (rn, ri, peer, afi, safi);
paul200df112005-06-01 11:17:05 +00002861 break;
2862 }
paul200df112005-06-01 11:17:05 +00002863 return WQ_SUCCESS;
2864}
2865
2866static void
paul0fb58d52005-11-14 14:31:49 +00002867bgp_clear_node_queue_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002868{
Chris Caputo228da422009-07-18 05:44:03 +00002869 struct bgp_clear_node_queue *cnq = data;
2870 struct bgp_node *rn = cnq->rn;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002871 struct bgp_table *table = bgp_node_table (rn);
Paul Jakma64e580a2006-02-21 01:09:01 +00002872
2873 bgp_unlock_node (rn);
Chris Caputo228da422009-07-18 05:44:03 +00002874 bgp_table_unlock (table);
2875 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
paul200df112005-06-01 11:17:05 +00002876}
2877
2878static void
paul94f2b392005-06-28 12:44:16 +00002879bgp_clear_node_complete (struct work_queue *wq)
paul200df112005-06-01 11:17:05 +00002880{
Paul Jakma64e580a2006-02-21 01:09:01 +00002881 struct peer *peer = wq->spec.data;
2882
Paul Jakma3e0c78e2006-03-06 18:06:53 +00002883 /* Tickle FSM to start moving again */
Paul Jakmaca058a32006-09-14 02:58:49 +00002884 BGP_EVENT_ADD (peer, Clearing_Completed);
Chris Caputo228da422009-07-18 05:44:03 +00002885
2886 peer_unlock (peer); /* bgp_clear_route */
paul200df112005-06-01 11:17:05 +00002887}
2888
2889static void
Paul Jakma64e580a2006-02-21 01:09:01 +00002890bgp_clear_node_queue_init (struct peer *peer)
paul200df112005-06-01 11:17:05 +00002891{
Paul Jakmaa2943652009-07-21 14:02:04 +01002892 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
Paul Jakma64e580a2006-02-21 01:09:01 +00002893
Paul Jakmaa2943652009-07-21 14:02:04 +01002894 snprintf (wname, sizeof(wname), "clear %s", peer->host);
Paul Jakma64e580a2006-02-21 01:09:01 +00002895#undef CLEAR_QUEUE_NAME_LEN
2896
2897 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
paul200df112005-06-01 11:17:05 +00002898 {
2899 zlog_err ("%s: Failed to allocate work queue", __func__);
2900 exit (1);
2901 }
Paul Jakma64e580a2006-02-21 01:09:01 +00002902 peer->clear_node_queue->spec.hold = 10;
2903 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2904 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2905 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2906 peer->clear_node_queue->spec.max_retries = 0;
2907
2908 /* we only 'lock' this peer reference when the queue is actually active */
2909 peer->clear_node_queue->spec.data = peer;
paul200df112005-06-01 11:17:05 +00002910}
2911
paul718e3742002-12-13 20:15:29 +00002912static void
2913bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
Chris Caputo228da422009-07-18 05:44:03 +00002914 struct bgp_table *table, struct peer *rsclient,
2915 enum bgp_clear_route_type purpose)
paul718e3742002-12-13 20:15:29 +00002916{
2917 struct bgp_node *rn;
paul200df112005-06-01 11:17:05 +00002918
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002919
paul718e3742002-12-13 20:15:29 +00002920 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002921 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
Paul Jakma64e580a2006-02-21 01:09:01 +00002922
hasso6cf159b2005-03-21 10:28:14 +00002923 /* If still no table => afi/safi isn't configured at all or smth. */
2924 if (! table)
2925 return;
Paul Jakma65ca75e2006-05-04 08:08:15 +00002926
2927 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2928 {
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002929 struct bgp_info *ri;
2930 struct bgp_adj_in *ain;
2931 struct bgp_adj_out *aout;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002932
2933 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2934 * queued for every clearing peer, regardless of whether it is
2935 * relevant to the peer at hand.
2936 *
2937 * Overview: There are 3 different indices which need to be
2938 * scrubbed, potentially, when a peer is removed:
2939 *
2940 * 1 peer's routes visible via the RIB (ie accepted routes)
2941 * 2 peer's routes visible by the (optional) peer's adj-in index
2942 * 3 other routes visible by the peer's adj-out index
2943 *
2944 * 3 there is no hurry in scrubbing, once the struct peer is
2945 * removed from bgp->peer, we could just GC such deleted peer's
2946 * adj-outs at our leisure.
2947 *
2948 * 1 and 2 must be 'scrubbed' in some way, at least made
2949 * invisible via RIB index before peer session is allowed to be
2950 * brought back up. So one needs to know when such a 'search' is
2951 * complete.
2952 *
2953 * Ideally:
2954 *
2955 * - there'd be a single global queue or a single RIB walker
2956 * - rather than tracking which route_nodes still need to be
2957 * examined on a peer basis, we'd track which peers still
2958 * aren't cleared
2959 *
2960 * Given that our per-peer prefix-counts now should be reliable,
2961 * this may actually be achievable. It doesn't seem to be a huge
2962 * problem at this time,
2963 */
Jorge Boncompte [DTI2]24e50f22012-05-07 15:17:33 +00002964 for (ain = rn->adj_in; ain; ain = ain->next)
2965 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2966 {
2967 bgp_adj_in_remove (rn, ain);
2968 bgp_unlock_node (rn);
2969 break;
2970 }
2971 for (aout = rn->adj_out; aout; aout = aout->next)
2972 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2973 {
2974 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2975 bgp_unlock_node (rn);
2976 break;
2977 }
2978
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002979 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002980 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002981 {
Chris Caputo228da422009-07-18 05:44:03 +00002982 struct bgp_clear_node_queue *cnq;
2983
2984 /* both unlocked in bgp_clear_node_queue_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07002985 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00002986 bgp_lock_node (rn);
2987 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2988 sizeof (struct bgp_clear_node_queue));
2989 cnq->rn = rn;
2990 cnq->purpose = purpose;
2991 work_queue_add (peer->clear_node_queue, cnq);
2992 break;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002993 }
Paul Jakma65ca75e2006-05-04 08:08:15 +00002994 }
2995 return;
2996}
2997
2998void
Chris Caputo228da422009-07-18 05:44:03 +00002999bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
3000 enum bgp_clear_route_type purpose)
Paul Jakma65ca75e2006-05-04 08:08:15 +00003001{
3002 struct bgp_node *rn;
3003 struct bgp_table *table;
3004 struct peer *rsclient;
3005 struct listnode *node, *nnode;
hasso6cf159b2005-03-21 10:28:14 +00003006
Paul Jakma64e580a2006-02-21 01:09:01 +00003007 if (peer->clear_node_queue == NULL)
3008 bgp_clear_node_queue_init (peer);
paul200df112005-06-01 11:17:05 +00003009
Paul Jakmaca058a32006-09-14 02:58:49 +00003010 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3011 * Idle until it receives a Clearing_Completed event. This protects
3012 * against peers which flap faster than we can we clear, which could
3013 * lead to:
Paul Jakma64e580a2006-02-21 01:09:01 +00003014 *
3015 * a) race with routes from the new session being installed before
3016 * clear_route_node visits the node (to delete the route of that
3017 * peer)
3018 * b) resource exhaustion, clear_route_node likely leads to an entry
3019 * on the process_main queue. Fast-flapping could cause that queue
3020 * to grow and grow.
paul200df112005-06-01 11:17:05 +00003021 */
Donald Sharp7ef42212015-03-30 06:32:52 -07003022
3023 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3024 * the unlock will happen upon work-queue completion; other wise, the
3025 * unlock happens at the end of this function.
3026 */
Paul Jakmaca058a32006-09-14 02:58:49 +00003027 if (!peer->clear_node_queue->thread)
Lou Berger050defe2016-01-12 13:41:59 -05003028 peer_lock (peer); /* bgp_clear_node_complete */
Chris Caputo228da422009-07-18 05:44:03 +00003029 switch (purpose)
paulfee0f4c2004-09-13 05:12:46 +00003030 {
Chris Caputo228da422009-07-18 05:44:03 +00003031 case BGP_CLEAR_ROUTE_NORMAL:
Lou Berger298cc2f2016-01-12 13:42:02 -05003032 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Chris Caputo228da422009-07-18 05:44:03 +00003033 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3034 else
3035 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3036 rn = bgp_route_next (rn))
3037 if ((table = rn->info) != NULL)
3038 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3039
3040 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3041 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3042 PEER_FLAG_RSERVER_CLIENT))
3043 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3044 break;
3045
3046 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
Lou Berger050defe2016-01-12 13:41:59 -05003047 /*
3048 * gpz 091009: TBD why don't we have special handling for
3049 * SAFI_MPLS_VPN here in the original quagga code?
3050 * (and, by extension, for SAFI_ENCAP)
3051 */
Chris Caputo228da422009-07-18 05:44:03 +00003052 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3053 break;
3054
3055 default:
3056 assert (0);
3057 break;
paulfee0f4c2004-09-13 05:12:46 +00003058 }
Donald Sharp7ef42212015-03-30 06:32:52 -07003059
3060 /* unlock if no nodes got added to the clear-node-queue. */
Paul Jakma65ca75e2006-05-04 08:08:15 +00003061 if (!peer->clear_node_queue->thread)
Donald Sharp7ef42212015-03-30 06:32:52 -07003062 peer_unlock (peer);
3063
paul718e3742002-12-13 20:15:29 +00003064}
3065
3066void
3067bgp_clear_route_all (struct peer *peer)
3068{
3069 afi_t afi;
3070 safi_t safi;
3071
3072 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3073 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
Chris Caputo228da422009-07-18 05:44:03 +00003074 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
paul718e3742002-12-13 20:15:29 +00003075}
3076
Lou Berger82dd7072016-01-12 13:41:57 -05003077/*
3078 * Finish freeing things when exiting
3079 */
3080static void
3081bgp_drain_workqueue_immediate (struct work_queue *wq)
3082{
3083 if (!wq)
3084 return;
3085
3086 if (!wq->thread)
3087 {
3088 /*
3089 * no thread implies no queued items
3090 */
3091 assert(!wq->items->count);
3092 return;
3093 }
3094
3095 while (wq->items->count)
3096 {
3097 if (wq->thread)
3098 thread_cancel(wq->thread);
3099 work_queue_run(wq->thread);
3100 }
3101}
3102
3103/*
3104 * Special function to process clear node queue when bgpd is exiting
3105 * and the thread scheduler is no longer running.
3106 */
3107void
3108bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3109{
3110 if (!peer)
3111 return;
3112
3113 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3114}
3115
3116/*
3117 * The work queues are not specific to a BGP instance, but the
3118 * items in them refer to BGP instances, so this should be called
3119 * before each BGP instance is deleted.
3120 */
3121void
3122bgp_process_queues_drain_immediate(void)
3123{
3124 bgp_drain_workqueue_immediate(bm->process_main_queue);
3125 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3126}
3127
paul718e3742002-12-13 20:15:29 +00003128void
3129bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3130{
3131 struct bgp_table *table;
3132 struct bgp_node *rn;
3133 struct bgp_adj_in *ain;
3134
3135 table = peer->bgp->rib[afi][safi];
3136
3137 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3138 for (ain = rn->adj_in; ain ; ain = ain->next)
3139 if (ain->peer == peer)
3140 {
3141 bgp_adj_in_remove (rn, ain);
3142 bgp_unlock_node (rn);
3143 break;
3144 }
3145}
hasso93406d82005-02-02 14:40:33 +00003146
3147void
3148bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3149{
3150 struct bgp_node *rn;
3151 struct bgp_info *ri;
3152 struct bgp_table *table;
3153
3154 table = peer->bgp->rib[afi][safi];
3155
3156 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3157 {
3158 for (ri = rn->info; ri; ri = ri->next)
3159 if (ri->peer == peer)
3160 {
3161 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3162 bgp_rib_remove (rn, ri, peer, afi, safi);
3163 break;
3164 }
3165 }
3166}
David Lamparter6b0655a2014-06-04 06:53:35 +02003167
Lou Berger82dd7072016-01-12 13:41:57 -05003168static void
3169bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3170{
3171 struct bgp_node *rn;
3172 struct bgp_info *ri;
3173 struct bgp_info *next;
3174
3175 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3176 for (ri = rn->info; ri; ri = next)
3177 {
3178 next = ri->next;
3179 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3180 && ri->type == ZEBRA_ROUTE_BGP
3181 && ri->sub_type == BGP_ROUTE_NORMAL)
3182 bgp_zebra_withdraw (&rn->p, ri, safi);
3183 }
3184}
3185
paul718e3742002-12-13 20:15:29 +00003186/* Delete all kernel routes. */
3187void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003188bgp_cleanup_routes (void)
paul718e3742002-12-13 20:15:29 +00003189{
3190 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00003191 struct listnode *node, *nnode;
Lou Berger82dd7072016-01-12 13:41:57 -05003192 afi_t afi;
paul718e3742002-12-13 20:15:29 +00003193
paul1eb8ef22005-04-07 07:30:20 +00003194 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00003195 {
Lou Berger82dd7072016-01-12 13:41:57 -05003196 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3197 {
3198 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00003199
Lou Berger82dd7072016-01-12 13:41:57 -05003200 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00003201
Lou Berger82dd7072016-01-12 13:41:57 -05003202 /*
3203 * VPN and ENCAP tables are two-level (RD is top level)
3204 */
3205 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3206 rn = bgp_route_next (rn))
Lou Berger298cc2f2016-01-12 13:42:02 -05003207 {
3208 if (rn->info)
Lou Berger82dd7072016-01-12 13:41:57 -05003209 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003210 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3211 bgp_table_finish ((struct bgp_table **)&(rn->info));
3212 rn->info = NULL;
3213 bgp_unlock_node(rn);
Lou Berger82dd7072016-01-12 13:41:57 -05003214 }
Lou Berger298cc2f2016-01-12 13:42:02 -05003215 }
3216
3217 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3218 rn = bgp_route_next (rn))
3219 {
3220 if (rn->info)
3221 {
3222 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3223 bgp_table_finish ((struct bgp_table **)&(rn->info));
3224 rn->info = NULL;
3225 bgp_unlock_node(rn);
3226 }
3227 }
Lou Berger82dd7072016-01-12 13:41:57 -05003228 }
paul718e3742002-12-13 20:15:29 +00003229 }
3230}
3231
3232void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003233bgp_reset (void)
paul718e3742002-12-13 20:15:29 +00003234{
3235 vty_reset ();
3236 bgp_zclient_reset ();
3237 access_list_reset ();
3238 prefix_list_reset ();
3239}
David Lamparter6b0655a2014-06-04 06:53:35 +02003240
paul718e3742002-12-13 20:15:29 +00003241/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3242 value. */
3243int
Paul Jakma518a4b72016-02-04 13:27:04 +00003244bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
3245 struct bgp_nlri *packet)
paul718e3742002-12-13 20:15:29 +00003246{
3247 u_char *pnt;
3248 u_char *lim;
3249 struct prefix p;
3250 int psize;
3251 int ret;
3252
3253 /* Check peer status. */
3254 if (peer->status != Established)
3255 return 0;
3256
3257 pnt = packet->nlri;
3258 lim = pnt + packet->length;
3259
Paul Jakma405e9e12016-02-04 17:00:18 +00003260 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3261 syntactic validity. If the field is syntactically incorrect,
3262 then the Error Subcode is set to Invalid Network Field. */
paul718e3742002-12-13 20:15:29 +00003263 for (; pnt < lim; pnt += psize)
3264 {
3265 /* Clear prefix structure. */
3266 memset (&p, 0, sizeof (struct prefix));
3267
3268 /* Fetch prefix length. */
3269 p.prefixlen = *pnt++;
Paul Jakma405e9e12016-02-04 17:00:18 +00003270 /* afi/safi validity already verified by caller, bgp_update_receive */
paul718e3742002-12-13 20:15:29 +00003271 p.family = afi2family (packet->afi);
3272
Paul Jakma405e9e12016-02-04 17:00:18 +00003273 /* Prefix length check. */
3274 if (p.prefixlen > prefix_blen (&p) * 8)
3275 {
3276 plog_err (peer->log,
3277 "%s [Error] Update packet error"
3278 " (wrong prefix length %u for afi %u)",
3279 peer->host, p.prefixlen, packet->afi);
3280 return -1;
3281 }
3282
paul718e3742002-12-13 20:15:29 +00003283 /* Packet size overflow check. */
3284 psize = PSIZE (p.prefixlen);
3285
3286 /* When packet overflow occur return immediately. */
3287 if (pnt + psize > lim)
Paul Jakma405e9e12016-02-04 17:00:18 +00003288 {
3289 plog_err (peer->log,
3290 "%s [Error] Update packet error"
3291 " (prefix length %u overflows packet)",
3292 peer->host, p.prefixlen);
3293 return -1;
3294 }
3295
3296 /* Defensive coding, double-check the psize fits in a struct prefix */
3297 if (psize > (ssize_t) sizeof(p.u))
3298 {
3299 plog_err (peer->log,
3300 "%s [Error] Update packet error"
3301 " (prefix length %u too large for prefix storage %zu!?!!",
3302 peer->host, p.prefixlen, sizeof(p.u));
3303 return -1;
3304 }
paul718e3742002-12-13 20:15:29 +00003305
3306 /* Fetch prefix from NLRI packet. */
3307 memcpy (&p.u.prefix, pnt, psize);
3308
3309 /* Check address. */
3310 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3311 {
3312 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3313 {
paulf5ba3872004-07-09 12:11:31 +00003314 /*
Paul Jakma405e9e12016-02-04 17:00:18 +00003315 * From RFC4271 Section 6.3:
3316 *
3317 * If a prefix in the NLRI field is semantically incorrect
3318 * (e.g., an unexpected multicast IP address), an error SHOULD
3319 * be logged locally, and the prefix SHOULD be ignored.
paulf5ba3872004-07-09 12:11:31 +00003320 */
paul718e3742002-12-13 20:15:29 +00003321 zlog (peer->log, LOG_ERR,
Paul Jakma405e9e12016-02-04 17:00:18 +00003322 "%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3323 peer->host, inet_ntoa (p.u.prefix4));
3324 continue;
paul718e3742002-12-13 20:15:29 +00003325 }
3326 }
3327
paul718e3742002-12-13 20:15:29 +00003328 /* Check address. */
3329 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3330 {
3331 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3332 {
3333 char buf[BUFSIZ];
3334
Paul Jakma405e9e12016-02-04 17:00:18 +00003335 zlog (peer->log, LOG_ERR,
3336 "%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3337 peer->host,
paul718e3742002-12-13 20:15:29 +00003338 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00003339 continue;
3340 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003341 if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6))
3342 {
3343 char buf[BUFSIZ];
3344
3345 zlog (peer->log, LOG_ERR,
3346 "%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3347 peer->host,
3348 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3349 continue;
3350 }
3351 }
paul718e3742002-12-13 20:15:29 +00003352
3353 /* Normal process. */
3354 if (attr)
3355 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3356 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3357 else
3358 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3359 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3360
3361 /* Address family configuration mismatch or maximum-prefix count
3362 overflow. */
3363 if (ret < 0)
3364 return -1;
3365 }
3366
3367 /* Packet length consistency check. */
3368 if (pnt != lim)
paul718e3742002-12-13 20:15:29 +00003369 {
3370 plog_err (peer->log,
Paul Jakma405e9e12016-02-04 17:00:18 +00003371 "%s [Error] Update packet error"
3372 " (prefix length mismatch with total length)",
3373 peer->host);
paul718e3742002-12-13 20:15:29 +00003374 return -1;
3375 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003376
paul718e3742002-12-13 20:15:29 +00003377 return 0;
3378}
David Lamparter6b0655a2014-06-04 06:53:35 +02003379
paul94f2b392005-06-28 12:44:16 +00003380static struct bgp_static *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003381bgp_static_new (void)
paul718e3742002-12-13 20:15:29 +00003382{
Stephen Hemminger393deb92008-08-18 14:13:29 -07003383 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
paul718e3742002-12-13 20:15:29 +00003384}
3385
paul94f2b392005-06-28 12:44:16 +00003386static void
paul718e3742002-12-13 20:15:29 +00003387bgp_static_free (struct bgp_static *bgp_static)
3388{
3389 if (bgp_static->rmap.name)
3390 free (bgp_static->rmap.name);
3391 XFREE (MTYPE_BGP_STATIC, bgp_static);
3392}
3393
paul94f2b392005-06-28 12:44:16 +00003394static void
paulfee0f4c2004-09-13 05:12:46 +00003395bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3396 struct prefix *p, afi_t afi, safi_t safi)
3397{
3398 struct bgp_node *rn;
3399 struct bgp_info *ri;
3400
3401 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3402
3403 /* Check selected route and self inserted route. */
3404 for (ri = rn->info; ri; ri = ri->next)
3405 if (ri->peer == bgp->peer_self
3406 && ri->type == ZEBRA_ROUTE_BGP
3407 && ri->sub_type == BGP_ROUTE_STATIC)
3408 break;
3409
3410 /* Withdraw static BGP route from routing table. */
3411 if (ri)
3412 {
paulfee0f4c2004-09-13 05:12:46 +00003413 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003414 bgp_process (bgp, rn, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003415 }
3416
3417 /* Unlock bgp_node_lookup. */
3418 bgp_unlock_node (rn);
3419}
3420
paul94f2b392005-06-28 12:44:16 +00003421static void
paulfee0f4c2004-09-13 05:12:46 +00003422bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
Paul Jakmafb982c22007-05-04 20:15:47 +00003423 struct bgp_static *bgp_static,
3424 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00003425{
3426 struct bgp_node *rn;
3427 struct bgp_info *ri;
3428 struct bgp_info *new;
3429 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00003430 struct attr *attr_new;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003431 struct attr attr;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003432 struct attr new_attr;
3433 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00003434 struct bgp *bgp;
3435 int ret;
3436 char buf[SU_ADDRSTRLEN];
3437
3438 bgp = rsclient->bgp;
3439
Paul Jakma06e110f2006-05-12 23:29:22 +00003440 assert (bgp_static);
3441 if (!bgp_static)
3442 return;
3443
paulfee0f4c2004-09-13 05:12:46 +00003444 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3445
3446 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakma06e110f2006-05-12 23:29:22 +00003447
3448 attr.nexthop = bgp_static->igpnexthop;
3449 attr.med = bgp_static->igpmetric;
3450 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Paul Jakma41367172007-08-06 15:24:51 +00003451
Paul Jakma41367172007-08-06 15:24:51 +00003452 if (bgp_static->atomic)
3453 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3454
paulfee0f4c2004-09-13 05:12:46 +00003455 /* Apply network route-map for export to this rsclient. */
3456 if (bgp_static->rmap.name)
3457 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003458 struct attr attr_tmp = attr;
paulfee0f4c2004-09-13 05:12:46 +00003459 info.peer = rsclient;
Paul Jakmafb982c22007-05-04 20:15:47 +00003460 info.attr = &attr_tmp;
3461
paulfee0f4c2004-09-13 05:12:46 +00003462 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3463 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3464
3465 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3466
3467 rsclient->rmap_type = 0;
3468
3469 if (ret == RMAP_DENYMATCH)
3470 {
3471 /* Free uninterned attribute. */
Paul Jakmafb982c22007-05-04 20:15:47 +00003472 bgp_attr_flush (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003473
3474 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003475 aspath_unintern (&attr.aspath);
paulfee0f4c2004-09-13 05:12:46 +00003476 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
Paul Jakmafb982c22007-05-04 20:15:47 +00003477 bgp_attr_extra_free (&attr);
3478
paulfee0f4c2004-09-13 05:12:46 +00003479 return;
3480 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003481 attr_new = bgp_attr_intern (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003482 }
3483 else
3484 attr_new = bgp_attr_intern (&attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003485
3486 new_attr.extra = &new_extra;
Stephen Hemminger7badc262010-08-05 10:26:31 -07003487 bgp_attr_dup(&new_attr, attr_new);
Paul Jakmafb982c22007-05-04 20:15:47 +00003488
paulfee0f4c2004-09-13 05:12:46 +00003489 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3490
Paul Jakmafb982c22007-05-04 20:15:47 +00003491 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3492 == RMAP_DENY)
3493 {
paulfee0f4c2004-09-13 05:12:46 +00003494 /* This BGP update is filtered. Log the reason then update BGP entry. */
3495 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00003496 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00003497 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3498 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3499 p->prefixlen, rsclient->host);
3500
3501 bgp->peer_self->rmap_type = 0;
3502
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003503 bgp_attr_unintern (&attr_new);
3504 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003505 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003506
3507 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3508
3509 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003510 }
paulfee0f4c2004-09-13 05:12:46 +00003511
3512 bgp->peer_self->rmap_type = 0;
3513
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003514 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00003515 attr_new = bgp_attr_intern (&new_attr);
3516
3517 for (ri = rn->info; ri; ri = ri->next)
3518 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3519 && ri->sub_type == BGP_ROUTE_STATIC)
3520 break;
3521
3522 if (ri)
3523 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003524 if (attrhash_cmp (ri->attr, attr_new) &&
3525 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paulfee0f4c2004-09-13 05:12:46 +00003526 {
3527 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003528 bgp_attr_unintern (&attr_new);
3529 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003530 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003531 return;
3532 }
3533 else
3534 {
3535 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003536 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00003537
3538 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003539 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3540 bgp_info_restore(rn, ri);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003541 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00003542 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003543 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003544
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003545 /* Nexthop reachability check. */
3546 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3547 {
Paul Jakma3dda6b32016-09-06 16:57:40 +01003548 if (bgp_ensure_nexthop (ri, NULL, 0))
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003549 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
3550 else
3551 {
3552 if (BGP_DEBUG(nht, NHT))
3553 {
3554 char buf1[INET6_ADDRSTRLEN];
3555 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3556 buf1, INET6_ADDRSTRLEN);
3557 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3558 }
3559 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
3560 }
3561 }
paulfee0f4c2004-09-13 05:12:46 +00003562 /* Process change. */
3563 bgp_process (bgp, rn, afi, safi);
3564 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003565 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003566 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003567 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003568 }
paulfee0f4c2004-09-13 05:12:46 +00003569 }
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003570
paulfee0f4c2004-09-13 05:12:46 +00003571 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003572 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
3573 attr_new, rn);
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003574 /* Nexthop reachability check. */
3575 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3576 {
Paul Jakma3dda6b32016-09-06 16:57:40 +01003577 if (bgp_ensure_nexthop (new, NULL, 0))
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003578 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
3579 else
3580 {
3581 if (BGP_DEBUG(nht, NHT))
3582 {
3583 char buf1[INET6_ADDRSTRLEN];
3584 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3585 buf1, INET6_ADDRSTRLEN);
3586 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3587 }
3588 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
3589 }
3590 }
3591 else
3592 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00003593
3594 /* Register new BGP information. */
3595 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003596
3597 /* route_node_get lock */
3598 bgp_unlock_node (rn);
3599
paulfee0f4c2004-09-13 05:12:46 +00003600 /* Process change. */
3601 bgp_process (bgp, rn, afi, safi);
3602
3603 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003604 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003605 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003606}
3607
paul94f2b392005-06-28 12:44:16 +00003608static void
paulfee0f4c2004-09-13 05:12:46 +00003609bgp_static_update_main (struct bgp *bgp, struct prefix *p,
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003610 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00003611{
3612 struct bgp_node *rn;
3613 struct bgp_info *ri;
3614 struct bgp_info *new;
3615 struct bgp_info info;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003616 struct attr attr;
paul718e3742002-12-13 20:15:29 +00003617 struct attr *attr_new;
3618 int ret;
3619
Paul Jakmadd8103a2006-05-12 23:27:30 +00003620 assert (bgp_static);
3621 if (!bgp_static)
3622 return;
3623
paulfee0f4c2004-09-13 05:12:46 +00003624 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003625
3626 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakmadd8103a2006-05-12 23:27:30 +00003627
3628 attr.nexthop = bgp_static->igpnexthop;
3629 attr.med = bgp_static->igpmetric;
3630 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
paul718e3742002-12-13 20:15:29 +00003631
Paul Jakma41367172007-08-06 15:24:51 +00003632 if (bgp_static->atomic)
3633 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3634
paul718e3742002-12-13 20:15:29 +00003635 /* Apply route-map. */
3636 if (bgp_static->rmap.name)
3637 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003638 struct attr attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00003639 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00003640 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00003641
paulfee0f4c2004-09-13 05:12:46 +00003642 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3643
paul718e3742002-12-13 20:15:29 +00003644 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00003645
paulfee0f4c2004-09-13 05:12:46 +00003646 bgp->peer_self->rmap_type = 0;
3647
paul718e3742002-12-13 20:15:29 +00003648 if (ret == RMAP_DENYMATCH)
3649 {
3650 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00003651 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003652
3653 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003654 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003655 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003656 bgp_static_withdraw (bgp, p, afi, safi);
3657 return;
3658 }
paul286e1e72003-08-08 00:24:31 +00003659 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003660 }
paul286e1e72003-08-08 00:24:31 +00003661 else
3662 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00003663
3664 for (ri = rn->info; ri; ri = ri->next)
3665 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3666 && ri->sub_type == BGP_ROUTE_STATIC)
3667 break;
3668
3669 if (ri)
3670 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003671 if (attrhash_cmp (ri->attr, attr_new) &&
3672 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00003673 {
3674 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003675 bgp_attr_unintern (&attr_new);
3676 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003677 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003678 return;
3679 }
3680 else
3681 {
3682 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003683 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00003684
3685 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003686 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3687 bgp_info_restore(rn, ri);
3688 else
3689 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003690 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00003691 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003692 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003693
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003694 /* Nexthop reachability check. */
3695 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3696 {
Paul Jakma3dda6b32016-09-06 16:57:40 +01003697 if (bgp_ensure_nexthop (ri, NULL, 0))
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003698 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
3699 else
3700 {
3701 if (BGP_DEBUG(nht, NHT))
3702 {
3703 char buf1[INET6_ADDRSTRLEN];
3704 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3705 buf1, INET6_ADDRSTRLEN);
3706 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3707 }
3708 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
3709 }
3710 }
paul718e3742002-12-13 20:15:29 +00003711 /* Process change. */
3712 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3713 bgp_process (bgp, rn, afi, safi);
3714 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003715 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003716 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003717 return;
3718 }
3719 }
3720
3721 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003722 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new,
3723 rn);
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003724 /* Nexthop reachability check. */
3725 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3726 {
Paul Jakma3dda6b32016-09-06 16:57:40 +01003727 if (bgp_ensure_nexthop (new, NULL, 0))
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003728 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
3729 else
3730 {
3731 if (BGP_DEBUG(nht, NHT))
3732 {
3733 char buf1[INET6_ADDRSTRLEN];
3734 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1,
3735 INET6_ADDRSTRLEN);
3736 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3737 }
3738 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
3739 }
3740 }
3741 else
3742 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00003743
3744 /* Aggregate address increment. */
3745 bgp_aggregate_increment (bgp, p, new, afi, safi);
3746
3747 /* Register new BGP information. */
3748 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003749
3750 /* route_node_get lock */
3751 bgp_unlock_node (rn);
3752
paul718e3742002-12-13 20:15:29 +00003753 /* Process change. */
3754 bgp_process (bgp, rn, afi, safi);
3755
3756 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003757 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003758 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003759}
3760
3761void
paulfee0f4c2004-09-13 05:12:46 +00003762bgp_static_update (struct bgp *bgp, struct prefix *p,
3763 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3764{
3765 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00003766 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00003767
3768 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3769
paul1eb8ef22005-04-07 07:30:20 +00003770 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00003771 {
Paul Jakmada5b30f2006-05-08 14:37:17 +00003772 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3773 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003774 }
3775}
3776
paul718e3742002-12-13 20:15:29 +00003777void
3778bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3779 safi_t safi)
3780{
3781 struct bgp_node *rn;
3782 struct bgp_info *ri;
3783
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003784 /* Make new BGP info. */
3785 rn = bgp_node_get (bgp->rib[afi][safi], p);
paul718e3742002-12-13 20:15:29 +00003786
3787 /* Check selected route and self inserted route. */
3788 for (ri = rn->info; ri; ri = ri->next)
3789 if (ri->peer == bgp->peer_self
3790 && ri->type == ZEBRA_ROUTE_BGP
3791 && ri->sub_type == BGP_ROUTE_STATIC)
3792 break;
3793
3794 /* Withdraw static BGP route from routing table. */
3795 if (ri)
3796 {
3797 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07003798 bgp_unlink_nexthop(ri);
paul718e3742002-12-13 20:15:29 +00003799 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003800 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003801 }
3802
3803 /* Unlock bgp_node_lookup. */
3804 bgp_unlock_node (rn);
3805}
3806
3807void
paulfee0f4c2004-09-13 05:12:46 +00003808bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3809{
3810 struct bgp_static *bgp_static;
3811 struct bgp *bgp;
3812 struct bgp_node *rn;
3813 struct prefix *p;
3814
3815 bgp = rsclient->bgp;
3816
3817 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3818 if ((bgp_static = rn->info) != NULL)
3819 {
3820 p = &rn->p;
3821
3822 bgp_static_update_rsclient (rsclient, p, bgp_static,
3823 afi, safi);
3824 }
3825}
3826
Lou Bergera76d9ca2016-01-12 13:41:53 -05003827/*
3828 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3829 */
paul94f2b392005-06-28 12:44:16 +00003830static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003831bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3832 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003833{
3834 struct bgp_node *rn;
3835 struct bgp_info *ri;
3836
paulfee0f4c2004-09-13 05:12:46 +00003837 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003838
3839 /* Check selected route and self inserted route. */
3840 for (ri = rn->info; ri; ri = ri->next)
3841 if (ri->peer == bgp->peer_self
3842 && ri->type == ZEBRA_ROUTE_BGP
3843 && ri->sub_type == BGP_ROUTE_STATIC)
3844 break;
3845
3846 /* Withdraw static BGP route from routing table. */
3847 if (ri)
3848 {
3849 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003850 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003851 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003852 }
3853
3854 /* Unlock bgp_node_lookup. */
3855 bgp_unlock_node (rn);
3856}
3857
Lou Bergera76d9ca2016-01-12 13:41:53 -05003858static void
3859bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3860 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3861{
3862 struct bgp_node *rn;
3863 struct bgp_info *new;
3864 struct attr *attr_new;
3865 struct attr attr = { 0 };
3866 struct bgp_info *ri;
3867
3868 assert (bgp_static);
3869
3870 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3871
3872 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3873
3874 attr.nexthop = bgp_static->igpnexthop;
3875 attr.med = bgp_static->igpmetric;
3876 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3877
3878 /* Apply route-map. */
3879 if (bgp_static->rmap.name)
3880 {
3881 struct attr attr_tmp = attr;
3882 struct bgp_info info;
3883 int ret;
3884
3885 info.peer = bgp->peer_self;
3886 info.attr = &attr_tmp;
3887
3888 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3889
3890 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3891
3892 bgp->peer_self->rmap_type = 0;
3893
3894 if (ret == RMAP_DENYMATCH)
3895 {
3896 /* Free uninterned attribute. */
3897 bgp_attr_flush (&attr_tmp);
3898
3899 /* Unintern original. */
3900 aspath_unintern (&attr.aspath);
3901 bgp_attr_extra_free (&attr);
3902 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3903 bgp_static->tag);
3904 return;
3905 }
3906
3907 attr_new = bgp_attr_intern (&attr_tmp);
3908 }
3909 else
3910 {
3911 attr_new = bgp_attr_intern (&attr);
3912 }
3913
3914 for (ri = rn->info; ri; ri = ri->next)
3915 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3916 && ri->sub_type == BGP_ROUTE_STATIC)
3917 break;
3918
3919 if (ri)
3920 {
3921 if (attrhash_cmp (ri->attr, attr_new) &&
3922 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3923 {
3924 bgp_unlock_node (rn);
3925 bgp_attr_unintern (&attr_new);
3926 aspath_unintern (&attr.aspath);
3927 bgp_attr_extra_free (&attr);
3928 return;
3929 }
3930 else
3931 {
3932 /* The attribute is changed. */
3933 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3934
3935 /* Rewrite BGP route information. */
3936 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3937 bgp_info_restore(rn, ri);
3938 else
3939 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3940 bgp_attr_unintern (&ri->attr);
3941 ri->attr = attr_new;
3942 ri->uptime = bgp_clock ();
3943
3944 /* Process change. */
3945 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3946 bgp_process (bgp, rn, afi, safi);
3947 bgp_unlock_node (rn);
3948 aspath_unintern (&attr.aspath);
3949 bgp_attr_extra_free (&attr);
3950 return;
3951 }
3952 }
3953
3954
3955 /* Make new BGP info. */
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003956 new = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
3957 attr_new, rn);
Lou Bergera76d9ca2016-01-12 13:41:53 -05003958 SET_FLAG (new->flags, BGP_INFO_VALID);
Lou Bergera76d9ca2016-01-12 13:41:53 -05003959 new->extra = bgp_info_extra_new();
3960 memcpy (new->extra->tag, bgp_static->tag, 3);
3961
3962 /* Aggregate address increment. */
3963 bgp_aggregate_increment (bgp, p, new, afi, safi);
3964
3965 /* Register new BGP information. */
3966 bgp_info_add (rn, new);
3967
3968 /* route_node_get lock */
3969 bgp_unlock_node (rn);
3970
3971 /* Process change. */
3972 bgp_process (bgp, rn, afi, safi);
3973
3974 /* Unintern original. */
3975 aspath_unintern (&attr.aspath);
3976 bgp_attr_extra_free (&attr);
3977}
3978
paul718e3742002-12-13 20:15:29 +00003979/* Configure static BGP network. When user don't run zebra, static
3980 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003981static int
paulfd79ac92004-10-13 05:06:08 +00003982bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003983 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003984{
3985 int ret;
3986 struct prefix p;
3987 struct bgp_static *bgp_static;
3988 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003989 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003990
3991 /* Convert IP prefix string to struct prefix. */
3992 ret = str2prefix (ip_str, &p);
3993 if (! ret)
3994 {
3995 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3996 return CMD_WARNING;
3997 }
paul718e3742002-12-13 20:15:29 +00003998 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3999 {
4000 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4001 VTY_NEWLINE);
4002 return CMD_WARNING;
4003 }
paul718e3742002-12-13 20:15:29 +00004004
4005 apply_mask (&p);
4006
4007 /* Set BGP static route configuration. */
4008 rn = bgp_node_get (bgp->route[afi][safi], &p);
4009
4010 if (rn->info)
4011 {
4012 /* Configuration change. */
4013 bgp_static = rn->info;
4014
4015 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004016 if (bgp_static->valid && bgp_static->backdoor != backdoor)
4017 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00004018
paul718e3742002-12-13 20:15:29 +00004019 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00004020
paul718e3742002-12-13 20:15:29 +00004021 if (rmap)
4022 {
4023 if (bgp_static->rmap.name)
4024 free (bgp_static->rmap.name);
4025 bgp_static->rmap.name = strdup (rmap);
4026 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4027 }
4028 else
4029 {
4030 if (bgp_static->rmap.name)
4031 free (bgp_static->rmap.name);
4032 bgp_static->rmap.name = NULL;
4033 bgp_static->rmap.map = NULL;
4034 bgp_static->valid = 0;
4035 }
4036 bgp_unlock_node (rn);
4037 }
4038 else
4039 {
4040 /* New configuration. */
4041 bgp_static = bgp_static_new ();
4042 bgp_static->backdoor = backdoor;
4043 bgp_static->valid = 0;
4044 bgp_static->igpmetric = 0;
4045 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00004046
paul718e3742002-12-13 20:15:29 +00004047 if (rmap)
4048 {
4049 if (bgp_static->rmap.name)
4050 free (bgp_static->rmap.name);
4051 bgp_static->rmap.name = strdup (rmap);
4052 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4053 }
4054 rn->info = bgp_static;
4055 }
4056
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07004057 bgp_static->valid = 1;
4058 if (need_update)
4059 bgp_static_withdraw (bgp, &p, afi, safi);
paul718e3742002-12-13 20:15:29 +00004060
Dinesh Duttd9ab53a2015-05-19 17:47:21 -07004061 if (! bgp_static->backdoor)
4062 bgp_static_update (bgp, &p, bgp_static, afi, safi);
paul718e3742002-12-13 20:15:29 +00004063
4064 return CMD_SUCCESS;
4065}
4066
4067/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00004068static int
paulfd79ac92004-10-13 05:06:08 +00004069bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004070 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004071{
4072 int ret;
4073 struct prefix p;
4074 struct bgp_static *bgp_static;
4075 struct bgp_node *rn;
4076
4077 /* Convert IP prefix string to struct prefix. */
4078 ret = str2prefix (ip_str, &p);
4079 if (! ret)
4080 {
4081 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4082 return CMD_WARNING;
4083 }
paul718e3742002-12-13 20:15:29 +00004084 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4085 {
4086 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4087 VTY_NEWLINE);
4088 return CMD_WARNING;
4089 }
paul718e3742002-12-13 20:15:29 +00004090
4091 apply_mask (&p);
4092
4093 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4094 if (! rn)
4095 {
4096 vty_out (vty, "%% Can't find specified static route configuration.%s",
4097 VTY_NEWLINE);
4098 return CMD_WARNING;
4099 }
4100
4101 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004102
paul718e3742002-12-13 20:15:29 +00004103 /* Update BGP RIB. */
4104 if (! bgp_static->backdoor)
4105 bgp_static_withdraw (bgp, &p, afi, safi);
4106
4107 /* Clear configuration. */
4108 bgp_static_free (bgp_static);
4109 rn->info = NULL;
4110 bgp_unlock_node (rn);
4111 bgp_unlock_node (rn);
4112
4113 return CMD_SUCCESS;
4114}
4115
4116/* Called from bgp_delete(). Delete all static routes from the BGP
4117 instance. */
4118void
4119bgp_static_delete (struct bgp *bgp)
4120{
4121 afi_t afi;
4122 safi_t safi;
4123 struct bgp_node *rn;
4124 struct bgp_node *rm;
4125 struct bgp_table *table;
4126 struct bgp_static *bgp_static;
4127
4128 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4129 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4130 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4131 if (rn->info != NULL)
4132 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004133 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004134 {
4135 table = rn->info;
4136
4137 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4138 {
4139 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004140 bgp_static_withdraw_safi (bgp, &rm->p,
4141 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004142 (struct prefix_rd *)&rn->p,
4143 bgp_static->tag);
4144 bgp_static_free (bgp_static);
4145 rn->info = NULL;
4146 bgp_unlock_node (rn);
4147 }
4148 }
4149 else
4150 {
4151 bgp_static = rn->info;
4152 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4153 bgp_static_free (bgp_static);
4154 rn->info = NULL;
4155 bgp_unlock_node (rn);
4156 }
4157 }
4158}
4159
Lou Bergera76d9ca2016-01-12 13:41:53 -05004160/*
4161 * gpz 110624
4162 * Currently this is used to set static routes for VPN and ENCAP.
4163 * I think it can probably be factored with bgp_static_set.
4164 */
paul718e3742002-12-13 20:15:29 +00004165int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004166bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4167 const char *rd_str, const char *tag_str,
4168 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004169{
4170 int ret;
4171 struct prefix p;
4172 struct prefix_rd prd;
4173 struct bgp *bgp;
4174 struct bgp_node *prn;
4175 struct bgp_node *rn;
4176 struct bgp_table *table;
4177 struct bgp_static *bgp_static;
4178 u_char tag[3];
4179
4180 bgp = vty->index;
4181
4182 ret = str2prefix (ip_str, &p);
4183 if (! ret)
4184 {
4185 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4186 return CMD_WARNING;
4187 }
4188 apply_mask (&p);
4189
4190 ret = str2prefix_rd (rd_str, &prd);
4191 if (! ret)
4192 {
4193 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4194 return CMD_WARNING;
4195 }
4196
4197 ret = str2tag (tag_str, tag);
4198 if (! ret)
4199 {
4200 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4201 return CMD_WARNING;
4202 }
4203
Lou Bergera76d9ca2016-01-12 13:41:53 -05004204 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004205 (struct prefix *)&prd);
4206 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004207 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004208 else
4209 bgp_unlock_node (prn);
4210 table = prn->info;
4211
4212 rn = bgp_node_get (table, &p);
4213
4214 if (rn->info)
4215 {
4216 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4217 bgp_unlock_node (rn);
4218 }
4219 else
4220 {
4221 /* New configuration. */
4222 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004223 bgp_static->backdoor = 0;
4224 bgp_static->valid = 0;
4225 bgp_static->igpmetric = 0;
4226 bgp_static->igpnexthop.s_addr = 0;
4227 memcpy(bgp_static->tag, tag, 3);
4228 bgp_static->prd = prd;
4229
4230 if (rmap_str)
4231 {
4232 if (bgp_static->rmap.name)
4233 free (bgp_static->rmap.name);
4234 bgp_static->rmap.name = strdup (rmap_str);
4235 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4236 }
paul718e3742002-12-13 20:15:29 +00004237 rn->info = bgp_static;
4238
Lou Bergera76d9ca2016-01-12 13:41:53 -05004239 bgp_static->valid = 1;
4240 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004241 }
4242
4243 return CMD_SUCCESS;
4244}
4245
4246/* Configure static BGP network. */
4247int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004248bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4249 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004250{
4251 int ret;
4252 struct bgp *bgp;
4253 struct prefix p;
4254 struct prefix_rd prd;
4255 struct bgp_node *prn;
4256 struct bgp_node *rn;
4257 struct bgp_table *table;
4258 struct bgp_static *bgp_static;
4259 u_char tag[3];
4260
4261 bgp = vty->index;
4262
4263 /* Convert IP prefix string to struct prefix. */
4264 ret = str2prefix (ip_str, &p);
4265 if (! ret)
4266 {
4267 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4268 return CMD_WARNING;
4269 }
4270 apply_mask (&p);
4271
4272 ret = str2prefix_rd (rd_str, &prd);
4273 if (! ret)
4274 {
4275 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4276 return CMD_WARNING;
4277 }
4278
4279 ret = str2tag (tag_str, tag);
4280 if (! ret)
4281 {
4282 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4283 return CMD_WARNING;
4284 }
4285
Lou Bergera76d9ca2016-01-12 13:41:53 -05004286 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004287 (struct prefix *)&prd);
4288 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004289 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004290 else
4291 bgp_unlock_node (prn);
4292 table = prn->info;
4293
4294 rn = bgp_node_lookup (table, &p);
4295
4296 if (rn)
4297 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004298 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004299
4300 bgp_static = rn->info;
4301 bgp_static_free (bgp_static);
4302 rn->info = NULL;
4303 bgp_unlock_node (rn);
4304 bgp_unlock_node (rn);
4305 }
4306 else
4307 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4308
4309 return CMD_SUCCESS;
4310}
David Lamparter6b0655a2014-06-04 06:53:35 +02004311
paul718e3742002-12-13 20:15:29 +00004312DEFUN (bgp_network,
4313 bgp_network_cmd,
4314 "network A.B.C.D/M",
4315 "Specify a network to announce via BGP\n"
4316 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4317{
4318 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004319 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004320}
4321
4322DEFUN (bgp_network_route_map,
4323 bgp_network_route_map_cmd,
4324 "network A.B.C.D/M route-map WORD",
4325 "Specify a network to announce via BGP\n"
4326 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4327 "Route-map to modify the attributes\n"
4328 "Name of the route map\n")
4329{
4330 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004331 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004332}
4333
4334DEFUN (bgp_network_backdoor,
4335 bgp_network_backdoor_cmd,
4336 "network A.B.C.D/M backdoor",
4337 "Specify a network to announce via BGP\n"
4338 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4339 "Specify a BGP backdoor route\n")
4340{
Paul Jakma41367172007-08-06 15:24:51 +00004341 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004342 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004343}
4344
4345DEFUN (bgp_network_mask,
4346 bgp_network_mask_cmd,
4347 "network A.B.C.D mask A.B.C.D",
4348 "Specify a network to announce via BGP\n"
4349 "Network number\n"
4350 "Network mask\n"
4351 "Network mask\n")
4352{
4353 int ret;
4354 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004355
paul718e3742002-12-13 20:15:29 +00004356 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4357 if (! ret)
4358 {
4359 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4360 return CMD_WARNING;
4361 }
4362
4363 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004364 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004365}
4366
4367DEFUN (bgp_network_mask_route_map,
4368 bgp_network_mask_route_map_cmd,
4369 "network A.B.C.D mask A.B.C.D route-map WORD",
4370 "Specify a network to announce via BGP\n"
4371 "Network number\n"
4372 "Network mask\n"
4373 "Network mask\n"
4374 "Route-map to modify the attributes\n"
4375 "Name of the route map\n")
4376{
4377 int ret;
4378 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004379
paul718e3742002-12-13 20:15:29 +00004380 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4381 if (! ret)
4382 {
4383 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4384 return CMD_WARNING;
4385 }
4386
4387 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004388 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004389}
4390
4391DEFUN (bgp_network_mask_backdoor,
4392 bgp_network_mask_backdoor_cmd,
4393 "network A.B.C.D mask A.B.C.D backdoor",
4394 "Specify a network to announce via BGP\n"
4395 "Network number\n"
4396 "Network mask\n"
4397 "Network mask\n"
4398 "Specify a BGP backdoor route\n")
4399{
4400 int ret;
4401 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004402
paul718e3742002-12-13 20:15:29 +00004403 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4404 if (! ret)
4405 {
4406 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4407 return CMD_WARNING;
4408 }
4409
Paul Jakma41367172007-08-06 15:24:51 +00004410 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004411 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004412}
4413
4414DEFUN (bgp_network_mask_natural,
4415 bgp_network_mask_natural_cmd,
4416 "network A.B.C.D",
4417 "Specify a network to announce via BGP\n"
4418 "Network number\n")
4419{
4420 int ret;
4421 char prefix_str[BUFSIZ];
4422
4423 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4424 if (! ret)
4425 {
4426 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4427 return CMD_WARNING;
4428 }
4429
4430 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004431 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004432}
4433
4434DEFUN (bgp_network_mask_natural_route_map,
4435 bgp_network_mask_natural_route_map_cmd,
4436 "network A.B.C.D route-map WORD",
4437 "Specify a network to announce via BGP\n"
4438 "Network number\n"
4439 "Route-map to modify the attributes\n"
4440 "Name of the route map\n")
4441{
4442 int ret;
4443 char prefix_str[BUFSIZ];
4444
4445 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4446 if (! ret)
4447 {
4448 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4449 return CMD_WARNING;
4450 }
4451
4452 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004453 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004454}
4455
4456DEFUN (bgp_network_mask_natural_backdoor,
4457 bgp_network_mask_natural_backdoor_cmd,
4458 "network A.B.C.D backdoor",
4459 "Specify a network to announce via BGP\n"
4460 "Network number\n"
4461 "Specify a BGP backdoor route\n")
4462{
4463 int ret;
4464 char prefix_str[BUFSIZ];
4465
4466 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4467 if (! ret)
4468 {
4469 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4470 return CMD_WARNING;
4471 }
4472
Paul Jakma41367172007-08-06 15:24:51 +00004473 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004474 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004475}
4476
4477DEFUN (no_bgp_network,
4478 no_bgp_network_cmd,
4479 "no network A.B.C.D/M",
4480 NO_STR
4481 "Specify a network to announce via BGP\n"
4482 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4483{
4484 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4485 bgp_node_safi (vty));
4486}
4487
4488ALIAS (no_bgp_network,
4489 no_bgp_network_route_map_cmd,
4490 "no network A.B.C.D/M route-map WORD",
4491 NO_STR
4492 "Specify a network to announce via BGP\n"
4493 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4494 "Route-map to modify the attributes\n"
4495 "Name of the route map\n")
4496
4497ALIAS (no_bgp_network,
4498 no_bgp_network_backdoor_cmd,
4499 "no network A.B.C.D/M backdoor",
4500 NO_STR
4501 "Specify a network to announce via BGP\n"
4502 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4503 "Specify a BGP backdoor route\n")
4504
4505DEFUN (no_bgp_network_mask,
4506 no_bgp_network_mask_cmd,
4507 "no network A.B.C.D mask A.B.C.D",
4508 NO_STR
4509 "Specify a network to announce via BGP\n"
4510 "Network number\n"
4511 "Network mask\n"
4512 "Network mask\n")
4513{
4514 int ret;
4515 char prefix_str[BUFSIZ];
4516
4517 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4518 if (! ret)
4519 {
4520 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4521 return CMD_WARNING;
4522 }
4523
4524 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4525 bgp_node_safi (vty));
4526}
4527
4528ALIAS (no_bgp_network_mask,
4529 no_bgp_network_mask_route_map_cmd,
4530 "no network A.B.C.D mask A.B.C.D route-map WORD",
4531 NO_STR
4532 "Specify a network to announce via BGP\n"
4533 "Network number\n"
4534 "Network mask\n"
4535 "Network mask\n"
4536 "Route-map to modify the attributes\n"
4537 "Name of the route map\n")
4538
4539ALIAS (no_bgp_network_mask,
4540 no_bgp_network_mask_backdoor_cmd,
4541 "no network A.B.C.D mask A.B.C.D backdoor",
4542 NO_STR
4543 "Specify a network to announce via BGP\n"
4544 "Network number\n"
4545 "Network mask\n"
4546 "Network mask\n"
4547 "Specify a BGP backdoor route\n")
4548
4549DEFUN (no_bgp_network_mask_natural,
4550 no_bgp_network_mask_natural_cmd,
4551 "no network A.B.C.D",
4552 NO_STR
4553 "Specify a network to announce via BGP\n"
4554 "Network number\n")
4555{
4556 int ret;
4557 char prefix_str[BUFSIZ];
4558
4559 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4560 if (! ret)
4561 {
4562 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4563 return CMD_WARNING;
4564 }
4565
4566 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4567 bgp_node_safi (vty));
4568}
4569
4570ALIAS (no_bgp_network_mask_natural,
4571 no_bgp_network_mask_natural_route_map_cmd,
4572 "no network A.B.C.D route-map WORD",
4573 NO_STR
4574 "Specify a network to announce via BGP\n"
4575 "Network number\n"
4576 "Route-map to modify the attributes\n"
4577 "Name of the route map\n")
4578
4579ALIAS (no_bgp_network_mask_natural,
4580 no_bgp_network_mask_natural_backdoor_cmd,
4581 "no network A.B.C.D backdoor",
4582 NO_STR
4583 "Specify a network to announce via BGP\n"
4584 "Network number\n"
4585 "Specify a BGP backdoor route\n")
4586
paul718e3742002-12-13 20:15:29 +00004587DEFUN (ipv6_bgp_network,
4588 ipv6_bgp_network_cmd,
4589 "network X:X::X:X/M",
4590 "Specify a network to announce via BGP\n"
4591 "IPv6 prefix <network>/<length>\n")
4592{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304593 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004594 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004595}
4596
4597DEFUN (ipv6_bgp_network_route_map,
4598 ipv6_bgp_network_route_map_cmd,
4599 "network X:X::X:X/M route-map WORD",
4600 "Specify a network to announce via BGP\n"
4601 "IPv6 prefix <network>/<length>\n"
4602 "Route-map to modify the attributes\n"
4603 "Name of the route map\n")
4604{
4605 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004606 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004607}
4608
4609DEFUN (no_ipv6_bgp_network,
4610 no_ipv6_bgp_network_cmd,
4611 "no network X:X::X:X/M",
4612 NO_STR
4613 "Specify a network to announce via BGP\n"
4614 "IPv6 prefix <network>/<length>\n")
4615{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304616 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004617}
4618
4619ALIAS (no_ipv6_bgp_network,
4620 no_ipv6_bgp_network_route_map_cmd,
4621 "no network X:X::X:X/M route-map WORD",
4622 NO_STR
4623 "Specify a network to announce via BGP\n"
4624 "IPv6 prefix <network>/<length>\n"
4625 "Route-map to modify the attributes\n"
4626 "Name of the route map\n")
4627
4628ALIAS (ipv6_bgp_network,
4629 old_ipv6_bgp_network_cmd,
4630 "ipv6 bgp network X:X::X:X/M",
4631 IPV6_STR
4632 BGP_STR
4633 "Specify a network to announce via BGP\n"
4634 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4635
4636ALIAS (no_ipv6_bgp_network,
4637 old_no_ipv6_bgp_network_cmd,
4638 "no ipv6 bgp network X:X::X:X/M",
4639 NO_STR
4640 IPV6_STR
4641 BGP_STR
4642 "Specify a network to announce via BGP\n"
4643 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004644
4645/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4646ALIAS_DEPRECATED (bgp_network,
4647 bgp_network_ttl_cmd,
4648 "network A.B.C.D/M pathlimit <0-255>",
4649 "Specify a network to announce via BGP\n"
4650 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4651 "AS-Path hopcount limit attribute\n"
4652 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4653ALIAS_DEPRECATED (bgp_network_backdoor,
4654 bgp_network_backdoor_ttl_cmd,
4655 "network A.B.C.D/M backdoor pathlimit <0-255>",
4656 "Specify a network to announce via BGP\n"
4657 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4658 "Specify a BGP backdoor route\n"
4659 "AS-Path hopcount limit attribute\n"
4660 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4661ALIAS_DEPRECATED (bgp_network_mask,
4662 bgp_network_mask_ttl_cmd,
4663 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4664 "Specify a network to announce via BGP\n"
4665 "Network number\n"
4666 "Network mask\n"
4667 "Network mask\n"
4668 "AS-Path hopcount limit attribute\n"
4669 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4670ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4671 bgp_network_mask_backdoor_ttl_cmd,
4672 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4673 "Specify a network to announce via BGP\n"
4674 "Network number\n"
4675 "Network mask\n"
4676 "Network mask\n"
4677 "Specify a BGP backdoor route\n"
4678 "AS-Path hopcount limit attribute\n"
4679 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4680ALIAS_DEPRECATED (bgp_network_mask_natural,
4681 bgp_network_mask_natural_ttl_cmd,
4682 "network A.B.C.D pathlimit <0-255>",
4683 "Specify a network to announce via BGP\n"
4684 "Network number\n"
4685 "AS-Path hopcount limit attribute\n"
4686 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4687ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4688 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004689 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004690 "Specify a network to announce via BGP\n"
4691 "Network number\n"
4692 "Specify a BGP backdoor route\n"
4693 "AS-Path hopcount limit attribute\n"
4694 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4695ALIAS_DEPRECATED (no_bgp_network,
4696 no_bgp_network_ttl_cmd,
4697 "no network A.B.C.D/M pathlimit <0-255>",
4698 NO_STR
4699 "Specify a network to announce via BGP\n"
4700 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4701 "AS-Path hopcount limit attribute\n"
4702 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4703ALIAS_DEPRECATED (no_bgp_network,
4704 no_bgp_network_backdoor_ttl_cmd,
4705 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4706 NO_STR
4707 "Specify a network to announce via BGP\n"
4708 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4709 "Specify a BGP backdoor route\n"
4710 "AS-Path hopcount limit attribute\n"
4711 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4712ALIAS_DEPRECATED (no_bgp_network,
4713 no_bgp_network_mask_ttl_cmd,
4714 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4715 NO_STR
4716 "Specify a network to announce via BGP\n"
4717 "Network number\n"
4718 "Network mask\n"
4719 "Network mask\n"
4720 "AS-Path hopcount limit attribute\n"
4721 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4722ALIAS_DEPRECATED (no_bgp_network_mask,
4723 no_bgp_network_mask_backdoor_ttl_cmd,
4724 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4725 NO_STR
4726 "Specify a network to announce via BGP\n"
4727 "Network number\n"
4728 "Network mask\n"
4729 "Network mask\n"
4730 "Specify a BGP backdoor route\n"
4731 "AS-Path hopcount limit attribute\n"
4732 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4733ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4734 no_bgp_network_mask_natural_ttl_cmd,
4735 "no network A.B.C.D pathlimit <0-255>",
4736 NO_STR
4737 "Specify a network to announce via BGP\n"
4738 "Network number\n"
4739 "AS-Path hopcount limit attribute\n"
4740 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4741ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4742 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4743 "no network A.B.C.D backdoor pathlimit <0-255>",
4744 NO_STR
4745 "Specify a network to announce via BGP\n"
4746 "Network number\n"
4747 "Specify a BGP backdoor route\n"
4748 "AS-Path hopcount limit attribute\n"
4749 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4750ALIAS_DEPRECATED (ipv6_bgp_network,
4751 ipv6_bgp_network_ttl_cmd,
4752 "network X:X::X:X/M pathlimit <0-255>",
4753 "Specify a network to announce via BGP\n"
4754 "IPv6 prefix <network>/<length>\n"
4755 "AS-Path hopcount limit attribute\n"
4756 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4757ALIAS_DEPRECATED (no_ipv6_bgp_network,
4758 no_ipv6_bgp_network_ttl_cmd,
4759 "no network X:X::X:X/M pathlimit <0-255>",
4760 NO_STR
4761 "Specify a network to announce via BGP\n"
4762 "IPv6 prefix <network>/<length>\n"
4763 "AS-Path hopcount limit attribute\n"
4764 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004765
paul718e3742002-12-13 20:15:29 +00004766/* Aggreagete address:
4767
4768 advertise-map Set condition to advertise attribute
4769 as-set Generate AS set path information
4770 attribute-map Set attributes of aggregate
4771 route-map Set parameters of aggregate
4772 summary-only Filter more specific routes from updates
4773 suppress-map Conditionally filter more specific routes from updates
4774 <cr>
4775 */
4776struct bgp_aggregate
4777{
4778 /* Summary-only flag. */
4779 u_char summary_only;
4780
4781 /* AS set generation. */
4782 u_char as_set;
4783
4784 /* Route-map for aggregated route. */
4785 struct route_map *map;
4786
4787 /* Suppress-count. */
4788 unsigned long count;
4789
4790 /* SAFI configuration. */
4791 safi_t safi;
4792};
4793
paul94f2b392005-06-28 12:44:16 +00004794static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004795bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004796{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004797 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004798}
4799
paul94f2b392005-06-28 12:44:16 +00004800static void
paul718e3742002-12-13 20:15:29 +00004801bgp_aggregate_free (struct bgp_aggregate *aggregate)
4802{
4803 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4804}
4805
Daniel Walton76a72802015-05-19 17:47:24 -07004806/* Update an aggregate as routes are added/removed from the BGP table */
paul94f2b392005-06-28 12:44:16 +00004807static void
paul718e3742002-12-13 20:15:29 +00004808bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4809 afi_t afi, safi_t safi, struct bgp_info *del,
4810 struct bgp_aggregate *aggregate)
4811{
4812 struct bgp_table *table;
4813 struct bgp_node *top;
4814 struct bgp_node *rn;
4815 u_char origin;
4816 struct aspath *aspath = NULL;
4817 struct aspath *asmerge = NULL;
4818 struct community *community = NULL;
4819 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004820 struct bgp_info *ri;
4821 struct bgp_info *new;
4822 int first = 1;
4823 unsigned long match = 0;
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004824 u_char atomic_aggregate = 0;
paul718e3742002-12-13 20:15:29 +00004825
paul718e3742002-12-13 20:15:29 +00004826 /* ORIGIN attribute: If at least one route among routes that are
4827 aggregated has ORIGIN with the value INCOMPLETE, then the
4828 aggregated route must have the ORIGIN attribute with the value
4829 INCOMPLETE. Otherwise, if at least one route among routes that
4830 are aggregated has ORIGIN with the value EGP, then the aggregated
4831 route must have the origin attribute with the value EGP. In all
4832 other case the value of the ORIGIN attribute of the aggregated
4833 route is INTERNAL. */
4834 origin = BGP_ORIGIN_IGP;
4835
4836 table = bgp->rib[afi][safi];
4837
4838 top = bgp_node_get (table, p);
4839 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4840 if (rn->p.prefixlen > p->prefixlen)
4841 {
4842 match = 0;
4843
4844 for (ri = rn->info; ri; ri = ri->next)
4845 {
4846 if (BGP_INFO_HOLDDOWN (ri))
4847 continue;
4848
4849 if (del && ri == del)
4850 continue;
4851
4852 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004853 first = 0;
paul718e3742002-12-13 20:15:29 +00004854
4855#ifdef AGGREGATE_NEXTHOP_CHECK
4856 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4857 || ri->attr->med != med)
4858 {
4859 if (aspath)
4860 aspath_free (aspath);
4861 if (community)
4862 community_free (community);
4863 bgp_unlock_node (rn);
4864 bgp_unlock_node (top);
4865 return;
4866 }
4867#endif /* AGGREGATE_NEXTHOP_CHECK */
4868
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004869 if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
4870 atomic_aggregate = 1;
4871
paul718e3742002-12-13 20:15:29 +00004872 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4873 {
4874 if (aggregate->summary_only)
4875 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004876 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004877 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004878 match++;
4879 }
4880
4881 aggregate->count++;
4882
Daniel Walton76a72802015-05-19 17:47:24 -07004883 if (origin < ri->attr->origin)
4884 origin = ri->attr->origin;
4885
paul718e3742002-12-13 20:15:29 +00004886 if (aggregate->as_set)
4887 {
paul718e3742002-12-13 20:15:29 +00004888 if (aspath)
4889 {
4890 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4891 aspath_free (aspath);
4892 aspath = asmerge;
4893 }
4894 else
4895 aspath = aspath_dup (ri->attr->aspath);
4896
4897 if (ri->attr->community)
4898 {
4899 if (community)
4900 {
4901 commerge = community_merge (community,
4902 ri->attr->community);
4903 community = community_uniq_sort (commerge);
4904 community_free (commerge);
4905 }
4906 else
4907 community = community_dup (ri->attr->community);
4908 }
4909 }
4910 }
4911 }
4912 if (match)
4913 bgp_process (bgp, rn, afi, safi);
4914 }
4915 bgp_unlock_node (top);
4916
4917 if (rinew)
4918 {
4919 aggregate->count++;
4920
4921 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004922 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004923
Daniel Walton76a72802015-05-19 17:47:24 -07004924 if (origin < rinew->attr->origin)
4925 origin = rinew->attr->origin;
4926
paul718e3742002-12-13 20:15:29 +00004927 if (aggregate->as_set)
4928 {
paul718e3742002-12-13 20:15:29 +00004929 if (aspath)
4930 {
4931 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4932 aspath_free (aspath);
4933 aspath = asmerge;
4934 }
4935 else
4936 aspath = aspath_dup (rinew->attr->aspath);
4937
4938 if (rinew->attr->community)
4939 {
4940 if (community)
4941 {
4942 commerge = community_merge (community,
4943 rinew->attr->community);
4944 community = community_uniq_sort (commerge);
4945 community_free (commerge);
4946 }
4947 else
4948 community = community_dup (rinew->attr->community);
4949 }
4950 }
4951 }
4952
4953 if (aggregate->count > 0)
4954 {
4955 rn = bgp_node_get (table, p);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05004956 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
4957 bgp_attr_aggregate_intern(bgp, origin, aspath, community,
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07004958 aggregate->as_set,
4959 atomic_aggregate), rn);
paul718e3742002-12-13 20:15:29 +00004960 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00004961
4962 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004963 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004964 bgp_process (bgp, rn, afi, safi);
4965 }
4966 else
4967 {
4968 if (aspath)
4969 aspath_free (aspath);
4970 if (community)
4971 community_free (community);
4972 }
4973}
4974
4975void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4976 struct bgp_aggregate *);
4977
4978void
4979bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4980 struct bgp_info *ri, afi_t afi, safi_t safi)
4981{
4982 struct bgp_node *child;
4983 struct bgp_node *rn;
4984 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004985 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004986
4987 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004988 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004989 return;
4990
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004991 table = bgp->aggregate[afi][safi];
4992
4993 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004994 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004995 return;
4996
paul718e3742002-12-13 20:15:29 +00004997 if (p->prefixlen == 0)
4998 return;
4999
5000 if (BGP_INFO_HOLDDOWN (ri))
5001 return;
5002
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02005003 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00005004
5005 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005006 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005007 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5008 {
5009 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005010 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00005011 }
5012 bgp_unlock_node (child);
5013}
5014
5015void
5016bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
5017 struct bgp_info *del, afi_t afi, safi_t safi)
5018{
5019 struct bgp_node *child;
5020 struct bgp_node *rn;
5021 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005022 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00005023
5024 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05005025 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00005026 return;
5027
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005028 table = bgp->aggregate[afi][safi];
5029
5030 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005031 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005032 return;
5033
paul718e3742002-12-13 20:15:29 +00005034 if (p->prefixlen == 0)
5035 return;
5036
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02005037 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00005038
5039 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005040 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005041 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5042 {
5043 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005044 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00005045 }
5046 bgp_unlock_node (child);
5047}
5048
Daniel Walton76a72802015-05-19 17:47:24 -07005049/* Called via bgp_aggregate_set when the user configures aggregate-address */
paul94f2b392005-06-28 12:44:16 +00005050static void
paul718e3742002-12-13 20:15:29 +00005051bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
5052 struct bgp_aggregate *aggregate)
5053{
5054 struct bgp_table *table;
5055 struct bgp_node *top;
5056 struct bgp_node *rn;
5057 struct bgp_info *new;
5058 struct bgp_info *ri;
5059 unsigned long match;
5060 u_char origin = BGP_ORIGIN_IGP;
5061 struct aspath *aspath = NULL;
5062 struct aspath *asmerge = NULL;
5063 struct community *community = NULL;
5064 struct community *commerge = NULL;
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005065 u_char atomic_aggregate = 0;
paul718e3742002-12-13 20:15:29 +00005066
5067 table = bgp->rib[afi][safi];
5068
5069 /* Sanity check. */
5070 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5071 return;
5072 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5073 return;
5074
5075 /* If routes exists below this node, generate aggregate routes. */
5076 top = bgp_node_get (table, p);
5077 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5078 if (rn->p.prefixlen > p->prefixlen)
5079 {
5080 match = 0;
5081
5082 for (ri = rn->info; ri; ri = ri->next)
5083 {
5084 if (BGP_INFO_HOLDDOWN (ri))
5085 continue;
5086
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005087 if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
5088 atomic_aggregate = 1;
5089
paul718e3742002-12-13 20:15:29 +00005090 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5091 {
5092 /* summary-only aggregate route suppress aggregated
5093 route announcement. */
5094 if (aggregate->summary_only)
5095 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005096 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005097 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005098 match++;
5099 }
Daniel Walton76a72802015-05-19 17:47:24 -07005100
5101 /* If at least one route among routes that are aggregated has
5102 * ORIGIN with the value INCOMPLETE, then the aggregated route
5103 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5104 * Otherwise, if at least one route among routes that are
5105 * aggregated has ORIGIN with the value EGP, then the aggregated
5106 * route MUST have the ORIGIN attribute with the value EGP.
5107 */
5108 if (origin < ri->attr->origin)
5109 origin = ri->attr->origin;
5110
paul718e3742002-12-13 20:15:29 +00005111 /* as-set aggregate route generate origin, as path,
5112 community aggregation. */
5113 if (aggregate->as_set)
5114 {
paul718e3742002-12-13 20:15:29 +00005115 if (aspath)
5116 {
5117 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5118 aspath_free (aspath);
5119 aspath = asmerge;
5120 }
5121 else
5122 aspath = aspath_dup (ri->attr->aspath);
5123
5124 if (ri->attr->community)
5125 {
5126 if (community)
5127 {
5128 commerge = community_merge (community,
5129 ri->attr->community);
5130 community = community_uniq_sort (commerge);
5131 community_free (commerge);
5132 }
5133 else
5134 community = community_dup (ri->attr->community);
5135 }
5136 }
5137 aggregate->count++;
5138 }
5139 }
5140
5141 /* If this node is suppressed, process the change. */
5142 if (match)
5143 bgp_process (bgp, rn, afi, safi);
5144 }
5145 bgp_unlock_node (top);
5146
5147 /* Add aggregate route to BGP table. */
5148 if (aggregate->count)
5149 {
5150 rn = bgp_node_get (table, p);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005151 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
5152 bgp_attr_aggregate_intern(bgp, origin, aspath, community,
Daniel Waltonf2eb9ca2015-05-19 17:47:21 -07005153 aggregate->as_set,
5154 atomic_aggregate), rn);
paul718e3742002-12-13 20:15:29 +00005155 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00005156
5157 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005158 bgp_unlock_node (rn);
5159
paul718e3742002-12-13 20:15:29 +00005160 /* Process change. */
5161 bgp_process (bgp, rn, afi, safi);
5162 }
Denil Virae2a92582015-08-11 13:34:59 -07005163 else
5164 {
5165 if (aspath)
5166 aspath_free (aspath);
5167 if (community)
5168 community_free (community);
5169 }
paul718e3742002-12-13 20:15:29 +00005170}
5171
5172void
5173bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5174 safi_t safi, struct bgp_aggregate *aggregate)
5175{
5176 struct bgp_table *table;
5177 struct bgp_node *top;
5178 struct bgp_node *rn;
5179 struct bgp_info *ri;
5180 unsigned long match;
5181
5182 table = bgp->rib[afi][safi];
5183
5184 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5185 return;
5186 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5187 return;
5188
5189 /* If routes exists below this node, generate aggregate routes. */
5190 top = bgp_node_get (table, p);
5191 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5192 if (rn->p.prefixlen > p->prefixlen)
5193 {
5194 match = 0;
5195
5196 for (ri = rn->info; ri; ri = ri->next)
5197 {
5198 if (BGP_INFO_HOLDDOWN (ri))
5199 continue;
5200
5201 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5202 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005203 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005204 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005205 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005206
Paul Jakmafb982c22007-05-04 20:15:47 +00005207 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005208 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005209 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005210 match++;
5211 }
5212 }
5213 aggregate->count--;
5214 }
5215 }
5216
Paul Jakmafb982c22007-05-04 20:15:47 +00005217 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005218 if (match)
5219 bgp_process (bgp, rn, afi, safi);
5220 }
5221 bgp_unlock_node (top);
5222
5223 /* Delete aggregate route from BGP table. */
5224 rn = bgp_node_get (table, p);
5225
5226 for (ri = rn->info; ri; ri = ri->next)
5227 if (ri->peer == bgp->peer_self
5228 && ri->type == ZEBRA_ROUTE_BGP
5229 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5230 break;
5231
5232 /* Withdraw static BGP route from routing table. */
5233 if (ri)
5234 {
paul718e3742002-12-13 20:15:29 +00005235 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005236 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005237 }
5238
5239 /* Unlock bgp_node_lookup. */
5240 bgp_unlock_node (rn);
5241}
5242
5243/* Aggregate route attribute. */
5244#define AGGREGATE_SUMMARY_ONLY 1
5245#define AGGREGATE_AS_SET 1
5246
paul94f2b392005-06-28 12:44:16 +00005247static int
Robert Baysf6269b42010-08-05 10:26:28 -07005248bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5249 afi_t afi, safi_t safi)
5250{
5251 int ret;
5252 struct prefix p;
5253 struct bgp_node *rn;
5254 struct bgp *bgp;
5255 struct bgp_aggregate *aggregate;
5256
5257 /* Convert string to prefix structure. */
5258 ret = str2prefix (prefix_str, &p);
5259 if (!ret)
5260 {
5261 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5262 return CMD_WARNING;
5263 }
5264 apply_mask (&p);
5265
5266 /* Get BGP structure. */
5267 bgp = vty->index;
5268
5269 /* Old configuration check. */
5270 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5271 if (! rn)
5272 {
5273 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5274 VTY_NEWLINE);
5275 return CMD_WARNING;
5276 }
5277
5278 aggregate = rn->info;
5279 if (aggregate->safi & SAFI_UNICAST)
5280 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5281 if (aggregate->safi & SAFI_MULTICAST)
5282 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5283
5284 /* Unlock aggregate address configuration. */
5285 rn->info = NULL;
5286 bgp_aggregate_free (aggregate);
5287 bgp_unlock_node (rn);
5288 bgp_unlock_node (rn);
5289
5290 return CMD_SUCCESS;
5291}
5292
5293static int
5294bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005295 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005296 u_char summary_only, u_char as_set)
5297{
5298 int ret;
5299 struct prefix p;
5300 struct bgp_node *rn;
5301 struct bgp *bgp;
5302 struct bgp_aggregate *aggregate;
5303
5304 /* Convert string to prefix structure. */
5305 ret = str2prefix (prefix_str, &p);
5306 if (!ret)
5307 {
5308 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5309 return CMD_WARNING;
5310 }
5311 apply_mask (&p);
5312
5313 /* Get BGP structure. */
5314 bgp = vty->index;
5315
5316 /* Old configuration check. */
5317 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5318
5319 if (rn->info)
5320 {
5321 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005322 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005323 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5324 if (ret)
5325 {
Robert Bays368473f2010-08-05 10:26:29 -07005326 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5327 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005328 return CMD_WARNING;
5329 }
paul718e3742002-12-13 20:15:29 +00005330 }
5331
5332 /* Make aggregate address structure. */
5333 aggregate = bgp_aggregate_new ();
5334 aggregate->summary_only = summary_only;
5335 aggregate->as_set = as_set;
5336 aggregate->safi = safi;
5337 rn->info = aggregate;
5338
5339 /* Aggregate address insert into BGP routing table. */
5340 if (safi & SAFI_UNICAST)
5341 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5342 if (safi & SAFI_MULTICAST)
5343 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5344
5345 return CMD_SUCCESS;
5346}
5347
paul718e3742002-12-13 20:15:29 +00005348DEFUN (aggregate_address,
5349 aggregate_address_cmd,
5350 "aggregate-address A.B.C.D/M",
5351 "Configure BGP aggregate entries\n"
5352 "Aggregate prefix\n")
5353{
5354 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5355}
5356
5357DEFUN (aggregate_address_mask,
5358 aggregate_address_mask_cmd,
5359 "aggregate-address A.B.C.D A.B.C.D",
5360 "Configure BGP aggregate entries\n"
5361 "Aggregate address\n"
5362 "Aggregate mask\n")
5363{
5364 int ret;
5365 char prefix_str[BUFSIZ];
5366
5367 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5368
5369 if (! ret)
5370 {
5371 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5372 return CMD_WARNING;
5373 }
5374
5375 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5376 0, 0);
5377}
5378
5379DEFUN (aggregate_address_summary_only,
5380 aggregate_address_summary_only_cmd,
5381 "aggregate-address A.B.C.D/M summary-only",
5382 "Configure BGP aggregate entries\n"
5383 "Aggregate prefix\n"
5384 "Filter more specific routes from updates\n")
5385{
5386 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5387 AGGREGATE_SUMMARY_ONLY, 0);
5388}
5389
5390DEFUN (aggregate_address_mask_summary_only,
5391 aggregate_address_mask_summary_only_cmd,
5392 "aggregate-address A.B.C.D A.B.C.D summary-only",
5393 "Configure BGP aggregate entries\n"
5394 "Aggregate address\n"
5395 "Aggregate mask\n"
5396 "Filter more specific routes from updates\n")
5397{
5398 int ret;
5399 char prefix_str[BUFSIZ];
5400
5401 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5402
5403 if (! ret)
5404 {
5405 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5406 return CMD_WARNING;
5407 }
5408
5409 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5410 AGGREGATE_SUMMARY_ONLY, 0);
5411}
5412
5413DEFUN (aggregate_address_as_set,
5414 aggregate_address_as_set_cmd,
5415 "aggregate-address A.B.C.D/M as-set",
5416 "Configure BGP aggregate entries\n"
5417 "Aggregate prefix\n"
5418 "Generate AS set path information\n")
5419{
5420 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5421 0, AGGREGATE_AS_SET);
5422}
5423
5424DEFUN (aggregate_address_mask_as_set,
5425 aggregate_address_mask_as_set_cmd,
5426 "aggregate-address A.B.C.D A.B.C.D as-set",
5427 "Configure BGP aggregate entries\n"
5428 "Aggregate address\n"
5429 "Aggregate mask\n"
5430 "Generate AS set path information\n")
5431{
5432 int ret;
5433 char prefix_str[BUFSIZ];
5434
5435 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5436
5437 if (! ret)
5438 {
5439 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5440 return CMD_WARNING;
5441 }
5442
5443 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5444 0, AGGREGATE_AS_SET);
5445}
5446
5447
5448DEFUN (aggregate_address_as_set_summary,
5449 aggregate_address_as_set_summary_cmd,
5450 "aggregate-address A.B.C.D/M as-set summary-only",
5451 "Configure BGP aggregate entries\n"
5452 "Aggregate prefix\n"
5453 "Generate AS set path information\n"
5454 "Filter more specific routes from updates\n")
5455{
5456 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5457 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5458}
5459
5460ALIAS (aggregate_address_as_set_summary,
5461 aggregate_address_summary_as_set_cmd,
5462 "aggregate-address A.B.C.D/M summary-only as-set",
5463 "Configure BGP aggregate entries\n"
5464 "Aggregate prefix\n"
5465 "Filter more specific routes from updates\n"
5466 "Generate AS set path information\n")
5467
5468DEFUN (aggregate_address_mask_as_set_summary,
5469 aggregate_address_mask_as_set_summary_cmd,
5470 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5471 "Configure BGP aggregate entries\n"
5472 "Aggregate address\n"
5473 "Aggregate mask\n"
5474 "Generate AS set path information\n"
5475 "Filter more specific routes from updates\n")
5476{
5477 int ret;
5478 char prefix_str[BUFSIZ];
5479
5480 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5481
5482 if (! ret)
5483 {
5484 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5485 return CMD_WARNING;
5486 }
5487
5488 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5489 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5490}
5491
5492ALIAS (aggregate_address_mask_as_set_summary,
5493 aggregate_address_mask_summary_as_set_cmd,
5494 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5495 "Configure BGP aggregate entries\n"
5496 "Aggregate address\n"
5497 "Aggregate mask\n"
5498 "Filter more specific routes from updates\n"
5499 "Generate AS set path information\n")
5500
5501DEFUN (no_aggregate_address,
5502 no_aggregate_address_cmd,
5503 "no aggregate-address A.B.C.D/M",
5504 NO_STR
5505 "Configure BGP aggregate entries\n"
5506 "Aggregate prefix\n")
5507{
5508 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5509}
5510
5511ALIAS (no_aggregate_address,
5512 no_aggregate_address_summary_only_cmd,
5513 "no aggregate-address A.B.C.D/M summary-only",
5514 NO_STR
5515 "Configure BGP aggregate entries\n"
5516 "Aggregate prefix\n"
5517 "Filter more specific routes from updates\n")
5518
5519ALIAS (no_aggregate_address,
5520 no_aggregate_address_as_set_cmd,
5521 "no aggregate-address A.B.C.D/M as-set",
5522 NO_STR
5523 "Configure BGP aggregate entries\n"
5524 "Aggregate prefix\n"
5525 "Generate AS set path information\n")
5526
5527ALIAS (no_aggregate_address,
5528 no_aggregate_address_as_set_summary_cmd,
5529 "no aggregate-address A.B.C.D/M as-set summary-only",
5530 NO_STR
5531 "Configure BGP aggregate entries\n"
5532 "Aggregate prefix\n"
5533 "Generate AS set path information\n"
5534 "Filter more specific routes from updates\n")
5535
5536ALIAS (no_aggregate_address,
5537 no_aggregate_address_summary_as_set_cmd,
5538 "no aggregate-address A.B.C.D/M summary-only as-set",
5539 NO_STR
5540 "Configure BGP aggregate entries\n"
5541 "Aggregate prefix\n"
5542 "Filter more specific routes from updates\n"
5543 "Generate AS set path information\n")
5544
5545DEFUN (no_aggregate_address_mask,
5546 no_aggregate_address_mask_cmd,
5547 "no aggregate-address A.B.C.D A.B.C.D",
5548 NO_STR
5549 "Configure BGP aggregate entries\n"
5550 "Aggregate address\n"
5551 "Aggregate mask\n")
5552{
5553 int ret;
5554 char prefix_str[BUFSIZ];
5555
5556 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5557
5558 if (! ret)
5559 {
5560 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5561 return CMD_WARNING;
5562 }
5563
5564 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5565}
5566
5567ALIAS (no_aggregate_address_mask,
5568 no_aggregate_address_mask_summary_only_cmd,
5569 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5570 NO_STR
5571 "Configure BGP aggregate entries\n"
5572 "Aggregate address\n"
5573 "Aggregate mask\n"
5574 "Filter more specific routes from updates\n")
5575
5576ALIAS (no_aggregate_address_mask,
5577 no_aggregate_address_mask_as_set_cmd,
5578 "no aggregate-address A.B.C.D A.B.C.D as-set",
5579 NO_STR
5580 "Configure BGP aggregate entries\n"
5581 "Aggregate address\n"
5582 "Aggregate mask\n"
5583 "Generate AS set path information\n")
5584
5585ALIAS (no_aggregate_address_mask,
5586 no_aggregate_address_mask_as_set_summary_cmd,
5587 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5588 NO_STR
5589 "Configure BGP aggregate entries\n"
5590 "Aggregate address\n"
5591 "Aggregate mask\n"
5592 "Generate AS set path information\n"
5593 "Filter more specific routes from updates\n")
5594
5595ALIAS (no_aggregate_address_mask,
5596 no_aggregate_address_mask_summary_as_set_cmd,
5597 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5598 NO_STR
5599 "Configure BGP aggregate entries\n"
5600 "Aggregate address\n"
5601 "Aggregate mask\n"
5602 "Filter more specific routes from updates\n"
5603 "Generate AS set path information\n")
5604
paul718e3742002-12-13 20:15:29 +00005605DEFUN (ipv6_aggregate_address,
5606 ipv6_aggregate_address_cmd,
5607 "aggregate-address X:X::X:X/M",
5608 "Configure BGP aggregate entries\n"
5609 "Aggregate prefix\n")
5610{
5611 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5612}
5613
5614DEFUN (ipv6_aggregate_address_summary_only,
5615 ipv6_aggregate_address_summary_only_cmd,
5616 "aggregate-address X:X::X:X/M summary-only",
5617 "Configure BGP aggregate entries\n"
5618 "Aggregate prefix\n"
5619 "Filter more specific routes from updates\n")
5620{
5621 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5622 AGGREGATE_SUMMARY_ONLY, 0);
5623}
5624
5625DEFUN (no_ipv6_aggregate_address,
5626 no_ipv6_aggregate_address_cmd,
5627 "no aggregate-address X:X::X:X/M",
5628 NO_STR
5629 "Configure BGP aggregate entries\n"
5630 "Aggregate prefix\n")
5631{
5632 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5633}
5634
5635DEFUN (no_ipv6_aggregate_address_summary_only,
5636 no_ipv6_aggregate_address_summary_only_cmd,
5637 "no aggregate-address X:X::X:X/M summary-only",
5638 NO_STR
5639 "Configure BGP aggregate entries\n"
5640 "Aggregate prefix\n"
5641 "Filter more specific routes from updates\n")
5642{
5643 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5644}
5645
5646ALIAS (ipv6_aggregate_address,
5647 old_ipv6_aggregate_address_cmd,
5648 "ipv6 bgp aggregate-address X:X::X:X/M",
5649 IPV6_STR
5650 BGP_STR
5651 "Configure BGP aggregate entries\n"
5652 "Aggregate prefix\n")
5653
5654ALIAS (ipv6_aggregate_address_summary_only,
5655 old_ipv6_aggregate_address_summary_only_cmd,
5656 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5657 IPV6_STR
5658 BGP_STR
5659 "Configure BGP aggregate entries\n"
5660 "Aggregate prefix\n"
5661 "Filter more specific routes from updates\n")
5662
5663ALIAS (no_ipv6_aggregate_address,
5664 old_no_ipv6_aggregate_address_cmd,
5665 "no ipv6 bgp aggregate-address X:X::X:X/M",
5666 NO_STR
5667 IPV6_STR
5668 BGP_STR
5669 "Configure BGP aggregate entries\n"
5670 "Aggregate prefix\n")
5671
5672ALIAS (no_ipv6_aggregate_address_summary_only,
5673 old_no_ipv6_aggregate_address_summary_only_cmd,
5674 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5675 NO_STR
5676 IPV6_STR
5677 BGP_STR
5678 "Configure BGP aggregate entries\n"
5679 "Aggregate prefix\n"
5680 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005681
paul718e3742002-12-13 20:15:29 +00005682/* Redistribute route treatment. */
5683void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005684bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5685 const struct in6_addr *nexthop6,
Paul Jakma96d10602016-07-01 14:23:45 +01005686 u_int32_t metric, u_char type, route_tag_t tag)
paul718e3742002-12-13 20:15:29 +00005687{
5688 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005689 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005690 struct bgp_info *new;
5691 struct bgp_info *bi;
5692 struct bgp_info info;
5693 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005694 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005695 struct attr *new_attr;
5696 afi_t afi;
5697 int ret;
5698
5699 /* Make default attribute. */
5700 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5701 if (nexthop)
5702 attr.nexthop = *nexthop;
5703
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005704 if (nexthop6)
5705 {
5706 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5707 extra->mp_nexthop_global = *nexthop6;
5708 extra->mp_nexthop_len = 16;
5709 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005710
paul718e3742002-12-13 20:15:29 +00005711 attr.med = metric;
5712 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Piotr Chytła605aa332015-12-01 10:03:54 -05005713 attr.extra->tag = tag;
paul718e3742002-12-13 20:15:29 +00005714
paul1eb8ef22005-04-07 07:30:20 +00005715 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005716 {
5717 afi = family2afi (p->family);
5718
5719 if (bgp->redist[afi][type])
5720 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005721 struct attr attr_new;
5722 struct attr_extra extra_new;
5723
paul718e3742002-12-13 20:15:29 +00005724 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005725 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005726 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005727
5728 if (bgp->redist_metric_flag[afi][type])
5729 attr_new.med = bgp->redist_metric[afi][type];
5730
5731 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005732 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005733 {
5734 info.peer = bgp->peer_self;
5735 info.attr = &attr_new;
5736
paulfee0f4c2004-09-13 05:12:46 +00005737 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5738
paul718e3742002-12-13 20:15:29 +00005739 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5740 &info);
paulfee0f4c2004-09-13 05:12:46 +00005741
5742 bgp->peer_self->rmap_type = 0;
5743
paul718e3742002-12-13 20:15:29 +00005744 if (ret == RMAP_DENYMATCH)
5745 {
5746 /* Free uninterned attribute. */
5747 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005748
paul718e3742002-12-13 20:15:29 +00005749 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005750 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005751 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005752 bgp_redistribute_delete (p, type);
5753 return;
5754 }
5755 }
5756
Paul Jakmafb982c22007-05-04 20:15:47 +00005757 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5758 afi, SAFI_UNICAST, p, NULL);
5759
paul718e3742002-12-13 20:15:29 +00005760 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005761
paul718e3742002-12-13 20:15:29 +00005762 for (bi = bn->info; bi; bi = bi->next)
5763 if (bi->peer == bgp->peer_self
5764 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5765 break;
5766
5767 if (bi)
5768 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005769 if (attrhash_cmp (bi->attr, new_attr) &&
5770 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005771 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005772 bgp_attr_unintern (&new_attr);
5773 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005774 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005775 bgp_unlock_node (bn);
5776 return;
5777 }
5778 else
5779 {
5780 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005781 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005782
5783 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005784 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5785 bgp_info_restore(bn, bi);
5786 else
5787 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005788 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005789 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005790 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005791
5792 /* Process change. */
5793 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5794 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5795 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005796 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005797 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005798 return;
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005799 }
paul718e3742002-12-13 20:15:29 +00005800 }
5801
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05005802 new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self,
5803 new_attr, bn);
paul718e3742002-12-13 20:15:29 +00005804 SET_FLAG (new->flags, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00005805
5806 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5807 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005808 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005809 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5810 }
5811 }
5812
5813 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005814 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005815 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005816}
5817
5818void
5819bgp_redistribute_delete (struct prefix *p, u_char type)
5820{
5821 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005822 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005823 afi_t afi;
5824 struct bgp_node *rn;
5825 struct bgp_info *ri;
5826
paul1eb8ef22005-04-07 07:30:20 +00005827 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005828 {
5829 afi = family2afi (p->family);
5830
5831 if (bgp->redist[afi][type])
5832 {
paulfee0f4c2004-09-13 05:12:46 +00005833 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005834
5835 for (ri = rn->info; ri; ri = ri->next)
5836 if (ri->peer == bgp->peer_self
5837 && ri->type == type)
5838 break;
5839
5840 if (ri)
5841 {
5842 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005843 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005844 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005845 }
5846 bgp_unlock_node (rn);
5847 }
5848 }
5849}
5850
5851/* Withdraw specified route type's route. */
5852void
5853bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5854{
5855 struct bgp_node *rn;
5856 struct bgp_info *ri;
5857 struct bgp_table *table;
5858
5859 table = bgp->rib[afi][SAFI_UNICAST];
5860
5861 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5862 {
5863 for (ri = rn->info; ri; ri = ri->next)
5864 if (ri->peer == bgp->peer_self
5865 && ri->type == type)
5866 break;
5867
5868 if (ri)
5869 {
5870 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005871 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005872 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005873 }
5874 }
5875}
David Lamparter6b0655a2014-06-04 06:53:35 +02005876
paul718e3742002-12-13 20:15:29 +00005877/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005878static void
paul718e3742002-12-13 20:15:29 +00005879route_vty_out_route (struct prefix *p, struct vty *vty)
5880{
5881 int len;
5882 u_int32_t destination;
5883 char buf[BUFSIZ];
5884
5885 if (p->family == AF_INET)
5886 {
5887 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5888 destination = ntohl (p->u.prefix4.s_addr);
5889
5890 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5891 || (IN_CLASSB (destination) && p->prefixlen == 16)
5892 || (IN_CLASSA (destination) && p->prefixlen == 8)
5893 || p->u.prefix4.s_addr == 0)
5894 {
5895 /* When mask is natural, mask is not displayed. */
5896 }
5897 else
5898 len += vty_out (vty, "/%d", p->prefixlen);
5899 }
5900 else
5901 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5902 p->prefixlen);
5903
5904 len = 17 - len;
5905 if (len < 1)
5906 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5907 else
5908 vty_out (vty, "%*s", len, " ");
5909}
5910
paul718e3742002-12-13 20:15:29 +00005911enum bgp_display_type
5912{
5913 normal_list,
5914};
5915
paulb40d9392005-08-22 22:34:41 +00005916/* Print the short form route status for a bgp_info */
5917static void
5918route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005919{
paulb40d9392005-08-22 22:34:41 +00005920 /* Route status display. */
5921 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5922 vty_out (vty, "R");
5923 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005924 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005925 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005926 vty_out (vty, "s");
Daniel Waltone2a0ebf2015-05-19 18:03:43 -07005927 else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) &&
5928 ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
paul718e3742002-12-13 20:15:29 +00005929 vty_out (vty, "*");
5930 else
5931 vty_out (vty, " ");
5932
5933 /* Selected */
5934 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5935 vty_out (vty, "h");
5936 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5937 vty_out (vty, "d");
5938 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5939 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005940 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5941 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005942 else
5943 vty_out (vty, " ");
5944
5945 /* Internal route. */
5946 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5947 vty_out (vty, "i");
5948 else
paulb40d9392005-08-22 22:34:41 +00005949 vty_out (vty, " ");
5950}
5951
5952/* called from terminal list command */
5953void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005954route_vty_out(
5955 struct vty *vty,
5956 struct prefix *p,
5957 struct bgp_info *binfo,
5958 int display,
5959 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005960{
5961 struct attr *attr;
5962
5963 /* short status lead text */
5964 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005965
5966 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005967 if (!display)
paul718e3742002-12-13 20:15:29 +00005968 route_vty_out_route (p, vty);
5969 else
5970 vty_out (vty, "%*s", 17, " ");
5971
5972 /* Print attribute */
5973 attr = binfo->attr;
5974 if (attr)
5975 {
paul718e3742002-12-13 20:15:29 +00005976
Lou Berger298cc2f2016-01-12 13:42:02 -05005977 /*
5978 * NEXTHOP start
5979 */
5980
5981 /*
5982 * For ENCAP routes, nexthop address family is not
5983 * neccessarily the same as the prefix address family.
5984 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5985 */
5986 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5987 if (attr->extra) {
5988 char buf[BUFSIZ];
5989 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5990
5991 switch (af) {
5992 case AF_INET:
5993 vty_out (vty, "%s", inet_ntop(af,
5994 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5995 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005996 case AF_INET6:
5997 vty_out (vty, "%s", inet_ntop(af,
5998 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
5999 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05006000 default:
6001 vty_out(vty, "?");
6002 }
6003 } else {
6004 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00006005 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006006 } else {
6007
6008 if (p->family == AF_INET)
6009 {
6010 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6011 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006012 else if (p->family == AF_INET6)
6013 {
6014 int len;
6015 char buf[BUFSIZ];
6016
6017 len = vty_out (vty, "%s",
6018 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6019 buf, BUFSIZ));
6020 len = 16 - len;
6021 if (len < 1)
6022 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6023 else
6024 vty_out (vty, "%*s", len, " ");
6025 }
Lou Berger298cc2f2016-01-12 13:42:02 -05006026 else
6027 {
6028 vty_out(vty, "?");
6029 }
6030 }
6031
6032 /*
6033 * NEXTHOP end
6034 */
6035
paul718e3742002-12-13 20:15:29 +00006036
6037 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Daniel Walton4d48bb32016-11-29 12:47:12 -05006038 vty_out (vty, "%10u", attr->med);
paul718e3742002-12-13 20:15:29 +00006039 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006040 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006041
6042 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Daniel Walton4d48bb32016-11-29 12:47:12 -05006043 vty_out (vty, "%7u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006044 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006045 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006046
Paul Jakmafb982c22007-05-04 20:15:47 +00006047 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00006048
Paul Jakmab2518c12006-05-12 23:48:40 +00006049 /* Print aspath */
6050 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006051 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006052
Paul Jakmab2518c12006-05-12 23:48:40 +00006053 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006054 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006055 }
paul718e3742002-12-13 20:15:29 +00006056 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006057}
6058
6059/* called from terminal list command */
6060void
6061route_vty_out_tmp (struct vty *vty, struct prefix *p,
6062 struct attr *attr, safi_t safi)
6063{
6064 /* Route status display. */
6065 vty_out (vty, "*");
6066 vty_out (vty, ">");
6067 vty_out (vty, " ");
6068
6069 /* print prefix and mask */
6070 route_vty_out_route (p, vty);
6071
6072 /* Print attribute */
6073 if (attr)
6074 {
6075 if (p->family == AF_INET)
6076 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006077 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006078 vty_out (vty, "%-16s",
6079 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006080 else
6081 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6082 }
paul718e3742002-12-13 20:15:29 +00006083 else if (p->family == AF_INET6)
6084 {
6085 int len;
6086 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006087
6088 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006089
6090 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006091 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6092 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006093 len = 16 - len;
6094 if (len < 1)
6095 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6096 else
6097 vty_out (vty, "%*s", len, " ");
6098 }
paul718e3742002-12-13 20:15:29 +00006099
6100 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006101 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006102 else
6103 vty_out (vty, " ");
6104
6105 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006106 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006107 else
6108 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006109
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006110 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006111
Paul Jakmab2518c12006-05-12 23:48:40 +00006112 /* Print aspath */
6113 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006114 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006115
Paul Jakmab2518c12006-05-12 23:48:40 +00006116 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006117 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006118 }
paul718e3742002-12-13 20:15:29 +00006119
6120 vty_out (vty, "%s", VTY_NEWLINE);
6121}
6122
ajs5a646652004-11-05 01:25:55 +00006123void
paul718e3742002-12-13 20:15:29 +00006124route_vty_out_tag (struct vty *vty, struct prefix *p,
6125 struct bgp_info *binfo, int display, safi_t safi)
6126{
6127 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006128 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006129
6130 if (!binfo->extra)
6131 return;
6132
paulb40d9392005-08-22 22:34:41 +00006133 /* short status lead text */
6134 route_vty_short_status_out (vty, binfo);
6135
paul718e3742002-12-13 20:15:29 +00006136 /* print prefix and mask */
6137 if (! display)
6138 route_vty_out_route (p, vty);
6139 else
6140 vty_out (vty, "%*s", 17, " ");
6141
6142 /* Print attribute */
6143 attr = binfo->attr;
6144 if (attr)
6145 {
6146 if (p->family == AF_INET)
6147 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006148 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006149 vty_out (vty, "%-16s",
6150 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006151 else
6152 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6153 }
paul718e3742002-12-13 20:15:29 +00006154 else if (p->family == AF_INET6)
6155 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006156 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006157 char buf[BUFSIZ];
6158 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006159 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006160 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006161 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6162 buf, BUFSIZ));
6163 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006164 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006165 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6166 buf, BUFSIZ),
6167 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6168 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006169
6170 }
paul718e3742002-12-13 20:15:29 +00006171 }
6172
Paul Jakmafb982c22007-05-04 20:15:47 +00006173 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006174
6175 vty_out (vty, "notag/%d", label);
6176
6177 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006178}
6179
6180/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006181static void
paul718e3742002-12-13 20:15:29 +00006182damp_route_vty_out (struct vty *vty, struct prefix *p,
6183 struct bgp_info *binfo, int display, safi_t safi)
6184{
6185 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006186 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006187 char timebuf[BGP_UPTIME_LEN];
paul718e3742002-12-13 20:15:29 +00006188
paulb40d9392005-08-22 22:34:41 +00006189 /* short status lead text */
6190 route_vty_short_status_out (vty, binfo);
6191
paul718e3742002-12-13 20:15:29 +00006192 /* print prefix and mask */
6193 if (! display)
6194 route_vty_out_route (p, vty);
6195 else
6196 vty_out (vty, "%*s", 17, " ");
6197
6198 len = vty_out (vty, "%s", binfo->peer->host);
6199 len = 17 - len;
6200 if (len < 1)
6201 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6202 else
6203 vty_out (vty, "%*s", len, " ");
6204
Chris Caputo50aef6f2009-06-23 06:06:49 +00006205 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006206
6207 /* Print attribute */
6208 attr = binfo->attr;
6209 if (attr)
6210 {
6211 /* Print aspath */
6212 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006213 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006214
6215 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006216 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006217 }
6218 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006219}
6220
paul718e3742002-12-13 20:15:29 +00006221/* flap route */
ajs5a646652004-11-05 01:25:55 +00006222static void
paul718e3742002-12-13 20:15:29 +00006223flap_route_vty_out (struct vty *vty, struct prefix *p,
6224 struct bgp_info *binfo, int display, safi_t safi)
6225{
6226 struct attr *attr;
6227 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006228 char timebuf[BGP_UPTIME_LEN];
6229 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006230
6231 if (!binfo->extra)
6232 return;
6233
6234 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006235
paulb40d9392005-08-22 22:34:41 +00006236 /* short status lead text */
6237 route_vty_short_status_out (vty, binfo);
6238
paul718e3742002-12-13 20:15:29 +00006239 /* print prefix and mask */
6240 if (! display)
6241 route_vty_out_route (p, vty);
6242 else
6243 vty_out (vty, "%*s", 17, " ");
6244
6245 len = vty_out (vty, "%s", binfo->peer->host);
6246 len = 16 - len;
6247 if (len < 1)
6248 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6249 else
6250 vty_out (vty, "%*s", len, " ");
6251
6252 len = vty_out (vty, "%d", bdi->flap);
6253 len = 5 - len;
6254 if (len < 1)
6255 vty_out (vty, " ");
6256 else
6257 vty_out (vty, "%*s ", len, " ");
6258
6259 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6260 timebuf, BGP_UPTIME_LEN));
6261
6262 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6263 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006264 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006265 else
6266 vty_out (vty, "%*s ", 8, " ");
6267
6268 /* Print attribute */
6269 attr = binfo->attr;
6270 if (attr)
6271 {
6272 /* Print aspath */
6273 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006274 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006275
6276 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006277 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006278 }
6279 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006280}
6281
paul94f2b392005-06-28 12:44:16 +00006282static void
paul718e3742002-12-13 20:15:29 +00006283route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6284 struct bgp_info *binfo, afi_t afi, safi_t safi)
6285{
6286 char buf[INET6_ADDRSTRLEN];
6287 char buf1[BUFSIZ];
6288 struct attr *attr;
6289 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006290#ifdef HAVE_CLOCK_MONOTONIC
6291 time_t tbuf;
6292#endif
paul718e3742002-12-13 20:15:29 +00006293
6294 attr = binfo->attr;
6295
6296 if (attr)
6297 {
6298 /* Line1 display AS-path, Aggregator */
6299 if (attr->aspath)
6300 {
6301 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006302 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006303 vty_out (vty, "Local");
6304 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006305 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006306 }
6307
paulb40d9392005-08-22 22:34:41 +00006308 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6309 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006310 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6311 vty_out (vty, ", (stale)");
6312 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006313 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006314 attr->extra->aggregator_as,
6315 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006316 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6317 vty_out (vty, ", (Received from a RR-client)");
6318 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6319 vty_out (vty, ", (Received from a RS-client)");
6320 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6321 vty_out (vty, ", (history entry)");
6322 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6323 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006324 vty_out (vty, "%s", VTY_NEWLINE);
6325
6326 /* Line2 display Next-hop, Neighbor, Router-id */
6327 if (p->family == AF_INET)
6328 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006329 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006330 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006331 inet_ntoa (attr->nexthop));
6332 }
paul718e3742002-12-13 20:15:29 +00006333 else
6334 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006335 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006336 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006337 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006338 buf, INET6_ADDRSTRLEN));
6339 }
paul718e3742002-12-13 20:15:29 +00006340
6341 if (binfo->peer == bgp->peer_self)
6342 {
6343 vty_out (vty, " from %s ",
6344 p->family == AF_INET ? "0.0.0.0" : "::");
6345 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6346 }
6347 else
6348 {
6349 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6350 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006351 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006352 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006353 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6354 buf[0] = '?';
6355 buf[1] = 0;
6356 }
6357 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006358 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006359 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006360 else
6361 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6362 }
6363 vty_out (vty, "%s", VTY_NEWLINE);
6364
paul718e3742002-12-13 20:15:29 +00006365 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006366 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006367 {
6368 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006369 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006370 buf, INET6_ADDRSTRLEN),
6371 VTY_NEWLINE);
6372 }
paul718e3742002-12-13 20:15:29 +00006373
Piotr Chytła605aa332015-12-01 10:03:54 -05006374 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
paul718e3742002-12-13 20:15:29 +00006375 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6376
6377 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006378 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006379
6380 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006381 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006382 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006383 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006384
Paul Jakmafb982c22007-05-04 20:15:47 +00006385 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006386 vty_out (vty, ", weight %u", attr->extra->weight);
Piotr Chytła605aa332015-12-01 10:03:54 -05006387
6388 if (attr->extra && attr->extra->tag != 0)
6389 vty_out (vty, ", tag %d", attr->extra->tag);
paul718e3742002-12-13 20:15:29 +00006390
Daniel Waltone2a0ebf2015-05-19 18:03:43 -07006391 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6392 vty_out (vty, ", invalid");
6393 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
paul718e3742002-12-13 20:15:29 +00006394 vty_out (vty, ", valid");
6395
6396 if (binfo->peer != bgp->peer_self)
6397 {
6398 if (binfo->peer->as == binfo->peer->local_as)
6399 vty_out (vty, ", internal");
6400 else
6401 vty_out (vty, ", %s",
6402 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6403 }
6404 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6405 vty_out (vty, ", aggregated, local");
6406 else if (binfo->type != ZEBRA_ROUTE_BGP)
6407 vty_out (vty, ", sourced");
6408 else
6409 vty_out (vty, ", sourced, local");
6410
6411 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6412 vty_out (vty, ", atomic-aggregate");
6413
Josh Baileyde8d5df2011-07-20 20:46:01 -07006414 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6415 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6416 bgp_info_mpath_count (binfo)))
6417 vty_out (vty, ", multipath");
6418
paul718e3742002-12-13 20:15:29 +00006419 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6420 vty_out (vty, ", best");
6421
6422 vty_out (vty, "%s", VTY_NEWLINE);
6423
6424 /* Line 4 display Community */
6425 if (attr->community)
6426 vty_out (vty, " Community: %s%s", attr->community->str,
6427 VTY_NEWLINE);
6428
6429 /* Line 5 display Extended-community */
6430 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006431 vty_out (vty, " Extended Community: %s%s",
6432 attr->extra->ecommunity->str, VTY_NEWLINE);
Job Snijders3334bab2017-01-20 14:47:12 +00006433
6434 /* Line 6 display Large community */
6435 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))
6436 vty_out (vty, " Large Community: %s%s",
6437 attr->extra->lcommunity->str, VTY_NEWLINE);
6438
6439 /* Line 7 display Originator, Cluster-id */
paul718e3742002-12-13 20:15:29 +00006440 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6441 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6442 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006443 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006444 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006445 vty_out (vty, " Originator: %s",
6446 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006447
6448 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6449 {
6450 int i;
6451 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006452 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6453 vty_out (vty, "%s ",
6454 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006455 }
6456 vty_out (vty, "%s", VTY_NEWLINE);
6457 }
Paul Jakma41367172007-08-06 15:24:51 +00006458
Paul Jakmafb982c22007-05-04 20:15:47 +00006459 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006460 bgp_damp_info_vty (vty, binfo);
6461
Job Snijders3334bab2017-01-20 14:47:12 +00006462 /* Line 8 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006463#ifdef HAVE_CLOCK_MONOTONIC
6464 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006465 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006466#else
6467 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6468#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006469 }
6470 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006471}
6472
6473#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6474 "h history, * valid, > best, = multipath,%s"\
6475 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006476#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006477#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6478#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6479#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6480
6481enum bgp_show_type
6482{
6483 bgp_show_type_normal,
6484 bgp_show_type_regexp,
6485 bgp_show_type_prefix_list,
6486 bgp_show_type_filter_list,
6487 bgp_show_type_route_map,
6488 bgp_show_type_neighbor,
6489 bgp_show_type_cidr_only,
6490 bgp_show_type_prefix_longer,
6491 bgp_show_type_community_all,
6492 bgp_show_type_community,
6493 bgp_show_type_community_exact,
6494 bgp_show_type_community_list,
6495 bgp_show_type_community_list_exact,
Job Snijders3334bab2017-01-20 14:47:12 +00006496 bgp_show_type_lcommunity_all,
6497 bgp_show_type_lcommunity,
6498 bgp_show_type_lcommunity_list,
paul718e3742002-12-13 20:15:29 +00006499 bgp_show_type_flap_statistics,
6500 bgp_show_type_flap_address,
6501 bgp_show_type_flap_prefix,
6502 bgp_show_type_flap_cidr_only,
6503 bgp_show_type_flap_regexp,
6504 bgp_show_type_flap_filter_list,
6505 bgp_show_type_flap_prefix_list,
6506 bgp_show_type_flap_prefix_longer,
6507 bgp_show_type_flap_route_map,
6508 bgp_show_type_flap_neighbor,
6509 bgp_show_type_dampend_paths,
6510 bgp_show_type_damp_neighbor
6511};
6512
ajs5a646652004-11-05 01:25:55 +00006513static int
paulfee0f4c2004-09-13 05:12:46 +00006514bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006515 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006516{
paul718e3742002-12-13 20:15:29 +00006517 struct bgp_info *ri;
6518 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006519 int header = 1;
paul718e3742002-12-13 20:15:29 +00006520 int display;
ajs5a646652004-11-05 01:25:55 +00006521 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006522 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006523
6524 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006525 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006526 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006527
paul718e3742002-12-13 20:15:29 +00006528 /* Start processing of routes. */
6529 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6530 if (rn->info != NULL)
6531 {
6532 display = 0;
6533
6534 for (ri = rn->info; ri; ri = ri->next)
6535 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006536 total_count++;
ajs5a646652004-11-05 01:25:55 +00006537 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006538 || type == bgp_show_type_flap_address
6539 || type == bgp_show_type_flap_prefix
6540 || type == bgp_show_type_flap_cidr_only
6541 || type == bgp_show_type_flap_regexp
6542 || type == bgp_show_type_flap_filter_list
6543 || type == bgp_show_type_flap_prefix_list
6544 || type == bgp_show_type_flap_prefix_longer
6545 || type == bgp_show_type_flap_route_map
6546 || type == bgp_show_type_flap_neighbor
6547 || type == bgp_show_type_dampend_paths
6548 || type == bgp_show_type_damp_neighbor)
6549 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006550 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006551 continue;
6552 }
6553 if (type == bgp_show_type_regexp
6554 || type == bgp_show_type_flap_regexp)
6555 {
ajs5a646652004-11-05 01:25:55 +00006556 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006557
6558 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6559 continue;
6560 }
6561 if (type == bgp_show_type_prefix_list
6562 || type == bgp_show_type_flap_prefix_list)
6563 {
ajs5a646652004-11-05 01:25:55 +00006564 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006565
6566 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6567 continue;
6568 }
6569 if (type == bgp_show_type_filter_list
6570 || type == bgp_show_type_flap_filter_list)
6571 {
ajs5a646652004-11-05 01:25:55 +00006572 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006573
6574 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6575 continue;
6576 }
6577 if (type == bgp_show_type_route_map
6578 || type == bgp_show_type_flap_route_map)
6579 {
ajs5a646652004-11-05 01:25:55 +00006580 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006581 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006582 struct attr dummy_attr;
6583 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006584 int ret;
6585
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006586 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006587 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006588
paul718e3742002-12-13 20:15:29 +00006589 binfo.peer = ri->peer;
6590 binfo.attr = &dummy_attr;
6591
6592 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006593 if (ret == RMAP_DENYMATCH)
6594 continue;
6595 }
6596 if (type == bgp_show_type_neighbor
6597 || type == bgp_show_type_flap_neighbor
6598 || type == bgp_show_type_damp_neighbor)
6599 {
ajs5a646652004-11-05 01:25:55 +00006600 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006601
6602 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6603 continue;
6604 }
6605 if (type == bgp_show_type_cidr_only
6606 || type == bgp_show_type_flap_cidr_only)
6607 {
6608 u_int32_t destination;
6609
6610 destination = ntohl (rn->p.u.prefix4.s_addr);
6611 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6612 continue;
6613 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6614 continue;
6615 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6616 continue;
6617 }
6618 if (type == bgp_show_type_prefix_longer
6619 || type == bgp_show_type_flap_prefix_longer)
6620 {
ajs5a646652004-11-05 01:25:55 +00006621 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006622
6623 if (! prefix_match (p, &rn->p))
6624 continue;
6625 }
6626 if (type == bgp_show_type_community_all)
6627 {
6628 if (! ri->attr->community)
6629 continue;
6630 }
6631 if (type == bgp_show_type_community)
6632 {
ajs5a646652004-11-05 01:25:55 +00006633 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006634
6635 if (! ri->attr->community ||
6636 ! community_match (ri->attr->community, com))
6637 continue;
6638 }
6639 if (type == bgp_show_type_community_exact)
6640 {
ajs5a646652004-11-05 01:25:55 +00006641 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006642
6643 if (! ri->attr->community ||
6644 ! community_cmp (ri->attr->community, com))
6645 continue;
6646 }
6647 if (type == bgp_show_type_community_list)
6648 {
ajs5a646652004-11-05 01:25:55 +00006649 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006650
6651 if (! community_list_match (ri->attr->community, list))
6652 continue;
6653 }
6654 if (type == bgp_show_type_community_list_exact)
6655 {
ajs5a646652004-11-05 01:25:55 +00006656 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006657
6658 if (! community_list_exact_match (ri->attr->community, list))
6659 continue;
6660 }
Job Snijders3334bab2017-01-20 14:47:12 +00006661 if (type == bgp_show_type_community_all)
6662 {
6663 if (! ri->attr->community)
6664 continue;
6665 }
6666 if (type == bgp_show_type_lcommunity)
6667 {
6668 struct lcommunity *lcom = output_arg;
6669
6670 if (! ri->attr->extra || ! ri->attr->extra->lcommunity ||
6671 ! lcommunity_match (ri->attr->extra->lcommunity, lcom))
6672 continue;
6673 }
6674 if (type == bgp_show_type_lcommunity_list)
6675 {
6676 struct community_list *list = output_arg;
6677
6678 if (! ri->attr->extra ||
6679 ! lcommunity_list_match (ri->attr->extra->lcommunity, list))
6680 continue;
6681 }
6682 if (type == bgp_show_type_lcommunity_all)
6683 {
6684 if (! ri->attr->extra || ! ri->attr->extra->lcommunity)
6685 continue;
6686 }
paul718e3742002-12-13 20:15:29 +00006687 if (type == bgp_show_type_flap_address
6688 || type == bgp_show_type_flap_prefix)
6689 {
ajs5a646652004-11-05 01:25:55 +00006690 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006691
6692 if (! prefix_match (&rn->p, p))
6693 continue;
6694
6695 if (type == bgp_show_type_flap_prefix)
6696 if (p->prefixlen != rn->p.prefixlen)
6697 continue;
6698 }
6699 if (type == bgp_show_type_dampend_paths
6700 || type == bgp_show_type_damp_neighbor)
6701 {
6702 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6703 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6704 continue;
6705 }
6706
6707 if (header)
6708 {
hasso93406d82005-02-02 14:40:33 +00006709 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6710 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6711 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006712 if (type == bgp_show_type_dampend_paths
6713 || type == bgp_show_type_damp_neighbor)
6714 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6715 else if (type == bgp_show_type_flap_statistics
6716 || type == bgp_show_type_flap_address
6717 || type == bgp_show_type_flap_prefix
6718 || type == bgp_show_type_flap_cidr_only
6719 || type == bgp_show_type_flap_regexp
6720 || type == bgp_show_type_flap_filter_list
6721 || type == bgp_show_type_flap_prefix_list
6722 || type == bgp_show_type_flap_prefix_longer
6723 || type == bgp_show_type_flap_route_map
6724 || type == bgp_show_type_flap_neighbor)
6725 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6726 else
6727 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006728 header = 0;
6729 }
6730
6731 if (type == bgp_show_type_dampend_paths
6732 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006733 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006734 else if (type == bgp_show_type_flap_statistics
6735 || type == bgp_show_type_flap_address
6736 || type == bgp_show_type_flap_prefix
6737 || type == bgp_show_type_flap_cidr_only
6738 || type == bgp_show_type_flap_regexp
6739 || type == bgp_show_type_flap_filter_list
6740 || type == bgp_show_type_flap_prefix_list
6741 || type == bgp_show_type_flap_prefix_longer
6742 || type == bgp_show_type_flap_route_map
6743 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006744 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006745 else
ajs5a646652004-11-05 01:25:55 +00006746 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006747 display++;
6748 }
6749 if (display)
ajs5a646652004-11-05 01:25:55 +00006750 output_count++;
paul718e3742002-12-13 20:15:29 +00006751 }
6752
6753 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006754 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006755 {
6756 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006757 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006758 }
6759 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006760 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6761 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006762
6763 return CMD_SUCCESS;
6764}
6765
ajs5a646652004-11-05 01:25:55 +00006766static int
paulfee0f4c2004-09-13 05:12:46 +00006767bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006768 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006769{
6770 struct bgp_table *table;
6771
6772 if (bgp == NULL) {
6773 bgp = bgp_get_default ();
6774 }
6775
6776 if (bgp == NULL)
6777 {
6778 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6779 return CMD_WARNING;
6780 }
6781
6782
6783 table = bgp->rib[afi][safi];
6784
ajs5a646652004-11-05 01:25:55 +00006785 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006786}
6787
paul718e3742002-12-13 20:15:29 +00006788/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006789static void
paul718e3742002-12-13 20:15:29 +00006790route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6791 struct bgp_node *rn,
6792 struct prefix_rd *prd, afi_t afi, safi_t safi)
6793{
6794 struct bgp_info *ri;
6795 struct prefix *p;
6796 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006797 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006798 char buf1[INET6_ADDRSTRLEN];
6799 char buf2[INET6_ADDRSTRLEN];
6800 int count = 0;
6801 int best = 0;
6802 int suppress = 0;
6803 int no_export = 0;
6804 int no_advertise = 0;
6805 int local_as = 0;
6806 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006807 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006808
6809 p = &rn->p;
6810 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006811 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6812 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006813 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6814 p->prefixlen, VTY_NEWLINE);
6815
6816 for (ri = rn->info; ri; ri = ri->next)
6817 {
6818 count++;
6819 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6820 {
6821 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006822 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006823 suppress = 1;
6824 if (ri->attr->community != NULL)
6825 {
6826 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6827 no_advertise = 1;
6828 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6829 no_export = 1;
6830 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6831 local_as = 1;
6832 }
6833 }
6834 }
6835
6836 vty_out (vty, "Paths: (%d available", count);
6837 if (best)
6838 {
6839 vty_out (vty, ", best #%d", best);
6840 if (safi == SAFI_UNICAST)
6841 vty_out (vty, ", table Default-IP-Routing-Table");
6842 }
6843 else
6844 vty_out (vty, ", no best path");
6845 if (no_advertise)
6846 vty_out (vty, ", not advertised to any peer");
6847 else if (no_export)
6848 vty_out (vty, ", not advertised to EBGP peer");
6849 else if (local_as)
6850 vty_out (vty, ", not advertised outside local AS");
6851 if (suppress)
6852 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6853 vty_out (vty, ")%s", VTY_NEWLINE);
6854
6855 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006856 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006857 {
6858 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6859 {
6860 if (! first)
6861 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6862 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6863 first = 1;
6864 }
6865 }
6866 if (! first)
6867 vty_out (vty, " Not advertised to any peer");
6868 vty_out (vty, "%s", VTY_NEWLINE);
6869}
6870
6871/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006872static int
paulfee0f4c2004-09-13 05:12:46 +00006873bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006874 struct bgp_table *rib, const char *ip_str,
6875 afi_t afi, safi_t safi, struct prefix_rd *prd,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006876 int prefix_check, enum bgp_path_type pathtype)
paul718e3742002-12-13 20:15:29 +00006877{
6878 int ret;
6879 int header;
6880 int display = 0;
6881 struct prefix match;
6882 struct bgp_node *rn;
6883 struct bgp_node *rm;
6884 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006885 struct bgp_table *table;
6886
Lou Berger050defe2016-01-12 13:41:59 -05006887 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006888 /* Check IP address argument. */
6889 ret = str2prefix (ip_str, &match);
6890 if (! ret)
6891 {
6892 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6893 return CMD_WARNING;
6894 }
6895
6896 match.family = afi2family (afi);
6897
Lou Berger298cc2f2016-01-12 13:42:02 -05006898 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006899 {
paulfee0f4c2004-09-13 05:12:46 +00006900 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006901 {
6902 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6903 continue;
6904
6905 if ((table = rn->info) != NULL)
6906 {
6907 header = 1;
6908
6909 if ((rm = bgp_node_match (table, &match)) != NULL)
6910 {
6911 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006912 {
6913 bgp_unlock_node (rm);
6914 continue;
6915 }
paul718e3742002-12-13 20:15:29 +00006916
6917 for (ri = rm->info; ri; ri = ri->next)
6918 {
6919 if (header)
6920 {
6921 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006922 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006923
6924 header = 0;
6925 }
6926 display++;
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006927
6928 if (pathtype == BGP_PATH_ALL ||
6929 (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) ||
6930 (pathtype == BGP_PATH_MULTIPATH &&
6931 (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))))
6932 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006933 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006934
6935 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006936 }
6937 }
6938 }
6939 }
6940 else
6941 {
6942 header = 1;
6943
paulfee0f4c2004-09-13 05:12:46 +00006944 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006945 {
6946 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6947 {
6948 for (ri = rn->info; ri; ri = ri->next)
6949 {
6950 if (header)
6951 {
6952 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6953 header = 0;
6954 }
6955 display++;
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006956
6957 if (pathtype == BGP_PATH_ALL ||
6958 (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) ||
6959 (pathtype == BGP_PATH_MULTIPATH &&
6960 (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))))
6961 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00006962 }
6963 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006964
6965 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006966 }
6967 }
6968
6969 if (! display)
6970 {
6971 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6972 return CMD_WARNING;
6973 }
6974
6975 return CMD_SUCCESS;
6976}
6977
paulfee0f4c2004-09-13 05:12:46 +00006978/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006979static int
paulfd79ac92004-10-13 05:06:08 +00006980bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006981 afi_t afi, safi_t safi, struct prefix_rd *prd,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07006982 int prefix_check, enum bgp_path_type pathtype)
paulfee0f4c2004-09-13 05:12:46 +00006983{
6984 struct bgp *bgp;
6985
6986 /* BGP structure lookup. */
6987 if (view_name)
6988 {
6989 bgp = bgp_lookup_by_name (view_name);
6990 if (bgp == NULL)
6991 {
6992 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6993 return CMD_WARNING;
6994 }
6995 }
6996 else
6997 {
6998 bgp = bgp_get_default ();
6999 if (bgp == NULL)
7000 {
7001 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
7002 return CMD_WARNING;
7003 }
7004 }
7005
7006 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007007 afi, safi, prd, prefix_check, pathtype);
paulfee0f4c2004-09-13 05:12:46 +00007008}
7009
paul718e3742002-12-13 20:15:29 +00007010/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05007011DEFUN (show_ip_bgp,
7012 show_ip_bgp_cmd,
7013 "show ip bgp",
7014 SHOW_STR
7015 IP_STR
7016 BGP_STR)
7017{
7018 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7019}
7020
7021DEFUN (show_ip_bgp_ipv4,
7022 show_ip_bgp_ipv4_cmd,
7023 "show ip bgp ipv4 (unicast|multicast)",
7024 SHOW_STR
7025 IP_STR
7026 BGP_STR
7027 "Address family\n"
7028 "Address Family modifier\n"
7029 "Address Family modifier\n")
7030{
7031 if (strncmp (argv[0], "m", 1) == 0)
7032 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7033 NULL);
7034
7035 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7036}
7037
7038DEFUN (show_ip_bgp_route,
7039 show_ip_bgp_route_cmd,
7040 "show ip bgp A.B.C.D",
7041 SHOW_STR
7042 IP_STR
7043 BGP_STR
7044 "Network in the BGP routing table to display\n")
7045{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007046 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7047}
7048
7049DEFUN (show_ip_bgp_route_pathtype,
7050 show_ip_bgp_route_pathtype_cmd,
7051 "show ip bgp A.B.C.D (bestpath|multipath)",
7052 SHOW_STR
7053 IP_STR
7054 BGP_STR
7055 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7056 "Display only the bestpath\n"
7057 "Display only multipaths\n")
7058{
7059 if (strncmp (argv[1], "b", 1) == 0)
7060 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7061 else
7062 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7063}
7064
7065DEFUN (show_bgp_ipv4_safi_route_pathtype,
7066 show_bgp_ipv4_safi_route_pathtype_cmd,
7067 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath)",
7068 SHOW_STR
7069 BGP_STR
7070 "Address family\n"
7071 "Address Family modifier\n"
7072 "Address Family modifier\n"
7073 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7074 "Display only the bestpath\n"
7075 "Display only multipaths\n")
7076{
7077 if (strncmp (argv[0], "m", 1) == 0)
7078 if (strncmp (argv[2], "b", 1) == 0)
7079 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH);
7080 else
7081 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH);
7082 else
7083 if (strncmp (argv[2], "b", 1) == 0)
7084 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7085 else
7086 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007087}
7088
7089DEFUN (show_ip_bgp_ipv4_route,
7090 show_ip_bgp_ipv4_route_cmd,
7091 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
7092 SHOW_STR
7093 IP_STR
7094 BGP_STR
7095 "Address family\n"
7096 "Address Family modifier\n"
7097 "Address Family modifier\n"
7098 "Network in the BGP routing table to display\n")
7099{
7100 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007101 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007102
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007103 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007104}
7105
7106DEFUN (show_ip_bgp_vpnv4_all_route,
7107 show_ip_bgp_vpnv4_all_route_cmd,
7108 "show ip bgp vpnv4 all A.B.C.D",
7109 SHOW_STR
7110 IP_STR
7111 BGP_STR
7112 "Display VPNv4 NLRI specific information\n"
7113 "Display information about all VPNv4 NLRIs\n"
7114 "Network in the BGP routing table to display\n")
7115{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007116 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 -05007117}
7118
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007119
Lou Bergerf9b6c392016-01-12 13:42:09 -05007120DEFUN (show_ip_bgp_vpnv4_rd_route,
7121 show_ip_bgp_vpnv4_rd_route_cmd,
7122 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
7123 SHOW_STR
7124 IP_STR
7125 BGP_STR
7126 "Display VPNv4 NLRI specific information\n"
7127 "Display information for a route distinguisher\n"
7128 "VPN Route Distinguisher\n"
7129 "Network in the BGP routing table to display\n")
7130{
7131 int ret;
7132 struct prefix_rd prd;
7133
7134 ret = str2prefix_rd (argv[0], &prd);
7135 if (! ret)
7136 {
7137 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7138 return CMD_WARNING;
7139 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007140 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 -05007141}
7142
7143DEFUN (show_ip_bgp_prefix,
7144 show_ip_bgp_prefix_cmd,
7145 "show ip bgp A.B.C.D/M",
7146 SHOW_STR
7147 IP_STR
7148 BGP_STR
7149 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7150{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007151 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7152}
7153
7154DEFUN (show_ip_bgp_prefix_pathtype,
7155 show_ip_bgp_prefix_pathtype_cmd,
7156 "show ip bgp A.B.C.D/M (bestpath|multipath)",
7157 SHOW_STR
7158 IP_STR
7159 BGP_STR
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[1], "b", 1) == 0)
7165 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7166 else
7167 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007168}
7169
7170DEFUN (show_ip_bgp_ipv4_prefix,
7171 show_ip_bgp_ipv4_prefix_cmd,
7172 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
7173 SHOW_STR
7174 IP_STR
7175 BGP_STR
7176 "Address family\n"
7177 "Address Family modifier\n"
7178 "Address Family modifier\n"
7179 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7180{
7181 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007182 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007183
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007184 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007185}
7186
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007187DEFUN (show_ip_bgp_ipv4_prefix_pathtype,
7188 show_ip_bgp_ipv4_prefix_pathtype_cmd,
7189 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)",
7190 SHOW_STR
7191 IP_STR
7192 BGP_STR
7193 "Address family\n"
7194 "Address Family modifier\n"
7195 "Address Family modifier\n"
7196 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7197 "Display only the bestpath\n"
7198 "Display only multipaths\n")
7199{
7200 if (strncmp (argv[0], "m", 1) == 0)
7201 if (strncmp (argv[2], "b", 1) == 0)
7202 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH);
7203 else
7204 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH);
7205 else
7206 if (strncmp (argv[2], "b", 1) == 0)
7207 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7208 else
7209 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7210}
7211
7212ALIAS (show_ip_bgp_ipv4_prefix_pathtype,
7213 show_bgp_ipv4_safi_prefix_pathtype_cmd,
7214 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)",
7215 SHOW_STR
7216 BGP_STR
7217 "Address family\n"
7218 "Address Family modifier\n"
7219 "Address Family modifier\n"
7220 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7221 "Display only the bestpath\n"
7222 "Display only multipaths\n")
7223
Lou Bergerf9b6c392016-01-12 13:42:09 -05007224DEFUN (show_ip_bgp_vpnv4_all_prefix,
7225 show_ip_bgp_vpnv4_all_prefix_cmd,
7226 "show ip bgp vpnv4 all A.B.C.D/M",
7227 SHOW_STR
7228 IP_STR
7229 BGP_STR
7230 "Display VPNv4 NLRI specific information\n"
7231 "Display information about all VPNv4 NLRIs\n"
7232 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7233{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007234 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 -05007235}
7236
7237DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7238 show_ip_bgp_vpnv4_rd_prefix_cmd,
7239 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7240 SHOW_STR
7241 IP_STR
7242 BGP_STR
7243 "Display VPNv4 NLRI specific information\n"
7244 "Display information for a route distinguisher\n"
7245 "VPN Route Distinguisher\n"
7246 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7247{
7248 int ret;
7249 struct prefix_rd prd;
7250
7251 ret = str2prefix_rd (argv[0], &prd);
7252 if (! ret)
7253 {
7254 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7255 return CMD_WARNING;
7256 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007257 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 -05007258}
7259
7260DEFUN (show_ip_bgp_view,
7261 show_ip_bgp_view_cmd,
7262 "show ip bgp view WORD",
7263 SHOW_STR
7264 IP_STR
7265 BGP_STR
7266 "BGP view\n"
7267 "View name\n")
7268{
7269 struct bgp *bgp;
7270
7271 /* BGP structure lookup. */
7272 bgp = bgp_lookup_by_name (argv[0]);
7273 if (bgp == NULL)
7274 {
7275 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7276 return CMD_WARNING;
7277 }
7278
7279 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7280}
7281
7282DEFUN (show_ip_bgp_view_route,
7283 show_ip_bgp_view_route_cmd,
7284 "show ip bgp view WORD A.B.C.D",
7285 SHOW_STR
7286 IP_STR
7287 BGP_STR
7288 "BGP view\n"
7289 "View name\n"
7290 "Network in the BGP routing table to display\n")
7291{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007292 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 -05007293}
7294
7295DEFUN (show_ip_bgp_view_prefix,
7296 show_ip_bgp_view_prefix_cmd,
7297 "show ip bgp view WORD A.B.C.D/M",
7298 SHOW_STR
7299 IP_STR
7300 BGP_STR
7301 "BGP view\n"
7302 "View name\n"
7303 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7304{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007305 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 -05007306}
7307
7308DEFUN (show_bgp,
7309 show_bgp_cmd,
7310 "show bgp",
7311 SHOW_STR
7312 BGP_STR)
7313{
7314 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7315 NULL);
7316}
7317
7318ALIAS (show_bgp,
7319 show_bgp_ipv6_cmd,
7320 "show bgp ipv6",
7321 SHOW_STR
7322 BGP_STR
7323 "Address family\n")
7324
7325/* old command */
7326DEFUN (show_ipv6_bgp,
7327 show_ipv6_bgp_cmd,
7328 "show ipv6 bgp",
7329 SHOW_STR
7330 IP_STR
7331 BGP_STR)
7332{
7333 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7334 NULL);
7335}
7336
7337DEFUN (show_bgp_route,
7338 show_bgp_route_cmd,
7339 "show bgp X:X::X:X",
7340 SHOW_STR
7341 BGP_STR
7342 "Network in the BGP routing table to display\n")
7343{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007344 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007345}
7346
Lou Berger35c36862016-01-12 13:42:06 -05007347DEFUN (show_bgp_ipv4_safi,
7348 show_bgp_ipv4_safi_cmd,
7349 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007350 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007351 BGP_STR
7352 "Address family\n"
7353 "Address Family modifier\n"
7354 "Address Family modifier\n")
7355{
7356 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007357 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7358 NULL);
paul718e3742002-12-13 20:15:29 +00007359
ajs5a646652004-11-05 01:25:55 +00007360 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007361}
7362
Lou Berger35c36862016-01-12 13:42:06 -05007363DEFUN (show_bgp_ipv4_safi_route,
7364 show_bgp_ipv4_safi_route_cmd,
7365 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007366 SHOW_STR
7367 BGP_STR
7368 "Address family\n"
7369 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007370 "Address Family modifier\n"
7371 "Network in the BGP routing table to display\n")
7372{
7373 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007374 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007375
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007376 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7377}
7378
7379DEFUN (show_bgp_route_pathtype,
7380 show_bgp_route_pathtype_cmd,
7381 "show bgp X:X::X:X (bestpath|multipath)",
7382 SHOW_STR
7383 BGP_STR
7384 "Network in the BGP routing table to display\n"
7385 "Display only the bestpath\n"
7386 "Display only multipaths\n")
7387{
7388 if (strncmp (argv[1], "b", 1) == 0)
7389 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7390 else
7391 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7392}
7393
7394ALIAS (show_bgp_route_pathtype,
7395 show_bgp_ipv6_route_pathtype_cmd,
7396 "show bgp ipv6 X:X::X:X (bestpath|multipath)",
7397 SHOW_STR
7398 BGP_STR
7399 "Address family\n"
7400 "Network in the BGP routing table to display\n"
7401 "Display only the bestpath\n"
7402 "Display only multipaths\n")
7403
7404DEFUN (show_bgp_ipv6_safi_route_pathtype,
7405 show_bgp_ipv6_safi_route_pathtype_cmd,
7406 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath)",
7407 SHOW_STR
7408 BGP_STR
7409 "Address family\n"
7410 "Address Family modifier\n"
7411 "Address Family modifier\n"
7412 "Network in the BGP routing table to display\n"
7413 "Display only the bestpath\n"
7414 "Display only multipaths\n")
7415{
7416 if (strncmp (argv[0], "m", 1) == 0)
7417 if (strncmp (argv[2], "b", 1) == 0)
7418 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH);
7419 else
7420 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH);
7421 else
7422 if (strncmp (argv[2], "b", 1) == 0)
7423 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7424 else
7425 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
paul718e3742002-12-13 20:15:29 +00007426}
7427
Lou Berger35c36862016-01-12 13:42:06 -05007428DEFUN (show_bgp_ipv4_vpn_route,
7429 show_bgp_ipv4_vpn_route_cmd,
7430 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007431 SHOW_STR
7432 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007433 "Address Family\n"
7434 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007435 "Network in the BGP routing table to display\n")
7436{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007437 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007438}
7439
Lou Berger35c36862016-01-12 13:42:06 -05007440DEFUN (show_bgp_ipv6_vpn_route,
7441 show_bgp_ipv6_vpn_route_cmd,
7442 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007443 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007444 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007445 "Address Family\n"
7446 "Display VPN NLRI specific information\n"
7447 "Network in the BGP routing table to display\n")
7448{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007449 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 -05007450}
Lou Berger35c36862016-01-12 13:42:06 -05007451
7452DEFUN (show_bgp_ipv4_vpn_rd_route,
7453 show_bgp_ipv4_vpn_rd_route_cmd,
7454 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7455 SHOW_STR
7456 BGP_STR
7457 IP_STR
7458 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007459 "Display information for a route distinguisher\n"
7460 "VPN Route Distinguisher\n"
7461 "Network in the BGP routing table to display\n")
7462{
7463 int ret;
7464 struct prefix_rd prd;
7465
7466 ret = str2prefix_rd (argv[0], &prd);
7467 if (! ret)
7468 {
7469 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7470 return CMD_WARNING;
7471 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007472 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007473}
7474
Lou Berger35c36862016-01-12 13:42:06 -05007475DEFUN (show_bgp_ipv6_vpn_rd_route,
7476 show_bgp_ipv6_vpn_rd_route_cmd,
7477 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007478 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007479 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007480 "Address Family\n"
7481 "Display VPN NLRI specific information\n"
7482 "Display information for a route distinguisher\n"
7483 "VPN Route Distinguisher\n"
7484 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007485{
Lou Berger35c36862016-01-12 13:42:06 -05007486 int ret;
7487 struct prefix_rd prd;
7488
7489 ret = str2prefix_rd (argv[0], &prd);
7490 if (! ret)
7491 {
7492 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7493 return CMD_WARNING;
7494 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007495 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
7496}
7497
7498DEFUN (show_bgp_prefix_pathtype,
7499 show_bgp_prefix_pathtype_cmd,
7500 "show bgp X:X::X:X/M (bestpath|multipath)",
7501 SHOW_STR
7502 BGP_STR
7503 "IPv6 prefix <network>/<length>\n"
7504 "Display only the bestpath\n"
7505 "Display only multipaths\n")
7506{
7507 if (strncmp (argv[1], "b", 1) == 0)
7508 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7509 else
7510 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7511}
7512
7513ALIAS (show_bgp_prefix_pathtype,
7514 show_bgp_ipv6_prefix_pathtype_cmd,
7515 "show bgp ipv6 X:X::X:X/M (bestpath|multipath)",
7516 SHOW_STR
7517 BGP_STR
7518 "Address family\n"
7519 "IPv6 prefix <network>/<length>\n"
7520 "Display only the bestpath\n"
7521 "Display only multipaths\n")
7522
7523DEFUN (show_bgp_ipv6_safi_prefix_pathtype,
7524 show_bgp_ipv6_safi_prefix_pathtype_cmd,
7525 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath)",
7526 SHOW_STR
7527 BGP_STR
7528 "Address family\n"
7529 "Address Family modifier\n"
7530 "Address Family modifier\n"
7531 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
7532 "Display only the bestpath\n"
7533 "Display only multipaths\n")
7534{
7535 if (strncmp (argv[0], "m", 1) == 0)
7536 if (strncmp (argv[2], "b", 1) == 0)
7537 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH);
7538 else
7539 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH);
7540 else
7541 if (strncmp (argv[2], "b", 1) == 0)
7542 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7543 else
7544 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
paul718e3742002-12-13 20:15:29 +00007545}
7546
Lou Berger651b4022016-01-12 13:42:07 -05007547DEFUN (show_bgp_ipv4_encap_route,
7548 show_bgp_ipv4_encap_route_cmd,
7549 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007550 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007551 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007552 IP_STR
7553 "Display ENCAP NLRI specific information\n"
7554 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007555{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007556 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007557}
7558
Lou Berger651b4022016-01-12 13:42:07 -05007559DEFUN (show_bgp_ipv6_encap_route,
7560 show_bgp_ipv6_encap_route_cmd,
7561 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007562 SHOW_STR
7563 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007564 IP6_STR
7565 "Display ENCAP NLRI specific information\n"
7566 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007567{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007568 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007569}
7570
Lou Berger651b4022016-01-12 13:42:07 -05007571DEFUN (show_bgp_ipv4_safi_rd_route,
7572 show_bgp_ipv4_safi_rd_route_cmd,
7573 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007574 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007575 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007576 "Address Family\n"
7577 "Address Family Modifier\n"
7578 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007579 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007580 "ENCAP Route Distinguisher\n"
7581 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007582{
7583 int ret;
7584 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007585 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007586
Lou Berger651b4022016-01-12 13:42:07 -05007587 if (bgp_parse_safi(argv[0], &safi)) {
7588 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7589 return CMD_WARNING;
7590 }
7591 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007592 if (! ret)
7593 {
7594 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7595 return CMD_WARNING;
7596 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007597 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007598}
7599
Lou Berger651b4022016-01-12 13:42:07 -05007600DEFUN (show_bgp_ipv6_safi_rd_route,
7601 show_bgp_ipv6_safi_rd_route_cmd,
7602 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007603 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007604 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007605 "Address Family\n"
7606 "Address Family Modifier\n"
7607 "Address Family Modifier\n"
7608 "Display information for a route distinguisher\n"
7609 "ENCAP Route Distinguisher\n"
7610 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007611{
Lou Berger651b4022016-01-12 13:42:07 -05007612 int ret;
7613 struct prefix_rd prd;
7614 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007615
Lou Berger651b4022016-01-12 13:42:07 -05007616 if (bgp_parse_safi(argv[0], &safi)) {
7617 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7618 return CMD_WARNING;
7619 }
7620 ret = str2prefix_rd (argv[1], &prd);
7621 if (! ret)
7622 {
7623 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7624 return CMD_WARNING;
7625 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007626 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007627}
7628
Lou Berger35c36862016-01-12 13:42:06 -05007629DEFUN (show_bgp_ipv4_prefix,
7630 show_bgp_ipv4_prefix_cmd,
7631 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007632 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007633 BGP_STR
paul718e3742002-12-13 20:15:29 +00007634 IP_STR
paul718e3742002-12-13 20:15:29 +00007635 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7636{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007637 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007638}
7639
Lou Berger35c36862016-01-12 13:42:06 -05007640DEFUN (show_bgp_ipv4_safi_prefix,
7641 show_bgp_ipv4_safi_prefix_cmd,
7642 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007643 SHOW_STR
7644 BGP_STR
7645 "Address family\n"
7646 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007647 "Address Family modifier\n"
7648 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007649{
7650 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007651 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007652
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007653 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007654}
7655
Lou Berger35c36862016-01-12 13:42:06 -05007656DEFUN (show_bgp_ipv4_vpn_prefix,
7657 show_bgp_ipv4_vpn_prefix_cmd,
7658 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007659 SHOW_STR
7660 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007661 IP_STR
7662 "Display VPN NLRI specific information\n"
7663 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007664{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007665 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007666}
7667
Lou Berger35c36862016-01-12 13:42:06 -05007668DEFUN (show_bgp_ipv6_vpn_prefix,
7669 show_bgp_ipv6_vpn_prefix_cmd,
7670 "show bgp ipv6 vpn X:X::X:X/M",
7671 SHOW_STR
7672 BGP_STR
7673 "Address Family\n"
7674 "Display VPN NLRI specific information\n"
7675 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7676{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007677 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 -05007678}
Lou Berger35c36862016-01-12 13:42:06 -05007679
Lou Berger651b4022016-01-12 13:42:07 -05007680DEFUN (show_bgp_ipv4_encap_prefix,
7681 show_bgp_ipv4_encap_prefix_cmd,
7682 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007683 SHOW_STR
7684 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007685 IP_STR
7686 "Display ENCAP NLRI specific information\n"
7687 "Display information about ENCAP NLRIs\n"
7688 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7689{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007690 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007691}
paul718e3742002-12-13 20:15:29 +00007692
Lou Berger651b4022016-01-12 13:42:07 -05007693DEFUN (show_bgp_ipv6_encap_prefix,
7694 show_bgp_ipv6_encap_prefix_cmd,
7695 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007696 SHOW_STR
7697 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007698 IP_STR
7699 "Display ENCAP NLRI specific information\n"
7700 "Display information about ENCAP NLRIs\n"
7701 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7702{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007703 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007704}
Lou Berger651b4022016-01-12 13:42:07 -05007705
7706DEFUN (show_bgp_ipv4_safi_rd_prefix,
7707 show_bgp_ipv4_safi_rd_prefix_cmd,
7708 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7709 SHOW_STR
7710 BGP_STR
7711 "Address Family\n"
7712 "Address Family Modifier\n"
7713 "Address Family Modifier\n"
7714 "Display information for a route distinguisher\n"
7715 "ENCAP Route Distinguisher\n"
7716 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7717{
7718 int ret;
7719 struct prefix_rd prd;
7720 safi_t safi;
7721
7722 if (bgp_parse_safi(argv[0], &safi)) {
7723 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7724 return CMD_WARNING;
7725 }
7726
7727 ret = str2prefix_rd (argv[1], &prd);
7728 if (! ret)
7729 {
7730 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7731 return CMD_WARNING;
7732 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007733 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007734}
7735
Lou Berger651b4022016-01-12 13:42:07 -05007736DEFUN (show_bgp_ipv6_safi_rd_prefix,
7737 show_bgp_ipv6_safi_rd_prefix_cmd,
7738 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7739 SHOW_STR
7740 BGP_STR
7741 "Address Family\n"
7742 "Address Family Modifier\n"
7743 "Address Family Modifier\n"
7744 "Display information for a route distinguisher\n"
7745 "ENCAP Route Distinguisher\n"
7746 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7747{
7748 int ret;
7749 struct prefix_rd prd;
7750 safi_t safi;
7751
7752 if (bgp_parse_safi(argv[0], &safi)) {
7753 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7754 return CMD_WARNING;
7755 }
7756
7757 ret = str2prefix_rd (argv[1], &prd);
7758 if (! ret)
7759 {
7760 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7761 return CMD_WARNING;
7762 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007763 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007764}
Lou Berger651b4022016-01-12 13:42:07 -05007765
7766DEFUN (show_bgp_afi_safi_view,
7767 show_bgp_afi_safi_view_cmd,
7768 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7769 SHOW_STR
7770 BGP_STR
7771 "BGP view\n"
7772 "BGP view name\n"
7773 "Address Family\n"
7774 "Address Family\n"
7775 "Address Family Modifier\n"
7776 "Address Family Modifier\n"
7777 "Address Family Modifier\n"
7778 "Address Family Modifier\n"
7779 )
7780{
7781 struct bgp *bgp;
7782 safi_t safi;
7783 afi_t afi;
7784
7785 if (bgp_parse_afi(argv[1], &afi)) {
7786 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7787 return CMD_WARNING;
7788 }
7789 if (bgp_parse_safi(argv[2], &safi)) {
7790 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7791 return CMD_WARNING;
7792 }
7793
7794 /* BGP structure lookup. */
7795 bgp = bgp_lookup_by_name (argv[0]);
7796 if (bgp == NULL)
7797 {
7798 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7799 return CMD_WARNING;
7800 }
7801
7802 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7803}
7804
7805DEFUN (show_bgp_view_afi_safi_route,
7806 show_bgp_view_afi_safi_route_cmd,
7807 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7808 SHOW_STR
7809 BGP_STR
7810 "BGP view\n"
7811 "View name\n"
7812 "Address Family\n"
7813 "Address Family\n"
7814 "Address Family Modifier\n"
7815 "Address Family Modifier\n"
7816 "Address Family Modifier\n"
7817 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007818 "Network in the BGP routing table to display\n")
7819{
Lou Berger651b4022016-01-12 13:42:07 -05007820 safi_t safi;
7821 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007822
Lou Berger651b4022016-01-12 13:42:07 -05007823 if (bgp_parse_afi(argv[1], &afi)) {
7824 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7825 return CMD_WARNING;
7826 }
7827 if (bgp_parse_safi(argv[2], &safi)) {
7828 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7829 return CMD_WARNING;
7830 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007831 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007832}
7833
7834DEFUN (show_bgp_view_afi_safi_prefix,
7835 show_bgp_view_afi_safi_prefix_cmd,
7836 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7837 SHOW_STR
7838 BGP_STR
7839 "BGP view\n"
7840 "View name\n"
7841 "Address Family\n"
7842 "Address Family\n"
7843 "Address Family Modifier\n"
7844 "Address Family Modifier\n"
7845 "Address Family Modifier\n"
7846 "Address Family Modifier\n"
7847 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7848{
7849 safi_t safi;
7850 afi_t afi;
7851
7852 if (bgp_parse_afi(argv[1], &afi)) {
7853 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7854 return CMD_WARNING;
7855 }
7856 if (bgp_parse_safi(argv[2], &safi)) {
7857 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7858 return CMD_WARNING;
7859 }
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007860 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1, BGP_PATH_ALL);
Lou Berger651b4022016-01-12 13:42:07 -05007861}
7862
7863/* new001 */
7864DEFUN (show_bgp_afi,
7865 show_bgp_afi_cmd,
7866 "show bgp (ipv4|ipv6)",
7867 SHOW_STR
7868 BGP_STR
7869 "Address family\n"
7870 "Address family\n")
7871{
7872 afi_t afi;
7873
7874 if (bgp_parse_afi(argv[0], &afi)) {
7875 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7876 return CMD_WARNING;
7877 }
7878 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7879 NULL);
7880}
7881
Lou Berger651b4022016-01-12 13:42:07 -05007882DEFUN (show_bgp_ipv6_safi,
7883 show_bgp_ipv6_safi_cmd,
7884 "show bgp ipv6 (unicast|multicast)",
7885 SHOW_STR
7886 BGP_STR
7887 "Address family\n"
7888 "Address Family modifier\n"
7889 "Address Family modifier\n")
7890{
7891 if (strncmp (argv[0], "m", 1) == 0)
7892 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7893 NULL);
7894
7895 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007896}
7897
Lou Berger35c36862016-01-12 13:42:06 -05007898DEFUN (show_bgp_ipv6_route,
7899 show_bgp_ipv6_route_cmd,
7900 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007901 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007902 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007903 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007904 "Network in the BGP routing table to display\n")
7905{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007906 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007907}
7908
Lou Berger35c36862016-01-12 13:42:06 -05007909DEFUN (show_bgp_ipv6_safi_route,
7910 show_bgp_ipv6_safi_route_cmd,
7911 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007912 SHOW_STR
7913 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007914 "Address family\n"
7915 "Address Family modifier\n"
7916 "Address Family modifier\n"
7917 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007918{
Lou Berger35c36862016-01-12 13:42:06 -05007919 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007920 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Berger35c36862016-01-12 13:42:06 -05007921
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007922 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00007923}
7924
Lou Bergerf9b6c392016-01-12 13:42:09 -05007925/* old command */
7926DEFUN (show_ipv6_bgp_route,
7927 show_ipv6_bgp_route_cmd,
7928 "show ipv6 bgp X:X::X:X",
7929 SHOW_STR
7930 IP_STR
7931 BGP_STR
7932 "Network in the BGP routing table to display\n")
7933{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007934 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007935}
7936
7937DEFUN (show_bgp_prefix,
7938 show_bgp_prefix_cmd,
7939 "show bgp X:X::X:X/M",
7940 SHOW_STR
7941 BGP_STR
7942 "IPv6 prefix <network>/<length>\n")
7943{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007944 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007945}
7946
7947
Lou Berger35c36862016-01-12 13:42:06 -05007948/* new002 */
7949DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007950 show_bgp_ipv6_prefix_cmd,
7951 "show bgp ipv6 X:X::X:X/M",
7952 SHOW_STR
7953 BGP_STR
7954 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007955 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7956{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007957 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Berger35c36862016-01-12 13:42:06 -05007958}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007959DEFUN (show_bgp_ipv6_safi_prefix,
7960 show_bgp_ipv6_safi_prefix_cmd,
7961 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7962 SHOW_STR
7963 BGP_STR
7964 "Address family\n"
7965 "Address Family modifier\n"
7966 "Address Family modifier\n"
7967 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7968{
7969 if (strncmp (argv[0], "m", 1) == 0)
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007970 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007971
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007972 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007973}
7974
Lou Bergerf9b6c392016-01-12 13:42:09 -05007975/* old command */
7976DEFUN (show_ipv6_bgp_prefix,
7977 show_ipv6_bgp_prefix_cmd,
7978 "show ipv6 bgp X:X::X:X/M",
7979 SHOW_STR
7980 IP_STR
7981 BGP_STR
7982 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7983{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07007984 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05007985}
7986
paulbb46e942003-10-24 19:02:03 +00007987DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007988 show_bgp_view_cmd,
7989 "show bgp view WORD",
7990 SHOW_STR
7991 BGP_STR
7992 "BGP view\n"
7993 "View name\n")
7994{
7995 struct bgp *bgp;
7996
7997 /* BGP structure lookup. */
7998 bgp = bgp_lookup_by_name (argv[0]);
7999 if (bgp == NULL)
8000 {
8001 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8002 return CMD_WARNING;
8003 }
8004
8005 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
8006}
8007
8008DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05008009 show_bgp_view_ipv6_cmd,
8010 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00008011 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05008012 BGP_STR
paulbb46e942003-10-24 19:02:03 +00008013 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05008014 "View name\n"
8015 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00008016{
8017 struct bgp *bgp;
8018
8019 /* BGP structure lookup. */
8020 bgp = bgp_lookup_by_name (argv[0]);
8021 if (bgp == NULL)
8022 {
8023 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8024 return CMD_WARNING;
8025 }
8026
ajs5a646652004-11-05 01:25:55 +00008027 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00008028}
paulbb46e942003-10-24 19:02:03 +00008029
8030DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05008031 show_bgp_view_route_cmd,
8032 "show bgp view WORD X:X::X:X",
8033 SHOW_STR
8034 BGP_STR
8035 "BGP view\n"
8036 "View name\n"
8037 "Network in the BGP routing table to display\n")
8038{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008039 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 -05008040}
8041
8042DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00008043 show_bgp_view_ipv6_route_cmd,
8044 "show bgp view WORD ipv6 X:X::X:X",
8045 SHOW_STR
8046 BGP_STR
8047 "BGP view\n"
8048 "View name\n"
8049 "Address family\n"
8050 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00008051{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008052 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paulbb46e942003-10-24 19:02:03 +00008053}
8054
Lou Bergerf9b6c392016-01-12 13:42:09 -05008055/* old command */
8056DEFUN (show_ipv6_mbgp,
8057 show_ipv6_mbgp_cmd,
8058 "show ipv6 mbgp",
8059 SHOW_STR
8060 IP_STR
8061 MBGP_STR)
8062{
8063 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
8064 NULL);
8065}
8066
8067/* old command */
8068DEFUN (show_ipv6_mbgp_route,
8069 show_ipv6_mbgp_route_cmd,
8070 "show ipv6 mbgp X:X::X:X",
8071 SHOW_STR
8072 IP_STR
8073 MBGP_STR
8074 "Network in the MBGP routing table to display\n")
8075{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008076 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05008077}
8078
8079/* old command */
8080DEFUN (show_ipv6_mbgp_prefix,
8081 show_ipv6_mbgp_prefix_cmd,
8082 "show ipv6 mbgp X:X::X:X/M",
8083 SHOW_STR
8084 IP_STR
8085 MBGP_STR
8086 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
8087{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008088 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -05008089}
8090
Lou Berger35c36862016-01-12 13:42:06 -05008091DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05008092 show_bgp_view_prefix_cmd,
8093 "show bgp view WORD X:X::X:X/M",
8094 SHOW_STR
8095 BGP_STR
8096 "BGP view\n"
8097 "View name\n"
8098 "IPv6 prefix <network>/<length>\n")
8099{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008100 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 -05008101}
8102
8103DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00008104 show_bgp_view_ipv6_prefix_cmd,
8105 "show bgp view WORD ipv6 X:X::X:X/M",
8106 SHOW_STR
8107 BGP_STR
8108 "BGP view\n"
8109 "View name\n"
8110 "Address family\n"
8111 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00008112{
Daniel Walton59fe0ee2015-05-19 17:58:11 -07008113 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paul718e3742002-12-13 20:15:29 +00008114}
8115
paul94f2b392005-06-28 12:44:16 +00008116static int
paulfd79ac92004-10-13 05:06:08 +00008117bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008118 safi_t safi, enum bgp_show_type type)
8119{
8120 int i;
8121 struct buffer *b;
8122 char *regstr;
8123 int first;
8124 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00008125 int rc;
paul718e3742002-12-13 20:15:29 +00008126
8127 first = 0;
8128 b = buffer_new (1024);
8129 for (i = 0; i < argc; i++)
8130 {
8131 if (first)
8132 buffer_putc (b, ' ');
8133 else
8134 {
8135 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
8136 continue;
8137 first = 1;
8138 }
8139
8140 buffer_putstr (b, argv[i]);
8141 }
8142 buffer_putc (b, '\0');
8143
8144 regstr = buffer_getstr (b);
8145 buffer_free (b);
8146
8147 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00008148 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00008149 if (! regex)
8150 {
8151 vty_out (vty, "Can't compile regexp %s%s", argv[0],
8152 VTY_NEWLINE);
8153 return CMD_WARNING;
8154 }
8155
ajs5a646652004-11-05 01:25:55 +00008156 rc = bgp_show (vty, NULL, afi, safi, type, regex);
8157 bgp_regex_free (regex);
8158 return rc;
paul718e3742002-12-13 20:15:29 +00008159}
8160
Lou Bergerf9b6c392016-01-12 13:42:09 -05008161
8162DEFUN (show_ip_bgp_regexp,
8163 show_ip_bgp_regexp_cmd,
8164 "show ip bgp regexp .LINE",
8165 SHOW_STR
8166 IP_STR
8167 BGP_STR
8168 "Display routes matching the AS path regular expression\n"
8169 "A regular-expression to match the BGP AS paths\n")
8170{
8171 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8172 bgp_show_type_regexp);
8173}
8174
8175DEFUN (show_ip_bgp_flap_regexp,
8176 show_ip_bgp_flap_regexp_cmd,
8177 "show ip bgp flap-statistics regexp .LINE",
8178 SHOW_STR
8179 IP_STR
8180 BGP_STR
8181 "Display flap statistics of routes\n"
8182 "Display routes matching the AS path regular expression\n"
8183 "A regular-expression to match the BGP AS paths\n")
8184{
8185 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8186 bgp_show_type_flap_regexp);
8187}
8188
8189ALIAS (show_ip_bgp_flap_regexp,
8190 show_ip_bgp_damp_flap_regexp_cmd,
8191 "show ip bgp dampening flap-statistics regexp .LINE",
8192 SHOW_STR
8193 IP_STR
8194 BGP_STR
8195 "Display detailed information about dampening\n"
8196 "Display flap statistics of routes\n"
8197 "Display routes matching the AS path regular expression\n"
8198 "A regular-expression to match the BGP AS paths\n")
8199
8200DEFUN (show_ip_bgp_ipv4_regexp,
8201 show_ip_bgp_ipv4_regexp_cmd,
8202 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
8203 SHOW_STR
8204 IP_STR
8205 BGP_STR
8206 "Address family\n"
8207 "Address Family modifier\n"
8208 "Address Family modifier\n"
8209 "Display routes matching the AS path regular expression\n"
8210 "A regular-expression to match the BGP AS paths\n")
8211{
8212 if (strncmp (argv[0], "m", 1) == 0)
8213 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
8214 bgp_show_type_regexp);
8215
8216 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8217 bgp_show_type_regexp);
8218}
8219
Lou Bergerf9b6c392016-01-12 13:42:09 -05008220DEFUN (show_bgp_regexp,
8221 show_bgp_regexp_cmd,
8222 "show bgp regexp .LINE",
8223 SHOW_STR
8224 BGP_STR
8225 "Display routes matching the AS path regular expression\n"
8226 "A regular-expression to match the BGP AS paths\n")
8227{
8228 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8229 bgp_show_type_regexp);
8230}
8231
8232/* old command */
8233DEFUN (show_ipv6_bgp_regexp,
8234 show_ipv6_bgp_regexp_cmd,
8235 "show ipv6 bgp regexp .LINE",
8236 SHOW_STR
8237 IP_STR
8238 BGP_STR
8239 "Display routes matching the AS path regular expression\n"
8240 "A regular-expression to match the BGP AS paths\n")
8241{
8242 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8243 bgp_show_type_regexp);
8244}
8245
8246/* old command */
8247DEFUN (show_ipv6_mbgp_regexp,
8248 show_ipv6_mbgp_regexp_cmd,
8249 "show ipv6 mbgp regexp .LINE",
8250 SHOW_STR
8251 IP_STR
8252 BGP_STR
8253 "Display routes matching the AS path regular expression\n"
8254 "A regular-expression to match the MBGP AS paths\n")
8255{
8256 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
8257 bgp_show_type_regexp);
8258}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008259
Lou Berger651b4022016-01-12 13:42:07 -05008260DEFUN (show_bgp_ipv4_safi_flap_regexp,
8261 show_bgp_ipv4_safi_flap_regexp_cmd,
8262 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008263 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008264 BGP_STR
paul718e3742002-12-13 20:15:29 +00008265 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008266 "Address Family Modifier\n"
8267 "Address Family Modifier\n"
8268 "Address Family Modifier\n"
8269 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008270 "Display flap statistics of routes\n"
8271 "Display routes matching the AS path regular expression\n"
8272 "A regular-expression to match the BGP AS paths\n")
8273{
Lou Berger651b4022016-01-12 13:42:07 -05008274 safi_t safi;
8275
8276 if (bgp_parse_safi(argv[0], &safi)) {
8277 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8278 return CMD_WARNING;
8279 }
8280 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
8281 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00008282}
8283
Lou Berger651b4022016-01-12 13:42:07 -05008284ALIAS (show_bgp_ipv4_safi_flap_regexp,
8285 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
8286 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05308287 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308288 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008289 IP_STR
8290 "Address Family Modifier\n"
8291 "Address Family Modifier\n"
8292 "Address Family Modifier\n"
8293 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308294 "Display detailed information about dampening\n"
8295 "Display flap statistics of routes\n"
8296 "Display routes matching the AS path regular expression\n"
8297 "A regular-expression to match the BGP AS paths\n")
8298
Lou Berger651b4022016-01-12 13:42:07 -05008299DEFUN (show_bgp_ipv6_safi_flap_regexp,
8300 show_bgp_ipv6_safi_flap_regexp_cmd,
8301 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008302 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008303 BGP_STR
8304 IPV6_STR
8305 "Address Family Modifier\n"
8306 "Address Family Modifier\n"
8307 "Address Family Modifier\n"
8308 "Address Family Modifier\n"
8309 "Display flap statistics of routes\n"
8310 "Display routes matching the AS path regular expression\n"
8311 "A regular-expression to match the BGP AS paths\n")
8312{
8313 safi_t safi;
8314
8315 if (bgp_parse_safi(argv[0], &safi)) {
8316 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8317 return CMD_WARNING;
8318 }
8319 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8320 bgp_show_type_flap_regexp);
8321}
8322
8323ALIAS (show_bgp_ipv6_safi_flap_regexp,
8324 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8325 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8326 SHOW_STR
8327 BGP_STR
8328 IPV6_STR
8329 "Address Family Modifier\n"
8330 "Address Family Modifier\n"
8331 "Address Family Modifier\n"
8332 "Address Family Modifier\n"
8333 "Display detailed information about dampening\n"
8334 "Display flap statistics of routes\n"
8335 "Display routes matching the AS path regular expression\n"
8336 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008337
8338DEFUN (show_bgp_ipv4_safi_regexp,
8339 show_bgp_ipv4_safi_regexp_cmd,
8340 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8341 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008342 BGP_STR
8343 "Address family\n"
8344 "Address Family modifier\n"
8345 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008346 "Address Family modifier\n"
8347 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008348 "Display routes matching the AS path regular expression\n"
8349 "A regular-expression to match the BGP AS paths\n")
8350{
Lou Berger651b4022016-01-12 13:42:07 -05008351 safi_t safi;
8352 if (bgp_parse_safi(argv[0], &safi)) {
8353 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8354 return CMD_WARNING;
8355 }
paul718e3742002-12-13 20:15:29 +00008356
Lou Berger651b4022016-01-12 13:42:07 -05008357 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008358 bgp_show_type_regexp);
8359}
Lou Berger205e6742016-01-12 13:42:11 -05008360
Lou Berger651b4022016-01-12 13:42:07 -05008361DEFUN (show_bgp_ipv6_safi_regexp,
8362 show_bgp_ipv6_safi_regexp_cmd,
8363 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008364 SHOW_STR
8365 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008366 "Address family\n"
8367 "Address Family modifier\n"
8368 "Address Family modifier\n"
8369 "Address Family modifier\n"
8370 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008371 "Display routes matching the AS path regular expression\n"
8372 "A regular-expression to match the BGP AS paths\n")
8373{
Lou Berger651b4022016-01-12 13:42:07 -05008374 safi_t safi;
8375 if (bgp_parse_safi(argv[0], &safi)) {
8376 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8377 return CMD_WARNING;
8378 }
8379
8380 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008381 bgp_show_type_regexp);
8382}
8383
Lou Berger651b4022016-01-12 13:42:07 -05008384DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008385 show_bgp_ipv6_regexp_cmd,
8386 "show bgp ipv6 regexp .LINE",
8387 SHOW_STR
8388 BGP_STR
8389 "Address family\n"
8390 "Display routes matching the AS path regular expression\n"
8391 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008392{
8393 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8394 bgp_show_type_regexp);
8395}
8396
paul94f2b392005-06-28 12:44:16 +00008397static int
paulfd79ac92004-10-13 05:06:08 +00008398bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008399 safi_t safi, enum bgp_show_type type)
8400{
8401 struct prefix_list *plist;
8402
8403 plist = prefix_list_lookup (afi, prefix_list_str);
8404 if (plist == NULL)
8405 {
8406 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8407 prefix_list_str, VTY_NEWLINE);
8408 return CMD_WARNING;
8409 }
8410
ajs5a646652004-11-05 01:25:55 +00008411 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008412}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008413DEFUN (show_ip_bgp_prefix_list,
8414 show_ip_bgp_prefix_list_cmd,
8415 "show ip bgp prefix-list WORD",
8416 SHOW_STR
8417 IP_STR
8418 BGP_STR
8419 "Display routes conforming to the prefix-list\n"
8420 "IP prefix-list name\n")
8421{
8422 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8423 bgp_show_type_prefix_list);
8424}
8425
8426DEFUN (show_ip_bgp_flap_prefix_list,
8427 show_ip_bgp_flap_prefix_list_cmd,
8428 "show ip bgp flap-statistics prefix-list WORD",
8429 SHOW_STR
8430 IP_STR
8431 BGP_STR
8432 "Display flap statistics of routes\n"
8433 "Display routes conforming to the prefix-list\n"
8434 "IP prefix-list name\n")
8435{
8436 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8437 bgp_show_type_flap_prefix_list);
8438}
8439
8440ALIAS (show_ip_bgp_flap_prefix_list,
8441 show_ip_bgp_damp_flap_prefix_list_cmd,
8442 "show ip bgp dampening flap-statistics prefix-list WORD",
8443 SHOW_STR
8444 IP_STR
8445 BGP_STR
8446 "Display detailed information about dampening\n"
8447 "Display flap statistics of routes\n"
8448 "Display routes conforming to the prefix-list\n"
8449 "IP prefix-list name\n")
8450
8451DEFUN (show_ip_bgp_ipv4_prefix_list,
8452 show_ip_bgp_ipv4_prefix_list_cmd,
8453 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8454 SHOW_STR
8455 IP_STR
8456 BGP_STR
8457 "Address family\n"
8458 "Address Family modifier\n"
8459 "Address Family modifier\n"
8460 "Display routes conforming to the prefix-list\n"
8461 "IP prefix-list name\n")
8462{
8463 if (strncmp (argv[0], "m", 1) == 0)
8464 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8465 bgp_show_type_prefix_list);
8466
8467 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8468 bgp_show_type_prefix_list);
8469}
8470
Lou Bergerf9b6c392016-01-12 13:42:09 -05008471DEFUN (show_bgp_prefix_list,
8472 show_bgp_prefix_list_cmd,
8473 "show bgp prefix-list WORD",
8474 SHOW_STR
8475 BGP_STR
8476 "Display routes conforming to the prefix-list\n"
8477 "IPv6 prefix-list name\n")
8478{
8479 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8480 bgp_show_type_prefix_list);
8481}
8482
8483ALIAS (show_bgp_prefix_list,
8484 show_bgp_ipv6_prefix_list_cmd,
8485 "show bgp ipv6 prefix-list WORD",
8486 SHOW_STR
8487 BGP_STR
8488 "Address family\n"
8489 "Display routes conforming to the prefix-list\n"
8490 "IPv6 prefix-list name\n")
8491
8492/* old command */
8493DEFUN (show_ipv6_bgp_prefix_list,
8494 show_ipv6_bgp_prefix_list_cmd,
8495 "show ipv6 bgp prefix-list WORD",
8496 SHOW_STR
8497 IPV6_STR
8498 BGP_STR
8499 "Display routes matching the prefix-list\n"
8500 "IPv6 prefix-list name\n")
8501{
8502 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8503 bgp_show_type_prefix_list);
8504}
8505
8506/* old command */
8507DEFUN (show_ipv6_mbgp_prefix_list,
8508 show_ipv6_mbgp_prefix_list_cmd,
8509 "show ipv6 mbgp prefix-list WORD",
8510 SHOW_STR
8511 IPV6_STR
8512 MBGP_STR
8513 "Display routes matching the prefix-list\n"
8514 "IPv6 prefix-list name\n")
8515{
8516 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8517 bgp_show_type_prefix_list);
8518}
paul718e3742002-12-13 20:15:29 +00008519
Lou Berger35c36862016-01-12 13:42:06 -05008520DEFUN (show_bgp_ipv4_prefix_list,
8521 show_bgp_ipv4_prefix_list_cmd,
8522 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008523 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008524 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008525 IP_STR
paul718e3742002-12-13 20:15:29 +00008526 "Display routes conforming to the prefix-list\n"
8527 "IP prefix-list name\n")
8528{
8529 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8530 bgp_show_type_prefix_list);
8531}
8532
Lou Berger651b4022016-01-12 13:42:07 -05008533DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8534 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8535 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008536 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008537 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008538 IP_STR
8539 "Address Family Modifier\n"
8540 "Address Family Modifier\n"
8541 "Address Family Modifier\n"
8542 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008543 "Display flap statistics of routes\n"
8544 "Display routes conforming to the prefix-list\n"
8545 "IP prefix-list name\n")
8546{
Lou Berger651b4022016-01-12 13:42:07 -05008547 safi_t safi;
8548 if (bgp_parse_safi(argv[0], &safi)) {
8549 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8550 return CMD_WARNING;
8551 }
8552 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008553 bgp_show_type_flap_prefix_list);
8554}
8555
Lou Berger651b4022016-01-12 13:42:07 -05008556ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8557 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8558 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308559 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308560 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008561 IP_STR
8562 "Address Family Modifier\n"
8563 "Address Family Modifier\n"
8564 "Address Family Modifier\n"
8565 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308566 "Display detailed information about dampening\n"
8567 "Display flap statistics of routes\n"
8568 "Display routes conforming to the prefix-list\n"
8569 "IP prefix-list name\n")
8570
Lou Berger651b4022016-01-12 13:42:07 -05008571DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8572 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8573 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008574 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008575 BGP_STR
8576 IPV6_STR
8577 "Address Family Modifier\n"
8578 "Address Family Modifier\n"
8579 "Address Family Modifier\n"
8580 "Address Family Modifier\n"
8581 "Display flap statistics of routes\n"
8582 "Display routes conforming to the prefix-list\n"
8583 "IP prefix-list name\n")
8584{
8585 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_IP6, safi,
8591 bgp_show_type_flap_prefix_list);
8592}
8593ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8594 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8595 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8596 SHOW_STR
8597 BGP_STR
8598 IPV6_STR
8599 "Address Family Modifier\n"
8600 "Address Family Modifier\n"
8601 "Address Family Modifier\n"
8602 "Address Family Modifier\n"
8603 "Display detailed information about dampening\n"
8604 "Display flap statistics of routes\n"
8605 "Display routes conforming to the prefix-list\n"
8606 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008607
8608DEFUN (show_bgp_ipv4_safi_prefix_list,
8609 show_bgp_ipv4_safi_prefix_list_cmd,
8610 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8611 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008612 BGP_STR
8613 "Address family\n"
8614 "Address Family modifier\n"
8615 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008616 "Address Family modifier\n"
8617 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008618 "Display routes conforming to the prefix-list\n"
8619 "IP prefix-list name\n")
8620{
Lou Berger651b4022016-01-12 13:42:07 -05008621 safi_t safi;
8622 if (bgp_parse_safi(argv[0], &safi)) {
8623 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8624 return CMD_WARNING;
8625 }
8626 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008627 bgp_show_type_prefix_list);
8628}
Lou Berger205e6742016-01-12 13:42:11 -05008629
Lou Berger651b4022016-01-12 13:42:07 -05008630DEFUN (show_bgp_ipv6_safi_prefix_list,
8631 show_bgp_ipv6_safi_prefix_list_cmd,
8632 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008633 SHOW_STR
8634 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008635 "Address family\n"
8636 "Address Family modifier\n"
8637 "Address Family modifier\n"
8638 "Address Family modifier\n"
8639 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008640 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008641 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008642{
Lou Berger651b4022016-01-12 13:42:07 -05008643 safi_t safi;
8644 if (bgp_parse_safi(argv[0], &safi)) {
8645 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8646 return CMD_WARNING;
8647 }
8648 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008649 bgp_show_type_prefix_list);
8650}
8651
paul94f2b392005-06-28 12:44:16 +00008652static int
paulfd79ac92004-10-13 05:06:08 +00008653bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008654 safi_t safi, enum bgp_show_type type)
8655{
8656 struct as_list *as_list;
8657
8658 as_list = as_list_lookup (filter);
8659 if (as_list == NULL)
8660 {
8661 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8662 return CMD_WARNING;
8663 }
8664
ajs5a646652004-11-05 01:25:55 +00008665 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008666}
8667
Lou Bergerf9b6c392016-01-12 13:42:09 -05008668DEFUN (show_ip_bgp_filter_list,
8669 show_ip_bgp_filter_list_cmd,
8670 "show ip bgp filter-list WORD",
8671 SHOW_STR
8672 IP_STR
8673 BGP_STR
8674 "Display routes conforming to the filter-list\n"
8675 "Regular expression access list name\n")
8676{
8677 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8678 bgp_show_type_filter_list);
8679}
8680
8681DEFUN (show_ip_bgp_flap_filter_list,
8682 show_ip_bgp_flap_filter_list_cmd,
8683 "show ip bgp flap-statistics filter-list WORD",
8684 SHOW_STR
8685 IP_STR
8686 BGP_STR
8687 "Display flap statistics of routes\n"
8688 "Display routes conforming to the filter-list\n"
8689 "Regular expression access list name\n")
8690{
8691 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8692 bgp_show_type_flap_filter_list);
8693}
8694
8695ALIAS (show_ip_bgp_flap_filter_list,
8696 show_ip_bgp_damp_flap_filter_list_cmd,
8697 "show ip bgp dampening flap-statistics filter-list WORD",
8698 SHOW_STR
8699 IP_STR
8700 BGP_STR
8701 "Display detailed information about dampening\n"
8702 "Display flap statistics of routes\n"
8703 "Display routes conforming to the filter-list\n"
8704 "Regular expression access list name\n")
8705
8706DEFUN (show_ip_bgp_ipv4_filter_list,
8707 show_ip_bgp_ipv4_filter_list_cmd,
8708 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8709 SHOW_STR
8710 IP_STR
8711 BGP_STR
8712 "Address family\n"
8713 "Address Family modifier\n"
8714 "Address Family modifier\n"
8715 "Display routes conforming to the filter-list\n"
8716 "Regular expression access list name\n")
8717{
8718 if (strncmp (argv[0], "m", 1) == 0)
8719 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8720 bgp_show_type_filter_list);
8721
8722 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8723 bgp_show_type_filter_list);
8724}
8725
Lou Bergerf9b6c392016-01-12 13:42:09 -05008726DEFUN (show_bgp_filter_list,
8727 show_bgp_filter_list_cmd,
8728 "show bgp filter-list WORD",
8729 SHOW_STR
8730 BGP_STR
8731 "Display routes conforming to the filter-list\n"
8732 "Regular expression access list name\n")
8733{
8734 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8735 bgp_show_type_filter_list);
8736}
8737
8738/* old command */
8739DEFUN (show_ipv6_bgp_filter_list,
8740 show_ipv6_bgp_filter_list_cmd,
8741 "show ipv6 bgp filter-list WORD",
8742 SHOW_STR
8743 IPV6_STR
8744 BGP_STR
8745 "Display routes conforming to the filter-list\n"
8746 "Regular expression access list name\n")
8747{
8748 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8749 bgp_show_type_filter_list);
8750}
8751
8752/* old command */
8753DEFUN (show_ipv6_mbgp_filter_list,
8754 show_ipv6_mbgp_filter_list_cmd,
8755 "show ipv6 mbgp filter-list WORD",
8756 SHOW_STR
8757 IPV6_STR
8758 MBGP_STR
8759 "Display routes conforming to the filter-list\n"
8760 "Regular expression access list name\n")
8761{
8762 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8763 bgp_show_type_filter_list);
8764}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008765
8766DEFUN (show_ip_bgp_dampening_info,
8767 show_ip_bgp_dampening_params_cmd,
8768 "show ip bgp dampening parameters",
8769 SHOW_STR
8770 IP_STR
8771 BGP_STR
8772 "Display detailed information about dampening\n"
8773 "Display detail of configured dampening parameters\n")
8774{
8775 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8776}
8777
Lou Berger651b4022016-01-12 13:42:07 -05008778DEFUN (show_bgp_ipv4_filter_list,
8779 show_bgp_ipv4_filter_list_cmd,
8780 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008781 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008782 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008783 IP_STR
paul718e3742002-12-13 20:15:29 +00008784 "Display routes conforming to the filter-list\n"
8785 "Regular expression access list name\n")
8786{
8787 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8788 bgp_show_type_filter_list);
8789}
8790
Lou Berger651b4022016-01-12 13:42:07 -05008791DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8792 show_bgp_ipv4_safi_flap_filter_list_cmd,
8793 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008794 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008795 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008796 IP_STR
8797 "Address Family modifier\n"
8798 "Address Family modifier\n"
8799 "Address Family modifier\n"
8800 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008801 "Display flap statistics of routes\n"
8802 "Display routes conforming to the filter-list\n"
8803 "Regular expression access list name\n")
8804{
Lou Berger651b4022016-01-12 13:42:07 -05008805 safi_t safi;
8806
8807 if (bgp_parse_safi(argv[0], &safi)) {
8808 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8809 return CMD_WARNING;
8810 }
8811 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008812 bgp_show_type_flap_filter_list);
8813}
8814
Lou Berger651b4022016-01-12 13:42:07 -05008815ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8816 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8817 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308818 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308819 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008820 IP_STR
8821 "Address Family modifier\n"
8822 "Address Family modifier\n"
8823 "Address Family modifier\n"
8824 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308825 "Display detailed information about dampening\n"
8826 "Display flap statistics of routes\n"
8827 "Display routes conforming to the filter-list\n"
8828 "Regular expression access list name\n")
8829
Lou Berger651b4022016-01-12 13:42:07 -05008830DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8831 show_bgp_ipv6_safi_flap_filter_list_cmd,
8832 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008833 SHOW_STR
8834 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008835 IPV6_STR
8836 "Address Family modifier\n"
8837 "Address Family modifier\n"
8838 "Address Family modifier\n"
8839 "Address Family modifier\n"
8840 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008841 "Display routes conforming to the filter-list\n"
8842 "Regular expression access list name\n")
8843{
Lou Berger651b4022016-01-12 13:42:07 -05008844 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_IP6, safi,
8851 bgp_show_type_flap_filter_list);
8852}
8853ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8854 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8855 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8856 SHOW_STR
8857 BGP_STR
8858 IPV6_STR
8859 "Address Family modifier\n"
8860 "Address Family modifier\n"
8861 "Address Family modifier\n"
8862 "Address Family modifier\n"
8863 "Display detailed information about dampening\n"
8864 "Display flap statistics of routes\n"
8865 "Display routes conforming to the filter-list\n"
8866 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008867
8868DEFUN (show_bgp_ipv4_safi_filter_list,
8869 show_bgp_ipv4_safi_filter_list_cmd,
8870 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8871 SHOW_STR
8872 BGP_STR
8873 "Address Family modifier\n"
8874 "Address Family modifier\n"
8875 "Address Family modifier\n"
8876 "Address Family modifier\n"
8877 "Display routes conforming to the filter-list\n"
8878 "Regular expression access list name\n")
8879{
8880 safi_t safi;
8881
8882 if (bgp_parse_safi(argv[0], &safi)) {
8883 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8884 return CMD_WARNING;
8885 }
8886 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8887 bgp_show_type_filter_list);
8888}
Lou Berger205e6742016-01-12 13:42:11 -05008889
Lou Berger651b4022016-01-12 13:42:07 -05008890DEFUN (show_bgp_ipv6_safi_filter_list,
8891 show_bgp_ipv6_safi_filter_list_cmd,
8892 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8893 SHOW_STR
8894 BGP_STR
8895 "Address Family modifier\n"
8896 "Address Family modifier\n"
8897 "Address Family modifier\n"
8898 "Address Family modifier\n"
8899 "Display routes conforming to the filter-list\n"
8900 "Regular expression access list name\n")
8901{
8902 safi_t safi;
8903
8904 if (bgp_parse_safi(argv[0], &safi)) {
8905 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8906 return CMD_WARNING;
8907 }
8908 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8909 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008910}
8911
Lou Bergerf9b6c392016-01-12 13:42:09 -05008912DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008913 show_bgp_ipv6_filter_list_cmd,
8914 "show bgp ipv6 filter-list WORD",
8915 SHOW_STR
8916 BGP_STR
8917 "Address family\n"
8918 "Display routes conforming to the filter-list\n"
8919 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008920{
8921 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8922 bgp_show_type_filter_list);
8923}
8924
Balaji9c52cae2016-01-20 22:59:26 +05308925
8926DEFUN (show_ip_bgp_ipv4_dampening_parameters,
8927 show_ip_bgp_ipv4_dampening_parameters_cmd,
8928 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
8929 SHOW_STR
8930 IP_STR
8931 BGP_STR
8932 "Address family\n"
8933 "Address Family modifier\n"
8934 "Address Family modifier\n"
8935 "Display detailed information about dampening\n"
8936 "Display detail of configured dampening parameters\n")
8937{
8938 if (strncmp(argv[0], "m", 1) == 0)
8939 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST);
8940
8941 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8942}
8943
8944
8945DEFUN (show_ip_bgp_ipv4_dampening_flap_stats,
8946 show_ip_bgp_ipv4_dampening_flap_stats_cmd,
8947 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
8948 SHOW_STR
8949 IP_STR
8950 BGP_STR
8951 "Address family\n"
8952 "Address Family modifier\n"
8953 "Address Family modifier\n"
8954 "Display detailed information about dampening\n"
8955 "Display flap statistics of routes\n")
8956{
8957 if (strncmp(argv[0], "m", 1) == 0)
8958 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8959 bgp_show_type_flap_statistics, NULL);
8960
8961 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8962 bgp_show_type_flap_statistics, NULL);
8963}
8964
8965DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths,
8966 show_ip_bgp_ipv4_dampening_dampd_paths_cmd,
8967 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
8968 SHOW_STR
8969 IP_STR
8970 BGP_STR
8971 "Address family\n"
8972 "Address Family modifier\n"
8973 "Address Family modifier\n"
8974 "Display detailed information about dampening\n"
8975 "Display paths suppressed due to dampening\n")
8976{
8977 if (strncmp(argv[0], "m", 1) == 0)
8978 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8979 bgp_show_type_dampend_paths, NULL);
8980
8981 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8982 bgp_show_type_dampend_paths, NULL);
8983}
8984
paul94f2b392005-06-28 12:44:16 +00008985static int
paulfd79ac92004-10-13 05:06:08 +00008986bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008987 safi_t safi, enum bgp_show_type type)
8988{
8989 struct route_map *rmap;
8990
8991 rmap = route_map_lookup_by_name (rmap_str);
8992 if (! rmap)
8993 {
8994 vty_out (vty, "%% %s is not a valid route-map name%s",
8995 rmap_str, VTY_NEWLINE);
8996 return CMD_WARNING;
8997 }
8998
ajs5a646652004-11-05 01:25:55 +00008999 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00009000}
9001
Lou Bergerf9b6c392016-01-12 13:42:09 -05009002DEFUN (show_ip_bgp_route_map,
9003 show_ip_bgp_route_map_cmd,
9004 "show ip bgp route-map WORD",
9005 SHOW_STR
9006 IP_STR
9007 BGP_STR
9008 "Display routes matching the route-map\n"
9009 "A route-map to match on\n")
9010{
9011 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
9012 bgp_show_type_route_map);
9013}
9014
9015DEFUN (show_ip_bgp_flap_route_map,
9016 show_ip_bgp_flap_route_map_cmd,
9017 "show ip bgp flap-statistics route-map WORD",
9018 SHOW_STR
9019 IP_STR
9020 BGP_STR
9021 "Display flap statistics of routes\n"
9022 "Display routes matching the route-map\n"
9023 "A route-map to match on\n")
9024{
9025 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
9026 bgp_show_type_flap_route_map);
9027}
9028
9029ALIAS (show_ip_bgp_flap_route_map,
9030 show_ip_bgp_damp_flap_route_map_cmd,
9031 "show ip bgp dampening flap-statistics route-map WORD",
9032 SHOW_STR
9033 IP_STR
9034 BGP_STR
9035 "Display detailed information about dampening\n"
9036 "Display flap statistics of routes\n"
9037 "Display routes matching the route-map\n"
9038 "A route-map to match on\n")
9039
9040DEFUN (show_ip_bgp_ipv4_route_map,
9041 show_ip_bgp_ipv4_route_map_cmd,
9042 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9043 SHOW_STR
9044 IP_STR
9045 BGP_STR
9046 "Address family\n"
9047 "Address Family modifier\n"
9048 "Address Family modifier\n"
9049 "Display routes matching the route-map\n"
9050 "A route-map to match on\n")
9051{
9052 if (strncmp (argv[0], "m", 1) == 0)
9053 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
9054 bgp_show_type_route_map);
9055
9056 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
9057 bgp_show_type_route_map);
9058}
9059
9060DEFUN (show_bgp_route_map,
9061 show_bgp_route_map_cmd,
9062 "show bgp route-map WORD",
9063 SHOW_STR
9064 BGP_STR
9065 "Display routes matching the route-map\n"
9066 "A route-map to match on\n")
9067{
9068 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9069 bgp_show_type_route_map);
9070}
9071
9072DEFUN (show_ip_bgp_cidr_only,
9073 show_ip_bgp_cidr_only_cmd,
9074 "show ip bgp cidr-only",
9075 SHOW_STR
9076 IP_STR
9077 BGP_STR
9078 "Display only routes with non-natural netmasks\n")
9079{
9080 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9081 bgp_show_type_cidr_only, NULL);
9082}
9083
9084DEFUN (show_ip_bgp_flap_cidr_only,
9085 show_ip_bgp_flap_cidr_only_cmd,
9086 "show ip bgp flap-statistics cidr-only",
9087 SHOW_STR
9088 IP_STR
9089 BGP_STR
9090 "Display flap statistics of routes\n"
9091 "Display only routes with non-natural netmasks\n")
9092{
9093 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9094 bgp_show_type_flap_cidr_only, NULL);
9095}
9096
9097ALIAS (show_ip_bgp_flap_cidr_only,
9098 show_ip_bgp_damp_flap_cidr_only_cmd,
9099 "show ip bgp dampening flap-statistics cidr-only",
9100 SHOW_STR
9101 IP_STR
9102 BGP_STR
9103 "Display detailed information about dampening\n"
9104 "Display flap statistics of routes\n"
9105 "Display only routes with non-natural netmasks\n")
9106
9107DEFUN (show_ip_bgp_ipv4_cidr_only,
9108 show_ip_bgp_ipv4_cidr_only_cmd,
9109 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9110 SHOW_STR
9111 IP_STR
9112 BGP_STR
9113 "Address family\n"
9114 "Address Family modifier\n"
9115 "Address Family modifier\n"
9116 "Display only routes with non-natural netmasks\n")
9117{
9118 if (strncmp (argv[0], "m", 1) == 0)
9119 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9120 bgp_show_type_cidr_only, NULL);
9121
9122 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9123 bgp_show_type_cidr_only, NULL);
9124}
9125
9126DEFUN (show_ip_bgp_community_all,
9127 show_ip_bgp_community_all_cmd,
9128 "show ip bgp community",
9129 SHOW_STR
9130 IP_STR
9131 BGP_STR
9132 "Display routes matching the communities\n")
9133{
9134 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9135 bgp_show_type_community_all, NULL);
9136}
9137
9138DEFUN (show_ip_bgp_ipv4_community_all,
9139 show_ip_bgp_ipv4_community_all_cmd,
9140 "show ip bgp ipv4 (unicast|multicast) community",
9141 SHOW_STR
9142 IP_STR
9143 BGP_STR
9144 "Address family\n"
9145 "Address Family modifier\n"
9146 "Address Family modifier\n"
9147 "Display routes matching the communities\n")
9148{
9149 if (strncmp (argv[0], "m", 1) == 0)
9150 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9151 bgp_show_type_community_all, NULL);
9152
9153 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9154 bgp_show_type_community_all, NULL);
9155}
9156
Lou Bergerf9b6c392016-01-12 13:42:09 -05009157DEFUN (show_bgp_community_all,
9158 show_bgp_community_all_cmd,
9159 "show bgp community",
9160 SHOW_STR
9161 BGP_STR
9162 "Display routes matching the communities\n")
9163{
9164 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9165 bgp_show_type_community_all, NULL);
9166}
9167
9168ALIAS (show_bgp_community_all,
9169 show_bgp_ipv6_community_all_cmd,
9170 "show bgp ipv6 community",
9171 SHOW_STR
9172 BGP_STR
9173 "Address family\n"
9174 "Display routes matching the communities\n")
9175
9176/* old command */
9177DEFUN (show_ipv6_bgp_community_all,
9178 show_ipv6_bgp_community_all_cmd,
9179 "show ipv6 bgp community",
9180 SHOW_STR
9181 IPV6_STR
9182 BGP_STR
9183 "Display routes matching the communities\n")
9184{
9185 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9186 bgp_show_type_community_all, NULL);
9187}
9188
9189/* old command */
9190DEFUN (show_ipv6_mbgp_community_all,
9191 show_ipv6_mbgp_community_all_cmd,
9192 "show ipv6 mbgp community",
9193 SHOW_STR
9194 IPV6_STR
9195 MBGP_STR
9196 "Display routes matching the communities\n")
9197{
9198 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
9199 bgp_show_type_community_all, NULL);
9200}
Lou Bergerf9b6c392016-01-12 13:42:09 -05009201
Job Snijders3334bab2017-01-20 14:47:12 +00009202/* large-community */
9203DEFUN (show_ip_bgp_lcommunity_all,
9204 show_ip_bgp_lcommunity_all_cmd,
9205 "show ip bgp large-community",
9206 SHOW_STR
9207 IP_STR
9208 BGP_STR
9209 "Display routes matching the large-communities\n")
9210{
9211 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9212 bgp_show_type_lcommunity_all, NULL);
9213}
9214
9215DEFUN (show_ip_bgp_ipv4_lcommunity_all,
9216 show_ip_bgp_ipv4_lcommunity_all_cmd,
9217 "show ip bgp ipv4 (unicast|multicast) large-community",
9218 SHOW_STR
9219 IP_STR
9220 BGP_STR
9221 "Address family\n"
9222 "Address Family modifier\n"
9223 "Address Family modifier\n"
9224 "Display routes matching the large-communities\n")
9225{
9226 if (strncmp (argv[0], "m", 1) == 0)
9227 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9228 bgp_show_type_lcommunity_all, NULL);
9229
9230 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9231 bgp_show_type_lcommunity_all, NULL);
9232}
9233
9234DEFUN (show_bgp_lcommunity_all,
9235 show_bgp_lcommunity_all_cmd,
9236 "show bgp large-community",
9237 SHOW_STR
9238 BGP_STR
9239 "Display routes matching the large-communities\n")
9240{
9241 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9242 bgp_show_type_lcommunity_all, NULL);
9243}
9244
9245ALIAS (show_bgp_lcommunity_all,
9246 show_bgp_ipv6_lcommunity_all_cmd,
9247 "show bgp ipv6 large-community",
9248 SHOW_STR
9249 BGP_STR
9250 "Address family\n"
9251 "Display routes matching the large-communities\n")
9252
9253/* old command */
9254DEFUN (show_ipv6_bgp_lcommunity_all,
9255 show_ipv6_bgp_lcommunity_all_cmd,
9256 "show ipv6 bgp large-community",
9257 SHOW_STR
9258 IPV6_STR
9259 BGP_STR
9260 "Display routes matching the large-communities\n")
9261{
9262 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9263 bgp_show_type_lcommunity_all, NULL);
9264}
9265
9266/* old command */
9267DEFUN (show_ipv6_mbgp_lcommunity_all,
9268 show_ipv6_mbgp_lcommunity_all_cmd,
9269 "show ipv6 mbgp large-community",
9270 SHOW_STR
9271 IPV6_STR
9272 MBGP_STR
9273 "Display routes matching the large-communities\n")
9274{
9275 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
9276 bgp_show_type_lcommunity_all, NULL);
9277}
9278
9279
Lou Berger651b4022016-01-12 13:42:07 -05009280DEFUN (show_bgp_ipv4_route_map,
9281 show_bgp_ipv4_route_map_cmd,
9282 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00009283 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009284 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009285 IP_STR
paul718e3742002-12-13 20:15:29 +00009286 "Display routes matching the route-map\n"
9287 "A route-map to match on\n")
9288{
9289 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
9290 bgp_show_type_route_map);
9291}
9292
Lou Berger651b4022016-01-12 13:42:07 -05009293DEFUN (show_bgp_ipv4_safi_flap_route_map,
9294 show_bgp_ipv4_safi_flap_route_map_cmd,
9295 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00009296 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009297 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009298 IP_STR
9299 "Address Family Modifier\n"
9300 "Address Family Modifier\n"
9301 "Address Family Modifier\n"
9302 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009303 "Display flap statistics of routes\n"
9304 "Display routes matching the route-map\n"
9305 "A route-map to match on\n")
9306{
Lou Berger651b4022016-01-12 13:42:07 -05009307 safi_t safi;
9308 if (bgp_parse_safi(argv[0], &safi)) {
9309 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9310 return CMD_WARNING;
9311 }
9312 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00009313 bgp_show_type_flap_route_map);
9314}
9315
Lou Berger651b4022016-01-12 13:42:07 -05009316ALIAS (show_bgp_ipv4_safi_flap_route_map,
9317 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
9318 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05309319 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309320 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009321 IP_STR
9322 "Address Family Modifier\n"
9323 "Address Family Modifier\n"
9324 "Address Family Modifier\n"
9325 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309326 "Display detailed information about dampening\n"
9327 "Display flap statistics of routes\n"
9328 "Display routes matching the route-map\n"
9329 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05009330
Lou Berger651b4022016-01-12 13:42:07 -05009331DEFUN (show_bgp_ipv6_safi_flap_route_map,
9332 show_bgp_ipv6_safi_flap_route_map_cmd,
9333 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00009334 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05009335 BGP_STR
9336 IPV6_STR
9337 "Address Family Modifier\n"
9338 "Address Family Modifier\n"
9339 "Address Family Modifier\n"
9340 "Address Family Modifier\n"
9341 "Display flap statistics of routes\n"
9342 "Display routes matching the route-map\n"
9343 "A route-map to match on\n")
9344{
9345 safi_t safi;
9346 if (bgp_parse_safi(argv[0], &safi)) {
9347 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9348 return CMD_WARNING;
9349 }
9350 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
9351 bgp_show_type_flap_route_map);
9352}
9353ALIAS (show_bgp_ipv6_safi_flap_route_map,
9354 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
9355 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
9356 SHOW_STR
9357 BGP_STR
9358 IPV6_STR
9359 "Address Family Modifier\n"
9360 "Address Family Modifier\n"
9361 "Address Family Modifier\n"
9362 "Address Family Modifier\n"
9363 "Display detailed information about dampening\n"
9364 "Display flap statistics of routes\n"
9365 "Display routes matching the route-map\n"
9366 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009367
9368DEFUN (show_bgp_ipv4_safi_route_map,
9369 show_bgp_ipv4_safi_route_map_cmd,
9370 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
9371 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009372 BGP_STR
9373 "Address family\n"
9374 "Address Family modifier\n"
9375 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05009376 "Address Family modifier\n"
9377 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009378 "Display routes matching the route-map\n"
9379 "A route-map to match on\n")
9380{
Lou Berger651b4022016-01-12 13:42:07 -05009381 safi_t safi;
9382 if (bgp_parse_safi(argv[0], &safi)) {
9383 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9384 return CMD_WARNING;
9385 }
9386 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00009387 bgp_show_type_route_map);
9388}
Lou Berger205e6742016-01-12 13:42:11 -05009389
Lou Berger651b4022016-01-12 13:42:07 -05009390DEFUN (show_bgp_ipv6_safi_route_map,
9391 show_bgp_ipv6_safi_route_map_cmd,
9392 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00009393 SHOW_STR
9394 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009395 "Address family\n"
9396 "Address Family modifier\n"
9397 "Address Family modifier\n"
9398 "Address Family modifier\n"
9399 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009400 "Display routes matching the route-map\n"
9401 "A route-map to match on\n")
9402{
Lou Berger651b4022016-01-12 13:42:07 -05009403 safi_t safi;
9404 if (bgp_parse_safi(argv[0], &safi)) {
9405 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9406 return CMD_WARNING;
9407 }
9408 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00009409 bgp_show_type_route_map);
9410}
9411
Lou Berger651b4022016-01-12 13:42:07 -05009412DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00009413 show_bgp_ipv6_route_map_cmd,
9414 "show bgp ipv6 route-map WORD",
9415 SHOW_STR
9416 BGP_STR
9417 "Address family\n"
9418 "Display routes matching the route-map\n"
9419 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009420{
9421 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9422 bgp_show_type_route_map);
9423}
David Lamparter6b0655a2014-06-04 06:53:35 +02009424
Lou Berger651b4022016-01-12 13:42:07 -05009425DEFUN (show_bgp_ipv4_cidr_only,
9426 show_bgp_ipv4_cidr_only_cmd,
9427 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00009428 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009429 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009430 IP_STR
paul718e3742002-12-13 20:15:29 +00009431 "Display only routes with non-natural netmasks\n")
9432{
9433 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009434 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009435}
9436
Lou Berger651b4022016-01-12 13:42:07 -05009437DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
9438 show_bgp_ipv4_safi_flap_cidr_only_cmd,
9439 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00009440 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009441 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009442 "Address Family\n"
9443 "Address Family Modifier\n"
9444 "Address Family Modifier\n"
9445 "Address Family Modifier\n"
9446 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009447 "Display flap statistics of routes\n"
9448 "Display only routes with non-natural netmasks\n")
9449{
Lou Berger651b4022016-01-12 13:42:07 -05009450 safi_t safi;
9451
9452 if (bgp_parse_safi(argv[0], &safi)) {
9453 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9454 return CMD_WARNING;
9455 }
9456 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009457}
9458
Lou Berger651b4022016-01-12 13:42:07 -05009459ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9460 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9461 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309462 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309463 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009464 "Address Family\n"
9465 "Address Family Modifier\n"
9466 "Address Family Modifier\n"
9467 "Address Family Modifier\n"
9468 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309469 "Display detailed information about dampening\n"
9470 "Display flap statistics of routes\n"
9471 "Display only routes with non-natural netmasks\n")
9472
Lou Berger651b4022016-01-12 13:42:07 -05009473DEFUN (show_bgp_ipv4_safi_cidr_only,
9474 show_bgp_ipv4_safi_cidr_only_cmd,
9475 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009476 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009477 BGP_STR
9478 "Address family\n"
9479 "Address Family modifier\n"
9480 "Address Family modifier\n"
9481 "Display only routes with non-natural netmasks\n")
9482{
9483 if (strncmp (argv[0], "m", 1) == 0)
9484 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009485 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009486
9487 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009488 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009489}
David Lamparter6b0655a2014-06-04 06:53:35 +02009490
Lou Berger651b4022016-01-12 13:42:07 -05009491/* new046 */
9492DEFUN (show_bgp_afi_safi_community_all,
9493 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009494 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009495 SHOW_STR
9496 BGP_STR
9497 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009498 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009499 "Address Family modifier\n"
9500 "Address Family modifier\n"
9501 "Address Family modifier\n"
9502 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009503 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009504{
9505 safi_t safi;
9506 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009507
Lou Berger651b4022016-01-12 13:42:07 -05009508 if (bgp_parse_afi(argv[0], &afi)) {
9509 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9510 return CMD_WARNING;
9511 }
9512 if (bgp_parse_safi(argv[1], &safi)) {
9513 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9514 return CMD_WARNING;
9515 }
9516
9517 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9518}
9519DEFUN (show_bgp_afi_community_all,
9520 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009521 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009522 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009523 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009524 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009525 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009526 "Display routes matching the communities\n")
9527{
Lou Berger651b4022016-01-12 13:42:07 -05009528 afi_t afi;
9529 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009530
Lou Berger651b4022016-01-12 13:42:07 -05009531 if (bgp_parse_afi(argv[0], &afi)) {
9532 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9533 return CMD_WARNING;
9534 }
9535 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009536}
David Lamparter6b0655a2014-06-04 06:53:35 +02009537
paul94f2b392005-06-28 12:44:16 +00009538static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009539bgp_show_community (struct vty *vty, const char *view_name, int argc,
9540 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009541{
9542 struct community *com;
9543 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009544 struct bgp *bgp;
Christian Frankec8e80972016-06-14 20:07:01 +02009545 int i, rv;
paul718e3742002-12-13 20:15:29 +00009546 char *str;
9547 int first = 0;
9548
Michael Lambert95cbbd22010-07-23 14:43:04 -04009549 /* BGP structure lookup */
9550 if (view_name)
9551 {
9552 bgp = bgp_lookup_by_name (view_name);
9553 if (bgp == NULL)
9554 {
9555 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9556 return CMD_WARNING;
9557 }
9558 }
9559 else
9560 {
9561 bgp = bgp_get_default ();
9562 if (bgp == NULL)
9563 {
9564 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9565 return CMD_WARNING;
9566 }
9567 }
9568
paul718e3742002-12-13 20:15:29 +00009569 b = buffer_new (1024);
9570 for (i = 0; i < argc; i++)
9571 {
9572 if (first)
9573 buffer_putc (b, ' ');
9574 else
9575 {
9576 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9577 continue;
9578 first = 1;
9579 }
9580
9581 buffer_putstr (b, argv[i]);
9582 }
9583 buffer_putc (b, '\0');
9584
9585 str = buffer_getstr (b);
9586 buffer_free (b);
9587
9588 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009589 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009590 if (! com)
9591 {
9592 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9593 return CMD_WARNING;
9594 }
9595
Christian Frankec8e80972016-06-14 20:07:01 +02009596 rv = bgp_show (vty, bgp, afi, safi,
9597 (exact ? bgp_show_type_community_exact :
9598 bgp_show_type_community), com);
9599 community_free(com);
9600 return rv;
paul718e3742002-12-13 20:15:29 +00009601}
9602
Lou Bergerf9b6c392016-01-12 13:42:09 -05009603DEFUN (show_ip_bgp_community,
9604 show_ip_bgp_community_cmd,
9605 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9606 SHOW_STR
9607 IP_STR
9608 BGP_STR
9609 "Display routes matching the communities\n"
9610 "community number\n"
9611 "Do not send outside local AS (well-known community)\n"
9612 "Do not advertise to any peer (well-known community)\n"
9613 "Do not export to next AS (well-known community)\n")
9614{
9615 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9616}
9617
9618ALIAS (show_ip_bgp_community,
9619 show_ip_bgp_community2_cmd,
9620 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9621 SHOW_STR
9622 IP_STR
9623 BGP_STR
9624 "Display routes matching the communities\n"
9625 "community number\n"
9626 "Do not send outside local AS (well-known community)\n"
9627 "Do not advertise to any peer (well-known community)\n"
9628 "Do not export to next AS (well-known community)\n"
9629 "community number\n"
9630 "Do not send outside local AS (well-known community)\n"
9631 "Do not advertise to any peer (well-known community)\n"
9632 "Do not export to next AS (well-known community)\n")
9633
9634ALIAS (show_ip_bgp_community,
9635 show_ip_bgp_community3_cmd,
9636 "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)",
9637 SHOW_STR
9638 IP_STR
9639 BGP_STR
9640 "Display routes matching the communities\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
9654ALIAS (show_ip_bgp_community,
9655 show_ip_bgp_community4_cmd,
9656 "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)",
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 "community number\n"
9666 "Do not send outside local AS (well-known community)\n"
9667 "Do not advertise to any peer (well-known community)\n"
9668 "Do not export to next AS (well-known community)\n"
9669 "community number\n"
9670 "Do not send outside local AS (well-known community)\n"
9671 "Do not advertise to any peer (well-known community)\n"
9672 "Do not export to next AS (well-known community)\n"
9673 "community number\n"
9674 "Do not send outside local AS (well-known community)\n"
9675 "Do not advertise to any peer (well-known community)\n"
9676 "Do not export to next AS (well-known community)\n")
9677
9678DEFUN (show_ip_bgp_ipv4_community,
9679 show_ip_bgp_ipv4_community_cmd,
9680 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9681 SHOW_STR
9682 IP_STR
9683 BGP_STR
9684 "Address family\n"
9685 "Address Family modifier\n"
9686 "Address Family modifier\n"
9687 "Display routes matching the communities\n"
9688 "community number\n"
9689 "Do not send outside local AS (well-known community)\n"
9690 "Do not advertise to any peer (well-known community)\n"
9691 "Do not export to next AS (well-known community)\n")
9692{
9693 if (strncmp (argv[0], "m", 1) == 0)
9694 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9695
9696 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9697}
9698
9699ALIAS (show_ip_bgp_ipv4_community,
9700 show_ip_bgp_ipv4_community2_cmd,
9701 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9702 SHOW_STR
9703 IP_STR
9704 BGP_STR
9705 "Address family\n"
9706 "Address Family modifier\n"
9707 "Address Family modifier\n"
9708 "Display routes matching the communities\n"
9709 "community number\n"
9710 "Do not send outside local AS (well-known community)\n"
9711 "Do not advertise to any peer (well-known community)\n"
9712 "Do not export to next AS (well-known community)\n"
9713 "community number\n"
9714 "Do not send outside local AS (well-known community)\n"
9715 "Do not advertise to any peer (well-known community)\n"
9716 "Do not export to next AS (well-known community)\n")
9717
9718ALIAS (show_ip_bgp_ipv4_community,
9719 show_ip_bgp_ipv4_community3_cmd,
9720 "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)",
9721 SHOW_STR
9722 IP_STR
9723 BGP_STR
9724 "Address family\n"
9725 "Address Family modifier\n"
9726 "Address Family modifier\n"
9727 "Display routes matching the communities\n"
9728 "community number\n"
9729 "Do not send outside local AS (well-known community)\n"
9730 "Do not advertise to any peer (well-known community)\n"
9731 "Do not export to next AS (well-known community)\n"
9732 "community number\n"
9733 "Do not send outside local AS (well-known community)\n"
9734 "Do not advertise to any peer (well-known community)\n"
9735 "Do not export to next AS (well-known community)\n"
9736 "community number\n"
9737 "Do not send outside local AS (well-known community)\n"
9738 "Do not advertise to any peer (well-known community)\n"
9739 "Do not export to next AS (well-known community)\n")
9740
9741ALIAS (show_ip_bgp_ipv4_community,
9742 show_ip_bgp_ipv4_community4_cmd,
9743 "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)",
9744 SHOW_STR
9745 IP_STR
9746 BGP_STR
9747 "Address family\n"
9748 "Address Family modifier\n"
9749 "Address Family modifier\n"
9750 "Display routes matching the communities\n"
9751 "community number\n"
9752 "Do not send outside local AS (well-known community)\n"
9753 "Do not advertise to any peer (well-known community)\n"
9754 "Do not export to next AS (well-known community)\n"
9755 "community number\n"
9756 "Do not send outside local AS (well-known community)\n"
9757 "Do not advertise to any peer (well-known community)\n"
9758 "Do not export to next AS (well-known community)\n"
9759 "community number\n"
9760 "Do not send outside local AS (well-known community)\n"
9761 "Do not advertise to any peer (well-known community)\n"
9762 "Do not export to next AS (well-known community)\n"
9763 "community number\n"
9764 "Do not send outside local AS (well-known community)\n"
9765 "Do not advertise to any peer (well-known community)\n"
9766 "Do not export to next AS (well-known community)\n")
9767
9768DEFUN (show_ip_bgp_community_exact,
9769 show_ip_bgp_community_exact_cmd,
9770 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9771 SHOW_STR
9772 IP_STR
9773 BGP_STR
9774 "Display routes matching the communities\n"
9775 "community number\n"
9776 "Do not send outside local AS (well-known community)\n"
9777 "Do not advertise to any peer (well-known community)\n"
9778 "Do not export to next AS (well-known community)\n"
9779 "Exact match of the communities")
9780{
9781 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9782}
9783
9784ALIAS (show_ip_bgp_community_exact,
9785 show_ip_bgp_community2_exact_cmd,
9786 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9787 SHOW_STR
9788 IP_STR
9789 BGP_STR
9790 "Display routes matching the communities\n"
9791 "community number\n"
9792 "Do not send outside local AS (well-known community)\n"
9793 "Do not advertise to any peer (well-known community)\n"
9794 "Do not export to next AS (well-known community)\n"
9795 "community number\n"
9796 "Do not send outside local AS (well-known community)\n"
9797 "Do not advertise to any peer (well-known community)\n"
9798 "Do not export to next AS (well-known community)\n"
9799 "Exact match of the communities")
9800
9801ALIAS (show_ip_bgp_community_exact,
9802 show_ip_bgp_community3_exact_cmd,
9803 "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",
9804 SHOW_STR
9805 IP_STR
9806 BGP_STR
9807 "Display routes matching the communities\n"
9808 "community number\n"
9809 "Do not send outside local AS (well-known community)\n"
9810 "Do not advertise to any peer (well-known community)\n"
9811 "Do not export to next AS (well-known community)\n"
9812 "community number\n"
9813 "Do not send outside local AS (well-known community)\n"
9814 "Do not advertise to any peer (well-known community)\n"
9815 "Do not export to next AS (well-known community)\n"
9816 "community number\n"
9817 "Do not send outside local AS (well-known community)\n"
9818 "Do not advertise to any peer (well-known community)\n"
9819 "Do not export to next AS (well-known community)\n"
9820 "Exact match of the communities")
9821
9822ALIAS (show_ip_bgp_community_exact,
9823 show_ip_bgp_community4_exact_cmd,
9824 "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",
9825 SHOW_STR
9826 IP_STR
9827 BGP_STR
9828 "Display routes matching the communities\n"
9829 "community number\n"
9830 "Do not send outside local AS (well-known community)\n"
9831 "Do not advertise to any peer (well-known community)\n"
9832 "Do not export to next AS (well-known community)\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 "community number\n"
9838 "Do not send outside local AS (well-known community)\n"
9839 "Do not advertise to any peer (well-known community)\n"
9840 "Do not export to next AS (well-known community)\n"
9841 "community number\n"
9842 "Do not send outside local AS (well-known community)\n"
9843 "Do not advertise to any peer (well-known community)\n"
9844 "Do not export to next AS (well-known community)\n"
9845 "Exact match of the communities")
9846
9847DEFUN (show_ip_bgp_ipv4_community_exact,
9848 show_ip_bgp_ipv4_community_exact_cmd,
9849 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9850 SHOW_STR
9851 IP_STR
9852 BGP_STR
9853 "Address family\n"
9854 "Address Family modifier\n"
9855 "Address Family modifier\n"
9856 "Display routes matching the communities\n"
9857 "community number\n"
9858 "Do not send outside local AS (well-known community)\n"
9859 "Do not advertise to any peer (well-known community)\n"
9860 "Do not export to next AS (well-known community)\n"
9861 "Exact match of the communities")
9862{
9863 if (strncmp (argv[0], "m", 1) == 0)
9864 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9865
9866 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9867}
9868
9869ALIAS (show_ip_bgp_ipv4_community_exact,
9870 show_ip_bgp_ipv4_community2_exact_cmd,
9871 "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",
9872 SHOW_STR
9873 IP_STR
9874 BGP_STR
9875 "Address family\n"
9876 "Address Family modifier\n"
9877 "Address Family modifier\n"
9878 "Display routes matching the communities\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 "community number\n"
9884 "Do not send outside local AS (well-known community)\n"
9885 "Do not advertise to any peer (well-known community)\n"
9886 "Do not export to next AS (well-known community)\n"
9887 "Exact match of the communities")
9888
9889ALIAS (show_ip_bgp_ipv4_community_exact,
9890 show_ip_bgp_ipv4_community3_exact_cmd,
9891 "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",
9892 SHOW_STR
9893 IP_STR
9894 BGP_STR
9895 "Address family\n"
9896 "Address Family modifier\n"
9897 "Address Family modifier\n"
9898 "Display routes matching the communities\n"
9899 "community number\n"
9900 "Do not send outside local AS (well-known community)\n"
9901 "Do not advertise to any peer (well-known community)\n"
9902 "Do not export to next AS (well-known community)\n"
9903 "community number\n"
9904 "Do not send outside local AS (well-known community)\n"
9905 "Do not advertise to any peer (well-known community)\n"
9906 "Do not export to next AS (well-known community)\n"
9907 "community number\n"
9908 "Do not send outside local AS (well-known community)\n"
9909 "Do not advertise to any peer (well-known community)\n"
9910 "Do not export to next AS (well-known community)\n"
9911 "Exact match of the communities")
9912
9913ALIAS (show_ip_bgp_ipv4_community_exact,
9914 show_ip_bgp_ipv4_community4_exact_cmd,
9915 "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",
9916 SHOW_STR
9917 IP_STR
9918 BGP_STR
9919 "Address family\n"
9920 "Address Family modifier\n"
9921 "Address Family modifier\n"
9922 "Display routes matching the communities\n"
9923 "community number\n"
9924 "Do not send outside local AS (well-known community)\n"
9925 "Do not advertise to any peer (well-known community)\n"
9926 "Do not export to next AS (well-known community)\n"
9927 "community number\n"
9928 "Do not send outside local AS (well-known community)\n"
9929 "Do not advertise to any peer (well-known community)\n"
9930 "Do not export to next AS (well-known community)\n"
9931 "community number\n"
9932 "Do not send outside local AS (well-known community)\n"
9933 "Do not advertise to any peer (well-known community)\n"
9934 "Do not export to next AS (well-known community)\n"
9935 "community number\n"
9936 "Do not send outside local AS (well-known community)\n"
9937 "Do not advertise to any peer (well-known community)\n"
9938 "Do not export to next AS (well-known community)\n"
9939 "Exact match of the communities")
9940
Lou Bergerf9b6c392016-01-12 13:42:09 -05009941DEFUN (show_bgp_community,
9942 show_bgp_community_cmd,
9943 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9944 SHOW_STR
9945 BGP_STR
9946 "Display routes matching the communities\n"
9947 "community number\n"
9948 "Do not send outside local AS (well-known community)\n"
9949 "Do not advertise to any peer (well-known community)\n"
9950 "Do not export to next AS (well-known community)\n")
9951{
9952 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9953}
9954
9955ALIAS (show_bgp_community,
9956 show_bgp_ipv6_community_cmd,
9957 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9958 SHOW_STR
9959 BGP_STR
9960 "Address family\n"
9961 "Display routes matching the communities\n"
9962 "community number\n"
9963 "Do not send outside local AS (well-known community)\n"
9964 "Do not advertise to any peer (well-known community)\n"
9965 "Do not export to next AS (well-known community)\n")
9966
9967ALIAS (show_bgp_community,
9968 show_bgp_community2_cmd,
9969 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9970 SHOW_STR
9971 BGP_STR
9972 "Display routes matching the communities\n"
9973 "community number\n"
9974 "Do not send outside local AS (well-known community)\n"
9975 "Do not advertise to any peer (well-known community)\n"
9976 "Do not export to next AS (well-known community)\n"
9977 "community number\n"
9978 "Do not send outside local AS (well-known community)\n"
9979 "Do not advertise to any peer (well-known community)\n"
9980 "Do not export to next AS (well-known community)\n")
9981
9982ALIAS (show_bgp_community,
9983 show_bgp_ipv6_community2_cmd,
9984 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9985 SHOW_STR
9986 BGP_STR
9987 "Address family\n"
9988 "Display routes matching the communities\n"
9989 "community number\n"
9990 "Do not send outside local AS (well-known community)\n"
9991 "Do not advertise to any peer (well-known community)\n"
9992 "Do not export to next AS (well-known community)\n"
9993 "community number\n"
9994 "Do not send outside local AS (well-known community)\n"
9995 "Do not advertise to any peer (well-known community)\n"
9996 "Do not export to next AS (well-known community)\n")
9997
9998ALIAS (show_bgp_community,
9999 show_bgp_community3_cmd,
10000 "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)",
10001 SHOW_STR
10002 BGP_STR
10003 "Display routes matching the communities\n"
10004 "community number\n"
10005 "Do not send outside local AS (well-known community)\n"
10006 "Do not advertise to any peer (well-known community)\n"
10007 "Do not export to next AS (well-known community)\n"
10008 "community number\n"
10009 "Do not send outside local AS (well-known community)\n"
10010 "Do not advertise to any peer (well-known community)\n"
10011 "Do not export to next AS (well-known community)\n"
10012 "community number\n"
10013 "Do not send outside local AS (well-known community)\n"
10014 "Do not advertise to any peer (well-known community)\n"
10015 "Do not export to next AS (well-known community)\n")
10016
10017ALIAS (show_bgp_community,
10018 show_bgp_ipv6_community3_cmd,
10019 "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)",
10020 SHOW_STR
10021 BGP_STR
10022 "Address family\n"
10023 "Display routes matching the communities\n"
10024 "community number\n"
10025 "Do not send outside local AS (well-known community)\n"
10026 "Do not advertise to any peer (well-known community)\n"
10027 "Do not export to next AS (well-known community)\n"
10028 "community number\n"
10029 "Do not send outside local AS (well-known community)\n"
10030 "Do not advertise to any peer (well-known community)\n"
10031 "Do not export to next AS (well-known community)\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
10037ALIAS (show_bgp_community,
10038 show_bgp_community4_cmd,
10039 "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)",
10040 SHOW_STR
10041 BGP_STR
10042 "Display routes matching the communities\n"
10043 "community number\n"
10044 "Do not send outside local AS (well-known community)\n"
10045 "Do not advertise to any peer (well-known community)\n"
10046 "Do not export to next AS (well-known community)\n"
10047 "community number\n"
10048 "Do not send outside local AS (well-known community)\n"
10049 "Do not advertise to any peer (well-known community)\n"
10050 "Do not export to next AS (well-known community)\n"
10051 "community number\n"
10052 "Do not send outside local AS (well-known community)\n"
10053 "Do not advertise to any peer (well-known community)\n"
10054 "Do not export to next AS (well-known community)\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
10060ALIAS (show_bgp_community,
10061 show_bgp_ipv6_community4_cmd,
10062 "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)",
10063 SHOW_STR
10064 BGP_STR
10065 "Address family\n"
10066 "Display routes matching the communities\n"
10067 "community number\n"
10068 "Do not send outside local AS (well-known community)\n"
10069 "Do not advertise to any peer (well-known community)\n"
10070 "Do not export to next AS (well-known community)\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 "community number\n"
10076 "Do not send outside local AS (well-known community)\n"
10077 "Do not advertise to any peer (well-known community)\n"
10078 "Do not export to next AS (well-known community)\n"
10079 "community number\n"
10080 "Do not send outside local AS (well-known community)\n"
10081 "Do not advertise to any peer (well-known community)\n"
10082 "Do not export to next AS (well-known community)\n")
10083
10084/* old command */
10085DEFUN (show_ipv6_bgp_community,
10086 show_ipv6_bgp_community_cmd,
10087 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10088 SHOW_STR
10089 IPV6_STR
10090 BGP_STR
10091 "Display routes matching the communities\n"
10092 "community number\n"
10093 "Do not send outside local AS (well-known community)\n"
10094 "Do not advertise to any peer (well-known community)\n"
10095 "Do not export to next AS (well-known community)\n")
10096{
10097 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
10098}
10099
10100/* old command */
10101ALIAS (show_ipv6_bgp_community,
10102 show_ipv6_bgp_community2_cmd,
10103 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10104 SHOW_STR
10105 IPV6_STR
10106 BGP_STR
10107 "Display routes matching the communities\n"
10108 "community number\n"
10109 "Do not send outside local AS (well-known community)\n"
10110 "Do not advertise to any peer (well-known community)\n"
10111 "Do not export to next AS (well-known community)\n"
10112 "community number\n"
10113 "Do not send outside local AS (well-known community)\n"
10114 "Do not advertise to any peer (well-known community)\n"
10115 "Do not export to next AS (well-known community)\n")
10116
10117/* old command */
10118ALIAS (show_ipv6_bgp_community,
10119 show_ipv6_bgp_community3_cmd,
10120 "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)",
10121 SHOW_STR
10122 IPV6_STR
10123 BGP_STR
10124 "Display routes matching the communities\n"
10125 "community number\n"
10126 "Do not send outside local AS (well-known community)\n"
10127 "Do not advertise to any peer (well-known community)\n"
10128 "Do not export to next AS (well-known community)\n"
10129 "community number\n"
10130 "Do not send outside local AS (well-known community)\n"
10131 "Do not advertise to any peer (well-known community)\n"
10132 "Do not export to next AS (well-known community)\n"
10133 "community number\n"
10134 "Do not send outside local AS (well-known community)\n"
10135 "Do not advertise to any peer (well-known community)\n"
10136 "Do not export to next AS (well-known community)\n")
10137
10138/* old command */
10139ALIAS (show_ipv6_bgp_community,
10140 show_ipv6_bgp_community4_cmd,
10141 "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)",
10142 SHOW_STR
10143 IPV6_STR
10144 BGP_STR
10145 "Display routes matching the communities\n"
10146 "community number\n"
10147 "Do not send outside local AS (well-known community)\n"
10148 "Do not advertise to any peer (well-known community)\n"
10149 "Do not export to next AS (well-known community)\n"
10150 "community number\n"
10151 "Do not send outside local AS (well-known community)\n"
10152 "Do not advertise to any peer (well-known community)\n"
10153 "Do not export to next AS (well-known community)\n"
10154 "community number\n"
10155 "Do not send outside local AS (well-known community)\n"
10156 "Do not advertise to any peer (well-known community)\n"
10157 "Do not export to next AS (well-known community)\n"
10158 "community number\n"
10159 "Do not send outside local AS (well-known community)\n"
10160 "Do not advertise to any peer (well-known community)\n"
10161 "Do not export to next AS (well-known community)\n")
10162
10163DEFUN (show_bgp_community_exact,
10164 show_bgp_community_exact_cmd,
10165 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10166 SHOW_STR
10167 BGP_STR
10168 "Display routes matching the communities\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{
10175 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10176}
10177
10178ALIAS (show_bgp_community_exact,
10179 show_bgp_ipv6_community_exact_cmd,
10180 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10181 SHOW_STR
10182 BGP_STR
10183 "Address family\n"
10184 "Display routes matching the communities\n"
10185 "community number\n"
10186 "Do not send outside local AS (well-known community)\n"
10187 "Do not advertise to any peer (well-known community)\n"
10188 "Do not export to next AS (well-known community)\n"
10189 "Exact match of the communities")
10190
10191ALIAS (show_bgp_community_exact,
10192 show_bgp_community2_exact_cmd,
10193 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10194 SHOW_STR
10195 BGP_STR
10196 "Display routes matching the communities\n"
10197 "community number\n"
10198 "Do not send outside local AS (well-known community)\n"
10199 "Do not advertise to any peer (well-known community)\n"
10200 "Do not export to next AS (well-known community)\n"
10201 "community number\n"
10202 "Do not send outside local AS (well-known community)\n"
10203 "Do not advertise to any peer (well-known community)\n"
10204 "Do not export to next AS (well-known community)\n"
10205 "Exact match of the communities")
10206
10207ALIAS (show_bgp_community_exact,
10208 show_bgp_ipv6_community2_exact_cmd,
10209 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10210 SHOW_STR
10211 BGP_STR
10212 "Address family\n"
10213 "Display routes matching the communities\n"
10214 "community number\n"
10215 "Do not send outside local AS (well-known community)\n"
10216 "Do not advertise to any peer (well-known community)\n"
10217 "Do not export to next AS (well-known community)\n"
10218 "community number\n"
10219 "Do not send outside local AS (well-known community)\n"
10220 "Do not advertise to any peer (well-known community)\n"
10221 "Do not export to next AS (well-known community)\n"
10222 "Exact match of the communities")
10223
10224ALIAS (show_bgp_community_exact,
10225 show_bgp_community3_exact_cmd,
10226 "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",
10227 SHOW_STR
10228 BGP_STR
10229 "Display routes matching the communities\n"
10230 "community number\n"
10231 "Do not send outside local AS (well-known community)\n"
10232 "Do not advertise to any peer (well-known community)\n"
10233 "Do not export to next AS (well-known community)\n"
10234 "community number\n"
10235 "Do not send outside local AS (well-known community)\n"
10236 "Do not advertise to any peer (well-known community)\n"
10237 "Do not export to next AS (well-known community)\n"
10238 "community number\n"
10239 "Do not send outside local AS (well-known community)\n"
10240 "Do not advertise to any peer (well-known community)\n"
10241 "Do not export to next AS (well-known community)\n"
10242 "Exact match of the communities")
10243
10244ALIAS (show_bgp_community_exact,
10245 show_bgp_ipv6_community3_exact_cmd,
10246 "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",
10247 SHOW_STR
10248 BGP_STR
10249 "Address family\n"
10250 "Display routes matching the communities\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 "community number\n"
10256 "Do not send outside local AS (well-known community)\n"
10257 "Do not advertise to any peer (well-known community)\n"
10258 "Do not export to next AS (well-known community)\n"
10259 "community number\n"
10260 "Do not send outside local AS (well-known community)\n"
10261 "Do not advertise to any peer (well-known community)\n"
10262 "Do not export to next AS (well-known community)\n"
10263 "Exact match of the communities")
10264
10265ALIAS (show_bgp_community_exact,
10266 show_bgp_community4_exact_cmd,
10267 "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",
10268 SHOW_STR
10269 BGP_STR
10270 "Display routes matching the communities\n"
10271 "community number\n"
10272 "Do not send outside local AS (well-known community)\n"
10273 "Do not advertise to any peer (well-known community)\n"
10274 "Do not export to next AS (well-known community)\n"
10275 "community number\n"
10276 "Do not send outside local AS (well-known community)\n"
10277 "Do not advertise to any peer (well-known community)\n"
10278 "Do not export to next AS (well-known community)\n"
10279 "community number\n"
10280 "Do not send outside local AS (well-known community)\n"
10281 "Do not advertise to any peer (well-known community)\n"
10282 "Do not export to next AS (well-known community)\n"
10283 "community number\n"
10284 "Do not send outside local AS (well-known community)\n"
10285 "Do not advertise to any peer (well-known community)\n"
10286 "Do not export to next AS (well-known community)\n"
10287 "Exact match of the communities")
10288
10289ALIAS (show_bgp_community_exact,
10290 show_bgp_ipv6_community4_exact_cmd,
10291 "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",
10292 SHOW_STR
10293 BGP_STR
10294 "Address family\n"
10295 "Display routes matching the communities\n"
10296 "community number\n"
10297 "Do not send outside local AS (well-known community)\n"
10298 "Do not advertise to any peer (well-known community)\n"
10299 "Do not export to next AS (well-known community)\n"
10300 "community number\n"
10301 "Do not send outside local AS (well-known community)\n"
10302 "Do not advertise to any peer (well-known community)\n"
10303 "Do not export to next AS (well-known community)\n"
10304 "community number\n"
10305 "Do not send outside local AS (well-known community)\n"
10306 "Do not advertise to any peer (well-known community)\n"
10307 "Do not export to next AS (well-known community)\n"
10308 "community number\n"
10309 "Do not send outside local AS (well-known community)\n"
10310 "Do not advertise to any peer (well-known community)\n"
10311 "Do not export to next AS (well-known community)\n"
10312 "Exact match of the communities")
10313
10314/* old command */
10315DEFUN (show_ipv6_bgp_community_exact,
10316 show_ipv6_bgp_community_exact_cmd,
10317 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10318 SHOW_STR
10319 IPV6_STR
10320 BGP_STR
10321 "Display routes matching the communities\n"
10322 "community number\n"
10323 "Do not send outside local AS (well-known community)\n"
10324 "Do not advertise to any peer (well-known community)\n"
10325 "Do not export to next AS (well-known community)\n"
10326 "Exact match of the communities")
10327{
10328 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10329}
10330
10331/* old command */
10332ALIAS (show_ipv6_bgp_community_exact,
10333 show_ipv6_bgp_community2_exact_cmd,
10334 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10335 SHOW_STR
10336 IPV6_STR
10337 BGP_STR
10338 "Display routes matching the communities\n"
10339 "community number\n"
10340 "Do not send outside local AS (well-known community)\n"
10341 "Do not advertise to any peer (well-known community)\n"
10342 "Do not export to next AS (well-known community)\n"
10343 "community number\n"
10344 "Do not send outside local AS (well-known community)\n"
10345 "Do not advertise to any peer (well-known community)\n"
10346 "Do not export to next AS (well-known community)\n"
10347 "Exact match of the communities")
10348
10349/* old command */
10350ALIAS (show_ipv6_bgp_community_exact,
10351 show_ipv6_bgp_community3_exact_cmd,
10352 "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",
10353 SHOW_STR
10354 IPV6_STR
10355 BGP_STR
10356 "Display routes matching the communities\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 "community number\n"
10362 "Do not send outside local AS (well-known community)\n"
10363 "Do not advertise to any peer (well-known community)\n"
10364 "Do not export to next AS (well-known community)\n"
10365 "community number\n"
10366 "Do not send outside local AS (well-known community)\n"
10367 "Do not advertise to any peer (well-known community)\n"
10368 "Do not export to next AS (well-known community)\n"
10369 "Exact match of the communities")
10370
10371/* old command */
10372ALIAS (show_ipv6_bgp_community_exact,
10373 show_ipv6_bgp_community4_exact_cmd,
10374 "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",
10375 SHOW_STR
10376 IPV6_STR
10377 BGP_STR
10378 "Display routes matching the communities\n"
10379 "community number\n"
10380 "Do not send outside local AS (well-known community)\n"
10381 "Do not advertise to any peer (well-known community)\n"
10382 "Do not export to next AS (well-known community)\n"
10383 "community number\n"
10384 "Do not send outside local AS (well-known community)\n"
10385 "Do not advertise to any peer (well-known community)\n"
10386 "Do not export to next AS (well-known community)\n"
10387 "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 */
10398DEFUN (show_ipv6_mbgp_community,
10399 show_ipv6_mbgp_community_cmd,
10400 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
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{
10410 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
10411}
10412
10413/* old command */
10414ALIAS (show_ipv6_mbgp_community,
10415 show_ipv6_mbgp_community2_cmd,
10416 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10417 SHOW_STR
10418 IPV6_STR
10419 MBGP_STR
10420 "Display routes matching the communities\n"
10421 "community number\n"
10422 "Do not send outside local AS (well-known community)\n"
10423 "Do not advertise to any peer (well-known community)\n"
10424 "Do not export to next AS (well-known community)\n"
10425 "community number\n"
10426 "Do not send outside local AS (well-known community)\n"
10427 "Do not advertise to any peer (well-known community)\n"
10428 "Do not export to next AS (well-known community)\n")
10429
10430/* old command */
10431ALIAS (show_ipv6_mbgp_community,
10432 show_ipv6_mbgp_community3_cmd,
10433 "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)",
10434 SHOW_STR
10435 IPV6_STR
10436 MBGP_STR
10437 "Display routes matching the communities\n"
10438 "community number\n"
10439 "Do not send outside local AS (well-known community)\n"
10440 "Do not advertise to any peer (well-known community)\n"
10441 "Do not export to next AS (well-known community)\n"
10442 "community number\n"
10443 "Do not send outside local AS (well-known community)\n"
10444 "Do not advertise to any peer (well-known community)\n"
10445 "Do not export to next AS (well-known community)\n"
10446 "community number\n"
10447 "Do not send outside local AS (well-known community)\n"
10448 "Do not advertise to any peer (well-known community)\n"
10449 "Do not export to next AS (well-known community)\n")
10450
10451/* old command */
10452ALIAS (show_ipv6_mbgp_community,
10453 show_ipv6_mbgp_community4_cmd,
10454 "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)",
10455 SHOW_STR
10456 IPV6_STR
10457 MBGP_STR
10458 "Display routes matching the communities\n"
10459 "community number\n"
10460 "Do not send outside local AS (well-known community)\n"
10461 "Do not advertise to any peer (well-known community)\n"
10462 "Do not export to next AS (well-known community)\n"
10463 "community number\n"
10464 "Do not send outside local AS (well-known community)\n"
10465 "Do not advertise to any peer (well-known community)\n"
10466 "Do not export to next AS (well-known community)\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
10476/* old command */
10477DEFUN (show_ipv6_mbgp_community_exact,
10478 show_ipv6_mbgp_community_exact_cmd,
10479 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10480 SHOW_STR
10481 IPV6_STR
10482 MBGP_STR
10483 "Display routes matching the communities\n"
10484 "community number\n"
10485 "Do not send outside local AS (well-known community)\n"
10486 "Do not advertise to any peer (well-known community)\n"
10487 "Do not export to next AS (well-known community)\n"
10488 "Exact match of the communities")
10489{
10490 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10491}
10492
10493/* old command */
10494ALIAS (show_ipv6_mbgp_community_exact,
10495 show_ipv6_mbgp_community2_exact_cmd,
10496 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10497 SHOW_STR
10498 IPV6_STR
10499 MBGP_STR
10500 "Display routes matching the communities\n"
10501 "community number\n"
10502 "Do not send outside local AS (well-known community)\n"
10503 "Do not advertise to any peer (well-known community)\n"
10504 "Do not export to next AS (well-known community)\n"
10505 "community number\n"
10506 "Do not send outside local AS (well-known community)\n"
10507 "Do not advertise to any peer (well-known community)\n"
10508 "Do not export to next AS (well-known community)\n"
10509 "Exact match of the communities")
10510
10511/* old command */
10512ALIAS (show_ipv6_mbgp_community_exact,
10513 show_ipv6_mbgp_community3_exact_cmd,
10514 "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",
10515 SHOW_STR
10516 IPV6_STR
10517 MBGP_STR
10518 "Display routes matching the communities\n"
10519 "community number\n"
10520 "Do not send outside local AS (well-known community)\n"
10521 "Do not advertise to any peer (well-known community)\n"
10522 "Do not export to next AS (well-known community)\n"
10523 "community number\n"
10524 "Do not send outside local AS (well-known community)\n"
10525 "Do not advertise to any peer (well-known community)\n"
10526 "Do not export to next AS (well-known community)\n"
10527 "community number\n"
10528 "Do not send outside local AS (well-known community)\n"
10529 "Do not advertise to any peer (well-known community)\n"
10530 "Do not export to next AS (well-known community)\n"
10531 "Exact match of the communities")
10532
10533/* old command */
10534ALIAS (show_ipv6_mbgp_community_exact,
10535 show_ipv6_mbgp_community4_exact_cmd,
10536 "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",
10537 SHOW_STR
10538 IPV6_STR
10539 MBGP_STR
10540 "Display routes matching the communities\n"
10541 "community number\n"
10542 "Do not send outside local AS (well-known community)\n"
10543 "Do not advertise to any peer (well-known community)\n"
10544 "Do not export to next AS (well-known community)\n"
10545 "community number\n"
10546 "Do not send outside local AS (well-known community)\n"
10547 "Do not advertise to any peer (well-known community)\n"
10548 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010558
Lou Berger651b4022016-01-12 13:42:07 -050010559DEFUN (show_bgp_ipv4_community,
10560 show_bgp_ipv4_community_cmd,
10561 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010562 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010563 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010564 IP_STR
paul718e3742002-12-13 20:15:29 +000010565 "Display routes matching the communities\n"
10566 "community number\n"
10567 "Do not send outside local AS (well-known community)\n"
10568 "Do not advertise to any peer (well-known community)\n"
10569 "Do not export to next AS (well-known community)\n")
10570{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010571 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010572}
10573
Lou Berger651b4022016-01-12 13:42:07 -050010574ALIAS (show_bgp_ipv4_community,
10575 show_bgp_ipv4_community2_cmd,
10576 "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 +000010577 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010578 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010579 IP_STR
paul718e3742002-12-13 20:15:29 +000010580 "Display routes matching the communities\n"
10581 "community number\n"
10582 "Do not send outside local AS (well-known community)\n"
10583 "Do not advertise to any peer (well-known community)\n"
10584 "Do not export to next AS (well-known community)\n"
10585 "community number\n"
10586 "Do not send outside local AS (well-known community)\n"
10587 "Do not advertise to any peer (well-known community)\n"
10588 "Do not export to next AS (well-known community)\n")
10589
Lou Berger651b4022016-01-12 13:42:07 -050010590ALIAS (show_bgp_ipv4_community,
10591 show_bgp_ipv4_community3_cmd,
10592 "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 +000010593 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010594 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010595 IP_STR
paul718e3742002-12-13 20:15:29 +000010596 "Display routes matching the communities\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 "community number\n"
10606 "Do not send outside local AS (well-known community)\n"
10607 "Do not advertise to any peer (well-known community)\n"
10608 "Do not export to next AS (well-known community)\n")
10609
Lou Berger651b4022016-01-12 13:42:07 -050010610ALIAS (show_bgp_ipv4_community,
10611 show_bgp_ipv4_community4_cmd,
10612 "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 +000010613 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010614 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010615 IP_STR
paul718e3742002-12-13 20:15:29 +000010616 "Display routes matching the communities\n"
10617 "community number\n"
10618 "Do not send outside local AS (well-known community)\n"
10619 "Do not advertise to any peer (well-known community)\n"
10620 "Do not export to next AS (well-known community)\n"
10621 "community number\n"
10622 "Do not send outside local AS (well-known community)\n"
10623 "Do not advertise to any peer (well-known community)\n"
10624 "Do not export to next AS (well-known community)\n"
10625 "community number\n"
10626 "Do not send outside local AS (well-known community)\n"
10627 "Do not advertise to any peer (well-known community)\n"
10628 "Do not export to next AS (well-known community)\n"
10629 "community number\n"
10630 "Do not send outside local AS (well-known community)\n"
10631 "Do not advertise to any peer (well-known community)\n"
10632 "Do not export to next AS (well-known community)\n")
10633
Lou Berger651b4022016-01-12 13:42:07 -050010634DEFUN (show_bgp_ipv4_safi_community,
10635 show_bgp_ipv4_safi_community_cmd,
10636 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010637 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010638 BGP_STR
10639 "Address family\n"
10640 "Address Family modifier\n"
10641 "Address Family modifier\n"
10642 "Display routes matching the communities\n"
10643 "community number\n"
10644 "Do not send outside local AS (well-known community)\n"
10645 "Do not advertise to any peer (well-known community)\n"
10646 "Do not export to next AS (well-known community)\n")
10647{
10648 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010649 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010650
Michael Lambert95cbbd22010-07-23 14:43:04 -040010651 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010652}
10653
Lou Berger651b4022016-01-12 13:42:07 -050010654ALIAS (show_bgp_ipv4_safi_community,
10655 show_bgp_ipv4_safi_community2_cmd,
10656 "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 +000010657 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010658 BGP_STR
10659 "Address family\n"
10660 "Address Family modifier\n"
10661 "Address Family modifier\n"
10662 "Display routes matching the communities\n"
10663 "community number\n"
10664 "Do not send outside local AS (well-known community)\n"
10665 "Do not advertise to any peer (well-known community)\n"
10666 "Do not export to next AS (well-known community)\n"
10667 "community number\n"
10668 "Do not send outside local AS (well-known community)\n"
10669 "Do not advertise to any peer (well-known community)\n"
10670 "Do not export to next AS (well-known community)\n")
10671
Lou Berger651b4022016-01-12 13:42:07 -050010672ALIAS (show_bgp_ipv4_safi_community,
10673 show_bgp_ipv4_safi_community3_cmd,
10674 "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 +000010675 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010676 BGP_STR
10677 "Address family\n"
10678 "Address Family modifier\n"
10679 "Address Family modifier\n"
10680 "Display routes matching the communities\n"
10681 "community number\n"
10682 "Do not send outside local AS (well-known community)\n"
10683 "Do not advertise to any peer (well-known community)\n"
10684 "Do not export to next AS (well-known community)\n"
10685 "community number\n"
10686 "Do not send outside local AS (well-known community)\n"
10687 "Do not advertise to any peer (well-known community)\n"
10688 "Do not export to next AS (well-known community)\n"
10689 "community number\n"
10690 "Do not send outside local AS (well-known community)\n"
10691 "Do not advertise to any peer (well-known community)\n"
10692 "Do not export to next AS (well-known community)\n")
10693
Lou Berger651b4022016-01-12 13:42:07 -050010694ALIAS (show_bgp_ipv4_safi_community,
10695 show_bgp_ipv4_safi_community4_cmd,
10696 "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 +000010697 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010698 BGP_STR
10699 "Address family\n"
10700 "Address Family modifier\n"
10701 "Address Family modifier\n"
10702 "Display routes matching the communities\n"
10703 "community number\n"
10704 "Do not send outside local AS (well-known community)\n"
10705 "Do not advertise to any peer (well-known community)\n"
10706 "Do not export to next AS (well-known community)\n"
10707 "community number\n"
10708 "Do not send outside local AS (well-known community)\n"
10709 "Do not advertise to any peer (well-known community)\n"
10710 "Do not export to next AS (well-known community)\n"
10711 "community number\n"
10712 "Do not send outside local AS (well-known community)\n"
10713 "Do not advertise to any peer (well-known community)\n"
10714 "Do not export to next AS (well-known community)\n"
10715 "community number\n"
10716 "Do not send outside local AS (well-known community)\n"
10717 "Do not advertise to any peer (well-known community)\n"
10718 "Do not export to next AS (well-known community)\n")
10719
Michael Lambert95cbbd22010-07-23 14:43:04 -040010720DEFUN (show_bgp_view_afi_safi_community_all,
10721 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010722 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010723 SHOW_STR
10724 BGP_STR
10725 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010726 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010727 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010728 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010729 "Address Family modifier\n"
10730 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010731 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010732{
10733 int afi;
10734 int safi;
10735 struct bgp *bgp;
10736
10737 /* BGP structure lookup. */
10738 bgp = bgp_lookup_by_name (argv[0]);
10739 if (bgp == NULL)
10740 {
10741 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10742 return CMD_WARNING;
10743 }
10744
Michael Lambert95cbbd22010-07-23 14:43:04 -040010745 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10746 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010747 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10748}
10749
10750DEFUN (show_bgp_view_afi_safi_community,
10751 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010752 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010753 SHOW_STR
10754 BGP_STR
10755 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010756 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010757 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010758 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010759 "Address family modifier\n"
10760 "Address family modifier\n"
10761 "Display routes matching the communities\n"
10762 "community number\n"
10763 "Do not send outside local AS (well-known community)\n"
10764 "Do not advertise to any peer (well-known community)\n"
10765 "Do not export to next AS (well-known community)\n")
10766{
10767 int afi;
10768 int safi;
10769
Michael Lambert95cbbd22010-07-23 14:43:04 -040010770 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10771 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10772 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010773}
10774
10775ALIAS (show_bgp_view_afi_safi_community,
10776 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010777 "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 -040010778 SHOW_STR
10779 BGP_STR
10780 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010781 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010782 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010783 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010784 "Address family modifier\n"
10785 "Address family modifier\n"
10786 "Display routes matching the communities\n"
10787 "community number\n"
10788 "Do not send outside local AS (well-known community)\n"
10789 "Do not advertise to any peer (well-known community)\n"
10790 "Do not export to next AS (well-known community)\n"
10791 "community number\n"
10792 "Do not send outside local AS (well-known community)\n"
10793 "Do not advertise to any peer (well-known community)\n"
10794 "Do not export to next AS (well-known community)\n")
10795
10796ALIAS (show_bgp_view_afi_safi_community,
10797 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010798 "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 -040010799 SHOW_STR
10800 BGP_STR
10801 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010802 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010803 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010804 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010805 "Address family modifier\n"
10806 "Address family modifier\n"
10807 "Display routes matching the communities\n"
10808 "community number\n"
10809 "Do not send outside local AS (well-known community)\n"
10810 "Do not advertise to any peer (well-known community)\n"
10811 "Do not export to next AS (well-known community)\n"
10812 "community number\n"
10813 "Do not send outside local AS (well-known community)\n"
10814 "Do not advertise to any peer (well-known community)\n"
10815 "Do not export to next AS (well-known community)\n"
10816 "community number\n"
10817 "Do not send outside local AS (well-known community)\n"
10818 "Do not advertise to any peer (well-known community)\n"
10819 "Do not export to next AS (well-known community)\n")
10820
10821ALIAS (show_bgp_view_afi_safi_community,
10822 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010823 "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 -040010824 SHOW_STR
10825 BGP_STR
10826 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010827 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010828 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010829 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010830 "Address family modifier\n"
10831 "Address family modifier\n"
10832 "Display routes matching the communities\n"
10833 "community number\n"
10834 "Do not send outside local AS (well-known community)\n"
10835 "Do not advertise to any peer (well-known community)\n"
10836 "Do not export to next AS (well-known community)\n"
10837 "community number\n"
10838 "Do not send outside local AS (well-known community)\n"
10839 "Do not advertise to any peer (well-known community)\n"
10840 "Do not export to next AS (well-known community)\n"
10841 "community number\n"
10842 "Do not send outside local AS (well-known community)\n"
10843 "Do not advertise to any peer (well-known community)\n"
10844 "Do not export to next AS (well-known community)\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
Lou Berger651b4022016-01-12 13:42:07 -050010850DEFUN (show_bgp_ipv4_community_exact,
10851 show_bgp_ipv4_community_exact_cmd,
10852 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010853 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010854 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010855 IP_STR
paul718e3742002-12-13 20:15:29 +000010856 "Display routes matching the communities\n"
10857 "community number\n"
10858 "Do not send outside local AS (well-known community)\n"
10859 "Do not advertise to any peer (well-known community)\n"
10860 "Do not export to next AS (well-known community)\n"
10861 "Exact match of the communities")
10862{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010863 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010864}
10865
Lou Berger651b4022016-01-12 13:42:07 -050010866ALIAS (show_bgp_ipv4_community_exact,
10867 show_bgp_ipv4_community2_exact_cmd,
10868 "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 +000010869 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010870 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010871 IP_STR
paul718e3742002-12-13 20:15:29 +000010872 "Display routes matching the communities\n"
10873 "community number\n"
10874 "Do not send outside local AS (well-known community)\n"
10875 "Do not advertise to any peer (well-known community)\n"
10876 "Do not export to next AS (well-known community)\n"
10877 "community number\n"
10878 "Do not send outside local AS (well-known community)\n"
10879 "Do not advertise to any peer (well-known community)\n"
10880 "Do not export to next AS (well-known community)\n"
10881 "Exact match of the communities")
10882
Lou Berger651b4022016-01-12 13:42:07 -050010883ALIAS (show_bgp_ipv4_community_exact,
10884 show_bgp_ipv4_community3_exact_cmd,
10885 "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 +000010886 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010887 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010888 IP_STR
paul718e3742002-12-13 20:15:29 +000010889 "Display routes matching the communities\n"
10890 "community number\n"
10891 "Do not send outside local AS (well-known community)\n"
10892 "Do not advertise to any peer (well-known community)\n"
10893 "Do not export to next AS (well-known community)\n"
10894 "community number\n"
10895 "Do not send outside local AS (well-known community)\n"
10896 "Do not advertise to any peer (well-known community)\n"
10897 "Do not export to next AS (well-known community)\n"
10898 "community number\n"
10899 "Do not send outside local AS (well-known community)\n"
10900 "Do not advertise to any peer (well-known community)\n"
10901 "Do not export to next AS (well-known community)\n"
10902 "Exact match of the communities")
10903
Lou Berger651b4022016-01-12 13:42:07 -050010904ALIAS (show_bgp_ipv4_community_exact,
10905 show_bgp_ipv4_community4_exact_cmd,
10906 "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 +000010907 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010908 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010909 IP_STR
paul718e3742002-12-13 20:15:29 +000010910 "Display routes matching the communities\n"
10911 "community number\n"
10912 "Do not send outside local AS (well-known community)\n"
10913 "Do not advertise to any peer (well-known community)\n"
10914 "Do not export to next AS (well-known community)\n"
10915 "community number\n"
10916 "Do not send outside local AS (well-known community)\n"
10917 "Do not advertise to any peer (well-known community)\n"
10918 "Do not export to next AS (well-known community)\n"
10919 "community number\n"
10920 "Do not send outside local AS (well-known community)\n"
10921 "Do not advertise to any peer (well-known community)\n"
10922 "Do not export to next AS (well-known community)\n"
10923 "community number\n"
10924 "Do not send outside local AS (well-known community)\n"
10925 "Do not advertise to any peer (well-known community)\n"
10926 "Do not export to next AS (well-known community)\n"
10927 "Exact match of the communities")
10928
Lou Berger651b4022016-01-12 13:42:07 -050010929DEFUN (show_bgp_ipv4_safi_community4_exact,
10930 show_bgp_ipv4_safi_community_exact_cmd,
10931 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010932 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010933 BGP_STR
10934 "Address family\n"
10935 "Address Family modifier\n"
10936 "Address Family modifier\n"
10937 "Display routes matching the communities\n"
10938 "community number\n"
10939 "Do not send outside local AS (well-known community)\n"
10940 "Do not advertise to any peer (well-known community)\n"
10941 "Do not export to next AS (well-known community)\n"
10942 "Exact match of the communities")
10943{
10944 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010945 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010946
Michael Lambert95cbbd22010-07-23 14:43:04 -040010947 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010948}
10949
Lou Berger651b4022016-01-12 13:42:07 -050010950ALIAS (show_bgp_ipv4_safi_community4_exact,
10951 show_bgp_ipv4_safi_community2_exact_cmd,
10952 "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 +000010953 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010954 BGP_STR
10955 "Address family\n"
10956 "Address Family modifier\n"
10957 "Address Family modifier\n"
10958 "Display routes matching the communities\n"
10959 "community number\n"
10960 "Do not send outside local AS (well-known community)\n"
10961 "Do not advertise to any peer (well-known community)\n"
10962 "Do not export to next AS (well-known community)\n"
10963 "community number\n"
10964 "Do not send outside local AS (well-known community)\n"
10965 "Do not advertise to any peer (well-known community)\n"
10966 "Do not export to next AS (well-known community)\n"
10967 "Exact match of the communities")
10968
Lou Berger651b4022016-01-12 13:42:07 -050010969ALIAS (show_bgp_ipv4_safi_community4_exact,
10970 show_bgp_ipv4_safi_community3_exact_cmd,
10971 "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 +000010972 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010973 BGP_STR
10974 "Address family\n"
10975 "Address Family modifier\n"
10976 "Address Family modifier\n"
10977 "Display routes matching the communities\n"
10978 "community number\n"
10979 "Do not send outside local AS (well-known community)\n"
10980 "Do not advertise to any peer (well-known community)\n"
10981 "Do not export to next AS (well-known community)\n"
10982 "community number\n"
10983 "Do not send outside local AS (well-known community)\n"
10984 "Do not advertise to any peer (well-known community)\n"
10985 "Do not export to next AS (well-known community)\n"
10986 "community number\n"
10987 "Do not send outside local AS (well-known community)\n"
10988 "Do not advertise to any peer (well-known community)\n"
10989 "Do not export to next AS (well-known community)\n"
10990 "Exact match of the communities")
10991
Lou Berger651b4022016-01-12 13:42:07 -050010992ALIAS (show_bgp_ipv4_safi_community4_exact,
10993 show_bgp_ipv4_safi_community4_exact_cmd,
10994 "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 +000010995 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010996 BGP_STR
10997 "Address family\n"
10998 "Address Family modifier\n"
10999 "Address Family modifier\n"
11000 "Display routes matching the communities\n"
11001 "community number\n"
11002 "Do not send outside local AS (well-known community)\n"
11003 "Do not advertise to any peer (well-known community)\n"
11004 "Do not export to next AS (well-known community)\n"
11005 "community number\n"
11006 "Do not send outside local AS (well-known community)\n"
11007 "Do not advertise to any peer (well-known community)\n"
11008 "Do not export to next AS (well-known community)\n"
11009 "community number\n"
11010 "Do not send outside local AS (well-known community)\n"
11011 "Do not advertise to any peer (well-known community)\n"
11012 "Do not export to next AS (well-known community)\n"
11013 "community number\n"
11014 "Do not send outside local AS (well-known community)\n"
11015 "Do not advertise to any peer (well-known community)\n"
11016 "Do not export to next AS (well-known community)\n"
11017 "Exact match of the communities")
11018
Lou Bergerf9b6c392016-01-12 13:42:09 -050011019DEFUN (show_bgp_ipv6_safi_community,
11020 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011021 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000011022 SHOW_STR
11023 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011024 "Address family\n"
11025 "Address family modifier\n"
11026 "Address family modifier\n"
11027 "Address family modifier\n"
11028 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011029 "Display routes matching the communities\n"
11030 "community number\n"
11031 "Do not send outside local AS (well-known community)\n"
11032 "Do not advertise to any peer (well-known community)\n"
11033 "Do not export to next AS (well-known community)\n")
11034{
Lou Berger651b4022016-01-12 13:42:07 -050011035 safi_t safi;
11036
11037 if (bgp_parse_safi(argv[0], &safi)) {
11038 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11039 return CMD_WARNING;
11040 }
11041 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011042}
11043
Lou Bergerf9b6c392016-01-12 13:42:09 -050011044ALIAS (show_bgp_ipv6_safi_community,
11045 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011046 "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 +000011047 SHOW_STR
11048 BGP_STR
11049 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011050 "Address family modifier\n"
11051 "Address family modifier\n"
11052 "Address family modifier\n"
11053 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011054 "Display routes matching the communities\n"
11055 "community number\n"
11056 "Do not send outside local AS (well-known community)\n"
11057 "Do not advertise to any peer (well-known community)\n"
11058 "Do not export to next AS (well-known community)\n"
11059 "community number\n"
11060 "Do not send outside local AS (well-known community)\n"
11061 "Do not advertise to any peer (well-known community)\n"
11062 "Do not export to next AS (well-known community)\n")
11063
Lou Bergerf9b6c392016-01-12 13:42:09 -050011064ALIAS (show_bgp_ipv6_safi_community,
11065 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011066 "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 +000011067 SHOW_STR
11068 BGP_STR
11069 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011070 "Address family modifier\n"
11071 "Address family modifier\n"
11072 "Address family modifier\n"
11073 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011074 "Display routes matching the communities\n"
11075 "community number\n"
11076 "Do not send outside local AS (well-known community)\n"
11077 "Do not advertise to any peer (well-known community)\n"
11078 "Do not export to next AS (well-known community)\n"
11079 "community number\n"
11080 "Do not send outside local AS (well-known community)\n"
11081 "Do not advertise to any peer (well-known community)\n"
11082 "Do not export to next AS (well-known community)\n"
11083 "community number\n"
11084 "Do not send outside local AS (well-known community)\n"
11085 "Do not advertise to any peer (well-known community)\n"
11086 "Do not export to next AS (well-known community)\n")
11087
Lou Bergerf9b6c392016-01-12 13:42:09 -050011088ALIAS (show_bgp_ipv6_safi_community,
11089 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011090 "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 +000011091 SHOW_STR
11092 BGP_STR
11093 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011094 "Address family modifier\n"
11095 "Address family modifier\n"
11096 "Address family modifier\n"
11097 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011098 "Display routes matching the communities\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 "community number\n"
11104 "Do not send outside local AS (well-known community)\n"
11105 "Do not advertise to any peer (well-known community)\n"
11106 "Do not export to next AS (well-known community)\n"
11107 "community number\n"
11108 "Do not send outside local AS (well-known community)\n"
11109 "Do not advertise to any peer (well-known community)\n"
11110 "Do not export to next AS (well-known community)\n"
11111 "community number\n"
11112 "Do not send outside local AS (well-known community)\n"
11113 "Do not advertise to any peer (well-known community)\n"
11114 "Do not export to next AS (well-known community)\n")
11115
paul718e3742002-12-13 20:15:29 +000011116
Lou Bergerf9b6c392016-01-12 13:42:09 -050011117DEFUN (show_bgp_ipv6_safi_community_exact,
11118 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011119 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000011120 SHOW_STR
11121 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011122 "Address family\n"
11123 "Address family modifier\n"
11124 "Address family modifier\n"
11125 "Address family modifier\n"
11126 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011127 "Display routes matching the communities\n"
11128 "community number\n"
11129 "Do not send outside local AS (well-known community)\n"
11130 "Do not advertise to any peer (well-known community)\n"
11131 "Do not export to next AS (well-known community)\n"
11132 "Exact match of the communities")
11133{
Lou Berger651b4022016-01-12 13:42:07 -050011134 safi_t safi;
11135
11136 if (bgp_parse_safi(argv[0], &safi)) {
11137 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11138 return CMD_WARNING;
11139 }
11140 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011141}
11142
paul718e3742002-12-13 20:15:29 +000011143
11144ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011145 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011146 "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 +000011147 SHOW_STR
11148 BGP_STR
11149 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011150 "Address family modifier\n"
11151 "Address family modifier\n"
11152 "Address family modifier\n"
11153 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011154 "Display routes matching the communities\n"
11155 "community number\n"
11156 "Do not send outside local AS (well-known community)\n"
11157 "Do not advertise to any peer (well-known community)\n"
11158 "Do not export to next AS (well-known community)\n"
11159 "community number\n"
11160 "Do not send outside local AS (well-known community)\n"
11161 "Do not advertise to any peer (well-known community)\n"
11162 "Do not export to next AS (well-known community)\n"
11163 "Exact match of the communities")
11164
11165ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011166 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011167 "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 +000011168 SHOW_STR
11169 BGP_STR
11170 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011171 "Address family modifier\n"
11172 "Address family modifier\n"
11173 "Address family modifier\n"
11174 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011175 "Display routes matching the communities\n"
11176 "community number\n"
11177 "Do not send outside local AS (well-known community)\n"
11178 "Do not advertise to any peer (well-known community)\n"
11179 "Do not export to next AS (well-known community)\n"
11180 "community number\n"
11181 "Do not send outside local AS (well-known community)\n"
11182 "Do not advertise to any peer (well-known community)\n"
11183 "Do not export to next AS (well-known community)\n"
11184 "community number\n"
11185 "Do not send outside local AS (well-known community)\n"
11186 "Do not advertise to any peer (well-known community)\n"
11187 "Do not export to next AS (well-known community)\n"
11188 "Exact match of the communities")
11189
11190ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011191 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011192 "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 +000011193 SHOW_STR
11194 BGP_STR
11195 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011196 "Address family modifier\n"
11197 "Address family modifier\n"
11198 "Address family modifier\n"
11199 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011200 "Display routes matching the communities\n"
11201 "community number\n"
11202 "Do not send outside local AS (well-known community)\n"
11203 "Do not advertise to any peer (well-known community)\n"
11204 "Do not export to next AS (well-known community)\n"
11205 "community number\n"
11206 "Do not send outside local AS (well-known community)\n"
11207 "Do not advertise to any peer (well-known community)\n"
11208 "Do not export to next AS (well-known community)\n"
11209 "community number\n"
11210 "Do not send outside local AS (well-known community)\n"
11211 "Do not advertise to any peer (well-known community)\n"
11212 "Do not export to next AS (well-known community)\n"
11213 "community number\n"
11214 "Do not send outside local AS (well-known community)\n"
11215 "Do not advertise to any peer (well-known community)\n"
11216 "Do not export to next AS (well-known community)\n"
11217 "Exact match of the communities")
11218
paul94f2b392005-06-28 12:44:16 +000011219static int
paulfd79ac92004-10-13 05:06:08 +000011220bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040011221 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000011222{
11223 struct community_list *list;
11224
hassofee6e4e2005-02-02 16:29:31 +000011225 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000011226 if (list == NULL)
11227 {
11228 vty_out (vty, "%% %s is not a valid community-list name%s", com,
11229 VTY_NEWLINE);
11230 return CMD_WARNING;
11231 }
11232
ajs5a646652004-11-05 01:25:55 +000011233 return bgp_show (vty, NULL, afi, safi,
11234 (exact ? bgp_show_type_community_list_exact :
11235 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000011236}
11237
Lou Bergerf9b6c392016-01-12 13:42:09 -050011238DEFUN (show_ip_bgp_community_list,
11239 show_ip_bgp_community_list_cmd,
11240 "show ip bgp community-list (<1-500>|WORD)",
11241 SHOW_STR
11242 IP_STR
11243 BGP_STR
11244 "Display routes matching the community-list\n"
11245 "community-list number\n"
11246 "community-list name\n")
11247{
11248 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11249}
11250
11251DEFUN (show_ip_bgp_ipv4_community_list,
11252 show_ip_bgp_ipv4_community_list_cmd,
11253 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11254 SHOW_STR
11255 IP_STR
11256 BGP_STR
11257 "Address family\n"
11258 "Address Family modifier\n"
11259 "Address Family modifier\n"
11260 "Display routes matching the community-list\n"
11261 "community-list number\n"
11262 "community-list name\n")
11263{
11264 if (strncmp (argv[0], "m", 1) == 0)
11265 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11266
11267 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11268}
11269
11270DEFUN (show_ip_bgp_community_list_exact,
11271 show_ip_bgp_community_list_exact_cmd,
11272 "show ip bgp community-list (<1-500>|WORD) exact-match",
11273 SHOW_STR
11274 IP_STR
11275 BGP_STR
11276 "Display routes matching the community-list\n"
11277 "community-list number\n"
11278 "community-list name\n"
11279 "Exact match of the communities\n")
11280{
11281 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11282}
11283
11284DEFUN (show_ip_bgp_ipv4_community_list_exact,
11285 show_ip_bgp_ipv4_community_list_exact_cmd,
11286 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11287 SHOW_STR
11288 IP_STR
11289 BGP_STR
11290 "Address family\n"
11291 "Address Family modifier\n"
11292 "Address Family modifier\n"
11293 "Display routes matching the community-list\n"
11294 "community-list number\n"
11295 "community-list name\n"
11296 "Exact match of the communities\n")
11297{
11298 if (strncmp (argv[0], "m", 1) == 0)
11299 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11300
11301 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11302}
11303
Lou Bergerf9b6c392016-01-12 13:42:09 -050011304DEFUN (show_bgp_community_list,
11305 show_bgp_community_list_cmd,
11306 "show bgp community-list (<1-500>|WORD)",
11307 SHOW_STR
11308 BGP_STR
11309 "Display routes matching the community-list\n"
11310 "community-list number\n"
11311 "community-list name\n")
11312{
11313 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11314}
11315
11316ALIAS (show_bgp_community_list,
11317 show_bgp_ipv6_community_list_cmd,
11318 "show bgp ipv6 community-list (<1-500>|WORD)",
11319 SHOW_STR
11320 BGP_STR
11321 "Address family\n"
11322 "Display routes matching the community-list\n"
11323 "community-list number\n"
11324 "community-list name\n")
11325
11326/* old command */
11327DEFUN (show_ipv6_bgp_community_list,
11328 show_ipv6_bgp_community_list_cmd,
11329 "show ipv6 bgp community-list WORD",
11330 SHOW_STR
11331 IPV6_STR
11332 BGP_STR
11333 "Display routes matching the community-list\n"
11334 "community-list name\n")
11335{
11336 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11337}
11338
11339/* old command */
11340DEFUN (show_ipv6_mbgp_community_list,
11341 show_ipv6_mbgp_community_list_cmd,
11342 "show ipv6 mbgp community-list WORD",
11343 SHOW_STR
11344 IPV6_STR
11345 MBGP_STR
11346 "Display routes matching the community-list\n"
11347 "community-list name\n")
11348{
11349 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
11350}
11351
11352DEFUN (show_bgp_community_list_exact,
11353 show_bgp_community_list_exact_cmd,
11354 "show bgp community-list (<1-500>|WORD) exact-match",
11355 SHOW_STR
11356 BGP_STR
11357 "Display routes matching the community-list\n"
11358 "community-list number\n"
11359 "community-list name\n"
11360 "Exact match of the communities\n")
11361{
11362 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11363}
11364
11365ALIAS (show_bgp_community_list_exact,
11366 show_bgp_ipv6_community_list_exact_cmd,
11367 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11368 SHOW_STR
11369 BGP_STR
11370 "Address family\n"
11371 "Display routes matching the community-list\n"
11372 "community-list number\n"
11373 "community-list name\n"
11374 "Exact match of the communities\n")
11375
11376/* old command */
11377DEFUN (show_ipv6_bgp_community_list_exact,
11378 show_ipv6_bgp_community_list_exact_cmd,
11379 "show ipv6 bgp community-list WORD exact-match",
11380 SHOW_STR
11381 IPV6_STR
11382 BGP_STR
11383 "Display routes matching the community-list\n"
11384 "community-list name\n"
11385 "Exact match of the communities\n")
11386{
11387 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11388}
11389
11390/* old command */
11391DEFUN (show_ipv6_mbgp_community_list_exact,
11392 show_ipv6_mbgp_community_list_exact_cmd,
11393 "show ipv6 mbgp community-list WORD exact-match",
11394 SHOW_STR
11395 IPV6_STR
11396 MBGP_STR
11397 "Display routes matching the community-list\n"
11398 "community-list name\n"
11399 "Exact match of the communities\n")
11400{
11401 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
11402}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011403
Lou Berger651b4022016-01-12 13:42:07 -050011404DEFUN (show_bgp_ipv4_community_list,
11405 show_bgp_ipv4_community_list_cmd,
11406 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011407 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011408 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011409 IP_STR
paul718e3742002-12-13 20:15:29 +000011410 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011411 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011412 "community-list name\n")
11413{
11414 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11415}
11416
Lou Berger651b4022016-01-12 13:42:07 -050011417DEFUN (show_bgp_ipv4_safi_community_list,
11418 show_bgp_ipv4_safi_community_list_cmd,
11419 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011420 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011421 BGP_STR
11422 "Address family\n"
11423 "Address Family modifier\n"
11424 "Address Family modifier\n"
11425 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011426 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011427 "community-list name\n")
11428{
11429 if (strncmp (argv[0], "m", 1) == 0)
11430 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11431
11432 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11433}
11434
Lou Berger651b4022016-01-12 13:42:07 -050011435DEFUN (show_bgp_ipv4_community_list_exact,
11436 show_bgp_ipv4_community_list_exact_cmd,
11437 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011438 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011439 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011440 IP_STR
paul718e3742002-12-13 20:15:29 +000011441 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011442 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011443 "community-list name\n"
11444 "Exact match of the communities\n")
11445{
11446 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11447}
11448
Lou Berger651b4022016-01-12 13:42:07 -050011449DEFUN (show_bgp_ipv4_safi_community_list_exact,
11450 show_bgp_ipv4_safi_community_list_exact_cmd,
11451 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011452 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011453 BGP_STR
11454 "Address family\n"
11455 "Address Family modifier\n"
11456 "Address Family modifier\n"
11457 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011458 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011459 "community-list name\n"
11460 "Exact match of the communities\n")
11461{
11462 if (strncmp (argv[0], "m", 1) == 0)
11463 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11464
11465 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11466}
11467
Lou Bergerf9b6c392016-01-12 13:42:09 -050011468DEFUN (show_bgp_ipv6_safi_community_list,
11469 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011470 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011471 SHOW_STR
11472 BGP_STR
11473 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011474 "Address family modifier\n"
11475 "Address family modifier\n"
11476 "Address family modifier\n"
11477 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011478 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011479 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011480 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011481{
Lou Berger651b4022016-01-12 13:42:07 -050011482 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011483
Lou Berger651b4022016-01-12 13:42:07 -050011484 if (bgp_parse_safi(argv[0], &safi)) {
11485 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11486 return CMD_WARNING;
11487 }
11488 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011489}
11490
Lou Bergerf9b6c392016-01-12 13:42:09 -050011491DEFUN (show_bgp_ipv6_safi_community_list_exact,
11492 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011493 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011494 SHOW_STR
11495 BGP_STR
11496 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011497 "Address family modifier\n"
11498 "Address family modifier\n"
11499 "Address family modifier\n"
11500 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011501 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011502 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011503 "community-list name\n"
11504 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011505{
Lou Berger651b4022016-01-12 13:42:07 -050011506 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011507
Lou Berger651b4022016-01-12 13:42:07 -050011508 if (bgp_parse_safi(argv[0], &safi)) {
11509 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11510 return CMD_WARNING;
11511 }
11512 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011513}
David Lamparter6b0655a2014-06-04 06:53:35 +020011514
Job Snijders3334bab2017-01-20 14:47:12 +000011515/*
11516 * Large Community show commands.
11517 */
11518
11519DEFUN (show_bgp_afi_lcommunity_all,
11520 show_bgp_afi_lcommunity_all_cmd,
11521 "show bgp (ipv4|ipv6) large-community",
11522 SHOW_STR
11523 BGP_STR
11524 "Address family\n"
11525 "Address family\n"
11526 "Display routes matching the large-communities\n")
11527{
11528 afi_t afi;
11529 safi_t safi = SAFI_UNICAST;
11530
11531 if (bgp_parse_afi(argv[0], &afi)) {
11532 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
11533 return CMD_WARNING;
11534 }
11535 return bgp_show (vty, NULL, afi, safi, bgp_show_type_lcommunity_all, NULL);
11536}
11537
11538static int
11539bgp_show_lcommunity (struct vty *vty, const char *view_name, int argc,
11540 const char **argv, afi_t afi, safi_t safi)
11541{
11542 struct lcommunity *lcom;
11543 struct buffer *b;
11544 struct bgp *bgp;
11545 int i;
11546 char *str;
11547 int first = 0;
11548
11549 /* BGP structure lookup */
11550 if (view_name)
11551 {
11552 bgp = bgp_lookup_by_name (view_name);
11553 if (bgp == NULL)
11554 {
11555 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11556 return CMD_WARNING;
11557 }
11558 }
11559 else
11560 {
11561 bgp = bgp_get_default ();
11562 if (bgp == NULL)
11563 {
11564 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11565 return CMD_WARNING;
11566 }
11567 }
11568
11569 b = buffer_new (1024);
11570 for (i = 0; i < argc; i++)
11571 {
11572 if (first)
11573 buffer_putc (b, ' ');
11574 else
11575 {
11576 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
11577 continue;
11578 first = 1;
11579 }
11580
11581 buffer_putstr (b, argv[i]);
11582 }
11583 buffer_putc (b, '\0');
11584
11585 str = buffer_getstr (b);
11586 buffer_free (b);
11587
11588 lcom = lcommunity_str2com (str);
11589 XFREE (MTYPE_TMP, str);
11590 if (! lcom)
11591 {
11592 vty_out (vty, "%% Large-community malformed: %s", VTY_NEWLINE);
11593 return CMD_WARNING;
11594 }
11595
11596 return bgp_show (vty, bgp, afi, safi, bgp_show_type_lcommunity, lcom);
11597}
11598
11599DEFUN (show_ip_bgp_lcommunity,
11600 show_ip_bgp_lcommunity_cmd,
11601 "show ip bgp large-community (AA:BB:CC)",
11602 SHOW_STR
11603 IP_STR
11604 BGP_STR
11605 "Display routes matching the large-communities\n"
11606 "large-community number\n")
11607{
11608 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_UNICAST);
11609}
11610
11611ALIAS (show_ip_bgp_lcommunity,
11612 show_ip_bgp_lcommunity2_cmd,
11613 "show ip bgp large-community (AA:BB:CC) (AA:BB:CC)",
11614 SHOW_STR
11615 IP_STR
11616 BGP_STR
11617 "Display routes matching the large-communities\n"
11618 "large-community number\n"
11619 "large-community number\n")
11620
11621ALIAS (show_ip_bgp_lcommunity,
11622 show_ip_bgp_lcommunity3_cmd,
11623 "show ip bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11624 SHOW_STR
11625 IP_STR
11626 BGP_STR
11627 "Display routes matching the large-communities\n"
11628 "largecommunity number\n"
11629 "largecommunity number\n"
11630 "largecommunity number\n")
11631
11632ALIAS (show_ip_bgp_lcommunity,
11633 show_ip_bgp_lcommunity4_cmd,
11634 "show ip bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11635 SHOW_STR
11636 IP_STR
11637 BGP_STR
11638 "Display routes matching the large-communities\n"
11639 "large-community number\n"
11640 "large-community number\n"
11641 "large-community number\n"
11642 "large-community number\n")
11643
11644DEFUN (show_ip_bgp_ipv4_lcommunity,
11645 show_ip_bgp_ipv4_lcommunity_cmd,
11646 "show ip bgp ipv4 (unicast|multicast) large-community (AA:BB:CC)",
11647 SHOW_STR
11648 IP_STR
11649 BGP_STR
11650 "Address family\n"
11651 "Address Family modifier\n"
11652 "Address Family modifier\n"
11653 "Display routes matching the large-communities\n"
11654 "large-community number\n")
11655{
11656 if (strncmp (argv[0], "m", 1) == 0)
11657 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_MULTICAST);
11658
11659 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_UNICAST);
11660}
11661
11662ALIAS (show_ip_bgp_ipv4_lcommunity,
11663 show_ip_bgp_ipv4_lcommunity2_cmd,
11664 "show ip bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC)",
11665 SHOW_STR
11666 IP_STR
11667 BGP_STR
11668 "Address family\n"
11669 "Address Family modifier\n"
11670 "Address Family modifier\n"
11671 "Display routes matching the large-communities\n"
11672 "large-community number\n"
11673 "large-community number\n")
11674
11675ALIAS (show_ip_bgp_ipv4_lcommunity,
11676 show_ip_bgp_ipv4_lcommunity3_cmd,
11677 "show ip bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11678 SHOW_STR
11679 IP_STR
11680 BGP_STR
11681 "Address family\n"
11682 "Address Family modifier\n"
11683 "Address Family modifier\n"
11684 "Display routes matching the large-communities\n"
11685 "large-community number\n"
11686 "large-community number\n"
11687 "large-community number\n")
11688
11689ALIAS (show_ip_bgp_ipv4_lcommunity,
11690 show_ip_bgp_ipv4_lcommunity4_cmd,
11691 "show ip bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11692 SHOW_STR
11693 IP_STR
11694 BGP_STR
11695 "Address family\n"
11696 "Address Family modifier\n"
11697 "Address Family modifier\n"
11698 "Display routes matching the large-communities\n"
11699 "large-community number\n"
11700 "large-community number\n"
11701 "large-community number\n"
11702 "large-community number\n")
11703
11704DEFUN (show_bgp_lcommunity,
11705 show_bgp_lcommunity_cmd,
11706 "show bgp large-community (AA:BB:CC)",
11707 SHOW_STR
11708 BGP_STR
11709 "Display routes matching the large-communities\n"
11710 "large-community number\n")
11711{
11712 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP6, SAFI_UNICAST);
11713}
11714
11715ALIAS (show_bgp_lcommunity,
11716 show_bgp_ipv6_lcommunity_cmd,
11717 "show bgp ipv6 large-community (AA:BB:CC)",
11718 SHOW_STR
11719 BGP_STR
11720 "Address family\n"
11721 "Display routes matching the large-communities\n"
11722 "large-community number\n")
11723
11724ALIAS (show_bgp_lcommunity,
11725 show_bgp_lcommunity2_cmd,
11726 "show bgp large-community (AA:BB:CC) (AA:BB:CC)",
11727 SHOW_STR
11728 BGP_STR
11729 "Display routes matching the large-communities\n"
11730 "large-community number\n"
11731 "large-community number\n")
11732
11733ALIAS (show_bgp_lcommunity,
11734 show_bgp_ipv6_lcommunity2_cmd,
11735 "show bgp ipv6 large-community (AA:BB:CC) (AA:BB:CC)",
11736 SHOW_STR
11737 BGP_STR
11738 "Address family\n"
11739 "Display routes matching the large-communities\n"
11740 "large-community number\n"
11741 "large-community number\n")
11742
11743ALIAS (show_bgp_lcommunity,
11744 show_bgp_lcommunity3_cmd,
11745 "show bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11746 SHOW_STR
11747 BGP_STR
11748 "Display routes matching the large-communities\n"
11749 "large-community number\n"
11750 "large-community number\n"
11751 "large-community number\n")
11752
11753ALIAS (show_bgp_lcommunity,
11754 show_bgp_ipv6_lcommunity3_cmd,
11755 "show bgp ipv6 large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11756 SHOW_STR
11757 BGP_STR
11758 "Address family\n"
11759 "Display routes matching the large-communities\n"
11760 "large-community number\n"
11761 "large-community number\n"
11762 "large-community number\n")
11763
11764ALIAS (show_bgp_lcommunity,
11765 show_bgp_lcommunity4_cmd,
11766 "show bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11767 SHOW_STR
11768 BGP_STR
11769 "Display routes matching the large-communities\n"
11770 "large-community number\n"
11771 "large-community number\n"
11772 "large-community number\n"
11773 "large-community number\n")
11774
11775ALIAS (show_bgp_lcommunity,
11776 show_bgp_ipv6_lcommunity4_cmd,
11777 "show bgp ipv6 large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11778 SHOW_STR
11779 BGP_STR
11780 "Address family\n"
11781 "Display routes matching the large-communities\n"
11782 "large-community number\n"
11783 "large-community number\n"
11784 "large-community number\n"
11785 "large-community number\n")
11786
11787/* old command */
11788DEFUN (show_ipv6_bgp_lcommunity,
11789 show_ipv6_bgp_lcommunity_cmd,
11790 "show ipv6 bgp large-community (AA:BB:CC)",
11791 SHOW_STR
11792 IPV6_STR
11793 BGP_STR
11794 "Display routes matching the large-communities\n"
11795 "large-community number\n")
11796{
11797 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP6, SAFI_UNICAST);
11798}
11799
11800/* old command */
11801ALIAS (show_ipv6_bgp_lcommunity,
11802 show_ipv6_bgp_lcommunity2_cmd,
11803 "show ipv6 bgp large-community (AA:BB:CC) (AA:BB:CC)",
11804 SHOW_STR
11805 IPV6_STR
11806 BGP_STR
11807 "Display routes matching the large-communities\n"
11808 "large-community number\n"
11809 "large-community number\n")
11810
11811/* old command */
11812ALIAS (show_ipv6_bgp_lcommunity,
11813 show_ipv6_bgp_lcommunity3_cmd,
11814 "show ipv6 bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11815 SHOW_STR
11816 IPV6_STR
11817 BGP_STR
11818 "Display routes matching the large-communities\n"
11819 "large-community number\n"
11820 "large-community number\n"
11821 "large-community number\n")
11822
11823/* old command */
11824ALIAS (show_ipv6_bgp_lcommunity,
11825 show_ipv6_bgp_lcommunity4_cmd,
11826 "show ipv6 bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11827 SHOW_STR
11828 IPV6_STR
11829 BGP_STR
11830 "Display routes matching the large-communities\n"
11831 "large-community number\n"
11832 "large-community number\n"
11833 "large-community number\n"
11834 "large-community number\n")
11835
11836/* old command */
11837DEFUN (show_ipv6_mbgp_lcommunity,
11838 show_ipv6_mbgp_lcommunity_cmd,
11839 "show ipv6 mbgp large-community (AA:BB:CC)",
11840 SHOW_STR
11841 IPV6_STR
11842 MBGP_STR
11843 "Display routes matching the large-communities\n"
11844 "large-community number\n")
11845{
11846 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP6, SAFI_MULTICAST);
11847}
11848
11849/* old command */
11850ALIAS (show_ipv6_mbgp_lcommunity,
11851 show_ipv6_mbgp_lcommunity2_cmd,
11852 "show ipv6 mbgp large-community (AA:BB:CC) (AA:BB:CC)",
11853 SHOW_STR
11854 IPV6_STR
11855 MBGP_STR
11856 "Display routes matching the large-communities\n"
11857 "large-community number\n"
11858 "large-community number\n")
11859
11860/* old command */
11861ALIAS (show_ipv6_mbgp_lcommunity,
11862 show_ipv6_mbgp_lcommunity3_cmd,
11863 "show ipv6 mbgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11864 SHOW_STR
11865 IPV6_STR
11866 MBGP_STR
11867 "Display routes matching the large-communities\n"
11868 "large-community number\n"
11869 "large-community number\n"
11870 "large-community number\n")
11871
11872/* old command */
11873ALIAS (show_ipv6_mbgp_lcommunity,
11874 show_ipv6_mbgp_lcommunity4_cmd,
11875 "show ipv6 mbgp laarge-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11876 SHOW_STR
11877 IPV6_STR
11878 MBGP_STR
11879 "Display routes matching the large-communities\n"
11880 "large-community number\n"
11881 "large-community number\n"
11882 "large-community number\n"
11883 "large-community number\n")
11884
11885DEFUN (show_bgp_ipv4_lcommunity,
11886 show_bgp_ipv4_lcommunity_cmd,
11887 "show bgp ipv4 large-community (AA:BB:CC)",
11888 SHOW_STR
11889 BGP_STR
11890 IP_STR
11891 "Display routes matching the large-communities\n"
11892 "large-community number\n")
11893{
11894 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_UNICAST);
11895}
11896
11897ALIAS (show_bgp_ipv4_lcommunity,
11898 show_bgp_ipv4_lcommunity2_cmd,
11899 "show bgp ipv4 large-community (AA:BB:CC) (AA:BB:CC)",
11900 SHOW_STR
11901 BGP_STR
11902 IP_STR
11903 "Display routes matching the large-communities\n"
11904 "large-community number\n"
11905 "large-community number\n")
11906
11907ALIAS (show_bgp_ipv4_lcommunity,
11908 show_bgp_ipv4_lcommunity3_cmd,
11909 "show bgp ipv4 large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11910 SHOW_STR
11911 BGP_STR
11912 IP_STR
11913 "Display routes matching the large-communities\n"
11914 "large-community number\n"
11915 "large-community number\n"
11916 "large-community number\n")
11917
11918ALIAS (show_bgp_ipv4_lcommunity,
11919 show_bgp_ipv4_lcommunity4_cmd,
11920 "show bgp ipv4 large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11921 SHOW_STR
11922 BGP_STR
11923 IP_STR
11924 "Display routes matching the large-communities\n"
11925 "large-community number\n"
11926 "large-community number\n"
11927 "large-community number\n"
11928 "large-community number\n")
11929
11930DEFUN (show_bgp_ipv4_safi_lcommunity,
11931 show_bgp_ipv4_safi_lcommunity_cmd,
11932 "show bgp ipv4 (unicast|multicast) large-community (AA:BB:CC)",
11933 SHOW_STR
11934 BGP_STR
11935 "Address family\n"
11936 "Address Family modifier\n"
11937 "Address Family modifier\n"
11938 "Display routes matching the large-communities\n"
11939 "large-community number\n")
11940{
11941 if (strncmp (argv[0], "m", 1) == 0)
11942 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_MULTICAST);
11943
11944 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_UNICAST);
11945}
11946
11947ALIAS (show_bgp_ipv4_safi_lcommunity,
11948 show_bgp_ipv4_safi_lcommunity2_cmd,
11949 "show bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC)",
11950 SHOW_STR
11951 BGP_STR
11952 "Address family\n"
11953 "Address Family modifier\n"
11954 "Address Family modifier\n"
11955 "Display routes matching the large-communities\n"
11956 "large-community number\n"
11957 "large-community number\n")
11958
11959ALIAS (show_bgp_ipv4_safi_lcommunity,
11960 show_bgp_ipv4_safi_lcommunity3_cmd,
11961 "show bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11962 SHOW_STR
11963 BGP_STR
11964 "Address family\n"
11965 "Address Family modifier\n"
11966 "Address Family modifier\n"
11967 "Display routes matching the large-communities\n"
11968 "large-community number\n"
11969 "large-community number\n"
11970 "large-community number\n")
11971
11972ALIAS (show_bgp_ipv4_safi_lcommunity,
11973 show_bgp_ipv4_safi_lcommunity4_cmd,
11974 "show bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11975 SHOW_STR
11976 BGP_STR
11977 "Address family\n"
11978 "Address Family modifier\n"
11979 "Address Family modifier\n"
11980 "Display routes matching the large-communities\n"
11981 "large-community number\n"
11982 "large-community number\n"
11983 "large-community number\n"
11984 "large-community number\n")
11985
11986DEFUN (show_bgp_view_afi_safi_lcommunity_all,
11987 show_bgp_view_afi_safi_lcommunity_all_cmd,
11988 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community",
11989 SHOW_STR
11990 BGP_STR
11991 "BGP view\n"
11992 "View name\n"
11993 "Address family\n"
11994 "Address family\n"
11995 "Address Family modifier\n"
11996 "Address Family modifier\n"
11997 "Display routes matching the large-communities\n")
11998{
11999 int afi;
12000 int safi;
12001 struct bgp *bgp;
12002
12003 /* BGP structure lookup. */
12004 bgp = bgp_lookup_by_name (argv[0]);
12005 if (bgp == NULL)
12006 {
12007 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
12008 return CMD_WARNING;
12009 }
12010
12011 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12012 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12013 return bgp_show (vty, bgp, afi, safi, bgp_show_type_lcommunity_all, NULL);
12014}
12015
12016DEFUN (show_bgp_view_afi_safi_lcommunity,
12017 show_bgp_view_afi_safi_lcommunity_cmd,
12018 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community (AA:BB:CC)",
12019 SHOW_STR
12020 BGP_STR
12021 "BGP view\n"
12022 "View name\n"
12023 "Address family\n"
12024 "Address family\n"
12025 "Address family modifier\n"
12026 "Address family modifier\n"
12027 "Display routes matching the large-communities\n"
12028 "large-community number\n")
12029{
12030 int afi;
12031 int safi;
12032
12033 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12034 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12035 return bgp_show_lcommunity (vty, argv[0], argc-3, &argv[3], afi, safi);
12036}
12037
12038ALIAS (show_bgp_view_afi_safi_lcommunity,
12039 show_bgp_view_afi_safi_lcommunity2_cmd,
12040 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC)",
12041 SHOW_STR
12042 BGP_STR
12043 "BGP view\n"
12044 "View name\n"
12045 "Address family\n"
12046 "Address family\n"
12047 "Address family modifier\n"
12048 "Address family modifier\n"
12049 "Display routes matching the large-communities\n"
12050 "large-community number\n"
12051 "large-community number\n")
12052
12053ALIAS (show_bgp_view_afi_safi_lcommunity,
12054 show_bgp_view_afi_safi_lcommunity3_cmd,
12055 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
12056 SHOW_STR
12057 BGP_STR
12058 "BGP view\n"
12059 "View name\n"
12060 "Address family\n"
12061 "Address family\n"
12062 "Address family modifier\n"
12063 "Address family modifier\n"
12064 "Display routes matching the large-communities\n"
12065 "large-community number\n"
12066 "large-community number\n"
12067 "large-community number\n")
12068
12069ALIAS (show_bgp_view_afi_safi_lcommunity,
12070 show_bgp_view_afi_safi_lcommunity4_cmd,
12071 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
12072 SHOW_STR
12073 BGP_STR
12074 "BGP view\n"
12075 "View name\n"
12076 "Address family\n"
12077 "Address family\n"
12078 "Address family modifier\n"
12079 "Address family modifier\n"
12080 "Display routes matching the large-communities\n"
12081 "large-community number\n"
12082 "large-community number\n"
12083 "large-community number\n"
12084 "large-community number\n")
12085
12086DEFUN (show_bgp_ipv6_safi_lcommunity,
12087 show_bgp_ipv6_safi_lcommunity_cmd,
12088 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community AA:BB:CC",
12089 SHOW_STR
12090 BGP_STR
12091 "Address family\n"
12092 "Address family modifier\n"
12093 "Address family modifier\n"
12094 "Address family modifier\n"
12095 "Address family modifier\n"
12096 "Display routes matching the large-communities\n"
12097 "large-community number\n")
12098{
12099 safi_t safi;
12100
12101 if (bgp_parse_safi(argv[0], &safi)) {
12102 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12103 return CMD_WARNING;
12104 }
12105 return bgp_show_lcommunity (vty, NULL, argc-1, argv+1, AFI_IP6, safi);
12106}
12107
12108ALIAS (show_bgp_ipv6_safi_lcommunity,
12109 show_bgp_ipv6_safi_lcommunity2_cmd,
12110 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community (AA:BB:CC) (AA:BB:CC)",
12111 SHOW_STR
12112 BGP_STR
12113 "Address family\n"
12114 "Address family modifier\n"
12115 "Address family modifier\n"
12116 "Address family modifier\n"
12117 "Address family modifier\n"
12118 "Display routes matching the large-communities\n"
12119 "large-community number\n"
12120 "large-community number\n")
12121
12122ALIAS (show_bgp_ipv6_safi_lcommunity,
12123 show_bgp_ipv6_safi_lcommunity3_cmd,
12124 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
12125 SHOW_STR
12126 BGP_STR
12127 "Address family\n"
12128 "Address family modifier\n"
12129 "Address family modifier\n"
12130 "Address family modifier\n"
12131 "Address family modifier\n"
12132 "Display routes matching the large-communities\n"
12133 "large-community number\n"
12134 "large-community number\n"
12135 "large-community number\n")
12136
12137ALIAS (show_bgp_ipv6_safi_lcommunity,
12138 show_bgp_ipv6_safi_lcommunity4_cmd,
12139 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
12140 SHOW_STR
12141 BGP_STR
12142 "Address family\n"
12143 "Address family modifier\n"
12144 "Address family modifier\n"
12145 "Address family modifier\n"
12146 "Address family modifier\n"
12147 "Display routes matching the large-communities\n"
12148 "large-community number\n"
12149 "large-community number\n"
12150 "large-community number\n"
12151 "large-community number\n")
12152
12153static int
12154bgp_show_lcommunity_list (struct vty *vty, const char *lcom,
12155 afi_t afi, safi_t safi)
12156{
12157 struct community_list *list;
12158
12159 list = community_list_lookup (bgp_clist, lcom, LARGE_COMMUNITY_LIST_MASTER);
12160 if (list == NULL)
12161 {
12162 vty_out (vty, "%% %s is not a valid large-community-list name%s", lcom,
12163 VTY_NEWLINE);
12164 return CMD_WARNING;
12165 }
12166
12167 return bgp_show (vty, NULL, afi, safi, bgp_show_type_lcommunity_list, list);
12168}
12169
12170DEFUN (show_ip_bgp_lcommunity_list,
12171 show_ip_bgp_lcommunity_list_cmd,
12172 "show ip bgp large-community-list (<1-500>|WORD)",
12173 SHOW_STR
12174 IP_STR
12175 BGP_STR
12176 "Display routes matching the large-community-list\n"
12177 "large-community-list number\n"
12178 "large-community-list name\n")
12179{
12180 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP, SAFI_UNICAST);
12181}
12182
12183DEFUN (show_ip_bgp_ipv4_lcommunity_list,
12184 show_ip_bgp_ipv4_lcommunity_list_cmd,
12185 "show ip bgp ipv4 (unicast|multicast) large-community-list (<1-500>|WORD)",
12186 SHOW_STR
12187 IP_STR
12188 BGP_STR
12189 "Address family\n"
12190 "Address Family modifier\n"
12191 "Address Family modifier\n"
12192 "Display routes matching the large-community-list\n"
12193 "large-community-list number\n"
12194 "large-community-list name\n")
12195{
12196 if (strncmp (argv[0], "m", 1) == 0)
12197 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP, SAFI_MULTICAST);
12198
12199 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP, SAFI_UNICAST);
12200}
12201
12202DEFUN (show_bgp_lcommunity_list,
12203 show_bgp_lcommunity_list_cmd,
12204 "show bgp large-community-list (<1-500>|WORD)",
12205 SHOW_STR
12206 BGP_STR
12207 "Display routes matching the large-community-list\n"
12208 "large-community-list number\n"
12209 "large-community-list name\n")
12210{
12211 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP6, SAFI_UNICAST);
12212}
12213
12214ALIAS (show_bgp_lcommunity_list,
12215 show_bgp_ipv6_lcommunity_list_cmd,
12216 "show bgp ipv6 large-community-list (<1-500>|WORD)",
12217 SHOW_STR
12218 BGP_STR
12219 "Address family\n"
12220 "Display routes matching the large-community-list\n"
12221 "large-community-list number\n"
12222 "large-community-list name\n")
12223
12224/* old command */
12225DEFUN (show_ipv6_bgp_lcommunity_list,
12226 show_ipv6_bgp_lcommunity_list_cmd,
12227 "show ipv6 bgp large-community-list WORD",
12228 SHOW_STR
12229 IPV6_STR
12230 BGP_STR
12231 "Display routes matching the large-community-list\n"
12232 "large-community-list name\n")
12233{
12234 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP6, SAFI_UNICAST);
12235}
12236
12237/* old command */
12238DEFUN (show_ipv6_mbgp_lcommunity_list,
12239 show_ipv6_mbgp_lcommunity_list_cmd,
12240 "show ipv6 mbgp large-community-list WORD",
12241 SHOW_STR
12242 IPV6_STR
12243 MBGP_STR
12244 "Display routes matching the large-community-list\n"
12245 "large-community-list name\n")
12246{
12247 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
12248}
12249
12250DEFUN (show_bgp_ipv4_lcommunity_list,
12251 show_bgp_ipv4_lcommunity_list_cmd,
12252 "show bgp ipv4 large-community-list (<1-500>|WORD)",
12253 SHOW_STR
12254 BGP_STR
12255 IP_STR
12256 "Display routes matching the large-community-list\n"
12257 "large-community-list number\n"
12258 "large-community-list name\n")
12259{
12260 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP, SAFI_UNICAST);
12261}
12262
12263DEFUN (show_bgp_ipv4_safi_lcommunity_list,
12264 show_bgp_ipv4_safi_lcommunity_list_cmd,
12265 "show bgp ipv4 (unicast|multicast) large-community-list (<1-500>|WORD)",
12266 SHOW_STR
12267 BGP_STR
12268 "Address family\n"
12269 "Address Family modifier\n"
12270 "Address Family modifier\n"
12271 "Display routes matching the large-community-list\n"
12272 "large-community-list number\n"
12273 "large-community-list name\n")
12274{
12275 if (strncmp (argv[0], "m", 1) == 0)
12276 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP, SAFI_MULTICAST);
12277
12278 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP, SAFI_UNICAST);
12279}
12280
12281DEFUN (show_bgp_ipv6_safi_lcommunity_list,
12282 show_bgp_ipv6_safi_lcommunity_list_cmd,
12283 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community-list (<1-500>|WORD)",
12284 SHOW_STR
12285 BGP_STR
12286 "Address family\n"
12287 "Address family modifier\n"
12288 "Address family modifier\n"
12289 "Address family modifier\n"
12290 "Address family modifier\n"
12291 "Display routes matching the large-community-list\n"
12292 "large-community-list number\n"
12293 "large-community-list name\n")
12294{
12295 safi_t safi;
12296
12297 if (bgp_parse_safi(argv[0], &safi)) {
12298 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12299 return CMD_WARNING;
12300 }
12301 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP6, safi);
12302}
12303
paul94f2b392005-06-28 12:44:16 +000012304static int
paulfd79ac92004-10-13 05:06:08 +000012305bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000012306 safi_t safi, enum bgp_show_type type)
12307{
12308 int ret;
12309 struct prefix *p;
12310
12311 p = prefix_new();
12312
12313 ret = str2prefix (prefix, p);
12314 if (! ret)
12315 {
12316 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
12317 return CMD_WARNING;
12318 }
12319
ajs5a646652004-11-05 01:25:55 +000012320 ret = bgp_show (vty, NULL, afi, safi, type, p);
12321 prefix_free(p);
12322 return ret;
paul718e3742002-12-13 20:15:29 +000012323}
12324
Lou Bergerf9b6c392016-01-12 13:42:09 -050012325DEFUN (show_ip_bgp_prefix_longer,
12326 show_ip_bgp_prefix_longer_cmd,
12327 "show ip bgp A.B.C.D/M longer-prefixes",
12328 SHOW_STR
12329 IP_STR
12330 BGP_STR
12331 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12332 "Display route and more specific routes\n")
12333{
12334 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12335 bgp_show_type_prefix_longer);
12336}
12337
12338DEFUN (show_ip_bgp_flap_prefix_longer,
12339 show_ip_bgp_flap_prefix_longer_cmd,
12340 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
12341 SHOW_STR
12342 IP_STR
12343 BGP_STR
12344 "Display flap statistics of routes\n"
12345 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12346 "Display route and more specific routes\n")
12347{
12348 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12349 bgp_show_type_flap_prefix_longer);
12350}
12351
12352ALIAS (show_ip_bgp_flap_prefix_longer,
12353 show_ip_bgp_damp_flap_prefix_longer_cmd,
12354 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
12355 SHOW_STR
12356 IP_STR
12357 BGP_STR
12358 "Display detailed information about dampening\n"
12359 "Display flap statistics of routes\n"
12360 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12361 "Display route and more specific routes\n")
12362
12363DEFUN (show_ip_bgp_ipv4_prefix_longer,
12364 show_ip_bgp_ipv4_prefix_longer_cmd,
12365 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
12366 SHOW_STR
12367 IP_STR
12368 BGP_STR
12369 "Address family\n"
12370 "Address Family modifier\n"
12371 "Address Family modifier\n"
12372 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12373 "Display route and more specific routes\n")
12374{
12375 if (strncmp (argv[0], "m", 1) == 0)
12376 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
12377 bgp_show_type_prefix_longer);
12378
12379 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
12380 bgp_show_type_prefix_longer);
12381}
12382
12383DEFUN (show_ip_bgp_flap_address,
12384 show_ip_bgp_flap_address_cmd,
12385 "show ip bgp flap-statistics A.B.C.D",
12386 SHOW_STR
12387 IP_STR
12388 BGP_STR
12389 "Display flap statistics of routes\n"
12390 "Network in the BGP routing table to display\n")
12391{
12392 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12393 bgp_show_type_flap_address);
12394}
12395
12396ALIAS (show_ip_bgp_flap_address,
12397 show_ip_bgp_damp_flap_address_cmd,
12398 "show ip bgp dampening flap-statistics A.B.C.D",
12399 SHOW_STR
12400 IP_STR
12401 BGP_STR
12402 "Display detailed information about dampening\n"
12403 "Display flap statistics of routes\n"
12404 "Network in the BGP routing table to display\n")
12405
12406DEFUN (show_ip_bgp_flap_prefix,
12407 show_ip_bgp_flap_prefix_cmd,
12408 "show ip bgp flap-statistics A.B.C.D/M",
12409 SHOW_STR
12410 IP_STR
12411 BGP_STR
12412 "Display flap statistics of routes\n"
12413 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12414{
12415 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12416 bgp_show_type_flap_prefix);
12417}
12418
12419ALIAS (show_ip_bgp_flap_prefix,
12420 show_ip_bgp_damp_flap_prefix_cmd,
12421 "show ip bgp dampening flap-statistics A.B.C.D/M",
12422 SHOW_STR
12423 IP_STR
12424 BGP_STR
12425 "Display detailed information about dampening\n"
12426 "Display flap statistics of routes\n"
12427 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12428
Lou Bergerf9b6c392016-01-12 13:42:09 -050012429DEFUN (show_bgp_prefix_longer,
12430 show_bgp_prefix_longer_cmd,
12431 "show bgp X:X::X:X/M longer-prefixes",
12432 SHOW_STR
12433 BGP_STR
12434 "IPv6 prefix <network>/<length>\n"
12435 "Display route and more specific routes\n")
12436{
12437 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
12438 bgp_show_type_prefix_longer);
12439}
12440
12441/* old command */
12442DEFUN (show_ipv6_bgp_prefix_longer,
12443 show_ipv6_bgp_prefix_longer_cmd,
12444 "show ipv6 bgp X:X::X:X/M longer-prefixes",
12445 SHOW_STR
12446 IPV6_STR
12447 BGP_STR
12448 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
12449 "Display route and more specific routes\n")
12450{
12451 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
12452 bgp_show_type_prefix_longer);
12453}
12454
12455/* old command */
12456DEFUN (show_ipv6_mbgp_prefix_longer,
12457 show_ipv6_mbgp_prefix_longer_cmd,
12458 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
12459 SHOW_STR
12460 IPV6_STR
12461 MBGP_STR
12462 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
12463 "Display route and more specific routes\n")
12464{
12465 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
12466 bgp_show_type_prefix_longer);
12467}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012468
Lou Berger651b4022016-01-12 13:42:07 -050012469DEFUN (show_bgp_ipv4_prefix_longer,
12470 show_bgp_ipv4_prefix_longer_cmd,
12471 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000012472 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012473 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012474 IP_STR
paul718e3742002-12-13 20:15:29 +000012475 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12476 "Display route and more specific routes\n")
12477{
12478 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12479 bgp_show_type_prefix_longer);
12480}
12481
Lou Berger651b4022016-01-12 13:42:07 -050012482DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
12483 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
12484 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000012485 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012486 BGP_STR
12487 "Address family\n"
12488 "Address Family modifier\n"
12489 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012490 "Address Family modifier\n"
12491 "Address Family modifier\n"
12492 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000012493 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12494 "Display route and more specific routes\n")
12495{
Lou Berger651b4022016-01-12 13:42:07 -050012496 safi_t safi;
paul718e3742002-12-13 20:15:29 +000012497
Lou Berger651b4022016-01-12 13:42:07 -050012498 if (bgp_parse_safi(argv[0], &safi)) {
12499 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12500 return CMD_WARNING;
12501 }
12502 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
12503 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000012504}
12505
Lou Berger651b4022016-01-12 13:42:07 -050012506ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
12507 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
12508 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000012509 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012510 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012511 "Address family\n"
12512 "Address Family modifier\n"
12513 "Address Family modifier\n"
12514 "Address Family modifier\n"
12515 "Address Family modifier\n"
12516 "Display detailed information about dampening\n"
12517 "Display flap statistics of routes\n"
12518 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12519 "Display route and more specific routes\n")
12520
Lou Berger651b4022016-01-12 13:42:07 -050012521DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
12522 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
12523 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
12524 SHOW_STR
12525 BGP_STR
12526 "Address family\n"
12527 "Address Family modifier\n"
12528 "Address Family modifier\n"
12529 "Address Family modifier\n"
12530 "Address Family modifier\n"
12531 "Display flap statistics of routes\n"
12532 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12533 "Display route and more specific routes\n")
12534{
12535 safi_t safi;
12536
12537 if (bgp_parse_safi(argv[0], &safi)) {
12538 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12539 return CMD_WARNING;
12540 }
12541 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
12542 bgp_show_type_flap_prefix_longer);
12543}
12544ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
12545 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
12546 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
12547 SHOW_STR
12548 BGP_STR
12549 "Address family\n"
12550 "Address Family modifier\n"
12551 "Address Family modifier\n"
12552 "Address Family modifier\n"
12553 "Address Family modifier\n"
12554 "Display detailed information about dampening\n"
12555 "Display flap statistics of routes\n"
12556 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12557 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050012558
12559DEFUN (show_bgp_ipv4_safi_prefix_longer,
12560 show_bgp_ipv4_safi_prefix_longer_cmd,
12561 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
12562 SHOW_STR
12563 BGP_STR
12564 "Address family\n"
12565 "Address Family modifier\n"
12566 "Address Family modifier\n"
12567 "Address Family modifier\n"
12568 "Address Family modifier\n"
12569 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12570 "Display route and more specific routes\n")
12571{
12572 safi_t safi;
12573
12574 if (bgp_parse_safi(argv[0], &safi)) {
12575 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12576 return CMD_WARNING;
12577 }
12578
12579 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
12580 bgp_show_type_prefix_longer);
12581}
12582
Lou Berger651b4022016-01-12 13:42:07 -050012583DEFUN (show_bgp_ipv6_safi_prefix_longer,
12584 show_bgp_ipv6_safi_prefix_longer_cmd,
12585 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
12586 SHOW_STR
12587 BGP_STR
12588 "Address family\n"
12589 "Address Family modifier\n"
12590 "Address Family modifier\n"
12591 "Address Family modifier\n"
12592 "Address Family modifier\n"
12593 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12594 "Display route and more specific routes\n")
12595{
12596 safi_t safi;
12597
12598 if (bgp_parse_safi(argv[0], &safi)) {
12599 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12600 return CMD_WARNING;
12601 }
12602
12603 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
12604 bgp_show_type_prefix_longer);
12605}
Lou Berger651b4022016-01-12 13:42:07 -050012606
12607DEFUN (show_bgp_ipv4_safi_flap_address,
12608 show_bgp_ipv4_safi_flap_address_cmd,
12609 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
12610 SHOW_STR
12611 BGP_STR
12612 "Address family\n"
12613 "Address Family modifier\n"
12614 "Address Family modifier\n"
12615 "Address Family modifier\n"
12616 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000012617 "Display flap statistics of routes\n"
12618 "Network in the BGP routing table to display\n")
12619{
Lou Berger651b4022016-01-12 13:42:07 -050012620 safi_t safi;
12621
12622 if (bgp_parse_safi(argv[0], &safi)) {
12623 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12624 return CMD_WARNING;
12625 }
12626 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000012627 bgp_show_type_flap_address);
12628}
Lou Berger651b4022016-01-12 13:42:07 -050012629ALIAS (show_bgp_ipv4_safi_flap_address,
12630 show_bgp_ipv4_safi_damp_flap_address_cmd,
12631 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053012632 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053012633 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012634 "Address family\n"
12635 "Address Family modifier\n"
12636 "Address Family modifier\n"
12637 "Address Family modifier\n"
12638 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053012639 "Display detailed information about dampening\n"
12640 "Display flap statistics of routes\n"
12641 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050012642
Lou Berger651b4022016-01-12 13:42:07 -050012643DEFUN (show_bgp_ipv6_flap_address,
12644 show_bgp_ipv6_flap_address_cmd,
12645 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000012646 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012647 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012648 "Address family\n"
12649 "Address Family modifier\n"
12650 "Address Family modifier\n"
12651 "Address Family modifier\n"
12652 "Address Family modifier\n"
12653 "Display flap statistics of routes\n"
12654 "Network in the BGP routing table to display\n")
12655{
12656 safi_t safi;
12657
12658 if (bgp_parse_safi(argv[0], &safi)) {
12659 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
12660 return CMD_WARNING;
12661 }
12662 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
12663 bgp_show_type_flap_address);
12664}
12665ALIAS (show_bgp_ipv6_flap_address,
12666 show_bgp_ipv6_damp_flap_address_cmd,
12667 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
12668 SHOW_STR
12669 BGP_STR
12670 "Address family\n"
12671 "Address Family modifier\n"
12672 "Address Family modifier\n"
12673 "Address Family modifier\n"
12674 "Address Family modifier\n"
12675 "Display detailed information about dampening\n"
12676 "Display flap statistics of routes\n"
12677 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050012678
12679DEFUN (show_bgp_ipv4_safi_flap_prefix,
12680 show_bgp_ipv4_safi_flap_prefix_cmd,
12681 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
12682 SHOW_STR
12683 BGP_STR
12684 "Address family\n"
12685 "Address Family modifier\n"
12686 "Address Family modifier\n"
12687 "Address Family modifier\n"
12688 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000012689 "Display flap statistics of routes\n"
12690 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12691{
Lou Berger651b4022016-01-12 13:42:07 -050012692 safi_t safi;
12693
12694 if (bgp_parse_safi(argv[0], &safi)) {
12695 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
12696 return CMD_WARNING;
12697 }
12698 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000012699 bgp_show_type_flap_prefix);
12700}
Balaji3921cc52015-05-16 23:12:17 +053012701
Lou Berger651b4022016-01-12 13:42:07 -050012702ALIAS (show_bgp_ipv4_safi_flap_prefix,
12703 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
12704 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053012705 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053012706 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012707 "Address family\n"
12708 "Address Family modifier\n"
12709 "Address Family modifier\n"
12710 "Address Family modifier\n"
12711 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053012712 "Display detailed information about dampening\n"
12713 "Display flap statistics of routes\n"
12714 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12715
Lou Berger651b4022016-01-12 13:42:07 -050012716DEFUN (show_bgp_ipv6_safi_flap_prefix,
12717 show_bgp_ipv6_safi_flap_prefix_cmd,
12718 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000012719 SHOW_STR
12720 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012721 "Address family\n"
12722 "Address Family modifier\n"
12723 "Address Family modifier\n"
12724 "Address Family modifier\n"
12725 "Address Family modifier\n"
12726 "Display flap statistics of routes\n"
12727 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000012728{
Lou Berger651b4022016-01-12 13:42:07 -050012729 safi_t safi;
12730
12731 if (bgp_parse_safi(argv[0], &safi)) {
12732 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
12733 return CMD_WARNING;
12734 }
12735 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
12736 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000012737}
12738
Lou Berger651b4022016-01-12 13:42:07 -050012739ALIAS (show_bgp_ipv6_safi_flap_prefix,
12740 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
12741 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
12742 SHOW_STR
12743 BGP_STR
12744 "Address family\n"
12745 "Address Family modifier\n"
12746 "Address Family modifier\n"
12747 "Address Family modifier\n"
12748 "Address Family modifier\n"
12749 "Display detailed information about dampening\n"
12750 "Display flap statistics of routes\n"
12751 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12752
12753DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000012754 show_bgp_ipv6_prefix_longer_cmd,
12755 "show bgp ipv6 X:X::X:X/M longer-prefixes",
12756 SHOW_STR
12757 BGP_STR
12758 "Address family\n"
12759 "IPv6 prefix <network>/<length>\n"
12760 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000012761{
12762 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
12763 bgp_show_type_prefix_longer);
12764}
12765
paul94f2b392005-06-28 12:44:16 +000012766static struct peer *
paulfd79ac92004-10-13 05:06:08 +000012767peer_lookup_in_view (struct vty *vty, const char *view_name,
12768 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000012769{
12770 int ret;
12771 struct bgp *bgp;
12772 struct peer *peer;
12773 union sockunion su;
12774
12775 /* BGP structure lookup. */
12776 if (view_name)
12777 {
12778 bgp = bgp_lookup_by_name (view_name);
12779 if (! bgp)
12780 {
12781 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
12782 return NULL;
12783 }
12784 }
paul5228ad22004-06-04 17:58:18 +000012785 else
paulbb46e942003-10-24 19:02:03 +000012786 {
12787 bgp = bgp_get_default ();
12788 if (! bgp)
12789 {
12790 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
12791 return NULL;
12792 }
12793 }
12794
12795 /* Get peer sockunion. */
12796 ret = str2sockunion (ip_str, &su);
12797 if (ret < 0)
12798 {
12799 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
12800 return NULL;
12801 }
12802
12803 /* Peer structure lookup. */
12804 peer = peer_lookup (bgp, &su);
12805 if (! peer)
12806 {
12807 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
12808 return NULL;
12809 }
12810
12811 return peer;
12812}
David Lamparter6b0655a2014-06-04 06:53:35 +020012813
Paul Jakma2815e612006-09-14 02:56:07 +000012814enum bgp_stats
12815{
12816 BGP_STATS_MAXBITLEN = 0,
12817 BGP_STATS_RIB,
12818 BGP_STATS_PREFIXES,
12819 BGP_STATS_TOTPLEN,
12820 BGP_STATS_UNAGGREGATEABLE,
12821 BGP_STATS_MAX_AGGREGATEABLE,
12822 BGP_STATS_AGGREGATES,
12823 BGP_STATS_SPACE,
12824 BGP_STATS_ASPATH_COUNT,
12825 BGP_STATS_ASPATH_MAXHOPS,
12826 BGP_STATS_ASPATH_TOTHOPS,
12827 BGP_STATS_ASPATH_MAXSIZE,
12828 BGP_STATS_ASPATH_TOTSIZE,
12829 BGP_STATS_ASN_HIGHEST,
12830 BGP_STATS_MAX,
12831};
paulbb46e942003-10-24 19:02:03 +000012832
Paul Jakma2815e612006-09-14 02:56:07 +000012833static const char *table_stats_strs[] =
12834{
12835 [BGP_STATS_PREFIXES] = "Total Prefixes",
12836 [BGP_STATS_TOTPLEN] = "Average prefix length",
12837 [BGP_STATS_RIB] = "Total Advertisements",
12838 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
12839 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
12840 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
12841 [BGP_STATS_SPACE] = "Address space advertised",
12842 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
12843 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
12844 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
12845 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
12846 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
12847 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
12848 [BGP_STATS_MAX] = NULL,
12849};
12850
12851struct bgp_table_stats
12852{
12853 struct bgp_table *table;
12854 unsigned long long counts[BGP_STATS_MAX];
12855};
12856
12857#if 0
12858#define TALLY_SIGFIG 100000
12859static unsigned long
12860ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
12861{
12862 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
12863 unsigned long res = (newtot * TALLY_SIGFIG) / count;
12864 unsigned long ret = newtot / count;
12865
12866 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
12867 return ret + 1;
12868 else
12869 return ret;
12870}
12871#endif
12872
12873static int
12874bgp_table_stats_walker (struct thread *t)
12875{
12876 struct bgp_node *rn;
12877 struct bgp_node *top;
12878 struct bgp_table_stats *ts = THREAD_ARG (t);
12879 unsigned int space = 0;
12880
Paul Jakma53d9f672006-10-15 23:41:16 +000012881 if (!(top = bgp_table_top (ts->table)))
12882 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000012883
12884 switch (top->p.family)
12885 {
12886 case AF_INET:
12887 space = IPV4_MAX_BITLEN;
12888 break;
12889 case AF_INET6:
12890 space = IPV6_MAX_BITLEN;
12891 break;
12892 }
12893
12894 ts->counts[BGP_STATS_MAXBITLEN] = space;
12895
12896 for (rn = top; rn; rn = bgp_route_next (rn))
12897 {
12898 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070012899 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000012900 unsigned int rinum = 0;
12901
12902 if (rn == top)
12903 continue;
12904
12905 if (!rn->info)
12906 continue;
12907
12908 ts->counts[BGP_STATS_PREFIXES]++;
12909 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
12910
12911#if 0
12912 ts->counts[BGP_STATS_AVGPLEN]
12913 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
12914 ts->counts[BGP_STATS_AVGPLEN],
12915 rn->p.prefixlen);
12916#endif
12917
12918 /* check if the prefix is included by any other announcements */
12919 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070012920 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000012921
12922 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000012923 {
12924 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
12925 /* announced address space */
12926 if (space)
12927 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
12928 }
Paul Jakma2815e612006-09-14 02:56:07 +000012929 else if (prn->info)
12930 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
12931
Paul Jakma2815e612006-09-14 02:56:07 +000012932 for (ri = rn->info; ri; ri = ri->next)
12933 {
12934 rinum++;
12935 ts->counts[BGP_STATS_RIB]++;
12936
12937 if (ri->attr &&
12938 (CHECK_FLAG (ri->attr->flag,
12939 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
12940 ts->counts[BGP_STATS_AGGREGATES]++;
12941
12942 /* as-path stats */
12943 if (ri->attr && ri->attr->aspath)
12944 {
12945 unsigned int hops = aspath_count_hops (ri->attr->aspath);
12946 unsigned int size = aspath_size (ri->attr->aspath);
12947 as_t highest = aspath_highest (ri->attr->aspath);
12948
12949 ts->counts[BGP_STATS_ASPATH_COUNT]++;
12950
12951 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
12952 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
12953
12954 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
12955 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
12956
12957 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
12958 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
12959#if 0
12960 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
12961 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12962 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
12963 hops);
12964 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
12965 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12966 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
12967 size);
12968#endif
12969 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
12970 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
12971 }
12972 }
12973 }
12974 return 0;
12975}
12976
12977static int
12978bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
12979{
12980 struct bgp_table_stats ts;
12981 unsigned int i;
12982
12983 if (!bgp->rib[afi][safi])
12984 {
Donald Sharp3c964042016-01-25 23:38:53 -050012985 vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s",
12986 afi, safi, VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000012987 return CMD_WARNING;
12988 }
12989
12990 memset (&ts, 0, sizeof (ts));
12991 ts.table = bgp->rib[afi][safi];
12992 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
12993
12994 vty_out (vty, "BGP %s RIB statistics%s%s",
12995 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
12996
12997 for (i = 0; i < BGP_STATS_MAX; i++)
12998 {
12999 if (!table_stats_strs[i])
13000 continue;
13001
13002 switch (i)
13003 {
13004#if 0
13005 case BGP_STATS_ASPATH_AVGHOPS:
13006 case BGP_STATS_ASPATH_AVGSIZE:
13007 case BGP_STATS_AVGPLEN:
13008 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13009 vty_out (vty, "%12.2f",
13010 (float)ts.counts[i] / (float)TALLY_SIGFIG);
13011 break;
13012#endif
13013 case BGP_STATS_ASPATH_TOTHOPS:
13014 case BGP_STATS_ASPATH_TOTSIZE:
13015 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13016 vty_out (vty, "%12.2f",
13017 ts.counts[i] ?
13018 (float)ts.counts[i] /
13019 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
13020 : 0);
13021 break;
13022 case BGP_STATS_TOTPLEN:
13023 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13024 vty_out (vty, "%12.2f",
13025 ts.counts[i] ?
13026 (float)ts.counts[i] /
13027 (float)ts.counts[BGP_STATS_PREFIXES]
13028 : 0);
13029 break;
13030 case BGP_STATS_SPACE:
13031 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13032 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
13033 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
13034 break;
Paul Jakma30a22312008-08-15 14:05:22 +010013035 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000013036 vty_out (vty, "%12.2f%s",
13037 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000013038 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000013039 VTY_NEWLINE);
13040 vty_out (vty, "%30s: ", "/8 equivalent ");
13041 vty_out (vty, "%12.2f%s",
13042 (float)ts.counts[BGP_STATS_SPACE] /
13043 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
13044 VTY_NEWLINE);
13045 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
13046 break;
13047 vty_out (vty, "%30s: ", "/24 equivalent ");
13048 vty_out (vty, "%12.2f",
13049 (float)ts.counts[BGP_STATS_SPACE] /
13050 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
13051 break;
13052 default:
13053 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13054 vty_out (vty, "%12llu", ts.counts[i]);
13055 }
13056
13057 vty_out (vty, "%s", VTY_NEWLINE);
13058 }
13059 return CMD_SUCCESS;
13060}
13061
13062static int
13063bgp_table_stats_vty (struct vty *vty, const char *name,
13064 const char *afi_str, const char *safi_str)
13065{
13066 struct bgp *bgp;
13067 afi_t afi;
13068 safi_t safi;
13069
13070 if (name)
13071 bgp = bgp_lookup_by_name (name);
13072 else
13073 bgp = bgp_get_default ();
13074
13075 if (!bgp)
13076 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050013077 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000013078 return CMD_WARNING;
13079 }
13080 if (strncmp (afi_str, "ipv", 3) == 0)
13081 {
13082 if (strncmp (afi_str, "ipv4", 4) == 0)
13083 afi = AFI_IP;
13084 else if (strncmp (afi_str, "ipv6", 4) == 0)
13085 afi = AFI_IP6;
13086 else
13087 {
13088 vty_out (vty, "%% Invalid address family %s%s",
13089 afi_str, VTY_NEWLINE);
13090 return CMD_WARNING;
13091 }
Lou Berger298cc2f2016-01-12 13:42:02 -050013092 switch (safi_str[0]) {
13093 case 'm':
13094 safi = SAFI_MULTICAST;
13095 break;
13096 case 'u':
13097 safi = SAFI_UNICAST;
13098 break;
13099 case 'v':
Donald Sharp3c964042016-01-25 23:38:53 -050013100 safi = SAFI_MPLS_VPN;
Lou Berger298cc2f2016-01-12 13:42:02 -050013101 break;
13102 case 'e':
13103 safi = SAFI_ENCAP;
13104 break;
13105 default:
13106 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000013107 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050013108 return CMD_WARNING;
13109 }
Paul Jakma2815e612006-09-14 02:56:07 +000013110 }
13111 else
13112 {
Lou Berger298cc2f2016-01-12 13:42:02 -050013113 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000013114 afi_str, VTY_NEWLINE);
13115 return CMD_WARNING;
13116 }
13117
Paul Jakma2815e612006-09-14 02:56:07 +000013118 return bgp_table_stats (vty, bgp, afi, safi);
13119}
13120
13121DEFUN (show_bgp_statistics,
13122 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050013123 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000013124 SHOW_STR
13125 BGP_STR
13126 "Address family\n"
13127 "Address family\n"
13128 "Address Family modifier\n"
13129 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050013130 "Address Family modifier\n"
13131 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000013132 "BGP RIB advertisement statistics\n")
13133{
13134 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
13135}
13136
Lou Bergerf9b6c392016-01-12 13:42:09 -050013137ALIAS (show_bgp_statistics,
13138 show_bgp_statistics_vpnv4_cmd,
13139 "show bgp (ipv4) (vpnv4) statistics",
13140 SHOW_STR
13141 BGP_STR
13142 "Address family\n"
13143 "Address Family modifier\n"
13144 "BGP RIB advertisement statistics\n")
13145
Paul Jakma2815e612006-09-14 02:56:07 +000013146DEFUN (show_bgp_statistics_view,
13147 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050013148 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000013149 SHOW_STR
13150 BGP_STR
13151 "BGP view\n"
13152 "Address family\n"
13153 "Address family\n"
13154 "Address Family modifier\n"
13155 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050013156 "Address Family modifier\n"
13157 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000013158 "BGP RIB advertisement statistics\n")
13159{
13160 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
13161}
13162
13163ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050013164 show_bgp_statistics_view_vpnv4_cmd,
13165 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000013166 SHOW_STR
13167 BGP_STR
13168 "BGP view\n"
13169 "Address family\n"
13170 "Address Family modifier\n"
13171 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020013172
Paul Jakmaff7924f2006-09-04 01:10:36 +000013173enum bgp_pcounts
13174{
13175 PCOUNT_ADJ_IN = 0,
13176 PCOUNT_DAMPED,
13177 PCOUNT_REMOVED,
13178 PCOUNT_HISTORY,
13179 PCOUNT_STALE,
13180 PCOUNT_VALID,
13181 PCOUNT_ALL,
13182 PCOUNT_COUNTED,
13183 PCOUNT_PFCNT, /* the figure we display to users */
13184 PCOUNT_MAX,
13185};
13186
13187static const char *pcount_strs[] =
13188{
13189 [PCOUNT_ADJ_IN] = "Adj-in",
13190 [PCOUNT_DAMPED] = "Damped",
13191 [PCOUNT_REMOVED] = "Removed",
13192 [PCOUNT_HISTORY] = "History",
13193 [PCOUNT_STALE] = "Stale",
13194 [PCOUNT_VALID] = "Valid",
13195 [PCOUNT_ALL] = "All RIB",
13196 [PCOUNT_COUNTED] = "PfxCt counted",
13197 [PCOUNT_PFCNT] = "Useable",
13198 [PCOUNT_MAX] = NULL,
13199};
13200
Paul Jakma2815e612006-09-14 02:56:07 +000013201struct peer_pcounts
13202{
13203 unsigned int count[PCOUNT_MAX];
13204 const struct peer *peer;
13205 const struct bgp_table *table;
13206};
13207
Paul Jakmaff7924f2006-09-04 01:10:36 +000013208static int
Paul Jakma2815e612006-09-14 02:56:07 +000013209bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000013210{
13211 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000013212 struct peer_pcounts *pc = THREAD_ARG (t);
13213 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013214
Paul Jakma2815e612006-09-14 02:56:07 +000013215 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000013216 {
13217 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000013218 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013219
13220 for (ain = rn->adj_in; ain; ain = ain->next)
13221 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000013222 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013223
Paul Jakmaff7924f2006-09-04 01:10:36 +000013224 for (ri = rn->info; ri; ri = ri->next)
13225 {
13226 char buf[SU_ADDRSTRLEN];
13227
13228 if (ri->peer != peer)
13229 continue;
13230
Paul Jakma2815e612006-09-14 02:56:07 +000013231 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013232
13233 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000013234 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013235 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000013236 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013237 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000013238 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013239 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000013240 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013241 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000013242 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000013243 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000013244 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013245
13246 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
13247 {
Paul Jakma2815e612006-09-14 02:56:07 +000013248 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000013249 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000013250 plog_warn (peer->log,
13251 "%s [pcount] %s/%d is counted but flags 0x%x",
13252 peer->host,
13253 inet_ntop(rn->p.family, &rn->p.u.prefix,
13254 buf, SU_ADDRSTRLEN),
13255 rn->p.prefixlen,
13256 ri->flags);
13257 }
13258 else
13259 {
Paul Jakma1a392d42006-09-07 00:24:49 +000013260 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000013261 plog_warn (peer->log,
13262 "%s [pcount] %s/%d not counted but flags 0x%x",
13263 peer->host,
13264 inet_ntop(rn->p.family, &rn->p.u.prefix,
13265 buf, SU_ADDRSTRLEN),
13266 rn->p.prefixlen,
13267 ri->flags);
13268 }
13269 }
13270 }
Paul Jakma2815e612006-09-14 02:56:07 +000013271 return 0;
13272}
Paul Jakmaff7924f2006-09-04 01:10:36 +000013273
Paul Jakma2815e612006-09-14 02:56:07 +000013274static int
13275bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
13276{
13277 struct peer_pcounts pcounts = { .peer = peer };
13278 unsigned int i;
13279
13280 if (!peer || !peer->bgp || !peer->afc[afi][safi]
13281 || !peer->bgp->rib[afi][safi])
13282 {
13283 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
13284 return CMD_WARNING;
13285 }
13286
13287 memset (&pcounts, 0, sizeof(pcounts));
13288 pcounts.peer = peer;
13289 pcounts.table = peer->bgp->rib[afi][safi];
13290
13291 /* in-place call via thread subsystem so as to record execution time
13292 * stats for the thread-walk (i.e. ensure this can't be blamed on
13293 * on just vty_read()).
13294 */
13295 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
13296
Paul Jakmaff7924f2006-09-04 01:10:36 +000013297 vty_out (vty, "Prefix counts for %s, %s%s",
13298 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
13299 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
13300 vty_out (vty, "%sCounts from RIB table walk:%s%s",
13301 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
13302
13303 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000013304 vty_out (vty, "%20s: %-10d%s",
13305 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000013306
Paul Jakma2815e612006-09-14 02:56:07 +000013307 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000013308 {
13309 vty_out (vty, "%s [pcount] PfxCt drift!%s",
13310 peer->host, VTY_NEWLINE);
13311 vty_out (vty, "Please report this bug, with the above command output%s",
13312 VTY_NEWLINE);
13313 }
13314
13315 return CMD_SUCCESS;
13316}
13317
Lou Bergerf9b6c392016-01-12 13:42:09 -050013318DEFUN (show_ip_bgp_neighbor_prefix_counts,
13319 show_ip_bgp_neighbor_prefix_counts_cmd,
13320 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13321 SHOW_STR
13322 IP_STR
13323 BGP_STR
13324 "Detailed information on TCP and BGP neighbor connections\n"
13325 "Neighbor to display information about\n"
13326 "Neighbor to display information about\n"
13327 "Display detailed prefix count information\n")
13328{
13329 struct peer *peer;
13330
13331 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13332 if (! peer)
13333 return CMD_WARNING;
13334
13335 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
13336}
13337
Paul Jakmaff7924f2006-09-04 01:10:36 +000013338DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
13339 show_bgp_ipv6_neighbor_prefix_counts_cmd,
13340 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13341 SHOW_STR
13342 BGP_STR
13343 "Address family\n"
13344 "Detailed information on TCP and BGP neighbor connections\n"
13345 "Neighbor to display information about\n"
13346 "Neighbor to display information about\n"
13347 "Display detailed prefix count information\n")
13348{
13349 struct peer *peer;
13350
13351 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13352 if (! peer)
13353 return CMD_WARNING;
13354
13355 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
13356}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013357
13358DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
13359 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
13360 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13361 SHOW_STR
13362 IP_STR
13363 BGP_STR
13364 "Address family\n"
13365 "Address Family modifier\n"
13366 "Address Family modifier\n"
13367 "Detailed information on TCP and BGP neighbor connections\n"
13368 "Neighbor to display information about\n"
13369 "Neighbor to display information about\n"
13370 "Display detailed prefix count information\n")
13371{
13372 struct peer *peer;
13373
13374 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13375 if (! peer)
13376 return CMD_WARNING;
13377
13378 if (strncmp (argv[0], "m", 1) == 0)
13379 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
13380
13381 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
13382}
13383
13384DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
13385 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
13386 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13387 SHOW_STR
13388 IP_STR
13389 BGP_STR
13390 "Address family\n"
13391 "Address Family modifier\n"
13392 "Address Family modifier\n"
13393 "Detailed information on TCP and BGP neighbor connections\n"
13394 "Neighbor to display information about\n"
13395 "Neighbor to display information about\n"
13396 "Display detailed prefix count information\n")
13397{
13398 struct peer *peer;
13399
13400 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13401 if (! peer)
13402 return CMD_WARNING;
13403
13404 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
13405}
Paul Jakmaff7924f2006-09-04 01:10:36 +000013406
Lou Berger651b4022016-01-12 13:42:07 -050013407DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
13408 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
13409 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000013410 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000013411 BGP_STR
13412 "Address family\n"
13413 "Address Family modifier\n"
13414 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050013415 "Address Family modifier\n"
13416 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000013417 "Detailed information on TCP and BGP neighbor connections\n"
13418 "Neighbor to display information about\n"
13419 "Neighbor to display information about\n"
13420 "Display detailed prefix count information\n")
13421{
13422 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013423 safi_t safi;
13424
13425 if (bgp_parse_safi(argv[0], &safi)) {
13426 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13427 return CMD_WARNING;
13428 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000013429
13430 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13431 if (! peer)
13432 return CMD_WARNING;
13433
Lou Berger651b4022016-01-12 13:42:07 -050013434 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000013435}
Lou Berger205e6742016-01-12 13:42:11 -050013436
Lou Berger651b4022016-01-12 13:42:07 -050013437DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
13438 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
13439 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13440 SHOW_STR
13441 BGP_STR
13442 "Address family\n"
13443 "Address Family modifier\n"
13444 "Address Family modifier\n"
13445 "Address Family modifier\n"
13446 "Address Family modifier\n"
13447 "Detailed information on TCP and BGP neighbor connections\n"
13448 "Neighbor to display information about\n"
13449 "Neighbor to display information about\n"
13450 "Display detailed prefix count information\n")
13451{
13452 struct peer *peer;
13453 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000013454
Lou Berger651b4022016-01-12 13:42:07 -050013455 if (bgp_parse_safi(argv[0], &safi)) {
13456 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13457 return CMD_WARNING;
13458 }
13459
13460 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13461 if (! peer)
13462 return CMD_WARNING;
13463
13464 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
13465}
Lou Berger651b4022016-01-12 13:42:07 -050013466
13467DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
13468 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
13469 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000013470 SHOW_STR
13471 IP_STR
13472 BGP_STR
13473 "Address family\n"
13474 "Address Family modifier\n"
13475 "Address Family modifier\n"
13476 "Detailed information on TCP and BGP neighbor connections\n"
13477 "Neighbor to display information about\n"
13478 "Neighbor to display information about\n"
13479 "Display detailed prefix count information\n")
13480{
13481 struct peer *peer;
13482
13483 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13484 if (! peer)
13485 return CMD_WARNING;
13486
Lou Berger651b4022016-01-12 13:42:07 -050013487 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000013488}
13489
13490
paul94f2b392005-06-28 12:44:16 +000013491static void
paul718e3742002-12-13 20:15:29 +000013492show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
13493 int in)
13494{
13495 struct bgp_table *table;
13496 struct bgp_adj_in *ain;
13497 struct bgp_adj_out *adj;
13498 unsigned long output_count;
13499 struct bgp_node *rn;
13500 int header1 = 1;
13501 struct bgp *bgp;
13502 int header2 = 1;
13503
paulbb46e942003-10-24 19:02:03 +000013504 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000013505
13506 if (! bgp)
13507 return;
13508
13509 table = bgp->rib[afi][safi];
13510
13511 output_count = 0;
13512
13513 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
13514 PEER_STATUS_DEFAULT_ORIGINATE))
13515 {
13516 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 +000013517 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13518 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013519
13520 vty_out (vty, "Originating default network 0.0.0.0%s%s",
13521 VTY_NEWLINE, VTY_NEWLINE);
13522 header1 = 0;
13523 }
13524
13525 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
13526 if (in)
13527 {
13528 for (ain = rn->adj_in; ain; ain = ain->next)
13529 if (ain->peer == peer)
13530 {
13531 if (header1)
13532 {
13533 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 +000013534 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13535 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013536 header1 = 0;
13537 }
13538 if (header2)
13539 {
13540 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
13541 header2 = 0;
13542 }
13543 if (ain->attr)
13544 {
13545 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
13546 output_count++;
13547 }
13548 }
13549 }
13550 else
13551 {
13552 for (adj = rn->adj_out; adj; adj = adj->next)
13553 if (adj->peer == peer)
13554 {
13555 if (header1)
13556 {
13557 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 +000013558 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13559 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013560 header1 = 0;
13561 }
13562 if (header2)
13563 {
13564 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
13565 header2 = 0;
13566 }
13567 if (adj->attr)
13568 {
13569 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
13570 output_count++;
13571 }
13572 }
13573 }
13574
13575 if (output_count != 0)
13576 vty_out (vty, "%sTotal number of prefixes %ld%s",
13577 VTY_NEWLINE, output_count, VTY_NEWLINE);
13578}
13579
paul94f2b392005-06-28 12:44:16 +000013580static int
paulbb46e942003-10-24 19:02:03 +000013581peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
13582{
paul718e3742002-12-13 20:15:29 +000013583 if (! peer || ! peer->afc[afi][safi])
13584 {
13585 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
13586 return CMD_WARNING;
13587 }
13588
13589 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
13590 {
13591 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
13592 VTY_NEWLINE);
13593 return CMD_WARNING;
13594 }
13595
13596 show_adj_route (vty, peer, afi, safi, in);
13597
13598 return CMD_SUCCESS;
13599}
13600
Lou Bergerf9b6c392016-01-12 13:42:09 -050013601DEFUN (show_ip_bgp_view_neighbor_advertised_route,
13602 show_ip_bgp_view_neighbor_advertised_route_cmd,
13603 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13604 SHOW_STR
13605 IP_STR
13606 BGP_STR
13607 "BGP view\n"
13608 "View name\n"
13609 "Detailed information on TCP and BGP neighbor connections\n"
13610 "Neighbor to display information about\n"
13611 "Neighbor to display information about\n"
13612 "Display the routes advertised to a BGP neighbor\n")
13613{
13614 struct peer *peer;
13615
13616 if (argc == 2)
13617 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13618 else
13619 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13620
13621 if (! peer)
13622 return CMD_WARNING;
13623
13624 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
13625}
13626
13627ALIAS (show_ip_bgp_view_neighbor_advertised_route,
13628 show_ip_bgp_neighbor_advertised_route_cmd,
13629 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13630 SHOW_STR
13631 IP_STR
13632 BGP_STR
13633 "Detailed information on TCP and BGP neighbor connections\n"
13634 "Neighbor to display information about\n"
13635 "Neighbor to display information about\n"
13636 "Display the routes advertised to a BGP neighbor\n")
13637
13638DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
13639 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
13640 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13641 SHOW_STR
13642 IP_STR
13643 BGP_STR
13644 "Address family\n"
13645 "Address Family modifier\n"
13646 "Address Family modifier\n"
13647 "Detailed information on TCP and BGP neighbor connections\n"
13648 "Neighbor to display information about\n"
13649 "Neighbor to display information about\n"
13650 "Display the routes advertised to a BGP neighbor\n")
13651{
13652 struct peer *peer;
13653
13654 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13655 if (! peer)
13656 return CMD_WARNING;
13657
13658 if (strncmp (argv[0], "m", 1) == 0)
13659 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
13660
13661 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
13662}
13663
Lou Bergerf9b6c392016-01-12 13:42:09 -050013664DEFUN (show_bgp_view_neighbor_advertised_route,
13665 show_bgp_view_neighbor_advertised_route_cmd,
13666 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13667 SHOW_STR
13668 BGP_STR
13669 "BGP view\n"
13670 "View name\n"
13671 "Detailed information on TCP and BGP neighbor connections\n"
13672 "Neighbor to display information about\n"
13673 "Neighbor to display information about\n"
13674 "Display the routes advertised to a BGP neighbor\n")
13675{
13676 struct peer *peer;
13677
13678 if (argc == 2)
13679 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13680 else
13681 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13682
13683 if (! peer)
13684 return CMD_WARNING;
13685
13686 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
13687}
13688
13689DEFUN (show_bgp_view_neighbor_received_routes,
13690 show_bgp_view_neighbor_received_routes_cmd,
13691 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
13692 SHOW_STR
13693 BGP_STR
13694 "BGP view\n"
13695 "View name\n"
13696 "Detailed information on TCP and BGP neighbor connections\n"
13697 "Neighbor to display information about\n"
13698 "Neighbor to display information about\n"
13699 "Display the received routes from neighbor\n")
13700{
13701 struct peer *peer;
13702
13703 if (argc == 2)
13704 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13705 else
13706 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13707
13708 if (! peer)
13709 return CMD_WARNING;
13710
13711 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
13712}
13713
13714ALIAS (show_bgp_view_neighbor_advertised_route,
13715 show_bgp_neighbor_advertised_route_cmd,
13716 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13717 SHOW_STR
13718 BGP_STR
13719 "Detailed information on TCP and BGP neighbor connections\n"
13720 "Neighbor to display information about\n"
13721 "Neighbor to display information about\n"
13722 "Display the routes advertised to a BGP neighbor\n")
13723
13724ALIAS (show_bgp_view_neighbor_advertised_route,
13725 show_bgp_ipv6_neighbor_advertised_route_cmd,
13726 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13727 SHOW_STR
13728 BGP_STR
13729 "Address family\n"
13730 "Detailed information on TCP and BGP neighbor connections\n"
13731 "Neighbor to display information about\n"
13732 "Neighbor to display information about\n"
13733 "Display the routes advertised to a BGP neighbor\n")
13734
13735/* old command */
13736ALIAS (show_bgp_view_neighbor_advertised_route,
13737 ipv6_bgp_neighbor_advertised_route_cmd,
13738 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13739 SHOW_STR
13740 IPV6_STR
13741 BGP_STR
13742 "Detailed information on TCP and BGP neighbor connections\n"
13743 "Neighbor to display information about\n"
13744 "Neighbor to display information about\n"
13745 "Display the routes advertised to a BGP neighbor\n")
13746
13747/* old command */
13748DEFUN (ipv6_mbgp_neighbor_advertised_route,
13749 ipv6_mbgp_neighbor_advertised_route_cmd,
13750 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13751 SHOW_STR
13752 IPV6_STR
13753 MBGP_STR
13754 "Detailed information on TCP and BGP neighbor connections\n"
13755 "Neighbor to display information about\n"
13756 "Neighbor to display information about\n"
13757 "Display the routes advertised to a BGP neighbor\n")
13758{
13759 struct peer *peer;
13760
13761 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13762 if (! peer)
13763 return CMD_WARNING;
13764
13765 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
13766}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013767
13768DEFUN (show_ip_bgp_view_neighbor_received_routes,
13769 show_ip_bgp_view_neighbor_received_routes_cmd,
13770 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
13771 SHOW_STR
13772 IP_STR
13773 BGP_STR
13774 "BGP view\n"
13775 "View name\n"
13776 "Detailed information on TCP and BGP neighbor connections\n"
13777 "Neighbor to display information about\n"
13778 "Neighbor to display information about\n"
13779 "Display the received routes from neighbor\n")
13780{
13781 struct peer *peer;
13782
13783 if (argc == 2)
13784 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13785 else
13786 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13787
13788 if (! peer)
13789 return CMD_WARNING;
13790
13791 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
13792}
13793
13794ALIAS (show_ip_bgp_view_neighbor_received_routes,
13795 show_ip_bgp_neighbor_received_routes_cmd,
13796 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13797 SHOW_STR
13798 IP_STR
13799 BGP_STR
13800 "Detailed information on TCP and BGP neighbor connections\n"
13801 "Neighbor to display information about\n"
13802 "Neighbor to display information about\n"
13803 "Display the received routes from neighbor\n")
13804
13805ALIAS (show_bgp_view_neighbor_received_routes,
13806 show_bgp_ipv6_neighbor_received_routes_cmd,
13807 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
13808 SHOW_STR
13809 BGP_STR
13810 "Address family\n"
13811 "Detailed information on TCP and BGP neighbor connections\n"
13812 "Neighbor to display information about\n"
13813 "Neighbor to display information about\n"
13814 "Display the received routes from neighbor\n")
13815
13816DEFUN (show_bgp_neighbor_received_prefix_filter,
13817 show_bgp_neighbor_received_prefix_filter_cmd,
13818 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13819 SHOW_STR
13820 BGP_STR
13821 "Detailed information on TCP and BGP neighbor connections\n"
13822 "Neighbor to display information about\n"
13823 "Neighbor to display information about\n"
13824 "Display information received from a BGP neighbor\n"
13825 "Display the prefixlist filter\n")
13826{
13827 char name[BUFSIZ];
13828 union sockunion su;
13829 struct peer *peer;
13830 int count, ret;
13831
13832 ret = str2sockunion (argv[0], &su);
13833 if (ret < 0)
13834 {
13835 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13836 return CMD_WARNING;
13837 }
13838
13839 peer = peer_lookup (NULL, &su);
13840 if (! peer)
13841 return CMD_WARNING;
13842
13843 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13844 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13845 if (count)
13846 {
13847 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13848 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13849 }
13850
13851 return CMD_SUCCESS;
13852}
13853
13854/* old command */
13855ALIAS (show_bgp_view_neighbor_received_routes,
13856 ipv6_bgp_neighbor_received_routes_cmd,
13857 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13858 SHOW_STR
13859 IPV6_STR
13860 BGP_STR
13861 "Detailed information on TCP and BGP neighbor connections\n"
13862 "Neighbor to display information about\n"
13863 "Neighbor to display information about\n"
13864 "Display the received routes from neighbor\n")
13865
13866/* old command */
13867DEFUN (ipv6_mbgp_neighbor_received_routes,
13868 ipv6_mbgp_neighbor_received_routes_cmd,
13869 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13870 SHOW_STR
13871 IPV6_STR
13872 MBGP_STR
13873 "Detailed information on TCP and BGP neighbor connections\n"
13874 "Neighbor to display information about\n"
13875 "Neighbor to display information about\n"
13876 "Display the received routes from neighbor\n")
13877{
13878 struct peer *peer;
13879
13880 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13881 if (! peer)
13882 return CMD_WARNING;
13883
13884 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
13885}
13886
13887DEFUN (show_bgp_view_neighbor_received_prefix_filter,
13888 show_bgp_view_neighbor_received_prefix_filter_cmd,
13889 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13890 SHOW_STR
13891 BGP_STR
13892 "BGP view\n"
13893 "View name\n"
13894 "Detailed information on TCP and BGP neighbor connections\n"
13895 "Neighbor to display information about\n"
13896 "Neighbor to display information about\n"
13897 "Display information received from a BGP neighbor\n"
13898 "Display the prefixlist filter\n")
13899{
13900 char name[BUFSIZ];
13901 union sockunion su;
13902 struct peer *peer;
13903 struct bgp *bgp;
13904 int count, ret;
13905
13906 /* BGP structure lookup. */
13907 bgp = bgp_lookup_by_name (argv[0]);
13908 if (bgp == NULL)
13909 {
13910 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13911 return CMD_WARNING;
13912 }
13913
13914 ret = str2sockunion (argv[1], &su);
13915 if (ret < 0)
13916 {
13917 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13918 return CMD_WARNING;
13919 }
13920
13921 peer = peer_lookup (bgp, &su);
13922 if (! peer)
13923 return CMD_WARNING;
13924
13925 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13926 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13927 if (count)
13928 {
13929 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13930 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13931 }
13932
13933 return CMD_SUCCESS;
13934}
13935
13936
13937DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
13938 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
13939 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
13940 SHOW_STR
13941 IP_STR
13942 BGP_STR
13943 "Address family\n"
13944 "Address Family modifier\n"
13945 "Address Family modifier\n"
13946 "Detailed information on TCP and BGP neighbor connections\n"
13947 "Neighbor to display information about\n"
13948 "Neighbor to display information about\n"
13949 "Display the received routes from neighbor\n")
13950{
13951 struct peer *peer;
13952
13953 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13954 if (! peer)
13955 return CMD_WARNING;
13956
13957 if (strncmp (argv[0], "m", 1) == 0)
13958 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
13959
13960 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
13961}
13962
Lou Berger651b4022016-01-12 13:42:07 -050013963DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
13964 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
13965 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013966 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013967 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013968 "Address Family modifier\n"
13969 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013970 "Detailed information on TCP and BGP neighbor connections\n"
13971 "Neighbor to display information about\n"
13972 "Neighbor to display information about\n"
13973 "Display the routes advertised to a BGP neighbor\n")
13974{
13975 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013976 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013977
Lou Berger651b4022016-01-12 13:42:07 -050013978 if (bgp_parse_safi(argv[0], &safi)) {
13979 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010013980 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013981 }
paul718e3742002-12-13 20:15:29 +000013982
paulbb46e942003-10-24 19:02:03 +000013983 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13984 if (! peer)
13985 return CMD_WARNING;
13986
Lou Berger651b4022016-01-12 13:42:07 -050013987 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
13988}
Lou Berger205e6742016-01-12 13:42:11 -050013989
Lou Berger651b4022016-01-12 13:42:07 -050013990DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
13991 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
13992 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13993 SHOW_STR
13994 BGP_STR
13995 "Address Family modifier\n"
13996 "Address Family modifier\n"
13997 "Address Family modifier\n"
13998 "Detailed information on TCP and BGP neighbor connections\n"
13999 "Neighbor to display information about\n"
14000 "Neighbor to display information about\n"
14001 "Display the routes advertised to a BGP neighbor\n")
14002{
14003 struct peer *peer;
14004 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000014005
Lou Berger651b4022016-01-12 13:42:07 -050014006 if (bgp_parse_safi(argv[0], &safi)) {
14007 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14008 return CMD_WARNING;
14009 }
14010
14011 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14012 if (! peer)
14013 return CMD_WARNING;
14014
14015 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000014016}
14017
Lou Bergerf9b6c392016-01-12 13:42:09 -050014018DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050014019 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
14020 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000014021 SHOW_STR
14022 BGP_STR
14023 "BGP view\n"
14024 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014025 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000014026 "Detailed information on TCP and BGP neighbor connections\n"
14027 "Neighbor to display information about\n"
14028 "Neighbor to display information about\n"
14029 "Display the routes advertised to a BGP neighbor\n")
14030{
14031 struct peer *peer;
14032
14033 if (argc == 2)
14034 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14035 else
14036 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14037
14038 if (! peer)
14039 return CMD_WARNING;
14040
14041 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
14042}
14043
Lou Bergerf9b6c392016-01-12 13:42:09 -050014044DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050014045 show_bgp_view_ipv6_neighbor_received_routes_cmd,
14046 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000014047 SHOW_STR
14048 BGP_STR
14049 "BGP view\n"
14050 "View name\n"
14051 "Address family\n"
14052 "Detailed information on TCP and BGP neighbor connections\n"
14053 "Neighbor to display information about\n"
14054 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000014055 "Display the received routes from neighbor\n")
14056{
14057 struct peer *peer;
14058
14059 if (argc == 2)
14060 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14061 else
14062 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14063
14064 if (! peer)
14065 return CMD_WARNING;
14066
14067 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
14068}
Lou Berger651b4022016-01-12 13:42:07 -050014069
14070DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
14071 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
14072 "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 +010014073 SHOW_STR
paul718e3742002-12-13 20:15:29 +000014074 BGP_STR
14075 "Address family\n"
14076 "Address Family modifier\n"
14077 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050014078 "Address Family modifier\n"
14079 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000014080 "Detailed information on TCP and BGP neighbor connections\n"
14081 "Neighbor to display information about\n"
14082 "Neighbor to display information about\n"
14083 "Display the received routes from neighbor\n")
14084{
paulbb46e942003-10-24 19:02:03 +000014085 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050014086 safi_t safi;
14087
14088 if (bgp_parse_safi(argv[0], &safi)) {
14089 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14090 return CMD_WARNING;
14091 }
paul718e3742002-12-13 20:15:29 +000014092
paulbb46e942003-10-24 19:02:03 +000014093 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14094 if (! peer)
14095 return CMD_WARNING;
14096
Lou Berger651b4022016-01-12 13:42:07 -050014097 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000014098}
Lou Berger205e6742016-01-12 13:42:11 -050014099
Lou Berger651b4022016-01-12 13:42:07 -050014100DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
14101 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
14102 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
14103 SHOW_STR
14104 BGP_STR
14105 "Address family\n"
14106 "Address Family modifier\n"
14107 "Address Family modifier\n"
14108 "Address Family modifier\n"
14109 "Address Family modifier\n"
14110 "Detailed information on TCP and BGP neighbor connections\n"
14111 "Neighbor to display information about\n"
14112 "Neighbor to display information about\n"
14113 "Display the received routes from neighbor\n")
14114{
14115 struct peer *peer;
14116 safi_t safi;
14117
14118 if (bgp_parse_safi(argv[0], &safi)) {
14119 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14120 return CMD_WARNING;
14121 }
14122
14123 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14124 if (! peer)
14125 return CMD_WARNING;
14126
14127 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
14128}
paul718e3742002-12-13 20:15:29 +000014129
Michael Lambert95cbbd22010-07-23 14:43:04 -040014130DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
14131 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040014132 "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 -040014133 SHOW_STR
14134 BGP_STR
14135 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014136 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014137 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014138 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014139 "Address family modifier\n"
14140 "Address family modifier\n"
14141 "Detailed information on TCP and BGP neighbor connections\n"
14142 "Neighbor to display information about\n"
14143 "Neighbor to display information about\n"
14144 "Display the advertised routes to neighbor\n"
14145 "Display the received routes from neighbor\n")
14146{
14147 int afi;
14148 int safi;
14149 int in;
14150 struct peer *peer;
14151
David Lamparter94bad672015-03-03 08:52:22 +010014152 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014153
14154 if (! peer)
14155 return CMD_WARNING;
14156
Michael Lambert95cbbd22010-07-23 14:43:04 -040014157 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
14158 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14159 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040014160
14161 return peer_adj_routes (vty, peer, afi, safi, in);
14162}
14163
Lou Bergerf9b6c392016-01-12 13:42:09 -050014164DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
14165 show_ip_bgp_neighbor_received_prefix_filter_cmd,
14166 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
14167 SHOW_STR
14168 IP_STR
14169 BGP_STR
14170 "Detailed information on TCP and BGP neighbor connections\n"
14171 "Neighbor to display information about\n"
14172 "Neighbor to display information about\n"
14173 "Display information received from a BGP neighbor\n"
14174 "Display the prefixlist filter\n")
14175{
14176 char name[BUFSIZ];
14177 union sockunion su;
14178 struct peer *peer;
14179 int count, ret;
14180
14181 ret = str2sockunion (argv[0], &su);
14182 if (ret < 0)
14183 {
14184 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
14185 return CMD_WARNING;
14186 }
14187
14188 peer = peer_lookup (NULL, &su);
14189 if (! peer)
14190 return CMD_WARNING;
14191
14192 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
14193 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
14194 if (count)
14195 {
14196 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
14197 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
14198 }
14199
14200 return CMD_SUCCESS;
14201}
14202
14203DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
14204 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
14205 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
14206 SHOW_STR
14207 IP_STR
14208 BGP_STR
14209 "Address family\n"
14210 "Address Family modifier\n"
14211 "Address Family modifier\n"
14212 "Detailed information on TCP and BGP neighbor connections\n"
14213 "Neighbor to display information about\n"
14214 "Neighbor to display information about\n"
14215 "Display information received from a BGP neighbor\n"
14216 "Display the prefixlist filter\n")
14217{
14218 char name[BUFSIZ];
14219 union sockunion su;
14220 struct peer *peer;
14221 int count, ret;
14222
14223 ret = str2sockunion (argv[1], &su);
14224 if (ret < 0)
14225 {
14226 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
14227 return CMD_WARNING;
14228 }
14229
14230 peer = peer_lookup (NULL, &su);
14231 if (! peer)
14232 return CMD_WARNING;
14233
14234 if (strncmp (argv[0], "m", 1) == 0)
14235 {
14236 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
14237 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
14238 if (count)
14239 {
14240 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
14241 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
14242 }
14243 }
14244 else
14245 {
14246 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
14247 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
14248 if (count)
14249 {
14250 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
14251 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
14252 }
14253 }
14254
14255 return CMD_SUCCESS;
14256}
14257
14258ALIAS (show_bgp_view_neighbor_received_routes,
14259 show_bgp_neighbor_received_routes_cmd,
14260 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
14261 SHOW_STR
14262 BGP_STR
14263 "Detailed information on TCP and BGP neighbor connections\n"
14264 "Neighbor to display information about\n"
14265 "Neighbor to display information about\n"
14266 "Display the received routes from neighbor\n")
14267
Lou Berger651b4022016-01-12 13:42:07 -050014268DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
14269 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
14270 "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 +000014271 SHOW_STR
paul718e3742002-12-13 20:15:29 +000014272 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014273 IP_STR
14274 "Address Family modifier\n"
14275 "Address Family modifier\n"
14276 "Address Family modifier\n"
14277 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000014278 "Detailed information on TCP and BGP neighbor connections\n"
14279 "Neighbor to display information about\n"
14280 "Neighbor to display information about\n"
14281 "Display information received from a BGP neighbor\n"
14282 "Display the prefixlist filter\n")
14283{
14284 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014285 union sockunion su;
paul718e3742002-12-13 20:15:29 +000014286 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014287 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050014288 safi_t safi;
paul718e3742002-12-13 20:15:29 +000014289
Lou Berger651b4022016-01-12 13:42:07 -050014290 if (bgp_parse_safi(argv[0], &safi)) {
14291 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000014292 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050014293 }
paul718e3742002-12-13 20:15:29 +000014294
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014295 ret = str2sockunion (argv[1], &su);
14296 if (ret < 0)
14297 {
14298 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
14299 return CMD_WARNING;
14300 }
paul718e3742002-12-13 20:15:29 +000014301
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014302 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000014303 if (! peer)
14304 return CMD_WARNING;
14305
Lou Berger651b4022016-01-12 13:42:07 -050014306 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
14307 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
14308 if (count) {
14309 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
14310 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
14311 }
paul718e3742002-12-13 20:15:29 +000014312
14313 return CMD_SUCCESS;
14314}
Lou Berger205e6742016-01-12 13:42:11 -050014315
Lou Berger651b4022016-01-12 13:42:07 -050014316DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
14317 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
14318 "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 +000014319 SHOW_STR
14320 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014321 IP_STR
14322 "Address Family modifier\n"
14323 "Address Family modifier\n"
14324 "Address Family modifier\n"
14325 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000014326 "Detailed information on TCP and BGP neighbor connections\n"
14327 "Neighbor to display information about\n"
14328 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050014329 "Display information received from a BGP neighbor\n"
14330 "Display the prefixlist filter\n")
14331{
14332 char name[BUFSIZ];
14333 union sockunion su;
14334 struct peer *peer;
14335 int count, ret;
14336 safi_t safi;
14337
14338 if (bgp_parse_safi(argv[0], &safi)) {
14339 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14340 return CMD_WARNING;
14341 }
14342
14343 ret = str2sockunion (argv[1], &su);
14344 if (ret < 0)
14345 {
14346 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
14347 return CMD_WARNING;
14348 }
14349
14350 peer = peer_lookup (NULL, &su);
14351 if (! peer)
14352 return CMD_WARNING;
14353
14354 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
14355 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
14356 if (count) {
14357 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
14358 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
14359 }
14360
14361 return CMD_SUCCESS;
14362}
paul718e3742002-12-13 20:15:29 +000014363
Lou Bergerf9b6c392016-01-12 13:42:09 -050014364DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050014365 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
14366 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000014367 SHOW_STR
14368 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014369 "Address family\n"
paul718e3742002-12-13 20:15:29 +000014370 "Detailed information on TCP and BGP neighbor connections\n"
14371 "Neighbor to display information about\n"
14372 "Neighbor to display information about\n"
14373 "Display information received from a BGP neighbor\n"
14374 "Display the prefixlist filter\n")
14375{
14376 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014377 union sockunion su;
paul718e3742002-12-13 20:15:29 +000014378 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014379 int count, ret;
paul718e3742002-12-13 20:15:29 +000014380
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014381 ret = str2sockunion (argv[0], &su);
14382 if (ret < 0)
14383 {
14384 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
14385 return CMD_WARNING;
14386 }
paul718e3742002-12-13 20:15:29 +000014387
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014388 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000014389 if (! peer)
14390 return CMD_WARNING;
14391
14392 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
14393 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
14394 if (count)
14395 {
14396 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
14397 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
14398 }
14399
14400 return CMD_SUCCESS;
14401}
14402
Lou Bergerf9b6c392016-01-12 13:42:09 -050014403DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050014404 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
14405 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000014406 SHOW_STR
14407 BGP_STR
14408 "BGP view\n"
14409 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014410 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000014411 "Detailed information on TCP and BGP neighbor connections\n"
14412 "Neighbor to display information about\n"
14413 "Neighbor to display information about\n"
14414 "Display information received from a BGP neighbor\n"
14415 "Display the prefixlist filter\n")
14416{
14417 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014418 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000014419 struct peer *peer;
14420 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014421 int count, ret;
paulbb46e942003-10-24 19:02:03 +000014422
14423 /* BGP structure lookup. */
14424 bgp = bgp_lookup_by_name (argv[0]);
14425 if (bgp == NULL)
14426 {
14427 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14428 return CMD_WARNING;
14429 }
14430
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014431 ret = str2sockunion (argv[1], &su);
14432 if (ret < 0)
14433 {
14434 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
14435 return CMD_WARNING;
14436 }
paulbb46e942003-10-24 19:02:03 +000014437
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020014438 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000014439 if (! peer)
14440 return CMD_WARNING;
14441
14442 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
14443 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
14444 if (count)
14445 {
14446 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
14447 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
14448 }
14449
14450 return CMD_SUCCESS;
14451}
David Lamparter6b0655a2014-06-04 06:53:35 +020014452
paul94f2b392005-06-28 12:44:16 +000014453static int
paulbb46e942003-10-24 19:02:03 +000014454bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000014455 safi_t safi, enum bgp_show_type type)
14456{
paul718e3742002-12-13 20:15:29 +000014457 if (! peer || ! peer->afc[afi][safi])
14458 {
14459 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000014460 return CMD_WARNING;
14461 }
14462
ajs5a646652004-11-05 01:25:55 +000014463 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000014464}
Lou Bergerf9b6c392016-01-12 13:42:09 -050014465DEFUN (show_ip_bgp_neighbor_routes,
14466 show_ip_bgp_neighbor_routes_cmd,
14467 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
14468 SHOW_STR
14469 IP_STR
14470 BGP_STR
14471 "Detailed information on TCP and BGP neighbor connections\n"
14472 "Neighbor to display information about\n"
14473 "Neighbor to display information about\n"
14474 "Display routes learned from neighbor\n")
14475{
14476 struct peer *peer;
14477
14478 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14479 if (! peer)
14480 return CMD_WARNING;
14481
14482 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
14483 bgp_show_type_neighbor);
14484}
14485
14486DEFUN (show_ip_bgp_neighbor_flap,
14487 show_ip_bgp_neighbor_flap_cmd,
14488 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14489 SHOW_STR
14490 IP_STR
14491 BGP_STR
14492 "Detailed information on TCP and BGP neighbor connections\n"
14493 "Neighbor to display information about\n"
14494 "Neighbor to display information about\n"
14495 "Display flap statistics of the routes learned from neighbor\n")
14496{
14497 struct peer *peer;
14498
14499 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14500 if (! peer)
14501 return CMD_WARNING;
14502
14503 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
14504 bgp_show_type_flap_neighbor);
14505}
14506
14507DEFUN (show_ip_bgp_neighbor_damp,
14508 show_ip_bgp_neighbor_damp_cmd,
14509 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14510 SHOW_STR
14511 IP_STR
14512 BGP_STR
14513 "Detailed information on TCP and BGP neighbor connections\n"
14514 "Neighbor to display information about\n"
14515 "Neighbor to display information about\n"
14516 "Display the dampened routes received from neighbor\n")
14517{
14518 struct peer *peer;
14519
14520 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14521 if (! peer)
14522 return CMD_WARNING;
14523
14524 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
14525 bgp_show_type_damp_neighbor);
14526}
14527
14528DEFUN (show_ip_bgp_ipv4_neighbor_routes,
14529 show_ip_bgp_ipv4_neighbor_routes_cmd,
14530 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
14531 SHOW_STR
14532 IP_STR
14533 BGP_STR
14534 "Address family\n"
14535 "Address Family modifier\n"
14536 "Address Family modifier\n"
14537 "Detailed information on TCP and BGP neighbor connections\n"
14538 "Neighbor to display information about\n"
14539 "Neighbor to display information about\n"
14540 "Display routes learned from neighbor\n")
14541{
14542 struct peer *peer;
14543
14544 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14545 if (! peer)
14546 return CMD_WARNING;
14547
14548 if (strncmp (argv[0], "m", 1) == 0)
14549 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
14550 bgp_show_type_neighbor);
14551
14552 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
14553 bgp_show_type_neighbor);
14554}
14555
14556DEFUN (show_ip_bgp_view_rsclient,
14557 show_ip_bgp_view_rsclient_cmd,
14558 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14559 SHOW_STR
14560 IP_STR
14561 BGP_STR
14562 "BGP view\n"
14563 "View name\n"
14564 "Information about Route Server Client\n"
14565 NEIGHBOR_ADDR_STR)
14566{
14567 struct bgp_table *table;
14568 struct peer *peer;
14569
14570 if (argc == 2)
14571 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14572 else
14573 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14574
14575 if (! peer)
14576 return CMD_WARNING;
14577
14578 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14579 {
14580 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14581 VTY_NEWLINE);
14582 return CMD_WARNING;
14583 }
14584
14585 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14586 PEER_FLAG_RSERVER_CLIENT))
14587 {
14588 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14589 VTY_NEWLINE);
14590 return CMD_WARNING;
14591 }
14592
14593 table = peer->rib[AFI_IP][SAFI_UNICAST];
14594
14595 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14596}
14597
14598ALIAS (show_ip_bgp_view_rsclient,
14599 show_ip_bgp_rsclient_cmd,
14600 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
14601 SHOW_STR
14602 IP_STR
14603 BGP_STR
14604 "Information about Route Server Client\n"
14605 NEIGHBOR_ADDR_STR)
14606
14607DEFUN (show_bgp_view_ipv4_safi_rsclient,
14608 show_bgp_view_ipv4_safi_rsclient_cmd,
14609 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14610 SHOW_STR
14611 BGP_STR
14612 "BGP view\n"
14613 "View name\n"
14614 "Address family\n"
14615 "Address Family modifier\n"
14616 "Address Family modifier\n"
14617 "Information about Route Server Client\n"
14618 NEIGHBOR_ADDR_STR)
14619{
14620 struct bgp_table *table;
14621 struct peer *peer;
14622 safi_t safi;
14623
14624 if (argc == 3) {
14625 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14626 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14627 } else {
14628 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14629 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14630 }
14631
14632 if (! peer)
14633 return CMD_WARNING;
14634
14635 if (! peer->afc[AFI_IP][safi])
14636 {
14637 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14638 VTY_NEWLINE);
14639 return CMD_WARNING;
14640 }
14641
14642 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14643 PEER_FLAG_RSERVER_CLIENT))
14644 {
14645 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14646 VTY_NEWLINE);
14647 return CMD_WARNING;
14648 }
14649
14650 table = peer->rib[AFI_IP][safi];
14651
14652 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14653}
14654
14655ALIAS (show_bgp_view_ipv4_safi_rsclient,
14656 show_bgp_ipv4_safi_rsclient_cmd,
14657 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14658 SHOW_STR
14659 BGP_STR
14660 "Address family\n"
14661 "Address Family modifier\n"
14662 "Address Family modifier\n"
14663 "Information about Route Server Client\n"
14664 NEIGHBOR_ADDR_STR)
14665
14666DEFUN (show_ip_bgp_view_rsclient_route,
14667 show_ip_bgp_view_rsclient_route_cmd,
14668 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14669 SHOW_STR
14670 IP_STR
14671 BGP_STR
14672 "BGP view\n"
14673 "View name\n"
14674 "Information about Route Server Client\n"
14675 NEIGHBOR_ADDR_STR
14676 "Network in the BGP routing table to display\n")
14677{
14678 struct bgp *bgp;
14679 struct peer *peer;
14680
14681 /* BGP structure lookup. */
14682 if (argc == 3)
14683 {
14684 bgp = bgp_lookup_by_name (argv[0]);
14685 if (bgp == NULL)
14686 {
14687 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14688 return CMD_WARNING;
14689 }
14690 }
14691 else
14692 {
14693 bgp = bgp_get_default ();
14694 if (bgp == NULL)
14695 {
14696 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14697 return CMD_WARNING;
14698 }
14699 }
14700
14701 if (argc == 3)
14702 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14703 else
14704 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14705
14706 if (! peer)
14707 return CMD_WARNING;
14708
14709 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14710 {
14711 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14712 VTY_NEWLINE);
14713 return CMD_WARNING;
14714}
14715
14716 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14717 PEER_FLAG_RSERVER_CLIENT))
14718 {
14719 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14720 VTY_NEWLINE);
14721 return CMD_WARNING;
14722 }
14723
14724 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
14725 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014726 AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050014727}
14728
14729ALIAS (show_ip_bgp_view_rsclient_route,
14730 show_ip_bgp_rsclient_route_cmd,
14731 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14732 SHOW_STR
14733 IP_STR
14734 BGP_STR
14735 "Information about Route Server Client\n"
14736 NEIGHBOR_ADDR_STR
14737 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000014738
Lou Berger651b4022016-01-12 13:42:07 -050014739DEFUN (show_bgp_ipv4_safi_neighbor_flap,
14740 show_bgp_ipv4_safi_neighbor_flap_cmd,
14741 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000014742 SHOW_STR
paul718e3742002-12-13 20:15:29 +000014743 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014744 "Address Family Modifier\n"
14745 "Address Family Modifier\n"
14746 "Address Family Modifier\n"
14747 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000014748 "Detailed information on TCP and BGP neighbor connections\n"
14749 "Neighbor to display information about\n"
14750 "Neighbor to display information about\n"
14751 "Display flap statistics of the routes learned from neighbor\n")
14752{
paulbb46e942003-10-24 19:02:03 +000014753 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050014754 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000014755
Lou Berger651b4022016-01-12 13:42:07 -050014756 if (bgp_parse_safi(argv[0], &safi)) {
14757 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14758 return CMD_WARNING;
14759 }
14760
14761 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000014762 if (! peer)
14763 return CMD_WARNING;
14764
Lou Berger651b4022016-01-12 13:42:07 -050014765 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000014766 bgp_show_type_flap_neighbor);
14767}
Lou Berger205e6742016-01-12 13:42:11 -050014768
Lou Berger651b4022016-01-12 13:42:07 -050014769DEFUN (show_bgp_ipv6_safi_neighbor_flap,
14770 show_bgp_ipv6_safi_neighbor_flap_cmd,
14771 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000014772 SHOW_STR
paul718e3742002-12-13 20:15:29 +000014773 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014774 "Address Family Modifier\n"
14775 "Address Family Modifier\n"
14776 "Address Family Modifier\n"
14777 "Address Family Modifier\n"
14778 "Detailed information on TCP and BGP neighbor connections\n"
14779 "Neighbor to display information about\n"
14780 "Neighbor to display information about\n"
14781 "Display flap statistics of the routes learned from neighbor\n")
14782{
14783 struct peer *peer;
14784 safi_t safi;
14785
14786 if (bgp_parse_safi(argv[0], &safi)) {
14787 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14788 return CMD_WARNING;
14789 }
14790
14791 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14792 if (! peer)
14793 return CMD_WARNING;
14794
14795 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14796 bgp_show_type_flap_neighbor);
14797}
Lou Berger651b4022016-01-12 13:42:07 -050014798
14799DEFUN (show_bgp_ipv4_safi_neighbor_damp,
14800 show_bgp_ipv4_safi_neighbor_damp_cmd,
14801 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14802 SHOW_STR
14803 BGP_STR
14804 "Address Family Modifier\n"
14805 "Address Family Modifier\n"
14806 "Address Family Modifier\n"
14807 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000014808 "Detailed information on TCP and BGP neighbor connections\n"
14809 "Neighbor to display information about\n"
14810 "Neighbor to display information about\n"
14811 "Display the dampened routes received from neighbor\n")
14812{
paulbb46e942003-10-24 19:02:03 +000014813 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050014814 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000014815
Lou Berger651b4022016-01-12 13:42:07 -050014816 if (bgp_parse_safi(argv[0], &safi)) {
14817 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14818 return CMD_WARNING;
14819 }
14820
14821 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000014822 if (! peer)
14823 return CMD_WARNING;
14824
Lou Berger651b4022016-01-12 13:42:07 -050014825 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000014826 bgp_show_type_damp_neighbor);
14827}
Lou Berger205e6742016-01-12 13:42:11 -050014828
Lou Berger651b4022016-01-12 13:42:07 -050014829DEFUN (show_bgp_ipv6_safi_neighbor_damp,
14830 show_bgp_ipv6_safi_neighbor_damp_cmd,
14831 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000014832 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050014833 BGP_STR
14834 "Address Family Modifier\n"
14835 "Address Family Modifier\n"
14836 "Address Family Modifier\n"
14837 "Address Family Modifier\n"
14838 "Detailed information on TCP and BGP neighbor connections\n"
14839 "Neighbor to display information about\n"
14840 "Neighbor to display information about\n"
14841 "Display the dampened routes received from neighbor\n")
14842{
14843 struct peer *peer;
14844 safi_t safi;
14845
14846 if (bgp_parse_safi(argv[0], &safi)) {
14847 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14848 return CMD_WARNING;
14849 }
14850
14851 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14852 if (! peer)
14853 return CMD_WARNING;
14854
14855 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14856 bgp_show_type_damp_neighbor);
14857}
Lou Berger651b4022016-01-12 13:42:07 -050014858
14859DEFUN (show_bgp_ipv4_safi_neighbor_routes,
14860 show_bgp_ipv4_safi_neighbor_routes_cmd,
14861 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
14862 SHOW_STR
paul718e3742002-12-13 20:15:29 +000014863 BGP_STR
14864 "Address family\n"
14865 "Address Family modifier\n"
14866 "Address Family modifier\n"
14867 "Detailed information on TCP and BGP neighbor connections\n"
14868 "Neighbor to display information about\n"
14869 "Neighbor to display information about\n"
14870 "Display routes learned from neighbor\n")
14871{
paulbb46e942003-10-24 19:02:03 +000014872 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050014873 safi_t safi;
14874
14875 if (bgp_parse_safi(argv[0], &safi)) {
14876 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14877 return CMD_WARNING;
14878 }
paulbb46e942003-10-24 19:02:03 +000014879
14880 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14881 if (! peer)
14882 return CMD_WARNING;
14883
Lou Berger651b4022016-01-12 13:42:07 -050014884 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000014885 bgp_show_type_neighbor);
14886}
Lou Berger205e6742016-01-12 13:42:11 -050014887
Lou Berger651b4022016-01-12 13:42:07 -050014888DEFUN (show_bgp_ipv6_safi_neighbor_routes,
14889 show_bgp_ipv6_safi_neighbor_routes_cmd,
14890 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000014891 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000014892 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014893 "Address family\n"
14894 "Address Family modifier\n"
14895 "Address Family modifier\n"
14896 "Detailed information on TCP and BGP neighbor connections\n"
14897 NEIGHBOR_ADDR_STR
14898 NEIGHBOR_ADDR_STR
14899 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014900{
paulfee0f4c2004-09-13 05:12:46 +000014901 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050014902 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000014903
Lou Berger651b4022016-01-12 13:42:07 -050014904 if (bgp_parse_safi(argv[0], &safi)) {
14905 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14906 return CMD_WARNING;
14907 }
paulfee0f4c2004-09-13 05:12:46 +000014908
Lou Berger651b4022016-01-12 13:42:07 -050014909 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000014910 if (! peer)
14911 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050014912
14913 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14914 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000014915}
paulfee0f4c2004-09-13 05:12:46 +000014916
Michael Lambert95cbbd22010-07-23 14:43:04 -040014917DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
14918 show_bgp_view_ipv4_safi_rsclient_route_cmd,
14919 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14920 SHOW_STR
14921 BGP_STR
14922 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014923 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014924 "Address family\n"
14925 "Address Family modifier\n"
14926 "Address Family modifier\n"
14927 "Information about Route Server Client\n"
14928 NEIGHBOR_ADDR_STR
14929 "Network in the BGP routing table to display\n")
14930{
14931 struct bgp *bgp;
14932 struct peer *peer;
14933 safi_t safi;
14934
14935 /* BGP structure lookup. */
14936 if (argc == 4)
14937 {
14938 bgp = bgp_lookup_by_name (argv[0]);
14939 if (bgp == NULL)
14940 {
14941 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14942 return CMD_WARNING;
14943 }
14944 }
14945 else
14946 {
14947 bgp = bgp_get_default ();
14948 if (bgp == NULL)
14949 {
14950 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14951 return CMD_WARNING;
14952 }
14953 }
14954
14955 if (argc == 4) {
14956 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14957 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14958 } else {
14959 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14960 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14961 }
14962
14963 if (! peer)
14964 return CMD_WARNING;
14965
14966 if (! peer->afc[AFI_IP][safi])
14967 {
14968 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14969 VTY_NEWLINE);
14970 return CMD_WARNING;
14971}
14972
14973 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14974 PEER_FLAG_RSERVER_CLIENT))
14975 {
14976 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14977 VTY_NEWLINE);
14978 return CMD_WARNING;
14979 }
14980
14981 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
14982 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070014983 AFI_IP, safi, NULL, 0, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040014984}
14985
14986ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
14987 show_bgp_ipv4_safi_rsclient_route_cmd,
14988 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14989 SHOW_STR
14990 BGP_STR
14991 "Address family\n"
14992 "Address Family modifier\n"
14993 "Address Family modifier\n"
14994 "Information about Route Server Client\n"
14995 NEIGHBOR_ADDR_STR
14996 "Network in the BGP routing table to display\n")
14997
paulfee0f4c2004-09-13 05:12:46 +000014998
Michael Lambert95cbbd22010-07-23 14:43:04 -040014999DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
15000 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
15001 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
15002 SHOW_STR
15003 BGP_STR
15004 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015005 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040015006 "Address family\n"
15007 "Address Family modifier\n"
15008 "Address Family modifier\n"
15009 "Information about Route Server Client\n"
15010 NEIGHBOR_ADDR_STR
15011 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15012{
15013 struct bgp *bgp;
15014 struct peer *peer;
15015 safi_t safi;
15016
15017 /* BGP structure lookup. */
15018 if (argc == 4)
15019 {
15020 bgp = bgp_lookup_by_name (argv[0]);
15021 if (bgp == NULL)
15022 {
15023 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15024 return CMD_WARNING;
15025 }
15026 }
15027 else
15028 {
15029 bgp = bgp_get_default ();
15030 if (bgp == NULL)
15031 {
15032 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15033 return CMD_WARNING;
15034 }
15035 }
15036
15037 if (argc == 4) {
15038 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15039 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15040 } else {
15041 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15042 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15043 }
15044
15045 if (! peer)
15046 return CMD_WARNING;
15047
15048 if (! peer->afc[AFI_IP][safi])
15049 {
15050 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15051 VTY_NEWLINE);
15052 return CMD_WARNING;
15053}
15054
15055 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
15056 PEER_FLAG_RSERVER_CLIENT))
15057{
15058 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15059 VTY_NEWLINE);
15060 return CMD_WARNING;
15061 }
15062
15063 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
15064 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015065 AFI_IP, safi, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015066}
15067
Lou Bergerf9b6c392016-01-12 13:42:09 -050015068DEFUN (show_ip_bgp_view_rsclient_prefix,
15069 show_ip_bgp_view_rsclient_prefix_cmd,
15070 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
15071 SHOW_STR
15072 IP_STR
15073 BGP_STR
15074 "BGP view\n"
15075 "View name\n"
15076 "Information about Route Server Client\n"
15077 NEIGHBOR_ADDR_STR
15078 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15079{
15080 struct bgp *bgp;
15081 struct peer *peer;
15082
15083 /* BGP structure lookup. */
15084 if (argc == 3)
15085 {
15086 bgp = bgp_lookup_by_name (argv[0]);
15087 if (bgp == NULL)
15088 {
15089 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15090 return CMD_WARNING;
15091 }
15092 }
15093 else
15094 {
15095 bgp = bgp_get_default ();
15096 if (bgp == NULL)
15097 {
15098 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15099 return CMD_WARNING;
15100 }
15101 }
15102
15103 if (argc == 3)
15104 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15105 else
15106 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15107
15108 if (! peer)
15109 return CMD_WARNING;
15110
15111 if (! peer->afc[AFI_IP][SAFI_UNICAST])
15112 {
15113 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15114 VTY_NEWLINE);
15115 return CMD_WARNING;
15116}
15117
15118 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
15119 PEER_FLAG_RSERVER_CLIENT))
15120{
15121 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15122 VTY_NEWLINE);
15123 return CMD_WARNING;
15124 }
15125
15126 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
15127 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015128 AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050015129}
15130
15131ALIAS (show_ip_bgp_view_rsclient_prefix,
15132 show_ip_bgp_rsclient_prefix_cmd,
15133 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
15134 SHOW_STR
15135 IP_STR
15136 BGP_STR
15137 "Information about Route Server Client\n"
15138 NEIGHBOR_ADDR_STR
15139 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15140
Michael Lambert95cbbd22010-07-23 14:43:04 -040015141ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
15142 show_bgp_ipv4_safi_rsclient_prefix_cmd,
15143 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
15144 SHOW_STR
15145 BGP_STR
15146 "Address family\n"
15147 "Address Family modifier\n"
15148 "Address Family modifier\n"
15149 "Information about Route Server Client\n"
15150 NEIGHBOR_ADDR_STR
15151 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000015152
Lou Bergerf9b6c392016-01-12 13:42:09 -050015153DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050015154 show_bgp_view_ipv6_neighbor_routes_cmd,
15155 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000015156 SHOW_STR
15157 BGP_STR
15158 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015159 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050015160 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000015161 "Detailed information on TCP and BGP neighbor connections\n"
15162 "Neighbor to display information about\n"
15163 "Neighbor to display information about\n"
15164 "Display routes learned from neighbor\n")
15165{
15166 struct peer *peer;
15167
15168 if (argc == 2)
15169 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15170 else
15171 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15172
15173 if (! peer)
15174 return CMD_WARNING;
15175
15176 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15177 bgp_show_type_neighbor);
15178}
15179
Lou Berger651b4022016-01-12 13:42:07 -050015180DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050015181 show_bgp_view_neighbor_damp_cmd,
15182 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
15183 SHOW_STR
15184 BGP_STR
15185 "BGP view\n"
15186 "View name\n"
15187 "Detailed information on TCP and BGP neighbor connections\n"
15188 "Neighbor to display information about\n"
15189 "Neighbor to display information about\n"
15190 "Display the dampened routes received from neighbor\n")
15191{
15192 struct peer *peer;
15193
15194 if (argc == 2)
15195 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15196 else
15197 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15198
15199 if (! peer)
15200 return CMD_WARNING;
15201
15202 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15203 bgp_show_type_damp_neighbor);
15204}
15205
15206DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050015207 show_bgp_view_ipv6_neighbor_damp_cmd,
15208 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000015209 SHOW_STR
15210 BGP_STR
15211 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015212 "View name\n"
paulbb46e942003-10-24 19:02:03 +000015213 "Address family\n"
15214 "Detailed information on TCP and BGP neighbor connections\n"
15215 "Neighbor to display information about\n"
15216 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000015217 "Display the dampened routes received from neighbor\n")
15218{
15219 struct peer *peer;
15220
15221 if (argc == 2)
15222 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15223 else
15224 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15225
15226 if (! peer)
15227 return CMD_WARNING;
15228
15229 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15230 bgp_show_type_damp_neighbor);
15231}
15232
Lou Bergerf9b6c392016-01-12 13:42:09 -050015233DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050015234 show_bgp_view_ipv6_neighbor_flap_cmd,
15235 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000015236 SHOW_STR
15237 BGP_STR
15238 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015239 "View name\n"
paulbb46e942003-10-24 19:02:03 +000015240 "Address family\n"
15241 "Detailed information on TCP and BGP neighbor connections\n"
15242 "Neighbor to display information about\n"
15243 "Neighbor to display information about\n"
15244 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000015245{
15246 struct peer *peer;
15247
15248 if (argc == 2)
15249 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15250 else
15251 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15252
15253 if (! peer)
15254 return CMD_WARNING;
15255
15256 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15257 bgp_show_type_flap_neighbor);
15258}
15259
Lou Bergerf9b6c392016-01-12 13:42:09 -050015260DEFUN (show_bgp_view_neighbor_flap,
15261 show_bgp_view_neighbor_flap_cmd,
15262 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
15263 SHOW_STR
15264 BGP_STR
15265 "BGP view\n"
15266 "View name\n"
15267 "Detailed information on TCP and BGP neighbor connections\n"
15268 "Neighbor to display information about\n"
15269 "Neighbor to display information about\n"
15270 "Display flap statistics of the routes learned from neighbor\n")
15271{
15272 struct peer *peer;
15273
15274 if (argc == 2)
15275 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15276 else
15277 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15278
15279 if (! peer)
15280 return CMD_WARNING;
15281
15282 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15283 bgp_show_type_flap_neighbor);
15284}
15285
15286ALIAS (show_bgp_view_neighbor_flap,
15287 show_bgp_neighbor_flap_cmd,
15288 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
15289 SHOW_STR
15290 BGP_STR
15291 "Detailed information on TCP and BGP neighbor connections\n"
15292 "Neighbor to display information about\n"
15293 "Neighbor to display information about\n"
15294 "Display flap statistics of the routes learned from neighbor\n")
15295
15296ALIAS (show_bgp_view_neighbor_damp,
15297 show_bgp_neighbor_damp_cmd,
15298 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
15299 SHOW_STR
15300 BGP_STR
15301 "Detailed information on TCP and BGP neighbor connections\n"
15302 "Neighbor to display information about\n"
15303 "Neighbor to display information about\n"
15304 "Display the dampened routes received from neighbor\n")
15305
15306DEFUN (show_bgp_view_neighbor_routes,
15307 show_bgp_view_neighbor_routes_cmd,
15308 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
15309 SHOW_STR
15310 BGP_STR
15311 "BGP view\n"
15312 "View name\n"
15313 "Detailed information on TCP and BGP neighbor connections\n"
15314 "Neighbor to display information about\n"
15315 "Neighbor to display information about\n"
15316 "Display routes learned from neighbor\n")
15317{
15318 struct peer *peer;
15319
15320 if (argc == 2)
15321 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15322 else
15323 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15324
15325 if (! peer)
15326 return CMD_WARNING;
15327
15328 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15329 bgp_show_type_neighbor);
15330}
15331
15332ALIAS (show_bgp_view_neighbor_routes,
15333 show_bgp_neighbor_routes_cmd,
15334 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
15335 SHOW_STR
15336 BGP_STR
15337 "Detailed information on TCP and BGP neighbor connections\n"
15338 "Neighbor to display information about\n"
15339 "Neighbor to display information about\n"
15340 "Display routes learned from neighbor\n")
15341
paulbb46e942003-10-24 19:02:03 +000015342ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000015343 show_bgp_ipv6_neighbor_routes_cmd,
15344 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
15345 SHOW_STR
15346 BGP_STR
15347 "Address family\n"
15348 "Detailed information on TCP and BGP neighbor connections\n"
15349 "Neighbor to display information about\n"
15350 "Neighbor to display information about\n"
15351 "Display routes learned from neighbor\n")
15352
Lou Bergerf9b6c392016-01-12 13:42:09 -050015353/* old command */
15354ALIAS (show_bgp_view_neighbor_routes,
15355 ipv6_bgp_neighbor_routes_cmd,
15356 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
15357 SHOW_STR
15358 IPV6_STR
15359 BGP_STR
15360 "Detailed information on TCP and BGP neighbor connections\n"
15361 "Neighbor to display information about\n"
15362 "Neighbor to display information about\n"
15363 "Display routes learned from neighbor\n")
15364
15365/* old command */
15366DEFUN (ipv6_mbgp_neighbor_routes,
15367 ipv6_mbgp_neighbor_routes_cmd,
15368 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
15369 SHOW_STR
15370 IPV6_STR
15371 MBGP_STR
15372 "Detailed information on TCP and BGP neighbor connections\n"
15373 "Neighbor to display information about\n"
15374 "Neighbor to display information about\n"
15375 "Display routes learned from neighbor\n")
15376{
15377 struct peer *peer;
15378
15379 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15380 if (! peer)
15381 return CMD_WARNING;
15382
15383 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
15384 bgp_show_type_neighbor);
15385}
15386
paulbb46e942003-10-24 19:02:03 +000015387ALIAS (show_bgp_view_neighbor_flap,
15388 show_bgp_ipv6_neighbor_flap_cmd,
15389 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
15390 SHOW_STR
15391 BGP_STR
15392 "Address family\n"
15393 "Detailed information on TCP and BGP neighbor connections\n"
15394 "Neighbor to display information about\n"
15395 "Neighbor to display information about\n"
15396 "Display flap statistics of the routes learned from neighbor\n")
15397
15398ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000015399 show_bgp_ipv6_neighbor_damp_cmd,
15400 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
15401 SHOW_STR
15402 BGP_STR
15403 "Address family\n"
15404 "Detailed information on TCP and BGP neighbor connections\n"
15405 "Neighbor to display information about\n"
15406 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000015407 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000015408
Lou Bergerf9b6c392016-01-12 13:42:09 -050015409DEFUN (show_bgp_view_rsclient,
15410 show_bgp_view_rsclient_cmd,
15411 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
15412 SHOW_STR
15413 BGP_STR
15414 "BGP view\n"
15415 "View name\n"
15416 "Information about Route Server Client\n"
15417 NEIGHBOR_ADDR_STR)
15418{
15419 struct bgp_table *table;
15420 struct peer *peer;
15421
15422 if (argc == 2)
15423 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15424 else
15425 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15426
15427 if (! peer)
15428 return CMD_WARNING;
15429
15430 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15431 {
15432 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15433 VTY_NEWLINE);
15434 return CMD_WARNING;
15435 }
15436
15437 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15438 PEER_FLAG_RSERVER_CLIENT))
15439 {
15440 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15441 VTY_NEWLINE);
15442 return CMD_WARNING;
15443 }
15444
15445 table = peer->rib[AFI_IP6][SAFI_UNICAST];
15446
15447 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
15448}
15449
15450ALIAS (show_bgp_view_rsclient,
15451 show_bgp_rsclient_cmd,
15452 "show bgp rsclient (A.B.C.D|X:X::X:X)",
15453 SHOW_STR
15454 BGP_STR
15455 "Information about Route Server Client\n"
15456 NEIGHBOR_ADDR_STR)
15457
Lou Berger651b4022016-01-12 13:42:07 -050015458DEFUN (show_bgp_view_ipv4_rsclient,
15459 show_bgp_view_ipv4_rsclient_cmd,
15460 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000015461 SHOW_STR
15462 BGP_STR
15463 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015464 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050015465 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000015466 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050015467 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000015468{
Lou Berger651b4022016-01-12 13:42:07 -050015469 struct bgp_table *table;
15470 struct peer *peer;
15471
15472 if (argc == 2)
15473 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15474 else
15475 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15476
15477 if (! peer)
15478 return CMD_WARNING;
15479
15480 if (! peer->afc[AFI_IP][SAFI_UNICAST])
15481 {
15482 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15483 VTY_NEWLINE);
15484 return CMD_WARNING;
15485 }
15486
15487 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
15488 PEER_FLAG_RSERVER_CLIENT))
15489 {
15490 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15491 VTY_NEWLINE);
15492 return CMD_WARNING;
15493 }
15494
15495 table = peer->rib[AFI_IP][SAFI_UNICAST];
15496
15497 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
15498}
15499DEFUN (show_bgp_view_ipv6_rsclient,
15500 show_bgp_view_ipv6_rsclient_cmd,
15501 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
15502 SHOW_STR
15503 BGP_STR
15504 "BGP view\n"
15505 "BGP view name\n"
15506 "Address Family\n"
15507 "Information about Route Server Client\n"
15508 NEIGHBOR_ADDR_STR2)
15509{
15510 struct bgp_table *table;
15511 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000015512
15513 if (argc == 2)
15514 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15515 else
15516 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15517
15518 if (! peer)
15519 return CMD_WARNING;
15520
15521 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15522 {
15523 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15524 VTY_NEWLINE);
15525 return CMD_WARNING;
15526 }
15527
15528 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15529 PEER_FLAG_RSERVER_CLIENT))
15530 {
15531 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15532 VTY_NEWLINE);
15533 return CMD_WARNING;
15534 }
15535
15536 table = peer->rib[AFI_IP6][SAFI_UNICAST];
15537
ajs5a646652004-11-05 01:25:55 +000015538 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000015539}
15540
Lou Berger651b4022016-01-12 13:42:07 -050015541ALIAS (show_bgp_view_ipv4_rsclient,
15542 show_bgp_ipv4_rsclient_cmd,
15543 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000015544 SHOW_STR
15545 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015546 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000015547 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050015548 NEIGHBOR_ADDR_STR2)
15549
Lou Berger651b4022016-01-12 13:42:07 -050015550ALIAS (show_bgp_view_ipv6_rsclient,
15551 show_bgp_ipv6_rsclient_cmd,
15552 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
15553 SHOW_STR
15554 BGP_STR
15555 "Address Family\n"
15556 "Information about Route Server Client\n"
15557 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000015558
Michael Lambert95cbbd22010-07-23 14:43:04 -040015559DEFUN (show_bgp_view_ipv6_safi_rsclient,
15560 show_bgp_view_ipv6_safi_rsclient_cmd,
15561 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
15562 SHOW_STR
15563 BGP_STR
15564 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015565 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040015566 "Address family\n"
15567 "Address Family modifier\n"
15568 "Address Family modifier\n"
15569 "Information about Route Server Client\n"
15570 NEIGHBOR_ADDR_STR)
15571{
15572 struct bgp_table *table;
15573 struct peer *peer;
15574 safi_t safi;
15575
15576 if (argc == 3) {
15577 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15578 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15579 } else {
15580 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15581 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15582 }
15583
15584 if (! peer)
15585 return CMD_WARNING;
15586
15587 if (! peer->afc[AFI_IP6][safi])
15588 {
15589 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15590 VTY_NEWLINE);
15591 return CMD_WARNING;
15592 }
15593
15594 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
15595 PEER_FLAG_RSERVER_CLIENT))
15596 {
15597 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15598 VTY_NEWLINE);
15599 return CMD_WARNING;
15600 }
15601
15602 table = peer->rib[AFI_IP6][safi];
15603
15604 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
15605}
15606
15607ALIAS (show_bgp_view_ipv6_safi_rsclient,
15608 show_bgp_ipv6_safi_rsclient_cmd,
15609 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
15610 SHOW_STR
15611 BGP_STR
15612 "Address family\n"
15613 "Address Family modifier\n"
15614 "Address Family modifier\n"
15615 "Information about Route Server Client\n"
15616 NEIGHBOR_ADDR_STR)
15617
paulfee0f4c2004-09-13 05:12:46 +000015618DEFUN (show_bgp_view_rsclient_route,
15619 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050015620 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15621 SHOW_STR
15622 BGP_STR
15623 "BGP view\n"
15624 "View name\n"
15625 "Information about Route Server Client\n"
15626 NEIGHBOR_ADDR_STR
15627 "Network in the BGP routing table to display\n")
15628{
15629 struct bgp *bgp;
15630 struct peer *peer;
15631
15632 /* BGP structure lookup. */
15633 if (argc == 3)
15634 {
15635 bgp = bgp_lookup_by_name (argv[0]);
15636 if (bgp == NULL)
15637 {
15638 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15639 return CMD_WARNING;
15640 }
15641 }
15642 else
15643 {
15644 bgp = bgp_get_default ();
15645 if (bgp == NULL)
15646 {
15647 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15648 return CMD_WARNING;
15649 }
15650 }
15651
15652 if (argc == 3)
15653 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15654 else
15655 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15656
15657 if (! peer)
15658 return CMD_WARNING;
15659
15660 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15661 {
15662 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15663 VTY_NEWLINE);
15664 return CMD_WARNING;
15665 }
15666
15667 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15668 PEER_FLAG_RSERVER_CLIENT))
15669 {
15670 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15671 VTY_NEWLINE);
15672 return CMD_WARNING;
15673 }
15674
15675 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15676 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015677 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050015678}
15679
15680DEFUN (show_bgp_view_ipv6_rsclient_route,
15681 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015682 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000015683 SHOW_STR
15684 BGP_STR
15685 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050015686 "BGP view name\n"
15687 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000015688 "Information about Route Server Client\n"
15689 NEIGHBOR_ADDR_STR
15690 "Network in the BGP routing table to display\n")
15691{
15692 struct bgp *bgp;
15693 struct peer *peer;
15694
15695 /* BGP structure lookup. */
15696 if (argc == 3)
15697 {
15698 bgp = bgp_lookup_by_name (argv[0]);
15699 if (bgp == NULL)
15700 {
15701 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15702 return CMD_WARNING;
15703 }
15704 }
15705 else
15706 {
15707 bgp = bgp_get_default ();
15708 if (bgp == NULL)
15709 {
15710 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15711 return CMD_WARNING;
15712 }
15713 }
15714
15715 if (argc == 3)
15716 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15717 else
15718 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15719
15720 if (! peer)
15721 return CMD_WARNING;
15722
15723 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15724 {
15725 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15726 VTY_NEWLINE);
15727 return CMD_WARNING;
15728 }
15729
15730 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15731 PEER_FLAG_RSERVER_CLIENT))
15732 {
15733 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15734 VTY_NEWLINE);
15735 return CMD_WARNING;
15736 }
15737
15738 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15739 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015740 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
paulfee0f4c2004-09-13 05:12:46 +000015741}
15742
Lou Bergerf9b6c392016-01-12 13:42:09 -050015743ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000015744 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050015745 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15746 SHOW_STR
15747 BGP_STR
15748 "Information about Route Server Client\n"
15749 NEIGHBOR_ADDR_STR
15750 "Network in the BGP routing table to display\n")
15751
15752ALIAS (show_bgp_view_ipv6_rsclient_route,
15753 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015754 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000015755 SHOW_STR
15756 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015757 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000015758 "Information about Route Server Client\n"
15759 NEIGHBOR_ADDR_STR
15760 "Network in the BGP routing table to display\n")
15761
Michael Lambert95cbbd22010-07-23 14:43:04 -040015762DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
15763 show_bgp_view_ipv6_safi_rsclient_route_cmd,
15764 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15765 SHOW_STR
15766 BGP_STR
15767 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015768 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040015769 "Address family\n"
15770 "Address Family modifier\n"
15771 "Address Family modifier\n"
15772 "Information about Route Server Client\n"
15773 NEIGHBOR_ADDR_STR
15774 "Network in the BGP routing table to display\n")
15775{
15776 struct bgp *bgp;
15777 struct peer *peer;
15778 safi_t safi;
15779
15780 /* BGP structure lookup. */
15781 if (argc == 4)
15782 {
15783 bgp = bgp_lookup_by_name (argv[0]);
15784 if (bgp == NULL)
15785 {
15786 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15787 return CMD_WARNING;
15788 }
15789 }
15790 else
15791 {
15792 bgp = bgp_get_default ();
15793 if (bgp == NULL)
15794 {
15795 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15796 return CMD_WARNING;
15797 }
15798 }
15799
15800 if (argc == 4) {
15801 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15802 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15803 } else {
15804 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15805 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15806 }
15807
15808 if (! peer)
15809 return CMD_WARNING;
15810
15811 if (! peer->afc[AFI_IP6][safi])
15812 {
15813 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15814 VTY_NEWLINE);
15815 return CMD_WARNING;
15816}
15817
15818 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
15819 PEER_FLAG_RSERVER_CLIENT))
15820 {
15821 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15822 VTY_NEWLINE);
15823 return CMD_WARNING;
15824 }
15825
15826 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
15827 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015828 AFI_IP6, safi, NULL, 0, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015829}
15830
15831ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
15832 show_bgp_ipv6_safi_rsclient_route_cmd,
15833 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15834 SHOW_STR
15835 BGP_STR
15836 "Address family\n"
15837 "Address Family modifier\n"
15838 "Address Family modifier\n"
15839 "Information about Route Server Client\n"
15840 NEIGHBOR_ADDR_STR
15841 "Network in the BGP routing table to display\n")
15842
Lou Berger651b4022016-01-12 13:42:07 -050015843
paulfee0f4c2004-09-13 05:12:46 +000015844DEFUN (show_bgp_view_rsclient_prefix,
15845 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050015846 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15847 SHOW_STR
15848 BGP_STR
15849 "BGP view\n"
15850 "View name\n"
15851 "Information about Route Server Client\n"
15852 NEIGHBOR_ADDR_STR
15853 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15854{
15855 struct bgp *bgp;
15856 struct peer *peer;
15857
15858 /* BGP structure lookup. */
15859 if (argc == 3)
15860 {
15861 bgp = bgp_lookup_by_name (argv[0]);
15862 if (bgp == NULL)
15863 {
15864 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15865 return CMD_WARNING;
15866 }
15867 }
15868 else
15869 {
15870 bgp = bgp_get_default ();
15871 if (bgp == NULL)
15872 {
15873 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15874 return CMD_WARNING;
15875 }
15876 }
15877
15878 if (argc == 3)
15879 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15880 else
15881 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15882
15883 if (! peer)
15884 return CMD_WARNING;
15885
15886 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15887 {
15888 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15889 VTY_NEWLINE);
15890 return CMD_WARNING;
15891 }
15892
15893 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15894 PEER_FLAG_RSERVER_CLIENT))
15895 {
15896 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15897 VTY_NEWLINE);
15898 return CMD_WARNING;
15899 }
15900
15901 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15902 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015903 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
Lou Bergerf9b6c392016-01-12 13:42:09 -050015904}
15905
15906DEFUN (show_bgp_view_ipv6_rsclient_prefix,
15907 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015908 "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 +000015909 SHOW_STR
15910 BGP_STR
15911 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015912 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050015913 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000015914 "Information about Route Server Client\n"
15915 NEIGHBOR_ADDR_STR
15916 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15917{
15918 struct bgp *bgp;
15919 struct peer *peer;
15920
15921 /* BGP structure lookup. */
15922 if (argc == 3)
15923 {
15924 bgp = bgp_lookup_by_name (argv[0]);
15925 if (bgp == NULL)
15926 {
15927 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15928 return CMD_WARNING;
15929 }
15930 }
15931 else
15932 {
15933 bgp = bgp_get_default ();
15934 if (bgp == NULL)
15935 {
15936 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15937 return CMD_WARNING;
15938 }
15939 }
15940
15941 if (argc == 3)
15942 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15943 else
15944 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15945
15946 if (! peer)
15947 return CMD_WARNING;
15948
15949 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15950 {
15951 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15952 VTY_NEWLINE);
15953 return CMD_WARNING;
15954 }
15955
15956 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15957 PEER_FLAG_RSERVER_CLIENT))
15958 {
15959 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15960 VTY_NEWLINE);
15961 return CMD_WARNING;
15962 }
15963
15964 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15965 (argc == 3) ? argv[2] : argv[1],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070015966 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
paulfee0f4c2004-09-13 05:12:46 +000015967}
15968
Lou Bergerf9b6c392016-01-12 13:42:09 -050015969ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000015970 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050015971 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15972 SHOW_STR
15973 BGP_STR
15974 "Information about Route Server Client\n"
15975 NEIGHBOR_ADDR_STR
15976 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15977
15978ALIAS (show_bgp_view_ipv6_rsclient_prefix,
15979 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050015980 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000015981 SHOW_STR
15982 BGP_STR
15983 "Information about Route Server Client\n"
15984 NEIGHBOR_ADDR_STR
15985 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15986
Michael Lambert95cbbd22010-07-23 14:43:04 -040015987DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
15988 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
15989 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15990 SHOW_STR
15991 BGP_STR
15992 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000015993 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040015994 "Address family\n"
15995 "Address Family modifier\n"
15996 "Address Family modifier\n"
15997 "Information about Route Server Client\n"
15998 NEIGHBOR_ADDR_STR
15999 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
16000{
16001 struct bgp *bgp;
16002 struct peer *peer;
16003 safi_t safi;
16004
16005 /* BGP structure lookup. */
16006 if (argc == 4)
16007 {
16008 bgp = bgp_lookup_by_name (argv[0]);
16009 if (bgp == NULL)
16010 {
16011 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
16012 return CMD_WARNING;
16013 }
16014 }
16015 else
16016 {
16017 bgp = bgp_get_default ();
16018 if (bgp == NULL)
16019 {
16020 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
16021 return CMD_WARNING;
16022 }
16023 }
16024
16025 if (argc == 4) {
16026 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
16027 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
16028 } else {
16029 peer = peer_lookup_in_view (vty, NULL, argv[1]);
16030 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
16031 }
16032
16033 if (! peer)
16034 return CMD_WARNING;
16035
16036 if (! peer->afc[AFI_IP6][safi])
16037 {
16038 vty_out (vty, "%% Activate the neighbor for the address family first%s",
16039 VTY_NEWLINE);
16040 return CMD_WARNING;
16041}
16042
16043 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
16044 PEER_FLAG_RSERVER_CLIENT))
16045{
16046 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
16047 VTY_NEWLINE);
16048 return CMD_WARNING;
16049 }
16050
16051 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
16052 (argc == 4) ? argv[3] : argv[2],
Daniel Walton59fe0ee2015-05-19 17:58:11 -070016053 AFI_IP6, safi, NULL, 1, BGP_PATH_ALL);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016054}
16055
16056ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
16057 show_bgp_ipv6_safi_rsclient_prefix_cmd,
16058 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
16059 SHOW_STR
16060 BGP_STR
16061 "Address family\n"
16062 "Address Family modifier\n"
16063 "Address Family modifier\n"
16064 "Information about Route Server Client\n"
16065 NEIGHBOR_ADDR_STR
16066 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
16067
paul718e3742002-12-13 20:15:29 +000016068struct bgp_table *bgp_distance_table;
16069
16070struct bgp_distance
16071{
16072 /* Distance value for the IP source prefix. */
16073 u_char distance;
16074
16075 /* Name of the access-list to be matched. */
16076 char *access_list;
16077};
16078
paul94f2b392005-06-28 12:44:16 +000016079static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080016080bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000016081{
Stephen Hemminger393deb92008-08-18 14:13:29 -070016082 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000016083}
16084
paul94f2b392005-06-28 12:44:16 +000016085static void
paul718e3742002-12-13 20:15:29 +000016086bgp_distance_free (struct bgp_distance *bdistance)
16087{
16088 XFREE (MTYPE_BGP_DISTANCE, bdistance);
16089}
16090
paul94f2b392005-06-28 12:44:16 +000016091static int
paulfd79ac92004-10-13 05:06:08 +000016092bgp_distance_set (struct vty *vty, const char *distance_str,
16093 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000016094{
16095 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016096 struct prefix p;
paul718e3742002-12-13 20:15:29 +000016097 u_char distance;
16098 struct bgp_node *rn;
16099 struct bgp_distance *bdistance;
16100
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016101 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000016102 if (ret == 0)
16103 {
16104 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
16105 return CMD_WARNING;
16106 }
16107
16108 distance = atoi (distance_str);
16109
16110 /* Get BGP distance node. */
16111 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
16112 if (rn->info)
16113 {
16114 bdistance = rn->info;
16115 bgp_unlock_node (rn);
16116 }
16117 else
16118 {
16119 bdistance = bgp_distance_new ();
16120 rn->info = bdistance;
16121 }
16122
16123 /* Set distance value. */
16124 bdistance->distance = distance;
16125
16126 /* Reset access-list configuration. */
16127 if (bdistance->access_list)
16128 {
16129 free (bdistance->access_list);
16130 bdistance->access_list = NULL;
16131 }
16132 if (access_list_str)
16133 bdistance->access_list = strdup (access_list_str);
16134
16135 return CMD_SUCCESS;
16136}
16137
paul94f2b392005-06-28 12:44:16 +000016138static int
paulfd79ac92004-10-13 05:06:08 +000016139bgp_distance_unset (struct vty *vty, const char *distance_str,
16140 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000016141{
16142 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016143 struct prefix p;
paul718e3742002-12-13 20:15:29 +000016144 u_char distance;
16145 struct bgp_node *rn;
16146 struct bgp_distance *bdistance;
16147
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016148 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000016149 if (ret == 0)
16150 {
16151 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
16152 return CMD_WARNING;
16153 }
16154
16155 distance = atoi (distance_str);
16156
16157 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
16158 if (! rn)
16159 {
16160 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
16161 return CMD_WARNING;
16162 }
16163
16164 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010016165
16166 if (bdistance->distance != distance)
16167 {
16168 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
16169 return CMD_WARNING;
16170 }
16171
paul718e3742002-12-13 20:15:29 +000016172 if (bdistance->access_list)
16173 free (bdistance->access_list);
16174 bgp_distance_free (bdistance);
16175
16176 rn->info = NULL;
16177 bgp_unlock_node (rn);
16178 bgp_unlock_node (rn);
16179
16180 return CMD_SUCCESS;
16181}
16182
paul718e3742002-12-13 20:15:29 +000016183/* Apply BGP information to distance method. */
16184u_char
16185bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
16186{
16187 struct bgp_node *rn;
16188 struct prefix_ipv4 q;
16189 struct peer *peer;
16190 struct bgp_distance *bdistance;
16191 struct access_list *alist;
16192 struct bgp_static *bgp_static;
16193
16194 if (! bgp)
16195 return 0;
16196
16197 if (p->family != AF_INET)
16198 return 0;
16199
16200 peer = rinfo->peer;
16201
16202 if (peer->su.sa.sa_family != AF_INET)
16203 return 0;
16204
16205 memset (&q, 0, sizeof (struct prefix_ipv4));
16206 q.family = AF_INET;
16207 q.prefix = peer->su.sin.sin_addr;
16208 q.prefixlen = IPV4_MAX_BITLEN;
16209
16210 /* Check source address. */
16211 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
16212 if (rn)
16213 {
16214 bdistance = rn->info;
16215 bgp_unlock_node (rn);
16216
16217 if (bdistance->access_list)
16218 {
16219 alist = access_list_lookup (AFI_IP, bdistance->access_list);
16220 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
16221 return bdistance->distance;
16222 }
16223 else
16224 return bdistance->distance;
16225 }
16226
16227 /* Backdoor check. */
16228 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
16229 if (rn)
16230 {
16231 bgp_static = rn->info;
16232 bgp_unlock_node (rn);
16233
16234 if (bgp_static->backdoor)
16235 {
16236 if (bgp->distance_local)
16237 return bgp->distance_local;
16238 else
16239 return ZEBRA_IBGP_DISTANCE_DEFAULT;
16240 }
16241 }
16242
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000016243 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000016244 {
16245 if (bgp->distance_ebgp)
16246 return bgp->distance_ebgp;
16247 return ZEBRA_EBGP_DISTANCE_DEFAULT;
16248 }
16249 else
16250 {
16251 if (bgp->distance_ibgp)
16252 return bgp->distance_ibgp;
16253 return ZEBRA_IBGP_DISTANCE_DEFAULT;
16254 }
16255}
16256
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016257#ifdef HAVE_IPV6
16258/* Apply BGP information to ipv6 distance method. */
16259u_char
16260ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
16261{
16262 struct bgp_node *rn;
16263 struct prefix_ipv6 q;
16264 struct peer *peer;
16265 struct bgp_distance *bdistance;
16266 struct access_list *alist;
16267 struct bgp_static *bgp_static;
16268
16269 if (! bgp)
16270 return 0;
16271
16272 if (p->family != AF_INET6)
16273 return 0;
16274
16275 peer = rinfo->peer;
16276
16277 if (peer->su.sa.sa_family != AF_INET6)
16278 return 0;
16279
16280 memset (&q, 0, sizeof (struct prefix_ipv6));
16281 q.family = AF_INET;
16282 q.prefix = peer->su.sin6.sin6_addr;
16283 q.prefixlen = IPV6_MAX_BITLEN;
16284
16285 /* Check source address. */
16286 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
16287 if (rn)
16288 {
16289 bdistance = rn->info;
16290 bgp_unlock_node (rn);
16291
16292 if (bdistance->access_list)
16293 {
16294 alist = access_list_lookup (AFI_IP6, bdistance->access_list);
16295 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
16296 return bdistance->distance;
16297 }
16298 else
16299 return bdistance->distance;
16300 }
16301 /* Backdoor check. */
16302 rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p);
16303 if (rn)
16304 {
16305 bgp_static = rn->info;
16306 bgp_unlock_node (rn);
16307
16308 if (bgp_static->backdoor)
16309 {
16310 if (bgp->ipv6_distance_local)
16311 return bgp->ipv6_distance_local;
16312 else
16313 return ZEBRA_IBGP_DISTANCE_DEFAULT;
16314 }
16315 }
16316
16317 if (peer_sort (peer) == BGP_PEER_EBGP)
16318 {
16319 if (bgp->ipv6_distance_ebgp)
16320 return bgp->ipv6_distance_ebgp;
16321 return ZEBRA_EBGP_DISTANCE_DEFAULT;
16322 }
16323 else
16324 {
16325 if (bgp->ipv6_distance_ibgp)
16326 return bgp->ipv6_distance_ibgp;
16327 return ZEBRA_IBGP_DISTANCE_DEFAULT;
16328 }
16329}
16330#endif /* HAVE_IPV6 */
16331
paul718e3742002-12-13 20:15:29 +000016332DEFUN (bgp_distance,
16333 bgp_distance_cmd,
16334 "distance bgp <1-255> <1-255> <1-255>",
16335 "Define an administrative distance\n"
16336 "BGP distance\n"
16337 "Distance for routes external to the AS\n"
16338 "Distance for routes internal to the AS\n"
16339 "Distance for local routes\n")
16340{
16341 struct bgp *bgp;
16342
16343 bgp = vty->index;
16344
16345 bgp->distance_ebgp = atoi (argv[0]);
16346 bgp->distance_ibgp = atoi (argv[1]);
16347 bgp->distance_local = atoi (argv[2]);
16348 return CMD_SUCCESS;
16349}
16350
16351DEFUN (no_bgp_distance,
16352 no_bgp_distance_cmd,
16353 "no distance bgp <1-255> <1-255> <1-255>",
16354 NO_STR
16355 "Define an administrative distance\n"
16356 "BGP distance\n"
16357 "Distance for routes external to the AS\n"
16358 "Distance for routes internal to the AS\n"
16359 "Distance for local routes\n")
16360{
16361 struct bgp *bgp;
16362
16363 bgp = vty->index;
16364
16365 bgp->distance_ebgp= 0;
16366 bgp->distance_ibgp = 0;
16367 bgp->distance_local = 0;
16368 return CMD_SUCCESS;
16369}
16370
16371ALIAS (no_bgp_distance,
16372 no_bgp_distance2_cmd,
16373 "no distance bgp",
16374 NO_STR
16375 "Define an administrative distance\n"
16376 "BGP distance\n")
16377
16378DEFUN (bgp_distance_source,
16379 bgp_distance_source_cmd,
16380 "distance <1-255> A.B.C.D/M",
16381 "Define an administrative distance\n"
16382 "Administrative distance\n"
16383 "IP source prefix\n")
16384{
16385 bgp_distance_set (vty, argv[0], argv[1], NULL);
16386 return CMD_SUCCESS;
16387}
16388
16389DEFUN (no_bgp_distance_source,
16390 no_bgp_distance_source_cmd,
16391 "no distance <1-255> A.B.C.D/M",
16392 NO_STR
16393 "Define an administrative distance\n"
16394 "Administrative distance\n"
16395 "IP source prefix\n")
16396{
16397 bgp_distance_unset (vty, argv[0], argv[1], NULL);
16398 return CMD_SUCCESS;
16399}
16400
16401DEFUN (bgp_distance_source_access_list,
16402 bgp_distance_source_access_list_cmd,
16403 "distance <1-255> A.B.C.D/M WORD",
16404 "Define an administrative distance\n"
16405 "Administrative distance\n"
16406 "IP source prefix\n"
16407 "Access list name\n")
16408{
16409 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
16410 return CMD_SUCCESS;
16411}
16412
16413DEFUN (no_bgp_distance_source_access_list,
16414 no_bgp_distance_source_access_list_cmd,
16415 "no distance <1-255> A.B.C.D/M WORD",
16416 NO_STR
16417 "Define an administrative distance\n"
16418 "Administrative distance\n"
16419 "IP source prefix\n"
16420 "Access list name\n")
16421{
16422 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
16423 return CMD_SUCCESS;
16424}
David Lamparter6b0655a2014-06-04 06:53:35 +020016425
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016426#ifdef HAVE_IPV6
16427DEFUN (ipv6_bgp_distance,
16428 ipv6_bgp_distance_cmd,
16429 "distance bgp <1-255> <1-255> <1-255>",
16430 "Define an administrative distance\n"
16431 "BGP distance\n"
16432 "Distance for routes external to the AS\n"
16433 "Distance for routes internal to the AS\n"
16434 "Distance for local routes\n")
16435{
16436 struct bgp *bgp;
16437
16438 bgp = vty->index;
16439
16440 bgp->ipv6_distance_ebgp = atoi (argv[0]);
16441 bgp->ipv6_distance_ibgp = atoi (argv[1]);
16442 bgp->ipv6_distance_local = atoi (argv[2]);
16443 return CMD_SUCCESS;
16444}
16445
16446DEFUN (no_ipv6_bgp_distance,
16447 no_ipv6_bgp_distance_cmd,
16448 "no distance bgp <1-255> <1-255> <1-255>",
16449 NO_STR
16450 "Define an administrative distance\n"
16451 "BGP distance\n"
16452 "Distance for routes external to the AS\n"
16453 "Distance for routes internal to the AS\n"
16454 "Distance for local routes\n")
16455{
16456 struct bgp *bgp;
16457
16458 bgp = vty->index;
16459
16460 bgp->ipv6_distance_ebgp= 0;
16461 bgp->ipv6_distance_ibgp = 0;
16462 bgp->ipv6_distance_local = 0;
16463 return CMD_SUCCESS;
16464}
16465
16466ALIAS (no_ipv6_bgp_distance,
16467 no_ipv6_bgp_distance2_cmd,
16468 "no distance bgp",
16469 NO_STR
16470 "Define an administrative distance\n"
16471 "BGP distance\n")
16472
16473DEFUN (ipv6_bgp_distance_source,
16474 ipv6_bgp_distance_source_cmd,
16475 "distance <1-255> X:X::X:X/M",
16476 "Define an administrative distance\n"
16477 "Administrative distance\n"
16478 "IP source prefix\n")
16479{
16480 bgp_distance_set (vty, argv[0], argv[1], NULL);
16481 return CMD_SUCCESS;
16482}
16483
16484DEFUN (no_ipv6_bgp_distance_source,
16485 no_ipv6_bgp_distance_source_cmd,
16486 "no distance <1-255> X:X::X:X/M",
16487 NO_STR
16488 "Define an administrative distance\n"
16489 "Administrative distance\n"
16490 "IP source prefix\n")
16491{
16492 bgp_distance_unset (vty, argv[0], argv[1], NULL);
16493 return CMD_SUCCESS;
16494}
16495
16496DEFUN (ipv6_bgp_distance_source_access_list,
16497 ipv6_bgp_distance_source_access_list_cmd,
16498 "distance <1-255> X:X::X:X/M WORD",
16499 "Define an administrative distance\n"
16500 "Administrative distance\n"
16501 "IP source prefix\n"
16502 "Access list name\n")
16503{
16504 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
16505 return CMD_SUCCESS;
16506}
16507
16508DEFUN (no_ipv6_bgp_distance_source_access_list,
16509 no_ipv6_bgp_distance_source_access_list_cmd,
16510 "no distance <1-255> X:X::X:X/M WORD",
16511 NO_STR
16512 "Define an administrative distance\n"
16513 "Administrative distance\n"
16514 "IP source prefix\n"
16515 "Access list name\n")
16516{
16517 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
16518 return CMD_SUCCESS;
16519}
16520#endif
16521
paul718e3742002-12-13 20:15:29 +000016522DEFUN (bgp_damp_set,
16523 bgp_damp_set_cmd,
16524 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
16525 "BGP Specific commands\n"
16526 "Enable route-flap dampening\n"
16527 "Half-life time for the penalty\n"
16528 "Value to start reusing a route\n"
16529 "Value to start suppressing a route\n"
16530 "Maximum duration to suppress a stable route\n")
16531{
16532 struct bgp *bgp;
16533 int half = DEFAULT_HALF_LIFE * 60;
16534 int reuse = DEFAULT_REUSE;
16535 int suppress = DEFAULT_SUPPRESS;
16536 int max = 4 * half;
16537
16538 if (argc == 4)
16539 {
16540 half = atoi (argv[0]) * 60;
16541 reuse = atoi (argv[1]);
16542 suppress = atoi (argv[2]);
16543 max = atoi (argv[3]) * 60;
16544 }
16545 else if (argc == 1)
16546 {
16547 half = atoi (argv[0]) * 60;
16548 max = 4 * half;
16549 }
16550
16551 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000016552
16553 if (suppress < reuse)
16554 {
16555 vty_out (vty, "Suppress value cannot be less than reuse value %s",
16556 VTY_NEWLINE);
16557 return 0;
16558 }
16559
paul718e3742002-12-13 20:15:29 +000016560 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
16561 half, reuse, suppress, max);
16562}
16563
16564ALIAS (bgp_damp_set,
16565 bgp_damp_set2_cmd,
16566 "bgp dampening <1-45>",
16567 "BGP Specific commands\n"
16568 "Enable route-flap dampening\n"
16569 "Half-life time for the penalty\n")
16570
16571ALIAS (bgp_damp_set,
16572 bgp_damp_set3_cmd,
16573 "bgp dampening",
16574 "BGP Specific commands\n"
16575 "Enable route-flap dampening\n")
16576
16577DEFUN (bgp_damp_unset,
16578 bgp_damp_unset_cmd,
16579 "no bgp dampening",
16580 NO_STR
16581 "BGP Specific commands\n"
16582 "Enable route-flap dampening\n")
16583{
16584 struct bgp *bgp;
16585
16586 bgp = vty->index;
16587 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
16588}
16589
16590ALIAS (bgp_damp_unset,
16591 bgp_damp_unset2_cmd,
16592 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
16593 NO_STR
16594 "BGP Specific commands\n"
16595 "Enable route-flap dampening\n"
16596 "Half-life time for the penalty\n"
16597 "Value to start reusing a route\n"
16598 "Value to start suppressing a route\n"
16599 "Maximum duration to suppress a stable route\n")
16600
Lou Bergerf9b6c392016-01-12 13:42:09 -050016601DEFUN (show_ip_bgp_dampened_paths,
16602 show_ip_bgp_dampened_paths_cmd,
16603 "show ip bgp dampened-paths",
16604 SHOW_STR
16605 IP_STR
16606 BGP_STR
16607 "Display paths suppressed due to dampening\n")
16608{
16609 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
16610 NULL);
16611}
16612
16613ALIAS (show_ip_bgp_dampened_paths,
16614 show_ip_bgp_damp_dampened_paths_cmd,
16615 "show ip bgp dampening dampened-paths",
16616 SHOW_STR
16617 IP_STR
16618 BGP_STR
16619 "Display detailed information about dampening\n"
16620 "Display paths suppressed due to dampening\n")
16621
16622DEFUN (show_ip_bgp_flap_statistics,
16623 show_ip_bgp_flap_statistics_cmd,
16624 "show ip bgp flap-statistics",
16625 SHOW_STR
16626 IP_STR
16627 BGP_STR
16628 "Display flap statistics of routes\n")
16629{
16630 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
16631 bgp_show_type_flap_statistics, NULL);
16632}
16633
16634ALIAS (show_ip_bgp_flap_statistics,
16635 show_ip_bgp_damp_flap_statistics_cmd,
16636 "show ip bgp dampening flap-statistics",
16637 SHOW_STR
16638 IP_STR
16639 BGP_STR
16640 "Display detailed information about dampening\n"
16641 "Display flap statistics of routes\n")
16642
Lou Berger651b4022016-01-12 13:42:07 -050016643DEFUN (show_bgp_ipv4_safi_dampened_paths,
16644 show_bgp_ipv4_safi_dampened_paths_cmd,
16645 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000016646 SHOW_STR
paul718e3742002-12-13 20:15:29 +000016647 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050016648 IP_STR
16649 "Address Family modifier\n"
16650 "Address Family modifier\n"
16651 "Address Family modifier\n"
16652 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000016653 "Display paths suppressed due to dampening\n")
16654{
Lou Berger651b4022016-01-12 13:42:07 -050016655 safi_t safi;
paul718e3742002-12-13 20:15:29 +000016656
Lou Berger651b4022016-01-12 13:42:07 -050016657 if (bgp_parse_safi(argv[0], &safi)) {
16658 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
16659 return CMD_WARNING;
16660 }
16661
16662 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
16663}
16664ALIAS (show_bgp_ipv4_safi_dampened_paths,
16665 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
16666 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053016667 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053016668 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050016669 IP_STR
16670 "Address Family modifier\n"
16671 "Address Family modifier\n"
16672 "Address Family modifier\n"
16673 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053016674 "Display detailed information about dampening\n"
16675 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050016676
Lou Berger651b4022016-01-12 13:42:07 -050016677DEFUN (show_bgp_ipv6_safi_dampened_paths,
16678 show_bgp_ipv6_safi_dampened_paths_cmd,
16679 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000016680 SHOW_STR
paul718e3742002-12-13 20:15:29 +000016681 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050016682 IPV6_STR
16683 "Address Family modifier\n"
16684 "Address Family modifier\n"
16685 "Address Family modifier\n"
16686 "Address Family modifier\n"
16687 "Display paths suppressed due to dampening\n")
16688{
16689 safi_t safi;
16690
16691 if (bgp_parse_safi(argv[0], &safi)) {
16692 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
16693 return CMD_WARNING;
16694 }
16695
16696 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
16697}
16698ALIAS (show_bgp_ipv6_safi_dampened_paths,
16699 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
16700 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
16701 SHOW_STR
16702 BGP_STR
16703 IPV6_STR
16704 "Address Family modifier\n"
16705 "Address Family modifier\n"
16706 "Address Family modifier\n"
16707 "Address Family modifier\n"
16708 "Display detailed information about dampening\n"
16709 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050016710
16711DEFUN (show_bgp_ipv4_safi_flap_statistics,
16712 show_bgp_ipv4_safi_flap_statistics_cmd,
16713 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
16714 SHOW_STR
16715 BGP_STR
16716 "Address Family\n"
16717 "Address Family modifier\n"
16718 "Address Family modifier\n"
16719 "Address Family modifier\n"
16720 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000016721 "Display flap statistics of routes\n")
16722{
Lou Berger651b4022016-01-12 13:42:07 -050016723 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020016724
Lou Berger651b4022016-01-12 13:42:07 -050016725 if (bgp_parse_safi(argv[0], &safi)) {
16726 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
16727 return CMD_WARNING;
16728 }
16729
16730 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
16731}
16732ALIAS (show_bgp_ipv4_safi_flap_statistics,
16733 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
16734 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053016735 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053016736 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050016737 "Address Family\n"
16738 "Address Family modifier\n"
16739 "Address Family modifier\n"
16740 "Address Family modifier\n"
16741 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053016742 "Display detailed information about dampening\n"
16743 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050016744
Lou Berger651b4022016-01-12 13:42:07 -050016745DEFUN (show_bgp_ipv6_safi_flap_statistics,
16746 show_bgp_ipv6_safi_flap_statistics_cmd,
16747 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
16748 SHOW_STR
16749 BGP_STR
16750 "Address Family\n"
16751 "Address Family modifier\n"
16752 "Address Family modifier\n"
16753 "Address Family modifier\n"
16754 "Address Family modifier\n"
16755 "Display flap statistics of routes\n")
16756{
16757 safi_t safi;
16758
16759 if (bgp_parse_safi(argv[0], &safi)) {
16760 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
16761 return CMD_WARNING;
16762 }
16763
16764 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
16765}
16766ALIAS (show_bgp_ipv6_safi_flap_statistics,
16767 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
16768 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
16769 SHOW_STR
16770 BGP_STR
16771 "Address Family\n"
16772 "Address Family modifier\n"
16773 "Address Family modifier\n"
16774 "Address Family modifier\n"
16775 "Address Family modifier\n"
16776 "Display detailed information about dampening\n"
16777 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053016778
paul718e3742002-12-13 20:15:29 +000016779/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000016780static int
paulfd79ac92004-10-13 05:06:08 +000016781bgp_clear_damp_route (struct vty *vty, const char *view_name,
16782 const char *ip_str, afi_t afi, safi_t safi,
16783 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000016784{
16785 int ret;
16786 struct prefix match;
16787 struct bgp_node *rn;
16788 struct bgp_node *rm;
16789 struct bgp_info *ri;
16790 struct bgp_info *ri_temp;
16791 struct bgp *bgp;
16792 struct bgp_table *table;
16793
16794 /* BGP structure lookup. */
16795 if (view_name)
16796 {
16797 bgp = bgp_lookup_by_name (view_name);
16798 if (bgp == NULL)
16799 {
16800 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
16801 return CMD_WARNING;
16802 }
16803 }
16804 else
16805 {
16806 bgp = bgp_get_default ();
16807 if (bgp == NULL)
16808 {
16809 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
16810 return CMD_WARNING;
16811 }
16812 }
16813
16814 /* Check IP address argument. */
16815 ret = str2prefix (ip_str, &match);
16816 if (! ret)
16817 {
16818 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
16819 return CMD_WARNING;
16820 }
16821
16822 match.family = afi2family (afi);
16823
Lou Berger298cc2f2016-01-12 13:42:02 -050016824 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000016825 {
Lou Berger298cc2f2016-01-12 13:42:02 -050016826 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000016827 {
16828 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
16829 continue;
16830
16831 if ((table = rn->info) != NULL)
16832 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000016833 {
16834 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
16835 {
16836 ri = rm->info;
16837 while (ri)
16838 {
16839 if (ri->extra && ri->extra->damp_info)
16840 {
16841 ri_temp = ri->next;
16842 bgp_damp_info_free (ri->extra->damp_info, 1);
16843 ri = ri_temp;
16844 }
16845 else
16846 ri = ri->next;
16847 }
16848 }
16849
16850 bgp_unlock_node (rm);
16851 }
paul718e3742002-12-13 20:15:29 +000016852 }
16853 }
16854 else
16855 {
16856 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000016857 {
16858 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
16859 {
16860 ri = rn->info;
16861 while (ri)
16862 {
16863 if (ri->extra && ri->extra->damp_info)
16864 {
16865 ri_temp = ri->next;
16866 bgp_damp_info_free (ri->extra->damp_info, 1);
16867 ri = ri_temp;
16868 }
16869 else
16870 ri = ri->next;
16871 }
16872 }
16873
16874 bgp_unlock_node (rn);
16875 }
paul718e3742002-12-13 20:15:29 +000016876 }
16877
16878 return CMD_SUCCESS;
16879}
16880
16881DEFUN (clear_ip_bgp_dampening,
16882 clear_ip_bgp_dampening_cmd,
16883 "clear ip bgp dampening",
16884 CLEAR_STR
16885 IP_STR
16886 BGP_STR
16887 "Clear route flap dampening information\n")
16888{
16889 bgp_damp_info_clean ();
16890 return CMD_SUCCESS;
16891}
16892
16893DEFUN (clear_ip_bgp_dampening_prefix,
16894 clear_ip_bgp_dampening_prefix_cmd,
16895 "clear ip bgp dampening A.B.C.D/M",
16896 CLEAR_STR
16897 IP_STR
16898 BGP_STR
16899 "Clear route flap dampening information\n"
16900 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
16901{
16902 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16903 SAFI_UNICAST, NULL, 1);
16904}
16905
16906DEFUN (clear_ip_bgp_dampening_address,
16907 clear_ip_bgp_dampening_address_cmd,
16908 "clear ip bgp dampening A.B.C.D",
16909 CLEAR_STR
16910 IP_STR
16911 BGP_STR
16912 "Clear route flap dampening information\n"
16913 "Network to clear damping information\n")
16914{
16915 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16916 SAFI_UNICAST, NULL, 0);
16917}
16918
16919DEFUN (clear_ip_bgp_dampening_address_mask,
16920 clear_ip_bgp_dampening_address_mask_cmd,
16921 "clear ip bgp dampening A.B.C.D A.B.C.D",
16922 CLEAR_STR
16923 IP_STR
16924 BGP_STR
16925 "Clear route flap dampening information\n"
16926 "Network to clear damping information\n"
16927 "Network mask\n")
16928{
16929 int ret;
16930 char prefix_str[BUFSIZ];
16931
16932 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
16933 if (! ret)
16934 {
16935 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
16936 return CMD_WARNING;
16937 }
16938
16939 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
16940 SAFI_UNICAST, NULL, 0);
16941}
David Lamparter6b0655a2014-06-04 06:53:35 +020016942
Lou Berger298cc2f2016-01-12 13:42:02 -050016943/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000016944static int
paul718e3742002-12-13 20:15:29 +000016945bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
16946 afi_t afi, safi_t safi, int *write)
16947{
16948 struct bgp_node *prn;
16949 struct bgp_node *rn;
16950 struct bgp_table *table;
16951 struct prefix *p;
16952 struct prefix_rd *prd;
16953 struct bgp_static *bgp_static;
16954 u_int32_t label;
16955 char buf[SU_ADDRSTRLEN];
16956 char rdbuf[RD_ADDRSTRLEN];
16957
16958 /* Network configuration. */
16959 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
16960 if ((table = prn->info) != NULL)
16961 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
16962 if ((bgp_static = rn->info) != NULL)
16963 {
16964 p = &rn->p;
16965 prd = (struct prefix_rd *) &prn->p;
16966
16967 /* "address-family" display. */
16968 bgp_config_write_family_header (vty, afi, safi, write);
16969
16970 /* "network" configuration display. */
16971 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
16972 label = decode_label (bgp_static->tag);
16973
16974 vty_out (vty, " network %s/%d rd %s tag %d",
16975 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16976 p->prefixlen,
16977 rdbuf, label);
16978 vty_out (vty, "%s", VTY_NEWLINE);
16979 }
16980 return 0;
16981}
16982
16983/* Configuration of static route announcement and aggregate
16984 information. */
16985int
16986bgp_config_write_network (struct vty *vty, struct bgp *bgp,
16987 afi_t afi, safi_t safi, int *write)
16988{
16989 struct bgp_node *rn;
16990 struct prefix *p;
16991 struct bgp_static *bgp_static;
16992 struct bgp_aggregate *bgp_aggregate;
16993 char buf[SU_ADDRSTRLEN];
16994
Lou Berger298cc2f2016-01-12 13:42:02 -050016995 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000016996 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
16997
16998 /* Network configuration. */
16999 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
17000 if ((bgp_static = rn->info) != NULL)
17001 {
17002 p = &rn->p;
17003
17004 /* "address-family" display. */
17005 bgp_config_write_family_header (vty, afi, safi, write);
17006
17007 /* "network" configuration display. */
17008 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
17009 {
17010 u_int32_t destination;
17011 struct in_addr netmask;
17012
17013 destination = ntohl (p->u.prefix4.s_addr);
17014 masklen2ip (p->prefixlen, &netmask);
17015 vty_out (vty, " network %s",
17016 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
17017
17018 if ((IN_CLASSC (destination) && p->prefixlen == 24)
17019 || (IN_CLASSB (destination) && p->prefixlen == 16)
17020 || (IN_CLASSA (destination) && p->prefixlen == 8)
17021 || p->u.prefix4.s_addr == 0)
17022 {
17023 /* Natural mask is not display. */
17024 }
17025 else
17026 vty_out (vty, " mask %s", inet_ntoa (netmask));
17027 }
17028 else
17029 {
17030 vty_out (vty, " network %s/%d",
17031 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
17032 p->prefixlen);
17033 }
17034
17035 if (bgp_static->rmap.name)
17036 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000017037 else
17038 {
17039 if (bgp_static->backdoor)
17040 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000017041 }
paul718e3742002-12-13 20:15:29 +000017042
17043 vty_out (vty, "%s", VTY_NEWLINE);
17044 }
17045
17046 /* Aggregate-address configuration. */
17047 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
17048 if ((bgp_aggregate = rn->info) != NULL)
17049 {
17050 p = &rn->p;
17051
17052 /* "address-family" display. */
17053 bgp_config_write_family_header (vty, afi, safi, write);
17054
17055 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
17056 {
17057 struct in_addr netmask;
17058
17059 masklen2ip (p->prefixlen, &netmask);
17060 vty_out (vty, " aggregate-address %s %s",
17061 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
17062 inet_ntoa (netmask));
17063 }
17064 else
17065 {
17066 vty_out (vty, " aggregate-address %s/%d",
17067 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
17068 p->prefixlen);
17069 }
17070
17071 if (bgp_aggregate->as_set)
17072 vty_out (vty, " as-set");
17073
17074 if (bgp_aggregate->summary_only)
17075 vty_out (vty, " summary-only");
17076
17077 vty_out (vty, "%s", VTY_NEWLINE);
17078 }
17079
17080 return 0;
17081}
17082
17083int
Roman Hoog Antink6184c392014-03-17 14:01:42 +010017084bgp_config_write_distance (struct vty *vty, struct bgp *bgp,
17085 afi_t afi, safi_t safi, int *write)
paul718e3742002-12-13 20:15:29 +000017086{
17087 struct bgp_node *rn;
17088 struct bgp_distance *bdistance;
17089
Roman Hoog Antink6184c392014-03-17 14:01:42 +010017090 if (afi == AFI_IP && safi == SAFI_UNICAST)
17091 {
17092 /* Distance configuration. */
17093 if (bgp->distance_ebgp
17094 && bgp->distance_ibgp
17095 && bgp->distance_local
17096 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
17097 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
17098 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
17099 vty_out (vty, " distance bgp %d %d %d%s",
17100 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
17101 VTY_NEWLINE);
17102
17103 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
17104 if ((bdistance = rn->info) != NULL)
17105 {
17106 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
17107 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
17108 bdistance->access_list ? bdistance->access_list : "",
17109 VTY_NEWLINE);
17110 }
17111 }
17112
17113#ifdef HAVE_IPV6
17114 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
17115 {
17116 bgp_config_write_family_header (vty, afi, safi, write);
17117 if (bgp->ipv6_distance_ebgp
17118 && bgp->ipv6_distance_ibgp
17119 && bgp->ipv6_distance_local
17120 && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
17121 || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
17122 || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
17123 vty_out (vty, " distance bgp %d %d %d%s",
17124 bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local,
17125 VTY_NEWLINE);
17126
Paul Jakma5bc62ca2016-07-11 16:21:23 +010017127 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
17128 if ((bdistance = rn->info) != NULL)
17129 {
17130 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
17131 inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen,
17132 bdistance->access_list ? bdistance->access_list : "",
17133 VTY_NEWLINE);
17134 }
Roman Hoog Antink6184c392014-03-17 14:01:42 +010017135 }
17136#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000017137
17138 return 0;
17139}
17140
17141/* Allocate routing table structure and install commands. */
17142void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080017143bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000017144{
17145 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000017146 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000017147
17148 /* IPv4 BGP commands. */
17149 install_element (BGP_NODE, &bgp_network_cmd);
17150 install_element (BGP_NODE, &bgp_network_mask_cmd);
17151 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
17152 install_element (BGP_NODE, &bgp_network_route_map_cmd);
17153 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
17154 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
17155 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
17156 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
17157 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
17158 install_element (BGP_NODE, &no_bgp_network_cmd);
17159 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
17160 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
17161 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
17162 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
17163 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
17164 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
17165 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
17166 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
17167
17168 install_element (BGP_NODE, &aggregate_address_cmd);
17169 install_element (BGP_NODE, &aggregate_address_mask_cmd);
17170 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
17171 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
17172 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
17173 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
17174 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
17175 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
17176 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
17177 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
17178 install_element (BGP_NODE, &no_aggregate_address_cmd);
17179 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
17180 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
17181 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
17182 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
17183 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
17184 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
17185 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
17186 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
17187 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
17188
17189 /* IPv4 unicast configuration. */
17190 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
17191 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
17192 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
17193 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
17194 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
17195 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000017196 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000017197 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
17198 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
17199 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
17200 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
17201 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000017202
paul718e3742002-12-13 20:15:29 +000017203 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
17204 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
17205 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
17206 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
17207 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
17208 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
17209 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
17210 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
17211 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
17212 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
17213 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
17214 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
17215 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
17216 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
17217 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
17218 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
17219 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
17220 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
17221 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
17222 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
17223
17224 /* IPv4 multicast configuration. */
17225 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
17226 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
17227 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
17228 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
17229 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
17230 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
17231 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
17232 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
17233 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
17234 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
17235 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
17236 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
17237 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
17238 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
17239 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
17240 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
17241 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
17242 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
17243 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
17244 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
17245 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
17246 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
17247 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
17248 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
17249 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
17250 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
17251 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
17252 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
17253 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
17254 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
17255 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
17256 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
17257
Michael Lambert95cbbd22010-07-23 14:43:04 -040017258 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017259 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017260 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
17261 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
17262 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
17263 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
17264 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
17265 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
17266 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
17267 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
17268 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017269 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017270 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
17271 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
17272 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
17273 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
17274 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
17275 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
17276 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
17277 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
17278 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
17279 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
17280 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
17281 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
17282 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
17283 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
17284 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
17285 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
17286 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
17287 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
17288 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
17289 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
17290 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
17291 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
17292 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
17293 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
17294 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
17295 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
17296 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
17297 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017298 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
17299 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
17300 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
17301 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
17302 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017303 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
17304 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
17305 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
17306 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
17307 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
17308 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
17309 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
17310 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
17311 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
17312 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
17313 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
17314 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017315
17316 /* large-communities */
17317 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity_cmd);
17318 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity2_cmd);
17319 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity3_cmd);
17320 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity4_cmd);
17321 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity_cmd);
17322 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity2_cmd);
17323 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity3_cmd);
17324 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity4_cmd);
17325 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity_all_cmd);
17326 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity_cmd);
17327 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity2_cmd);
17328 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity3_cmd);
17329 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity4_cmd);
17330 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity_list_cmd);
17331 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity_list_cmd);
17332
Lou Berger651b4022016-01-12 13:42:07 -050017333 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
17334 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
17335 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
17336 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
17337 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
17338 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
17339 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017340 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017341 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
17342 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
17343 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
17344 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
17345 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
17346 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
17347 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
17348 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
17349 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
17350 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
17351 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
17352 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
17353 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
17354 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
17355 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
17356 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
17357 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
17358 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
17359 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
17360 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
17361 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
17362 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
17363 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
17364 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
17365 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
17366 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
17367 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
17368 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
17369 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
17370 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
17371 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
17372 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
17373 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
17374 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
17375 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
17376 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
17377 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
17378 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
17379 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
17380 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
17381 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
17382 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
17383 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
17384 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
17385 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017386 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017387 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017388 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017389 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017390 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017391 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010017392
17393 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040017394 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017395 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
17396 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
17397 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
17398 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
17399 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017400 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017401 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
17402 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
17403 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
17404 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
17405 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
17406 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
17407 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
17408 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
17409 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
17410 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
17411 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
17412 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
17413 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
17414 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
17415 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
17416 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017417 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
17418 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
17419 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
17420 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
17421 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017422 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
17423 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
17424 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
17425 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
17426 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
17427 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
17428 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
17429 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017430
17431 /* large-community */
17432 install_element (RESTRICTED_NODE, &show_bgp_ipv4_lcommunity_cmd);
17433 install_element (RESTRICTED_NODE, &show_bgp_ipv4_lcommunity2_cmd);
17434 install_element (RESTRICTED_NODE, &show_bgp_ipv4_lcommunity3_cmd);
17435 install_element (RESTRICTED_NODE, &show_bgp_ipv4_lcommunity4_cmd);
17436 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_lcommunity_cmd);
17437 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_lcommunity2_cmd);
17438 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_lcommunity3_cmd);
17439 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_lcommunity4_cmd);
17440 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity_all_cmd);
17441 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity_cmd);
17442 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity2_cmd);
17443 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity3_cmd);
17444 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity4_cmd);
17445
Michael Lambert95cbbd22010-07-23 14:43:04 -040017446 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017447 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017448 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017449 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000017450
Donald Sharp68b45cc2016-03-11 14:27:13 -050017451 /* BGP dampening clear commands */
paul718e3742002-12-13 20:15:29 +000017452 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
17453 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017454
paul718e3742002-12-13 20:15:29 +000017455 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
17456 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
17457
paul718e3742002-12-13 20:15:29 +000017458 /* New config IPv6 BGP commands. */
17459 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
17460 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
17461 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
17462 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
17463
17464 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
17465 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
17466 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
17467 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
17468
G.Balaji73bfe0b2011-09-23 22:36:20 +053017469 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
17470 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
17471
paul718e3742002-12-13 20:15:29 +000017472 /* Old config IPv6 BGP commands. */
17473 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
17474 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
17475
17476 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
17477 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
17478 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
17479 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
17480
Michael Lambert95cbbd22010-07-23 14:43:04 -040017481 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000017482 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017483 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000017484 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017485 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000017486 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000017487 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000017488 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000017489 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017490 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
17491 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
17492 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
17493 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
17494 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
17495 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
17496 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
17497 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000017498 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017499
17500 /* large-community */
17501 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity_cmd);
17502 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity2_cmd);
17503 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity3_cmd);
17504 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity4_cmd);
17505 install_element (VIEW_NODE, &show_bgp_lcommunity_list_cmd);
17506
paul718e3742002-12-13 20:15:29 +000017507 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000017508 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000017509 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000017510 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000017511 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000017512 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000017513 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017514 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
17515 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017516 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017517 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017518 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017519 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017520 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000017521 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000017522 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000017523 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000017524 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000017525 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000017526 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000017527 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000017528 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000017529 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017530 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
17531 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017532 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017533 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017534 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017535 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017536 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010017537
17538 /* Restricted:
17539 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
17540 */
Paul Jakma62687ff2008-08-23 14:27:06 +010017541 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017542 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010017543 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017544 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017545 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
17546 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
17547 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
17548 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
17549 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
17550 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
17551 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
17552 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017553 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_lcommunity_cmd);
17554 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_lcommunity2_cmd);
17555 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_lcommunity3_cmd);
17556 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_lcommunity4_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017557 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017558 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017559 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017560 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010017561 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010017562 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010017563 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017564 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017565 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017566 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040017567 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000017568
Paul Jakma2815e612006-09-14 02:56:07 +000017569 /* Statistics */
17570 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050017571 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000017572
17573 install_element (BGP_NODE, &bgp_distance_cmd);
17574 install_element (BGP_NODE, &no_bgp_distance_cmd);
17575 install_element (BGP_NODE, &no_bgp_distance2_cmd);
17576 install_element (BGP_NODE, &bgp_distance_source_cmd);
17577 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
17578 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
17579 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
Roman Hoog Antink6184c392014-03-17 14:01:42 +010017580#ifdef HAVE_IPV6
17581 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd);
17582 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd);
17583 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd);
17584 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd);
17585 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd);
17586 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd);
17587 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd);
17588#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000017589
17590 install_element (BGP_NODE, &bgp_damp_set_cmd);
17591 install_element (BGP_NODE, &bgp_damp_set2_cmd);
17592 install_element (BGP_NODE, &bgp_damp_set3_cmd);
17593 install_element (BGP_NODE, &bgp_damp_unset_cmd);
17594 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
17595 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
17596 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
17597 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
17598 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
17599 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Balaji9145f0e2016-01-20 22:59:27 +053017600
17601 /* IPv4 Multicast Mode */
17602 install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd);
17603 install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd);
17604 install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd);
17605 install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd);
17606 install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd);
17607
Paul Jakmac8f3fe32010-12-05 20:28:02 +000017608
17609 /* Deprecated AS-Pathlimit commands */
17610 install_element (BGP_NODE, &bgp_network_ttl_cmd);
17611 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
17612 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
17613 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
17614 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
17615 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
17616
17617 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
17618 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
17619 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
17620 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
17621 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
17622 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
17623
17624 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
17625 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
17626 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
17627 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
17628 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
17629 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
17630
17631 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
17632 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
17633 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
17634 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
17635 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
17636 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
17637
17638 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
17639 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
17640 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
17641 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
17642 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
17643 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
17644
17645 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
17646 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
17647 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
17648 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
17649 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
17650 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000017651
Paul Jakmac8f3fe32010-12-05 20:28:02 +000017652 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
17653 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017654
17655 /* old style commands */
17656 install_element (VIEW_NODE, &show_ip_bgp_cmd);
17657 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
17658 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070017659 install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd);
17660 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017661 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
17662 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
17663 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
17664 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
17665 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070017666 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
17667 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
17668 install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017669 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
17670 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
17671 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
17672 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
17673 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
17674 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
17675 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
17676 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
17677 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
17678 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
17679 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
17680 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
17681 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
17682 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
17683 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
17684 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
17685 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
17686 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
17687 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
17688 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
17689 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
17690 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
17691 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
17692 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
17693 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
17694 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
17695 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
17696 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
17697 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
17698 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
17699 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
17700 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
17701 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
17702 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
17703 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
17704 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
17705 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017706 install_element (VIEW_NODE, &show_ip_bgp_lcommunity_all_cmd);
17707 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity_all_cmd);
17708 install_element (VIEW_NODE, &show_ip_bgp_lcommunity_cmd);
17709 install_element (VIEW_NODE, &show_ip_bgp_lcommunity2_cmd);
17710 install_element (VIEW_NODE, &show_ip_bgp_lcommunity3_cmd);
17711 install_element (VIEW_NODE, &show_ip_bgp_lcommunity4_cmd);
17712 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity_cmd);
17713 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity2_cmd);
17714 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity3_cmd);
17715 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity4_cmd);
17716 install_element (VIEW_NODE, &show_ip_bgp_lcommunity_list_cmd);
17717 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017718 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
17719 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
17720 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
17721 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
17722 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
17723 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
17724 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
17725 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
17726 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
17727 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
17728 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053017729 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017730 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053017731 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd);
17732 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017733 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
17734 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
17735 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
17736 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
17737 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
17738 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
17739 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
17740 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
17741 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
17742 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
17743 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
17744 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
17745 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
17746 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
17747 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
17748 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
17749 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
17750 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
17751 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
17752 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
17753 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
17754 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
17755 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
17756 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
17757 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
17758 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
17759 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050017760
Lou Bergerf9b6c392016-01-12 13:42:09 -050017761 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070017762 install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd);
17763 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017764 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
17765 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
17766 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
17767 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070017768 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
17769 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
17770 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017771 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
17772 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
17773 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
17774 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
17775 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
17776 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
17777 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
17778 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
17779 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
17780 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
17781 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
17782 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
17783 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
17784 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
17785 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
17786 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
17787 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
17788 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
17789 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
17790 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017791 install_element (RESTRICTED_NODE, &show_ip_bgp_lcommunity_cmd);
17792 install_element (RESTRICTED_NODE, &show_ip_bgp_lcommunity2_cmd);
17793 install_element (RESTRICTED_NODE, &show_ip_bgp_lcommunity3_cmd);
17794 install_element (RESTRICTED_NODE, &show_ip_bgp_lcommunity4_cmd);
17795 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_lcommunity_cmd);
17796 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_lcommunity2_cmd);
17797 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_lcommunity3_cmd);
17798 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_lcommunity4_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017799 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
17800 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
17801 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
17802 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050017803
17804 install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
17805 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
17806 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070017807
Lou Bergerf9b6c392016-01-12 13:42:09 -050017808 install_element (VIEW_NODE, &show_bgp_cmd);
17809 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
17810 install_element (VIEW_NODE, &show_bgp_route_cmd);
17811 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070017812 install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd);
17813 install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd);
17814 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
17815 install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd);
17816 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
17817 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017818 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
17819 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
17820 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
17821 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
17822 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
17823 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
17824 install_element (VIEW_NODE, &show_bgp_community_cmd);
17825 install_element (VIEW_NODE, &show_bgp_community2_cmd);
17826 install_element (VIEW_NODE, &show_bgp_community3_cmd);
17827 install_element (VIEW_NODE, &show_bgp_community4_cmd);
17828 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
17829 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
17830 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
17831 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
17832 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
17833 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
17834 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017835 install_element (VIEW_NODE, &show_bgp_lcommunity_all_cmd);
17836 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity_all_cmd);
17837 install_element (VIEW_NODE, &show_bgp_lcommunity_cmd);
17838 install_element (VIEW_NODE, &show_bgp_lcommunity2_cmd);
17839 install_element (VIEW_NODE, &show_bgp_lcommunity3_cmd);
17840 install_element (VIEW_NODE, &show_bgp_lcommunity4_cmd);
17841 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017842 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
17843 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
17844 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
17845 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
17846 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
17847 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
17848 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
17849 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
17850 install_element (VIEW_NODE, &show_bgp_view_cmd);
17851 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
17852 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
17853 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
17854 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
17855 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
17856 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
17857 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
17858 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
17859 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050017860
Lou Bergerf9b6c392016-01-12 13:42:09 -050017861 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
17862 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070017863 install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd);
17864 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd);
17865 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
17866 install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd);
17867 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
17868 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017869 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
17870 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
17871 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
17872 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
17873 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
17874 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
17875 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
17876 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017877 install_element (RESTRICTED_NODE, &show_bgp_lcommunity_cmd);
17878 install_element (RESTRICTED_NODE, &show_bgp_lcommunity2_cmd);
17879 install_element (RESTRICTED_NODE, &show_bgp_lcommunity3_cmd);
17880 install_element (RESTRICTED_NODE, &show_bgp_lcommunity4_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017881 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
17882 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
17883 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
Daniel Walton59fe0ee2015-05-19 17:58:11 -070017884
Lou Bergerf9b6c392016-01-12 13:42:09 -050017885 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
17886 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050017887
Lou Bergerf9b6c392016-01-12 13:42:09 -050017888 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
17889 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
17890 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
17891 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
17892 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
17893 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
17894 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
17895 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
17896 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
17897 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
17898 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
17899 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
17900 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
17901 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
17902 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
17903 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
17904 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017905 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity_all_cmd);
17906 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity_cmd);
17907 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity2_cmd);
17908 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity3_cmd);
17909 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity4_cmd);
17910 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017911 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
17912 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
17913 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
17914 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
17915 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
17916 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
17917 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
17918 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
17919 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
17920 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
17921 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
17922 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
17923 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
17924 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
17925 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
17926 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
17927 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
17928 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
Job Snijders3334bab2017-01-20 14:47:12 +000017929 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity_all_cmd);
17930 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity_cmd);
17931 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity2_cmd);
17932 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity3_cmd);
17933 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity4_cmd);
17934 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017935 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017936 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017937 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017938 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017939 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017940 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017941 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017942 /* old with name safi collision */
17943 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
17944 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
17945 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
17946 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
17947 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
17948 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
17949 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
17950 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
17951 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
17952 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
17953 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
17954 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
17955 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
17956 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
17957 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
17958 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
Donald Sharp68b45cc2016-03-11 14:27:13 -050017959
Lou Bergerf9b6c392016-01-12 13:42:09 -050017960 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
17961 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017962
Job Snijders3334bab2017-01-20 14:47:12 +000017963 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity_cmd);
17964 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity2_cmd);
17965 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity3_cmd);
17966 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity4_cmd);
17967 install_element (RESTRICTED_NODE, &show_bgp_ipv6_lcommunity_cmd);
17968 install_element (RESTRICTED_NODE, &show_bgp_ipv6_lcommunity2_cmd);
17969 install_element (RESTRICTED_NODE, &show_bgp_ipv6_lcommunity3_cmd);
17970 install_element (RESTRICTED_NODE, &show_bgp_ipv6_lcommunity4_cmd);
17971 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity_list_cmd);
17972
Lou Bergerf9b6c392016-01-12 13:42:09 -050017973 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
17974 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
17975 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
17976 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050017977
17978 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
17979 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
17980 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
17981 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000017982}
Chris Caputo228da422009-07-18 05:44:03 +000017983
17984void
17985bgp_route_finish (void)
17986{
17987 bgp_table_unlock (bgp_distance_table);
17988 bgp_distance_table = NULL;
17989}