paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP routing information |
| 2 | Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 3 | Copyright (C) 2016 Job Snijders <job@instituut.net> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4 | |
| 5 | This file is part of GNU Zebra. |
| 6 | |
| 7 | GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | under the terms of the GNU General Public License as published by the |
| 9 | Free Software Foundation; either version 2, or (at your option) any |
| 10 | later version. |
| 11 | |
| 12 | GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | 02111-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" |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 37 | #include "workqueue.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 38 | |
| 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 48 | #include "bgpd/bgp_lcommunity.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 49 | #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" |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 58 | #include "bgpd/bgp_vty.h" |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 59 | #include "bgpd/bgp_mpath.h" |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 60 | #include "bgpd/bgp_nht.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | |
| 62 | /* Extern from bgp_dump.c */ |
Stephen Hemminger | dde7258 | 2009-05-08 15:19:07 -0700 | [diff] [blame] | 63 | extern const char *bgp_origin_str[]; |
| 64 | extern const char *bgp_origin_long_str[]; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 65 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 66 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 67 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | struct prefix_rd *prd) |
| 69 | { |
| 70 | struct bgp_node *rn; |
| 71 | struct bgp_node *prn = NULL; |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 72 | |
| 73 | assert (table); |
| 74 | if (!table) |
| 75 | return NULL; |
| 76 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 77 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 78 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 79 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 80 | |
| 81 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 82 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 83 | else |
| 84 | bgp_unlock_node (prn); |
| 85 | table = prn->info; |
| 86 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 87 | |
| 88 | rn = bgp_node_get (table, p); |
| 89 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 90 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 91 | rn->prn = prn; |
| 92 | |
| 93 | return rn; |
| 94 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 95 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 96 | /* Allocate bgp_info_extra */ |
| 97 | static struct bgp_info_extra * |
| 98 | bgp_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 | |
| 105 | static void |
| 106 | bgp_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 | */ |
| 124 | struct bgp_info_extra * |
| 125 | bgp_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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 133 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | bgp_info_free (struct bgp_info *binfo) |
| 135 | { |
| 136 | if (binfo->attr) |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 137 | bgp_attr_unintern (&binfo->attr); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 138 | |
Paul Jakma | 3dda6b3 | 2016-09-06 16:57:40 +0100 | [diff] [blame] | 139 | bgp_unlink_nexthop (binfo); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 140 | bgp_info_extra_free (&binfo->extra); |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 141 | bgp_info_mpath_free (&binfo->mpath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 142 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 143 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 144 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 145 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 146 | } |
| 147 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 148 | struct bgp_info * |
| 149 | bgp_info_lock (struct bgp_info *binfo) |
| 150 | { |
| 151 | binfo->lock++; |
| 152 | return binfo; |
| 153 | } |
| 154 | |
| 155 | struct bgp_info * |
| 156 | bgp_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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 182 | void |
| 183 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 184 | { |
| 185 | struct bgp_info *top; |
| 186 | |
| 187 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 188 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 189 | ri->next = rn->info; |
| 190 | ri->prev = NULL; |
| 191 | if (top) |
| 192 | top->prev = ri; |
| 193 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 194 | |
| 195 | bgp_info_lock (ri); |
| 196 | bgp_lock_node (rn); |
| 197 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 198 | } |
| 199 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 200 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 201 | completion callback *only* */ |
| 202 | static void |
| 203 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 204 | { |
| 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; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 211 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 212 | bgp_info_mpath_dequeue (ri); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 213 | bgp_info_unlock (ri); |
| 214 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 215 | } |
| 216 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 217 | void |
| 218 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 219 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 220 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
| 221 | /* set of previous already took care of pcount */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 222 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 223 | } |
| 224 | |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 225 | /* 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 */ |
| 228 | static void |
| 229 | bgp_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 Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 236 | /* Adjust pcount as required */ |
| 237 | static void |
| 238 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) |
| 239 | { |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 240 | struct bgp_table *table; |
| 241 | |
| 242 | assert (rn && bgp_node_table (rn)); |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 243 | assert (ri && ri->peer && ri->peer->bgp); |
| 244 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 245 | table = bgp_node_table (rn); |
| 246 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 247 | /* Ignore 'pcount' for RS-client tables */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 248 | if (table->type != BGP_TABLE_MAIN |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 249 | || ri->peer == ri->peer->bgp->peer_self) |
| 250 | return; |
| 251 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame] | 252 | if (!BGP_INFO_COUNTABLE (ri) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 253 | && 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 Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 259 | if (ri->peer->pcount[table->afi][table->safi]) |
| 260 | ri->peer->pcount[table->afi][table->safi]--; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 261 | 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 Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame] | 269 | else if (BGP_INFO_COUNTABLE (ri) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 270 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 271 | { |
| 272 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 273 | ri->peer->pcount[table->afi][table->safi]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 274 | } |
| 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 | */ |
| 281 | void |
| 282 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 283 | { |
| 284 | SET_FLAG (ri->flags, flag); |
| 285 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame] | 286 | /* 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 Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 288 | return; |
| 289 | |
| 290 | bgp_pcount_adjust (rn, ri); |
| 291 | } |
| 292 | |
| 293 | void |
| 294 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 295 | { |
| 296 | UNSET_FLAG (ri->flags, flag); |
| 297 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame] | 298 | /* 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 Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 300 | return; |
| 301 | |
| 302 | bgp_pcount_adjust (rn, ri); |
| 303 | } |
| 304 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 305 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 306 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 307 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 308 | bgp_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)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 315 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 316 | else |
| 317 | return 0; |
| 318 | } |
| 319 | } |
| 320 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 321 | /* 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 */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 324 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 325 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 326 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 327 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 328 | struct attr *newattr, *existattr; |
| 329 | struct attr_extra *newattre, *existattre; |
| 330 | bgp_peer_sort_t new_sort; |
| 331 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 332 | 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] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 336 | u_int32_t new_weight; |
| 337 | u_int32_t exist_weight; |
| 338 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 339 | struct in_addr new_id; |
| 340 | struct in_addr exist_id; |
| 341 | int new_cluster; |
| 342 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 343 | int internal_as_route; |
| 344 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 345 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 346 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 347 | /* 0. Null check. */ |
| 348 | if (new == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 349 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 350 | if (exist == NULL) |
| 351 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 352 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 353 | newattr = new->attr; |
| 354 | existattr = exist->attr; |
| 355 | newattre = newattr->extra; |
| 356 | existattre = existattr->extra; |
| 357 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 358 | /* 1. Weight check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 359 | new_weight = exist_weight = 0; |
| 360 | |
| 361 | if (newattre) |
| 362 | new_weight = newattre->weight; |
| 363 | if (existattre) |
| 364 | exist_weight = existattre->weight; |
| 365 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 366 | if (new_weight > exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 367 | return -1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 368 | if (new_weight < exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 369 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 370 | |
| 371 | /* 2. Local preference check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 372 | new_pref = exist_pref = bgp->default_local_pref; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 373 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 374 | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 379 | if (new_pref > exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 380 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 381 | if (new_pref < exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 382 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 383 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 384 | /* 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 Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 390 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 391 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 392 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 393 | |
| 394 | /* 4. AS path length check. */ |
| 395 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 396 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 397 | int exist_hops = aspath_count_hops (existattr->aspath); |
| 398 | int exist_confeds = aspath_count_confeds (existattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 399 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 400 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 401 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 402 | int aspath_hops; |
| 403 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 404 | aspath_hops = aspath_count_hops (newattr->aspath); |
| 405 | aspath_hops += aspath_count_confeds (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 406 | |
| 407 | if ( aspath_hops < (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 408 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 409 | if ( aspath_hops > (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 410 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 411 | } |
| 412 | else |
| 413 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 414 | int newhops = aspath_count_hops (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 415 | |
| 416 | if (newhops < exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 417 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 418 | if (newhops > exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 419 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 420 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | /* 5. Origin check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 424 | if (newattr->origin < existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 425 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 426 | if (newattr->origin > existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 427 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 428 | |
| 429 | /* 6. MED check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 430 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 436 | |
| 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] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 440 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
| 441 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 442 | || 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 Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 448 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 449 | if (new_med > exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 450 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | /* 7. Peer type check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 454 | 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 Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 459 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 460 | if (exist_sort == BGP_PEER_EBGP |
| 461 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 462 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 463 | |
| 464 | /* 8. IGP metric check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 465 | newm = existm = 0; |
| 466 | |
| 467 | if (new->extra) |
| 468 | newm = new->extra->igpmetric; |
| 469 | if (exist->extra) |
| 470 | existm = exist->extra->igpmetric; |
| 471 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 472 | if (newm < existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 473 | return -1; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 474 | if (newm > existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 475 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 476 | |
| 477 | /* 9. Maximum path check. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 478 | if (bgp_mpath_is_configured (bgp, afi, safi)) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 479 | { |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 480 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) |
| 481 | { |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 482 | /* |
| 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 Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 491 | } |
| 492 | else if (new->peer->sort == BGP_PEER_IBGP) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 493 | { |
| 494 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 495 | return 0; |
| 496 | } |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 497 | else if (new->peer->as == exist->peer->as) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 498 | return 0; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 499 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 500 | |
| 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] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 506 | && new_sort == BGP_PEER_EBGP |
| 507 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | { |
| 509 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 510 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 512 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 513 | } |
| 514 | |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 515 | /* 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] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 520 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 521 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 522 | else |
| 523 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 524 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 525 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 526 | 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 Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 530 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 531 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 532 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 533 | |
| 534 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 535 | 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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 541 | |
| 542 | if (new_cluster < exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 543 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | if (new_cluster > exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 545 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 546 | |
| 547 | /* 13. Neighbor address comparision. */ |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 548 | /* 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 Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 552 | return -1; |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 553 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 554 | return 1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 555 | /* locally configured routes to advertise do not have su_remote */ |
| 556 | if (new->peer->su_remote == NULL) |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 557 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 558 | if (exist->peer->su_remote == NULL) |
| 559 | return -1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 560 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 561 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 562 | |
| 563 | if (ret == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 564 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 565 | if (ret == -1) |
| 566 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 567 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 568 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 569 | } |
| 570 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 571 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 572 | bgp_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 Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 579 | #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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 588 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 589 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 590 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 591 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 592 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 593 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 594 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 595 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 596 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 597 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 599 | if (FILTER_LIST_IN_NAME (filter)) { |
| 600 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 601 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 602 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 603 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 604 | } |
| 605 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 606 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 607 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 608 | } |
| 609 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 610 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 611 | bgp_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 Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 618 | #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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 627 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 628 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 629 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 630 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 631 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 632 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 633 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 634 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 635 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 636 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 637 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 638 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 639 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 640 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 641 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 642 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 643 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 644 | |
| 645 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 646 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 650 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 651 | bgp_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] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 660 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 661 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 662 | return 1; |
| 663 | |
| 664 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 665 | if (peer->sort == BGP_PEER_EBGP |
| 666 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 667 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 668 | return 1; |
| 669 | } |
| 670 | return 0; |
| 671 | } |
| 672 | |
| 673 | /* Route reflection loop check. */ |
| 674 | static int |
| 675 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 676 | { |
| 677 | struct in_addr cluster_id; |
| 678 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 679 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 680 | { |
| 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 686 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 687 | return 1; |
| 688 | } |
| 689 | return 0; |
| 690 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 691 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 692 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 693 | bgp_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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 703 | if (peer->weight) |
| 704 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 705 | |
| 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 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 713 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 714 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 715 | /* Apply BGP route map to the attribute. */ |
| 716 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 717 | |
| 718 | peer->rmap_type = 0; |
| 719 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 720 | if (ret == RMAP_DENYMATCH) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 721 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 722 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | } |
| 724 | return RMAP_PERMIT; |
| 725 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 726 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 727 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 728 | bgp_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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 761 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 762 | bgp_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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 772 | if (peer->weight) |
| 773 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 774 | |
| 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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 798 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 799 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 800 | bgp_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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 806 | struct peer *from; |
| 807 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 808 | int transparent; |
| 809 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 810 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 811 | |
| 812 | from = ri->peer; |
| 813 | filter = &peer->filter[afi][safi]; |
| 814 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 815 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 816 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 817 | if (DISABLE_BGP_ANNOUNCE) |
| 818 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 819 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 820 | /* 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 824 | /* Do not send back route to sender. */ |
| 825 | if (from == peer) |
| 826 | return 0; |
| 827 | |
| 828 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 829 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 830 | 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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 838 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 839 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 840 | } |
| 841 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 842 | /* 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 849 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 850 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | return 0; |
| 852 | |
| 853 | /* If the attribute has originator-id and it is same as remote |
| 854 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 855 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 856 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 857 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 858 | { |
| 859 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 860 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 861 | "%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 Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 880 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 881 | { |
| 882 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 883 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 884 | "%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 Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 893 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 894 | { |
| 895 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 896 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 897 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 898 | peer->host, peer->as); |
| 899 | return 0; |
| 900 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 901 | |
| 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 Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 905 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 906 | { |
| 907 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 908 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 909 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 910 | peer->host, |
| 911 | bgp->confed_id); |
| 912 | return 0; |
| 913 | } |
| 914 | } |
Thorvald Natvig | 95509a6 | 2016-09-29 10:25:35 -0700 | [diff] [blame] | 915 | #endif /* BGP_SEND_ASPATH_CHECK */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 916 | |
| 917 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 918 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 919 | 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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 945 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 946 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 947 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 948 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 949 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 950 | if ((peer->sort == BGP_PEER_IBGP |
| 951 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 952 | && (! (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 Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 958 | /* 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 969 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 970 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 971 | && 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 978 | |
| 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 983 | #define NEXTHOP_IS_V6 (\ |
| 984 | (safi != SAFI_ENCAP && p->family == AF_INET6) || \ |
| 985 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 986 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 987 | /* next-hop-set */ |
Timo Teräs | 9e7a53c | 2014-04-24 10:22:37 +0300 | [diff] [blame] | 988 | if (transparent |
| 989 | || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 990 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 991 | && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 992 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 993 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 994 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 995 | { |
| 996 | /* NEXT-HOP Unchanged. */ |
| 997 | } |
| 998 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 999 | || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1000 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1001 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1002 | || (peer->sort == BGP_PEER_EBGP |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 1003 | && (bgp_multiaccess_check_v4 (attr->nexthop, peer) == 0))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1004 | { |
| 1005 | /* Set IPv4 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1006 | if (NEXTHOP_IS_V4) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1007 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1008 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1009 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1010 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1011 | else |
| 1012 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1013 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1014 | /* Set IPv6 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1015 | if (NEXTHOP_IS_V6) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1016 | { |
| 1017 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1018 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1019 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1020 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1021 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1024 | if (p->family == AF_INET6 && safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1025 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1026 | /* Left nexthop_local unchanged if so configured. */ |
| 1027 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1028 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1029 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1030 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1031 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1032 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1033 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1034 | } |
| 1035 | |
| 1036 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1037 | else |
| 1038 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1039 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1040 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1041 | |
| 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1046 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1047 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1048 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1052 | address.*/ |
| 1053 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1054 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1055 | |
| 1056 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1057 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1058 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1059 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1060 | |
| 1061 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1062 | |
| 1063 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1064 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1065 | && 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1071 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1072 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1073 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1074 | struct attr dummy_attr; |
| 1075 | struct attr_extra dummy_extra; |
| 1076 | |
| 1077 | dummy_attr.extra = &dummy_extra; |
| 1078 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1079 | info.peer = peer; |
| 1080 | info.attr = attr; |
| 1081 | |
| 1082 | /* The route reflector is not allowed to modify the attributes |
Dinesh Dutt | 083e5e2 | 2015-11-09 20:21:54 -0500 | [diff] [blame] | 1083 | 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)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1086 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1087 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1088 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1089 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1090 | |
| 1091 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1092 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1093 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1094 | 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 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1098 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1099 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1100 | if (ret == RMAP_DENYMATCH) |
| 1101 | { |
| 1102 | bgp_attr_flush (attr); |
| 1103 | return 0; |
| 1104 | } |
| 1105 | } |
| 1106 | return 1; |
| 1107 | } |
| 1108 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1109 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1110 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1111 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1112 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1113 | int ret; |
| 1114 | char buf[SU_ADDRSTRLEN]; |
| 1115 | struct bgp_filter *filter; |
| 1116 | struct bgp_info info; |
| 1117 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1118 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1119 | |
| 1120 | from = ri->peer; |
| 1121 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1122 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1123 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1124 | if (DISABLE_BGP_ANNOUNCE) |
| 1125 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1126 | |
| 1127 | /* Do not send back route to sender. */ |
| 1128 | if (from == rsclient) |
| 1129 | return 0; |
| 1130 | |
| 1131 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1132 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1133 | 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; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1142 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1143 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1144 | } |
| 1145 | |
| 1146 | /* If the attribute has originator-id and it is same as remote |
| 1147 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1148 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1149 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1150 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1151 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1152 | { |
| 1153 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1154 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1155 | "%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 Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1174 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1175 | { |
| 1176 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1177 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1178 | "%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 Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1187 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1188 | { |
| 1189 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1190 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1191 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1192 | 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 Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1198 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1199 | |
| 1200 | /* next-hop-set */ |
| 1201 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1202 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1203 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1204 | ) |
| 1205 | { |
| 1206 | /* Set IPv4 nexthop. */ |
| 1207 | if (p->family == AF_INET) |
| 1208 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1209 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1210 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1211 | IPV4_MAX_BYTELEN); |
| 1212 | else |
| 1213 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1214 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1215 | /* Set IPv6 nexthop. */ |
| 1216 | if (p->family == AF_INET6) |
| 1217 | { |
| 1218 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1219 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1220 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1221 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1222 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | } |
| 1224 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1225 | if (p->family == AF_INET6) |
| 1226 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1227 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1228 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1229 | /* Left nexthop_local unchanged if so configured. */ |
| 1230 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1231 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1232 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1233 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1234 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1235 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1236 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1237 | } |
| 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1246 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1247 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1248 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1249 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1250 | } |
| 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1256 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1257 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1258 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1262 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1266 | |
| 1267 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1268 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1269 | && 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1274 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1275 | { |
| 1276 | info.peer = rsclient; |
| 1277 | info.attr = attr; |
| 1278 | |
| 1279 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1280 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1281 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1282 | 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 | |
| 1298 | struct bgp_info_pair |
| 1299 | { |
| 1300 | struct bgp_info *old; |
| 1301 | struct bgp_info *new; |
| 1302 | }; |
| 1303 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1304 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1305 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1306 | struct bgp_info_pair *result, |
| 1307 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1308 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1309 | struct bgp_info *new_select; |
| 1310 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1311 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1312 | struct bgp_info *ri1; |
| 1313 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1314 | struct bgp_info *nextri = NULL; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1315 | int cmpret, do_mpath; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1316 | struct list mp_list; |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1317 | |
| 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 Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1329 | bgp_mp_list_init (&mp_list); |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1330 | do_mpath = bgp_mpath_is_configured (bgp, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1331 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1332 | /* 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 Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1341 | if (ri1->peer && ri1->peer != bgp->peer_self) |
| 1342 | if (ri1->peer->status != Established) |
| 1343 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1344 | |
| 1345 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1346 | if (do_mpath) |
| 1347 | bgp_mp_list_add (&mp_list, ri1); |
| 1348 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1349 | 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 Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1356 | 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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | |
| 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 Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1366 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1367 | old_select = ri2; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1368 | if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi)) |
| 1369 | == -1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1370 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1371 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1372 | new_select = ri2; |
| 1373 | } |
| 1374 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1375 | 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 Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1383 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1384 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1385 | } |
| 1386 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1387 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1388 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1389 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1390 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1391 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | /* Check old selected route and new selected route. */ |
| 1395 | old_select = NULL; |
| 1396 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1397 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1398 | { |
| 1399 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1400 | old_select = ri; |
| 1401 | |
| 1402 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1403 | { |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1413 | |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1414 | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1420 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1421 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1422 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1423 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1424 | continue; |
| 1425 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1426 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1427 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1428 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1429 | if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1430 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1431 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1432 | bgp_mp_dmed_deselect (new_select); |
| 1433 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1434 | new_select = ri; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1435 | } |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1436 | else if (cmpret == 1 && do_mpath |
| 1437 | && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1438 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1439 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1440 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1448 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1449 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1450 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1451 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1452 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1453 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1454 | bgp_mp_list_clear (&mp_list); |
| 1455 | |
| 1456 | result->old = old_select; |
| 1457 | result->new = new_select; |
| 1458 | |
| 1459 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1460 | } |
| 1461 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1462 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1463 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1464 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1465 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1466 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1467 | struct attr attr; |
| 1468 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1469 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1470 | memset (&attr, 0, sizeof(struct attr)); |
| 1471 | memset (&extra, 0, sizeof(struct attr_extra)); |
| 1472 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | p = &rn->p; |
| 1474 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1475 | /* Announce route to Established peer. */ |
| 1476 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1477 | return 0; |
| 1478 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1479 | /* Address family configuration check. */ |
| 1480 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1481 | return 0; |
| 1482 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1483 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1484 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1485 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1486 | return 0; |
| 1487 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1488 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1489 | attr.extra = &extra; |
| 1490 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1491 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1492 | { |
| 1493 | case BGP_TABLE_MAIN: |
| 1494 | /* Announcement to peer->conf. If the route is filtered, |
| 1495 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1496 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1497 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1498 | 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 Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1504 | 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); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1509 | break; |
| 1510 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1511 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1512 | bgp_attr_flush (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1513 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1514 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1515 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1516 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1517 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1518 | struct bgp *bgp; |
| 1519 | struct bgp_node *rn; |
| 1520 | afi_t afi; |
| 1521 | safi_t safi; |
| 1522 | }; |
| 1523 | |
| 1524 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1525 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1526 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1527 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1528 | struct bgp *bgp = pq->bgp; |
| 1529 | struct bgp_node *rn = pq->rn; |
| 1530 | afi_t afi = pq->afi; |
| 1531 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1532 | struct bgp_info *new_select; |
| 1533 | struct bgp_info *old_select; |
| 1534 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1535 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1536 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1537 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1538 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1539 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1540 | new_select = old_and_new.new; |
| 1541 | old_select = old_and_new.old; |
| 1542 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1543 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1544 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1545 | 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; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1552 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1553 | 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 Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1559 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1560 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1561 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1562 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1563 | afi, safi); |
| 1564 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1565 | } |
| 1566 | else |
| 1567 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1568 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1569 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1570 | if (new_select) |
| 1571 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1572 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1573 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1574 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1575 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1576 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1577 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1578 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1579 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1580 | bgp_info_reap (rn, old_select); |
| 1581 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1582 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1583 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1584 | } |
| 1585 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1586 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1587 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1588 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1589 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1590 | 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; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1595 | struct bgp_info *new_select; |
| 1596 | struct bgp_info *old_select; |
| 1597 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1598 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1599 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1600 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1601 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1602 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1603 | old_select = old_and_new.old; |
| 1604 | new_select = old_and_new.new; |
| 1605 | |
| 1606 | /* Nothing to do. */ |
Daniel Walton | 325fcfb | 2015-05-19 17:58:10 -0700 | [diff] [blame] | 1607 | if (old_select && old_select == new_select |
| 1608 | && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1609 | { |
| 1610 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1611 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1612 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1613 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1614 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1615 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1616 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1617 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1618 | return WQ_SUCCESS; |
| 1619 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1620 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1621 | |
Daniel Walton | 325fcfb | 2015-05-19 17:58:10 -0700 | [diff] [blame] | 1622 | /* 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 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1625 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1626 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1627 | if (new_select) |
| 1628 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1629 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1630 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1631 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1632 | } |
| 1633 | |
| 1634 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1635 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1636 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1638 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1639 | } |
| 1640 | |
| 1641 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1642 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1643 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1644 | { |
| 1645 | if (new_select |
| 1646 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1647 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1648 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1649 | 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.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1655 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1656 | } |
| 1657 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1658 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1659 | /* Reap old select bgp_info, if it has been removed */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1660 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1661 | bgp_info_reap (rn, old_select); |
| 1662 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1663 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1664 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1665 | } |
| 1666 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1667 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1668 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1669 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1670 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1671 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1672 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1673 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1674 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1675 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1676 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1677 | } |
| 1678 | |
| 1679 | static void |
| 1680 | bgp_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; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1694 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1695 | bm->process_main_queue->spec.max_retries = 0; |
| 1696 | bm->process_main_queue->spec.hold = 50; |
| 1697 | |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1698 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
David Lamparter | d43f8b3 | 2015-03-03 08:54:54 +0100 | [diff] [blame] | 1699 | 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; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1702 | } |
| 1703 | |
| 1704 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1705 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1706 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1707 | 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 Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1713 | 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 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1726 | 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 Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1734 | |
| 1735 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1736 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1737 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1738 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1739 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1740 | pqnode->afi = afi; |
| 1741 | pqnode->safi = safi; |
| 1742 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1743 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1744 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1745 | 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; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1751 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1752 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1753 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1754 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1755 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1756 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1757 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1758 | bgp_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 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1774 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1775 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1776 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1777 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1778 | 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]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1782 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1783 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1784 | && ! always) |
| 1785 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1786 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1787 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1788 | "%%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]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1791 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1792 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1793 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1794 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1795 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1796 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1797 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1798 | |
| 1799 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1800 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1801 | |
| 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]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1809 | |
| 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 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1814 | |
| 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 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1828 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1829 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1830 | 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, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1840 | "%%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]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1843 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1847 | return 0; |
| 1848 | } |
| 1849 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1850 | /* Unconditionally remove the route from the RIB, without taking |
| 1851 | * damping into consideration (eg, because the session went down) |
| 1852 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1853 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1854 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1855 | afi_t afi, safi_t safi) |
| 1856 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1857 | 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 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1862 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1863 | } |
| 1864 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1865 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1866 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1867 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1868 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1869 | int status = BGP_DAMP_NONE; |
| 1870 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1871 | /* 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] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1875 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1876 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1877 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1878 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1879 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1880 | return; |
| 1881 | } |
| 1882 | |
| 1883 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1884 | } |
| 1885 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 1886 | static struct bgp_info * |
| 1887 | info_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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1903 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1904 | bgp_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] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1910 | struct attr new_attr; |
| 1911 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1912 | struct attr *attr_new; |
| 1913 | struct attr *attr_new2; |
| 1914 | struct bgp_info *ri; |
| 1915 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1916 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1917 | 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 Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1932 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1933 | { |
| 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1940 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1941 | { |
| 1942 | reason = "originator is us;"; |
| 1943 | goto filtered; |
| 1944 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1945 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1946 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1947 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1948 | |
| 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1958 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1959 | /* Apply import policy. */ |
| 1960 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1961 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1962 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1963 | |
| 1964 | reason = "import-policy;"; |
| 1965 | goto filtered; |
| 1966 | } |
| 1967 | |
| 1968 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1969 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1970 | |
| 1971 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1972 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1973 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1974 | /* Next hop must not be 0.0.0.0 nor Class D/E address. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1975 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1976 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1977 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1978 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1979 | |
| 1980 | reason = "martian next-hop;"; |
| 1981 | goto filtered; |
| 1982 | } |
| 1983 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1984 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1985 | /* If the update is implicit withdraw. */ |
| 1986 | if (ri) |
| 1987 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1988 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1989 | |
| 1990 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1991 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1992 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1993 | { |
| 1994 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1995 | |
| 1996 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1997 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1998 | "%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 Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2003 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2004 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2005 | bgp_attr_flush(&new_attr); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2006 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2007 | } |
| 2008 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2009 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2010 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2011 | bgp_info_restore (rn, ri); |
| 2012 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2013 | /* Received Logging. */ |
| 2014 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2015 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2016 | 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 Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2021 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2022 | |
| 2023 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2024 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2025 | ri->attr = attr_new; |
| 2026 | |
| 2027 | /* Update MPLS tag. */ |
| 2028 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2029 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2030 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2031 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2032 | |
| 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 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2043 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2044 | peer->host, |
| 2045 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2046 | p->prefixlen, rsclient->host); |
| 2047 | } |
| 2048 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2049 | new = info_make(type, sub_type, peer, attr_new, rn); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2050 | |
| 2051 | /* Update MPLS tag. */ |
| 2052 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2053 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2054 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2055 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2056 | |
| 2057 | /* Register new BGP information. */ |
| 2058 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2059 | |
| 2060 | /* route_node_get lock */ |
| 2061 | bgp_unlock_node (rn); |
| 2062 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2063 | /* Process change. */ |
| 2064 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2065 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2066 | 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)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2072 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2073 | "%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) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2079 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2080 | |
| 2081 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2082 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2083 | return; |
| 2084 | } |
| 2085 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2086 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2087 | bgp_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 Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2090 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2091 | struct bgp_node *rn; |
| 2092 | struct bgp_info *ri; |
| 2093 | char buf[SU_ADDRSTRLEN]; |
| 2094 | |
| 2095 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2096 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2097 | |
| 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 Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2107 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2108 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2109 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2110 | "%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 Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2115 | bgp_unlock_node (rn); |
| 2116 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2117 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2118 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2119 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2120 | 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] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2127 | struct attr new_attr; |
| 2128 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2129 | struct attr *attr_new; |
| 2130 | struct bgp_info *ri; |
| 2131 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2132 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2133 | char buf[SU_ADDRSTRLEN]; |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2134 | int connected = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2135 | |
Lou Berger | 370b7e5 | 2016-02-04 21:29:49 -0500 | [diff] [blame] | 2136 | memset (&new_attr, 0, sizeof(struct attr)); |
| 2137 | memset (&new_extra, 0, sizeof(struct attr_extra)); |
| 2138 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2139 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2140 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2141 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2142 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2143 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2144 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2145 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2146 | 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2178 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2179 | { |
| 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] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2198 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2199 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2200 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2201 | /* 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) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2205 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2206 | { |
| 2207 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2208 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2209 | goto filtered; |
| 2210 | } |
| 2211 | |
| 2212 | /* IPv4 unicast next hop check. */ |
| 2213 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2214 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2215 | /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2216 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2217 | if (new_attr.nexthop.s_addr == 0 |
| 2218 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2219 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2220 | { |
| 2221 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2222 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2223 | 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 Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2232 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2233 | |
| 2234 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2235 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2236 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2237 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2238 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2239 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2240 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2241 | { |
| 2242 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2243 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2244 | peer->host, |
| 2245 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2246 | p->prefixlen); |
| 2247 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2248 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2253 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2254 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2255 | { |
| 2256 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2257 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2258 | "%s rcvd %s/%d...duplicate ignored", |
| 2259 | peer->host, |
| 2260 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2261 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2262 | |
| 2263 | /* graceful restart STALE flag unset. */ |
| 2264 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2265 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2266 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2267 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2268 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2269 | } |
| 2270 | |
| 2271 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2272 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2273 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2274 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2275 | return 0; |
| 2276 | } |
| 2277 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2278 | /* 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2289 | /* Received Logging. */ |
| 2290 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2291 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2292 | peer->host, |
| 2293 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2294 | p->prefixlen); |
| 2295 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2296 | /* graceful restart STALE flag unset. */ |
| 2297 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2298 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2299 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2301 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2302 | |
| 2303 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2304 | * only if update is accepted, they'll increment below. |
| 2305 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2306 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2308 | /* Update bgp route dampening information. */ |
| 2309 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2310 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | { |
| 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | } |
| 2317 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2318 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2319 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2320 | ri->attr = attr_new; |
| 2321 | |
| 2322 | /* Update MPLS tag. */ |
| 2323 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2324 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2325 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2326 | bgp_attr_flush (&new_attr); |
| 2327 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | /* Update bgp route dampening information. */ |
| 2329 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2330 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2331 | { |
| 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 Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2342 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2343 | { |
Timo Teräs | e3443a2 | 2016-10-19 16:02:34 +0300 | [diff] [blame] | 2344 | if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 && |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2345 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
| 2346 | connected = 1; |
| 2347 | else |
| 2348 | connected = 0; |
| 2349 | |
Paul Jakma | 3dda6b3 | 2016-09-06 16:57:40 +0100 | [diff] [blame] | 2350 | if (bgp_ensure_nexthop (ri, NULL, connected)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2351 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2352 | else |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2353 | { |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2362 | } |
| 2363 | else |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2364 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2365 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2366 | bgp_attr_flush (&new_attr); |
| 2367 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2368 | /* 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] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2373 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2374 | return 0; |
| 2375 | } |
| 2376 | |
| 2377 | /* Received Logging. */ |
| 2378 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2379 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2380 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2381 | peer->host, |
| 2382 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2383 | p->prefixlen); |
| 2384 | } |
| 2385 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2386 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2387 | new = info_make(type, sub_type, peer, attr_new, rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2388 | |
| 2389 | /* Update MPLS tag. */ |
| 2390 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2391 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2392 | |
| 2393 | /* Nexthop reachability check. */ |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2394 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2395 | { |
Timo Teräs | e3443a2 | 2016-10-19 16:02:34 +0300 | [diff] [blame] | 2396 | if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 && |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2397 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
| 2398 | connected = 1; |
| 2399 | else |
| 2400 | connected = 0; |
| 2401 | |
Paul Jakma | 3dda6b3 | 2016-09-06 16:57:40 +0100 | [diff] [blame] | 2402 | if (bgp_ensure_nexthop (new, NULL, connected)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2403 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2404 | else |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2405 | { |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2414 | } |
| 2415 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2416 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2417 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2418 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2419 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2420 | |
| 2421 | /* Register new BGP information. */ |
| 2422 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2423 | |
| 2424 | /* route_node_get lock */ |
| 2425 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2426 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2427 | bgp_attr_flush (&new_attr); |
| 2428 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2429 | /* If maximum prefix count is configured and current prefix |
| 2430 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2431 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2432 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2433 | |
| 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)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2443 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2444 | "%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) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2450 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2451 | |
| 2452 | bgp_unlock_node (rn); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2453 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2454 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2455 | return 0; |
| 2456 | } |
| 2457 | |
| 2458 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2459 | bgp_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; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2464 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2465 | 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. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2474 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2475 | { |
| 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 | |
| 2484 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2485 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2486 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2487 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2488 | { |
| 2489 | struct bgp *bgp; |
| 2490 | char buf[SU_ADDRSTRLEN]; |
| 2491 | struct bgp_node *rn; |
| 2492 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2493 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2494 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2495 | |
| 2496 | bgp = peer->bgp; |
| 2497 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2498 | /* 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 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2519 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2520 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2521 | { |
| 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2526 | /* Logging. */ |
| 2527 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2528 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2529 | peer->host, |
| 2530 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2531 | p->prefixlen); |
| 2532 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2533 | /* 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 Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2540 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2541 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2542 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2543 | "%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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2552 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2553 | void |
| 2554 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2555 | { |
| 2556 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2557 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2558 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2559 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2560 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2561 | struct bgp_node *rn; |
| 2562 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2563 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2564 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2565 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2566 | return; |
| 2567 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2568 | bgp = peer->bgp; |
| 2569 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2570 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2571 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2578 | else if (afi == AFI_IP6) |
| 2579 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2580 | struct attr_extra *ae = attr.extra; |
| 2581 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2582 | str2prefix ("::/0", &p); |
| 2583 | |
| 2584 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2585 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2586 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2587 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2588 | |
| 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2594 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2595 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2596 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2597 | } |
| 2598 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2599 | |
| 2600 | if (peer->default_rmap[afi][safi].name) |
| 2601 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2602 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2603 | 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; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2610 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2611 | /* 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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2616 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2617 | 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 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2629 | bgp->peer_self->rmap_type = 0; |
| 2630 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2631 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2632 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2633 | } |
| 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 Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2643 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2648 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2649 | |
| 2650 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2651 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2652 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2653 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2654 | static void |
| 2655 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2656 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2657 | { |
| 2658 | struct bgp_node *rn; |
| 2659 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2660 | struct attr attr; |
| 2661 | struct attr_extra extra; |
| 2662 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2663 | memset(&extra, 0, sizeof(extra)); |
| 2664 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2665 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2666 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2667 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2668 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2669 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2670 | bgp_default_originate (peer, afi, safi, 0); |
| 2671 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2672 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2673 | attr.extra = &extra; |
| 2674 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2675 | 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 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2679 | 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))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2682 | 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2686 | |
| 2687 | bgp_attr_flush_encap(&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2688 | } |
| 2689 | |
| 2690 | void |
| 2691 | bgp_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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2706 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2707 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2708 | 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) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2712 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2716 | } |
| 2717 | |
| 2718 | void |
| 2719 | bgp_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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2728 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2729 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2730 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2731 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2732 | { |
| 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] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2742 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2743 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2744 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2745 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2746 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2747 | } |
| 2748 | } |
| 2749 | |
| 2750 | void |
| 2751 | bgp_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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2756 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2757 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2758 | |
| 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] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2763 | { |
| 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 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2771 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2772 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2773 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2774 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2775 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2776 | { |
| 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] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2789 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2790 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2791 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2792 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2793 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2794 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2795 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2796 | if (ret < 0) |
| 2797 | { |
| 2798 | bgp_unlock_node (rn); |
| 2799 | return; |
| 2800 | } |
| 2801 | continue; |
| 2802 | } |
| 2803 | } |
| 2804 | } |
| 2805 | |
| 2806 | void |
| 2807 | bgp_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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2815 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2816 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2817 | 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] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2821 | { |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2829 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2830 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2831 | |
| 2832 | struct bgp_clear_node_queue |
| 2833 | { |
| 2834 | struct bgp_node *rn; |
| 2835 | enum bgp_clear_route_type purpose; |
| 2836 | }; |
| 2837 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2838 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2839 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2840 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2841 | struct bgp_clear_node_queue *cnq = data; |
| 2842 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2843 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2844 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2845 | afi_t afi = bgp_node_table (rn)->afi; |
| 2846 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2847 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2848 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2849 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2850 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2851 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2852 | { |
| 2853 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2854 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2855 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2856 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2857 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2858 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2859 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2860 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2861 | break; |
| 2862 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2863 | return WQ_SUCCESS; |
| 2864 | } |
| 2865 | |
| 2866 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2867 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2868 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2869 | struct bgp_clear_node_queue *cnq = data; |
| 2870 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2871 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2872 | |
| 2873 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2874 | bgp_table_unlock (table); |
| 2875 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2876 | } |
| 2877 | |
| 2878 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2879 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2880 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2881 | struct peer *peer = wq->spec.data; |
| 2882 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2883 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2884 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2885 | |
| 2886 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2887 | } |
| 2888 | |
| 2889 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2890 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2891 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2892 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2893 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2894 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2895 | #undef CLEAR_QUEUE_NAME_LEN |
| 2896 | |
| 2897 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2898 | { |
| 2899 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2900 | exit (1); |
| 2901 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2902 | 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; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2910 | } |
| 2911 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2912 | static void |
| 2913 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2914 | struct bgp_table *table, struct peer *rsclient, |
| 2915 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2916 | { |
| 2917 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2918 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2919 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2920 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2921 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2922 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2923 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2924 | if (! table) |
| 2925 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2926 | |
| 2927 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2928 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2929 | struct bgp_info *ri; |
| 2930 | struct bgp_adj_in *ain; |
| 2931 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2932 | |
| 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] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2964 | 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 Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2979 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2980 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2981 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2982 | struct bgp_clear_node_queue *cnq; |
| 2983 | |
| 2984 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2985 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2986 | 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 Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2993 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2994 | } |
| 2995 | return; |
| 2996 | } |
| 2997 | |
| 2998 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2999 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 3000 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3001 | { |
| 3002 | struct bgp_node *rn; |
| 3003 | struct bgp_table *table; |
| 3004 | struct peer *rsclient; |
| 3005 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 3006 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3007 | if (peer->clear_node_queue == NULL) |
| 3008 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3009 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3010 | /* 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 Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3014 | * |
| 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. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3021 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3022 | |
| 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 Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3027 | if (!peer->clear_node_queue->thread) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3028 | peer_lock (peer); /* bgp_clear_node_complete */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3029 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3030 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3031 | case BGP_CLEAR_ROUTE_NORMAL: |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3032 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3033 | 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 Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3047 | /* |
| 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 Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3052 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3053 | break; |
| 3054 | |
| 3055 | default: |
| 3056 | assert (0); |
| 3057 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3058 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3059 | |
| 3060 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3061 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3062 | peer_unlock (peer); |
| 3063 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3064 | } |
| 3065 | |
| 3066 | void |
| 3067 | bgp_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 Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3074 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3075 | } |
| 3076 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3077 | /* |
| 3078 | * Finish freeing things when exiting |
| 3079 | */ |
| 3080 | static void |
| 3081 | bgp_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 | */ |
| 3107 | void |
| 3108 | bgp_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 | */ |
| 3121 | void |
| 3122 | bgp_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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3128 | void |
| 3129 | bgp_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 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3146 | |
| 3147 | void |
| 3148 | bgp_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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3167 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3168 | static void |
| 3169 | bgp_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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3186 | /* Delete all kernel routes. */ |
| 3187 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3188 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3189 | { |
| 3190 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3191 | struct listnode *node, *nnode; |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3192 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3193 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3194 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3195 | { |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3196 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
| 3197 | { |
| 3198 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3199 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3200 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3201 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3202 | /* |
| 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3207 | { |
| 3208 | if (rn->info) |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3209 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3210 | 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 Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3214 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3215 | } |
| 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 Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3228 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3229 | } |
| 3230 | } |
| 3231 | |
| 3232 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3233 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3234 | { |
| 3235 | vty_reset (); |
| 3236 | bgp_zclient_reset (); |
| 3237 | access_list_reset (); |
| 3238 | prefix_list_reset (); |
| 3239 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3240 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3241 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3242 | value. */ |
| 3243 | int |
Paul Jakma | 518a4b7 | 2016-02-04 13:27:04 +0000 | [diff] [blame] | 3244 | bgp_nlri_parse_ip (struct peer *peer, struct attr *attr, |
| 3245 | struct bgp_nlri *packet) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3246 | { |
| 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 Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3260 | /* 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. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3263 | 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 Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3270 | /* afi/safi validity already verified by caller, bgp_update_receive */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3271 | p.family = afi2family (packet->afi); |
| 3272 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3273 | /* 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3283 | /* Packet size overflow check. */ |
| 3284 | psize = PSIZE (p.prefixlen); |
| 3285 | |
| 3286 | /* When packet overflow occur return immediately. */ |
| 3287 | if (pnt + psize > lim) |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3288 | { |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3305 | |
| 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 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3314 | /* |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3315 | * 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. |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3320 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3321 | zlog (peer->log, LOG_ERR, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3322 | "%s: IPv4 unicast NLRI is multicast address %s, ignoring", |
| 3323 | peer->host, inet_ntoa (p.u.prefix4)); |
| 3324 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3325 | } |
| 3326 | } |
| 3327 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3328 | /* 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 Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3335 | zlog (peer->log, LOG_ERR, |
| 3336 | "%s: IPv6 unicast NLRI is link-local address %s, ignoring", |
| 3337 | peer->host, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3338 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3339 | continue; |
| 3340 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3341 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3352 | |
| 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) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3369 | { |
| 3370 | plog_err (peer->log, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3371 | "%s [Error] Update packet error" |
| 3372 | " (prefix length mismatch with total length)", |
| 3373 | peer->host); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3374 | return -1; |
| 3375 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3376 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3377 | return 0; |
| 3378 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3379 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3380 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3381 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3382 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3383 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3384 | } |
| 3385 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3386 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3387 | bgp_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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3394 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3395 | bgp_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 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3413 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3414 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3415 | } |
| 3416 | |
| 3417 | /* Unlock bgp_node_lookup. */ |
| 3418 | bgp_unlock_node (rn); |
| 3419 | } |
| 3420 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3421 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3422 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3423 | struct bgp_static *bgp_static, |
| 3424 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3425 | { |
| 3426 | struct bgp_node *rn; |
| 3427 | struct bgp_info *ri; |
| 3428 | struct bgp_info *new; |
| 3429 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3430 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3431 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3432 | struct attr new_attr; |
| 3433 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3434 | struct bgp *bgp; |
| 3435 | int ret; |
| 3436 | char buf[SU_ADDRSTRLEN]; |
| 3437 | |
| 3438 | bgp = rsclient->bgp; |
| 3439 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3440 | assert (bgp_static); |
| 3441 | if (!bgp_static) |
| 3442 | return; |
| 3443 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3444 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3445 | |
| 3446 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3447 | |
| 3448 | attr.nexthop = bgp_static->igpnexthop; |
| 3449 | attr.med = bgp_static->igpmetric; |
| 3450 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3451 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3452 | if (bgp_static->atomic) |
| 3453 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3454 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3455 | /* Apply network route-map for export to this rsclient. */ |
| 3456 | if (bgp_static->rmap.name) |
| 3457 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3458 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3459 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3460 | info.attr = &attr_tmp; |
| 3461 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3462 | 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3472 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3473 | |
| 3474 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3475 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3476 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3477 | bgp_attr_extra_free (&attr); |
| 3478 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3479 | return; |
| 3480 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3481 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3482 | } |
| 3483 | else |
| 3484 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3485 | |
| 3486 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3487 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3488 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3489 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3490 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3491 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3492 | == RMAP_DENY) |
| 3493 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3494 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3495 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3496 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3497 | "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 Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3503 | bgp_attr_unintern (&attr_new); |
| 3504 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3505 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3506 | |
| 3507 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3508 | |
| 3509 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3510 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3511 | |
| 3512 | bgp->peer_self->rmap_type = 0; |
| 3513 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3514 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3515 | 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. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3524 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3525 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3526 | { |
| 3527 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3528 | bgp_attr_unintern (&attr_new); |
| 3529 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3530 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3531 | return; |
| 3532 | } |
| 3533 | else |
| 3534 | { |
| 3535 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3536 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3537 | |
| 3538 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3539 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3540 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3541 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3542 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3543 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3544 | |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3545 | /* Nexthop reachability check. */ |
| 3546 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3547 | { |
Paul Jakma | 3dda6b3 | 2016-09-06 16:57:40 +0100 | [diff] [blame] | 3548 | if (bgp_ensure_nexthop (ri, NULL, 0)) |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3549 | 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 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3562 | /* Process change. */ |
| 3563 | bgp_process (bgp, rn, afi, safi); |
| 3564 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3565 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3566 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3567 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3568 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3569 | } |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3570 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3571 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3572 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3573 | attr_new, rn); |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3574 | /* Nexthop reachability check. */ |
| 3575 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3576 | { |
Paul Jakma | 3dda6b3 | 2016-09-06 16:57:40 +0100 | [diff] [blame] | 3577 | if (bgp_ensure_nexthop (new, NULL, 0)) |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3578 | 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); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3593 | |
| 3594 | /* Register new BGP information. */ |
| 3595 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3596 | |
| 3597 | /* route_node_get lock */ |
| 3598 | bgp_unlock_node (rn); |
| 3599 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3600 | /* Process change. */ |
| 3601 | bgp_process (bgp, rn, afi, safi); |
| 3602 | |
| 3603 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3604 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3605 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3606 | } |
| 3607 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3608 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3609 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3610 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3611 | { |
| 3612 | struct bgp_node *rn; |
| 3613 | struct bgp_info *ri; |
| 3614 | struct bgp_info *new; |
| 3615 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3616 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3617 | struct attr *attr_new; |
| 3618 | int ret; |
| 3619 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3620 | assert (bgp_static); |
| 3621 | if (!bgp_static) |
| 3622 | return; |
| 3623 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3624 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3625 | |
| 3626 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3627 | |
| 3628 | attr.nexthop = bgp_static->igpnexthop; |
| 3629 | attr.med = bgp_static->igpmetric; |
| 3630 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3631 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3632 | if (bgp_static->atomic) |
| 3633 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3634 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3635 | /* Apply route-map. */ |
| 3636 | if (bgp_static->rmap.name) |
| 3637 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3638 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3639 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3640 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3641 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3642 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3644 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3645 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3646 | bgp->peer_self->rmap_type = 0; |
| 3647 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3648 | if (ret == RMAP_DENYMATCH) |
| 3649 | { |
| 3650 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3651 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3652 | |
| 3653 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3654 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3655 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3656 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3657 | return; |
| 3658 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3659 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3660 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3661 | else |
| 3662 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3663 | |
| 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. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3671 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3672 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3673 | { |
| 3674 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3675 | bgp_attr_unintern (&attr_new); |
| 3676 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3677 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3678 | return; |
| 3679 | } |
| 3680 | else |
| 3681 | { |
| 3682 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3683 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3684 | |
| 3685 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3686 | 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 Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3690 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3691 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3692 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3693 | |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3694 | /* Nexthop reachability check. */ |
| 3695 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3696 | { |
Paul Jakma | 3dda6b3 | 2016-09-06 16:57:40 +0100 | [diff] [blame] | 3697 | if (bgp_ensure_nexthop (ri, NULL, 0)) |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3698 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3711 | /* Process change. */ |
| 3712 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3713 | bgp_process (bgp, rn, afi, safi); |
| 3714 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3715 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3716 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3717 | return; |
| 3718 | } |
| 3719 | } |
| 3720 | |
| 3721 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3722 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new, |
| 3723 | rn); |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3724 | /* Nexthop reachability check. */ |
| 3725 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3726 | { |
Paul Jakma | 3dda6b3 | 2016-09-06 16:57:40 +0100 | [diff] [blame] | 3727 | if (bgp_ensure_nexthop (new, NULL, 0)) |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3728 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3743 | |
| 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); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3749 | |
| 3750 | /* route_node_get lock */ |
| 3751 | bgp_unlock_node (rn); |
| 3752 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3753 | /* Process change. */ |
| 3754 | bgp_process (bgp, rn, afi, safi); |
| 3755 | |
| 3756 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3757 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3758 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3759 | } |
| 3760 | |
| 3761 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3762 | bgp_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; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3766 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3767 | |
| 3768 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3769 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3770 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3771 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3772 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3773 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3774 | } |
| 3775 | } |
| 3776 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3777 | void |
| 3778 | bgp_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 Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3784 | /* Make new BGP info. */ |
| 3785 | rn = bgp_node_get (bgp->rib[afi][safi], p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3786 | |
| 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 Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3798 | bgp_unlink_nexthop(ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3799 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3800 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3801 | } |
| 3802 | |
| 3803 | /* Unlock bgp_node_lookup. */ |
| 3804 | bgp_unlock_node (rn); |
| 3805 | } |
| 3806 | |
| 3807 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3808 | bgp_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 Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3827 | /* |
| 3828 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP |
| 3829 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3830 | static void |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3831 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3832 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3833 | { |
| 3834 | struct bgp_node *rn; |
| 3835 | struct bgp_info *ri; |
| 3836 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3837 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3838 | |
| 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3850 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3851 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3852 | } |
| 3853 | |
| 3854 | /* Unlock bgp_node_lookup. */ |
| 3855 | bgp_unlock_node (rn); |
| 3856 | } |
| 3857 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3858 | static void |
| 3859 | bgp_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 Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3956 | new = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3957 | attr_new, rn); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3958 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3959 | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3979 | /* Configure static BGP network. When user don't run zebra, static |
| 3980 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3981 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3982 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3983 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3984 | { |
| 3985 | int ret; |
| 3986 | struct prefix p; |
| 3987 | struct bgp_static *bgp_static; |
| 3988 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3989 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3990 | |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3998 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4004 | |
| 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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4016 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 4017 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4018 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4019 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4020 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4021 | 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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4046 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4047 | 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 Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4057 | bgp_static->valid = 1; |
| 4058 | if (need_update) |
| 4059 | bgp_static_withdraw (bgp, &p, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4060 | |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4061 | if (! bgp_static->backdoor) |
| 4062 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4063 | |
| 4064 | return CMD_SUCCESS; |
| 4065 | } |
| 4066 | |
| 4067 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4068 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4069 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 4070 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4071 | { |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4084 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4090 | |
| 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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4102 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4103 | /* 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. */ |
| 4118 | void |
| 4119 | bgp_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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4133 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4134 | { |
| 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 Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4140 | bgp_static_withdraw_safi (bgp, &rm->p, |
| 4141 | AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4142 | (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 Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4160 | /* |
| 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 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4165 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4166 | bgp_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) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4169 | { |
| 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 Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4204 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4205 | (struct prefix *)&prd); |
| 4206 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4207 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4208 | 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 Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4223 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4237 | rn->info = bgp_static; |
| 4238 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4239 | bgp_static->valid = 1; |
| 4240 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4241 | } |
| 4242 | |
| 4243 | return CMD_SUCCESS; |
| 4244 | } |
| 4245 | |
| 4246 | /* Configure static BGP network. */ |
| 4247 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4248 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
| 4249 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4250 | { |
| 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 Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4286 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4287 | (struct prefix *)&prd); |
| 4288 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4289 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4290 | else |
| 4291 | bgp_unlock_node (prn); |
| 4292 | table = prn->info; |
| 4293 | |
| 4294 | rn = bgp_node_lookup (table, &p); |
| 4295 | |
| 4296 | if (rn) |
| 4297 | { |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4298 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4299 | |
| 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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4311 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4312 | DEFUN (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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4319 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4320 | } |
| 4321 | |
| 4322 | DEFUN (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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4331 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4332 | } |
| 4333 | |
| 4334 | DEFUN (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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4341 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4342 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4343 | } |
| 4344 | |
| 4345 | DEFUN (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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4355 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4356 | 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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4364 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4365 | } |
| 4366 | |
| 4367 | DEFUN (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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4379 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4380 | 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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4388 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4389 | } |
| 4390 | |
| 4391 | DEFUN (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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4402 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4403 | 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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4410 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4411 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4412 | } |
| 4413 | |
| 4414 | DEFUN (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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4431 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4432 | } |
| 4433 | |
| 4434 | DEFUN (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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4453 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4454 | } |
| 4455 | |
| 4456 | DEFUN (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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4473 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4474 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4475 | } |
| 4476 | |
| 4477 | DEFUN (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 | |
| 4488 | ALIAS (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 | |
| 4497 | ALIAS (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 | |
| 4505 | DEFUN (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 | |
| 4528 | ALIAS (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 | |
| 4539 | ALIAS (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 | |
| 4549 | DEFUN (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 | |
| 4570 | ALIAS (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 | |
| 4579 | ALIAS (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4587 | DEFUN (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.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4593 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty), |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4594 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4595 | } |
| 4596 | |
| 4597 | DEFUN (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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4606 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | DEFUN (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.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4616 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4617 | } |
| 4618 | |
| 4619 | ALIAS (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 | |
| 4628 | ALIAS (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 | |
| 4636 | ALIAS (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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4644 | |
| 4645 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4646 | ALIAS_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") |
| 4653 | ALIAS_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") |
| 4661 | ALIAS_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") |
| 4670 | ALIAS_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") |
| 4680 | ALIAS_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") |
| 4687 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4688 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4689 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4690 | "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") |
| 4695 | ALIAS_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") |
| 4703 | ALIAS_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") |
| 4712 | ALIAS_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") |
| 4722 | ALIAS_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") |
| 4733 | ALIAS_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") |
| 4741 | ALIAS_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") |
| 4750 | ALIAS_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") |
| 4757 | ALIAS_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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4765 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4766 | /* 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 | */ |
| 4776 | struct 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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4794 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4795 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4796 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4797 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4798 | } |
| 4799 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4800 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4801 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4802 | { |
| 4803 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4804 | } |
| 4805 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4806 | /* Update an aggregate as routes are added/removed from the BGP table */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4807 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4808 | bgp_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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4820 | struct bgp_info *ri; |
| 4821 | struct bgp_info *new; |
| 4822 | int first = 1; |
| 4823 | unsigned long match = 0; |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4824 | u_char atomic_aggregate = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4825 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4826 | /* 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 Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4853 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4854 | |
| 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 Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4869 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 4870 | atomic_aggregate = 1; |
| 4871 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4872 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4873 | { |
| 4874 | if (aggregate->summary_only) |
| 4875 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4876 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4877 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4878 | match++; |
| 4879 | } |
| 4880 | |
| 4881 | aggregate->count++; |
| 4882 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4883 | if (origin < ri->attr->origin) |
| 4884 | origin = ri->attr->origin; |
| 4885 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4886 | if (aggregate->as_set) |
| 4887 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4888 | 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4922 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4923 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4924 | if (origin < rinew->attr->origin) |
| 4925 | origin = rinew->attr->origin; |
| 4926 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4927 | if (aggregate->as_set) |
| 4928 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4929 | 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 Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 4956 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self, |
| 4957 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4958 | aggregate->as_set, |
| 4959 | atomic_aggregate), rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4960 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4961 | |
| 4962 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4963 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4964 | 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 | |
| 4975 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4976 | struct bgp_aggregate *); |
| 4977 | |
| 4978 | void |
| 4979 | bgp_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] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4985 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4986 | |
| 4987 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4988 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4989 | return; |
| 4990 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4991 | table = bgp->aggregate[afi][safi]; |
| 4992 | |
| 4993 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4994 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4995 | return; |
| 4996 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4997 | if (p->prefixlen == 0) |
| 4998 | return; |
| 4999 | |
| 5000 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5001 | return; |
| 5002 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 5003 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5004 | |
| 5005 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5006 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5007 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 5008 | { |
| 5009 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 5010 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5011 | } |
| 5012 | bgp_unlock_node (child); |
| 5013 | } |
| 5014 | |
| 5015 | void |
| 5016 | bgp_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] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5022 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5023 | |
| 5024 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5025 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5026 | return; |
| 5027 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5028 | table = bgp->aggregate[afi][safi]; |
| 5029 | |
| 5030 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5031 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5032 | return; |
| 5033 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5034 | if (p->prefixlen == 0) |
| 5035 | return; |
| 5036 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 5037 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5038 | |
| 5039 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5040 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5041 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 5042 | { |
| 5043 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 5044 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5045 | } |
| 5046 | bgp_unlock_node (child); |
| 5047 | } |
| 5048 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 5049 | /* Called via bgp_aggregate_set when the user configures aggregate-address */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5050 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5051 | bgp_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 Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 5065 | u_char atomic_aggregate = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5066 | |
| 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 Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 5087 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5088 | atomic_aggregate = 1; |
| 5089 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5090 | 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5096 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5097 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5098 | match++; |
| 5099 | } |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 5100 | |
| 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5111 | /* as-set aggregate route generate origin, as path, |
| 5112 | community aggregation. */ |
| 5113 | if (aggregate->as_set) |
| 5114 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5115 | 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 Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5151 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self, |
| 5152 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 5153 | aggregate->as_set, |
| 5154 | atomic_aggregate), rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5155 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5156 | |
| 5157 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5158 | bgp_unlock_node (rn); |
| 5159 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5160 | /* Process change. */ |
| 5161 | bgp_process (bgp, rn, afi, safi); |
| 5162 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 5163 | else |
| 5164 | { |
| 5165 | if (aspath) |
| 5166 | aspath_free (aspath); |
| 5167 | if (community) |
| 5168 | community_free (community); |
| 5169 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5170 | } |
| 5171 | |
| 5172 | void |
| 5173 | bgp_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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5203 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5204 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5205 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5206 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5207 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5208 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5209 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5210 | match++; |
| 5211 | } |
| 5212 | } |
| 5213 | aggregate->count--; |
| 5214 | } |
| 5215 | } |
| 5216 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5217 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5218 | 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 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5235 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5236 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5237 | } |
| 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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5247 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5248 | bgp_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 | |
| 5293 | static int |
| 5294 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5295 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5296 | 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 Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5322 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5323 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5324 | if (ret) |
| 5325 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5326 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5327 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5328 | return CMD_WARNING; |
| 5329 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5330 | } |
| 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5348 | DEFUN (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 | |
| 5357 | DEFUN (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 | |
| 5379 | DEFUN (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 | |
| 5390 | DEFUN (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 | |
| 5413 | DEFUN (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 | |
| 5424 | DEFUN (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 | |
| 5448 | DEFUN (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 | |
| 5460 | ALIAS (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 | |
| 5468 | DEFUN (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 | |
| 5492 | ALIAS (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 | |
| 5501 | DEFUN (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 | |
| 5511 | ALIAS (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 | |
| 5519 | ALIAS (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 | |
| 5527 | ALIAS (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 | |
| 5536 | ALIAS (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 | |
| 5545 | DEFUN (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 | |
| 5567 | ALIAS (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 | |
| 5576 | ALIAS (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 | |
| 5585 | ALIAS (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 | |
| 5595 | ALIAS (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5605 | DEFUN (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 | |
| 5614 | DEFUN (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 | |
| 5625 | DEFUN (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 | |
| 5635 | DEFUN (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 | |
| 5646 | ALIAS (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 | |
| 5654 | ALIAS (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 | |
| 5663 | ALIAS (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 | |
| 5672 | ALIAS (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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5681 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5682 | /* Redistribute route treatment. */ |
| 5683 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5684 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5685 | const struct in6_addr *nexthop6, |
Paul Jakma | 96d1060 | 2016-07-01 14:23:45 +0100 | [diff] [blame] | 5686 | u_int32_t metric, u_char type, route_tag_t tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5687 | { |
| 5688 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5689 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5690 | struct bgp_info *new; |
| 5691 | struct bgp_info *bi; |
| 5692 | struct bgp_info info; |
| 5693 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5694 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5695 | 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 Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5704 | 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 Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5710 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5711 | attr.med = metric; |
| 5712 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 5713 | attr.extra->tag = tag; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5714 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5715 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5716 | { |
| 5717 | afi = family2afi (p->family); |
| 5718 | |
| 5719 | if (bgp->redist[afi][type]) |
| 5720 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5721 | struct attr attr_new; |
| 5722 | struct attr_extra extra_new; |
| 5723 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5724 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5725 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5726 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5727 | |
| 5728 | if (bgp->redist_metric_flag[afi][type]) |
| 5729 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5730 | |
| 5731 | /* Apply route-map. */ |
Daniel Walton | 1994dc8 | 2015-09-17 10:15:59 -0400 | [diff] [blame] | 5732 | if (bgp->rmap[afi][type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5733 | { |
| 5734 | info.peer = bgp->peer_self; |
| 5735 | info.attr = &attr_new; |
| 5736 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5737 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5738 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5739 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5740 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5741 | |
| 5742 | bgp->peer_self->rmap_type = 0; |
| 5743 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5744 | if (ret == RMAP_DENYMATCH) |
| 5745 | { |
| 5746 | /* Free uninterned attribute. */ |
| 5747 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5748 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5749 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5750 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5751 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5752 | bgp_redistribute_delete (p, type); |
| 5753 | return; |
| 5754 | } |
| 5755 | } |
| 5756 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5757 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5758 | afi, SAFI_UNICAST, p, NULL); |
| 5759 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5760 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5761 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5762 | 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. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5769 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5770 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5771 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5772 | bgp_attr_unintern (&new_attr); |
| 5773 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5774 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5775 | bgp_unlock_node (bn); |
| 5776 | return; |
| 5777 | } |
| 5778 | else |
| 5779 | { |
| 5780 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5781 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5782 | |
| 5783 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5784 | 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 Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5788 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5789 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5790 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5791 | |
| 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 Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5796 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5797 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5798 | return; |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5799 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5800 | } |
| 5801 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5802 | new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self, |
| 5803 | new_attr, bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5804 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5805 | |
| 5806 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5807 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5808 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5809 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5810 | } |
| 5811 | } |
| 5812 | |
| 5813 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5814 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5815 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5816 | } |
| 5817 | |
| 5818 | void |
| 5819 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5820 | { |
| 5821 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5822 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5823 | afi_t afi; |
| 5824 | struct bgp_node *rn; |
| 5825 | struct bgp_info *ri; |
| 5826 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5827 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5828 | { |
| 5829 | afi = family2afi (p->family); |
| 5830 | |
| 5831 | if (bgp->redist[afi][type]) |
| 5832 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5833 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5834 | |
| 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5843 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5844 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5845 | } |
| 5846 | bgp_unlock_node (rn); |
| 5847 | } |
| 5848 | } |
| 5849 | } |
| 5850 | |
| 5851 | /* Withdraw specified route type's route. */ |
| 5852 | void |
| 5853 | bgp_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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5871 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5872 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5873 | } |
| 5874 | } |
| 5875 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5876 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5877 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5878 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5879 | route_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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5911 | enum bgp_display_type |
| 5912 | { |
| 5913 | normal_list, |
| 5914 | }; |
| 5915 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5916 | /* Print the short form route status for a bgp_info */ |
| 5917 | static void |
| 5918 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5919 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5920 | /* 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)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5924 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5925 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | vty_out (vty, "s"); |
Daniel Walton | e2a0ebf | 2015-05-19 18:03:43 -0700 | [diff] [blame] | 5927 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && |
| 5928 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5929 | 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 Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5940 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5941 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5942 | 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 |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5949 | vty_out (vty, " "); |
| 5950 | } |
| 5951 | |
| 5952 | /* called from terminal list command */ |
| 5953 | void |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5954 | route_vty_out( |
| 5955 | struct vty *vty, |
| 5956 | struct prefix *p, |
| 5957 | struct bgp_info *binfo, |
| 5958 | int display, |
| 5959 | safi_t safi) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5960 | { |
| 5961 | struct attr *attr; |
| 5962 | |
| 5963 | /* short status lead text */ |
| 5964 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5965 | |
| 5966 | /* print prefix and mask */ |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5967 | if (!display) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5968 | 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 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5976 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5977 | /* |
| 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5996 | case AF_INET6: |
| 5997 | vty_out (vty, "%s", inet_ntop(af, |
| 5998 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); |
| 5999 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6000 | default: |
| 6001 | vty_out(vty, "?"); |
| 6002 | } |
| 6003 | } else { |
| 6004 | vty_out(vty, "?"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6005 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6006 | } else { |
| 6007 | |
| 6008 | if (p->family == AF_INET) |
| 6009 | { |
| 6010 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6011 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6012 | 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6026 | else |
| 6027 | { |
| 6028 | vty_out(vty, "?"); |
| 6029 | } |
| 6030 | } |
| 6031 | |
| 6032 | /* |
| 6033 | * NEXTHOP end |
| 6034 | */ |
| 6035 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6036 | |
| 6037 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Daniel Walton | 4d48bb3 | 2016-11-29 12:47:12 -0500 | [diff] [blame] | 6038 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6039 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6040 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6041 | |
| 6042 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Daniel Walton | 4d48bb3 | 2016-11-29 12:47:12 -0500 | [diff] [blame] | 6043 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6044 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6045 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6046 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6047 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6048 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6049 | /* Print aspath */ |
| 6050 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6051 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6052 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6053 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6054 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6055 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6056 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6057 | } |
| 6058 | |
| 6059 | /* called from terminal list command */ |
| 6060 | void |
| 6061 | route_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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6077 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6078 | vty_out (vty, "%-16s", |
| 6079 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6080 | else |
| 6081 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6082 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6083 | else if (p->family == AF_INET6) |
| 6084 | { |
| 6085 | int len; |
| 6086 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6087 | |
| 6088 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6089 | |
| 6090 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6091 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6092 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6093 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6099 | |
| 6100 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6101 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6102 | else |
| 6103 | vty_out (vty, " "); |
| 6104 | |
| 6105 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6106 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6107 | else |
| 6108 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6109 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6110 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6111 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6112 | /* Print aspath */ |
| 6113 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6114 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6115 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6116 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6117 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6118 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6119 | |
| 6120 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6121 | } |
| 6122 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6123 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6124 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 6125 | struct bgp_info *binfo, int display, safi_t safi) |
| 6126 | { |
| 6127 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6128 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6129 | |
| 6130 | if (!binfo->extra) |
| 6131 | return; |
| 6132 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6133 | /* short status lead text */ |
| 6134 | route_vty_short_status_out (vty, binfo); |
| 6135 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6136 | /* 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6148 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6149 | vty_out (vty, "%-16s", |
| 6150 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6151 | else |
| 6152 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6153 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6154 | else if (p->family == AF_INET6) |
| 6155 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6156 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6157 | char buf[BUFSIZ]; |
| 6158 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6159 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6160 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6161 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6162 | buf, BUFSIZ)); |
| 6163 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6164 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6165 | 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)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6169 | |
| 6170 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6171 | } |
| 6172 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6173 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6174 | |
| 6175 | vty_out (vty, "notag/%d", label); |
| 6176 | |
| 6177 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6178 | } |
| 6179 | |
| 6180 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6181 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6182 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 6183 | struct bgp_info *binfo, int display, safi_t safi) |
| 6184 | { |
| 6185 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6186 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6187 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6188 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6189 | /* short status lead text */ |
| 6190 | route_vty_short_status_out (vty, binfo); |
| 6191 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6192 | /* 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 Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6205 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6206 | |
| 6207 | /* Print attribute */ |
| 6208 | attr = binfo->attr; |
| 6209 | if (attr) |
| 6210 | { |
| 6211 | /* Print aspath */ |
| 6212 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6213 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6214 | |
| 6215 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6216 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6217 | } |
| 6218 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6219 | } |
| 6220 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6221 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6222 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6223 | flap_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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6228 | char timebuf[BGP_UPTIME_LEN]; |
| 6229 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6230 | |
| 6231 | if (!binfo->extra) |
| 6232 | return; |
| 6233 | |
| 6234 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6235 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6236 | /* short status lead text */ |
| 6237 | route_vty_short_status_out (vty, binfo); |
| 6238 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6239 | /* 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 Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6264 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6265 | 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 Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6274 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6275 | |
| 6276 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6277 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6278 | } |
| 6279 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6280 | } |
| 6281 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6282 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6283 | route_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 Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6290 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6291 | time_t tbuf; |
| 6292 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6293 | |
| 6294 | attr = binfo->attr; |
| 6295 | |
| 6296 | if (attr) |
| 6297 | { |
| 6298 | /* Line1 display AS-path, Aggregator */ |
| 6299 | if (attr->aspath) |
| 6300 | { |
| 6301 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6302 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6303 | vty_out (vty, "Local"); |
| 6304 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6305 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6306 | } |
| 6307 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6308 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6309 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6310 | 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 Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6313 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6314 | attr->extra->aggregator_as, |
| 6315 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6316 | 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)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6324 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6325 | |
| 6326 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6327 | if (p->family == AF_INET) |
| 6328 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6329 | vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6330 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6331 | inet_ntoa (attr->nexthop)); |
| 6332 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6333 | else |
| 6334 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6335 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6336 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6337 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6338 | buf, INET6_ADDRSTRLEN)); |
| 6339 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6340 | |
| 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6351 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6352 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6353 | if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) { |
| 6354 | buf[0] = '?'; |
| 6355 | buf[1] = 0; |
| 6356 | } |
| 6357 | vty_out (vty, " from %s", buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6358 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6359 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6360 | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6365 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6366 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6367 | { |
| 6368 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6369 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6370 | buf, INET6_ADDRSTRLEN), |
| 6371 | VTY_NEWLINE); |
| 6372 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6373 | |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 6374 | /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6375 | 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 Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6378 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6379 | |
| 6380 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6381 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6382 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6383 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6384 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6385 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6386 | vty_out (vty, ", weight %u", attr->extra->weight); |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 6387 | |
| 6388 | if (attr->extra && attr->extra->tag != 0) |
| 6389 | vty_out (vty, ", tag %d", attr->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6390 | |
Daniel Walton | e2a0ebf | 2015-05-19 18:03:43 -0700 | [diff] [blame] | 6391 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6392 | vty_out (vty, ", invalid"); |
| 6393 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6394 | 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 Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6414 | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6419 | 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6431 | vty_out (vty, " Extended Community: %s%s", |
| 6432 | attr->extra->ecommunity->str, VTY_NEWLINE); |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 6433 | |
| 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 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6440 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6441 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6442 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6443 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6444 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6445 | vty_out (vty, " Originator: %s", |
| 6446 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6447 | |
| 6448 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6449 | { |
| 6450 | int i; |
| 6451 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6452 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6453 | vty_out (vty, "%s ", |
| 6454 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6455 | } |
| 6456 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6457 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6458 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6459 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6460 | bgp_damp_info_vty (vty, binfo); |
| 6461 | |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 6462 | /* Line 8 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6463 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6464 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6465 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6466 | #else |
| 6467 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6468 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6469 | } |
| 6470 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6471 | } |
| 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" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6476 | #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6477 | #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 | |
| 6481 | enum 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 6496 | bgp_show_type_lcommunity_all, |
| 6497 | bgp_show_type_lcommunity, |
| 6498 | bgp_show_type_lcommunity_list, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6499 | 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6513 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6514 | bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6515 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6516 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6517 | struct bgp_info *ri; |
| 6518 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6519 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6520 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6521 | unsigned long output_count; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6522 | unsigned long total_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6523 | |
| 6524 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6525 | output_count = 0; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6526 | total_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6527 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6528 | /* 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 Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6536 | total_count++; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6537 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6538 | || 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6550 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6551 | continue; |
| 6552 | } |
| 6553 | if (type == bgp_show_type_regexp |
| 6554 | || type == bgp_show_type_flap_regexp) |
| 6555 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6556 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6557 | |
| 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 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6564 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6565 | |
| 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 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6572 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6573 | |
| 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 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6580 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6581 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6582 | struct attr dummy_attr; |
| 6583 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6584 | int ret; |
| 6585 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6586 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6587 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6588 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6589 | binfo.peer = ri->peer; |
| 6590 | binfo.attr = &dummy_attr; |
| 6591 | |
| 6592 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6593 | 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 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6600 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6601 | |
| 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 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6621 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6622 | |
| 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 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6633 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6634 | |
| 6635 | if (! ri->attr->community || |
| 6636 | ! community_match (ri->attr->community, com)) |
| 6637 | continue; |
| 6638 | } |
| 6639 | if (type == bgp_show_type_community_exact) |
| 6640 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6641 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6642 | |
| 6643 | if (! ri->attr->community || |
| 6644 | ! community_cmp (ri->attr->community, com)) |
| 6645 | continue; |
| 6646 | } |
| 6647 | if (type == bgp_show_type_community_list) |
| 6648 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6649 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6650 | |
| 6651 | if (! community_list_match (ri->attr->community, list)) |
| 6652 | continue; |
| 6653 | } |
| 6654 | if (type == bgp_show_type_community_list_exact) |
| 6655 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6656 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6657 | |
| 6658 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6659 | continue; |
| 6660 | } |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 6661 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6687 | if (type == bgp_show_type_flap_address |
| 6688 | || type == bgp_show_type_flap_prefix) |
| 6689 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6690 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6691 | |
| 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 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6709 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6712 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6728 | header = 0; |
| 6729 | } |
| 6730 | |
| 6731 | if (type == bgp_show_type_dampend_paths |
| 6732 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6733 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6734 | 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) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6744 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6745 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6746 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6747 | display++; |
| 6748 | } |
| 6749 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6750 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6751 | } |
| 6752 | |
| 6753 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6754 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6755 | { |
| 6756 | if (type == bgp_show_type_normal) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6757 | vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6758 | } |
| 6759 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6760 | vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", |
| 6761 | VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6762 | |
| 6763 | return CMD_SUCCESS; |
| 6764 | } |
| 6765 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6766 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6767 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6768 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6769 | { |
| 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6785 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6786 | } |
| 6787 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6788 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6789 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6790 | route_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; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6797 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6798 | 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6807 | int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6808 | |
| 6809 | p = &rn->p; |
| 6810 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6811 | (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6812 | printrd ? ":" : "", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6813 | 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 Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6822 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6823 | 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 */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6856 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6857 | { |
| 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. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6872 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6873 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6874 | struct bgp_table *rib, const char *ip_str, |
| 6875 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6876 | int prefix_check, enum bgp_path_type pathtype) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6877 | { |
| 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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6885 | struct bgp_table *table; |
| 6886 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 6887 | memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6888 | /* 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6898 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6899 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6900 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6901 | { |
| 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 Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6912 | { |
| 6913 | bgp_unlock_node (rm); |
| 6914 | continue; |
| 6915 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6916 | |
| 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6922 | AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6923 | |
| 6924 | header = 0; |
| 6925 | } |
| 6926 | display++; |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6927 | |
| 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6933 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6934 | |
| 6935 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6936 | } |
| 6937 | } |
| 6938 | } |
| 6939 | } |
| 6940 | else |
| 6941 | { |
| 6942 | header = 1; |
| 6943 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6944 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6945 | { |
| 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6956 | |
| 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6962 | } |
| 6963 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6964 | |
| 6965 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6966 | } |
| 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 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6978 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6979 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6980 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6981 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6982 | int prefix_check, enum bgp_path_type pathtype) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6983 | { |
| 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7007 | afi, safi, prd, prefix_check, pathtype); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 7008 | } |
| 7009 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7010 | /* BGP route print out function. */ |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7011 | DEFUN (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 | |
| 7021 | DEFUN (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 | |
| 7038 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7046 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
| 7047 | } |
| 7048 | |
| 7049 | DEFUN (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 | |
| 7065 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7087 | } |
| 7088 | |
| 7089 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7101 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7102 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7103 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7104 | } |
| 7105 | |
| 7106 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7116 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7117 | } |
| 7118 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7119 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7120 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7140 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7141 | } |
| 7142 | |
| 7143 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7151 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
| 7152 | } |
| 7153 | |
| 7154 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7168 | } |
| 7169 | |
| 7170 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7182 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7183 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7184 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7185 | } |
| 7186 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7187 | DEFUN (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 | |
| 7212 | ALIAS (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7224 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7234 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7235 | } |
| 7236 | |
| 7237 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7257 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7258 | } |
| 7259 | |
| 7260 | DEFUN (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 | |
| 7282 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7292 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7293 | } |
| 7294 | |
| 7295 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7305 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7306 | } |
| 7307 | |
| 7308 | DEFUN (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 | |
| 7318 | ALIAS (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 */ |
| 7326 | DEFUN (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 | |
| 7337 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7344 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7345 | } |
| 7346 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7347 | DEFUN (show_bgp_ipv4_safi, |
| 7348 | show_bgp_ipv4_safi_cmd, |
| 7349 | "show bgp ipv4 (unicast|multicast)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7350 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7351 | 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) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7357 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 7358 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7359 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7360 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7361 | } |
| 7362 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7363 | DEFUN (show_bgp_ipv4_safi_route, |
| 7364 | show_bgp_ipv4_safi_route_cmd, |
| 7365 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7366 | SHOW_STR |
| 7367 | BGP_STR |
| 7368 | "Address family\n" |
| 7369 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7370 | "Address Family modifier\n" |
| 7371 | "Network in the BGP routing table to display\n") |
| 7372 | { |
| 7373 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7374 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7375 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7376 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
| 7377 | } |
| 7378 | |
| 7379 | DEFUN (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 | |
| 7394 | ALIAS (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 | |
| 7404 | DEFUN (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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7426 | } |
| 7427 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7428 | DEFUN (show_bgp_ipv4_vpn_route, |
| 7429 | show_bgp_ipv4_vpn_route_cmd, |
| 7430 | "show bgp ipv4 vpn A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7431 | SHOW_STR |
| 7432 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7433 | "Address Family\n" |
| 7434 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7435 | "Network in the BGP routing table to display\n") |
| 7436 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7437 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7438 | } |
| 7439 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7440 | DEFUN (show_bgp_ipv6_vpn_route, |
| 7441 | show_bgp_ipv6_vpn_route_cmd, |
| 7442 | "show bgp ipv6 vpn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7443 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7444 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7445 | "Address Family\n" |
| 7446 | "Display VPN NLRI specific information\n" |
| 7447 | "Network in the BGP routing table to display\n") |
| 7448 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7449 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL); |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7450 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7451 | |
| 7452 | DEFUN (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" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7459 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7472 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7473 | } |
| 7474 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7475 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7478 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7479 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7480 | "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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7485 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7486 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7495 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL); |
| 7496 | } |
| 7497 | |
| 7498 | DEFUN (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 | |
| 7513 | ALIAS (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 | |
| 7523 | DEFUN (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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7545 | } |
| 7546 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7547 | DEFUN (show_bgp_ipv4_encap_route, |
| 7548 | show_bgp_ipv4_encap_route_cmd, |
| 7549 | "show bgp ipv4 encap A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7550 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7551 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7552 | IP_STR |
| 7553 | "Display ENCAP NLRI specific information\n" |
| 7554 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7555 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7556 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7557 | } |
| 7558 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7559 | DEFUN (show_bgp_ipv6_encap_route, |
| 7560 | show_bgp_ipv6_encap_route_cmd, |
| 7561 | "show bgp ipv6 encap X:X::X:X", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7562 | SHOW_STR |
| 7563 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7564 | IP6_STR |
| 7565 | "Display ENCAP NLRI specific information\n" |
| 7566 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7567 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7568 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7569 | } |
| 7570 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7571 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7574 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7575 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7576 | "Address Family\n" |
| 7577 | "Address Family Modifier\n" |
| 7578 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7579 | "Display information for a route distinguisher\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7580 | "ENCAP Route Distinguisher\n" |
| 7581 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7582 | { |
| 7583 | int ret; |
| 7584 | struct prefix_rd prd; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7585 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7586 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7587 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7592 | if (! ret) |
| 7593 | { |
| 7594 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7595 | return CMD_WARNING; |
| 7596 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7597 | return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7598 | } |
| 7599 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7600 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7603 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7604 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7605 | "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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7611 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7612 | int ret; |
| 7613 | struct prefix_rd prd; |
| 7614 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7615 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7616 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7626 | return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7627 | } |
| 7628 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7629 | DEFUN (show_bgp_ipv4_prefix, |
| 7630 | show_bgp_ipv4_prefix_cmd, |
| 7631 | "show bgp ipv4 A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7632 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7633 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7634 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7635 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7636 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7637 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7638 | } |
| 7639 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7640 | DEFUN (show_bgp_ipv4_safi_prefix, |
| 7641 | show_bgp_ipv4_safi_prefix_cmd, |
| 7642 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7643 | SHOW_STR |
| 7644 | BGP_STR |
| 7645 | "Address family\n" |
| 7646 | "Address Family modifier\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7647 | "Address Family modifier\n" |
| 7648 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7649 | { |
| 7650 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7651 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7652 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7653 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7654 | } |
| 7655 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7656 | DEFUN (show_bgp_ipv4_vpn_prefix, |
| 7657 | show_bgp_ipv4_vpn_prefix_cmd, |
| 7658 | "show bgp ipv4 vpn A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7659 | SHOW_STR |
| 7660 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7661 | IP_STR |
| 7662 | "Display VPN NLRI specific information\n" |
| 7663 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7664 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7665 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7666 | } |
| 7667 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7668 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7677 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7678 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7679 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7680 | DEFUN (show_bgp_ipv4_encap_prefix, |
| 7681 | show_bgp_ipv4_encap_prefix_cmd, |
| 7682 | "show bgp ipv4 encap A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7683 | SHOW_STR |
| 7684 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7685 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7690 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7691 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7692 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7693 | DEFUN (show_bgp_ipv6_encap_prefix, |
| 7694 | show_bgp_ipv6_encap_prefix_cmd, |
| 7695 | "show bgp ipv6 encap X:X::X:X/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7696 | SHOW_STR |
| 7697 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7698 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7703 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7704 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7705 | |
| 7706 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7733 | return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7734 | } |
| 7735 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7736 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7763 | return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7764 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7765 | |
| 7766 | DEFUN (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 | |
| 7805 | DEFUN (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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7818 | "Network in the BGP routing table to display\n") |
| 7819 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7820 | safi_t safi; |
| 7821 | afi_t afi; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7822 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7823 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7831 | return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7832 | } |
| 7833 | |
| 7834 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7860 | return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7861 | } |
| 7862 | |
| 7863 | /* new001 */ |
| 7864 | DEFUN (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7882 | DEFUN (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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7896 | } |
| 7897 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7898 | DEFUN (show_bgp_ipv6_route, |
| 7899 | show_bgp_ipv6_route_cmd, |
| 7900 | "show bgp ipv6 X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7901 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7902 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7903 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7904 | "Network in the BGP routing table to display\n") |
| 7905 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7906 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7907 | } |
| 7908 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7909 | DEFUN (show_bgp_ipv6_safi_route, |
| 7910 | show_bgp_ipv6_safi_route_cmd, |
| 7911 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7912 | SHOW_STR |
| 7913 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7914 | "Address family\n" |
| 7915 | "Address Family modifier\n" |
| 7916 | "Address Family modifier\n" |
| 7917 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7918 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7919 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7920 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7921 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7922 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7923 | } |
| 7924 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7925 | /* old command */ |
| 7926 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7934 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7935 | } |
| 7936 | |
| 7937 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7944 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7945 | } |
| 7946 | |
| 7947 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7948 | /* new002 */ |
| 7949 | DEFUN (show_bgp_ipv6_prefix, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7950 | 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 Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7955 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7956 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7957 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7958 | } |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7959 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7970 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7971 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7972 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7973 | } |
| 7974 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7975 | /* old command */ |
| 7976 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7984 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7985 | } |
| 7986 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7987 | DEFUN (show_bgp_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7988 | 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 | |
| 8008 | DEFUN (show_bgp_view_ipv6, |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8009 | show_bgp_view_ipv6_cmd, |
| 8010 | "show bgp view WORD ipv6", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8011 | SHOW_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8012 | BGP_STR |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8013 | "BGP view\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8014 | "View name\n" |
| 8015 | "Address family\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8016 | { |
| 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8027 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8028 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8029 | |
| 8030 | DEFUN (show_bgp_view_route, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8031 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8039 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8040 | } |
| 8041 | |
| 8042 | DEFUN (show_bgp_view_ipv6_route, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8043 | 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") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8051 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8052 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8053 | } |
| 8054 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8055 | /* old command */ |
| 8056 | DEFUN (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 */ |
| 8068 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8076 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8077 | } |
| 8078 | |
| 8079 | /* old command */ |
| 8080 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8088 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8089 | } |
| 8090 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8091 | DEFUN (show_bgp_view_prefix, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8092 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8100 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8101 | } |
| 8102 | |
| 8103 | DEFUN (show_bgp_view_ipv6_prefix, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8104 | 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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8112 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8113 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8114 | } |
| 8115 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8116 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8117 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8118 | 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; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8125 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8126 | |
| 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); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 8148 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8149 | if (! regex) |
| 8150 | { |
| 8151 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 8152 | VTY_NEWLINE); |
| 8153 | return CMD_WARNING; |
| 8154 | } |
| 8155 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8156 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 8157 | bgp_regex_free (regex); |
| 8158 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8159 | } |
| 8160 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8161 | |
| 8162 | DEFUN (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 | |
| 8175 | DEFUN (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 | |
| 8189 | ALIAS (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 | |
| 8200 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8220 | DEFUN (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 */ |
| 8233 | DEFUN (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 */ |
| 8247 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8259 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8260 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8263 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8264 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8265 | IP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8266 | "Address Family Modifier\n" |
| 8267 | "Address Family Modifier\n" |
| 8268 | "Address Family Modifier\n" |
| 8269 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8270 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8274 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8282 | } |
| 8283 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8284 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8287 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8288 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8289 | IP_STR |
| 8290 | "Address Family Modifier\n" |
| 8291 | "Address Family Modifier\n" |
| 8292 | "Address Family Modifier\n" |
| 8293 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8294 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8299 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8302 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8303 | 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 | |
| 8323 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8337 | |
| 8338 | DEFUN (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 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8342 | BGP_STR |
| 8343 | "Address family\n" |
| 8344 | "Address Family modifier\n" |
| 8345 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8346 | "Address Family modifier\n" |
| 8347 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8348 | "Display routes matching the AS path regular expression\n" |
| 8349 | "A regular-expression to match the BGP AS paths\n") |
| 8350 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8351 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8356 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8357 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8358 | bgp_show_type_regexp); |
| 8359 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8360 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8361 | DEFUN (show_bgp_ipv6_safi_regexp, |
| 8362 | show_bgp_ipv6_safi_regexp_cmd, |
| 8363 | "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8364 | SHOW_STR |
| 8365 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8366 | "Address family\n" |
| 8367 | "Address Family modifier\n" |
| 8368 | "Address Family modifier\n" |
| 8369 | "Address Family modifier\n" |
| 8370 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8371 | "Display routes matching the AS path regular expression\n" |
| 8372 | "A regular-expression to match the BGP AS paths\n") |
| 8373 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8374 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8381 | bgp_show_type_regexp); |
| 8382 | } |
| 8383 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8384 | DEFUN (show_bgp_ipv6_regexp, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8385 | 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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8392 | { |
| 8393 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8394 | bgp_show_type_regexp); |
| 8395 | } |
| 8396 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8397 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8398 | bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8399 | 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8411 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8412 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8413 | DEFUN (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 | |
| 8426 | DEFUN (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 | |
| 8440 | ALIAS (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 | |
| 8451 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8471 | DEFUN (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 | |
| 8483 | ALIAS (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 */ |
| 8493 | DEFUN (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 */ |
| 8507 | DEFUN (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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8519 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8520 | DEFUN (show_bgp_ipv4_prefix_list, |
| 8521 | show_bgp_ipv4_prefix_list_cmd, |
| 8522 | "show bgp ipv4 prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8523 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8524 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8525 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8526 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8533 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8536 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8537 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8538 | IP_STR |
| 8539 | "Address Family Modifier\n" |
| 8540 | "Address Family Modifier\n" |
| 8541 | "Address Family Modifier\n" |
| 8542 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8543 | "Display flap statistics of routes\n" |
| 8544 | "Display routes conforming to the prefix-list\n" |
| 8545 | "IP prefix-list name\n") |
| 8546 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8547 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8553 | bgp_show_type_flap_prefix_list); |
| 8554 | } |
| 8555 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8556 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8559 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8560 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8561 | IP_STR |
| 8562 | "Address Family Modifier\n" |
| 8563 | "Address Family Modifier\n" |
| 8564 | "Address Family Modifier\n" |
| 8565 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8566 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8571 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8574 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8575 | 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 | } |
| 8593 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8607 | |
| 8608 | DEFUN (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 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8612 | BGP_STR |
| 8613 | "Address family\n" |
| 8614 | "Address Family modifier\n" |
| 8615 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8616 | "Address Family modifier\n" |
| 8617 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8618 | "Display routes conforming to the prefix-list\n" |
| 8619 | "IP prefix-list name\n") |
| 8620 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8621 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8627 | bgp_show_type_prefix_list); |
| 8628 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8629 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8630 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8633 | SHOW_STR |
| 8634 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8635 | "Address family\n" |
| 8636 | "Address Family modifier\n" |
| 8637 | "Address Family modifier\n" |
| 8638 | "Address Family modifier\n" |
| 8639 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8640 | "Display routes conforming to the prefix-list\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8641 | "IP prefix-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8642 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8643 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8649 | bgp_show_type_prefix_list); |
| 8650 | } |
| 8651 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8652 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8653 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8654 | 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8665 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8666 | } |
| 8667 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8668 | DEFUN (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 | |
| 8681 | DEFUN (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 | |
| 8695 | ALIAS (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 | |
| 8706 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8726 | DEFUN (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 */ |
| 8739 | DEFUN (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 */ |
| 8753 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8765 | |
| 8766 | DEFUN (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8778 | DEFUN (show_bgp_ipv4_filter_list, |
| 8779 | show_bgp_ipv4_filter_list_cmd, |
| 8780 | "show bgp ipv4 filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8781 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8782 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8783 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8784 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8791 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8794 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8795 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8796 | IP_STR |
| 8797 | "Address Family modifier\n" |
| 8798 | "Address Family modifier\n" |
| 8799 | "Address Family modifier\n" |
| 8800 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8801 | "Display flap statistics of routes\n" |
| 8802 | "Display routes conforming to the filter-list\n" |
| 8803 | "Regular expression access list name\n") |
| 8804 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8805 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8812 | bgp_show_type_flap_filter_list); |
| 8813 | } |
| 8814 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8815 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8818 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8819 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8820 | IP_STR |
| 8821 | "Address Family modifier\n" |
| 8822 | "Address Family modifier\n" |
| 8823 | "Address Family modifier\n" |
| 8824 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8825 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8830 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8833 | SHOW_STR |
| 8834 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8835 | 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" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8841 | "Display routes conforming to the filter-list\n" |
| 8842 | "Regular expression access list name\n") |
| 8843 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8844 | safi_t safi; |
| 8845 | |
| 8846 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8847 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8848 | return CMD_WARNING; |
| 8849 | } |
| 8850 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8851 | bgp_show_type_flap_filter_list); |
| 8852 | } |
| 8853 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8867 | |
| 8868 | DEFUN (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 Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8889 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8890 | DEFUN (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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8910 | } |
| 8911 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8912 | DEFUN (show_bgp_ipv6_filter_list, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8913 | 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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8920 | { |
| 8921 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8922 | bgp_show_type_filter_list); |
| 8923 | } |
| 8924 | |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 8925 | |
| 8926 | DEFUN (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 | |
| 8945 | DEFUN (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 | |
| 8965 | DEFUN (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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8985 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8986 | bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8987 | 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8999 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9000 | } |
| 9001 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9002 | DEFUN (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 | |
| 9015 | DEFUN (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 | |
| 9029 | ALIAS (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 | |
| 9040 | DEFUN (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 | |
| 9060 | DEFUN (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 | |
| 9072 | DEFUN (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 | |
| 9084 | DEFUN (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 | |
| 9097 | ALIAS (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 | |
| 9107 | DEFUN (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 | |
| 9126 | DEFUN (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 | |
| 9138 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9157 | DEFUN (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 | |
| 9168 | ALIAS (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 */ |
| 9177 | DEFUN (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 */ |
| 9190 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9201 | |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 9202 | /* large-community */ |
| 9203 | DEFUN (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 | |
| 9215 | DEFUN (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 | |
| 9234 | DEFUN (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 | |
| 9245 | ALIAS (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 */ |
| 9254 | DEFUN (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 */ |
| 9267 | DEFUN (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9280 | DEFUN (show_bgp_ipv4_route_map, |
| 9281 | show_bgp_ipv4_route_map_cmd, |
| 9282 | "show bgp ipv4 route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9283 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9284 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9285 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9286 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9293 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9296 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9297 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9298 | IP_STR |
| 9299 | "Address Family Modifier\n" |
| 9300 | "Address Family Modifier\n" |
| 9301 | "Address Family Modifier\n" |
| 9302 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9303 | "Display flap statistics of routes\n" |
| 9304 | "Display routes matching the route-map\n" |
| 9305 | "A route-map to match on\n") |
| 9306 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9307 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9313 | bgp_show_type_flap_route_map); |
| 9314 | } |
| 9315 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9316 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9319 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9320 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9321 | IP_STR |
| 9322 | "Address Family Modifier\n" |
| 9323 | "Address Family Modifier\n" |
| 9324 | "Address Family Modifier\n" |
| 9325 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9326 | "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 Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 9330 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9331 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9334 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9335 | 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 | } |
| 9353 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9367 | |
| 9368 | DEFUN (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 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9372 | BGP_STR |
| 9373 | "Address family\n" |
| 9374 | "Address Family modifier\n" |
| 9375 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9376 | "Address Family modifier\n" |
| 9377 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9378 | "Display routes matching the route-map\n" |
| 9379 | "A route-map to match on\n") |
| 9380 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9381 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9387 | bgp_show_type_route_map); |
| 9388 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 9389 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9390 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9393 | SHOW_STR |
| 9394 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9395 | "Address family\n" |
| 9396 | "Address Family modifier\n" |
| 9397 | "Address Family modifier\n" |
| 9398 | "Address Family modifier\n" |
| 9399 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9400 | "Display routes matching the route-map\n" |
| 9401 | "A route-map to match on\n") |
| 9402 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9403 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9409 | bgp_show_type_route_map); |
| 9410 | } |
| 9411 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9412 | DEFUN (show_bgp_ipv6_route_map, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9413 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9420 | { |
| 9421 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9422 | bgp_show_type_route_map); |
| 9423 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9424 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9425 | DEFUN (show_bgp_ipv4_cidr_only, |
| 9426 | show_bgp_ipv4_cidr_only_cmd, |
| 9427 | "show bgp ipv4 cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9428 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9429 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9430 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9431 | "Display only routes with non-natural netmasks\n") |
| 9432 | { |
| 9433 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9434 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9435 | } |
| 9436 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9437 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9440 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9441 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9442 | "Address Family\n" |
| 9443 | "Address Family Modifier\n" |
| 9444 | "Address Family Modifier\n" |
| 9445 | "Address Family Modifier\n" |
| 9446 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9447 | "Display flap statistics of routes\n" |
| 9448 | "Display only routes with non-natural netmasks\n") |
| 9449 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9450 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9457 | } |
| 9458 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9459 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9462 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9463 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9464 | "Address Family\n" |
| 9465 | "Address Family Modifier\n" |
| 9466 | "Address Family Modifier\n" |
| 9467 | "Address Family Modifier\n" |
| 9468 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9469 | "Display detailed information about dampening\n" |
| 9470 | "Display flap statistics of routes\n" |
| 9471 | "Display only routes with non-natural netmasks\n") |
| 9472 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9473 | DEFUN (show_bgp_ipv4_safi_cidr_only, |
| 9474 | show_bgp_ipv4_safi_cidr_only_cmd, |
| 9475 | "show bgp ipv4 (unicast|multicast) cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9476 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9477 | 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, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9485 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9486 | |
| 9487 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9488 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9489 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9490 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9491 | /* new046 */ |
| 9492 | DEFUN (show_bgp_afi_safi_community_all, |
| 9493 | show_bgp_afi_safi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9494 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9495 | SHOW_STR |
| 9496 | BGP_STR |
| 9497 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9498 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9499 | "Address Family modifier\n" |
| 9500 | "Address Family modifier\n" |
| 9501 | "Address Family modifier\n" |
| 9502 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9503 | "Display routes matching the communities\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9504 | { |
| 9505 | safi_t safi; |
| 9506 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9507 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9508 | 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 | } |
| 9519 | DEFUN (show_bgp_afi_community_all, |
| 9520 | show_bgp_afi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9521 | "show bgp (ipv4|ipv6) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9522 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9523 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9524 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9525 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9526 | "Display routes matching the communities\n") |
| 9527 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9528 | afi_t afi; |
| 9529 | safi_t safi = SAFI_UNICAST; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9530 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9531 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9536 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9537 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9538 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9539 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 9540 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9541 | { |
| 9542 | struct community *com; |
| 9543 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9544 | struct bgp *bgp; |
Christian Franke | c8e8097 | 2016-06-14 20:07:01 +0200 | [diff] [blame] | 9545 | int i, rv; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9546 | char *str; |
| 9547 | int first = 0; |
| 9548 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9549 | /* 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9569 | 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); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 9589 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9590 | if (! com) |
| 9591 | { |
| 9592 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 9593 | return CMD_WARNING; |
| 9594 | } |
| 9595 | |
Christian Franke | c8e8097 | 2016-06-14 20:07:01 +0200 | [diff] [blame] | 9596 | 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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9601 | } |
| 9602 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9603 | DEFUN (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 | |
| 9618 | ALIAS (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 | |
| 9634 | ALIAS (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 | |
| 9654 | ALIAS (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 | |
| 9678 | DEFUN (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 | |
| 9699 | ALIAS (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 | |
| 9718 | ALIAS (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 | |
| 9741 | ALIAS (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 | |
| 9768 | DEFUN (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 | |
| 9784 | ALIAS (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 | |
| 9801 | ALIAS (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 | |
| 9822 | ALIAS (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 | |
| 9847 | DEFUN (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 | |
| 9869 | ALIAS (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 | |
| 9889 | ALIAS (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 | |
| 9913 | ALIAS (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9941 | DEFUN (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 | |
| 9955 | ALIAS (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 | |
| 9967 | ALIAS (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 | |
| 9982 | ALIAS (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 | |
| 9998 | ALIAS (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 | |
| 10017 | ALIAS (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 | |
| 10037 | ALIAS (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 | |
| 10060 | ALIAS (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 */ |
| 10085 | DEFUN (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 */ |
| 10101 | ALIAS (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 */ |
| 10118 | ALIAS (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 */ |
| 10139 | ALIAS (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 | |
| 10163 | DEFUN (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 | |
| 10178 | ALIAS (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 | |
| 10191 | ALIAS (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 | |
| 10207 | ALIAS (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 | |
| 10224 | ALIAS (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 | |
| 10244 | ALIAS (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 | |
| 10265 | ALIAS (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 | |
| 10289 | ALIAS (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 */ |
| 10315 | DEFUN (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 */ |
| 10332 | ALIAS (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 */ |
| 10350 | ALIAS (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 */ |
| 10372 | ALIAS (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 */ |
| 10398 | DEFUN (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 */ |
| 10414 | ALIAS (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 */ |
| 10431 | ALIAS (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 */ |
| 10452 | ALIAS (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 */ |
| 10477 | DEFUN (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 */ |
| 10494 | ALIAS (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 */ |
| 10512 | ALIAS (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 */ |
| 10534 | ALIAS (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10558 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10559 | DEFUN (show_bgp_ipv4_community, |
| 10560 | show_bgp_ipv4_community_cmd, |
| 10561 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10562 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10563 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10564 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10565 | "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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10571 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10572 | } |
| 10573 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10574 | ALIAS (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10577 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10578 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10579 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10580 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10590 | ALIAS (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10593 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10594 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10595 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10596 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10610 | ALIAS (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10613 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10614 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10615 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10616 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10634 | DEFUN (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10637 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10638 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10649 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10650 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10651 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10652 | } |
| 10653 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10654 | ALIAS (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10657 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10658 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10672 | ALIAS (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10675 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10676 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10694 | ALIAS (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10697 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10698 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10720 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 10721 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10722 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10723 | SHOW_STR |
| 10724 | BGP_STR |
| 10725 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10726 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10727 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10728 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10729 | "Address Family modifier\n" |
| 10730 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10731 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10732 | { |
| 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10745 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10746 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10747 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 10748 | } |
| 10749 | |
| 10750 | DEFUN (show_bgp_view_afi_safi_community, |
| 10751 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10752 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10753 | SHOW_STR |
| 10754 | BGP_STR |
| 10755 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10756 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10757 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10758 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10759 | "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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10770 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10773 | } |
| 10774 | |
| 10775 | ALIAS (show_bgp_view_afi_safi_community, |
| 10776 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10777 | "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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10778 | SHOW_STR |
| 10779 | BGP_STR |
| 10780 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10781 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10782 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10783 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10784 | "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 | |
| 10796 | ALIAS (show_bgp_view_afi_safi_community, |
| 10797 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10798 | "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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10799 | SHOW_STR |
| 10800 | BGP_STR |
| 10801 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10802 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10803 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10804 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10805 | "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 | |
| 10821 | ALIAS (show_bgp_view_afi_safi_community, |
| 10822 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10823 | "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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10824 | SHOW_STR |
| 10825 | BGP_STR |
| 10826 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10827 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10828 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10829 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10830 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10850 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10853 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10854 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10855 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10856 | "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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10863 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10864 | } |
| 10865 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10866 | ALIAS (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10869 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10870 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10871 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10872 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10883 | ALIAS (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10886 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10887 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10888 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10889 | "Display routes matching the communities\n" |
| 10890 | "community number\n" |
| 10891 | "Do not send outside local AS (well-known community)\n" |
| 10892 | "Do not advertise to any peer (well-known community)\n" |
| 10893 | "Do not export to next AS (well-known community)\n" |
| 10894 | "community number\n" |
| 10895 | "Do not send outside local AS (well-known community)\n" |
| 10896 | "Do not advertise to any peer (well-known community)\n" |
| 10897 | "Do not export to next AS (well-known community)\n" |
| 10898 | "community number\n" |
| 10899 | "Do not send outside local AS (well-known community)\n" |
| 10900 | "Do not advertise to any peer (well-known community)\n" |
| 10901 | "Do not export to next AS (well-known community)\n" |
| 10902 | "Exact match of the communities") |
| 10903 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10904 | ALIAS (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10907 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10908 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10909 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10910 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10929 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10932 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10933 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10945 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10946 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10947 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10948 | } |
| 10949 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10950 | ALIAS (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10953 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10954 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10969 | ALIAS (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10972 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10973 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10992 | ALIAS (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10995 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10996 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11019 | DEFUN (show_bgp_ipv6_safi_community, |
| 11020 | show_bgp_ipv6_safi_community_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11021 | "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11022 | SHOW_STR |
| 11023 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11024 | "Address family\n" |
| 11025 | "Address family modifier\n" |
| 11026 | "Address family modifier\n" |
| 11027 | "Address family modifier\n" |
| 11028 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11029 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11035 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11042 | } |
| 11043 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11044 | ALIAS (show_bgp_ipv6_safi_community, |
| 11045 | show_bgp_ipv6_safi_community2_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11046 | "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11047 | SHOW_STR |
| 11048 | BGP_STR |
| 11049 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11050 | "Address family modifier\n" |
| 11051 | "Address family modifier\n" |
| 11052 | "Address family modifier\n" |
| 11053 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11054 | "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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11064 | ALIAS (show_bgp_ipv6_safi_community, |
| 11065 | show_bgp_ipv6_safi_community3_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11066 | "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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11067 | SHOW_STR |
| 11068 | BGP_STR |
| 11069 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11070 | "Address family modifier\n" |
| 11071 | "Address family modifier\n" |
| 11072 | "Address family modifier\n" |
| 11073 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11074 | "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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11088 | ALIAS (show_bgp_ipv6_safi_community, |
| 11089 | show_bgp_ipv6_safi_community4_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11090 | "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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11091 | SHOW_STR |
| 11092 | BGP_STR |
| 11093 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11094 | "Address family modifier\n" |
| 11095 | "Address family modifier\n" |
| 11096 | "Address family modifier\n" |
| 11097 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11098 | "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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11116 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11117 | DEFUN (show_bgp_ipv6_safi_community_exact, |
| 11118 | show_bgp_ipv6_safi_community_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11119 | "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11120 | SHOW_STR |
| 11121 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11122 | "Address family\n" |
| 11123 | "Address family modifier\n" |
| 11124 | "Address family modifier\n" |
| 11125 | "Address family modifier\n" |
| 11126 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11127 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11134 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11141 | } |
| 11142 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11143 | |
| 11144 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11145 | show_bgp_ipv6_safi_community2_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11146 | "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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11147 | SHOW_STR |
| 11148 | BGP_STR |
| 11149 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11150 | "Address family modifier\n" |
| 11151 | "Address family modifier\n" |
| 11152 | "Address family modifier\n" |
| 11153 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11154 | "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 | |
| 11165 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11166 | show_bgp_ipv6_safi_community3_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11167 | "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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11168 | SHOW_STR |
| 11169 | BGP_STR |
| 11170 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11171 | "Address family modifier\n" |
| 11172 | "Address family modifier\n" |
| 11173 | "Address family modifier\n" |
| 11174 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11175 | "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 | |
| 11190 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11191 | show_bgp_ipv6_safi_community4_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11192 | "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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11193 | SHOW_STR |
| 11194 | BGP_STR |
| 11195 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11196 | "Address family modifier\n" |
| 11197 | "Address family modifier\n" |
| 11198 | "Address family modifier\n" |
| 11199 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11200 | "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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11219 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11220 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 11221 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11222 | { |
| 11223 | struct community_list *list; |
| 11224 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11225 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11226 | 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11233 | return bgp_show (vty, NULL, afi, safi, |
| 11234 | (exact ? bgp_show_type_community_list_exact : |
| 11235 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11236 | } |
| 11237 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11238 | DEFUN (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 | |
| 11251 | DEFUN (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 | |
| 11270 | DEFUN (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 | |
| 11284 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11304 | DEFUN (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 | |
| 11316 | ALIAS (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 */ |
| 11327 | DEFUN (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 */ |
| 11340 | DEFUN (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 | |
| 11352 | DEFUN (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 | |
| 11365 | ALIAS (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 */ |
| 11377 | DEFUN (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 */ |
| 11391 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11403 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11404 | DEFUN (show_bgp_ipv4_community_list, |
| 11405 | show_bgp_ipv4_community_list_cmd, |
| 11406 | "show bgp ipv4 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11407 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11408 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11409 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11410 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11411 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11412 | "community-list name\n") |
| 11413 | { |
| 11414 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11415 | } |
| 11416 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11417 | DEFUN (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11420 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11421 | BGP_STR |
| 11422 | "Address family\n" |
| 11423 | "Address Family modifier\n" |
| 11424 | "Address Family modifier\n" |
| 11425 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11426 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11427 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11435 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11438 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11439 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11440 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11441 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11442 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11443 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11449 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11452 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11453 | BGP_STR |
| 11454 | "Address family\n" |
| 11455 | "Address Family modifier\n" |
| 11456 | "Address Family modifier\n" |
| 11457 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11458 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11459 | "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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11468 | DEFUN (show_bgp_ipv6_safi_community_list, |
| 11469 | show_bgp_ipv6_safi_community_list_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11470 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11471 | SHOW_STR |
| 11472 | BGP_STR |
| 11473 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11474 | "Address family modifier\n" |
| 11475 | "Address family modifier\n" |
| 11476 | "Address family modifier\n" |
| 11477 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11478 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11479 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 11480 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11481 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11482 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11483 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11484 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11489 | } |
| 11490 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11491 | DEFUN (show_bgp_ipv6_safi_community_list_exact, |
| 11492 | show_bgp_ipv6_safi_community_list_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11493 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11494 | SHOW_STR |
| 11495 | BGP_STR |
| 11496 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11497 | "Address family modifier\n" |
| 11498 | "Address family modifier\n" |
| 11499 | "Address family modifier\n" |
| 11500 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11501 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11502 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11503 | "community-list name\n" |
| 11504 | "Exact match of the communities\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11505 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11506 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11507 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11508 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11513 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11514 | |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 11515 | /* |
| 11516 | * Large Community show commands. |
| 11517 | */ |
| 11518 | |
| 11519 | DEFUN (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 | |
| 11538 | static int |
| 11539 | bgp_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 | |
| 11599 | DEFUN (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 | |
| 11611 | ALIAS (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 | |
| 11621 | ALIAS (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 | |
| 11632 | ALIAS (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 | |
| 11644 | DEFUN (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 | |
| 11662 | ALIAS (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 | |
| 11675 | ALIAS (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 | |
| 11689 | ALIAS (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 | |
| 11704 | DEFUN (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 | |
| 11715 | ALIAS (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 | |
| 11724 | ALIAS (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 | |
| 11733 | ALIAS (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 | |
| 11743 | ALIAS (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 | |
| 11753 | ALIAS (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 | |
| 11764 | ALIAS (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 | |
| 11775 | ALIAS (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 */ |
| 11788 | DEFUN (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 */ |
| 11801 | ALIAS (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 */ |
| 11812 | ALIAS (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 */ |
| 11824 | ALIAS (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 */ |
| 11837 | DEFUN (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 */ |
| 11850 | ALIAS (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 */ |
| 11861 | ALIAS (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 */ |
| 11873 | ALIAS (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 | |
| 11885 | DEFUN (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 | |
| 11897 | ALIAS (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 | |
| 11907 | ALIAS (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 | |
| 11918 | ALIAS (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 | |
| 11930 | DEFUN (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 | |
| 11947 | ALIAS (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 | |
| 11959 | ALIAS (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 | |
| 11972 | ALIAS (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 | |
| 11986 | DEFUN (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 | |
| 12016 | DEFUN (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 | |
| 12038 | ALIAS (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 | |
| 12053 | ALIAS (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 | |
| 12069 | ALIAS (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 | |
| 12086 | DEFUN (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 | |
| 12108 | ALIAS (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 | |
| 12122 | ALIAS (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 | |
| 12137 | ALIAS (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 | |
| 12153 | static int |
| 12154 | bgp_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 | |
| 12170 | DEFUN (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 | |
| 12183 | DEFUN (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 | |
| 12202 | DEFUN (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 | |
| 12214 | ALIAS (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 */ |
| 12225 | DEFUN (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 */ |
| 12238 | DEFUN (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 | |
| 12250 | DEFUN (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 | |
| 12263 | DEFUN (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 | |
| 12281 | DEFUN (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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12304 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12305 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12306 | 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12320 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 12321 | prefix_free(p); |
| 12322 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12323 | } |
| 12324 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12325 | DEFUN (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 | |
| 12338 | DEFUN (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 | |
| 12352 | ALIAS (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 | |
| 12363 | DEFUN (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 | |
| 12383 | DEFUN (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 | |
| 12396 | ALIAS (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 | |
| 12406 | DEFUN (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 | |
| 12419 | ALIAS (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12429 | DEFUN (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 */ |
| 12442 | DEFUN (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 */ |
| 12456 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12468 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12469 | DEFUN (show_bgp_ipv4_prefix_longer, |
| 12470 | show_bgp_ipv4_prefix_longer_cmd, |
| 12471 | "show bgp ipv4 A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12472 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12473 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12474 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12475 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12482 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12485 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12486 | BGP_STR |
| 12487 | "Address family\n" |
| 12488 | "Address Family modifier\n" |
| 12489 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12490 | "Address Family modifier\n" |
| 12491 | "Address Family modifier\n" |
| 12492 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12493 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 12494 | "Display route and more specific routes\n") |
| 12495 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12496 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12497 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12498 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12504 | } |
| 12505 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12506 | ALIAS (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12509 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12510 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12511 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12521 | DEFUN (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 | } |
| 12544 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12558 | |
| 12559 | DEFUN (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12583 | DEFUN (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12606 | |
| 12607 | DEFUN (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" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12617 | "Display flap statistics of routes\n" |
| 12618 | "Network in the BGP routing table to display\n") |
| 12619 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12620 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12627 | bgp_show_type_flap_address); |
| 12628 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12629 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12632 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12633 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12634 | "Address family\n" |
| 12635 | "Address Family modifier\n" |
| 12636 | "Address Family modifier\n" |
| 12637 | "Address Family modifier\n" |
| 12638 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12639 | "Display detailed information about dampening\n" |
| 12640 | "Display flap statistics of routes\n" |
| 12641 | "Network in the BGP routing table to display\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12642 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12643 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12646 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12647 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12648 | "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 | } |
| 12665 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12678 | |
| 12679 | DEFUN (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" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12689 | "Display flap statistics of routes\n" |
| 12690 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12691 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12692 | 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, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12699 | bgp_show_type_flap_prefix); |
| 12700 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12701 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12702 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12705 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12706 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12707 | "Address family\n" |
| 12708 | "Address Family modifier\n" |
| 12709 | "Address Family modifier\n" |
| 12710 | "Address Family modifier\n" |
| 12711 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12712 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12716 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12719 | SHOW_STR |
| 12720 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12721 | "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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12728 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12729 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12737 | } |
| 12738 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12739 | ALIAS (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 | |
| 12753 | DEFUN (show_bgp_ipv6_prefix_longer, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12754 | 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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12761 | { |
| 12762 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 12763 | bgp_show_type_prefix_longer); |
| 12764 | } |
| 12765 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12766 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12767 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 12768 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12769 | { |
| 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 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 12785 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12786 | { |
| 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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12813 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12814 | enum 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 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12832 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12833 | static 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 | |
| 12851 | struct 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 |
| 12859 | static unsigned long |
| 12860 | ravg_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 | |
| 12873 | static int |
| 12874 | bgp_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 Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 12881 | if (!(top = bgp_table_top (ts->table))) |
| 12882 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12883 | |
| 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 Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 12899 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12900 | 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 Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 12920 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12921 | |
| 12922 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 12923 | { |
| 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 Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12929 | else if (prn->info) |
| 12930 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 12931 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12932 | 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 | |
| 12977 | static int |
| 12978 | bgp_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 Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12985 | vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s", |
| 12986 | afi, safi, VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12987 | 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 Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 13035 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13036 | vty_out (vty, "%12.2f%s", |
| 13037 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 13038 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13039 | 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 | |
| 13062 | static int |
| 13063 | bgp_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 Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 13077 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13078 | 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13092 | 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 Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 13100 | safi = SAFI_MPLS_VPN; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13101 | break; |
| 13102 | case 'e': |
| 13103 | safi = SAFI_ENCAP; |
| 13104 | break; |
| 13105 | default: |
| 13106 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13107 | safi_str, VTY_NEWLINE); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13108 | return CMD_WARNING; |
| 13109 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13110 | } |
| 13111 | else |
| 13112 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13113 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13114 | afi_str, VTY_NEWLINE); |
| 13115 | return CMD_WARNING; |
| 13116 | } |
| 13117 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13118 | return bgp_table_stats (vty, bgp, afi, safi); |
| 13119 | } |
| 13120 | |
| 13121 | DEFUN (show_bgp_statistics, |
| 13122 | show_bgp_statistics_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13123 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13124 | SHOW_STR |
| 13125 | BGP_STR |
| 13126 | "Address family\n" |
| 13127 | "Address family\n" |
| 13128 | "Address Family modifier\n" |
| 13129 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13130 | "Address Family modifier\n" |
| 13131 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13132 | "BGP RIB advertisement statistics\n") |
| 13133 | { |
| 13134 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 13135 | } |
| 13136 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13137 | ALIAS (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 Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13146 | DEFUN (show_bgp_statistics_view, |
| 13147 | show_bgp_statistics_view_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13148 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13149 | 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13156 | "Address Family modifier\n" |
| 13157 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13158 | "BGP RIB advertisement statistics\n") |
| 13159 | { |
| 13160 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 13161 | } |
| 13162 | |
| 13163 | ALIAS (show_bgp_statistics_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13164 | show_bgp_statistics_view_vpnv4_cmd, |
| 13165 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13166 | 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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 13172 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13173 | enum 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 | |
| 13187 | static 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 Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13201 | struct peer_pcounts |
| 13202 | { |
| 13203 | unsigned int count[PCOUNT_MAX]; |
| 13204 | const struct peer *peer; |
| 13205 | const struct bgp_table *table; |
| 13206 | }; |
| 13207 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13208 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13209 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13210 | { |
| 13211 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13212 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 13213 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13214 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13215 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13216 | { |
| 13217 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13218 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13219 | |
| 13220 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 13221 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13222 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13223 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13224 | for (ri = rn->info; ri; ri = ri->next) |
| 13225 | { |
| 13226 | char buf[SU_ADDRSTRLEN]; |
| 13227 | |
| 13228 | if (ri->peer != peer) |
| 13229 | continue; |
| 13230 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13231 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13232 | |
| 13233 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13234 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13235 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13236 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13237 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13238 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13239 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13240 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13241 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13242 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 13243 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13244 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13245 | |
| 13246 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 13247 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13248 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 13249 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13250 | 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 Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 13260 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13261 | 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 Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13271 | return 0; |
| 13272 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13273 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13274 | static int |
| 13275 | bgp_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 Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13297 | 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 Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13304 | vty_out (vty, "%20s: %-10d%s", |
| 13305 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13306 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13307 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13308 | { |
| 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13318 | DEFUN (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 Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13338 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13357 | |
| 13358 | DEFUN (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 | |
| 13384 | DEFUN (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 Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13406 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13407 | DEFUN (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 Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13410 | SHOW_STR |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13411 | BGP_STR |
| 13412 | "Address family\n" |
| 13413 | "Address Family modifier\n" |
| 13414 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13415 | "Address Family modifier\n" |
| 13416 | "Address Family modifier\n" |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13417 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13423 | 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 Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13429 | |
| 13430 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13431 | if (! peer) |
| 13432 | return CMD_WARNING; |
| 13433 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13434 | return bgp_peer_counts (vty, peer, AFI_IP, safi); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13435 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13436 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13437 | DEFUN (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 Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13454 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13455 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13466 | |
| 13467 | DEFUN (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 Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13470 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13487 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13488 | } |
| 13489 | |
| 13490 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 13491 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13492 | show_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 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13504 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13505 | |
| 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); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 13517 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 13518 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13519 | |
| 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); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 13534 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 13535 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13536 | 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); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 13558 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 13559 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13560 | 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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 13580 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13581 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 13582 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13583 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13601 | DEFUN (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 | |
| 13627 | ALIAS (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 | |
| 13638 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13664 | DEFUN (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 | |
| 13689 | DEFUN (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 | |
| 13714 | ALIAS (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 | |
| 13724 | ALIAS (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 */ |
| 13736 | ALIAS (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 */ |
| 13748 | DEFUN (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13767 | |
| 13768 | DEFUN (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 | |
| 13794 | ALIAS (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 | |
| 13805 | ALIAS (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 | |
| 13816 | DEFUN (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 */ |
| 13855 | ALIAS (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 */ |
| 13867 | DEFUN (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 | |
| 13887 | DEFUN (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 | |
| 13937 | DEFUN (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13963 | DEFUN (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 Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13966 | SHOW_STR |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13967 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13968 | "Address Family modifier\n" |
| 13969 | "Address Family modifier\n" |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13970 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13976 | safi_t safi; |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13977 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13978 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13979 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13980 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13981 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13982 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13983 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13984 | if (! peer) |
| 13985 | return CMD_WARNING; |
| 13986 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13987 | return peer_adj_routes (vty, peer, AFI_IP, safi, 0); |
| 13988 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13989 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13990 | DEFUN (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; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14005 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14006 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14016 | } |
| 14017 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14018 | DEFUN (show_bgp_view_ipv6_neighbor_advertised_route, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14019 | 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", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14021 | SHOW_STR |
| 14022 | BGP_STR |
| 14023 | "BGP view\n" |
| 14024 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14025 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14026 | "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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14044 | DEFUN (show_bgp_view_ipv6_neighbor_received_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14045 | 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", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14047 | 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" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14055 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14069 | |
| 14070 | DEFUN (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 Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 14073 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14074 | BGP_STR |
| 14075 | "Address family\n" |
| 14076 | "Address Family modifier\n" |
| 14077 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14078 | "Address Family modifier\n" |
| 14079 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14080 | "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 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14085 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14086 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14092 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14093 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14094 | if (! peer) |
| 14095 | return CMD_WARNING; |
| 14096 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14097 | return peer_adj_routes (vty, peer, AFI_IP, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14098 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 14099 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14100 | DEFUN (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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14129 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14130 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 14131 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14132 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14133 | SHOW_STR |
| 14134 | BGP_STR |
| 14135 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14136 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14137 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14138 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14139 | "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 Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 14152 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14153 | |
| 14154 | if (! peer) |
| 14155 | return CMD_WARNING; |
| 14156 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14157 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14160 | |
| 14161 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 14162 | } |
| 14163 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14164 | DEFUN (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 | |
| 14203 | DEFUN (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 | |
| 14258 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14268 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14271 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14272 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14273 | IP_STR |
| 14274 | "Address Family modifier\n" |
| 14275 | "Address Family modifier\n" |
| 14276 | "Address Family modifier\n" |
| 14277 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14278 | "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] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14285 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14286 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14287 | int count, ret; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14288 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14289 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14290 | if (bgp_parse_safi(argv[0], &safi)) { |
| 14291 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14292 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14293 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14294 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14295 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14301 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14302 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14303 | if (! peer) |
| 14304 | return CMD_WARNING; |
| 14305 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14306 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14312 | |
| 14313 | return CMD_SUCCESS; |
| 14314 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 14315 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14316 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14319 | SHOW_STR |
| 14320 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14321 | IP_STR |
| 14322 | "Address Family modifier\n" |
| 14323 | "Address Family modifier\n" |
| 14324 | "Address Family modifier\n" |
| 14325 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14326 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14327 | "Neighbor to display information about\n" |
| 14328 | "Neighbor to display information about\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14329 | "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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14363 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14364 | DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14365 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 14366 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14367 | SHOW_STR |
| 14368 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14369 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14370 | "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] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14377 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14378 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14379 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14380 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14381 | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14387 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14388 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14389 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14403 | DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14404 | 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", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14406 | SHOW_STR |
| 14407 | BGP_STR |
| 14408 | "BGP view\n" |
| 14409 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14410 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14411 | "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] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14418 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14419 | struct peer *peer; |
| 14420 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14421 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14422 | |
| 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] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14431 | 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 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14437 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 14438 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14439 | 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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 14452 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14453 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14454 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14455 | safi_t safi, enum bgp_show_type type) |
| 14456 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14457 | if (! peer || ! peer->afc[afi][safi]) |
| 14458 | { |
| 14459 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14460 | return CMD_WARNING; |
| 14461 | } |
| 14462 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 14463 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14464 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14465 | DEFUN (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 | |
| 14486 | DEFUN (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 | |
| 14507 | DEFUN (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 | |
| 14528 | DEFUN (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 | |
| 14556 | DEFUN (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 | |
| 14598 | ALIAS (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 | |
| 14607 | DEFUN (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 | |
| 14655 | ALIAS (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 | |
| 14666 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14726 | AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14727 | } |
| 14728 | |
| 14729 | ALIAS (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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14738 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14739 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14742 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14743 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14744 | "Address Family Modifier\n" |
| 14745 | "Address Family Modifier\n" |
| 14746 | "Address Family Modifier\n" |
| 14747 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14748 | "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 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14753 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14754 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14755 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14756 | 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]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14762 | if (! peer) |
| 14763 | return CMD_WARNING; |
| 14764 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14765 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14766 | bgp_show_type_flap_neighbor); |
| 14767 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 14768 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14769 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14772 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14773 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14774 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14798 | |
| 14799 | DEFUN (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" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14808 | "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 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14813 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14814 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14815 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14816 | 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]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14822 | if (! peer) |
| 14823 | return CMD_WARNING; |
| 14824 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14825 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14826 | bgp_show_type_damp_neighbor); |
| 14827 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 14828 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14829 | DEFUN (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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14832 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14833 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14858 | |
| 14859 | DEFUN (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 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14863 | 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 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14872 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14873 | 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 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14879 | |
| 14880 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14881 | if (! peer) |
| 14882 | return CMD_WARNING; |
| 14883 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14884 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14885 | bgp_show_type_neighbor); |
| 14886 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 14887 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14888 | DEFUN (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", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14891 | SHOW_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14892 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14893 | "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") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14900 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14901 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14902 | safi_t safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14903 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14904 | 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 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14908 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14909 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14910 | if (! peer) |
| 14911 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14912 | |
| 14913 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 14914 | bgp_show_type_neighbor); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14915 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14916 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14917 | DEFUN (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 Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14923 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14924 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14983 | AFI_IP, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14984 | } |
| 14985 | |
| 14986 | ALIAS (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 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14998 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14999 | DEFUN (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 Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15005 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15006 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15065 | AFI_IP, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15066 | } |
| 15067 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15068 | DEFUN (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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15128 | AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15129 | } |
| 15130 | |
| 15131 | ALIAS (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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15141 | ALIAS (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") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15152 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15153 | DEFUN (show_bgp_view_ipv6_neighbor_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15154 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 15155 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15156 | SHOW_STR |
| 15157 | BGP_STR |
| 15158 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15159 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15160 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15161 | "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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15180 | DEFUN (show_bgp_view_neighbor_damp, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15181 | 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 | |
| 15206 | DEFUN (show_bgp_view_ipv6_neighbor_damp, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15207 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 15208 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15209 | SHOW_STR |
| 15210 | BGP_STR |
| 15211 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15212 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15213 | "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" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15217 | "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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15233 | DEFUN (show_bgp_view_ipv6_neighbor_flap, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15234 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 15235 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15236 | SHOW_STR |
| 15237 | BGP_STR |
| 15238 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15239 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15240 | "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") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15245 | { |
| 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15260 | DEFUN (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 | |
| 15286 | ALIAS (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 | |
| 15296 | ALIAS (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 | |
| 15306 | DEFUN (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 | |
| 15332 | ALIAS (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 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15342 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15343 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15353 | /* old command */ |
| 15354 | ALIAS (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 */ |
| 15366 | DEFUN (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 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15387 | ALIAS (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 | |
| 15398 | ALIAS (show_bgp_view_neighbor_damp, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 15399 | 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" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 15407 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15408 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15409 | DEFUN (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 | |
| 15450 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15458 | DEFUN (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)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15461 | SHOW_STR |
| 15462 | BGP_STR |
| 15463 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15464 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15465 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15466 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15467 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15468 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15469 | 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 | } |
| 15499 | DEFUN (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; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15512 | |
| 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 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 15538 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15539 | } |
| 15540 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15541 | ALIAS (show_bgp_view_ipv4_rsclient, |
| 15542 | show_bgp_ipv4_rsclient_cmd, |
| 15543 | "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15544 | SHOW_STR |
| 15545 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15546 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15547 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15548 | NEIGHBOR_ADDR_STR2) |
| 15549 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15550 | ALIAS (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) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15558 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15559 | DEFUN (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 Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15565 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15566 | "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 | |
| 15607 | ALIAS (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 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15618 | DEFUN (show_bgp_view_rsclient_route, |
| 15619 | show_bgp_view_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15620 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15677 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15678 | } |
| 15679 | |
| 15680 | DEFUN (show_bgp_view_ipv6_rsclient_route, |
| 15681 | show_bgp_view_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15682 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15683 | SHOW_STR |
| 15684 | BGP_STR |
| 15685 | "BGP view\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15686 | "BGP view name\n" |
| 15687 | "IP6_STR" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15688 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15740 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15741 | } |
| 15742 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15743 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15744 | show_bgp_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15745 | "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 | |
| 15752 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
| 15753 | show_bgp_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15754 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15755 | SHOW_STR |
| 15756 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15757 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15758 | "Information about Route Server Client\n" |
| 15759 | NEIGHBOR_ADDR_STR |
| 15760 | "Network in the BGP routing table to display\n") |
| 15761 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15762 | DEFUN (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 Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15768 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15769 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15828 | AFI_IP6, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15829 | } |
| 15830 | |
| 15831 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15843 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15844 | DEFUN (show_bgp_view_rsclient_prefix, |
| 15845 | show_bgp_view_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15846 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15903 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15904 | } |
| 15905 | |
| 15906 | DEFUN (show_bgp_view_ipv6_rsclient_prefix, |
| 15907 | show_bgp_view_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15908 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15909 | SHOW_STR |
| 15910 | BGP_STR |
| 15911 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15912 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15913 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15914 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15966 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15967 | } |
| 15968 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15969 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15970 | show_bgp_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15971 | "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 | |
| 15978 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
| 15979 | show_bgp_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15980 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15981 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15987 | DEFUN (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 Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15993 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15994 | "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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16053 | AFI_IP6, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16054 | } |
| 16055 | |
| 16056 | ALIAS (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16068 | struct bgp_table *bgp_distance_table; |
| 16069 | |
| 16070 | struct 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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 16079 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 16080 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16081 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 16082 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16083 | } |
| 16084 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 16085 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16086 | bgp_distance_free (struct bgp_distance *bdistance) |
| 16087 | { |
| 16088 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 16089 | } |
| 16090 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 16091 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 16092 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 16093 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16094 | { |
| 16095 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16096 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16097 | u_char distance; |
| 16098 | struct bgp_node *rn; |
| 16099 | struct bgp_distance *bdistance; |
| 16100 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16101 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16102 | 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 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 16138 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 16139 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 16140 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16141 | { |
| 16142 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16143 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16144 | u_char distance; |
| 16145 | struct bgp_node *rn; |
| 16146 | struct bgp_distance *bdistance; |
| 16147 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16148 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16149 | 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 Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 16165 | |
| 16166 | if (bdistance->distance != distance) |
| 16167 | { |
| 16168 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 16169 | return CMD_WARNING; |
| 16170 | } |
| 16171 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16172 | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16183 | /* Apply BGP information to distance method. */ |
| 16184 | u_char |
| 16185 | bgp_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] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 16243 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16244 | { |
| 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 Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16257 | #ifdef HAVE_IPV6 |
| 16258 | /* Apply BGP information to ipv6 distance method. */ |
| 16259 | u_char |
| 16260 | ipv6_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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16332 | DEFUN (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 | |
| 16351 | DEFUN (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 | |
| 16371 | ALIAS (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 | |
| 16378 | DEFUN (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 | |
| 16389 | DEFUN (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 | |
| 16401 | DEFUN (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 | |
| 16413 | DEFUN (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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 16425 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16426 | #ifdef HAVE_IPV6 |
| 16427 | DEFUN (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 | |
| 16446 | DEFUN (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 | |
| 16466 | ALIAS (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 | |
| 16473 | DEFUN (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 | |
| 16484 | DEFUN (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 | |
| 16496 | DEFUN (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 | |
| 16508 | DEFUN (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16522 | DEFUN (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; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 16552 | |
| 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16560 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 16561 | half, reuse, suppress, max); |
| 16562 | } |
| 16563 | |
| 16564 | ALIAS (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 | |
| 16571 | ALIAS (bgp_damp_set, |
| 16572 | bgp_damp_set3_cmd, |
| 16573 | "bgp dampening", |
| 16574 | "BGP Specific commands\n" |
| 16575 | "Enable route-flap dampening\n") |
| 16576 | |
| 16577 | DEFUN (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 | |
| 16590 | ALIAS (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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16601 | DEFUN (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 | |
| 16613 | ALIAS (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 | |
| 16622 | DEFUN (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 | |
| 16634 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16643 | DEFUN (show_bgp_ipv4_safi_dampened_paths, |
| 16644 | show_bgp_ipv4_safi_dampened_paths_cmd, |
| 16645 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16646 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16647 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16648 | IP_STR |
| 16649 | "Address Family modifier\n" |
| 16650 | "Address Family modifier\n" |
| 16651 | "Address Family modifier\n" |
| 16652 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16653 | "Display paths suppressed due to dampening\n") |
| 16654 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16655 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16656 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16657 | 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 | } |
| 16664 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 16667 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 16668 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16669 | IP_STR |
| 16670 | "Address Family modifier\n" |
| 16671 | "Address Family modifier\n" |
| 16672 | "Address Family modifier\n" |
| 16673 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 16674 | "Display detailed information about dampening\n" |
| 16675 | "Display paths suppressed due to dampening\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 16676 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16677 | DEFUN (show_bgp_ipv6_safi_dampened_paths, |
| 16678 | show_bgp_ipv6_safi_dampened_paths_cmd, |
| 16679 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16680 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16681 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16682 | 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 | } |
| 16698 | ALIAS (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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16710 | |
| 16711 | DEFUN (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" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16721 | "Display flap statistics of routes\n") |
| 16722 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16723 | safi_t safi; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 16724 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16725 | 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 | } |
| 16732 | ALIAS (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", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 16735 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 16736 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16737 | "Address Family\n" |
| 16738 | "Address Family modifier\n" |
| 16739 | "Address Family modifier\n" |
| 16740 | "Address Family modifier\n" |
| 16741 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 16742 | "Display detailed information about dampening\n" |
| 16743 | "Display flap statistics of routes\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 16744 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16745 | DEFUN (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 | } |
| 16766 | ALIAS (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") |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 16778 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16779 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 16780 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 16781 | bgp_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) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16784 | { |
| 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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16824 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16825 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16826 | for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16827 | { |
| 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 Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 16833 | { |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16852 | } |
| 16853 | } |
| 16854 | else |
| 16855 | { |
| 16856 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 16857 | { |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16876 | } |
| 16877 | |
| 16878 | return CMD_SUCCESS; |
| 16879 | } |
| 16880 | |
| 16881 | DEFUN (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 | |
| 16893 | DEFUN (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 | |
| 16906 | DEFUN (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 | |
| 16919 | DEFUN (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 Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 16942 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16943 | /* also used for encap safi */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 16944 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16945 | bgp_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. */ |
| 16985 | int |
| 16986 | bgp_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 Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16995 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16996 | 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 Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 17037 | else |
| 17038 | { |
| 17039 | if (bgp_static->backdoor) |
| 17040 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 17041 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17042 | |
| 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 | |
| 17083 | int |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 17084 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp, |
| 17085 | afi_t afi, safi_t safi, int *write) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17086 | { |
| 17087 | struct bgp_node *rn; |
| 17088 | struct bgp_distance *bdistance; |
| 17089 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 17090 | 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 Jakma | 5bc62ca | 2016-07-11 16:21:23 +0100 | [diff] [blame] | 17127 | 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 Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 17135 | } |
| 17136 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17137 | |
| 17138 | return 0; |
| 17139 | } |
| 17140 | |
| 17141 | /* Allocate routing table structure and install commands. */ |
| 17142 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 17143 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17144 | { |
| 17145 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 17146 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17147 | |
| 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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 17196 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17197 | 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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 17202 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17203 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17258 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17259 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17260 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17269 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17270 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17298 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17303 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17315 | |
| 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17333 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17340 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17341 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17386 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17387 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17388 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17389 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17390 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17391 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 17392 | |
| 17393 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17394 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17395 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17400 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17401 | 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17417 | 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 Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17422 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17430 | |
| 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17446 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17447 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17448 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17449 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17450 | |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 17451 | /* BGP dampening clear commands */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17452 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 17453 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17454 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17455 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 17456 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 17457 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17458 | /* 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.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 17469 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 17470 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 17471 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17472 | /* 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 Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17481 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17482 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17483 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17484 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17485 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17486 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17487 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17488 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17489 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17490 | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17498 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17499 | |
| 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17507 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17508 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17509 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17510 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17511 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17512 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17513 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17514 | install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 17515 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17516 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17517 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17518 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17519 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17520 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17521 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17522 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17523 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17524 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17525 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17526 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17527 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17528 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 17529 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17530 | install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 17531 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17532 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17533 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17534 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17535 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17536 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 17537 | |
| 17538 | /* Restricted: |
| 17539 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 17540 | */ |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 17541 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17542 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 17543 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17544 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17545 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17553 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17557 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17558 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17559 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17560 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 17561 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 17562 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 17563 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17564 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17565 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17566 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 17567 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17568 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 17569 | /* Statistics */ |
| 17570 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 17571 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17572 | |
| 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 Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 17580 | #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 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17589 | |
| 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); |
Balaji | 9145f0e | 2016-01-20 22:59:27 +0530 | [diff] [blame] | 17600 | |
| 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 Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 17608 | |
| 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 Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 17651 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 17652 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 17653 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17654 | |
| 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 17659 | install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 17660 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17661 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 17666 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17669 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17706 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17718 | 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); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 17729 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17730 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 17731 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17733 | 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 Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 17760 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17761 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 17762 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 17763 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17764 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 17768 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17771 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17791 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17799 | 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 Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 17803 | |
| 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 17807 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17808 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 17812 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17818 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17835 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17842 | 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 Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 17860 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17861 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 17862 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 17863 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17869 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17877 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17881 | 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 Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 17884 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17885 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 17886 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 17887 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17888 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17905 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17911 | 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 Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17929 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17935 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17936 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17937 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17938 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17939 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17940 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17941 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17942 | /* 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 Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 17959 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17960 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 17961 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17962 | |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 17963 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17973 | 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 Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 17977 | |
| 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17982 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 17983 | |
| 17984 | void |
| 17985 | bgp_route_finish (void) |
| 17986 | { |
| 17987 | bgp_table_unlock (bgp_distance_table); |
| 17988 | bgp_distance_table = NULL; |
| 17989 | } |