paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP routing information |
| 2 | Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro |
| 3 | |
| 4 | This file is part of GNU Zebra. |
| 5 | |
| 6 | GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by the |
| 8 | Free Software Foundation; either version 2, or (at your option) any |
| 9 | later version. |
| 10 | |
| 11 | GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | 02111-1307, USA. */ |
| 20 | |
| 21 | #include <zebra.h> |
| 22 | |
| 23 | #include "prefix.h" |
| 24 | #include "linklist.h" |
| 25 | #include "memory.h" |
| 26 | #include "command.h" |
| 27 | #include "stream.h" |
| 28 | #include "filter.h" |
| 29 | #include "str.h" |
| 30 | #include "log.h" |
| 31 | #include "routemap.h" |
| 32 | #include "buffer.h" |
| 33 | #include "sockunion.h" |
| 34 | #include "plist.h" |
| 35 | #include "thread.h" |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 36 | #include "workqueue.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | |
| 38 | #include "bgpd/bgpd.h" |
| 39 | #include "bgpd/bgp_table.h" |
| 40 | #include "bgpd/bgp_route.h" |
| 41 | #include "bgpd/bgp_attr.h" |
| 42 | #include "bgpd/bgp_debug.h" |
| 43 | #include "bgpd/bgp_aspath.h" |
| 44 | #include "bgpd/bgp_regex.h" |
| 45 | #include "bgpd/bgp_community.h" |
| 46 | #include "bgpd/bgp_ecommunity.h" |
| 47 | #include "bgpd/bgp_clist.h" |
| 48 | #include "bgpd/bgp_packet.h" |
| 49 | #include "bgpd/bgp_filter.h" |
| 50 | #include "bgpd/bgp_fsm.h" |
| 51 | #include "bgpd/bgp_mplsvpn.h" |
| 52 | #include "bgpd/bgp_nexthop.h" |
| 53 | #include "bgpd/bgp_damp.h" |
| 54 | #include "bgpd/bgp_advertise.h" |
| 55 | #include "bgpd/bgp_zebra.h" |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 56 | #include "bgpd/bgp_vty.h" |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 57 | #include "bgpd/bgp_mpath.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | |
| 59 | /* Extern from bgp_dump.c */ |
Stephen Hemminger | dde7258 | 2009-05-08 15:19:07 -0700 | [diff] [blame] | 60 | extern const char *bgp_origin_str[]; |
| 61 | extern const char *bgp_origin_long_str[]; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 62 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 63 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 64 | 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] | 65 | struct prefix_rd *prd) |
| 66 | { |
| 67 | struct bgp_node *rn; |
| 68 | struct bgp_node *prn = NULL; |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 69 | |
| 70 | assert (table); |
| 71 | if (!table) |
| 72 | return NULL; |
| 73 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 74 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 76 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 77 | |
| 78 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 79 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 80 | else |
| 81 | bgp_unlock_node (prn); |
| 82 | table = prn->info; |
| 83 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 84 | |
| 85 | rn = bgp_node_get (table, p); |
| 86 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 87 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 88 | rn->prn = prn; |
| 89 | |
| 90 | return rn; |
| 91 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 92 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 93 | /* Allocate bgp_info_extra */ |
| 94 | static struct bgp_info_extra * |
| 95 | bgp_info_extra_new (void) |
| 96 | { |
| 97 | struct bgp_info_extra *new; |
| 98 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); |
| 99 | return new; |
| 100 | } |
| 101 | |
| 102 | static void |
| 103 | bgp_info_extra_free (struct bgp_info_extra **extra) |
| 104 | { |
| 105 | if (extra && *extra) |
| 106 | { |
| 107 | if ((*extra)->damp_info) |
| 108 | bgp_damp_info_free ((*extra)->damp_info, 0); |
| 109 | |
| 110 | (*extra)->damp_info = NULL; |
| 111 | |
| 112 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); |
| 113 | |
| 114 | *extra = NULL; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /* Get bgp_info extra information for the given bgp_info, lazy allocated |
| 119 | * if required. |
| 120 | */ |
| 121 | struct bgp_info_extra * |
| 122 | bgp_info_extra_get (struct bgp_info *ri) |
| 123 | { |
| 124 | if (!ri->extra) |
| 125 | ri->extra = bgp_info_extra_new(); |
| 126 | return ri->extra; |
| 127 | } |
| 128 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | /* Allocate new bgp info structure. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 130 | static struct bgp_info * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 131 | bgp_info_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 133 | return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 137 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 138 | bgp_info_free (struct bgp_info *binfo) |
| 139 | { |
| 140 | if (binfo->attr) |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 141 | bgp_attr_unintern (&binfo->attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 142 | |
| 143 | bgp_info_extra_free (&binfo->extra); |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 144 | bgp_info_mpath_free (&binfo->mpath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 145 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 146 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 147 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 149 | } |
| 150 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 151 | struct bgp_info * |
| 152 | bgp_info_lock (struct bgp_info *binfo) |
| 153 | { |
| 154 | binfo->lock++; |
| 155 | return binfo; |
| 156 | } |
| 157 | |
| 158 | struct bgp_info * |
| 159 | bgp_info_unlock (struct bgp_info *binfo) |
| 160 | { |
| 161 | assert (binfo && binfo->lock > 0); |
| 162 | binfo->lock--; |
| 163 | |
| 164 | if (binfo->lock == 0) |
| 165 | { |
| 166 | #if 0 |
| 167 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 168 | zlog_backtrace (LOG_DEBUG); |
| 169 | #endif |
| 170 | bgp_info_free (binfo); |
| 171 | return NULL; |
| 172 | } |
| 173 | |
| 174 | #if 0 |
| 175 | if (binfo->lock == 1) |
| 176 | { |
| 177 | zlog_debug ("%s: unlocked to 1", __func__); |
| 178 | zlog_backtrace (LOG_DEBUG); |
| 179 | } |
| 180 | #endif |
| 181 | |
| 182 | return binfo; |
| 183 | } |
| 184 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 185 | void |
| 186 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 187 | { |
| 188 | struct bgp_info *top; |
| 189 | |
| 190 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 191 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 192 | ri->next = rn->info; |
| 193 | ri->prev = NULL; |
| 194 | if (top) |
| 195 | top->prev = ri; |
| 196 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 197 | |
| 198 | bgp_info_lock (ri); |
| 199 | bgp_lock_node (rn); |
| 200 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 201 | } |
| 202 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 203 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 204 | completion callback *only* */ |
| 205 | static void |
| 206 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | { |
| 208 | if (ri->next) |
| 209 | ri->next->prev = ri->prev; |
| 210 | if (ri->prev) |
| 211 | ri->prev->next = ri->next; |
| 212 | else |
| 213 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 214 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 215 | bgp_info_mpath_dequeue (ri); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 216 | bgp_info_unlock (ri); |
| 217 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | } |
| 219 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 220 | void |
| 221 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 222 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 223 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
| 224 | /* set of previous already took care of pcount */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 225 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 226 | } |
| 227 | |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 228 | /* undo the effects of a previous call to bgp_info_delete; typically |
| 229 | called when a route is deleted and then quickly re-added before the |
| 230 | deletion has been processed */ |
| 231 | static void |
| 232 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) |
| 233 | { |
| 234 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); |
| 235 | /* unset of previous already took care of pcount */ |
| 236 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 237 | } |
| 238 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 239 | /* Adjust pcount as required */ |
| 240 | static void |
| 241 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) |
| 242 | { |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 243 | struct bgp_table *table; |
| 244 | |
| 245 | assert (rn && bgp_node_table (rn)); |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 246 | assert (ri && ri->peer && ri->peer->bgp); |
| 247 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 248 | table = bgp_node_table (rn); |
| 249 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 250 | /* Ignore 'pcount' for RS-client tables */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 251 | if (table->type != BGP_TABLE_MAIN |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 252 | || ri->peer == ri->peer->bgp->peer_self) |
| 253 | return; |
| 254 | |
| 255 | if (BGP_INFO_HOLDDOWN (ri) |
| 256 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 257 | { |
| 258 | |
| 259 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 260 | |
| 261 | /* slight hack, but more robust against errors. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 262 | if (ri->peer->pcount[table->afi][table->safi]) |
| 263 | ri->peer->pcount[table->afi][table->safi]--; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 264 | else |
| 265 | { |
| 266 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 267 | __func__, ri->peer->host); |
| 268 | zlog_backtrace (LOG_WARNING); |
| 269 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 270 | } |
| 271 | } |
| 272 | else if (!BGP_INFO_HOLDDOWN (ri) |
| 273 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 274 | { |
| 275 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 276 | ri->peer->pcount[table->afi][table->safi]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | |
| 280 | |
| 281 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 282 | * This is here primarily to keep prefix-count in check. |
| 283 | */ |
| 284 | void |
| 285 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 286 | { |
| 287 | SET_FLAG (ri->flags, flag); |
| 288 | |
| 289 | /* early bath if we know it's not a flag that changes useability state */ |
| 290 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 291 | return; |
| 292 | |
| 293 | bgp_pcount_adjust (rn, ri); |
| 294 | } |
| 295 | |
| 296 | void |
| 297 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 298 | { |
| 299 | UNSET_FLAG (ri->flags, flag); |
| 300 | |
| 301 | /* early bath if we know it's not a flag that changes useability state */ |
| 302 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 303 | return; |
| 304 | |
| 305 | bgp_pcount_adjust (rn, ri); |
| 306 | } |
| 307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 308 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 309 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 310 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 311 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 312 | { |
| 313 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 314 | return attr->med; |
| 315 | else |
| 316 | { |
| 317 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 318 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 319 | else |
| 320 | return 0; |
| 321 | } |
| 322 | } |
| 323 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 324 | /* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist |
| 325 | * is preferred, or 0 if they are the same (usually will only occur if |
| 326 | * multipath is enabled */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 327 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 328 | 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] | 329 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 330 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 331 | struct attr *newattr, *existattr; |
| 332 | struct attr_extra *newattre, *existattre; |
| 333 | bgp_peer_sort_t new_sort; |
| 334 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 335 | u_int32_t new_pref; |
| 336 | u_int32_t exist_pref; |
| 337 | u_int32_t new_med; |
| 338 | u_int32_t exist_med; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 339 | u_int32_t new_weight; |
| 340 | u_int32_t exist_weight; |
| 341 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 342 | struct in_addr new_id; |
| 343 | struct in_addr exist_id; |
| 344 | int new_cluster; |
| 345 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 346 | int internal_as_route; |
| 347 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 348 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 349 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 350 | /* 0. Null check. */ |
| 351 | if (new == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 352 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 353 | if (exist == NULL) |
| 354 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 355 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 356 | newattr = new->attr; |
| 357 | existattr = exist->attr; |
| 358 | newattre = newattr->extra; |
| 359 | existattre = existattr->extra; |
| 360 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 361 | /* 1. Weight check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 362 | new_weight = exist_weight = 0; |
| 363 | |
| 364 | if (newattre) |
| 365 | new_weight = newattre->weight; |
| 366 | if (existattre) |
| 367 | exist_weight = existattre->weight; |
| 368 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 369 | if (new_weight > exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 370 | return -1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 371 | if (new_weight < exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 372 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 373 | |
| 374 | /* 2. Local preference check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 375 | new_pref = exist_pref = bgp->default_local_pref; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 376 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 377 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 378 | new_pref = newattr->local_pref; |
| 379 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 380 | exist_pref = existattr->local_pref; |
| 381 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 382 | if (new_pref > exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 383 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 384 | if (new_pref < exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 385 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 386 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 387 | /* 3. Local route check. We prefer: |
| 388 | * - BGP_ROUTE_STATIC |
| 389 | * - BGP_ROUTE_AGGREGATE |
| 390 | * - BGP_ROUTE_REDISTRIBUTE |
| 391 | */ |
| 392 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 393 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 394 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 395 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 396 | |
| 397 | /* 4. AS path length check. */ |
| 398 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 399 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 400 | int exist_hops = aspath_count_hops (existattr->aspath); |
| 401 | int exist_confeds = aspath_count_confeds (existattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 402 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 403 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 404 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 405 | int aspath_hops; |
| 406 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 407 | aspath_hops = aspath_count_hops (newattr->aspath); |
| 408 | aspath_hops += aspath_count_confeds (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 409 | |
| 410 | if ( aspath_hops < (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 411 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 412 | if ( aspath_hops > (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 413 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 414 | } |
| 415 | else |
| 416 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 417 | int newhops = aspath_count_hops (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 418 | |
| 419 | if (newhops < exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 420 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 421 | if (newhops > exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 422 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 423 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | /* 5. Origin check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 427 | if (newattr->origin < existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 428 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 429 | if (newattr->origin > existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 430 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 431 | |
| 432 | /* 6. MED check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 433 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
| 434 | && aspath_count_hops (existattr->aspath) == 0); |
| 435 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 |
| 436 | && aspath_count_confeds (existattr->aspath) > 0 |
| 437 | && aspath_count_hops (newattr->aspath) == 0 |
| 438 | && aspath_count_hops (existattr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 439 | |
| 440 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 441 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 442 | && confed_as_route) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 443 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
| 444 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 445 | || internal_as_route) |
| 446 | { |
| 447 | new_med = bgp_med_value (new->attr, bgp); |
| 448 | exist_med = bgp_med_value (exist->attr, bgp); |
| 449 | |
| 450 | if (new_med < exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 451 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 452 | if (new_med > exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 453 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | /* 7. Peer type check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 457 | new_sort = new->peer->sort; |
| 458 | exist_sort = exist->peer->sort; |
| 459 | |
| 460 | if (new_sort == BGP_PEER_EBGP |
| 461 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 462 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 463 | if (exist_sort == BGP_PEER_EBGP |
| 464 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 465 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 466 | |
| 467 | /* 8. IGP metric check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 468 | newm = existm = 0; |
| 469 | |
| 470 | if (new->extra) |
| 471 | newm = new->extra->igpmetric; |
| 472 | if (exist->extra) |
| 473 | existm = exist->extra->igpmetric; |
| 474 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 475 | if (newm < existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 476 | return -1; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 477 | if (newm > existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 478 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 479 | |
| 480 | /* 9. Maximum path check. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 481 | if (bgp_mpath_is_configured (bgp, afi, safi)) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 482 | { |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 483 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) |
| 484 | { |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 485 | /* |
| 486 | * For the two paths, all comparison steps till IGP metric |
| 487 | * have succeeded - including AS_PATH hop count. Since 'bgp |
| 488 | * bestpath as-path multipath-relax' knob is on, we don't need |
| 489 | * an exact match of AS_PATH. Thus, mark the paths are equal. |
| 490 | * That will trigger both these paths to get into the multipath |
| 491 | * array. |
| 492 | */ |
| 493 | return 0; |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 494 | } |
| 495 | else if (new->peer->sort == BGP_PEER_IBGP) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 496 | { |
| 497 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 498 | return 0; |
| 499 | } |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 500 | else if (new->peer->as == exist->peer->as) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 501 | return 0; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 502 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 503 | |
| 504 | /* 10. If both paths are external, prefer the path that was received |
| 505 | first (the oldest one). This step minimizes route-flap, since a |
| 506 | newer path won't displace an older one, even if it was the |
| 507 | preferred route based on the additional decision criteria below. */ |
| 508 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 509 | && new_sort == BGP_PEER_EBGP |
| 510 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | { |
| 512 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 513 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 514 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 515 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 516 | } |
| 517 | |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 518 | /* 11. Router-ID comparision. */ |
| 519 | /* If one of the paths is "stale", the corresponding peer router-id will |
| 520 | * be 0 and would always win over the other path. If originator id is |
| 521 | * used for the comparision, it will decide which path is better. |
| 522 | */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 523 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 524 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 525 | else |
| 526 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 527 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 528 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | else |
| 530 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 531 | |
| 532 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 533 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 535 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | |
| 537 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 538 | new_cluster = exist_cluster = 0; |
| 539 | |
| 540 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 541 | new_cluster = newattre->cluster->length; |
| 542 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 543 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | |
| 545 | if (new_cluster < exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 546 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 547 | if (new_cluster > exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 548 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 549 | |
| 550 | /* 13. Neighbor address comparision. */ |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 551 | /* Do this only if neither path is "stale" as stale paths do not have |
| 552 | * valid peer information (as the connection may or may not be up). |
| 553 | */ |
| 554 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 555 | return -1; |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 556 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 557 | return 1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 558 | /* locally configured routes to advertise do not have su_remote */ |
| 559 | if (new->peer->su_remote == NULL) |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 560 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 561 | if (exist->peer->su_remote == NULL) |
| 562 | return -1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 563 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 564 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 565 | |
| 566 | if (ret == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 567 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 568 | if (ret == -1) |
| 569 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 571 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 572 | } |
| 573 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 574 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 575 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 576 | afi_t afi, safi_t safi) |
| 577 | { |
| 578 | struct bgp_filter *filter; |
| 579 | |
| 580 | filter = &peer->filter[afi][safi]; |
| 581 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 582 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 583 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 584 | && !(F ## _IN (filter))) \ |
| 585 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 586 | peer->host, #f, F ## _IN_NAME(filter)); |
| 587 | |
| 588 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 589 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 590 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 591 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 592 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 593 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 594 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 595 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 596 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 597 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 599 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 600 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 601 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 602 | if (FILTER_LIST_IN_NAME (filter)) { |
| 603 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 606 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 607 | } |
| 608 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 609 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 610 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 611 | } |
| 612 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 613 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 614 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 615 | afi_t afi, safi_t safi) |
| 616 | { |
| 617 | struct bgp_filter *filter; |
| 618 | |
| 619 | filter = &peer->filter[afi][safi]; |
| 620 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 621 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 622 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 623 | && !(F ## _OUT (filter))) \ |
| 624 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 625 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 626 | |
| 627 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 628 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 629 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 630 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 631 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 632 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 633 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 634 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 635 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 636 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 637 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 638 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 639 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 640 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 641 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 642 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 644 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 645 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 646 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 647 | |
| 648 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 649 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 653 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 654 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 655 | { |
| 656 | if (attr->community) |
| 657 | { |
| 658 | /* NO_ADVERTISE check. */ |
| 659 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 660 | return 1; |
| 661 | |
| 662 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 663 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 664 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 665 | return 1; |
| 666 | |
| 667 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 668 | if (peer->sort == BGP_PEER_EBGP |
| 669 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 670 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 671 | return 1; |
| 672 | } |
| 673 | return 0; |
| 674 | } |
| 675 | |
| 676 | /* Route reflection loop check. */ |
| 677 | static int |
| 678 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 679 | { |
| 680 | struct in_addr cluster_id; |
| 681 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 682 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 683 | { |
| 684 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 685 | cluster_id = peer->bgp->cluster_id; |
| 686 | else |
| 687 | cluster_id = peer->bgp->router_id; |
| 688 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 689 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | return 1; |
| 691 | } |
| 692 | return 0; |
| 693 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 694 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 695 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 696 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 697 | afi_t afi, safi_t safi) |
| 698 | { |
| 699 | struct bgp_filter *filter; |
| 700 | struct bgp_info info; |
| 701 | route_map_result_t ret; |
| 702 | |
| 703 | filter = &peer->filter[afi][safi]; |
| 704 | |
| 705 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 706 | if (peer->weight) |
| 707 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 708 | |
| 709 | /* Route map apply. */ |
| 710 | if (ROUTE_MAP_IN_NAME (filter)) |
| 711 | { |
| 712 | /* Duplicate current value to new strucutre for modification. */ |
| 713 | info.peer = peer; |
| 714 | info.attr = attr; |
| 715 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 716 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 717 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 718 | /* Apply BGP route map to the attribute. */ |
| 719 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 720 | |
| 721 | peer->rmap_type = 0; |
| 722 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | if (ret == RMAP_DENYMATCH) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 724 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 725 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 726 | } |
| 727 | return RMAP_PERMIT; |
| 728 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 729 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 730 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 731 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 732 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 733 | { |
| 734 | struct bgp_filter *filter; |
| 735 | struct bgp_info info; |
| 736 | route_map_result_t ret; |
| 737 | |
| 738 | filter = &peer->filter[afi][safi]; |
| 739 | |
| 740 | /* Route map apply. */ |
| 741 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 742 | { |
| 743 | /* Duplicate current value to new strucutre for modification. */ |
| 744 | info.peer = rsclient; |
| 745 | info.attr = attr; |
| 746 | |
| 747 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 748 | |
| 749 | /* Apply BGP route map to the attribute. */ |
| 750 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 751 | |
| 752 | rsclient->rmap_type = 0; |
| 753 | |
| 754 | if (ret == RMAP_DENYMATCH) |
| 755 | { |
| 756 | /* Free newly generated AS path and community by route-map. */ |
| 757 | bgp_attr_flush (attr); |
| 758 | return RMAP_DENY; |
| 759 | } |
| 760 | } |
| 761 | return RMAP_PERMIT; |
| 762 | } |
| 763 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 764 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 765 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 766 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 767 | { |
| 768 | struct bgp_filter *filter; |
| 769 | struct bgp_info info; |
| 770 | route_map_result_t ret; |
| 771 | |
| 772 | filter = &rsclient->filter[afi][safi]; |
| 773 | |
| 774 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 775 | if (peer->weight) |
| 776 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 777 | |
| 778 | /* Route map apply. */ |
| 779 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 780 | { |
| 781 | /* Duplicate current value to new strucutre for modification. */ |
| 782 | info.peer = peer; |
| 783 | info.attr = attr; |
| 784 | |
| 785 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 786 | |
| 787 | /* Apply BGP route map to the attribute. */ |
| 788 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 789 | |
| 790 | peer->rmap_type = 0; |
| 791 | |
| 792 | if (ret == RMAP_DENYMATCH) |
| 793 | { |
| 794 | /* Free newly generated AS path and community by route-map. */ |
| 795 | bgp_attr_flush (attr); |
| 796 | return RMAP_DENY; |
| 797 | } |
| 798 | } |
| 799 | return RMAP_PERMIT; |
| 800 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 801 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 802 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 803 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 804 | struct attr *attr, afi_t afi, safi_t safi) |
| 805 | { |
| 806 | int ret; |
| 807 | char buf[SU_ADDRSTRLEN]; |
| 808 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | struct peer *from; |
| 810 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 811 | int transparent; |
| 812 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 813 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 814 | |
| 815 | from = ri->peer; |
| 816 | filter = &peer->filter[afi][safi]; |
| 817 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 818 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 819 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 820 | if (DISABLE_BGP_ANNOUNCE) |
| 821 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 822 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 823 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 824 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 825 | return 0; |
| 826 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 827 | /* Do not send back route to sender. */ |
| 828 | if (from == peer) |
| 829 | return 0; |
| 830 | |
| 831 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 832 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 833 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 834 | return 0; |
| 835 | |
| 836 | /* Default route check. */ |
| 837 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 838 | { |
| 839 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 840 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 841 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 842 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 843 | } |
| 844 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 845 | /* Transparency check. */ |
| 846 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 847 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 848 | transparent = 1; |
| 849 | else |
| 850 | transparent = 0; |
| 851 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 852 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 853 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | return 0; |
| 855 | |
| 856 | /* If the attribute has originator-id and it is same as remote |
| 857 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 858 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 859 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 860 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 861 | { |
| 862 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 863 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 864 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 865 | peer->host, |
| 866 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 867 | p->prefixlen); |
| 868 | return 0; |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | /* ORF prefix-list filter check */ |
| 873 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 874 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 875 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 876 | if (peer->orf_plist[afi][safi]) |
| 877 | { |
| 878 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 879 | return 0; |
| 880 | } |
| 881 | |
| 882 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 883 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 884 | { |
| 885 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 886 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 887 | "%s [Update:SEND] %s/%d is filtered", |
| 888 | peer->host, |
| 889 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 890 | p->prefixlen); |
| 891 | return 0; |
| 892 | } |
| 893 | |
| 894 | #ifdef BGP_SEND_ASPATH_CHECK |
| 895 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 896 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 897 | { |
| 898 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 899 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 900 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 901 | peer->host, peer->as); |
| 902 | return 0; |
| 903 | } |
| 904 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 905 | |
| 906 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 907 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 908 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 909 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 910 | { |
| 911 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 912 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 913 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 914 | peer->host, |
| 915 | bgp->confed_id); |
| 916 | return 0; |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 921 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 922 | reflect = 1; |
| 923 | else |
| 924 | reflect = 0; |
| 925 | |
| 926 | /* IBGP reflection check. */ |
| 927 | if (reflect) |
| 928 | { |
| 929 | /* A route from a Client peer. */ |
| 930 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 931 | { |
| 932 | /* Reflect to all the Non-Client peers and also to the |
| 933 | Client peers other than the originator. Originator check |
| 934 | is already done. So there is noting to do. */ |
| 935 | /* no bgp client-to-client reflection check. */ |
| 936 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 937 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 938 | return 0; |
| 939 | } |
| 940 | else |
| 941 | { |
| 942 | /* A route from a Non-client peer. Reflect to all other |
| 943 | clients. */ |
| 944 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 945 | return 0; |
| 946 | } |
| 947 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 948 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 949 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 950 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 951 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 952 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 953 | if ((peer->sort == BGP_PEER_IBGP |
| 954 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 955 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 956 | { |
| 957 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 958 | attr->local_pref = bgp->default_local_pref; |
| 959 | } |
| 960 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 961 | /* If originator-id is not set and the route is to be reflected, |
| 962 | set the originator id */ |
| 963 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 964 | from->sort == BGP_PEER_IBGP && |
| 965 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 966 | { |
| 967 | attr->extra = bgp_attr_extra_get(attr); |
| 968 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 969 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 970 | } |
| 971 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 972 | /* 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] | 973 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 974 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 975 | { |
| 976 | if (ri->peer != bgp->peer_self && ! transparent |
| 977 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 978 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 979 | } |
| 980 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 981 | |
| 982 | #define NEXTHOP_IS_V4 (\ |
| 983 | (safi != SAFI_ENCAP && p->family == AF_INET) || \ |
| 984 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4)) |
| 985 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 986 | #define NEXTHOP_IS_V6 (\ |
| 987 | (safi != SAFI_ENCAP && p->family == AF_INET6) || \ |
| 988 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 989 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 990 | /* next-hop-set */ |
Timo Teräs | 9e7a53c | 2014-04-24 10:22:37 +0300 | [diff] [blame] | 991 | if (transparent |
| 992 | || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 993 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 994 | && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 995 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 996 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 997 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 998 | { |
| 999 | /* NEXT-HOP Unchanged. */ |
| 1000 | } |
| 1001 | 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] | 1002 | || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1003 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1004 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1005 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1006 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 1007 | { |
| 1008 | /* Set IPv4 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1009 | if (NEXTHOP_IS_V4) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1010 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1011 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1012 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1013 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1014 | else |
| 1015 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1016 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1017 | /* Set IPv6 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1018 | if (NEXTHOP_IS_V6) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1019 | { |
| 1020 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1021 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1022 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1023 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1024 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1027 | if (p->family == AF_INET6 && safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1028 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1029 | /* Left nexthop_local unchanged if so configured. */ |
| 1030 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1031 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1032 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1033 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1034 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1035 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1036 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1040 | else |
| 1041 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1042 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1043 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1044 | |
| 1045 | /* Set link-local address for shared network peer. */ |
| 1046 | if (peer->shared_network |
| 1047 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1048 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1049 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1050 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1051 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1055 | address.*/ |
| 1056 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1057 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1058 | |
| 1059 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1060 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1061 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1062 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1063 | |
| 1064 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1065 | |
| 1066 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1067 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1068 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1069 | && aspath_private_as_check (attr->aspath)) |
| 1070 | attr->aspath = aspath_empty_get (); |
| 1071 | |
| 1072 | /* Route map & unsuppress-map apply. */ |
| 1073 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1074 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1075 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1076 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1077 | struct attr dummy_attr; |
| 1078 | struct attr_extra dummy_extra; |
| 1079 | |
| 1080 | dummy_attr.extra = &dummy_extra; |
| 1081 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1082 | info.peer = peer; |
| 1083 | info.attr = attr; |
| 1084 | |
| 1085 | /* The route reflector is not allowed to modify the attributes |
| 1086 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1087 | if (from->sort == BGP_PEER_IBGP |
| 1088 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1089 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1090 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1091 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1092 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1093 | |
| 1094 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1095 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1096 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1097 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1098 | else |
| 1099 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1100 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1101 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1102 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1103 | if (ret == RMAP_DENYMATCH) |
| 1104 | { |
| 1105 | bgp_attr_flush (attr); |
| 1106 | return 0; |
| 1107 | } |
| 1108 | } |
| 1109 | return 1; |
| 1110 | } |
| 1111 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1112 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1113 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1114 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1115 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1116 | int ret; |
| 1117 | char buf[SU_ADDRSTRLEN]; |
| 1118 | struct bgp_filter *filter; |
| 1119 | struct bgp_info info; |
| 1120 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1121 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1122 | |
| 1123 | from = ri->peer; |
| 1124 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1125 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1126 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1127 | if (DISABLE_BGP_ANNOUNCE) |
| 1128 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1129 | |
| 1130 | /* Do not send back route to sender. */ |
| 1131 | if (from == rsclient) |
| 1132 | return 0; |
| 1133 | |
| 1134 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1135 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1136 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1137 | return 0; |
| 1138 | |
| 1139 | /* Default route check. */ |
| 1140 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1141 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1142 | { |
| 1143 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1144 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1145 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1146 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | /* If the attribute has originator-id and it is same as remote |
| 1150 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1151 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1152 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1153 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1154 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1155 | { |
| 1156 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1157 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1158 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1159 | rsclient->host, |
| 1160 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1161 | p->prefixlen); |
| 1162 | return 0; |
| 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | /* ORF prefix-list filter check */ |
| 1167 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1168 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1169 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1170 | if (rsclient->orf_plist[afi][safi]) |
| 1171 | { |
| 1172 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1173 | return 0; |
| 1174 | } |
| 1175 | |
| 1176 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1177 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1178 | { |
| 1179 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1180 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1181 | "%s [Update:SEND] %s/%d is filtered", |
| 1182 | rsclient->host, |
| 1183 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1184 | p->prefixlen); |
| 1185 | return 0; |
| 1186 | } |
| 1187 | |
| 1188 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1189 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1190 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1191 | { |
| 1192 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1193 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1194 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1195 | rsclient->host, rsclient->as); |
| 1196 | return 0; |
| 1197 | } |
| 1198 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1199 | |
| 1200 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1201 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1202 | |
| 1203 | /* next-hop-set */ |
| 1204 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1205 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1206 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1207 | ) |
| 1208 | { |
| 1209 | /* Set IPv4 nexthop. */ |
| 1210 | if (p->family == AF_INET) |
| 1211 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1212 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1213 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1214 | IPV4_MAX_BYTELEN); |
| 1215 | else |
| 1216 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1217 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1218 | /* Set IPv6 nexthop. */ |
| 1219 | if (p->family == AF_INET6) |
| 1220 | { |
| 1221 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1222 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1224 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1225 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1226 | } |
| 1227 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1228 | if (p->family == AF_INET6) |
| 1229 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1230 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1231 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1232 | /* Left nexthop_local unchanged if so configured. */ |
| 1233 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1234 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1235 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1236 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1237 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1238 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1239 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1240 | } |
| 1241 | |
| 1242 | /* Default nexthop_local treatment for RS-Clients */ |
| 1243 | else |
| 1244 | { |
| 1245 | /* Announcer and RS-Client are both in the same network */ |
| 1246 | if (rsclient->shared_network && from->shared_network && |
| 1247 | (rsclient->ifindex == from->ifindex)) |
| 1248 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1249 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1250 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1251 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1252 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | /* Set link-local address for shared network peer. */ |
| 1256 | else if (rsclient->shared_network |
| 1257 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1258 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1259 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1260 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1261 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1262 | } |
| 1263 | |
| 1264 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1265 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1269 | |
| 1270 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1271 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1272 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1273 | && aspath_private_as_check (attr->aspath)) |
| 1274 | attr->aspath = aspath_empty_get (); |
| 1275 | |
| 1276 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1277 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1278 | { |
| 1279 | info.peer = rsclient; |
| 1280 | info.attr = attr; |
| 1281 | |
| 1282 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1283 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1284 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1285 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1286 | else |
| 1287 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1288 | |
| 1289 | rsclient->rmap_type = 0; |
| 1290 | |
| 1291 | if (ret == RMAP_DENYMATCH) |
| 1292 | { |
| 1293 | bgp_attr_flush (attr); |
| 1294 | return 0; |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | return 1; |
| 1299 | } |
| 1300 | |
| 1301 | struct bgp_info_pair |
| 1302 | { |
| 1303 | struct bgp_info *old; |
| 1304 | struct bgp_info *new; |
| 1305 | }; |
| 1306 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1307 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1308 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1309 | struct bgp_info_pair *result, |
| 1310 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1311 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1312 | struct bgp_info *new_select; |
| 1313 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1314 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1315 | struct bgp_info *ri1; |
| 1316 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1317 | struct bgp_info *nextri = NULL; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1318 | int cmpret, do_mpath; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1319 | struct list mp_list; |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1320 | |
| 1321 | result->old = result->new = NULL; |
| 1322 | |
| 1323 | if (rn->info == NULL) |
| 1324 | { |
| 1325 | char buf[PREFIX_STRLEN]; |
| 1326 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1327 | __func__, |
| 1328 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1329 | return; |
| 1330 | } |
| 1331 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1332 | bgp_mp_list_init (&mp_list); |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1333 | do_mpath = bgp_mpath_is_configured (bgp, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1334 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1335 | /* bgp deterministic-med */ |
| 1336 | new_select = NULL; |
| 1337 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1338 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1339 | { |
| 1340 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1341 | continue; |
| 1342 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1343 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1344 | if (ri1->peer && ri1->peer != bgp->peer_self) |
| 1345 | if (ri1->peer->status != Established) |
| 1346 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1347 | |
| 1348 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1349 | if (do_mpath) |
| 1350 | bgp_mp_list_add (&mp_list, ri1); |
| 1351 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1352 | if (ri1->next) |
| 1353 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1354 | { |
| 1355 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1356 | continue; |
| 1357 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1358 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1359 | if (ri2->peer && |
| 1360 | ri2->peer != bgp->peer_self && |
| 1361 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1362 | if (ri2->peer->status != Established) |
| 1363 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1364 | |
| 1365 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1366 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1367 | ri2->attr->aspath)) |
| 1368 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1369 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1370 | old_select = ri2; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1371 | if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi)) |
| 1372 | == -1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1373 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1374 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1375 | new_select = ri2; |
| 1376 | } |
| 1377 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1378 | if (do_mpath) |
| 1379 | { |
| 1380 | if (cmpret != 0) |
| 1381 | bgp_mp_list_clear (&mp_list); |
| 1382 | |
| 1383 | if (cmpret == 0 || cmpret == -1) |
| 1384 | bgp_mp_list_add (&mp_list, ri2); |
| 1385 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1386 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1387 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1388 | } |
| 1389 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1390 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1391 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1392 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1393 | 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] | 1394 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1395 | } |
| 1396 | |
| 1397 | /* Check old selected route and new selected route. */ |
| 1398 | old_select = NULL; |
| 1399 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1400 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1401 | { |
| 1402 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1403 | old_select = ri; |
| 1404 | |
| 1405 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1406 | { |
| 1407 | /* reap REMOVED routes, if needs be |
| 1408 | * selected route must stay for a while longer though |
| 1409 | */ |
| 1410 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1411 | && (ri != old_select)) |
| 1412 | bgp_info_reap (rn, ri); |
| 1413 | |
| 1414 | continue; |
| 1415 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1416 | |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1417 | if (ri->peer && |
| 1418 | ri->peer != bgp->peer_self && |
| 1419 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1420 | if (ri->peer->status != Established) |
| 1421 | continue; |
| 1422 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1423 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1424 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1425 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1426 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1427 | continue; |
| 1428 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1429 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1430 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1431 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1432 | if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1433 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1434 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1435 | bgp_mp_dmed_deselect (new_select); |
| 1436 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1437 | new_select = ri; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1438 | } |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1439 | else if (cmpret == 1 && do_mpath |
| 1440 | && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1441 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1442 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1443 | if (do_mpath) |
| 1444 | { |
| 1445 | if (cmpret != 0) |
| 1446 | bgp_mp_list_clear (&mp_list); |
| 1447 | |
| 1448 | if (cmpret == 0 || cmpret == -1) |
| 1449 | bgp_mp_list_add (&mp_list, ri); |
| 1450 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1451 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1452 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1453 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1454 | 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] | 1455 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1456 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1457 | bgp_mp_list_clear (&mp_list); |
| 1458 | |
| 1459 | result->old = old_select; |
| 1460 | result->new = new_select; |
| 1461 | |
| 1462 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1463 | } |
| 1464 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1465 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1466 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1467 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1468 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1469 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1470 | struct attr attr; |
| 1471 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1472 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1473 | memset (&attr, 0, sizeof(struct attr)); |
| 1474 | memset (&extra, 0, sizeof(struct attr_extra)); |
| 1475 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1476 | p = &rn->p; |
| 1477 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1478 | /* Announce route to Established peer. */ |
| 1479 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1480 | return 0; |
| 1481 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1482 | /* Address family configuration check. */ |
| 1483 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1484 | return 0; |
| 1485 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1486 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1487 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1488 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1489 | return 0; |
| 1490 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1491 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1492 | attr.extra = &extra; |
| 1493 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1494 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1495 | { |
| 1496 | case BGP_TABLE_MAIN: |
| 1497 | /* Announcement to peer->conf. If the route is filtered, |
| 1498 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1499 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1500 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1501 | else |
| 1502 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1503 | break; |
| 1504 | case BGP_TABLE_RSCLIENT: |
| 1505 | /* Announcement to peer->conf. If the route is filtered, |
| 1506 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1507 | if (selected && |
| 1508 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1509 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1510 | else |
| 1511 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1512 | break; |
| 1513 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1514 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1515 | bgp_attr_flush (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1516 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1517 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1518 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1519 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1520 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1521 | struct bgp *bgp; |
| 1522 | struct bgp_node *rn; |
| 1523 | afi_t afi; |
| 1524 | safi_t safi; |
| 1525 | }; |
| 1526 | |
| 1527 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1528 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1529 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1530 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1531 | struct bgp *bgp = pq->bgp; |
| 1532 | struct bgp_node *rn = pq->rn; |
| 1533 | afi_t afi = pq->afi; |
| 1534 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1535 | struct bgp_info *new_select; |
| 1536 | struct bgp_info *old_select; |
| 1537 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1538 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1539 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1540 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1541 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1542 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1543 | new_select = old_and_new.new; |
| 1544 | old_select = old_and_new.old; |
| 1545 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1546 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1547 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1548 | if (rsclient->group) |
| 1549 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1550 | { |
| 1551 | /* Nothing to do. */ |
| 1552 | if (old_select && old_select == new_select) |
| 1553 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1554 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1555 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1556 | if (old_select) |
| 1557 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1558 | if (new_select) |
| 1559 | { |
| 1560 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1561 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1562 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1563 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1564 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1565 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1566 | afi, safi); |
| 1567 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1568 | } |
| 1569 | else |
| 1570 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1571 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1572 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1573 | if (new_select) |
| 1574 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1575 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1576 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1577 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1578 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1579 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1580 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1581 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1582 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1583 | bgp_info_reap (rn, old_select); |
| 1584 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1585 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1586 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1587 | } |
| 1588 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1589 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1590 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1591 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1592 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1593 | struct bgp *bgp = pq->bgp; |
| 1594 | struct bgp_node *rn = pq->rn; |
| 1595 | afi_t afi = pq->afi; |
| 1596 | safi_t safi = pq->safi; |
| 1597 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1598 | struct bgp_info *new_select; |
| 1599 | struct bgp_info *old_select; |
| 1600 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1601 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1602 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1603 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1604 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1605 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1606 | old_select = old_and_new.old; |
| 1607 | new_select = old_and_new.new; |
| 1608 | |
| 1609 | /* Nothing to do. */ |
| 1610 | if (old_select && old_select == new_select) |
| 1611 | { |
| 1612 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1613 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1614 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1615 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1616 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1617 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1618 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1619 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1620 | return WQ_SUCCESS; |
| 1621 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1622 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1623 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1624 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1625 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1626 | if (new_select) |
| 1627 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1628 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1629 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1630 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1631 | } |
| 1632 | |
| 1633 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1634 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1635 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1636 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1637 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1638 | } |
| 1639 | |
| 1640 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1641 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1642 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1643 | { |
| 1644 | if (new_select |
| 1645 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1646 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1647 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1648 | else |
| 1649 | { |
| 1650 | /* Withdraw the route from the kernel. */ |
| 1651 | if (old_select |
| 1652 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1653 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1654 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1655 | } |
| 1656 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1657 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1658 | /* Reap old select bgp_info, if it has been removed */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1659 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1660 | bgp_info_reap (rn, old_select); |
| 1661 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1662 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1663 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1664 | } |
| 1665 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1666 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1667 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1668 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1669 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1670 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1671 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1672 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1673 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1674 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1675 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1676 | } |
| 1677 | |
| 1678 | static void |
| 1679 | bgp_process_queue_init (void) |
| 1680 | { |
| 1681 | bm->process_main_queue |
| 1682 | = work_queue_new (bm->master, "process_main_queue"); |
| 1683 | bm->process_rsclient_queue |
| 1684 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1685 | |
| 1686 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1687 | { |
| 1688 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1689 | exit (1); |
| 1690 | } |
| 1691 | |
| 1692 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1693 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1694 | bm->process_main_queue->spec.max_retries = 0; |
| 1695 | bm->process_main_queue->spec.hold = 50; |
| 1696 | |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1697 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
David Lamparter | d43f8b3 | 2015-03-03 08:54:54 +0100 | [diff] [blame] | 1698 | bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del; |
| 1699 | bm->process_rsclient_queue->spec.max_retries = 0; |
| 1700 | bm->process_rsclient_queue->spec.hold = 50; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1701 | } |
| 1702 | |
| 1703 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1704 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1705 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1706 | struct bgp_process_queue *pqnode; |
| 1707 | |
| 1708 | /* already scheduled for processing? */ |
| 1709 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1710 | return; |
| 1711 | |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1712 | if (rn->info == NULL) |
| 1713 | { |
| 1714 | /* XXX: Perhaps remove before next release, after we've flushed out |
| 1715 | * any obvious cases |
| 1716 | */ |
| 1717 | assert (rn->info != NULL); |
| 1718 | char buf[PREFIX_STRLEN]; |
| 1719 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1720 | __func__, |
| 1721 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1722 | return; |
| 1723 | } |
| 1724 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1725 | if ( (bm->process_main_queue == NULL) || |
| 1726 | (bm->process_rsclient_queue == NULL) ) |
| 1727 | bgp_process_queue_init (); |
| 1728 | |
| 1729 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1730 | sizeof (struct bgp_process_queue)); |
| 1731 | if (!pqnode) |
| 1732 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1733 | |
| 1734 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1735 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1736 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1737 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1738 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1739 | pqnode->afi = afi; |
| 1740 | pqnode->safi = safi; |
| 1741 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1742 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1743 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1744 | case BGP_TABLE_MAIN: |
| 1745 | work_queue_add (bm->process_main_queue, pqnode); |
| 1746 | break; |
| 1747 | case BGP_TABLE_RSCLIENT: |
| 1748 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1749 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1750 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1751 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1752 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1753 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1754 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1755 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1756 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1757 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1758 | { |
| 1759 | struct peer *peer; |
| 1760 | |
| 1761 | peer = THREAD_ARG (thread); |
| 1762 | peer->t_pmax_restart = NULL; |
| 1763 | |
| 1764 | if (BGP_DEBUG (events, EVENTS)) |
| 1765 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1766 | peer->host); |
| 1767 | |
| 1768 | peer_clear (peer); |
| 1769 | |
| 1770 | return 0; |
| 1771 | } |
| 1772 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1773 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1774 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1775 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1776 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1777 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1778 | return 0; |
| 1779 | |
| 1780 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1781 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1782 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1783 | && ! always) |
| 1784 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1785 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1786 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1787 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1788 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1789 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1790 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1791 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1792 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1793 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1794 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1795 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1796 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1797 | |
| 1798 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1799 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1800 | |
| 1801 | ndata[0] = (afi >> 8); |
| 1802 | ndata[1] = afi; |
| 1803 | ndata[2] = safi; |
| 1804 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1805 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1806 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1807 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1808 | |
| 1809 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1810 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1811 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1812 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1813 | |
| 1814 | /* restart timer start */ |
| 1815 | if (peer->pmax_restart[afi][safi]) |
| 1816 | { |
| 1817 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1818 | |
| 1819 | if (BGP_DEBUG (events, EVENTS)) |
| 1820 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1821 | peer->host, peer->v_pmax_restart); |
| 1822 | |
| 1823 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1824 | peer->v_pmax_restart); |
| 1825 | } |
| 1826 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1827 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1828 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1829 | else |
| 1830 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1831 | |
| 1832 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1833 | { |
| 1834 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1835 | && ! always) |
| 1836 | return 0; |
| 1837 | |
| 1838 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1839 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1840 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1841 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1842 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1843 | } |
| 1844 | else |
| 1845 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1846 | return 0; |
| 1847 | } |
| 1848 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1849 | /* Unconditionally remove the route from the RIB, without taking |
| 1850 | * damping into consideration (eg, because the session went down) |
| 1851 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1852 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1853 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1854 | afi_t afi, safi_t safi) |
| 1855 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1856 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1857 | |
| 1858 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1859 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1860 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1861 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1862 | } |
| 1863 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1864 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1865 | 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] | 1866 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1867 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1868 | int status = BGP_DAMP_NONE; |
| 1869 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1870 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1871 | * the bgp_info in the RIB for historical reference. |
| 1872 | */ |
| 1873 | 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] | 1874 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1875 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1876 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1877 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1878 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1879 | return; |
| 1880 | } |
| 1881 | |
| 1882 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1883 | } |
| 1884 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1885 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1886 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1887 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1888 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1889 | { |
| 1890 | struct bgp_node *rn; |
| 1891 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1892 | struct attr new_attr; |
| 1893 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1894 | struct attr *attr_new; |
| 1895 | struct attr *attr_new2; |
| 1896 | struct bgp_info *ri; |
| 1897 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1898 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1899 | char buf[SU_ADDRSTRLEN]; |
| 1900 | |
| 1901 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1902 | if (peer == rsclient) |
| 1903 | return; |
| 1904 | |
| 1905 | bgp = peer->bgp; |
| 1906 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1907 | |
| 1908 | /* Check previously received route. */ |
| 1909 | for (ri = rn->info; ri; ri = ri->next) |
| 1910 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1911 | break; |
| 1912 | |
| 1913 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1914 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1915 | { |
| 1916 | reason = "as-path contains our own AS;"; |
| 1917 | goto filtered; |
| 1918 | } |
| 1919 | |
| 1920 | /* Route reflector originator ID check. */ |
| 1921 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1922 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1923 | { |
| 1924 | reason = "originator is us;"; |
| 1925 | goto filtered; |
| 1926 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1927 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1928 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1929 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1930 | |
| 1931 | /* Apply export policy. */ |
| 1932 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1933 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1934 | { |
| 1935 | reason = "export-policy;"; |
| 1936 | goto filtered; |
| 1937 | } |
| 1938 | |
| 1939 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1940 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1941 | /* Apply import policy. */ |
| 1942 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1943 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1944 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1945 | |
| 1946 | reason = "import-policy;"; |
| 1947 | goto filtered; |
| 1948 | } |
| 1949 | |
| 1950 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1951 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1952 | |
| 1953 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1954 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1955 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1956 | /* 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] | 1957 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1958 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1959 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1960 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1961 | |
| 1962 | reason = "martian next-hop;"; |
| 1963 | goto filtered; |
| 1964 | } |
| 1965 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1966 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1967 | /* If the update is implicit withdraw. */ |
| 1968 | if (ri) |
| 1969 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1970 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1971 | |
| 1972 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1973 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1974 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1975 | { |
| 1976 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1977 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1978 | |
| 1979 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1980 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1981 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1982 | peer->host, |
| 1983 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1984 | p->prefixlen, rsclient->host); |
| 1985 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1986 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1987 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1988 | bgp_attr_flush(&new_attr); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1989 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1990 | } |
| 1991 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1992 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1993 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1994 | bgp_info_restore (rn, ri); |
| 1995 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1996 | /* Received Logging. */ |
| 1997 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1998 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1999 | peer->host, |
| 2000 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2001 | p->prefixlen, rsclient->host); |
| 2002 | |
| 2003 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2004 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2005 | |
| 2006 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2007 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2008 | ri->attr = attr_new; |
| 2009 | |
| 2010 | /* Update MPLS tag. */ |
| 2011 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2012 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2013 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2014 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2015 | |
| 2016 | /* Process change. */ |
| 2017 | bgp_process (bgp, rn, afi, safi); |
| 2018 | bgp_unlock_node (rn); |
| 2019 | |
| 2020 | return; |
| 2021 | } |
| 2022 | |
| 2023 | /* Received Logging. */ |
| 2024 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2025 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2026 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2027 | peer->host, |
| 2028 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2029 | p->prefixlen, rsclient->host); |
| 2030 | } |
| 2031 | |
| 2032 | /* Make new BGP info. */ |
| 2033 | new = bgp_info_new (); |
| 2034 | new->type = type; |
| 2035 | new->sub_type = sub_type; |
| 2036 | new->peer = peer; |
| 2037 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2038 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2039 | |
| 2040 | /* Update MPLS tag. */ |
| 2041 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2042 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2043 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2044 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2045 | |
| 2046 | /* Register new BGP information. */ |
| 2047 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2048 | |
| 2049 | /* route_node_get lock */ |
| 2050 | bgp_unlock_node (rn); |
| 2051 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2052 | /* Process change. */ |
| 2053 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2054 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2055 | return; |
| 2056 | |
| 2057 | filtered: |
| 2058 | |
| 2059 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2060 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2061 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2062 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2063 | peer->host, |
| 2064 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2065 | p->prefixlen, rsclient->host, reason); |
| 2066 | |
| 2067 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2068 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2069 | |
| 2070 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2071 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2072 | return; |
| 2073 | } |
| 2074 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2075 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2076 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2077 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2078 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2079 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2080 | struct bgp_node *rn; |
| 2081 | struct bgp_info *ri; |
| 2082 | char buf[SU_ADDRSTRLEN]; |
| 2083 | |
| 2084 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2085 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2086 | |
| 2087 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2088 | |
| 2089 | /* Lookup withdrawn route. */ |
| 2090 | for (ri = rn->info; ri; ri = ri->next) |
| 2091 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2092 | break; |
| 2093 | |
| 2094 | /* Withdraw specified route from routing table. */ |
| 2095 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2096 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2097 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2098 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2099 | "%s Can't find the route %s/%d", peer->host, |
| 2100 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2101 | p->prefixlen); |
| 2102 | |
| 2103 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2104 | bgp_unlock_node (rn); |
| 2105 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2106 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2107 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2108 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2109 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2110 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2111 | { |
| 2112 | int ret; |
| 2113 | int aspath_loop_count = 0; |
| 2114 | struct bgp_node *rn; |
| 2115 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2116 | struct attr new_attr; |
| 2117 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2118 | struct attr *attr_new; |
| 2119 | struct bgp_info *ri; |
| 2120 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2121 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2122 | char buf[SU_ADDRSTRLEN]; |
| 2123 | |
| 2124 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2125 | 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] | 2126 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2127 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2128 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2129 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2130 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2131 | bgp_adj_in_set (rn, peer, attr); |
| 2132 | |
| 2133 | /* Check previously received route. */ |
| 2134 | for (ri = rn->info; ri; ri = ri->next) |
| 2135 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2136 | break; |
| 2137 | |
| 2138 | /* AS path local-as loop check. */ |
| 2139 | if (peer->change_local_as) |
| 2140 | { |
| 2141 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2142 | aspath_loop_count = 1; |
| 2143 | |
| 2144 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2145 | { |
| 2146 | reason = "as-path contains our own AS;"; |
| 2147 | goto filtered; |
| 2148 | } |
| 2149 | } |
| 2150 | |
| 2151 | /* AS path loop check. */ |
| 2152 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2153 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2154 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2155 | > peer->allowas_in[afi][safi])) |
| 2156 | { |
| 2157 | reason = "as-path contains our own AS;"; |
| 2158 | goto filtered; |
| 2159 | } |
| 2160 | |
| 2161 | /* Route reflector originator ID check. */ |
| 2162 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2163 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2164 | { |
| 2165 | reason = "originator is us;"; |
| 2166 | goto filtered; |
| 2167 | } |
| 2168 | |
| 2169 | /* Route reflector cluster ID check. */ |
| 2170 | if (bgp_cluster_filter (peer, attr)) |
| 2171 | { |
| 2172 | reason = "reflected from the same cluster;"; |
| 2173 | goto filtered; |
| 2174 | } |
| 2175 | |
| 2176 | /* Apply incoming filter. */ |
| 2177 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2178 | { |
| 2179 | reason = "filter;"; |
| 2180 | goto filtered; |
| 2181 | } |
| 2182 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2183 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2184 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2185 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2186 | /* Apply incoming route-map. |
| 2187 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2188 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2189 | * the attr (which takes over the memory references) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2190 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2191 | { |
| 2192 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2193 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2194 | goto filtered; |
| 2195 | } |
| 2196 | |
| 2197 | /* IPv4 unicast next hop check. */ |
| 2198 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2199 | { |
| 2200 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2201 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2202 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2203 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2204 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2205 | { |
| 2206 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2207 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2208 | goto filtered; |
| 2209 | } |
| 2210 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2211 | /* 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] | 2212 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2213 | if (new_attr.nexthop.s_addr == 0 |
| 2214 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2215 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2216 | { |
| 2217 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2218 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2219 | goto filtered; |
| 2220 | } |
| 2221 | } |
| 2222 | |
| 2223 | attr_new = bgp_attr_intern (&new_attr); |
| 2224 | |
| 2225 | /* If the update is implicit withdraw. */ |
| 2226 | if (ri) |
| 2227 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2228 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2229 | |
| 2230 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2231 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2232 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2233 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2234 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2235 | |
| 2236 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2237 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2238 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2239 | { |
| 2240 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2241 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2242 | peer->host, |
| 2243 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2244 | p->prefixlen); |
| 2245 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2246 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2247 | { |
| 2248 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2249 | bgp_process (bgp, rn, afi, safi); |
| 2250 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2251 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2252 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2253 | { |
| 2254 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2255 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2256 | "%s rcvd %s/%d...duplicate ignored", |
| 2257 | peer->host, |
| 2258 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2259 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2260 | |
| 2261 | /* graceful restart STALE flag unset. */ |
| 2262 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2263 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2264 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2265 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2266 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2270 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2271 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2272 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2273 | return 0; |
| 2274 | } |
| 2275 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2276 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2277 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2278 | { |
| 2279 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2280 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2281 | peer->host, |
| 2282 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2283 | p->prefixlen); |
| 2284 | bgp_info_restore (rn, ri); |
| 2285 | } |
| 2286 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2287 | /* Received Logging. */ |
| 2288 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2289 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2290 | peer->host, |
| 2291 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2292 | p->prefixlen); |
| 2293 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2294 | /* graceful restart STALE flag unset. */ |
| 2295 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2296 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2297 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2298 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2299 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2300 | |
| 2301 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2302 | * only if update is accepted, they'll increment below. |
| 2303 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2304 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2305 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2306 | /* Update bgp route dampening information. */ |
| 2307 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2308 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2309 | { |
| 2310 | /* This is implicit withdraw so we should update dampening |
| 2311 | information. */ |
| 2312 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2313 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2314 | } |
| 2315 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2317 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2318 | ri->attr = attr_new; |
| 2319 | |
| 2320 | /* Update MPLS tag. */ |
| 2321 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2322 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2323 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2324 | bgp_attr_flush (&new_attr); |
| 2325 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2326 | /* Update bgp route dampening information. */ |
| 2327 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2328 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2329 | { |
| 2330 | /* Now we do normal update dampening. */ |
| 2331 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2332 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2333 | { |
| 2334 | bgp_unlock_node (rn); |
| 2335 | return 0; |
| 2336 | } |
| 2337 | } |
| 2338 | |
| 2339 | /* Nexthop reachability check. */ |
| 2340 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2341 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2342 | && (peer->sort == BGP_PEER_IBGP |
| 2343 | || peer->sort == BGP_PEER_CONFED |
| 2344 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2345 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2346 | { |
| 2347 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2348 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2349 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2350 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2351 | } |
| 2352 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2353 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2354 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2355 | bgp_attr_flush (&new_attr); |
| 2356 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2357 | /* Process change. */ |
| 2358 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2359 | |
| 2360 | bgp_process (bgp, rn, afi, safi); |
| 2361 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2362 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2363 | return 0; |
| 2364 | } |
| 2365 | |
| 2366 | /* Received Logging. */ |
| 2367 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2368 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2369 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2370 | peer->host, |
| 2371 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2372 | p->prefixlen); |
| 2373 | } |
| 2374 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2375 | /* Make new BGP info. */ |
| 2376 | new = bgp_info_new (); |
| 2377 | new->type = type; |
| 2378 | new->sub_type = sub_type; |
| 2379 | new->peer = peer; |
| 2380 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2381 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2382 | |
| 2383 | /* Update MPLS tag. */ |
| 2384 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2385 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2386 | |
| 2387 | /* Nexthop reachability check. */ |
| 2388 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2389 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2390 | && (peer->sort == BGP_PEER_IBGP |
| 2391 | || peer->sort == BGP_PEER_CONFED |
| 2392 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2393 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2394 | { |
| 2395 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2396 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2397 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2398 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2399 | } |
| 2400 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2401 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2402 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2403 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2404 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2405 | |
| 2406 | /* Register new BGP information. */ |
| 2407 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2408 | |
| 2409 | /* route_node_get lock */ |
| 2410 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2411 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2412 | bgp_attr_flush (&new_attr); |
| 2413 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2414 | /* If maximum prefix count is configured and current prefix |
| 2415 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2416 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2417 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2418 | |
| 2419 | /* Process change. */ |
| 2420 | bgp_process (bgp, rn, afi, safi); |
| 2421 | |
| 2422 | return 0; |
| 2423 | |
| 2424 | /* This BGP update is filtered. Log the reason then update BGP |
| 2425 | entry. */ |
| 2426 | filtered: |
| 2427 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2428 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2429 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2430 | peer->host, |
| 2431 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2432 | p->prefixlen, reason); |
| 2433 | |
| 2434 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2435 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2436 | |
| 2437 | bgp_unlock_node (rn); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2438 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2439 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2440 | return 0; |
| 2441 | } |
| 2442 | |
| 2443 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2444 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2445 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2446 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2447 | { |
| 2448 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2449 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2450 | struct bgp *bgp; |
| 2451 | int ret; |
| 2452 | |
| 2453 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2454 | soft_reconfig); |
| 2455 | |
| 2456 | bgp = peer->bgp; |
| 2457 | |
| 2458 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2459 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2460 | { |
| 2461 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2462 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2463 | sub_type, prd, tag); |
| 2464 | } |
| 2465 | |
| 2466 | return ret; |
| 2467 | } |
| 2468 | |
| 2469 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2470 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2471 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2472 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2473 | { |
| 2474 | struct bgp *bgp; |
| 2475 | char buf[SU_ADDRSTRLEN]; |
| 2476 | struct bgp_node *rn; |
| 2477 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2478 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2479 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2480 | |
| 2481 | bgp = peer->bgp; |
| 2482 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2483 | /* Lookup node. */ |
| 2484 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2485 | |
| 2486 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2487 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2488 | * the iteration over all RS clients. |
| 2489 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2490 | * if there was no entry, we don't need to do anything more. */ |
| 2491 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2492 | && peer != bgp->peer_self) |
| 2493 | if (!bgp_adj_in_unset (rn, peer)) |
| 2494 | { |
| 2495 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2496 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2497 | "not in adj-in", peer->host, |
| 2498 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2499 | p->prefixlen); |
| 2500 | bgp_unlock_node (rn); |
| 2501 | return 0; |
| 2502 | } |
| 2503 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2504 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2505 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2506 | { |
| 2507 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2508 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2509 | } |
| 2510 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2511 | /* Logging. */ |
| 2512 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2513 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2514 | peer->host, |
| 2515 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2516 | p->prefixlen); |
| 2517 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2518 | /* Lookup withdrawn route. */ |
| 2519 | for (ri = rn->info; ri; ri = ri->next) |
| 2520 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2521 | break; |
| 2522 | |
| 2523 | /* Withdraw specified route from routing table. */ |
| 2524 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2525 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2526 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2527 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2528 | "%s Can't find the route %s/%d", peer->host, |
| 2529 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2530 | p->prefixlen); |
| 2531 | |
| 2532 | /* Unlock bgp_node_get() lock. */ |
| 2533 | bgp_unlock_node (rn); |
| 2534 | |
| 2535 | return 0; |
| 2536 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2537 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2538 | void |
| 2539 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2540 | { |
| 2541 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2542 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2543 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2544 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2545 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2546 | struct bgp_node *rn; |
| 2547 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2548 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2549 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2550 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2551 | return; |
| 2552 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2553 | bgp = peer->bgp; |
| 2554 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2555 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2556 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2557 | aspath = attr.aspath; |
| 2558 | attr.local_pref = bgp->default_local_pref; |
| 2559 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2560 | |
| 2561 | if (afi == AFI_IP) |
| 2562 | str2prefix ("0.0.0.0/0", &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2563 | else if (afi == AFI_IP6) |
| 2564 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2565 | struct attr_extra *ae = attr.extra; |
| 2566 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2567 | str2prefix ("::/0", &p); |
| 2568 | |
| 2569 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2570 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2571 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2572 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2573 | |
| 2574 | /* If the peer is on shared nextwork and we have link-local |
| 2575 | nexthop set it. */ |
| 2576 | if (peer->shared_network |
| 2577 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2578 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2579 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2580 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2581 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2582 | } |
| 2583 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2584 | |
| 2585 | if (peer->default_rmap[afi][safi].name) |
| 2586 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2587 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2588 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2589 | { |
| 2590 | for (ri = rn->info; ri; ri = ri->next) |
| 2591 | { |
| 2592 | struct attr dummy_attr; |
| 2593 | struct attr_extra dummy_extra; |
| 2594 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2595 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2596 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2597 | dummy_attr.extra = &dummy_extra; |
| 2598 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2599 | info.peer = ri->peer; |
| 2600 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2601 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2602 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2603 | RMAP_BGP, &info); |
| 2604 | |
| 2605 | /* The route map might have set attributes. If we don't flush them |
| 2606 | * here, they will be leaked. */ |
| 2607 | bgp_attr_flush(&dummy_attr); |
| 2608 | if (ret != RMAP_DENYMATCH) |
| 2609 | break; |
| 2610 | } |
| 2611 | if (ret != RMAP_DENYMATCH) |
| 2612 | break; |
| 2613 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2614 | bgp->peer_self->rmap_type = 0; |
| 2615 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2616 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2617 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2618 | } |
| 2619 | |
| 2620 | if (withdraw) |
| 2621 | { |
| 2622 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2623 | bgp_default_withdraw_send (peer, afi, safi); |
| 2624 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2625 | } |
| 2626 | else |
| 2627 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2628 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2629 | { |
| 2630 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2631 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2632 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2633 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2634 | |
| 2635 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2636 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2637 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2639 | static void |
| 2640 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2641 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | { |
| 2643 | struct bgp_node *rn; |
| 2644 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2645 | struct attr attr; |
| 2646 | struct attr_extra extra; |
| 2647 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2648 | memset(&extra, 0, sizeof(extra)); |
| 2649 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2650 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2651 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2652 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2653 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2654 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2655 | bgp_default_originate (peer, afi, safi, 0); |
| 2656 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2657 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2658 | attr.extra = &extra; |
| 2659 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2660 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2661 | for (ri = rn->info; ri; ri = ri->next) |
| 2662 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2663 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2664 | if ( (rsclient) ? |
| 2665 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2666 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2667 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2668 | else |
| 2669 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2670 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2671 | |
| 2672 | bgp_attr_flush_encap(&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | } |
| 2674 | |
| 2675 | void |
| 2676 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2677 | { |
| 2678 | struct bgp_node *rn; |
| 2679 | struct bgp_table *table; |
| 2680 | |
| 2681 | if (peer->status != Established) |
| 2682 | return; |
| 2683 | |
| 2684 | if (! peer->afc_nego[afi][safi]) |
| 2685 | return; |
| 2686 | |
| 2687 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2688 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2689 | return; |
| 2690 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2691 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2692 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2693 | else |
| 2694 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2695 | rn = bgp_route_next(rn)) |
| 2696 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2697 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2698 | |
| 2699 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2700 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2701 | } |
| 2702 | |
| 2703 | void |
| 2704 | bgp_announce_route_all (struct peer *peer) |
| 2705 | { |
| 2706 | afi_t afi; |
| 2707 | safi_t safi; |
| 2708 | |
| 2709 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2710 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2711 | bgp_announce_route (peer, afi, safi); |
| 2712 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2713 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2714 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2715 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2716 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2717 | { |
| 2718 | struct bgp_node *rn; |
| 2719 | struct bgp_adj_in *ain; |
| 2720 | |
| 2721 | if (! table) |
| 2722 | table = rsclient->bgp->rib[afi][safi]; |
| 2723 | |
| 2724 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2725 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2726 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2727 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2728 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2729 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2730 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2731 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2732 | } |
| 2733 | } |
| 2734 | |
| 2735 | void |
| 2736 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2737 | { |
| 2738 | struct bgp_table *table; |
| 2739 | struct bgp_node *rn; |
| 2740 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2741 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2742 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2743 | |
| 2744 | else |
| 2745 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2746 | rn = bgp_route_next (rn)) |
| 2747 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2748 | { |
| 2749 | struct prefix_rd prd; |
| 2750 | prd.family = AF_UNSPEC; |
| 2751 | prd.prefixlen = 64; |
| 2752 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2753 | |
| 2754 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2755 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2756 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2757 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2758 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2759 | 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] | 2760 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2761 | { |
| 2762 | int ret; |
| 2763 | struct bgp_node *rn; |
| 2764 | struct bgp_adj_in *ain; |
| 2765 | |
| 2766 | if (! table) |
| 2767 | table = peer->bgp->rib[afi][safi]; |
| 2768 | |
| 2769 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2770 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2771 | { |
| 2772 | if (ain->peer == peer) |
| 2773 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2774 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2775 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2776 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2777 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2778 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2779 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2780 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2781 | if (ret < 0) |
| 2782 | { |
| 2783 | bgp_unlock_node (rn); |
| 2784 | return; |
| 2785 | } |
| 2786 | continue; |
| 2787 | } |
| 2788 | } |
| 2789 | } |
| 2790 | |
| 2791 | void |
| 2792 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2793 | { |
| 2794 | struct bgp_node *rn; |
| 2795 | struct bgp_table *table; |
| 2796 | |
| 2797 | if (peer->status != Established) |
| 2798 | return; |
| 2799 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2800 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2801 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2802 | else |
| 2803 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2804 | rn = bgp_route_next (rn)) |
| 2805 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2806 | { |
| 2807 | struct prefix_rd prd; |
| 2808 | prd.family = AF_UNSPEC; |
| 2809 | prd.prefixlen = 64; |
| 2810 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2811 | |
| 2812 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2813 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2814 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2815 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2816 | |
| 2817 | struct bgp_clear_node_queue |
| 2818 | { |
| 2819 | struct bgp_node *rn; |
| 2820 | enum bgp_clear_route_type purpose; |
| 2821 | }; |
| 2822 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2823 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2824 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2825 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2826 | struct bgp_clear_node_queue *cnq = data; |
| 2827 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2828 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2829 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2830 | afi_t afi = bgp_node_table (rn)->afi; |
| 2831 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2832 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2833 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2834 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2835 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2836 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2837 | { |
| 2838 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2839 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2840 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2841 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2842 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2843 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2844 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2845 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2846 | break; |
| 2847 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2848 | return WQ_SUCCESS; |
| 2849 | } |
| 2850 | |
| 2851 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2852 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2853 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2854 | struct bgp_clear_node_queue *cnq = data; |
| 2855 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2856 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2857 | |
| 2858 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2859 | bgp_table_unlock (table); |
| 2860 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2861 | } |
| 2862 | |
| 2863 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2864 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2865 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2866 | struct peer *peer = wq->spec.data; |
| 2867 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2868 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2869 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2870 | |
| 2871 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2872 | } |
| 2873 | |
| 2874 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2875 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2876 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2877 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2878 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2879 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2880 | #undef CLEAR_QUEUE_NAME_LEN |
| 2881 | |
| 2882 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2883 | { |
| 2884 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2885 | exit (1); |
| 2886 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2887 | peer->clear_node_queue->spec.hold = 10; |
| 2888 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2889 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2890 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2891 | peer->clear_node_queue->spec.max_retries = 0; |
| 2892 | |
| 2893 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2894 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2895 | } |
| 2896 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2897 | static void |
| 2898 | 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] | 2899 | struct bgp_table *table, struct peer *rsclient, |
| 2900 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2901 | { |
| 2902 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2903 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2904 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2905 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2906 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2907 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2908 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2909 | if (! table) |
| 2910 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2911 | |
| 2912 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2913 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2914 | struct bgp_info *ri; |
| 2915 | struct bgp_adj_in *ain; |
| 2916 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2917 | |
| 2918 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2919 | * queued for every clearing peer, regardless of whether it is |
| 2920 | * relevant to the peer at hand. |
| 2921 | * |
| 2922 | * Overview: There are 3 different indices which need to be |
| 2923 | * scrubbed, potentially, when a peer is removed: |
| 2924 | * |
| 2925 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2926 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2927 | * 3 other routes visible by the peer's adj-out index |
| 2928 | * |
| 2929 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2930 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2931 | * adj-outs at our leisure. |
| 2932 | * |
| 2933 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2934 | * invisible via RIB index before peer session is allowed to be |
| 2935 | * brought back up. So one needs to know when such a 'search' is |
| 2936 | * complete. |
| 2937 | * |
| 2938 | * Ideally: |
| 2939 | * |
| 2940 | * - there'd be a single global queue or a single RIB walker |
| 2941 | * - rather than tracking which route_nodes still need to be |
| 2942 | * examined on a peer basis, we'd track which peers still |
| 2943 | * aren't cleared |
| 2944 | * |
| 2945 | * Given that our per-peer prefix-counts now should be reliable, |
| 2946 | * this may actually be achievable. It doesn't seem to be a huge |
| 2947 | * problem at this time, |
| 2948 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2949 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2950 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2951 | { |
| 2952 | bgp_adj_in_remove (rn, ain); |
| 2953 | bgp_unlock_node (rn); |
| 2954 | break; |
| 2955 | } |
| 2956 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2957 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2958 | { |
| 2959 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2960 | bgp_unlock_node (rn); |
| 2961 | break; |
| 2962 | } |
| 2963 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2964 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2965 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2966 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2967 | struct bgp_clear_node_queue *cnq; |
| 2968 | |
| 2969 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2970 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2971 | bgp_lock_node (rn); |
| 2972 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2973 | sizeof (struct bgp_clear_node_queue)); |
| 2974 | cnq->rn = rn; |
| 2975 | cnq->purpose = purpose; |
| 2976 | work_queue_add (peer->clear_node_queue, cnq); |
| 2977 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2978 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2979 | } |
| 2980 | return; |
| 2981 | } |
| 2982 | |
| 2983 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2984 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2985 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2986 | { |
| 2987 | struct bgp_node *rn; |
| 2988 | struct bgp_table *table; |
| 2989 | struct peer *rsclient; |
| 2990 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2991 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2992 | if (peer->clear_node_queue == NULL) |
| 2993 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2994 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2995 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2996 | * Idle until it receives a Clearing_Completed event. This protects |
| 2997 | * against peers which flap faster than we can we clear, which could |
| 2998 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2999 | * |
| 3000 | * a) race with routes from the new session being installed before |
| 3001 | * clear_route_node visits the node (to delete the route of that |
| 3002 | * peer) |
| 3003 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 3004 | * on the process_main queue. Fast-flapping could cause that queue |
| 3005 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3006 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3007 | |
| 3008 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 3009 | * the unlock will happen upon work-queue completion; other wise, the |
| 3010 | * unlock happens at the end of this function. |
| 3011 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3012 | if (!peer->clear_node_queue->thread) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3013 | peer_lock (peer); /* bgp_clear_node_complete */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3014 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3015 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3016 | case BGP_CLEAR_ROUTE_NORMAL: |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3017 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3018 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3019 | else |
| 3020 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3021 | rn = bgp_route_next (rn)) |
| 3022 | if ((table = rn->info) != NULL) |
| 3023 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3024 | |
| 3025 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3026 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3027 | PEER_FLAG_RSERVER_CLIENT)) |
| 3028 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3029 | break; |
| 3030 | |
| 3031 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3032 | /* |
| 3033 | * gpz 091009: TBD why don't we have special handling for |
| 3034 | * SAFI_MPLS_VPN here in the original quagga code? |
| 3035 | * (and, by extension, for SAFI_ENCAP) |
| 3036 | */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3037 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3038 | break; |
| 3039 | |
| 3040 | default: |
| 3041 | assert (0); |
| 3042 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3043 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3044 | |
| 3045 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3046 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3047 | peer_unlock (peer); |
| 3048 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3049 | } |
| 3050 | |
| 3051 | void |
| 3052 | bgp_clear_route_all (struct peer *peer) |
| 3053 | { |
| 3054 | afi_t afi; |
| 3055 | safi_t safi; |
| 3056 | |
| 3057 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3058 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3059 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3060 | } |
| 3061 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3062 | /* |
| 3063 | * Finish freeing things when exiting |
| 3064 | */ |
| 3065 | static void |
| 3066 | bgp_drain_workqueue_immediate (struct work_queue *wq) |
| 3067 | { |
| 3068 | if (!wq) |
| 3069 | return; |
| 3070 | |
| 3071 | if (!wq->thread) |
| 3072 | { |
| 3073 | /* |
| 3074 | * no thread implies no queued items |
| 3075 | */ |
| 3076 | assert(!wq->items->count); |
| 3077 | return; |
| 3078 | } |
| 3079 | |
| 3080 | while (wq->items->count) |
| 3081 | { |
| 3082 | if (wq->thread) |
| 3083 | thread_cancel(wq->thread); |
| 3084 | work_queue_run(wq->thread); |
| 3085 | } |
| 3086 | } |
| 3087 | |
| 3088 | /* |
| 3089 | * Special function to process clear node queue when bgpd is exiting |
| 3090 | * and the thread scheduler is no longer running. |
| 3091 | */ |
| 3092 | void |
| 3093 | bgp_peer_clear_node_queue_drain_immediate(struct peer *peer) |
| 3094 | { |
| 3095 | if (!peer) |
| 3096 | return; |
| 3097 | |
| 3098 | bgp_drain_workqueue_immediate(peer->clear_node_queue); |
| 3099 | } |
| 3100 | |
| 3101 | /* |
| 3102 | * The work queues are not specific to a BGP instance, but the |
| 3103 | * items in them refer to BGP instances, so this should be called |
| 3104 | * before each BGP instance is deleted. |
| 3105 | */ |
| 3106 | void |
| 3107 | bgp_process_queues_drain_immediate(void) |
| 3108 | { |
| 3109 | bgp_drain_workqueue_immediate(bm->process_main_queue); |
| 3110 | bgp_drain_workqueue_immediate(bm->process_rsclient_queue); |
| 3111 | } |
| 3112 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3113 | void |
| 3114 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3115 | { |
| 3116 | struct bgp_table *table; |
| 3117 | struct bgp_node *rn; |
| 3118 | struct bgp_adj_in *ain; |
| 3119 | |
| 3120 | table = peer->bgp->rib[afi][safi]; |
| 3121 | |
| 3122 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3123 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3124 | if (ain->peer == peer) |
| 3125 | { |
| 3126 | bgp_adj_in_remove (rn, ain); |
| 3127 | bgp_unlock_node (rn); |
| 3128 | break; |
| 3129 | } |
| 3130 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3131 | |
| 3132 | void |
| 3133 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3134 | { |
| 3135 | struct bgp_node *rn; |
| 3136 | struct bgp_info *ri; |
| 3137 | struct bgp_table *table; |
| 3138 | |
| 3139 | table = peer->bgp->rib[afi][safi]; |
| 3140 | |
| 3141 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3142 | { |
| 3143 | for (ri = rn->info; ri; ri = ri->next) |
| 3144 | if (ri->peer == peer) |
| 3145 | { |
| 3146 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3147 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3148 | break; |
| 3149 | } |
| 3150 | } |
| 3151 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3152 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3153 | static void |
| 3154 | bgp_cleanup_table(struct bgp_table *table, safi_t safi) |
| 3155 | { |
| 3156 | struct bgp_node *rn; |
| 3157 | struct bgp_info *ri; |
| 3158 | struct bgp_info *next; |
| 3159 | |
| 3160 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3161 | for (ri = rn->info; ri; ri = next) |
| 3162 | { |
| 3163 | next = ri->next; |
| 3164 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3165 | && ri->type == ZEBRA_ROUTE_BGP |
| 3166 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 3167 | bgp_zebra_withdraw (&rn->p, ri, safi); |
| 3168 | } |
| 3169 | } |
| 3170 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3171 | /* Delete all kernel routes. */ |
| 3172 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3173 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3174 | { |
| 3175 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3176 | struct listnode *node, *nnode; |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3177 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3178 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3179 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3180 | { |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3181 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
| 3182 | { |
| 3183 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3184 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3185 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3186 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3187 | /* |
| 3188 | * VPN and ENCAP tables are two-level (RD is top level) |
| 3189 | */ |
| 3190 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn; |
| 3191 | rn = bgp_route_next (rn)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3192 | { |
| 3193 | if (rn->info) |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3194 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3195 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN); |
| 3196 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3197 | rn->info = NULL; |
| 3198 | bgp_unlock_node(rn); |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3199 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3200 | } |
| 3201 | |
| 3202 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn; |
| 3203 | rn = bgp_route_next (rn)) |
| 3204 | { |
| 3205 | if (rn->info) |
| 3206 | { |
| 3207 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP); |
| 3208 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3209 | rn->info = NULL; |
| 3210 | bgp_unlock_node(rn); |
| 3211 | } |
| 3212 | } |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3213 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3214 | } |
| 3215 | } |
| 3216 | |
| 3217 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3218 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3219 | { |
| 3220 | vty_reset (); |
| 3221 | bgp_zclient_reset (); |
| 3222 | access_list_reset (); |
| 3223 | prefix_list_reset (); |
| 3224 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3225 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3226 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3227 | value. */ |
| 3228 | int |
| 3229 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3230 | { |
| 3231 | u_char *pnt; |
| 3232 | u_char *lim; |
| 3233 | struct prefix p; |
| 3234 | int psize; |
| 3235 | int ret; |
| 3236 | |
| 3237 | /* Check peer status. */ |
| 3238 | if (peer->status != Established) |
| 3239 | return 0; |
| 3240 | |
| 3241 | pnt = packet->nlri; |
| 3242 | lim = pnt + packet->length; |
| 3243 | |
| 3244 | for (; pnt < lim; pnt += psize) |
| 3245 | { |
| 3246 | /* Clear prefix structure. */ |
| 3247 | memset (&p, 0, sizeof (struct prefix)); |
| 3248 | |
| 3249 | /* Fetch prefix length. */ |
| 3250 | p.prefixlen = *pnt++; |
| 3251 | p.family = afi2family (packet->afi); |
| 3252 | |
| 3253 | /* Already checked in nlri_sanity_check(). We do double check |
| 3254 | here. */ |
| 3255 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3256 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3257 | return -1; |
| 3258 | |
| 3259 | /* Packet size overflow check. */ |
| 3260 | psize = PSIZE (p.prefixlen); |
| 3261 | |
| 3262 | /* When packet overflow occur return immediately. */ |
| 3263 | if (pnt + psize > lim) |
| 3264 | return -1; |
| 3265 | |
| 3266 | /* Fetch prefix from NLRI packet. */ |
| 3267 | memcpy (&p.u.prefix, pnt, psize); |
| 3268 | |
| 3269 | /* Check address. */ |
| 3270 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3271 | { |
| 3272 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3273 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3274 | /* |
| 3275 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3276 | * If a BGP router receives an UPDATE message with a |
| 3277 | * semantically incorrect NLRI field, in which a prefix is |
| 3278 | * semantically incorrect (eg. an unexpected multicast IP |
| 3279 | * address), it should ignore the prefix. |
| 3280 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3281 | zlog (peer->log, LOG_ERR, |
| 3282 | "IPv4 unicast NLRI is multicast address %s", |
| 3283 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3284 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3285 | return -1; |
| 3286 | } |
| 3287 | } |
| 3288 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3289 | /* Check address. */ |
| 3290 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3291 | { |
| 3292 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3293 | { |
| 3294 | char buf[BUFSIZ]; |
| 3295 | |
| 3296 | zlog (peer->log, LOG_WARNING, |
| 3297 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3298 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3299 | |
| 3300 | continue; |
| 3301 | } |
| 3302 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3303 | |
| 3304 | /* Normal process. */ |
| 3305 | if (attr) |
| 3306 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3307 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3308 | else |
| 3309 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3310 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3311 | |
| 3312 | /* Address family configuration mismatch or maximum-prefix count |
| 3313 | overflow. */ |
| 3314 | if (ret < 0) |
| 3315 | return -1; |
| 3316 | } |
| 3317 | |
| 3318 | /* Packet length consistency check. */ |
| 3319 | if (pnt != lim) |
| 3320 | return -1; |
| 3321 | |
| 3322 | return 0; |
| 3323 | } |
| 3324 | |
| 3325 | /* NLRI encode syntax check routine. */ |
| 3326 | int |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3327 | bgp_nlri_sanity_check (struct peer *peer, int afi, safi_t safi, |
| 3328 | u_char *pnt, bgp_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3329 | { |
| 3330 | u_char *end; |
| 3331 | u_char prefixlen; |
| 3332 | int psize; |
| 3333 | |
| 3334 | end = pnt + length; |
| 3335 | |
| 3336 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3337 | syntactic validity. If the field is syntactically incorrect, |
| 3338 | then the Error Subcode is set to Invalid Network Field. */ |
| 3339 | |
| 3340 | while (pnt < end) |
| 3341 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3342 | int badlength; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3343 | prefixlen = *pnt++; |
| 3344 | |
| 3345 | /* Prefix length check. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3346 | badlength = 0; |
| 3347 | if (safi == SAFI_ENCAP) { |
| 3348 | if (prefixlen > 128) |
| 3349 | badlength = 1; |
| 3350 | } else { |
| 3351 | if ((afi == AFI_IP && prefixlen > 32) || |
| 3352 | (afi == AFI_IP6 && prefixlen > 128)) { |
| 3353 | |
| 3354 | badlength = 1; |
| 3355 | } |
| 3356 | } |
| 3357 | if (badlength) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3358 | { |
| 3359 | plog_err (peer->log, |
| 3360 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3361 | peer->host, prefixlen); |
| 3362 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3363 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3364 | return -1; |
| 3365 | } |
| 3366 | |
| 3367 | /* Packet size overflow check. */ |
| 3368 | psize = PSIZE (prefixlen); |
| 3369 | |
| 3370 | if (pnt + psize > end) |
| 3371 | { |
| 3372 | plog_err (peer->log, |
| 3373 | "%s [Error] Update packet error" |
| 3374 | " (prefix data overflow prefix size is %d)", |
| 3375 | peer->host, psize); |
| 3376 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3377 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3378 | return -1; |
| 3379 | } |
| 3380 | |
| 3381 | pnt += psize; |
| 3382 | } |
| 3383 | |
| 3384 | /* Packet length consistency check. */ |
| 3385 | if (pnt != end) |
| 3386 | { |
| 3387 | plog_err (peer->log, |
| 3388 | "%s [Error] Update packet error" |
| 3389 | " (prefix length mismatch with total length)", |
| 3390 | peer->host); |
| 3391 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3392 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3393 | return -1; |
| 3394 | } |
| 3395 | return 0; |
| 3396 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3397 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3398 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3399 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3400 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3401 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3402 | } |
| 3403 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3404 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3405 | bgp_static_free (struct bgp_static *bgp_static) |
| 3406 | { |
| 3407 | if (bgp_static->rmap.name) |
| 3408 | free (bgp_static->rmap.name); |
| 3409 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3410 | } |
| 3411 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3412 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3413 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3414 | struct prefix *p, afi_t afi, safi_t safi) |
| 3415 | { |
| 3416 | struct bgp_node *rn; |
| 3417 | struct bgp_info *ri; |
| 3418 | |
| 3419 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3420 | |
| 3421 | /* Check selected route and self inserted route. */ |
| 3422 | for (ri = rn->info; ri; ri = ri->next) |
| 3423 | if (ri->peer == bgp->peer_self |
| 3424 | && ri->type == ZEBRA_ROUTE_BGP |
| 3425 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3426 | break; |
| 3427 | |
| 3428 | /* Withdraw static BGP route from routing table. */ |
| 3429 | if (ri) |
| 3430 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3431 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3432 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3433 | } |
| 3434 | |
| 3435 | /* Unlock bgp_node_lookup. */ |
| 3436 | bgp_unlock_node (rn); |
| 3437 | } |
| 3438 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3439 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3440 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3441 | struct bgp_static *bgp_static, |
| 3442 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3443 | { |
| 3444 | struct bgp_node *rn; |
| 3445 | struct bgp_info *ri; |
| 3446 | struct bgp_info *new; |
| 3447 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3448 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3449 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3450 | struct attr new_attr; |
| 3451 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3452 | struct bgp *bgp; |
| 3453 | int ret; |
| 3454 | char buf[SU_ADDRSTRLEN]; |
| 3455 | |
| 3456 | bgp = rsclient->bgp; |
| 3457 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3458 | assert (bgp_static); |
| 3459 | if (!bgp_static) |
| 3460 | return; |
| 3461 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3462 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3463 | |
| 3464 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3465 | |
| 3466 | attr.nexthop = bgp_static->igpnexthop; |
| 3467 | attr.med = bgp_static->igpmetric; |
| 3468 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3469 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3470 | if (bgp_static->atomic) |
| 3471 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3472 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3473 | /* Apply network route-map for export to this rsclient. */ |
| 3474 | if (bgp_static->rmap.name) |
| 3475 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3476 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3477 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3478 | info.attr = &attr_tmp; |
| 3479 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3480 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3481 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3482 | |
| 3483 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3484 | |
| 3485 | rsclient->rmap_type = 0; |
| 3486 | |
| 3487 | if (ret == RMAP_DENYMATCH) |
| 3488 | { |
| 3489 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3490 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3491 | |
| 3492 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3493 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3494 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3495 | bgp_attr_extra_free (&attr); |
| 3496 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3497 | return; |
| 3498 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3499 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3500 | } |
| 3501 | else |
| 3502 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3503 | |
| 3504 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3505 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3506 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3507 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3508 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3509 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3510 | == RMAP_DENY) |
| 3511 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3512 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3513 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3514 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3515 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3516 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3517 | p->prefixlen, rsclient->host); |
| 3518 | |
| 3519 | bgp->peer_self->rmap_type = 0; |
| 3520 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3521 | bgp_attr_unintern (&attr_new); |
| 3522 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3523 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3524 | |
| 3525 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3526 | |
| 3527 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3528 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3529 | |
| 3530 | bgp->peer_self->rmap_type = 0; |
| 3531 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3532 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3533 | attr_new = bgp_attr_intern (&new_attr); |
| 3534 | |
| 3535 | for (ri = rn->info; ri; ri = ri->next) |
| 3536 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3537 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3538 | break; |
| 3539 | |
| 3540 | if (ri) |
| 3541 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3542 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3543 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3544 | { |
| 3545 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3546 | bgp_attr_unintern (&attr_new); |
| 3547 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3548 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3549 | return; |
| 3550 | } |
| 3551 | else |
| 3552 | { |
| 3553 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3554 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3555 | |
| 3556 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3557 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3558 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3559 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3560 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3561 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3562 | |
| 3563 | /* Process change. */ |
| 3564 | bgp_process (bgp, rn, afi, safi); |
| 3565 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3566 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3567 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3568 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3569 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3570 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3571 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3572 | /* Make new BGP info. */ |
| 3573 | new = bgp_info_new (); |
| 3574 | new->type = ZEBRA_ROUTE_BGP; |
| 3575 | new->sub_type = BGP_ROUTE_STATIC; |
| 3576 | new->peer = bgp->peer_self; |
| 3577 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3578 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3579 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3580 | |
| 3581 | /* Register new BGP information. */ |
| 3582 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3583 | |
| 3584 | /* route_node_get lock */ |
| 3585 | bgp_unlock_node (rn); |
| 3586 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3587 | /* Process change. */ |
| 3588 | bgp_process (bgp, rn, afi, safi); |
| 3589 | |
| 3590 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3591 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3592 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3593 | } |
| 3594 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3595 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3596 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3597 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3598 | { |
| 3599 | struct bgp_node *rn; |
| 3600 | struct bgp_info *ri; |
| 3601 | struct bgp_info *new; |
| 3602 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3603 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3604 | struct attr *attr_new; |
| 3605 | int ret; |
| 3606 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3607 | assert (bgp_static); |
| 3608 | if (!bgp_static) |
| 3609 | return; |
| 3610 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3611 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3612 | |
| 3613 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3614 | |
| 3615 | attr.nexthop = bgp_static->igpnexthop; |
| 3616 | attr.med = bgp_static->igpmetric; |
| 3617 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3618 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3619 | if (bgp_static->atomic) |
| 3620 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3621 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3622 | /* Apply route-map. */ |
| 3623 | if (bgp_static->rmap.name) |
| 3624 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3625 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3626 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3627 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3628 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3629 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3630 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3631 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3632 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3633 | bgp->peer_self->rmap_type = 0; |
| 3634 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3635 | if (ret == RMAP_DENYMATCH) |
| 3636 | { |
| 3637 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3638 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3639 | |
| 3640 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3641 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3642 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3643 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3644 | return; |
| 3645 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3646 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3647 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3648 | else |
| 3649 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3650 | |
| 3651 | for (ri = rn->info; ri; ri = ri->next) |
| 3652 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3653 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3654 | break; |
| 3655 | |
| 3656 | if (ri) |
| 3657 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3658 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3659 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3660 | { |
| 3661 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3662 | bgp_attr_unintern (&attr_new); |
| 3663 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3664 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3665 | return; |
| 3666 | } |
| 3667 | else |
| 3668 | { |
| 3669 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3670 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3671 | |
| 3672 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3673 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3674 | bgp_info_restore(rn, ri); |
| 3675 | else |
| 3676 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3677 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3678 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3679 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3680 | |
| 3681 | /* Process change. */ |
| 3682 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3683 | bgp_process (bgp, rn, afi, safi); |
| 3684 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3685 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3686 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3687 | return; |
| 3688 | } |
| 3689 | } |
| 3690 | |
| 3691 | /* Make new BGP info. */ |
| 3692 | new = bgp_info_new (); |
| 3693 | new->type = ZEBRA_ROUTE_BGP; |
| 3694 | new->sub_type = BGP_ROUTE_STATIC; |
| 3695 | new->peer = bgp->peer_self; |
| 3696 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3697 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3698 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3699 | |
| 3700 | /* Aggregate address increment. */ |
| 3701 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3702 | |
| 3703 | /* Register new BGP information. */ |
| 3704 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3705 | |
| 3706 | /* route_node_get lock */ |
| 3707 | bgp_unlock_node (rn); |
| 3708 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3709 | /* Process change. */ |
| 3710 | bgp_process (bgp, rn, afi, safi); |
| 3711 | |
| 3712 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3713 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3714 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3715 | } |
| 3716 | |
| 3717 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3718 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3719 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3720 | { |
| 3721 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3722 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3723 | |
| 3724 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3725 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3726 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3727 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3728 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3729 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3730 | } |
| 3731 | } |
| 3732 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3733 | void |
| 3734 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3735 | safi_t safi) |
| 3736 | { |
| 3737 | struct bgp_node *rn; |
| 3738 | struct bgp_info *ri; |
| 3739 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3740 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3741 | |
| 3742 | /* Check selected route and self inserted route. */ |
| 3743 | for (ri = rn->info; ri; ri = ri->next) |
| 3744 | if (ri->peer == bgp->peer_self |
| 3745 | && ri->type == ZEBRA_ROUTE_BGP |
| 3746 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3747 | break; |
| 3748 | |
| 3749 | /* Withdraw static BGP route from routing table. */ |
| 3750 | if (ri) |
| 3751 | { |
| 3752 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3753 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3754 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3755 | } |
| 3756 | |
| 3757 | /* Unlock bgp_node_lookup. */ |
| 3758 | bgp_unlock_node (rn); |
| 3759 | } |
| 3760 | |
| 3761 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3762 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3763 | { |
| 3764 | struct bgp_static *bgp_static; |
| 3765 | struct bgp *bgp; |
| 3766 | struct bgp_node *rn; |
| 3767 | struct prefix *p; |
| 3768 | |
| 3769 | bgp = rsclient->bgp; |
| 3770 | |
| 3771 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3772 | if ((bgp_static = rn->info) != NULL) |
| 3773 | { |
| 3774 | p = &rn->p; |
| 3775 | |
| 3776 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3777 | afi, safi); |
| 3778 | } |
| 3779 | } |
| 3780 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3781 | /* |
| 3782 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP |
| 3783 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3784 | static void |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3785 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3786 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3787 | { |
| 3788 | struct bgp_node *rn; |
| 3789 | struct bgp_info *ri; |
| 3790 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3791 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3792 | |
| 3793 | /* Check selected route and self inserted route. */ |
| 3794 | for (ri = rn->info; ri; ri = ri->next) |
| 3795 | if (ri->peer == bgp->peer_self |
| 3796 | && ri->type == ZEBRA_ROUTE_BGP |
| 3797 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3798 | break; |
| 3799 | |
| 3800 | /* Withdraw static BGP route from routing table. */ |
| 3801 | if (ri) |
| 3802 | { |
| 3803 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3804 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3805 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3806 | } |
| 3807 | |
| 3808 | /* Unlock bgp_node_lookup. */ |
| 3809 | bgp_unlock_node (rn); |
| 3810 | } |
| 3811 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3812 | static void |
| 3813 | bgp_static_update_safi (struct bgp *bgp, struct prefix *p, |
| 3814 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3815 | { |
| 3816 | struct bgp_node *rn; |
| 3817 | struct bgp_info *new; |
| 3818 | struct attr *attr_new; |
| 3819 | struct attr attr = { 0 }; |
| 3820 | struct bgp_info *ri; |
| 3821 | |
| 3822 | assert (bgp_static); |
| 3823 | |
| 3824 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd); |
| 3825 | |
| 3826 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 3827 | |
| 3828 | attr.nexthop = bgp_static->igpnexthop; |
| 3829 | attr.med = bgp_static->igpmetric; |
| 3830 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3831 | |
| 3832 | /* Apply route-map. */ |
| 3833 | if (bgp_static->rmap.name) |
| 3834 | { |
| 3835 | struct attr attr_tmp = attr; |
| 3836 | struct bgp_info info; |
| 3837 | int ret; |
| 3838 | |
| 3839 | info.peer = bgp->peer_self; |
| 3840 | info.attr = &attr_tmp; |
| 3841 | |
| 3842 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3843 | |
| 3844 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3845 | |
| 3846 | bgp->peer_self->rmap_type = 0; |
| 3847 | |
| 3848 | if (ret == RMAP_DENYMATCH) |
| 3849 | { |
| 3850 | /* Free uninterned attribute. */ |
| 3851 | bgp_attr_flush (&attr_tmp); |
| 3852 | |
| 3853 | /* Unintern original. */ |
| 3854 | aspath_unintern (&attr.aspath); |
| 3855 | bgp_attr_extra_free (&attr); |
| 3856 | bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd, |
| 3857 | bgp_static->tag); |
| 3858 | return; |
| 3859 | } |
| 3860 | |
| 3861 | attr_new = bgp_attr_intern (&attr_tmp); |
| 3862 | } |
| 3863 | else |
| 3864 | { |
| 3865 | attr_new = bgp_attr_intern (&attr); |
| 3866 | } |
| 3867 | |
| 3868 | for (ri = rn->info; ri; ri = ri->next) |
| 3869 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3870 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3871 | break; |
| 3872 | |
| 3873 | if (ri) |
| 3874 | { |
| 3875 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3876 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3877 | { |
| 3878 | bgp_unlock_node (rn); |
| 3879 | bgp_attr_unintern (&attr_new); |
| 3880 | aspath_unintern (&attr.aspath); |
| 3881 | bgp_attr_extra_free (&attr); |
| 3882 | return; |
| 3883 | } |
| 3884 | else |
| 3885 | { |
| 3886 | /* The attribute is changed. */ |
| 3887 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
| 3888 | |
| 3889 | /* Rewrite BGP route information. */ |
| 3890 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3891 | bgp_info_restore(rn, ri); |
| 3892 | else |
| 3893 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3894 | bgp_attr_unintern (&ri->attr); |
| 3895 | ri->attr = attr_new; |
| 3896 | ri->uptime = bgp_clock (); |
| 3897 | |
| 3898 | /* Process change. */ |
| 3899 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3900 | bgp_process (bgp, rn, afi, safi); |
| 3901 | bgp_unlock_node (rn); |
| 3902 | aspath_unintern (&attr.aspath); |
| 3903 | bgp_attr_extra_free (&attr); |
| 3904 | return; |
| 3905 | } |
| 3906 | } |
| 3907 | |
| 3908 | |
| 3909 | /* Make new BGP info. */ |
| 3910 | new = bgp_info_new (); |
| 3911 | new->type = ZEBRA_ROUTE_BGP; |
| 3912 | new->sub_type = BGP_ROUTE_STATIC; |
| 3913 | new->peer = bgp->peer_self; |
| 3914 | new->attr = attr_new; |
| 3915 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3916 | new->uptime = bgp_clock (); |
| 3917 | new->extra = bgp_info_extra_new(); |
| 3918 | memcpy (new->extra->tag, bgp_static->tag, 3); |
| 3919 | |
| 3920 | /* Aggregate address increment. */ |
| 3921 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3922 | |
| 3923 | /* Register new BGP information. */ |
| 3924 | bgp_info_add (rn, new); |
| 3925 | |
| 3926 | /* route_node_get lock */ |
| 3927 | bgp_unlock_node (rn); |
| 3928 | |
| 3929 | /* Process change. */ |
| 3930 | bgp_process (bgp, rn, afi, safi); |
| 3931 | |
| 3932 | /* Unintern original. */ |
| 3933 | aspath_unintern (&attr.aspath); |
| 3934 | bgp_attr_extra_free (&attr); |
| 3935 | } |
| 3936 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3937 | /* Configure static BGP network. When user don't run zebra, static |
| 3938 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3939 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3940 | 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] | 3941 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3942 | { |
| 3943 | int ret; |
| 3944 | struct prefix p; |
| 3945 | struct bgp_static *bgp_static; |
| 3946 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3947 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3948 | |
| 3949 | /* Convert IP prefix string to struct prefix. */ |
| 3950 | ret = str2prefix (ip_str, &p); |
| 3951 | if (! ret) |
| 3952 | { |
| 3953 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3954 | return CMD_WARNING; |
| 3955 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3956 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3957 | { |
| 3958 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3959 | VTY_NEWLINE); |
| 3960 | return CMD_WARNING; |
| 3961 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3962 | |
| 3963 | apply_mask (&p); |
| 3964 | |
| 3965 | /* Set BGP static route configuration. */ |
| 3966 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3967 | |
| 3968 | if (rn->info) |
| 3969 | { |
| 3970 | /* Configuration change. */ |
| 3971 | bgp_static = rn->info; |
| 3972 | |
| 3973 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3974 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3975 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3976 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3977 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3978 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3979 | if (rmap) |
| 3980 | { |
| 3981 | if (bgp_static->rmap.name) |
| 3982 | free (bgp_static->rmap.name); |
| 3983 | bgp_static->rmap.name = strdup (rmap); |
| 3984 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3985 | } |
| 3986 | else |
| 3987 | { |
| 3988 | if (bgp_static->rmap.name) |
| 3989 | free (bgp_static->rmap.name); |
| 3990 | bgp_static->rmap.name = NULL; |
| 3991 | bgp_static->rmap.map = NULL; |
| 3992 | bgp_static->valid = 0; |
| 3993 | } |
| 3994 | bgp_unlock_node (rn); |
| 3995 | } |
| 3996 | else |
| 3997 | { |
| 3998 | /* New configuration. */ |
| 3999 | bgp_static = bgp_static_new (); |
| 4000 | bgp_static->backdoor = backdoor; |
| 4001 | bgp_static->valid = 0; |
| 4002 | bgp_static->igpmetric = 0; |
| 4003 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4004 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4005 | if (rmap) |
| 4006 | { |
| 4007 | if (bgp_static->rmap.name) |
| 4008 | free (bgp_static->rmap.name); |
| 4009 | bgp_static->rmap.name = strdup (rmap); |
| 4010 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 4011 | } |
| 4012 | rn->info = bgp_static; |
| 4013 | } |
| 4014 | |
| 4015 | /* If BGP scan is not enabled, we should install this route here. */ |
| 4016 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 4017 | { |
| 4018 | bgp_static->valid = 1; |
| 4019 | |
| 4020 | if (need_update) |
| 4021 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 4022 | |
| 4023 | if (! bgp_static->backdoor) |
| 4024 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 4025 | } |
| 4026 | |
| 4027 | return CMD_SUCCESS; |
| 4028 | } |
| 4029 | |
| 4030 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4031 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4032 | 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] | 4033 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4034 | { |
| 4035 | int ret; |
| 4036 | struct prefix p; |
| 4037 | struct bgp_static *bgp_static; |
| 4038 | struct bgp_node *rn; |
| 4039 | |
| 4040 | /* Convert IP prefix string to struct prefix. */ |
| 4041 | ret = str2prefix (ip_str, &p); |
| 4042 | if (! ret) |
| 4043 | { |
| 4044 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4045 | return CMD_WARNING; |
| 4046 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4047 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 4048 | { |
| 4049 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 4050 | VTY_NEWLINE); |
| 4051 | return CMD_WARNING; |
| 4052 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4053 | |
| 4054 | apply_mask (&p); |
| 4055 | |
| 4056 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 4057 | if (! rn) |
| 4058 | { |
| 4059 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 4060 | VTY_NEWLINE); |
| 4061 | return CMD_WARNING; |
| 4062 | } |
| 4063 | |
| 4064 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4065 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4066 | /* Update BGP RIB. */ |
| 4067 | if (! bgp_static->backdoor) |
| 4068 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 4069 | |
| 4070 | /* Clear configuration. */ |
| 4071 | bgp_static_free (bgp_static); |
| 4072 | rn->info = NULL; |
| 4073 | bgp_unlock_node (rn); |
| 4074 | bgp_unlock_node (rn); |
| 4075 | |
| 4076 | return CMD_SUCCESS; |
| 4077 | } |
| 4078 | |
| 4079 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 4080 | instance. */ |
| 4081 | void |
| 4082 | bgp_static_delete (struct bgp *bgp) |
| 4083 | { |
| 4084 | afi_t afi; |
| 4085 | safi_t safi; |
| 4086 | struct bgp_node *rn; |
| 4087 | struct bgp_node *rm; |
| 4088 | struct bgp_table *table; |
| 4089 | struct bgp_static *bgp_static; |
| 4090 | |
| 4091 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 4092 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 4093 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 4094 | if (rn->info != NULL) |
| 4095 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4096 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4097 | { |
| 4098 | table = rn->info; |
| 4099 | |
| 4100 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 4101 | { |
| 4102 | bgp_static = rn->info; |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4103 | bgp_static_withdraw_safi (bgp, &rm->p, |
| 4104 | AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4105 | (struct prefix_rd *)&rn->p, |
| 4106 | bgp_static->tag); |
| 4107 | bgp_static_free (bgp_static); |
| 4108 | rn->info = NULL; |
| 4109 | bgp_unlock_node (rn); |
| 4110 | } |
| 4111 | } |
| 4112 | else |
| 4113 | { |
| 4114 | bgp_static = rn->info; |
| 4115 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 4116 | bgp_static_free (bgp_static); |
| 4117 | rn->info = NULL; |
| 4118 | bgp_unlock_node (rn); |
| 4119 | } |
| 4120 | } |
| 4121 | } |
| 4122 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4123 | /* |
| 4124 | * gpz 110624 |
| 4125 | * Currently this is used to set static routes for VPN and ENCAP. |
| 4126 | * I think it can probably be factored with bgp_static_set. |
| 4127 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4128 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4129 | bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, |
| 4130 | const char *rd_str, const char *tag_str, |
| 4131 | const char *rmap_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4132 | { |
| 4133 | int ret; |
| 4134 | struct prefix p; |
| 4135 | struct prefix_rd prd; |
| 4136 | struct bgp *bgp; |
| 4137 | struct bgp_node *prn; |
| 4138 | struct bgp_node *rn; |
| 4139 | struct bgp_table *table; |
| 4140 | struct bgp_static *bgp_static; |
| 4141 | u_char tag[3]; |
| 4142 | |
| 4143 | bgp = vty->index; |
| 4144 | |
| 4145 | ret = str2prefix (ip_str, &p); |
| 4146 | if (! ret) |
| 4147 | { |
| 4148 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4149 | return CMD_WARNING; |
| 4150 | } |
| 4151 | apply_mask (&p); |
| 4152 | |
| 4153 | ret = str2prefix_rd (rd_str, &prd); |
| 4154 | if (! ret) |
| 4155 | { |
| 4156 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4157 | return CMD_WARNING; |
| 4158 | } |
| 4159 | |
| 4160 | ret = str2tag (tag_str, tag); |
| 4161 | if (! ret) |
| 4162 | { |
| 4163 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4164 | return CMD_WARNING; |
| 4165 | } |
| 4166 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4167 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4168 | (struct prefix *)&prd); |
| 4169 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4170 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4171 | else |
| 4172 | bgp_unlock_node (prn); |
| 4173 | table = prn->info; |
| 4174 | |
| 4175 | rn = bgp_node_get (table, &p); |
| 4176 | |
| 4177 | if (rn->info) |
| 4178 | { |
| 4179 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 4180 | bgp_unlock_node (rn); |
| 4181 | } |
| 4182 | else |
| 4183 | { |
| 4184 | /* New configuration. */ |
| 4185 | bgp_static = bgp_static_new (); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4186 | bgp_static->backdoor = 0; |
| 4187 | bgp_static->valid = 0; |
| 4188 | bgp_static->igpmetric = 0; |
| 4189 | bgp_static->igpnexthop.s_addr = 0; |
| 4190 | memcpy(bgp_static->tag, tag, 3); |
| 4191 | bgp_static->prd = prd; |
| 4192 | |
| 4193 | if (rmap_str) |
| 4194 | { |
| 4195 | if (bgp_static->rmap.name) |
| 4196 | free (bgp_static->rmap.name); |
| 4197 | bgp_static->rmap.name = strdup (rmap_str); |
| 4198 | bgp_static->rmap.map = route_map_lookup_by_name (rmap_str); |
| 4199 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4200 | rn->info = bgp_static; |
| 4201 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4202 | bgp_static->valid = 1; |
| 4203 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4204 | } |
| 4205 | |
| 4206 | return CMD_SUCCESS; |
| 4207 | } |
| 4208 | |
| 4209 | /* Configure static BGP network. */ |
| 4210 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4211 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
| 4212 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4213 | { |
| 4214 | int ret; |
| 4215 | struct bgp *bgp; |
| 4216 | struct prefix p; |
| 4217 | struct prefix_rd prd; |
| 4218 | struct bgp_node *prn; |
| 4219 | struct bgp_node *rn; |
| 4220 | struct bgp_table *table; |
| 4221 | struct bgp_static *bgp_static; |
| 4222 | u_char tag[3]; |
| 4223 | |
| 4224 | bgp = vty->index; |
| 4225 | |
| 4226 | /* Convert IP prefix string to struct prefix. */ |
| 4227 | ret = str2prefix (ip_str, &p); |
| 4228 | if (! ret) |
| 4229 | { |
| 4230 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4231 | return CMD_WARNING; |
| 4232 | } |
| 4233 | apply_mask (&p); |
| 4234 | |
| 4235 | ret = str2prefix_rd (rd_str, &prd); |
| 4236 | if (! ret) |
| 4237 | { |
| 4238 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4239 | return CMD_WARNING; |
| 4240 | } |
| 4241 | |
| 4242 | ret = str2tag (tag_str, tag); |
| 4243 | if (! ret) |
| 4244 | { |
| 4245 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4246 | return CMD_WARNING; |
| 4247 | } |
| 4248 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4249 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4250 | (struct prefix *)&prd); |
| 4251 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4252 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4253 | else |
| 4254 | bgp_unlock_node (prn); |
| 4255 | table = prn->info; |
| 4256 | |
| 4257 | rn = bgp_node_lookup (table, &p); |
| 4258 | |
| 4259 | if (rn) |
| 4260 | { |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4261 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4262 | |
| 4263 | bgp_static = rn->info; |
| 4264 | bgp_static_free (bgp_static); |
| 4265 | rn->info = NULL; |
| 4266 | bgp_unlock_node (rn); |
| 4267 | bgp_unlock_node (rn); |
| 4268 | } |
| 4269 | else |
| 4270 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4271 | |
| 4272 | return CMD_SUCCESS; |
| 4273 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4274 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4275 | DEFUN (bgp_network, |
| 4276 | bgp_network_cmd, |
| 4277 | "network A.B.C.D/M", |
| 4278 | "Specify a network to announce via BGP\n" |
| 4279 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4280 | { |
| 4281 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4282 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4283 | } |
| 4284 | |
| 4285 | DEFUN (bgp_network_route_map, |
| 4286 | bgp_network_route_map_cmd, |
| 4287 | "network A.B.C.D/M route-map WORD", |
| 4288 | "Specify a network to announce via BGP\n" |
| 4289 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4290 | "Route-map to modify the attributes\n" |
| 4291 | "Name of the route map\n") |
| 4292 | { |
| 4293 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4294 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4295 | } |
| 4296 | |
| 4297 | DEFUN (bgp_network_backdoor, |
| 4298 | bgp_network_backdoor_cmd, |
| 4299 | "network A.B.C.D/M backdoor", |
| 4300 | "Specify a network to announce via BGP\n" |
| 4301 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4302 | "Specify a BGP backdoor route\n") |
| 4303 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4304 | 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] | 4305 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4306 | } |
| 4307 | |
| 4308 | DEFUN (bgp_network_mask, |
| 4309 | bgp_network_mask_cmd, |
| 4310 | "network A.B.C.D mask A.B.C.D", |
| 4311 | "Specify a network to announce via BGP\n" |
| 4312 | "Network number\n" |
| 4313 | "Network mask\n" |
| 4314 | "Network mask\n") |
| 4315 | { |
| 4316 | int ret; |
| 4317 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4318 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4319 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4320 | if (! ret) |
| 4321 | { |
| 4322 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4323 | return CMD_WARNING; |
| 4324 | } |
| 4325 | |
| 4326 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4327 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4328 | } |
| 4329 | |
| 4330 | DEFUN (bgp_network_mask_route_map, |
| 4331 | bgp_network_mask_route_map_cmd, |
| 4332 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4333 | "Specify a network to announce via BGP\n" |
| 4334 | "Network number\n" |
| 4335 | "Network mask\n" |
| 4336 | "Network mask\n" |
| 4337 | "Route-map to modify the attributes\n" |
| 4338 | "Name of the route map\n") |
| 4339 | { |
| 4340 | int ret; |
| 4341 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4342 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4343 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4344 | if (! ret) |
| 4345 | { |
| 4346 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4347 | return CMD_WARNING; |
| 4348 | } |
| 4349 | |
| 4350 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4351 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4352 | } |
| 4353 | |
| 4354 | DEFUN (bgp_network_mask_backdoor, |
| 4355 | bgp_network_mask_backdoor_cmd, |
| 4356 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4357 | "Specify a network to announce via BGP\n" |
| 4358 | "Network number\n" |
| 4359 | "Network mask\n" |
| 4360 | "Network mask\n" |
| 4361 | "Specify a BGP backdoor route\n") |
| 4362 | { |
| 4363 | int ret; |
| 4364 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4365 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4366 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4367 | if (! ret) |
| 4368 | { |
| 4369 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4370 | return CMD_WARNING; |
| 4371 | } |
| 4372 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4373 | 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] | 4374 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4375 | } |
| 4376 | |
| 4377 | DEFUN (bgp_network_mask_natural, |
| 4378 | bgp_network_mask_natural_cmd, |
| 4379 | "network A.B.C.D", |
| 4380 | "Specify a network to announce via BGP\n" |
| 4381 | "Network number\n") |
| 4382 | { |
| 4383 | int ret; |
| 4384 | char prefix_str[BUFSIZ]; |
| 4385 | |
| 4386 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4387 | if (! ret) |
| 4388 | { |
| 4389 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4390 | return CMD_WARNING; |
| 4391 | } |
| 4392 | |
| 4393 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4394 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4395 | } |
| 4396 | |
| 4397 | DEFUN (bgp_network_mask_natural_route_map, |
| 4398 | bgp_network_mask_natural_route_map_cmd, |
| 4399 | "network A.B.C.D route-map WORD", |
| 4400 | "Specify a network to announce via BGP\n" |
| 4401 | "Network number\n" |
| 4402 | "Route-map to modify the attributes\n" |
| 4403 | "Name of the route map\n") |
| 4404 | { |
| 4405 | int ret; |
| 4406 | char prefix_str[BUFSIZ]; |
| 4407 | |
| 4408 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4409 | if (! ret) |
| 4410 | { |
| 4411 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4412 | return CMD_WARNING; |
| 4413 | } |
| 4414 | |
| 4415 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4416 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4417 | } |
| 4418 | |
| 4419 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4420 | bgp_network_mask_natural_backdoor_cmd, |
| 4421 | "network A.B.C.D backdoor", |
| 4422 | "Specify a network to announce via BGP\n" |
| 4423 | "Network number\n" |
| 4424 | "Specify a BGP backdoor route\n") |
| 4425 | { |
| 4426 | int ret; |
| 4427 | char prefix_str[BUFSIZ]; |
| 4428 | |
| 4429 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4430 | if (! ret) |
| 4431 | { |
| 4432 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4433 | return CMD_WARNING; |
| 4434 | } |
| 4435 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4436 | 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] | 4437 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4438 | } |
| 4439 | |
| 4440 | DEFUN (no_bgp_network, |
| 4441 | no_bgp_network_cmd, |
| 4442 | "no network A.B.C.D/M", |
| 4443 | NO_STR |
| 4444 | "Specify a network to announce via BGP\n" |
| 4445 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4446 | { |
| 4447 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4448 | bgp_node_safi (vty)); |
| 4449 | } |
| 4450 | |
| 4451 | ALIAS (no_bgp_network, |
| 4452 | no_bgp_network_route_map_cmd, |
| 4453 | "no network A.B.C.D/M route-map WORD", |
| 4454 | NO_STR |
| 4455 | "Specify a network to announce via BGP\n" |
| 4456 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4457 | "Route-map to modify the attributes\n" |
| 4458 | "Name of the route map\n") |
| 4459 | |
| 4460 | ALIAS (no_bgp_network, |
| 4461 | no_bgp_network_backdoor_cmd, |
| 4462 | "no network A.B.C.D/M backdoor", |
| 4463 | NO_STR |
| 4464 | "Specify a network to announce via BGP\n" |
| 4465 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4466 | "Specify a BGP backdoor route\n") |
| 4467 | |
| 4468 | DEFUN (no_bgp_network_mask, |
| 4469 | no_bgp_network_mask_cmd, |
| 4470 | "no network A.B.C.D mask A.B.C.D", |
| 4471 | NO_STR |
| 4472 | "Specify a network to announce via BGP\n" |
| 4473 | "Network number\n" |
| 4474 | "Network mask\n" |
| 4475 | "Network mask\n") |
| 4476 | { |
| 4477 | int ret; |
| 4478 | char prefix_str[BUFSIZ]; |
| 4479 | |
| 4480 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4481 | if (! ret) |
| 4482 | { |
| 4483 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4484 | return CMD_WARNING; |
| 4485 | } |
| 4486 | |
| 4487 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4488 | bgp_node_safi (vty)); |
| 4489 | } |
| 4490 | |
| 4491 | ALIAS (no_bgp_network_mask, |
| 4492 | no_bgp_network_mask_route_map_cmd, |
| 4493 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4494 | NO_STR |
| 4495 | "Specify a network to announce via BGP\n" |
| 4496 | "Network number\n" |
| 4497 | "Network mask\n" |
| 4498 | "Network mask\n" |
| 4499 | "Route-map to modify the attributes\n" |
| 4500 | "Name of the route map\n") |
| 4501 | |
| 4502 | ALIAS (no_bgp_network_mask, |
| 4503 | no_bgp_network_mask_backdoor_cmd, |
| 4504 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4505 | NO_STR |
| 4506 | "Specify a network to announce via BGP\n" |
| 4507 | "Network number\n" |
| 4508 | "Network mask\n" |
| 4509 | "Network mask\n" |
| 4510 | "Specify a BGP backdoor route\n") |
| 4511 | |
| 4512 | DEFUN (no_bgp_network_mask_natural, |
| 4513 | no_bgp_network_mask_natural_cmd, |
| 4514 | "no network A.B.C.D", |
| 4515 | NO_STR |
| 4516 | "Specify a network to announce via BGP\n" |
| 4517 | "Network number\n") |
| 4518 | { |
| 4519 | int ret; |
| 4520 | char prefix_str[BUFSIZ]; |
| 4521 | |
| 4522 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4523 | if (! ret) |
| 4524 | { |
| 4525 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4526 | return CMD_WARNING; |
| 4527 | } |
| 4528 | |
| 4529 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4530 | bgp_node_safi (vty)); |
| 4531 | } |
| 4532 | |
| 4533 | ALIAS (no_bgp_network_mask_natural, |
| 4534 | no_bgp_network_mask_natural_route_map_cmd, |
| 4535 | "no network A.B.C.D route-map WORD", |
| 4536 | NO_STR |
| 4537 | "Specify a network to announce via BGP\n" |
| 4538 | "Network number\n" |
| 4539 | "Route-map to modify the attributes\n" |
| 4540 | "Name of the route map\n") |
| 4541 | |
| 4542 | ALIAS (no_bgp_network_mask_natural, |
| 4543 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4544 | "no network A.B.C.D backdoor", |
| 4545 | NO_STR |
| 4546 | "Specify a network to announce via BGP\n" |
| 4547 | "Network number\n" |
| 4548 | "Specify a BGP backdoor route\n") |
| 4549 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4550 | DEFUN (ipv6_bgp_network, |
| 4551 | ipv6_bgp_network_cmd, |
| 4552 | "network X:X::X:X/M", |
| 4553 | "Specify a network to announce via BGP\n" |
| 4554 | "IPv6 prefix <network>/<length>\n") |
| 4555 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4556 | 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] | 4557 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4558 | } |
| 4559 | |
| 4560 | DEFUN (ipv6_bgp_network_route_map, |
| 4561 | ipv6_bgp_network_route_map_cmd, |
| 4562 | "network X:X::X:X/M route-map WORD", |
| 4563 | "Specify a network to announce via BGP\n" |
| 4564 | "IPv6 prefix <network>/<length>\n" |
| 4565 | "Route-map to modify the attributes\n" |
| 4566 | "Name of the route map\n") |
| 4567 | { |
| 4568 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4569 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4570 | } |
| 4571 | |
| 4572 | DEFUN (no_ipv6_bgp_network, |
| 4573 | no_ipv6_bgp_network_cmd, |
| 4574 | "no network X:X::X:X/M", |
| 4575 | NO_STR |
| 4576 | "Specify a network to announce via BGP\n" |
| 4577 | "IPv6 prefix <network>/<length>\n") |
| 4578 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4579 | 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] | 4580 | } |
| 4581 | |
| 4582 | ALIAS (no_ipv6_bgp_network, |
| 4583 | no_ipv6_bgp_network_route_map_cmd, |
| 4584 | "no network X:X::X:X/M route-map WORD", |
| 4585 | NO_STR |
| 4586 | "Specify a network to announce via BGP\n" |
| 4587 | "IPv6 prefix <network>/<length>\n" |
| 4588 | "Route-map to modify the attributes\n" |
| 4589 | "Name of the route map\n") |
| 4590 | |
| 4591 | ALIAS (ipv6_bgp_network, |
| 4592 | old_ipv6_bgp_network_cmd, |
| 4593 | "ipv6 bgp network X:X::X:X/M", |
| 4594 | IPV6_STR |
| 4595 | BGP_STR |
| 4596 | "Specify a network to announce via BGP\n" |
| 4597 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4598 | |
| 4599 | ALIAS (no_ipv6_bgp_network, |
| 4600 | old_no_ipv6_bgp_network_cmd, |
| 4601 | "no ipv6 bgp network X:X::X:X/M", |
| 4602 | NO_STR |
| 4603 | IPV6_STR |
| 4604 | BGP_STR |
| 4605 | "Specify a network to announce via BGP\n" |
| 4606 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4607 | |
| 4608 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4609 | ALIAS_DEPRECATED (bgp_network, |
| 4610 | bgp_network_ttl_cmd, |
| 4611 | "network A.B.C.D/M pathlimit <0-255>", |
| 4612 | "Specify a network to announce via BGP\n" |
| 4613 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4614 | "AS-Path hopcount limit attribute\n" |
| 4615 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4616 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4617 | bgp_network_backdoor_ttl_cmd, |
| 4618 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4619 | "Specify a network to announce via BGP\n" |
| 4620 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4621 | "Specify a BGP backdoor route\n" |
| 4622 | "AS-Path hopcount limit attribute\n" |
| 4623 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4624 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4625 | bgp_network_mask_ttl_cmd, |
| 4626 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4627 | "Specify a network to announce via BGP\n" |
| 4628 | "Network number\n" |
| 4629 | "Network mask\n" |
| 4630 | "Network mask\n" |
| 4631 | "AS-Path hopcount limit attribute\n" |
| 4632 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4633 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4634 | bgp_network_mask_backdoor_ttl_cmd, |
| 4635 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4636 | "Specify a network to announce via BGP\n" |
| 4637 | "Network number\n" |
| 4638 | "Network mask\n" |
| 4639 | "Network mask\n" |
| 4640 | "Specify a BGP backdoor route\n" |
| 4641 | "AS-Path hopcount limit attribute\n" |
| 4642 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4643 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4644 | bgp_network_mask_natural_ttl_cmd, |
| 4645 | "network A.B.C.D pathlimit <0-255>", |
| 4646 | "Specify a network to announce via BGP\n" |
| 4647 | "Network number\n" |
| 4648 | "AS-Path hopcount limit attribute\n" |
| 4649 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4650 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4651 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4652 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4653 | "Specify a network to announce via BGP\n" |
| 4654 | "Network number\n" |
| 4655 | "Specify a BGP backdoor route\n" |
| 4656 | "AS-Path hopcount limit attribute\n" |
| 4657 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4658 | ALIAS_DEPRECATED (no_bgp_network, |
| 4659 | no_bgp_network_ttl_cmd, |
| 4660 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4661 | NO_STR |
| 4662 | "Specify a network to announce via BGP\n" |
| 4663 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4664 | "AS-Path hopcount limit attribute\n" |
| 4665 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4666 | ALIAS_DEPRECATED (no_bgp_network, |
| 4667 | no_bgp_network_backdoor_ttl_cmd, |
| 4668 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4669 | NO_STR |
| 4670 | "Specify a network to announce via BGP\n" |
| 4671 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4672 | "Specify a BGP backdoor route\n" |
| 4673 | "AS-Path hopcount limit attribute\n" |
| 4674 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4675 | ALIAS_DEPRECATED (no_bgp_network, |
| 4676 | no_bgp_network_mask_ttl_cmd, |
| 4677 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4678 | NO_STR |
| 4679 | "Specify a network to announce via BGP\n" |
| 4680 | "Network number\n" |
| 4681 | "Network mask\n" |
| 4682 | "Network mask\n" |
| 4683 | "AS-Path hopcount limit attribute\n" |
| 4684 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4685 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4686 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4687 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4688 | NO_STR |
| 4689 | "Specify a network to announce via BGP\n" |
| 4690 | "Network number\n" |
| 4691 | "Network mask\n" |
| 4692 | "Network mask\n" |
| 4693 | "Specify a BGP backdoor route\n" |
| 4694 | "AS-Path hopcount limit attribute\n" |
| 4695 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4696 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4697 | no_bgp_network_mask_natural_ttl_cmd, |
| 4698 | "no network A.B.C.D pathlimit <0-255>", |
| 4699 | NO_STR |
| 4700 | "Specify a network to announce via BGP\n" |
| 4701 | "Network number\n" |
| 4702 | "AS-Path hopcount limit attribute\n" |
| 4703 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4704 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4705 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4706 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4707 | NO_STR |
| 4708 | "Specify a network to announce via BGP\n" |
| 4709 | "Network number\n" |
| 4710 | "Specify a BGP backdoor route\n" |
| 4711 | "AS-Path hopcount limit attribute\n" |
| 4712 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4713 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4714 | ipv6_bgp_network_ttl_cmd, |
| 4715 | "network X:X::X:X/M pathlimit <0-255>", |
| 4716 | "Specify a network to announce via BGP\n" |
| 4717 | "IPv6 prefix <network>/<length>\n" |
| 4718 | "AS-Path hopcount limit attribute\n" |
| 4719 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4720 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4721 | no_ipv6_bgp_network_ttl_cmd, |
| 4722 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4723 | NO_STR |
| 4724 | "Specify a network to announce via BGP\n" |
| 4725 | "IPv6 prefix <network>/<length>\n" |
| 4726 | "AS-Path hopcount limit attribute\n" |
| 4727 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4728 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4729 | /* Aggreagete address: |
| 4730 | |
| 4731 | advertise-map Set condition to advertise attribute |
| 4732 | as-set Generate AS set path information |
| 4733 | attribute-map Set attributes of aggregate |
| 4734 | route-map Set parameters of aggregate |
| 4735 | summary-only Filter more specific routes from updates |
| 4736 | suppress-map Conditionally filter more specific routes from updates |
| 4737 | <cr> |
| 4738 | */ |
| 4739 | struct bgp_aggregate |
| 4740 | { |
| 4741 | /* Summary-only flag. */ |
| 4742 | u_char summary_only; |
| 4743 | |
| 4744 | /* AS set generation. */ |
| 4745 | u_char as_set; |
| 4746 | |
| 4747 | /* Route-map for aggregated route. */ |
| 4748 | struct route_map *map; |
| 4749 | |
| 4750 | /* Suppress-count. */ |
| 4751 | unsigned long count; |
| 4752 | |
| 4753 | /* SAFI configuration. */ |
| 4754 | safi_t safi; |
| 4755 | }; |
| 4756 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4757 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4758 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4759 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4760 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4761 | } |
| 4762 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4763 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4764 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4765 | { |
| 4766 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4767 | } |
| 4768 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4769 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4770 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4771 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4772 | struct bgp_aggregate *aggregate) |
| 4773 | { |
| 4774 | struct bgp_table *table; |
| 4775 | struct bgp_node *top; |
| 4776 | struct bgp_node *rn; |
| 4777 | u_char origin; |
| 4778 | struct aspath *aspath = NULL; |
| 4779 | struct aspath *asmerge = NULL; |
| 4780 | struct community *community = NULL; |
| 4781 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4782 | struct bgp_info *ri; |
| 4783 | struct bgp_info *new; |
| 4784 | int first = 1; |
| 4785 | unsigned long match = 0; |
| 4786 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4787 | /* ORIGIN attribute: If at least one route among routes that are |
| 4788 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4789 | aggregated route must have the ORIGIN attribute with the value |
| 4790 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4791 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4792 | route must have the origin attribute with the value EGP. In all |
| 4793 | other case the value of the ORIGIN attribute of the aggregated |
| 4794 | route is INTERNAL. */ |
| 4795 | origin = BGP_ORIGIN_IGP; |
| 4796 | |
| 4797 | table = bgp->rib[afi][safi]; |
| 4798 | |
| 4799 | top = bgp_node_get (table, p); |
| 4800 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4801 | if (rn->p.prefixlen > p->prefixlen) |
| 4802 | { |
| 4803 | match = 0; |
| 4804 | |
| 4805 | for (ri = rn->info; ri; ri = ri->next) |
| 4806 | { |
| 4807 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4808 | continue; |
| 4809 | |
| 4810 | if (del && ri == del) |
| 4811 | continue; |
| 4812 | |
| 4813 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4814 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4815 | |
| 4816 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4817 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4818 | || ri->attr->med != med) |
| 4819 | { |
| 4820 | if (aspath) |
| 4821 | aspath_free (aspath); |
| 4822 | if (community) |
| 4823 | community_free (community); |
| 4824 | bgp_unlock_node (rn); |
| 4825 | bgp_unlock_node (top); |
| 4826 | return; |
| 4827 | } |
| 4828 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4829 | |
| 4830 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4831 | { |
| 4832 | if (aggregate->summary_only) |
| 4833 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4834 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4835 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4836 | match++; |
| 4837 | } |
| 4838 | |
| 4839 | aggregate->count++; |
| 4840 | |
| 4841 | if (aggregate->as_set) |
| 4842 | { |
| 4843 | if (origin < ri->attr->origin) |
| 4844 | origin = ri->attr->origin; |
| 4845 | |
| 4846 | if (aspath) |
| 4847 | { |
| 4848 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4849 | aspath_free (aspath); |
| 4850 | aspath = asmerge; |
| 4851 | } |
| 4852 | else |
| 4853 | aspath = aspath_dup (ri->attr->aspath); |
| 4854 | |
| 4855 | if (ri->attr->community) |
| 4856 | { |
| 4857 | if (community) |
| 4858 | { |
| 4859 | commerge = community_merge (community, |
| 4860 | ri->attr->community); |
| 4861 | community = community_uniq_sort (commerge); |
| 4862 | community_free (commerge); |
| 4863 | } |
| 4864 | else |
| 4865 | community = community_dup (ri->attr->community); |
| 4866 | } |
| 4867 | } |
| 4868 | } |
| 4869 | } |
| 4870 | if (match) |
| 4871 | bgp_process (bgp, rn, afi, safi); |
| 4872 | } |
| 4873 | bgp_unlock_node (top); |
| 4874 | |
| 4875 | if (rinew) |
| 4876 | { |
| 4877 | aggregate->count++; |
| 4878 | |
| 4879 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4880 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4881 | |
| 4882 | if (aggregate->as_set) |
| 4883 | { |
| 4884 | if (origin < rinew->attr->origin) |
| 4885 | origin = rinew->attr->origin; |
| 4886 | |
| 4887 | if (aspath) |
| 4888 | { |
| 4889 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4890 | aspath_free (aspath); |
| 4891 | aspath = asmerge; |
| 4892 | } |
| 4893 | else |
| 4894 | aspath = aspath_dup (rinew->attr->aspath); |
| 4895 | |
| 4896 | if (rinew->attr->community) |
| 4897 | { |
| 4898 | if (community) |
| 4899 | { |
| 4900 | commerge = community_merge (community, |
| 4901 | rinew->attr->community); |
| 4902 | community = community_uniq_sort (commerge); |
| 4903 | community_free (commerge); |
| 4904 | } |
| 4905 | else |
| 4906 | community = community_dup (rinew->attr->community); |
| 4907 | } |
| 4908 | } |
| 4909 | } |
| 4910 | |
| 4911 | if (aggregate->count > 0) |
| 4912 | { |
| 4913 | rn = bgp_node_get (table, p); |
| 4914 | new = bgp_info_new (); |
| 4915 | new->type = ZEBRA_ROUTE_BGP; |
| 4916 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4917 | new->peer = bgp->peer_self; |
| 4918 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4919 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 4920 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4921 | |
| 4922 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4923 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4924 | bgp_process (bgp, rn, afi, safi); |
| 4925 | } |
| 4926 | else |
| 4927 | { |
| 4928 | if (aspath) |
| 4929 | aspath_free (aspath); |
| 4930 | if (community) |
| 4931 | community_free (community); |
| 4932 | } |
| 4933 | } |
| 4934 | |
| 4935 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4936 | struct bgp_aggregate *); |
| 4937 | |
| 4938 | void |
| 4939 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4940 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4941 | { |
| 4942 | struct bgp_node *child; |
| 4943 | struct bgp_node *rn; |
| 4944 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4945 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4946 | |
| 4947 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4948 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4949 | return; |
| 4950 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4951 | table = bgp->aggregate[afi][safi]; |
| 4952 | |
| 4953 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4954 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4955 | return; |
| 4956 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4957 | if (p->prefixlen == 0) |
| 4958 | return; |
| 4959 | |
| 4960 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4961 | return; |
| 4962 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4963 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4964 | |
| 4965 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4966 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4967 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4968 | { |
| 4969 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4970 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4971 | } |
| 4972 | bgp_unlock_node (child); |
| 4973 | } |
| 4974 | |
| 4975 | void |
| 4976 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4977 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4978 | { |
| 4979 | struct bgp_node *child; |
| 4980 | struct bgp_node *rn; |
| 4981 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4982 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4983 | |
| 4984 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4985 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4986 | return; |
| 4987 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4988 | table = bgp->aggregate[afi][safi]; |
| 4989 | |
| 4990 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4991 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4992 | return; |
| 4993 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4994 | if (p->prefixlen == 0) |
| 4995 | return; |
| 4996 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4997 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4998 | |
| 4999 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5000 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5001 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 5002 | { |
| 5003 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 5004 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5005 | } |
| 5006 | bgp_unlock_node (child); |
| 5007 | } |
| 5008 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5009 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5010 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 5011 | struct bgp_aggregate *aggregate) |
| 5012 | { |
| 5013 | struct bgp_table *table; |
| 5014 | struct bgp_node *top; |
| 5015 | struct bgp_node *rn; |
| 5016 | struct bgp_info *new; |
| 5017 | struct bgp_info *ri; |
| 5018 | unsigned long match; |
| 5019 | u_char origin = BGP_ORIGIN_IGP; |
| 5020 | struct aspath *aspath = NULL; |
| 5021 | struct aspath *asmerge = NULL; |
| 5022 | struct community *community = NULL; |
| 5023 | struct community *commerge = NULL; |
| 5024 | |
| 5025 | table = bgp->rib[afi][safi]; |
| 5026 | |
| 5027 | /* Sanity check. */ |
| 5028 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5029 | return; |
| 5030 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5031 | return; |
| 5032 | |
| 5033 | /* If routes exists below this node, generate aggregate routes. */ |
| 5034 | top = bgp_node_get (table, p); |
| 5035 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5036 | if (rn->p.prefixlen > p->prefixlen) |
| 5037 | { |
| 5038 | match = 0; |
| 5039 | |
| 5040 | for (ri = rn->info; ri; ri = ri->next) |
| 5041 | { |
| 5042 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5043 | continue; |
| 5044 | |
| 5045 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5046 | { |
| 5047 | /* summary-only aggregate route suppress aggregated |
| 5048 | route announcement. */ |
| 5049 | if (aggregate->summary_only) |
| 5050 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5051 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5052 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5053 | match++; |
| 5054 | } |
| 5055 | /* as-set aggregate route generate origin, as path, |
| 5056 | community aggregation. */ |
| 5057 | if (aggregate->as_set) |
| 5058 | { |
| 5059 | if (origin < ri->attr->origin) |
| 5060 | origin = ri->attr->origin; |
| 5061 | |
| 5062 | if (aspath) |
| 5063 | { |
| 5064 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 5065 | aspath_free (aspath); |
| 5066 | aspath = asmerge; |
| 5067 | } |
| 5068 | else |
| 5069 | aspath = aspath_dup (ri->attr->aspath); |
| 5070 | |
| 5071 | if (ri->attr->community) |
| 5072 | { |
| 5073 | if (community) |
| 5074 | { |
| 5075 | commerge = community_merge (community, |
| 5076 | ri->attr->community); |
| 5077 | community = community_uniq_sort (commerge); |
| 5078 | community_free (commerge); |
| 5079 | } |
| 5080 | else |
| 5081 | community = community_dup (ri->attr->community); |
| 5082 | } |
| 5083 | } |
| 5084 | aggregate->count++; |
| 5085 | } |
| 5086 | } |
| 5087 | |
| 5088 | /* If this node is suppressed, process the change. */ |
| 5089 | if (match) |
| 5090 | bgp_process (bgp, rn, afi, safi); |
| 5091 | } |
| 5092 | bgp_unlock_node (top); |
| 5093 | |
| 5094 | /* Add aggregate route to BGP table. */ |
| 5095 | if (aggregate->count) |
| 5096 | { |
| 5097 | rn = bgp_node_get (table, p); |
| 5098 | |
| 5099 | new = bgp_info_new (); |
| 5100 | new->type = ZEBRA_ROUTE_BGP; |
| 5101 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 5102 | new->peer = bgp->peer_self; |
| 5103 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5104 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5105 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5106 | |
| 5107 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5108 | bgp_unlock_node (rn); |
| 5109 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5110 | /* Process change. */ |
| 5111 | bgp_process (bgp, rn, afi, safi); |
| 5112 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 5113 | else |
| 5114 | { |
| 5115 | if (aspath) |
| 5116 | aspath_free (aspath); |
| 5117 | if (community) |
| 5118 | community_free (community); |
| 5119 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5120 | } |
| 5121 | |
| 5122 | void |
| 5123 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 5124 | safi_t safi, struct bgp_aggregate *aggregate) |
| 5125 | { |
| 5126 | struct bgp_table *table; |
| 5127 | struct bgp_node *top; |
| 5128 | struct bgp_node *rn; |
| 5129 | struct bgp_info *ri; |
| 5130 | unsigned long match; |
| 5131 | |
| 5132 | table = bgp->rib[afi][safi]; |
| 5133 | |
| 5134 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5135 | return; |
| 5136 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5137 | return; |
| 5138 | |
| 5139 | /* If routes exists below this node, generate aggregate routes. */ |
| 5140 | top = bgp_node_get (table, p); |
| 5141 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5142 | if (rn->p.prefixlen > p->prefixlen) |
| 5143 | { |
| 5144 | match = 0; |
| 5145 | |
| 5146 | for (ri = rn->info; ri; ri = ri->next) |
| 5147 | { |
| 5148 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5149 | continue; |
| 5150 | |
| 5151 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5152 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5153 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5154 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5155 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5156 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5157 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5158 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5159 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5160 | match++; |
| 5161 | } |
| 5162 | } |
| 5163 | aggregate->count--; |
| 5164 | } |
| 5165 | } |
| 5166 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5167 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5168 | if (match) |
| 5169 | bgp_process (bgp, rn, afi, safi); |
| 5170 | } |
| 5171 | bgp_unlock_node (top); |
| 5172 | |
| 5173 | /* Delete aggregate route from BGP table. */ |
| 5174 | rn = bgp_node_get (table, p); |
| 5175 | |
| 5176 | for (ri = rn->info; ri; ri = ri->next) |
| 5177 | if (ri->peer == bgp->peer_self |
| 5178 | && ri->type == ZEBRA_ROUTE_BGP |
| 5179 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 5180 | break; |
| 5181 | |
| 5182 | /* Withdraw static BGP route from routing table. */ |
| 5183 | if (ri) |
| 5184 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5185 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5186 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5187 | } |
| 5188 | |
| 5189 | /* Unlock bgp_node_lookup. */ |
| 5190 | bgp_unlock_node (rn); |
| 5191 | } |
| 5192 | |
| 5193 | /* Aggregate route attribute. */ |
| 5194 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 5195 | #define AGGREGATE_AS_SET 1 |
| 5196 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5197 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5198 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 5199 | afi_t afi, safi_t safi) |
| 5200 | { |
| 5201 | int ret; |
| 5202 | struct prefix p; |
| 5203 | struct bgp_node *rn; |
| 5204 | struct bgp *bgp; |
| 5205 | struct bgp_aggregate *aggregate; |
| 5206 | |
| 5207 | /* Convert string to prefix structure. */ |
| 5208 | ret = str2prefix (prefix_str, &p); |
| 5209 | if (!ret) |
| 5210 | { |
| 5211 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5212 | return CMD_WARNING; |
| 5213 | } |
| 5214 | apply_mask (&p); |
| 5215 | |
| 5216 | /* Get BGP structure. */ |
| 5217 | bgp = vty->index; |
| 5218 | |
| 5219 | /* Old configuration check. */ |
| 5220 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 5221 | if (! rn) |
| 5222 | { |
| 5223 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 5224 | VTY_NEWLINE); |
| 5225 | return CMD_WARNING; |
| 5226 | } |
| 5227 | |
| 5228 | aggregate = rn->info; |
| 5229 | if (aggregate->safi & SAFI_UNICAST) |
| 5230 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5231 | if (aggregate->safi & SAFI_MULTICAST) |
| 5232 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5233 | |
| 5234 | /* Unlock aggregate address configuration. */ |
| 5235 | rn->info = NULL; |
| 5236 | bgp_aggregate_free (aggregate); |
| 5237 | bgp_unlock_node (rn); |
| 5238 | bgp_unlock_node (rn); |
| 5239 | |
| 5240 | return CMD_SUCCESS; |
| 5241 | } |
| 5242 | |
| 5243 | static int |
| 5244 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5245 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5246 | u_char summary_only, u_char as_set) |
| 5247 | { |
| 5248 | int ret; |
| 5249 | struct prefix p; |
| 5250 | struct bgp_node *rn; |
| 5251 | struct bgp *bgp; |
| 5252 | struct bgp_aggregate *aggregate; |
| 5253 | |
| 5254 | /* Convert string to prefix structure. */ |
| 5255 | ret = str2prefix (prefix_str, &p); |
| 5256 | if (!ret) |
| 5257 | { |
| 5258 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5259 | return CMD_WARNING; |
| 5260 | } |
| 5261 | apply_mask (&p); |
| 5262 | |
| 5263 | /* Get BGP structure. */ |
| 5264 | bgp = vty->index; |
| 5265 | |
| 5266 | /* Old configuration check. */ |
| 5267 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5268 | |
| 5269 | if (rn->info) |
| 5270 | { |
| 5271 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5272 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5273 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5274 | if (ret) |
| 5275 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5276 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5277 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5278 | return CMD_WARNING; |
| 5279 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5280 | } |
| 5281 | |
| 5282 | /* Make aggregate address structure. */ |
| 5283 | aggregate = bgp_aggregate_new (); |
| 5284 | aggregate->summary_only = summary_only; |
| 5285 | aggregate->as_set = as_set; |
| 5286 | aggregate->safi = safi; |
| 5287 | rn->info = aggregate; |
| 5288 | |
| 5289 | /* Aggregate address insert into BGP routing table. */ |
| 5290 | if (safi & SAFI_UNICAST) |
| 5291 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5292 | if (safi & SAFI_MULTICAST) |
| 5293 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5294 | |
| 5295 | return CMD_SUCCESS; |
| 5296 | } |
| 5297 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5298 | DEFUN (aggregate_address, |
| 5299 | aggregate_address_cmd, |
| 5300 | "aggregate-address A.B.C.D/M", |
| 5301 | "Configure BGP aggregate entries\n" |
| 5302 | "Aggregate prefix\n") |
| 5303 | { |
| 5304 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5305 | } |
| 5306 | |
| 5307 | DEFUN (aggregate_address_mask, |
| 5308 | aggregate_address_mask_cmd, |
| 5309 | "aggregate-address A.B.C.D A.B.C.D", |
| 5310 | "Configure BGP aggregate entries\n" |
| 5311 | "Aggregate address\n" |
| 5312 | "Aggregate mask\n") |
| 5313 | { |
| 5314 | int ret; |
| 5315 | char prefix_str[BUFSIZ]; |
| 5316 | |
| 5317 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5318 | |
| 5319 | if (! ret) |
| 5320 | { |
| 5321 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5322 | return CMD_WARNING; |
| 5323 | } |
| 5324 | |
| 5325 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5326 | 0, 0); |
| 5327 | } |
| 5328 | |
| 5329 | DEFUN (aggregate_address_summary_only, |
| 5330 | aggregate_address_summary_only_cmd, |
| 5331 | "aggregate-address A.B.C.D/M summary-only", |
| 5332 | "Configure BGP aggregate entries\n" |
| 5333 | "Aggregate prefix\n" |
| 5334 | "Filter more specific routes from updates\n") |
| 5335 | { |
| 5336 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5337 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5338 | } |
| 5339 | |
| 5340 | DEFUN (aggregate_address_mask_summary_only, |
| 5341 | aggregate_address_mask_summary_only_cmd, |
| 5342 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5343 | "Configure BGP aggregate entries\n" |
| 5344 | "Aggregate address\n" |
| 5345 | "Aggregate mask\n" |
| 5346 | "Filter more specific routes from updates\n") |
| 5347 | { |
| 5348 | int ret; |
| 5349 | char prefix_str[BUFSIZ]; |
| 5350 | |
| 5351 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5352 | |
| 5353 | if (! ret) |
| 5354 | { |
| 5355 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5356 | return CMD_WARNING; |
| 5357 | } |
| 5358 | |
| 5359 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5360 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5361 | } |
| 5362 | |
| 5363 | DEFUN (aggregate_address_as_set, |
| 5364 | aggregate_address_as_set_cmd, |
| 5365 | "aggregate-address A.B.C.D/M as-set", |
| 5366 | "Configure BGP aggregate entries\n" |
| 5367 | "Aggregate prefix\n" |
| 5368 | "Generate AS set path information\n") |
| 5369 | { |
| 5370 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5371 | 0, AGGREGATE_AS_SET); |
| 5372 | } |
| 5373 | |
| 5374 | DEFUN (aggregate_address_mask_as_set, |
| 5375 | aggregate_address_mask_as_set_cmd, |
| 5376 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5377 | "Configure BGP aggregate entries\n" |
| 5378 | "Aggregate address\n" |
| 5379 | "Aggregate mask\n" |
| 5380 | "Generate AS set path information\n") |
| 5381 | { |
| 5382 | int ret; |
| 5383 | char prefix_str[BUFSIZ]; |
| 5384 | |
| 5385 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5386 | |
| 5387 | if (! ret) |
| 5388 | { |
| 5389 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5390 | return CMD_WARNING; |
| 5391 | } |
| 5392 | |
| 5393 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5394 | 0, AGGREGATE_AS_SET); |
| 5395 | } |
| 5396 | |
| 5397 | |
| 5398 | DEFUN (aggregate_address_as_set_summary, |
| 5399 | aggregate_address_as_set_summary_cmd, |
| 5400 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5401 | "Configure BGP aggregate entries\n" |
| 5402 | "Aggregate prefix\n" |
| 5403 | "Generate AS set path information\n" |
| 5404 | "Filter more specific routes from updates\n") |
| 5405 | { |
| 5406 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5407 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5408 | } |
| 5409 | |
| 5410 | ALIAS (aggregate_address_as_set_summary, |
| 5411 | aggregate_address_summary_as_set_cmd, |
| 5412 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5413 | "Configure BGP aggregate entries\n" |
| 5414 | "Aggregate prefix\n" |
| 5415 | "Filter more specific routes from updates\n" |
| 5416 | "Generate AS set path information\n") |
| 5417 | |
| 5418 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5419 | aggregate_address_mask_as_set_summary_cmd, |
| 5420 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5421 | "Configure BGP aggregate entries\n" |
| 5422 | "Aggregate address\n" |
| 5423 | "Aggregate mask\n" |
| 5424 | "Generate AS set path information\n" |
| 5425 | "Filter more specific routes from updates\n") |
| 5426 | { |
| 5427 | int ret; |
| 5428 | char prefix_str[BUFSIZ]; |
| 5429 | |
| 5430 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5431 | |
| 5432 | if (! ret) |
| 5433 | { |
| 5434 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5435 | return CMD_WARNING; |
| 5436 | } |
| 5437 | |
| 5438 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5439 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5440 | } |
| 5441 | |
| 5442 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5443 | aggregate_address_mask_summary_as_set_cmd, |
| 5444 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5445 | "Configure BGP aggregate entries\n" |
| 5446 | "Aggregate address\n" |
| 5447 | "Aggregate mask\n" |
| 5448 | "Filter more specific routes from updates\n" |
| 5449 | "Generate AS set path information\n") |
| 5450 | |
| 5451 | DEFUN (no_aggregate_address, |
| 5452 | no_aggregate_address_cmd, |
| 5453 | "no aggregate-address A.B.C.D/M", |
| 5454 | NO_STR |
| 5455 | "Configure BGP aggregate entries\n" |
| 5456 | "Aggregate prefix\n") |
| 5457 | { |
| 5458 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5459 | } |
| 5460 | |
| 5461 | ALIAS (no_aggregate_address, |
| 5462 | no_aggregate_address_summary_only_cmd, |
| 5463 | "no aggregate-address A.B.C.D/M summary-only", |
| 5464 | NO_STR |
| 5465 | "Configure BGP aggregate entries\n" |
| 5466 | "Aggregate prefix\n" |
| 5467 | "Filter more specific routes from updates\n") |
| 5468 | |
| 5469 | ALIAS (no_aggregate_address, |
| 5470 | no_aggregate_address_as_set_cmd, |
| 5471 | "no aggregate-address A.B.C.D/M as-set", |
| 5472 | NO_STR |
| 5473 | "Configure BGP aggregate entries\n" |
| 5474 | "Aggregate prefix\n" |
| 5475 | "Generate AS set path information\n") |
| 5476 | |
| 5477 | ALIAS (no_aggregate_address, |
| 5478 | no_aggregate_address_as_set_summary_cmd, |
| 5479 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5480 | NO_STR |
| 5481 | "Configure BGP aggregate entries\n" |
| 5482 | "Aggregate prefix\n" |
| 5483 | "Generate AS set path information\n" |
| 5484 | "Filter more specific routes from updates\n") |
| 5485 | |
| 5486 | ALIAS (no_aggregate_address, |
| 5487 | no_aggregate_address_summary_as_set_cmd, |
| 5488 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5489 | NO_STR |
| 5490 | "Configure BGP aggregate entries\n" |
| 5491 | "Aggregate prefix\n" |
| 5492 | "Filter more specific routes from updates\n" |
| 5493 | "Generate AS set path information\n") |
| 5494 | |
| 5495 | DEFUN (no_aggregate_address_mask, |
| 5496 | no_aggregate_address_mask_cmd, |
| 5497 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5498 | NO_STR |
| 5499 | "Configure BGP aggregate entries\n" |
| 5500 | "Aggregate address\n" |
| 5501 | "Aggregate mask\n") |
| 5502 | { |
| 5503 | int ret; |
| 5504 | char prefix_str[BUFSIZ]; |
| 5505 | |
| 5506 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5507 | |
| 5508 | if (! ret) |
| 5509 | { |
| 5510 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5511 | return CMD_WARNING; |
| 5512 | } |
| 5513 | |
| 5514 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5515 | } |
| 5516 | |
| 5517 | ALIAS (no_aggregate_address_mask, |
| 5518 | no_aggregate_address_mask_summary_only_cmd, |
| 5519 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5520 | NO_STR |
| 5521 | "Configure BGP aggregate entries\n" |
| 5522 | "Aggregate address\n" |
| 5523 | "Aggregate mask\n" |
| 5524 | "Filter more specific routes from updates\n") |
| 5525 | |
| 5526 | ALIAS (no_aggregate_address_mask, |
| 5527 | no_aggregate_address_mask_as_set_cmd, |
| 5528 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5529 | NO_STR |
| 5530 | "Configure BGP aggregate entries\n" |
| 5531 | "Aggregate address\n" |
| 5532 | "Aggregate mask\n" |
| 5533 | "Generate AS set path information\n") |
| 5534 | |
| 5535 | ALIAS (no_aggregate_address_mask, |
| 5536 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5537 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5538 | NO_STR |
| 5539 | "Configure BGP aggregate entries\n" |
| 5540 | "Aggregate address\n" |
| 5541 | "Aggregate mask\n" |
| 5542 | "Generate AS set path information\n" |
| 5543 | "Filter more specific routes from updates\n") |
| 5544 | |
| 5545 | ALIAS (no_aggregate_address_mask, |
| 5546 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5547 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5548 | NO_STR |
| 5549 | "Configure BGP aggregate entries\n" |
| 5550 | "Aggregate address\n" |
| 5551 | "Aggregate mask\n" |
| 5552 | "Filter more specific routes from updates\n" |
| 5553 | "Generate AS set path information\n") |
| 5554 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5555 | DEFUN (ipv6_aggregate_address, |
| 5556 | ipv6_aggregate_address_cmd, |
| 5557 | "aggregate-address X:X::X:X/M", |
| 5558 | "Configure BGP aggregate entries\n" |
| 5559 | "Aggregate prefix\n") |
| 5560 | { |
| 5561 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5562 | } |
| 5563 | |
| 5564 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5565 | ipv6_aggregate_address_summary_only_cmd, |
| 5566 | "aggregate-address X:X::X:X/M summary-only", |
| 5567 | "Configure BGP aggregate entries\n" |
| 5568 | "Aggregate prefix\n" |
| 5569 | "Filter more specific routes from updates\n") |
| 5570 | { |
| 5571 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5572 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5573 | } |
| 5574 | |
| 5575 | DEFUN (no_ipv6_aggregate_address, |
| 5576 | no_ipv6_aggregate_address_cmd, |
| 5577 | "no aggregate-address X:X::X:X/M", |
| 5578 | NO_STR |
| 5579 | "Configure BGP aggregate entries\n" |
| 5580 | "Aggregate prefix\n") |
| 5581 | { |
| 5582 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5583 | } |
| 5584 | |
| 5585 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5586 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5587 | "no aggregate-address X:X::X:X/M summary-only", |
| 5588 | NO_STR |
| 5589 | "Configure BGP aggregate entries\n" |
| 5590 | "Aggregate prefix\n" |
| 5591 | "Filter more specific routes from updates\n") |
| 5592 | { |
| 5593 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5594 | } |
| 5595 | |
| 5596 | ALIAS (ipv6_aggregate_address, |
| 5597 | old_ipv6_aggregate_address_cmd, |
| 5598 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5599 | IPV6_STR |
| 5600 | BGP_STR |
| 5601 | "Configure BGP aggregate entries\n" |
| 5602 | "Aggregate prefix\n") |
| 5603 | |
| 5604 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5605 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5606 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5607 | IPV6_STR |
| 5608 | BGP_STR |
| 5609 | "Configure BGP aggregate entries\n" |
| 5610 | "Aggregate prefix\n" |
| 5611 | "Filter more specific routes from updates\n") |
| 5612 | |
| 5613 | ALIAS (no_ipv6_aggregate_address, |
| 5614 | old_no_ipv6_aggregate_address_cmd, |
| 5615 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5616 | NO_STR |
| 5617 | IPV6_STR |
| 5618 | BGP_STR |
| 5619 | "Configure BGP aggregate entries\n" |
| 5620 | "Aggregate prefix\n") |
| 5621 | |
| 5622 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5623 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5624 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5625 | NO_STR |
| 5626 | IPV6_STR |
| 5627 | BGP_STR |
| 5628 | "Configure BGP aggregate entries\n" |
| 5629 | "Aggregate prefix\n" |
| 5630 | "Filter more specific routes from updates\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5631 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5632 | /* Redistribute route treatment. */ |
| 5633 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5634 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5635 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5636 | u_int32_t metric, u_char type) |
| 5637 | { |
| 5638 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5639 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5640 | struct bgp_info *new; |
| 5641 | struct bgp_info *bi; |
| 5642 | struct bgp_info info; |
| 5643 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5644 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5645 | struct attr *new_attr; |
| 5646 | afi_t afi; |
| 5647 | int ret; |
| 5648 | |
| 5649 | /* Make default attribute. */ |
| 5650 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5651 | if (nexthop) |
| 5652 | attr.nexthop = *nexthop; |
| 5653 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5654 | if (nexthop6) |
| 5655 | { |
| 5656 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5657 | extra->mp_nexthop_global = *nexthop6; |
| 5658 | extra->mp_nexthop_len = 16; |
| 5659 | } |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5660 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5661 | attr.med = metric; |
| 5662 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5663 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5664 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5665 | { |
| 5666 | afi = family2afi (p->family); |
| 5667 | |
| 5668 | if (bgp->redist[afi][type]) |
| 5669 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5670 | struct attr attr_new; |
| 5671 | struct attr_extra extra_new; |
| 5672 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5673 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5674 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5675 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5676 | |
| 5677 | if (bgp->redist_metric_flag[afi][type]) |
| 5678 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5679 | |
| 5680 | /* Apply route-map. */ |
Daniel Walton | 1994dc8 | 2015-09-17 10:15:59 -0400 | [diff] [blame] | 5681 | if (bgp->rmap[afi][type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5682 | { |
| 5683 | info.peer = bgp->peer_self; |
| 5684 | info.attr = &attr_new; |
| 5685 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5686 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5687 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5688 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5689 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5690 | |
| 5691 | bgp->peer_self->rmap_type = 0; |
| 5692 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5693 | if (ret == RMAP_DENYMATCH) |
| 5694 | { |
| 5695 | /* Free uninterned attribute. */ |
| 5696 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5698 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5699 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5700 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5701 | bgp_redistribute_delete (p, type); |
| 5702 | return; |
| 5703 | } |
| 5704 | } |
| 5705 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5706 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5707 | afi, SAFI_UNICAST, p, NULL); |
| 5708 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5709 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5710 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5711 | for (bi = bn->info; bi; bi = bi->next) |
| 5712 | if (bi->peer == bgp->peer_self |
| 5713 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5714 | break; |
| 5715 | |
| 5716 | if (bi) |
| 5717 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5718 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5719 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5720 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5721 | bgp_attr_unintern (&new_attr); |
| 5722 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5723 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5724 | bgp_unlock_node (bn); |
| 5725 | return; |
| 5726 | } |
| 5727 | else |
| 5728 | { |
| 5729 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5730 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5731 | |
| 5732 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5733 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5734 | bgp_info_restore(bn, bi); |
| 5735 | else |
| 5736 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5737 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5738 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5739 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5740 | |
| 5741 | /* Process change. */ |
| 5742 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5743 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5744 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5745 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5746 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5747 | return; |
| 5748 | } |
| 5749 | } |
| 5750 | |
| 5751 | new = bgp_info_new (); |
| 5752 | new->type = type; |
| 5753 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5754 | new->peer = bgp->peer_self; |
| 5755 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5756 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5757 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5758 | |
| 5759 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5760 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5761 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5762 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5763 | } |
| 5764 | } |
| 5765 | |
| 5766 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5767 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5768 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5769 | } |
| 5770 | |
| 5771 | void |
| 5772 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5773 | { |
| 5774 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5775 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5776 | afi_t afi; |
| 5777 | struct bgp_node *rn; |
| 5778 | struct bgp_info *ri; |
| 5779 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5780 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5781 | { |
| 5782 | afi = family2afi (p->family); |
| 5783 | |
| 5784 | if (bgp->redist[afi][type]) |
| 5785 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5786 | 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] | 5787 | |
| 5788 | for (ri = rn->info; ri; ri = ri->next) |
| 5789 | if (ri->peer == bgp->peer_self |
| 5790 | && ri->type == type) |
| 5791 | break; |
| 5792 | |
| 5793 | if (ri) |
| 5794 | { |
| 5795 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5796 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5797 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5798 | } |
| 5799 | bgp_unlock_node (rn); |
| 5800 | } |
| 5801 | } |
| 5802 | } |
| 5803 | |
| 5804 | /* Withdraw specified route type's route. */ |
| 5805 | void |
| 5806 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5807 | { |
| 5808 | struct bgp_node *rn; |
| 5809 | struct bgp_info *ri; |
| 5810 | struct bgp_table *table; |
| 5811 | |
| 5812 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5813 | |
| 5814 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5815 | { |
| 5816 | for (ri = rn->info; ri; ri = ri->next) |
| 5817 | if (ri->peer == bgp->peer_self |
| 5818 | && ri->type == type) |
| 5819 | break; |
| 5820 | |
| 5821 | if (ri) |
| 5822 | { |
| 5823 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5824 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5825 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5826 | } |
| 5827 | } |
| 5828 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5829 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5830 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5831 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5832 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5833 | { |
| 5834 | int len; |
| 5835 | u_int32_t destination; |
| 5836 | char buf[BUFSIZ]; |
| 5837 | |
| 5838 | if (p->family == AF_INET) |
| 5839 | { |
| 5840 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5841 | destination = ntohl (p->u.prefix4.s_addr); |
| 5842 | |
| 5843 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5844 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5845 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5846 | || p->u.prefix4.s_addr == 0) |
| 5847 | { |
| 5848 | /* When mask is natural, mask is not displayed. */ |
| 5849 | } |
| 5850 | else |
| 5851 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5852 | } |
| 5853 | else |
| 5854 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5855 | p->prefixlen); |
| 5856 | |
| 5857 | len = 17 - len; |
| 5858 | if (len < 1) |
| 5859 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5860 | else |
| 5861 | vty_out (vty, "%*s", len, " "); |
| 5862 | } |
| 5863 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5864 | enum bgp_display_type |
| 5865 | { |
| 5866 | normal_list, |
| 5867 | }; |
| 5868 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5869 | /* Print the short form route status for a bgp_info */ |
| 5870 | static void |
| 5871 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5872 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5873 | /* Route status display. */ |
| 5874 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5875 | vty_out (vty, "R"); |
| 5876 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5877 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5878 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5879 | vty_out (vty, "s"); |
| 5880 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5881 | vty_out (vty, "*"); |
| 5882 | else |
| 5883 | vty_out (vty, " "); |
| 5884 | |
| 5885 | /* Selected */ |
| 5886 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5887 | vty_out (vty, "h"); |
| 5888 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5889 | vty_out (vty, "d"); |
| 5890 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5891 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5892 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5893 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5894 | else |
| 5895 | vty_out (vty, " "); |
| 5896 | |
| 5897 | /* Internal route. */ |
| 5898 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5899 | vty_out (vty, "i"); |
| 5900 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5901 | vty_out (vty, " "); |
| 5902 | } |
| 5903 | |
| 5904 | /* called from terminal list command */ |
| 5905 | void |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5906 | route_vty_out( |
| 5907 | struct vty *vty, |
| 5908 | struct prefix *p, |
| 5909 | struct bgp_info *binfo, |
| 5910 | int display, |
| 5911 | safi_t safi) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5912 | { |
| 5913 | struct attr *attr; |
| 5914 | |
| 5915 | /* short status lead text */ |
| 5916 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5917 | |
| 5918 | /* print prefix and mask */ |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5919 | if (!display) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5920 | route_vty_out_route (p, vty); |
| 5921 | else |
| 5922 | vty_out (vty, "%*s", 17, " "); |
| 5923 | |
| 5924 | /* Print attribute */ |
| 5925 | attr = binfo->attr; |
| 5926 | if (attr) |
| 5927 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5928 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5929 | /* |
| 5930 | * NEXTHOP start |
| 5931 | */ |
| 5932 | |
| 5933 | /* |
| 5934 | * For ENCAP routes, nexthop address family is not |
| 5935 | * neccessarily the same as the prefix address family. |
| 5936 | * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field |
| 5937 | */ |
| 5938 | if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) { |
| 5939 | if (attr->extra) { |
| 5940 | char buf[BUFSIZ]; |
| 5941 | int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); |
| 5942 | |
| 5943 | switch (af) { |
| 5944 | case AF_INET: |
| 5945 | vty_out (vty, "%s", inet_ntop(af, |
| 5946 | &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); |
| 5947 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5948 | case AF_INET6: |
| 5949 | vty_out (vty, "%s", inet_ntop(af, |
| 5950 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); |
| 5951 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5952 | default: |
| 5953 | vty_out(vty, "?"); |
| 5954 | } |
| 5955 | } else { |
| 5956 | vty_out(vty, "?"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5957 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5958 | } else { |
| 5959 | |
| 5960 | if (p->family == AF_INET) |
| 5961 | { |
| 5962 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5963 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5964 | else if (p->family == AF_INET6) |
| 5965 | { |
| 5966 | int len; |
| 5967 | char buf[BUFSIZ]; |
| 5968 | |
| 5969 | len = vty_out (vty, "%s", |
| 5970 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5971 | buf, BUFSIZ)); |
| 5972 | len = 16 - len; |
| 5973 | if (len < 1) |
| 5974 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5975 | else |
| 5976 | vty_out (vty, "%*s", len, " "); |
| 5977 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5978 | else |
| 5979 | { |
| 5980 | vty_out(vty, "?"); |
| 5981 | } |
| 5982 | } |
| 5983 | |
| 5984 | /* |
| 5985 | * NEXTHOP end |
| 5986 | */ |
| 5987 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5988 | |
| 5989 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5990 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5991 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5992 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5993 | |
| 5994 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5995 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5996 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5997 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5998 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5999 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6000 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6001 | /* Print aspath */ |
| 6002 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6003 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6004 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6005 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6006 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6007 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6008 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6009 | } |
| 6010 | |
| 6011 | /* called from terminal list command */ |
| 6012 | void |
| 6013 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 6014 | struct attr *attr, safi_t safi) |
| 6015 | { |
| 6016 | /* Route status display. */ |
| 6017 | vty_out (vty, "*"); |
| 6018 | vty_out (vty, ">"); |
| 6019 | vty_out (vty, " "); |
| 6020 | |
| 6021 | /* print prefix and mask */ |
| 6022 | route_vty_out_route (p, vty); |
| 6023 | |
| 6024 | /* Print attribute */ |
| 6025 | if (attr) |
| 6026 | { |
| 6027 | if (p->family == AF_INET) |
| 6028 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6029 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6030 | vty_out (vty, "%-16s", |
| 6031 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6032 | else |
| 6033 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6034 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6035 | else if (p->family == AF_INET6) |
| 6036 | { |
| 6037 | int len; |
| 6038 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6039 | |
| 6040 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6041 | |
| 6042 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6043 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6044 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6045 | len = 16 - len; |
| 6046 | if (len < 1) |
| 6047 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 6048 | else |
| 6049 | vty_out (vty, "%*s", len, " "); |
| 6050 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6051 | |
| 6052 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6053 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6054 | else |
| 6055 | vty_out (vty, " "); |
| 6056 | |
| 6057 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6058 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6059 | else |
| 6060 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6061 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6062 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6063 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6064 | /* Print aspath */ |
| 6065 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6066 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6067 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6068 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6069 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6070 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6071 | |
| 6072 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6073 | } |
| 6074 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6075 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6076 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 6077 | struct bgp_info *binfo, int display, safi_t safi) |
| 6078 | { |
| 6079 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6080 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6081 | |
| 6082 | if (!binfo->extra) |
| 6083 | return; |
| 6084 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6085 | /* short status lead text */ |
| 6086 | route_vty_short_status_out (vty, binfo); |
| 6087 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6088 | /* print prefix and mask */ |
| 6089 | if (! display) |
| 6090 | route_vty_out_route (p, vty); |
| 6091 | else |
| 6092 | vty_out (vty, "%*s", 17, " "); |
| 6093 | |
| 6094 | /* Print attribute */ |
| 6095 | attr = binfo->attr; |
| 6096 | if (attr) |
| 6097 | { |
| 6098 | if (p->family == AF_INET) |
| 6099 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6100 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6101 | vty_out (vty, "%-16s", |
| 6102 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6103 | else |
| 6104 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6105 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6106 | else if (p->family == AF_INET6) |
| 6107 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6108 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6109 | char buf[BUFSIZ]; |
| 6110 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6111 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6112 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6113 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6114 | buf, BUFSIZ)); |
| 6115 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6116 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6117 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6118 | buf, BUFSIZ), |
| 6119 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 6120 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6121 | |
| 6122 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6123 | } |
| 6124 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6125 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6126 | |
| 6127 | vty_out (vty, "notag/%d", label); |
| 6128 | |
| 6129 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6130 | } |
| 6131 | |
| 6132 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6133 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6134 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 6135 | struct bgp_info *binfo, int display, safi_t safi) |
| 6136 | { |
| 6137 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6138 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6139 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6140 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6141 | /* short status lead text */ |
| 6142 | route_vty_short_status_out (vty, binfo); |
| 6143 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6144 | /* print prefix and mask */ |
| 6145 | if (! display) |
| 6146 | route_vty_out_route (p, vty); |
| 6147 | else |
| 6148 | vty_out (vty, "%*s", 17, " "); |
| 6149 | |
| 6150 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6151 | len = 17 - len; |
| 6152 | if (len < 1) |
| 6153 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 6154 | else |
| 6155 | vty_out (vty, "%*s", len, " "); |
| 6156 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6157 | 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] | 6158 | |
| 6159 | /* Print attribute */ |
| 6160 | attr = binfo->attr; |
| 6161 | if (attr) |
| 6162 | { |
| 6163 | /* Print aspath */ |
| 6164 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6165 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6166 | |
| 6167 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6168 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6169 | } |
| 6170 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6171 | } |
| 6172 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6173 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6174 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6175 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 6176 | struct bgp_info *binfo, int display, safi_t safi) |
| 6177 | { |
| 6178 | struct attr *attr; |
| 6179 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6180 | char timebuf[BGP_UPTIME_LEN]; |
| 6181 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6182 | |
| 6183 | if (!binfo->extra) |
| 6184 | return; |
| 6185 | |
| 6186 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6187 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6188 | /* short status lead text */ |
| 6189 | route_vty_short_status_out (vty, binfo); |
| 6190 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6191 | /* print prefix and mask */ |
| 6192 | if (! display) |
| 6193 | route_vty_out_route (p, vty); |
| 6194 | else |
| 6195 | vty_out (vty, "%*s", 17, " "); |
| 6196 | |
| 6197 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6198 | len = 16 - len; |
| 6199 | if (len < 1) |
| 6200 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 6201 | else |
| 6202 | vty_out (vty, "%*s", len, " "); |
| 6203 | |
| 6204 | len = vty_out (vty, "%d", bdi->flap); |
| 6205 | len = 5 - len; |
| 6206 | if (len < 1) |
| 6207 | vty_out (vty, " "); |
| 6208 | else |
| 6209 | vty_out (vty, "%*s ", len, " "); |
| 6210 | |
| 6211 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 6212 | timebuf, BGP_UPTIME_LEN)); |
| 6213 | |
| 6214 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 6215 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6216 | 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] | 6217 | else |
| 6218 | vty_out (vty, "%*s ", 8, " "); |
| 6219 | |
| 6220 | /* Print attribute */ |
| 6221 | attr = binfo->attr; |
| 6222 | if (attr) |
| 6223 | { |
| 6224 | /* Print aspath */ |
| 6225 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6226 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6227 | |
| 6228 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6229 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6230 | } |
| 6231 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6232 | } |
| 6233 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6234 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6235 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 6236 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 6237 | { |
| 6238 | char buf[INET6_ADDRSTRLEN]; |
| 6239 | char buf1[BUFSIZ]; |
| 6240 | struct attr *attr; |
| 6241 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6242 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6243 | time_t tbuf; |
| 6244 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6245 | |
| 6246 | attr = binfo->attr; |
| 6247 | |
| 6248 | if (attr) |
| 6249 | { |
| 6250 | /* Line1 display AS-path, Aggregator */ |
| 6251 | if (attr->aspath) |
| 6252 | { |
| 6253 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6254 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6255 | vty_out (vty, "Local"); |
| 6256 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6257 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6258 | } |
| 6259 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6260 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6261 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6262 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6263 | vty_out (vty, ", (stale)"); |
| 6264 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6265 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6266 | attr->extra->aggregator_as, |
| 6267 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6268 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6269 | vty_out (vty, ", (Received from a RR-client)"); |
| 6270 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6271 | vty_out (vty, ", (Received from a RS-client)"); |
| 6272 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6273 | vty_out (vty, ", (history entry)"); |
| 6274 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6275 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6276 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6277 | |
| 6278 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6279 | if (p->family == AF_INET) |
| 6280 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6281 | vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6282 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6283 | inet_ntoa (attr->nexthop)); |
| 6284 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6285 | else |
| 6286 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6287 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6288 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6289 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6290 | buf, INET6_ADDRSTRLEN)); |
| 6291 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6292 | |
| 6293 | if (binfo->peer == bgp->peer_self) |
| 6294 | { |
| 6295 | vty_out (vty, " from %s ", |
| 6296 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6297 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6298 | } |
| 6299 | else |
| 6300 | { |
| 6301 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6302 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6303 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6304 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6305 | if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) { |
| 6306 | buf[0] = '?'; |
| 6307 | buf[1] = 0; |
| 6308 | } |
| 6309 | vty_out (vty, " from %s", buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6310 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6311 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6312 | else |
| 6313 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6314 | } |
| 6315 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6316 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6317 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6318 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6319 | { |
| 6320 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6321 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6322 | buf, INET6_ADDRSTRLEN), |
| 6323 | VTY_NEWLINE); |
| 6324 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6325 | |
| 6326 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6327 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6328 | |
| 6329 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6330 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6331 | |
| 6332 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6333 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6334 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6335 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6336 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6337 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6338 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6339 | |
| 6340 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6341 | vty_out (vty, ", valid"); |
| 6342 | |
| 6343 | if (binfo->peer != bgp->peer_self) |
| 6344 | { |
| 6345 | if (binfo->peer->as == binfo->peer->local_as) |
| 6346 | vty_out (vty, ", internal"); |
| 6347 | else |
| 6348 | vty_out (vty, ", %s", |
| 6349 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6350 | } |
| 6351 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6352 | vty_out (vty, ", aggregated, local"); |
| 6353 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6354 | vty_out (vty, ", sourced"); |
| 6355 | else |
| 6356 | vty_out (vty, ", sourced, local"); |
| 6357 | |
| 6358 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6359 | vty_out (vty, ", atomic-aggregate"); |
| 6360 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6361 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6362 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6363 | bgp_info_mpath_count (binfo))) |
| 6364 | vty_out (vty, ", multipath"); |
| 6365 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6366 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6367 | vty_out (vty, ", best"); |
| 6368 | |
| 6369 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6370 | |
| 6371 | /* Line 4 display Community */ |
| 6372 | if (attr->community) |
| 6373 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6374 | VTY_NEWLINE); |
| 6375 | |
| 6376 | /* Line 5 display Extended-community */ |
| 6377 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6378 | vty_out (vty, " Extended Community: %s%s", |
| 6379 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6380 | |
| 6381 | /* Line 6 display Originator, Cluster-id */ |
| 6382 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6383 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6384 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6385 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6386 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6387 | vty_out (vty, " Originator: %s", |
| 6388 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6389 | |
| 6390 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6391 | { |
| 6392 | int i; |
| 6393 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6394 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6395 | vty_out (vty, "%s ", |
| 6396 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6397 | } |
| 6398 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6399 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6400 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6401 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6402 | bgp_damp_info_vty (vty, binfo); |
| 6403 | |
| 6404 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6405 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6406 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6407 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6408 | #else |
| 6409 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6410 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6411 | } |
| 6412 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6413 | } |
| 6414 | |
| 6415 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6416 | "h history, * valid, > best, = multipath,%s"\ |
| 6417 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6418 | #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] | 6419 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6420 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6421 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6422 | |
| 6423 | enum bgp_show_type |
| 6424 | { |
| 6425 | bgp_show_type_normal, |
| 6426 | bgp_show_type_regexp, |
| 6427 | bgp_show_type_prefix_list, |
| 6428 | bgp_show_type_filter_list, |
| 6429 | bgp_show_type_route_map, |
| 6430 | bgp_show_type_neighbor, |
| 6431 | bgp_show_type_cidr_only, |
| 6432 | bgp_show_type_prefix_longer, |
| 6433 | bgp_show_type_community_all, |
| 6434 | bgp_show_type_community, |
| 6435 | bgp_show_type_community_exact, |
| 6436 | bgp_show_type_community_list, |
| 6437 | bgp_show_type_community_list_exact, |
| 6438 | bgp_show_type_flap_statistics, |
| 6439 | bgp_show_type_flap_address, |
| 6440 | bgp_show_type_flap_prefix, |
| 6441 | bgp_show_type_flap_cidr_only, |
| 6442 | bgp_show_type_flap_regexp, |
| 6443 | bgp_show_type_flap_filter_list, |
| 6444 | bgp_show_type_flap_prefix_list, |
| 6445 | bgp_show_type_flap_prefix_longer, |
| 6446 | bgp_show_type_flap_route_map, |
| 6447 | bgp_show_type_flap_neighbor, |
| 6448 | bgp_show_type_dampend_paths, |
| 6449 | bgp_show_type_damp_neighbor |
| 6450 | }; |
| 6451 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6452 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6453 | 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] | 6454 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6455 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6456 | struct bgp_info *ri; |
| 6457 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6458 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6459 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6460 | unsigned long output_count; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6461 | unsigned long total_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6462 | |
| 6463 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6464 | output_count = 0; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6465 | total_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6466 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6467 | /* Start processing of routes. */ |
| 6468 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6469 | if (rn->info != NULL) |
| 6470 | { |
| 6471 | display = 0; |
| 6472 | |
| 6473 | for (ri = rn->info; ri; ri = ri->next) |
| 6474 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6475 | total_count++; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6476 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6477 | || type == bgp_show_type_flap_address |
| 6478 | || type == bgp_show_type_flap_prefix |
| 6479 | || type == bgp_show_type_flap_cidr_only |
| 6480 | || type == bgp_show_type_flap_regexp |
| 6481 | || type == bgp_show_type_flap_filter_list |
| 6482 | || type == bgp_show_type_flap_prefix_list |
| 6483 | || type == bgp_show_type_flap_prefix_longer |
| 6484 | || type == bgp_show_type_flap_route_map |
| 6485 | || type == bgp_show_type_flap_neighbor |
| 6486 | || type == bgp_show_type_dampend_paths |
| 6487 | || type == bgp_show_type_damp_neighbor) |
| 6488 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6489 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6490 | continue; |
| 6491 | } |
| 6492 | if (type == bgp_show_type_regexp |
| 6493 | || type == bgp_show_type_flap_regexp) |
| 6494 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6495 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6496 | |
| 6497 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6498 | continue; |
| 6499 | } |
| 6500 | if (type == bgp_show_type_prefix_list |
| 6501 | || type == bgp_show_type_flap_prefix_list) |
| 6502 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6503 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6504 | |
| 6505 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6506 | continue; |
| 6507 | } |
| 6508 | if (type == bgp_show_type_filter_list |
| 6509 | || type == bgp_show_type_flap_filter_list) |
| 6510 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6511 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6512 | |
| 6513 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6514 | continue; |
| 6515 | } |
| 6516 | if (type == bgp_show_type_route_map |
| 6517 | || type == bgp_show_type_flap_route_map) |
| 6518 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6519 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6520 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6521 | struct attr dummy_attr; |
| 6522 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6523 | int ret; |
| 6524 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6525 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6526 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6527 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6528 | binfo.peer = ri->peer; |
| 6529 | binfo.attr = &dummy_attr; |
| 6530 | |
| 6531 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6532 | if (ret == RMAP_DENYMATCH) |
| 6533 | continue; |
| 6534 | } |
| 6535 | if (type == bgp_show_type_neighbor |
| 6536 | || type == bgp_show_type_flap_neighbor |
| 6537 | || type == bgp_show_type_damp_neighbor) |
| 6538 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6539 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6540 | |
| 6541 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6542 | continue; |
| 6543 | } |
| 6544 | if (type == bgp_show_type_cidr_only |
| 6545 | || type == bgp_show_type_flap_cidr_only) |
| 6546 | { |
| 6547 | u_int32_t destination; |
| 6548 | |
| 6549 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6550 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6551 | continue; |
| 6552 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6553 | continue; |
| 6554 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6555 | continue; |
| 6556 | } |
| 6557 | if (type == bgp_show_type_prefix_longer |
| 6558 | || type == bgp_show_type_flap_prefix_longer) |
| 6559 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6560 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6561 | |
| 6562 | if (! prefix_match (p, &rn->p)) |
| 6563 | continue; |
| 6564 | } |
| 6565 | if (type == bgp_show_type_community_all) |
| 6566 | { |
| 6567 | if (! ri->attr->community) |
| 6568 | continue; |
| 6569 | } |
| 6570 | if (type == bgp_show_type_community) |
| 6571 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6572 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6573 | |
| 6574 | if (! ri->attr->community || |
| 6575 | ! community_match (ri->attr->community, com)) |
| 6576 | continue; |
| 6577 | } |
| 6578 | if (type == bgp_show_type_community_exact) |
| 6579 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6580 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6581 | |
| 6582 | if (! ri->attr->community || |
| 6583 | ! community_cmp (ri->attr->community, com)) |
| 6584 | continue; |
| 6585 | } |
| 6586 | if (type == bgp_show_type_community_list) |
| 6587 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6588 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6589 | |
| 6590 | if (! community_list_match (ri->attr->community, list)) |
| 6591 | continue; |
| 6592 | } |
| 6593 | if (type == bgp_show_type_community_list_exact) |
| 6594 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6595 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6596 | |
| 6597 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6598 | continue; |
| 6599 | } |
| 6600 | if (type == bgp_show_type_flap_address |
| 6601 | || type == bgp_show_type_flap_prefix) |
| 6602 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6603 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6604 | |
| 6605 | if (! prefix_match (&rn->p, p)) |
| 6606 | continue; |
| 6607 | |
| 6608 | if (type == bgp_show_type_flap_prefix) |
| 6609 | if (p->prefixlen != rn->p.prefixlen) |
| 6610 | continue; |
| 6611 | } |
| 6612 | if (type == bgp_show_type_dampend_paths |
| 6613 | || type == bgp_show_type_damp_neighbor) |
| 6614 | { |
| 6615 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6616 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6617 | continue; |
| 6618 | } |
| 6619 | |
| 6620 | if (header) |
| 6621 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6622 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6623 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6624 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6625 | if (type == bgp_show_type_dampend_paths |
| 6626 | || type == bgp_show_type_damp_neighbor) |
| 6627 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6628 | else if (type == bgp_show_type_flap_statistics |
| 6629 | || type == bgp_show_type_flap_address |
| 6630 | || type == bgp_show_type_flap_prefix |
| 6631 | || type == bgp_show_type_flap_cidr_only |
| 6632 | || type == bgp_show_type_flap_regexp |
| 6633 | || type == bgp_show_type_flap_filter_list |
| 6634 | || type == bgp_show_type_flap_prefix_list |
| 6635 | || type == bgp_show_type_flap_prefix_longer |
| 6636 | || type == bgp_show_type_flap_route_map |
| 6637 | || type == bgp_show_type_flap_neighbor) |
| 6638 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6639 | else |
| 6640 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6641 | header = 0; |
| 6642 | } |
| 6643 | |
| 6644 | if (type == bgp_show_type_dampend_paths |
| 6645 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6646 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6647 | else if (type == bgp_show_type_flap_statistics |
| 6648 | || type == bgp_show_type_flap_address |
| 6649 | || type == bgp_show_type_flap_prefix |
| 6650 | || type == bgp_show_type_flap_cidr_only |
| 6651 | || type == bgp_show_type_flap_regexp |
| 6652 | || type == bgp_show_type_flap_filter_list |
| 6653 | || type == bgp_show_type_flap_prefix_list |
| 6654 | || type == bgp_show_type_flap_prefix_longer |
| 6655 | || type == bgp_show_type_flap_route_map |
| 6656 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6657 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6658 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6659 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6660 | display++; |
| 6661 | } |
| 6662 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6663 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6664 | } |
| 6665 | |
| 6666 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6667 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6668 | { |
| 6669 | if (type == bgp_show_type_normal) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6670 | 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] | 6671 | } |
| 6672 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6673 | vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", |
| 6674 | VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6675 | |
| 6676 | return CMD_SUCCESS; |
| 6677 | } |
| 6678 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6679 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6680 | 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] | 6681 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6682 | { |
| 6683 | struct bgp_table *table; |
| 6684 | |
| 6685 | if (bgp == NULL) { |
| 6686 | bgp = bgp_get_default (); |
| 6687 | } |
| 6688 | |
| 6689 | if (bgp == NULL) |
| 6690 | { |
| 6691 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6692 | return CMD_WARNING; |
| 6693 | } |
| 6694 | |
| 6695 | |
| 6696 | table = bgp->rib[afi][safi]; |
| 6697 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6698 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6699 | } |
| 6700 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6701 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6702 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6703 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6704 | struct bgp_node *rn, |
| 6705 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6706 | { |
| 6707 | struct bgp_info *ri; |
| 6708 | struct prefix *p; |
| 6709 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6710 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6711 | char buf1[INET6_ADDRSTRLEN]; |
| 6712 | char buf2[INET6_ADDRSTRLEN]; |
| 6713 | int count = 0; |
| 6714 | int best = 0; |
| 6715 | int suppress = 0; |
| 6716 | int no_export = 0; |
| 6717 | int no_advertise = 0; |
| 6718 | int local_as = 0; |
| 6719 | int first = 0; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6720 | int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6721 | |
| 6722 | p = &rn->p; |
| 6723 | 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] | 6724 | (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6725 | printrd ? ":" : "", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6726 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6727 | p->prefixlen, VTY_NEWLINE); |
| 6728 | |
| 6729 | for (ri = rn->info; ri; ri = ri->next) |
| 6730 | { |
| 6731 | count++; |
| 6732 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6733 | { |
| 6734 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6735 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6736 | suppress = 1; |
| 6737 | if (ri->attr->community != NULL) |
| 6738 | { |
| 6739 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6740 | no_advertise = 1; |
| 6741 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6742 | no_export = 1; |
| 6743 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6744 | local_as = 1; |
| 6745 | } |
| 6746 | } |
| 6747 | } |
| 6748 | |
| 6749 | vty_out (vty, "Paths: (%d available", count); |
| 6750 | if (best) |
| 6751 | { |
| 6752 | vty_out (vty, ", best #%d", best); |
| 6753 | if (safi == SAFI_UNICAST) |
| 6754 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6755 | } |
| 6756 | else |
| 6757 | vty_out (vty, ", no best path"); |
| 6758 | if (no_advertise) |
| 6759 | vty_out (vty, ", not advertised to any peer"); |
| 6760 | else if (no_export) |
| 6761 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6762 | else if (local_as) |
| 6763 | vty_out (vty, ", not advertised outside local AS"); |
| 6764 | if (suppress) |
| 6765 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6766 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6767 | |
| 6768 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6769 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6770 | { |
| 6771 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6772 | { |
| 6773 | if (! first) |
| 6774 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6775 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6776 | first = 1; |
| 6777 | } |
| 6778 | } |
| 6779 | if (! first) |
| 6780 | vty_out (vty, " Not advertised to any peer"); |
| 6781 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6782 | } |
| 6783 | |
| 6784 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6785 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6786 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6787 | struct bgp_table *rib, const char *ip_str, |
| 6788 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6789 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6790 | { |
| 6791 | int ret; |
| 6792 | int header; |
| 6793 | int display = 0; |
| 6794 | struct prefix match; |
| 6795 | struct bgp_node *rn; |
| 6796 | struct bgp_node *rm; |
| 6797 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6798 | struct bgp_table *table; |
| 6799 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 6800 | memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6801 | /* Check IP address argument. */ |
| 6802 | ret = str2prefix (ip_str, &match); |
| 6803 | if (! ret) |
| 6804 | { |
| 6805 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6806 | return CMD_WARNING; |
| 6807 | } |
| 6808 | |
| 6809 | match.family = afi2family (afi); |
| 6810 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6811 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6812 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6813 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6814 | { |
| 6815 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6816 | continue; |
| 6817 | |
| 6818 | if ((table = rn->info) != NULL) |
| 6819 | { |
| 6820 | header = 1; |
| 6821 | |
| 6822 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6823 | { |
| 6824 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6825 | { |
| 6826 | bgp_unlock_node (rm); |
| 6827 | continue; |
| 6828 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6829 | |
| 6830 | for (ri = rm->info; ri; ri = ri->next) |
| 6831 | { |
| 6832 | if (header) |
| 6833 | { |
| 6834 | 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] | 6835 | AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6836 | |
| 6837 | header = 0; |
| 6838 | } |
| 6839 | display++; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6840 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6841 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6842 | |
| 6843 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6844 | } |
| 6845 | } |
| 6846 | } |
| 6847 | } |
| 6848 | else |
| 6849 | { |
| 6850 | header = 1; |
| 6851 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6852 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6853 | { |
| 6854 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6855 | { |
| 6856 | for (ri = rn->info; ri; ri = ri->next) |
| 6857 | { |
| 6858 | if (header) |
| 6859 | { |
| 6860 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6861 | header = 0; |
| 6862 | } |
| 6863 | display++; |
| 6864 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6865 | } |
| 6866 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6867 | |
| 6868 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6869 | } |
| 6870 | } |
| 6871 | |
| 6872 | if (! display) |
| 6873 | { |
| 6874 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6875 | return CMD_WARNING; |
| 6876 | } |
| 6877 | |
| 6878 | return CMD_SUCCESS; |
| 6879 | } |
| 6880 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6881 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6882 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6883 | 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] | 6884 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6885 | int prefix_check) |
| 6886 | { |
| 6887 | struct bgp *bgp; |
| 6888 | |
| 6889 | /* BGP structure lookup. */ |
| 6890 | if (view_name) |
| 6891 | { |
| 6892 | bgp = bgp_lookup_by_name (view_name); |
| 6893 | if (bgp == NULL) |
| 6894 | { |
| 6895 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6896 | return CMD_WARNING; |
| 6897 | } |
| 6898 | } |
| 6899 | else |
| 6900 | { |
| 6901 | bgp = bgp_get_default (); |
| 6902 | if (bgp == NULL) |
| 6903 | { |
| 6904 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6905 | return CMD_WARNING; |
| 6906 | } |
| 6907 | } |
| 6908 | |
| 6909 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6910 | afi, safi, prd, prefix_check); |
| 6911 | } |
| 6912 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6913 | /* BGP route print out function. */ |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 6914 | DEFUN (show_ip_bgp, |
| 6915 | show_ip_bgp_cmd, |
| 6916 | "show ip bgp", |
| 6917 | SHOW_STR |
| 6918 | IP_STR |
| 6919 | BGP_STR) |
| 6920 | { |
| 6921 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6922 | } |
| 6923 | |
| 6924 | DEFUN (show_ip_bgp_ipv4, |
| 6925 | show_ip_bgp_ipv4_cmd, |
| 6926 | "show ip bgp ipv4 (unicast|multicast)", |
| 6927 | SHOW_STR |
| 6928 | IP_STR |
| 6929 | BGP_STR |
| 6930 | "Address family\n" |
| 6931 | "Address Family modifier\n" |
| 6932 | "Address Family modifier\n") |
| 6933 | { |
| 6934 | if (strncmp (argv[0], "m", 1) == 0) |
| 6935 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6936 | NULL); |
| 6937 | |
| 6938 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6939 | } |
| 6940 | |
| 6941 | DEFUN (show_ip_bgp_route, |
| 6942 | show_ip_bgp_route_cmd, |
| 6943 | "show ip bgp A.B.C.D", |
| 6944 | SHOW_STR |
| 6945 | IP_STR |
| 6946 | BGP_STR |
| 6947 | "Network in the BGP routing table to display\n") |
| 6948 | { |
| 6949 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6950 | } |
| 6951 | |
| 6952 | DEFUN (show_ip_bgp_ipv4_route, |
| 6953 | show_ip_bgp_ipv4_route_cmd, |
| 6954 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6955 | SHOW_STR |
| 6956 | IP_STR |
| 6957 | BGP_STR |
| 6958 | "Address family\n" |
| 6959 | "Address Family modifier\n" |
| 6960 | "Address Family modifier\n" |
| 6961 | "Network in the BGP routing table to display\n") |
| 6962 | { |
| 6963 | if (strncmp (argv[0], "m", 1) == 0) |
| 6964 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6965 | |
| 6966 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6967 | } |
| 6968 | |
| 6969 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6970 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6971 | "show ip bgp vpnv4 all A.B.C.D", |
| 6972 | SHOW_STR |
| 6973 | IP_STR |
| 6974 | BGP_STR |
| 6975 | "Display VPNv4 NLRI specific information\n" |
| 6976 | "Display information about all VPNv4 NLRIs\n" |
| 6977 | "Network in the BGP routing table to display\n") |
| 6978 | { |
| 6979 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6980 | } |
| 6981 | |
| 6982 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6983 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6984 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6985 | SHOW_STR |
| 6986 | IP_STR |
| 6987 | BGP_STR |
| 6988 | "Display VPNv4 NLRI specific information\n" |
| 6989 | "Display information for a route distinguisher\n" |
| 6990 | "VPN Route Distinguisher\n" |
| 6991 | "Network in the BGP routing table to display\n") |
| 6992 | { |
| 6993 | int ret; |
| 6994 | struct prefix_rd prd; |
| 6995 | |
| 6996 | ret = str2prefix_rd (argv[0], &prd); |
| 6997 | if (! ret) |
| 6998 | { |
| 6999 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7000 | return CMD_WARNING; |
| 7001 | } |
| 7002 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 7003 | } |
| 7004 | |
| 7005 | DEFUN (show_ip_bgp_prefix, |
| 7006 | show_ip_bgp_prefix_cmd, |
| 7007 | "show ip bgp A.B.C.D/M", |
| 7008 | SHOW_STR |
| 7009 | IP_STR |
| 7010 | BGP_STR |
| 7011 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7012 | { |
| 7013 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 7014 | } |
| 7015 | |
| 7016 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 7017 | show_ip_bgp_ipv4_prefix_cmd, |
| 7018 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 7019 | SHOW_STR |
| 7020 | IP_STR |
| 7021 | BGP_STR |
| 7022 | "Address family\n" |
| 7023 | "Address Family modifier\n" |
| 7024 | "Address Family modifier\n" |
| 7025 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7026 | { |
| 7027 | if (strncmp (argv[0], "m", 1) == 0) |
| 7028 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 7029 | |
| 7030 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 7031 | } |
| 7032 | |
| 7033 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 7034 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 7035 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 7036 | SHOW_STR |
| 7037 | IP_STR |
| 7038 | BGP_STR |
| 7039 | "Display VPNv4 NLRI specific information\n" |
| 7040 | "Display information about all VPNv4 NLRIs\n" |
| 7041 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7042 | { |
| 7043 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 7044 | } |
| 7045 | |
| 7046 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 7047 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 7048 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7049 | SHOW_STR |
| 7050 | IP_STR |
| 7051 | BGP_STR |
| 7052 | "Display VPNv4 NLRI specific information\n" |
| 7053 | "Display information for a route distinguisher\n" |
| 7054 | "VPN Route Distinguisher\n" |
| 7055 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7056 | { |
| 7057 | int ret; |
| 7058 | struct prefix_rd prd; |
| 7059 | |
| 7060 | ret = str2prefix_rd (argv[0], &prd); |
| 7061 | if (! ret) |
| 7062 | { |
| 7063 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7064 | return CMD_WARNING; |
| 7065 | } |
| 7066 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 7067 | } |
| 7068 | |
| 7069 | DEFUN (show_ip_bgp_view, |
| 7070 | show_ip_bgp_view_cmd, |
| 7071 | "show ip bgp view WORD", |
| 7072 | SHOW_STR |
| 7073 | IP_STR |
| 7074 | BGP_STR |
| 7075 | "BGP view\n" |
| 7076 | "View name\n") |
| 7077 | { |
| 7078 | struct bgp *bgp; |
| 7079 | |
| 7080 | /* BGP structure lookup. */ |
| 7081 | bgp = bgp_lookup_by_name (argv[0]); |
| 7082 | if (bgp == NULL) |
| 7083 | { |
| 7084 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7085 | return CMD_WARNING; |
| 7086 | } |
| 7087 | |
| 7088 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7089 | } |
| 7090 | |
| 7091 | DEFUN (show_ip_bgp_view_route, |
| 7092 | show_ip_bgp_view_route_cmd, |
| 7093 | "show ip bgp view WORD A.B.C.D", |
| 7094 | SHOW_STR |
| 7095 | IP_STR |
| 7096 | BGP_STR |
| 7097 | "BGP view\n" |
| 7098 | "View name\n" |
| 7099 | "Network in the BGP routing table to display\n") |
| 7100 | { |
| 7101 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 7102 | } |
| 7103 | |
| 7104 | DEFUN (show_ip_bgp_view_prefix, |
| 7105 | show_ip_bgp_view_prefix_cmd, |
| 7106 | "show ip bgp view WORD A.B.C.D/M", |
| 7107 | SHOW_STR |
| 7108 | IP_STR |
| 7109 | BGP_STR |
| 7110 | "BGP view\n" |
| 7111 | "View name\n" |
| 7112 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7113 | { |
| 7114 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 7115 | } |
| 7116 | |
| 7117 | DEFUN (show_bgp, |
| 7118 | show_bgp_cmd, |
| 7119 | "show bgp", |
| 7120 | SHOW_STR |
| 7121 | BGP_STR) |
| 7122 | { |
| 7123 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7124 | NULL); |
| 7125 | } |
| 7126 | |
| 7127 | ALIAS (show_bgp, |
| 7128 | show_bgp_ipv6_cmd, |
| 7129 | "show bgp ipv6", |
| 7130 | SHOW_STR |
| 7131 | BGP_STR |
| 7132 | "Address family\n") |
| 7133 | |
| 7134 | /* old command */ |
| 7135 | DEFUN (show_ipv6_bgp, |
| 7136 | show_ipv6_bgp_cmd, |
| 7137 | "show ipv6 bgp", |
| 7138 | SHOW_STR |
| 7139 | IP_STR |
| 7140 | BGP_STR) |
| 7141 | { |
| 7142 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7143 | NULL); |
| 7144 | } |
| 7145 | |
| 7146 | DEFUN (show_bgp_route, |
| 7147 | show_bgp_route_cmd, |
| 7148 | "show bgp X:X::X:X", |
| 7149 | SHOW_STR |
| 7150 | BGP_STR |
| 7151 | "Network in the BGP routing table to display\n") |
| 7152 | { |
| 7153 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7154 | } |
| 7155 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7156 | DEFUN (show_bgp_ipv4_safi, |
| 7157 | show_bgp_ipv4_safi_cmd, |
| 7158 | "show bgp ipv4 (unicast|multicast)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7159 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7160 | BGP_STR |
| 7161 | "Address family\n" |
| 7162 | "Address Family modifier\n" |
| 7163 | "Address Family modifier\n") |
| 7164 | { |
| 7165 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7166 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 7167 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7168 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7169 | 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] | 7170 | } |
| 7171 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7172 | DEFUN (show_bgp_ipv4_safi_route, |
| 7173 | show_bgp_ipv4_safi_route_cmd, |
| 7174 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7175 | SHOW_STR |
| 7176 | BGP_STR |
| 7177 | "Address family\n" |
| 7178 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7179 | "Address Family modifier\n" |
| 7180 | "Network in the BGP routing table to display\n") |
| 7181 | { |
| 7182 | if (strncmp (argv[0], "m", 1) == 0) |
| 7183 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 7184 | |
| 7185 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 7186 | } |
| 7187 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7188 | DEFUN (show_bgp_ipv4_vpn_route, |
| 7189 | show_bgp_ipv4_vpn_route_cmd, |
| 7190 | "show bgp ipv4 vpn A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7191 | SHOW_STR |
| 7192 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7193 | "Address Family\n" |
| 7194 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7195 | "Network in the BGP routing table to display\n") |
| 7196 | { |
| 7197 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 7198 | } |
| 7199 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7200 | DEFUN (show_bgp_ipv6_vpn_route, |
| 7201 | show_bgp_ipv6_vpn_route_cmd, |
| 7202 | "show bgp ipv6 vpn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7203 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7204 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7205 | "Address Family\n" |
| 7206 | "Display VPN NLRI specific information\n" |
| 7207 | "Network in the BGP routing table to display\n") |
| 7208 | { |
| 7209 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0); |
| 7210 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7211 | |
| 7212 | DEFUN (show_bgp_ipv4_vpn_rd_route, |
| 7213 | show_bgp_ipv4_vpn_rd_route_cmd, |
| 7214 | "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7215 | SHOW_STR |
| 7216 | BGP_STR |
| 7217 | IP_STR |
| 7218 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7219 | "Display information for a route distinguisher\n" |
| 7220 | "VPN Route Distinguisher\n" |
| 7221 | "Network in the BGP routing table to display\n") |
| 7222 | { |
| 7223 | int ret; |
| 7224 | struct prefix_rd prd; |
| 7225 | |
| 7226 | ret = str2prefix_rd (argv[0], &prd); |
| 7227 | if (! ret) |
| 7228 | { |
| 7229 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7230 | return CMD_WARNING; |
| 7231 | } |
| 7232 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 7233 | } |
| 7234 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7235 | DEFUN (show_bgp_ipv6_vpn_rd_route, |
| 7236 | show_bgp_ipv6_vpn_rd_route_cmd, |
| 7237 | "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] | 7238 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7239 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7240 | "Address Family\n" |
| 7241 | "Display VPN NLRI specific information\n" |
| 7242 | "Display information for a route distinguisher\n" |
| 7243 | "VPN Route Distinguisher\n" |
| 7244 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7245 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7246 | int ret; |
| 7247 | struct prefix_rd prd; |
| 7248 | |
| 7249 | ret = str2prefix_rd (argv[0], &prd); |
| 7250 | if (! ret) |
| 7251 | { |
| 7252 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7253 | return CMD_WARNING; |
| 7254 | } |
| 7255 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7256 | } |
| 7257 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7258 | DEFUN (show_bgp_ipv4_encap_route, |
| 7259 | show_bgp_ipv4_encap_route_cmd, |
| 7260 | "show bgp ipv4 encap A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7261 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7262 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7263 | IP_STR |
| 7264 | "Display ENCAP NLRI specific information\n" |
| 7265 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7266 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7267 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7268 | } |
| 7269 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7270 | DEFUN (show_bgp_ipv6_encap_route, |
| 7271 | show_bgp_ipv6_encap_route_cmd, |
| 7272 | "show bgp ipv6 encap X:X::X:X", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7273 | SHOW_STR |
| 7274 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7275 | IP6_STR |
| 7276 | "Display ENCAP NLRI specific information\n" |
| 7277 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7278 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7279 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7280 | } |
| 7281 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7282 | DEFUN (show_bgp_ipv4_safi_rd_route, |
| 7283 | show_bgp_ipv4_safi_rd_route_cmd, |
| 7284 | "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] | 7285 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7286 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7287 | "Address Family\n" |
| 7288 | "Address Family Modifier\n" |
| 7289 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7290 | "Display information for a route distinguisher\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7291 | "ENCAP Route Distinguisher\n" |
| 7292 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7293 | { |
| 7294 | int ret; |
| 7295 | struct prefix_rd prd; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7296 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7297 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7298 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7299 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7300 | return CMD_WARNING; |
| 7301 | } |
| 7302 | ret = str2prefix_rd (argv[1], &prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7303 | if (! ret) |
| 7304 | { |
| 7305 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7306 | return CMD_WARNING; |
| 7307 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7308 | return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7309 | } |
| 7310 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7311 | DEFUN (show_bgp_ipv6_safi_rd_route, |
| 7312 | show_bgp_ipv6_safi_rd_route_cmd, |
| 7313 | "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] | 7314 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7315 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7316 | "Address Family\n" |
| 7317 | "Address Family Modifier\n" |
| 7318 | "Address Family Modifier\n" |
| 7319 | "Display information for a route distinguisher\n" |
| 7320 | "ENCAP Route Distinguisher\n" |
| 7321 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7322 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7323 | int ret; |
| 7324 | struct prefix_rd prd; |
| 7325 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7326 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7327 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7328 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7329 | return CMD_WARNING; |
| 7330 | } |
| 7331 | ret = str2prefix_rd (argv[1], &prd); |
| 7332 | if (! ret) |
| 7333 | { |
| 7334 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7335 | return CMD_WARNING; |
| 7336 | } |
| 7337 | return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7338 | } |
| 7339 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7340 | DEFUN (show_bgp_ipv4_prefix, |
| 7341 | show_bgp_ipv4_prefix_cmd, |
| 7342 | "show bgp ipv4 A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7343 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7344 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7345 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7346 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7347 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7348 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7349 | } |
| 7350 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7351 | DEFUN (show_bgp_ipv4_safi_prefix, |
| 7352 | show_bgp_ipv4_safi_prefix_cmd, |
| 7353 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7354 | SHOW_STR |
| 7355 | BGP_STR |
| 7356 | "Address family\n" |
| 7357 | "Address Family modifier\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7358 | "Address Family modifier\n" |
| 7359 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7360 | { |
| 7361 | if (strncmp (argv[0], "m", 1) == 0) |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7362 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7363 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7364 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7365 | } |
| 7366 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7367 | DEFUN (show_bgp_ipv4_vpn_prefix, |
| 7368 | show_bgp_ipv4_vpn_prefix_cmd, |
| 7369 | "show bgp ipv4 vpn A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7370 | SHOW_STR |
| 7371 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7372 | IP_STR |
| 7373 | "Display VPN NLRI specific information\n" |
| 7374 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7375 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7376 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7377 | } |
| 7378 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7379 | DEFUN (show_bgp_ipv6_vpn_prefix, |
| 7380 | show_bgp_ipv6_vpn_prefix_cmd, |
| 7381 | "show bgp ipv6 vpn X:X::X:X/M", |
| 7382 | SHOW_STR |
| 7383 | BGP_STR |
| 7384 | "Address Family\n" |
| 7385 | "Display VPN NLRI specific information\n" |
| 7386 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7387 | { |
| 7388 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1); |
| 7389 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7390 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7391 | DEFUN (show_bgp_ipv4_encap_prefix, |
| 7392 | show_bgp_ipv4_encap_prefix_cmd, |
| 7393 | "show bgp ipv4 encap A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7394 | SHOW_STR |
| 7395 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7396 | IP_STR |
| 7397 | "Display ENCAP NLRI specific information\n" |
| 7398 | "Display information about ENCAP NLRIs\n" |
| 7399 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7400 | { |
| 7401 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1); |
| 7402 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7403 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7404 | DEFUN (show_bgp_ipv6_encap_prefix, |
| 7405 | show_bgp_ipv6_encap_prefix_cmd, |
| 7406 | "show bgp ipv6 encap X:X::X:X/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7407 | SHOW_STR |
| 7408 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7409 | IP_STR |
| 7410 | "Display ENCAP NLRI specific information\n" |
| 7411 | "Display information about ENCAP NLRIs\n" |
| 7412 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7413 | { |
| 7414 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1); |
| 7415 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7416 | |
| 7417 | DEFUN (show_bgp_ipv4_safi_rd_prefix, |
| 7418 | show_bgp_ipv4_safi_rd_prefix_cmd, |
| 7419 | "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7420 | SHOW_STR |
| 7421 | BGP_STR |
| 7422 | "Address Family\n" |
| 7423 | "Address Family Modifier\n" |
| 7424 | "Address Family Modifier\n" |
| 7425 | "Display information for a route distinguisher\n" |
| 7426 | "ENCAP Route Distinguisher\n" |
| 7427 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7428 | { |
| 7429 | int ret; |
| 7430 | struct prefix_rd prd; |
| 7431 | safi_t safi; |
| 7432 | |
| 7433 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7434 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7435 | return CMD_WARNING; |
| 7436 | } |
| 7437 | |
| 7438 | ret = str2prefix_rd (argv[1], &prd); |
| 7439 | if (! ret) |
| 7440 | { |
| 7441 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7442 | return CMD_WARNING; |
| 7443 | } |
| 7444 | return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1); |
| 7445 | } |
| 7446 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7447 | DEFUN (show_bgp_ipv6_safi_rd_prefix, |
| 7448 | show_bgp_ipv6_safi_rd_prefix_cmd, |
| 7449 | "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M", |
| 7450 | SHOW_STR |
| 7451 | BGP_STR |
| 7452 | "Address Family\n" |
| 7453 | "Address Family Modifier\n" |
| 7454 | "Address Family Modifier\n" |
| 7455 | "Display information for a route distinguisher\n" |
| 7456 | "ENCAP Route Distinguisher\n" |
| 7457 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7458 | { |
| 7459 | int ret; |
| 7460 | struct prefix_rd prd; |
| 7461 | safi_t safi; |
| 7462 | |
| 7463 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7464 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7465 | return CMD_WARNING; |
| 7466 | } |
| 7467 | |
| 7468 | ret = str2prefix_rd (argv[1], &prd); |
| 7469 | if (! ret) |
| 7470 | { |
| 7471 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7472 | return CMD_WARNING; |
| 7473 | } |
| 7474 | return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1); |
| 7475 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7476 | |
| 7477 | DEFUN (show_bgp_afi_safi_view, |
| 7478 | show_bgp_afi_safi_view_cmd, |
| 7479 | "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)", |
| 7480 | SHOW_STR |
| 7481 | BGP_STR |
| 7482 | "BGP view\n" |
| 7483 | "BGP view name\n" |
| 7484 | "Address Family\n" |
| 7485 | "Address Family\n" |
| 7486 | "Address Family Modifier\n" |
| 7487 | "Address Family Modifier\n" |
| 7488 | "Address Family Modifier\n" |
| 7489 | "Address Family Modifier\n" |
| 7490 | ) |
| 7491 | { |
| 7492 | struct bgp *bgp; |
| 7493 | safi_t safi; |
| 7494 | afi_t afi; |
| 7495 | |
| 7496 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7497 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7498 | return CMD_WARNING; |
| 7499 | } |
| 7500 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7501 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7502 | return CMD_WARNING; |
| 7503 | } |
| 7504 | |
| 7505 | /* BGP structure lookup. */ |
| 7506 | bgp = bgp_lookup_by_name (argv[0]); |
| 7507 | if (bgp == NULL) |
| 7508 | { |
| 7509 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7510 | return CMD_WARNING; |
| 7511 | } |
| 7512 | |
| 7513 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL); |
| 7514 | } |
| 7515 | |
| 7516 | DEFUN (show_bgp_view_afi_safi_route, |
| 7517 | show_bgp_view_afi_safi_route_cmd, |
| 7518 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D", |
| 7519 | SHOW_STR |
| 7520 | BGP_STR |
| 7521 | "BGP view\n" |
| 7522 | "View name\n" |
| 7523 | "Address Family\n" |
| 7524 | "Address Family\n" |
| 7525 | "Address Family Modifier\n" |
| 7526 | "Address Family Modifier\n" |
| 7527 | "Address Family Modifier\n" |
| 7528 | "Address Family Modifier\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7529 | "Network in the BGP routing table to display\n") |
| 7530 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7531 | safi_t safi; |
| 7532 | afi_t afi; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7533 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7534 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7535 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7536 | return CMD_WARNING; |
| 7537 | } |
| 7538 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7539 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7540 | return CMD_WARNING; |
| 7541 | } |
| 7542 | return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0); |
| 7543 | } |
| 7544 | |
| 7545 | DEFUN (show_bgp_view_afi_safi_prefix, |
| 7546 | show_bgp_view_afi_safi_prefix_cmd, |
| 7547 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M", |
| 7548 | SHOW_STR |
| 7549 | BGP_STR |
| 7550 | "BGP view\n" |
| 7551 | "View name\n" |
| 7552 | "Address Family\n" |
| 7553 | "Address Family\n" |
| 7554 | "Address Family Modifier\n" |
| 7555 | "Address Family Modifier\n" |
| 7556 | "Address Family Modifier\n" |
| 7557 | "Address Family Modifier\n" |
| 7558 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7559 | { |
| 7560 | safi_t safi; |
| 7561 | afi_t afi; |
| 7562 | |
| 7563 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7564 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7565 | return CMD_WARNING; |
| 7566 | } |
| 7567 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7568 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7569 | return CMD_WARNING; |
| 7570 | } |
| 7571 | return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1); |
| 7572 | } |
| 7573 | |
| 7574 | /* new001 */ |
| 7575 | DEFUN (show_bgp_afi, |
| 7576 | show_bgp_afi_cmd, |
| 7577 | "show bgp (ipv4|ipv6)", |
| 7578 | SHOW_STR |
| 7579 | BGP_STR |
| 7580 | "Address family\n" |
| 7581 | "Address family\n") |
| 7582 | { |
| 7583 | afi_t afi; |
| 7584 | |
| 7585 | if (bgp_parse_afi(argv[0], &afi)) { |
| 7586 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7587 | return CMD_WARNING; |
| 7588 | } |
| 7589 | return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal, |
| 7590 | NULL); |
| 7591 | } |
| 7592 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7593 | DEFUN (show_bgp_ipv6_safi, |
| 7594 | show_bgp_ipv6_safi_cmd, |
| 7595 | "show bgp ipv6 (unicast|multicast)", |
| 7596 | SHOW_STR |
| 7597 | BGP_STR |
| 7598 | "Address family\n" |
| 7599 | "Address Family modifier\n" |
| 7600 | "Address Family modifier\n") |
| 7601 | { |
| 7602 | if (strncmp (argv[0], "m", 1) == 0) |
| 7603 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7604 | NULL); |
| 7605 | |
| 7606 | 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] | 7607 | } |
| 7608 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7609 | DEFUN (show_bgp_ipv6_route, |
| 7610 | show_bgp_ipv6_route_cmd, |
| 7611 | "show bgp ipv6 X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7612 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7613 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7614 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7615 | "Network in the BGP routing table to display\n") |
| 7616 | { |
| 7617 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7618 | } |
| 7619 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7620 | DEFUN (show_bgp_ipv6_safi_route, |
| 7621 | show_bgp_ipv6_safi_route_cmd, |
| 7622 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7623 | SHOW_STR |
| 7624 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7625 | "Address family\n" |
| 7626 | "Address Family modifier\n" |
| 7627 | "Address Family modifier\n" |
| 7628 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7629 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7630 | if (strncmp (argv[0], "m", 1) == 0) |
| 7631 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7632 | |
| 7633 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7634 | } |
| 7635 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7636 | /* old command */ |
| 7637 | DEFUN (show_ipv6_bgp_route, |
| 7638 | show_ipv6_bgp_route_cmd, |
| 7639 | "show ipv6 bgp X:X::X:X", |
| 7640 | SHOW_STR |
| 7641 | IP_STR |
| 7642 | BGP_STR |
| 7643 | "Network in the BGP routing table to display\n") |
| 7644 | { |
| 7645 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7646 | } |
| 7647 | |
| 7648 | DEFUN (show_bgp_prefix, |
| 7649 | show_bgp_prefix_cmd, |
| 7650 | "show bgp X:X::X:X/M", |
| 7651 | SHOW_STR |
| 7652 | BGP_STR |
| 7653 | "IPv6 prefix <network>/<length>\n") |
| 7654 | { |
| 7655 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7656 | } |
| 7657 | |
| 7658 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7659 | /* new002 */ |
| 7660 | DEFUN (show_bgp_ipv6_prefix, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7661 | show_bgp_ipv6_prefix_cmd, |
| 7662 | "show bgp ipv6 X:X::X:X/M", |
| 7663 | SHOW_STR |
| 7664 | BGP_STR |
| 7665 | "Address family\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7666 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7667 | { |
| 7668 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7669 | } |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7670 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 7671 | show_bgp_ipv6_safi_prefix_cmd, |
| 7672 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 7673 | SHOW_STR |
| 7674 | BGP_STR |
| 7675 | "Address family\n" |
| 7676 | "Address Family modifier\n" |
| 7677 | "Address Family modifier\n" |
| 7678 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7679 | { |
| 7680 | if (strncmp (argv[0], "m", 1) == 0) |
| 7681 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7682 | |
| 7683 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7684 | } |
| 7685 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7686 | /* old command */ |
| 7687 | DEFUN (show_ipv6_bgp_prefix, |
| 7688 | show_ipv6_bgp_prefix_cmd, |
| 7689 | "show ipv6 bgp X:X::X:X/M", |
| 7690 | SHOW_STR |
| 7691 | IP_STR |
| 7692 | BGP_STR |
| 7693 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7694 | { |
| 7695 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7696 | } |
| 7697 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7698 | DEFUN (show_bgp_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7699 | show_bgp_view_cmd, |
| 7700 | "show bgp view WORD", |
| 7701 | SHOW_STR |
| 7702 | BGP_STR |
| 7703 | "BGP view\n" |
| 7704 | "View name\n") |
| 7705 | { |
| 7706 | struct bgp *bgp; |
| 7707 | |
| 7708 | /* BGP structure lookup. */ |
| 7709 | bgp = bgp_lookup_by_name (argv[0]); |
| 7710 | if (bgp == NULL) |
| 7711 | { |
| 7712 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7713 | return CMD_WARNING; |
| 7714 | } |
| 7715 | |
| 7716 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7717 | } |
| 7718 | |
| 7719 | DEFUN (show_bgp_view_ipv6, |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7720 | show_bgp_view_ipv6_cmd, |
| 7721 | "show bgp view WORD ipv6", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7722 | SHOW_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7723 | BGP_STR |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7724 | "BGP view\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7725 | "View name\n" |
| 7726 | "Address family\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7727 | { |
| 7728 | struct bgp *bgp; |
| 7729 | |
| 7730 | /* BGP structure lookup. */ |
| 7731 | bgp = bgp_lookup_by_name (argv[0]); |
| 7732 | if (bgp == NULL) |
| 7733 | { |
| 7734 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7735 | return CMD_WARNING; |
| 7736 | } |
| 7737 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7738 | 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] | 7739 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7740 | |
| 7741 | DEFUN (show_bgp_view_route, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7742 | show_bgp_view_route_cmd, |
| 7743 | "show bgp view WORD X:X::X:X", |
| 7744 | SHOW_STR |
| 7745 | BGP_STR |
| 7746 | "BGP view\n" |
| 7747 | "View name\n" |
| 7748 | "Network in the BGP routing table to display\n") |
| 7749 | { |
| 7750 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7751 | } |
| 7752 | |
| 7753 | DEFUN (show_bgp_view_ipv6_route, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7754 | show_bgp_view_ipv6_route_cmd, |
| 7755 | "show bgp view WORD ipv6 X:X::X:X", |
| 7756 | SHOW_STR |
| 7757 | BGP_STR |
| 7758 | "BGP view\n" |
| 7759 | "View name\n" |
| 7760 | "Address family\n" |
| 7761 | "Network in the BGP routing table to display\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7762 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7763 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7764 | } |
| 7765 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7766 | /* old command */ |
| 7767 | DEFUN (show_ipv6_mbgp, |
| 7768 | show_ipv6_mbgp_cmd, |
| 7769 | "show ipv6 mbgp", |
| 7770 | SHOW_STR |
| 7771 | IP_STR |
| 7772 | MBGP_STR) |
| 7773 | { |
| 7774 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7775 | NULL); |
| 7776 | } |
| 7777 | |
| 7778 | /* old command */ |
| 7779 | DEFUN (show_ipv6_mbgp_route, |
| 7780 | show_ipv6_mbgp_route_cmd, |
| 7781 | "show ipv6 mbgp X:X::X:X", |
| 7782 | SHOW_STR |
| 7783 | IP_STR |
| 7784 | MBGP_STR |
| 7785 | "Network in the MBGP routing table to display\n") |
| 7786 | { |
| 7787 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7788 | } |
| 7789 | |
| 7790 | /* old command */ |
| 7791 | DEFUN (show_ipv6_mbgp_prefix, |
| 7792 | show_ipv6_mbgp_prefix_cmd, |
| 7793 | "show ipv6 mbgp X:X::X:X/M", |
| 7794 | SHOW_STR |
| 7795 | IP_STR |
| 7796 | MBGP_STR |
| 7797 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7798 | { |
| 7799 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7800 | } |
| 7801 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7802 | DEFUN (show_bgp_view_prefix, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7803 | show_bgp_view_prefix_cmd, |
| 7804 | "show bgp view WORD X:X::X:X/M", |
| 7805 | SHOW_STR |
| 7806 | BGP_STR |
| 7807 | "BGP view\n" |
| 7808 | "View name\n" |
| 7809 | "IPv6 prefix <network>/<length>\n") |
| 7810 | { |
| 7811 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7812 | } |
| 7813 | |
| 7814 | DEFUN (show_bgp_view_ipv6_prefix, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7815 | show_bgp_view_ipv6_prefix_cmd, |
| 7816 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7817 | SHOW_STR |
| 7818 | BGP_STR |
| 7819 | "BGP view\n" |
| 7820 | "View name\n" |
| 7821 | "Address family\n" |
| 7822 | "IPv6 prefix <network>/<length>\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7823 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7824 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7825 | } |
| 7826 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7827 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7828 | 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] | 7829 | safi_t safi, enum bgp_show_type type) |
| 7830 | { |
| 7831 | int i; |
| 7832 | struct buffer *b; |
| 7833 | char *regstr; |
| 7834 | int first; |
| 7835 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7836 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7837 | |
| 7838 | first = 0; |
| 7839 | b = buffer_new (1024); |
| 7840 | for (i = 0; i < argc; i++) |
| 7841 | { |
| 7842 | if (first) |
| 7843 | buffer_putc (b, ' '); |
| 7844 | else |
| 7845 | { |
| 7846 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7847 | continue; |
| 7848 | first = 1; |
| 7849 | } |
| 7850 | |
| 7851 | buffer_putstr (b, argv[i]); |
| 7852 | } |
| 7853 | buffer_putc (b, '\0'); |
| 7854 | |
| 7855 | regstr = buffer_getstr (b); |
| 7856 | buffer_free (b); |
| 7857 | |
| 7858 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7859 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7860 | if (! regex) |
| 7861 | { |
| 7862 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7863 | VTY_NEWLINE); |
| 7864 | return CMD_WARNING; |
| 7865 | } |
| 7866 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7867 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7868 | bgp_regex_free (regex); |
| 7869 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7870 | } |
| 7871 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7872 | |
| 7873 | DEFUN (show_ip_bgp_regexp, |
| 7874 | show_ip_bgp_regexp_cmd, |
| 7875 | "show ip bgp regexp .LINE", |
| 7876 | SHOW_STR |
| 7877 | IP_STR |
| 7878 | BGP_STR |
| 7879 | "Display routes matching the AS path regular expression\n" |
| 7880 | "A regular-expression to match the BGP AS paths\n") |
| 7881 | { |
| 7882 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7883 | bgp_show_type_regexp); |
| 7884 | } |
| 7885 | |
| 7886 | DEFUN (show_ip_bgp_flap_regexp, |
| 7887 | show_ip_bgp_flap_regexp_cmd, |
| 7888 | "show ip bgp flap-statistics regexp .LINE", |
| 7889 | SHOW_STR |
| 7890 | IP_STR |
| 7891 | BGP_STR |
| 7892 | "Display flap statistics of routes\n" |
| 7893 | "Display routes matching the AS path regular expression\n" |
| 7894 | "A regular-expression to match the BGP AS paths\n") |
| 7895 | { |
| 7896 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7897 | bgp_show_type_flap_regexp); |
| 7898 | } |
| 7899 | |
| 7900 | ALIAS (show_ip_bgp_flap_regexp, |
| 7901 | show_ip_bgp_damp_flap_regexp_cmd, |
| 7902 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 7903 | SHOW_STR |
| 7904 | IP_STR |
| 7905 | BGP_STR |
| 7906 | "Display detailed information about dampening\n" |
| 7907 | "Display flap statistics of routes\n" |
| 7908 | "Display routes matching the AS path regular expression\n" |
| 7909 | "A regular-expression to match the BGP AS paths\n") |
| 7910 | |
| 7911 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7912 | show_ip_bgp_ipv4_regexp_cmd, |
| 7913 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7914 | SHOW_STR |
| 7915 | IP_STR |
| 7916 | BGP_STR |
| 7917 | "Address family\n" |
| 7918 | "Address Family modifier\n" |
| 7919 | "Address Family modifier\n" |
| 7920 | "Display routes matching the AS path regular expression\n" |
| 7921 | "A regular-expression to match the BGP AS paths\n") |
| 7922 | { |
| 7923 | if (strncmp (argv[0], "m", 1) == 0) |
| 7924 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7925 | bgp_show_type_regexp); |
| 7926 | |
| 7927 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7928 | bgp_show_type_regexp); |
| 7929 | } |
| 7930 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7931 | DEFUN (show_bgp_regexp, |
| 7932 | show_bgp_regexp_cmd, |
| 7933 | "show bgp regexp .LINE", |
| 7934 | SHOW_STR |
| 7935 | BGP_STR |
| 7936 | "Display routes matching the AS path regular expression\n" |
| 7937 | "A regular-expression to match the BGP AS paths\n") |
| 7938 | { |
| 7939 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7940 | bgp_show_type_regexp); |
| 7941 | } |
| 7942 | |
| 7943 | /* old command */ |
| 7944 | DEFUN (show_ipv6_bgp_regexp, |
| 7945 | show_ipv6_bgp_regexp_cmd, |
| 7946 | "show ipv6 bgp regexp .LINE", |
| 7947 | SHOW_STR |
| 7948 | IP_STR |
| 7949 | BGP_STR |
| 7950 | "Display routes matching the AS path regular expression\n" |
| 7951 | "A regular-expression to match the BGP AS paths\n") |
| 7952 | { |
| 7953 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7954 | bgp_show_type_regexp); |
| 7955 | } |
| 7956 | |
| 7957 | /* old command */ |
| 7958 | DEFUN (show_ipv6_mbgp_regexp, |
| 7959 | show_ipv6_mbgp_regexp_cmd, |
| 7960 | "show ipv6 mbgp regexp .LINE", |
| 7961 | SHOW_STR |
| 7962 | IP_STR |
| 7963 | BGP_STR |
| 7964 | "Display routes matching the AS path regular expression\n" |
| 7965 | "A regular-expression to match the MBGP AS paths\n") |
| 7966 | { |
| 7967 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7968 | bgp_show_type_regexp); |
| 7969 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7970 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7971 | DEFUN (show_bgp_ipv4_safi_flap_regexp, |
| 7972 | show_bgp_ipv4_safi_flap_regexp_cmd, |
| 7973 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7974 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7975 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7976 | IP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7977 | "Address Family Modifier\n" |
| 7978 | "Address Family Modifier\n" |
| 7979 | "Address Family Modifier\n" |
| 7980 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7981 | "Display flap statistics of routes\n" |
| 7982 | "Display routes matching the AS path regular expression\n" |
| 7983 | "A regular-expression to match the BGP AS paths\n") |
| 7984 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7985 | safi_t safi; |
| 7986 | |
| 7987 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7988 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7989 | return CMD_WARNING; |
| 7990 | } |
| 7991 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
| 7992 | bgp_show_type_flap_regexp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7993 | } |
| 7994 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7995 | ALIAS (show_bgp_ipv4_safi_flap_regexp, |
| 7996 | show_bgp_ipv4_safi_damp_flap_regexp_cmd, |
| 7997 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7998 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7999 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8000 | IP_STR |
| 8001 | "Address Family Modifier\n" |
| 8002 | "Address Family Modifier\n" |
| 8003 | "Address Family Modifier\n" |
| 8004 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8005 | "Display detailed information about dampening\n" |
| 8006 | "Display flap statistics of routes\n" |
| 8007 | "Display routes matching the AS path regular expression\n" |
| 8008 | "A regular-expression to match the BGP AS paths\n") |
| 8009 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8010 | DEFUN (show_bgp_ipv6_safi_flap_regexp, |
| 8011 | show_bgp_ipv6_safi_flap_regexp_cmd, |
| 8012 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8013 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8014 | BGP_STR |
| 8015 | IPV6_STR |
| 8016 | "Address Family Modifier\n" |
| 8017 | "Address Family Modifier\n" |
| 8018 | "Address Family Modifier\n" |
| 8019 | "Address Family Modifier\n" |
| 8020 | "Display flap statistics of routes\n" |
| 8021 | "Display routes matching the AS path regular expression\n" |
| 8022 | "A regular-expression to match the BGP AS paths\n") |
| 8023 | { |
| 8024 | safi_t safi; |
| 8025 | |
| 8026 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8027 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 8028 | return CMD_WARNING; |
| 8029 | } |
| 8030 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
| 8031 | bgp_show_type_flap_regexp); |
| 8032 | } |
| 8033 | |
| 8034 | ALIAS (show_bgp_ipv6_safi_flap_regexp, |
| 8035 | show_bgp_ipv6_safi_damp_flap_regexp_cmd, |
| 8036 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
| 8037 | SHOW_STR |
| 8038 | BGP_STR |
| 8039 | IPV6_STR |
| 8040 | "Address Family Modifier\n" |
| 8041 | "Address Family Modifier\n" |
| 8042 | "Address Family Modifier\n" |
| 8043 | "Address Family Modifier\n" |
| 8044 | "Display detailed information about dampening\n" |
| 8045 | "Display flap statistics of routes\n" |
| 8046 | "Display routes matching the AS path regular expression\n" |
| 8047 | "A regular-expression to match the BGP AS paths\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8048 | |
| 8049 | DEFUN (show_bgp_ipv4_safi_regexp, |
| 8050 | show_bgp_ipv4_safi_regexp_cmd, |
| 8051 | "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE", |
| 8052 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8053 | BGP_STR |
| 8054 | "Address family\n" |
| 8055 | "Address Family modifier\n" |
| 8056 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8057 | "Address Family modifier\n" |
| 8058 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8059 | "Display routes matching the AS path regular expression\n" |
| 8060 | "A regular-expression to match the BGP AS paths\n") |
| 8061 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8062 | safi_t safi; |
| 8063 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8064 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8065 | return CMD_WARNING; |
| 8066 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8067 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8068 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8069 | bgp_show_type_regexp); |
| 8070 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8071 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8072 | DEFUN (show_bgp_ipv6_safi_regexp, |
| 8073 | show_bgp_ipv6_safi_regexp_cmd, |
| 8074 | "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8075 | SHOW_STR |
| 8076 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8077 | "Address family\n" |
| 8078 | "Address Family modifier\n" |
| 8079 | "Address Family modifier\n" |
| 8080 | "Address Family modifier\n" |
| 8081 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8082 | "Display routes matching the AS path regular expression\n" |
| 8083 | "A regular-expression to match the BGP AS paths\n") |
| 8084 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8085 | safi_t safi; |
| 8086 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8087 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8088 | return CMD_WARNING; |
| 8089 | } |
| 8090 | |
| 8091 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8092 | bgp_show_type_regexp); |
| 8093 | } |
| 8094 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8095 | DEFUN (show_bgp_ipv6_regexp, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8096 | show_bgp_ipv6_regexp_cmd, |
| 8097 | "show bgp ipv6 regexp .LINE", |
| 8098 | SHOW_STR |
| 8099 | BGP_STR |
| 8100 | "Address family\n" |
| 8101 | "Display routes matching the AS path regular expression\n" |
| 8102 | "A regular-expression to match the BGP AS paths\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8103 | { |
| 8104 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8105 | bgp_show_type_regexp); |
| 8106 | } |
| 8107 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8108 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8109 | 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] | 8110 | safi_t safi, enum bgp_show_type type) |
| 8111 | { |
| 8112 | struct prefix_list *plist; |
| 8113 | |
| 8114 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 8115 | if (plist == NULL) |
| 8116 | { |
| 8117 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 8118 | prefix_list_str, VTY_NEWLINE); |
| 8119 | return CMD_WARNING; |
| 8120 | } |
| 8121 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8122 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8123 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8124 | DEFUN (show_ip_bgp_prefix_list, |
| 8125 | show_ip_bgp_prefix_list_cmd, |
| 8126 | "show ip bgp prefix-list WORD", |
| 8127 | SHOW_STR |
| 8128 | IP_STR |
| 8129 | BGP_STR |
| 8130 | "Display routes conforming to the prefix-list\n" |
| 8131 | "IP prefix-list name\n") |
| 8132 | { |
| 8133 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8134 | bgp_show_type_prefix_list); |
| 8135 | } |
| 8136 | |
| 8137 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 8138 | show_ip_bgp_flap_prefix_list_cmd, |
| 8139 | "show ip bgp flap-statistics prefix-list WORD", |
| 8140 | SHOW_STR |
| 8141 | IP_STR |
| 8142 | BGP_STR |
| 8143 | "Display flap statistics of routes\n" |
| 8144 | "Display routes conforming to the prefix-list\n" |
| 8145 | "IP prefix-list name\n") |
| 8146 | { |
| 8147 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8148 | bgp_show_type_flap_prefix_list); |
| 8149 | } |
| 8150 | |
| 8151 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 8152 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 8153 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 8154 | SHOW_STR |
| 8155 | IP_STR |
| 8156 | BGP_STR |
| 8157 | "Display detailed information about dampening\n" |
| 8158 | "Display flap statistics of routes\n" |
| 8159 | "Display routes conforming to the prefix-list\n" |
| 8160 | "IP prefix-list name\n") |
| 8161 | |
| 8162 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 8163 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 8164 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 8165 | SHOW_STR |
| 8166 | IP_STR |
| 8167 | BGP_STR |
| 8168 | "Address family\n" |
| 8169 | "Address Family modifier\n" |
| 8170 | "Address Family modifier\n" |
| 8171 | "Display routes conforming to the prefix-list\n" |
| 8172 | "IP prefix-list name\n") |
| 8173 | { |
| 8174 | if (strncmp (argv[0], "m", 1) == 0) |
| 8175 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8176 | bgp_show_type_prefix_list); |
| 8177 | |
| 8178 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8179 | bgp_show_type_prefix_list); |
| 8180 | } |
| 8181 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8182 | DEFUN (show_bgp_prefix_list, |
| 8183 | show_bgp_prefix_list_cmd, |
| 8184 | "show bgp prefix-list WORD", |
| 8185 | SHOW_STR |
| 8186 | BGP_STR |
| 8187 | "Display routes conforming to the prefix-list\n" |
| 8188 | "IPv6 prefix-list name\n") |
| 8189 | { |
| 8190 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8191 | bgp_show_type_prefix_list); |
| 8192 | } |
| 8193 | |
| 8194 | ALIAS (show_bgp_prefix_list, |
| 8195 | show_bgp_ipv6_prefix_list_cmd, |
| 8196 | "show bgp ipv6 prefix-list WORD", |
| 8197 | SHOW_STR |
| 8198 | BGP_STR |
| 8199 | "Address family\n" |
| 8200 | "Display routes conforming to the prefix-list\n" |
| 8201 | "IPv6 prefix-list name\n") |
| 8202 | |
| 8203 | /* old command */ |
| 8204 | DEFUN (show_ipv6_bgp_prefix_list, |
| 8205 | show_ipv6_bgp_prefix_list_cmd, |
| 8206 | "show ipv6 bgp prefix-list WORD", |
| 8207 | SHOW_STR |
| 8208 | IPV6_STR |
| 8209 | BGP_STR |
| 8210 | "Display routes matching the prefix-list\n" |
| 8211 | "IPv6 prefix-list name\n") |
| 8212 | { |
| 8213 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8214 | bgp_show_type_prefix_list); |
| 8215 | } |
| 8216 | |
| 8217 | /* old command */ |
| 8218 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 8219 | show_ipv6_mbgp_prefix_list_cmd, |
| 8220 | "show ipv6 mbgp prefix-list WORD", |
| 8221 | SHOW_STR |
| 8222 | IPV6_STR |
| 8223 | MBGP_STR |
| 8224 | "Display routes matching the prefix-list\n" |
| 8225 | "IPv6 prefix-list name\n") |
| 8226 | { |
| 8227 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8228 | bgp_show_type_prefix_list); |
| 8229 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8230 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8231 | DEFUN (show_bgp_ipv4_prefix_list, |
| 8232 | show_bgp_ipv4_prefix_list_cmd, |
| 8233 | "show bgp ipv4 prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8234 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8235 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8236 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8237 | "Display routes conforming to the prefix-list\n" |
| 8238 | "IP prefix-list name\n") |
| 8239 | { |
| 8240 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8241 | bgp_show_type_prefix_list); |
| 8242 | } |
| 8243 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8244 | DEFUN (show_bgp_ipv4_safi_flap_prefix_list, |
| 8245 | show_bgp_ipv4_safi_flap_prefix_list_cmd, |
| 8246 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8247 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8248 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8249 | IP_STR |
| 8250 | "Address Family Modifier\n" |
| 8251 | "Address Family Modifier\n" |
| 8252 | "Address Family Modifier\n" |
| 8253 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8254 | "Display flap statistics of routes\n" |
| 8255 | "Display routes conforming to the prefix-list\n" |
| 8256 | "IP prefix-list name\n") |
| 8257 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8258 | safi_t safi; |
| 8259 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8260 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8261 | return CMD_WARNING; |
| 8262 | } |
| 8263 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8264 | bgp_show_type_flap_prefix_list); |
| 8265 | } |
| 8266 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8267 | ALIAS (show_bgp_ipv4_safi_flap_prefix_list, |
| 8268 | show_bgp_ipv4_safi_damp_flap_prefix_list_cmd, |
| 8269 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8270 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8271 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8272 | IP_STR |
| 8273 | "Address Family Modifier\n" |
| 8274 | "Address Family Modifier\n" |
| 8275 | "Address Family Modifier\n" |
| 8276 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8277 | "Display detailed information about dampening\n" |
| 8278 | "Display flap statistics of routes\n" |
| 8279 | "Display routes conforming to the prefix-list\n" |
| 8280 | "IP prefix-list name\n") |
| 8281 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8282 | DEFUN (show_bgp_ipv6_safi_flap_prefix_list, |
| 8283 | show_bgp_ipv6_safi_flap_prefix_list_cmd, |
| 8284 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8285 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8286 | BGP_STR |
| 8287 | IPV6_STR |
| 8288 | "Address Family Modifier\n" |
| 8289 | "Address Family Modifier\n" |
| 8290 | "Address Family Modifier\n" |
| 8291 | "Address Family Modifier\n" |
| 8292 | "Display flap statistics of routes\n" |
| 8293 | "Display routes conforming to the prefix-list\n" |
| 8294 | "IP prefix-list name\n") |
| 8295 | { |
| 8296 | safi_t safi; |
| 8297 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8298 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8299 | return CMD_WARNING; |
| 8300 | } |
| 8301 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
| 8302 | bgp_show_type_flap_prefix_list); |
| 8303 | } |
| 8304 | ALIAS (show_bgp_ipv6_safi_flap_prefix_list, |
| 8305 | show_bgp_ipv6_safi_damp_flap_prefix_list_cmd, |
| 8306 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
| 8307 | SHOW_STR |
| 8308 | BGP_STR |
| 8309 | IPV6_STR |
| 8310 | "Address Family Modifier\n" |
| 8311 | "Address Family Modifier\n" |
| 8312 | "Address Family Modifier\n" |
| 8313 | "Address Family Modifier\n" |
| 8314 | "Display detailed information about dampening\n" |
| 8315 | "Display flap statistics of routes\n" |
| 8316 | "Display routes conforming to the prefix-list\n" |
| 8317 | "IP prefix-list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8318 | |
| 8319 | DEFUN (show_bgp_ipv4_safi_prefix_list, |
| 8320 | show_bgp_ipv4_safi_prefix_list_cmd, |
| 8321 | "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD", |
| 8322 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8323 | BGP_STR |
| 8324 | "Address family\n" |
| 8325 | "Address Family modifier\n" |
| 8326 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8327 | "Address Family modifier\n" |
| 8328 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8329 | "Display routes conforming to the prefix-list\n" |
| 8330 | "IP prefix-list name\n") |
| 8331 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8332 | safi_t safi; |
| 8333 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8334 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8335 | return CMD_WARNING; |
| 8336 | } |
| 8337 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8338 | bgp_show_type_prefix_list); |
| 8339 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8340 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8341 | DEFUN (show_bgp_ipv6_safi_prefix_list, |
| 8342 | show_bgp_ipv6_safi_prefix_list_cmd, |
| 8343 | "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8344 | SHOW_STR |
| 8345 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8346 | "Address family\n" |
| 8347 | "Address Family modifier\n" |
| 8348 | "Address Family modifier\n" |
| 8349 | "Address Family modifier\n" |
| 8350 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8351 | "Display routes conforming to the prefix-list\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8352 | "IP prefix-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8353 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8354 | safi_t safi; |
| 8355 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8356 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8357 | return CMD_WARNING; |
| 8358 | } |
| 8359 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8360 | bgp_show_type_prefix_list); |
| 8361 | } |
| 8362 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8363 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8364 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8365 | safi_t safi, enum bgp_show_type type) |
| 8366 | { |
| 8367 | struct as_list *as_list; |
| 8368 | |
| 8369 | as_list = as_list_lookup (filter); |
| 8370 | if (as_list == NULL) |
| 8371 | { |
| 8372 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 8373 | return CMD_WARNING; |
| 8374 | } |
| 8375 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8376 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8377 | } |
| 8378 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8379 | DEFUN (show_ip_bgp_filter_list, |
| 8380 | show_ip_bgp_filter_list_cmd, |
| 8381 | "show ip bgp filter-list WORD", |
| 8382 | SHOW_STR |
| 8383 | IP_STR |
| 8384 | BGP_STR |
| 8385 | "Display routes conforming to the filter-list\n" |
| 8386 | "Regular expression access list name\n") |
| 8387 | { |
| 8388 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8389 | bgp_show_type_filter_list); |
| 8390 | } |
| 8391 | |
| 8392 | DEFUN (show_ip_bgp_flap_filter_list, |
| 8393 | show_ip_bgp_flap_filter_list_cmd, |
| 8394 | "show ip bgp flap-statistics filter-list WORD", |
| 8395 | SHOW_STR |
| 8396 | IP_STR |
| 8397 | BGP_STR |
| 8398 | "Display flap statistics of routes\n" |
| 8399 | "Display routes conforming to the filter-list\n" |
| 8400 | "Regular expression access list name\n") |
| 8401 | { |
| 8402 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8403 | bgp_show_type_flap_filter_list); |
| 8404 | } |
| 8405 | |
| 8406 | ALIAS (show_ip_bgp_flap_filter_list, |
| 8407 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 8408 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 8409 | SHOW_STR |
| 8410 | IP_STR |
| 8411 | BGP_STR |
| 8412 | "Display detailed information about dampening\n" |
| 8413 | "Display flap statistics of routes\n" |
| 8414 | "Display routes conforming to the filter-list\n" |
| 8415 | "Regular expression access list name\n") |
| 8416 | |
| 8417 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 8418 | show_ip_bgp_ipv4_filter_list_cmd, |
| 8419 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 8420 | SHOW_STR |
| 8421 | IP_STR |
| 8422 | BGP_STR |
| 8423 | "Address family\n" |
| 8424 | "Address Family modifier\n" |
| 8425 | "Address Family modifier\n" |
| 8426 | "Display routes conforming to the filter-list\n" |
| 8427 | "Regular expression access list name\n") |
| 8428 | { |
| 8429 | if (strncmp (argv[0], "m", 1) == 0) |
| 8430 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8431 | bgp_show_type_filter_list); |
| 8432 | |
| 8433 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8434 | bgp_show_type_filter_list); |
| 8435 | } |
| 8436 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8437 | DEFUN (show_bgp_filter_list, |
| 8438 | show_bgp_filter_list_cmd, |
| 8439 | "show bgp filter-list WORD", |
| 8440 | SHOW_STR |
| 8441 | BGP_STR |
| 8442 | "Display routes conforming to the filter-list\n" |
| 8443 | "Regular expression access list name\n") |
| 8444 | { |
| 8445 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8446 | bgp_show_type_filter_list); |
| 8447 | } |
| 8448 | |
| 8449 | /* old command */ |
| 8450 | DEFUN (show_ipv6_bgp_filter_list, |
| 8451 | show_ipv6_bgp_filter_list_cmd, |
| 8452 | "show ipv6 bgp filter-list WORD", |
| 8453 | SHOW_STR |
| 8454 | IPV6_STR |
| 8455 | BGP_STR |
| 8456 | "Display routes conforming to the filter-list\n" |
| 8457 | "Regular expression access list name\n") |
| 8458 | { |
| 8459 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8460 | bgp_show_type_filter_list); |
| 8461 | } |
| 8462 | |
| 8463 | /* old command */ |
| 8464 | DEFUN (show_ipv6_mbgp_filter_list, |
| 8465 | show_ipv6_mbgp_filter_list_cmd, |
| 8466 | "show ipv6 mbgp filter-list WORD", |
| 8467 | SHOW_STR |
| 8468 | IPV6_STR |
| 8469 | MBGP_STR |
| 8470 | "Display routes conforming to the filter-list\n" |
| 8471 | "Regular expression access list name\n") |
| 8472 | { |
| 8473 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8474 | bgp_show_type_filter_list); |
| 8475 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8476 | |
| 8477 | DEFUN (show_ip_bgp_dampening_info, |
| 8478 | show_ip_bgp_dampening_params_cmd, |
| 8479 | "show ip bgp dampening parameters", |
| 8480 | SHOW_STR |
| 8481 | IP_STR |
| 8482 | BGP_STR |
| 8483 | "Display detailed information about dampening\n" |
| 8484 | "Display detail of configured dampening parameters\n") |
| 8485 | { |
| 8486 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8487 | } |
| 8488 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8489 | DEFUN (show_bgp_ipv4_filter_list, |
| 8490 | show_bgp_ipv4_filter_list_cmd, |
| 8491 | "show bgp ipv4 filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8492 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8493 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8494 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8495 | "Display routes conforming to the filter-list\n" |
| 8496 | "Regular expression access list name\n") |
| 8497 | { |
| 8498 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8499 | bgp_show_type_filter_list); |
| 8500 | } |
| 8501 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8502 | DEFUN (show_bgp_ipv4_safi_flap_filter_list, |
| 8503 | show_bgp_ipv4_safi_flap_filter_list_cmd, |
| 8504 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8505 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8506 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8507 | IP_STR |
| 8508 | "Address Family modifier\n" |
| 8509 | "Address Family modifier\n" |
| 8510 | "Address Family modifier\n" |
| 8511 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8512 | "Display flap statistics of routes\n" |
| 8513 | "Display routes conforming to the filter-list\n" |
| 8514 | "Regular expression access list name\n") |
| 8515 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8516 | safi_t safi; |
| 8517 | |
| 8518 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8519 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8520 | return CMD_WARNING; |
| 8521 | } |
| 8522 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8523 | bgp_show_type_flap_filter_list); |
| 8524 | } |
| 8525 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8526 | ALIAS (show_bgp_ipv4_safi_flap_filter_list, |
| 8527 | show_bgp_ipv4_safi_damp_flap_filter_list_cmd, |
| 8528 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8529 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8530 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8531 | IP_STR |
| 8532 | "Address Family modifier\n" |
| 8533 | "Address Family modifier\n" |
| 8534 | "Address Family modifier\n" |
| 8535 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8536 | "Display detailed information about dampening\n" |
| 8537 | "Display flap statistics of routes\n" |
| 8538 | "Display routes conforming to the filter-list\n" |
| 8539 | "Regular expression access list name\n") |
| 8540 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8541 | DEFUN (show_bgp_ipv6_safi_flap_filter_list, |
| 8542 | show_bgp_ipv6_safi_flap_filter_list_cmd, |
| 8543 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8544 | SHOW_STR |
| 8545 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8546 | IPV6_STR |
| 8547 | "Address Family modifier\n" |
| 8548 | "Address Family modifier\n" |
| 8549 | "Address Family modifier\n" |
| 8550 | "Address Family modifier\n" |
| 8551 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8552 | "Display routes conforming to the filter-list\n" |
| 8553 | "Regular expression access list name\n") |
| 8554 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8555 | safi_t safi; |
| 8556 | |
| 8557 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8558 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8559 | return CMD_WARNING; |
| 8560 | } |
| 8561 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8562 | bgp_show_type_flap_filter_list); |
| 8563 | } |
| 8564 | ALIAS (show_bgp_ipv6_safi_flap_filter_list, |
| 8565 | show_bgp_ipv6_safi_damp_flap_filter_list_cmd, |
| 8566 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
| 8567 | SHOW_STR |
| 8568 | BGP_STR |
| 8569 | IPV6_STR |
| 8570 | "Address Family modifier\n" |
| 8571 | "Address Family modifier\n" |
| 8572 | "Address Family modifier\n" |
| 8573 | "Address Family modifier\n" |
| 8574 | "Display detailed information about dampening\n" |
| 8575 | "Display flap statistics of routes\n" |
| 8576 | "Display routes conforming to the filter-list\n" |
| 8577 | "Regular expression access list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8578 | |
| 8579 | DEFUN (show_bgp_ipv4_safi_filter_list, |
| 8580 | show_bgp_ipv4_safi_filter_list_cmd, |
| 8581 | "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8582 | SHOW_STR |
| 8583 | BGP_STR |
| 8584 | "Address Family modifier\n" |
| 8585 | "Address Family modifier\n" |
| 8586 | "Address Family modifier\n" |
| 8587 | "Address Family modifier\n" |
| 8588 | "Display routes conforming to the filter-list\n" |
| 8589 | "Regular expression access list name\n") |
| 8590 | { |
| 8591 | safi_t safi; |
| 8592 | |
| 8593 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8594 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8595 | return CMD_WARNING; |
| 8596 | } |
| 8597 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
| 8598 | bgp_show_type_filter_list); |
| 8599 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8600 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8601 | DEFUN (show_bgp_ipv6_safi_filter_list, |
| 8602 | show_bgp_ipv6_safi_filter_list_cmd, |
| 8603 | "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8604 | SHOW_STR |
| 8605 | BGP_STR |
| 8606 | "Address Family modifier\n" |
| 8607 | "Address Family modifier\n" |
| 8608 | "Address Family modifier\n" |
| 8609 | "Address Family modifier\n" |
| 8610 | "Display routes conforming to the filter-list\n" |
| 8611 | "Regular expression access list name\n") |
| 8612 | { |
| 8613 | safi_t safi; |
| 8614 | |
| 8615 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8616 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8617 | return CMD_WARNING; |
| 8618 | } |
| 8619 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8620 | bgp_show_type_filter_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8621 | } |
| 8622 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8623 | DEFUN (show_bgp_ipv6_filter_list, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8624 | show_bgp_ipv6_filter_list_cmd, |
| 8625 | "show bgp ipv6 filter-list WORD", |
| 8626 | SHOW_STR |
| 8627 | BGP_STR |
| 8628 | "Address family\n" |
| 8629 | "Display routes conforming to the filter-list\n" |
| 8630 | "Regular expression access list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8631 | { |
| 8632 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8633 | bgp_show_type_filter_list); |
| 8634 | } |
| 8635 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8636 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8637 | 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] | 8638 | safi_t safi, enum bgp_show_type type) |
| 8639 | { |
| 8640 | struct route_map *rmap; |
| 8641 | |
| 8642 | rmap = route_map_lookup_by_name (rmap_str); |
| 8643 | if (! rmap) |
| 8644 | { |
| 8645 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 8646 | rmap_str, VTY_NEWLINE); |
| 8647 | return CMD_WARNING; |
| 8648 | } |
| 8649 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8650 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8651 | } |
| 8652 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8653 | DEFUN (show_ip_bgp_route_map, |
| 8654 | show_ip_bgp_route_map_cmd, |
| 8655 | "show ip bgp route-map WORD", |
| 8656 | SHOW_STR |
| 8657 | IP_STR |
| 8658 | BGP_STR |
| 8659 | "Display routes matching the route-map\n" |
| 8660 | "A route-map to match on\n") |
| 8661 | { |
| 8662 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8663 | bgp_show_type_route_map); |
| 8664 | } |
| 8665 | |
| 8666 | DEFUN (show_ip_bgp_flap_route_map, |
| 8667 | show_ip_bgp_flap_route_map_cmd, |
| 8668 | "show ip bgp flap-statistics route-map WORD", |
| 8669 | SHOW_STR |
| 8670 | IP_STR |
| 8671 | BGP_STR |
| 8672 | "Display flap statistics of routes\n" |
| 8673 | "Display routes matching the route-map\n" |
| 8674 | "A route-map to match on\n") |
| 8675 | { |
| 8676 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8677 | bgp_show_type_flap_route_map); |
| 8678 | } |
| 8679 | |
| 8680 | ALIAS (show_ip_bgp_flap_route_map, |
| 8681 | show_ip_bgp_damp_flap_route_map_cmd, |
| 8682 | "show ip bgp dampening flap-statistics route-map WORD", |
| 8683 | SHOW_STR |
| 8684 | IP_STR |
| 8685 | BGP_STR |
| 8686 | "Display detailed information about dampening\n" |
| 8687 | "Display flap statistics of routes\n" |
| 8688 | "Display routes matching the route-map\n" |
| 8689 | "A route-map to match on\n") |
| 8690 | |
| 8691 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 8692 | show_ip_bgp_ipv4_route_map_cmd, |
| 8693 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 8694 | SHOW_STR |
| 8695 | IP_STR |
| 8696 | BGP_STR |
| 8697 | "Address family\n" |
| 8698 | "Address Family modifier\n" |
| 8699 | "Address Family modifier\n" |
| 8700 | "Display routes matching the route-map\n" |
| 8701 | "A route-map to match on\n") |
| 8702 | { |
| 8703 | if (strncmp (argv[0], "m", 1) == 0) |
| 8704 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8705 | bgp_show_type_route_map); |
| 8706 | |
| 8707 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8708 | bgp_show_type_route_map); |
| 8709 | } |
| 8710 | |
| 8711 | DEFUN (show_bgp_route_map, |
| 8712 | show_bgp_route_map_cmd, |
| 8713 | "show bgp route-map WORD", |
| 8714 | SHOW_STR |
| 8715 | BGP_STR |
| 8716 | "Display routes matching the route-map\n" |
| 8717 | "A route-map to match on\n") |
| 8718 | { |
| 8719 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8720 | bgp_show_type_route_map); |
| 8721 | } |
| 8722 | |
| 8723 | DEFUN (show_ip_bgp_cidr_only, |
| 8724 | show_ip_bgp_cidr_only_cmd, |
| 8725 | "show ip bgp cidr-only", |
| 8726 | SHOW_STR |
| 8727 | IP_STR |
| 8728 | BGP_STR |
| 8729 | "Display only routes with non-natural netmasks\n") |
| 8730 | { |
| 8731 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8732 | bgp_show_type_cidr_only, NULL); |
| 8733 | } |
| 8734 | |
| 8735 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 8736 | show_ip_bgp_flap_cidr_only_cmd, |
| 8737 | "show ip bgp flap-statistics cidr-only", |
| 8738 | SHOW_STR |
| 8739 | IP_STR |
| 8740 | BGP_STR |
| 8741 | "Display flap statistics of routes\n" |
| 8742 | "Display only routes with non-natural netmasks\n") |
| 8743 | { |
| 8744 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8745 | bgp_show_type_flap_cidr_only, NULL); |
| 8746 | } |
| 8747 | |
| 8748 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 8749 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 8750 | "show ip bgp dampening flap-statistics cidr-only", |
| 8751 | SHOW_STR |
| 8752 | IP_STR |
| 8753 | BGP_STR |
| 8754 | "Display detailed information about dampening\n" |
| 8755 | "Display flap statistics of routes\n" |
| 8756 | "Display only routes with non-natural netmasks\n") |
| 8757 | |
| 8758 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 8759 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 8760 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 8761 | SHOW_STR |
| 8762 | IP_STR |
| 8763 | BGP_STR |
| 8764 | "Address family\n" |
| 8765 | "Address Family modifier\n" |
| 8766 | "Address Family modifier\n" |
| 8767 | "Display only routes with non-natural netmasks\n") |
| 8768 | { |
| 8769 | if (strncmp (argv[0], "m", 1) == 0) |
| 8770 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8771 | bgp_show_type_cidr_only, NULL); |
| 8772 | |
| 8773 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8774 | bgp_show_type_cidr_only, NULL); |
| 8775 | } |
| 8776 | |
| 8777 | DEFUN (show_ip_bgp_community_all, |
| 8778 | show_ip_bgp_community_all_cmd, |
| 8779 | "show ip bgp community", |
| 8780 | SHOW_STR |
| 8781 | IP_STR |
| 8782 | BGP_STR |
| 8783 | "Display routes matching the communities\n") |
| 8784 | { |
| 8785 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8786 | bgp_show_type_community_all, NULL); |
| 8787 | } |
| 8788 | |
| 8789 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 8790 | show_ip_bgp_ipv4_community_all_cmd, |
| 8791 | "show ip bgp ipv4 (unicast|multicast) community", |
| 8792 | SHOW_STR |
| 8793 | IP_STR |
| 8794 | BGP_STR |
| 8795 | "Address family\n" |
| 8796 | "Address Family modifier\n" |
| 8797 | "Address Family modifier\n" |
| 8798 | "Display routes matching the communities\n") |
| 8799 | { |
| 8800 | if (strncmp (argv[0], "m", 1) == 0) |
| 8801 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8802 | bgp_show_type_community_all, NULL); |
| 8803 | |
| 8804 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8805 | bgp_show_type_community_all, NULL); |
| 8806 | } |
| 8807 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8808 | DEFUN (show_bgp_community_all, |
| 8809 | show_bgp_community_all_cmd, |
| 8810 | "show bgp community", |
| 8811 | SHOW_STR |
| 8812 | BGP_STR |
| 8813 | "Display routes matching the communities\n") |
| 8814 | { |
| 8815 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 8816 | bgp_show_type_community_all, NULL); |
| 8817 | } |
| 8818 | |
| 8819 | ALIAS (show_bgp_community_all, |
| 8820 | show_bgp_ipv6_community_all_cmd, |
| 8821 | "show bgp ipv6 community", |
| 8822 | SHOW_STR |
| 8823 | BGP_STR |
| 8824 | "Address family\n" |
| 8825 | "Display routes matching the communities\n") |
| 8826 | |
| 8827 | /* old command */ |
| 8828 | DEFUN (show_ipv6_bgp_community_all, |
| 8829 | show_ipv6_bgp_community_all_cmd, |
| 8830 | "show ipv6 bgp community", |
| 8831 | SHOW_STR |
| 8832 | IPV6_STR |
| 8833 | BGP_STR |
| 8834 | "Display routes matching the communities\n") |
| 8835 | { |
| 8836 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 8837 | bgp_show_type_community_all, NULL); |
| 8838 | } |
| 8839 | |
| 8840 | /* old command */ |
| 8841 | DEFUN (show_ipv6_mbgp_community_all, |
| 8842 | show_ipv6_mbgp_community_all_cmd, |
| 8843 | "show ipv6 mbgp community", |
| 8844 | SHOW_STR |
| 8845 | IPV6_STR |
| 8846 | MBGP_STR |
| 8847 | "Display routes matching the communities\n") |
| 8848 | { |
| 8849 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
| 8850 | bgp_show_type_community_all, NULL); |
| 8851 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8852 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8853 | DEFUN (show_bgp_ipv4_route_map, |
| 8854 | show_bgp_ipv4_route_map_cmd, |
| 8855 | "show bgp ipv4 route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8856 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8857 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8858 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8859 | "Display routes matching the route-map\n" |
| 8860 | "A route-map to match on\n") |
| 8861 | { |
| 8862 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8863 | bgp_show_type_route_map); |
| 8864 | } |
| 8865 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8866 | DEFUN (show_bgp_ipv4_safi_flap_route_map, |
| 8867 | show_bgp_ipv4_safi_flap_route_map_cmd, |
| 8868 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8869 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8870 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8871 | IP_STR |
| 8872 | "Address Family Modifier\n" |
| 8873 | "Address Family Modifier\n" |
| 8874 | "Address Family Modifier\n" |
| 8875 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8876 | "Display flap statistics of routes\n" |
| 8877 | "Display routes matching the route-map\n" |
| 8878 | "A route-map to match on\n") |
| 8879 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8880 | safi_t safi; |
| 8881 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8882 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8883 | return CMD_WARNING; |
| 8884 | } |
| 8885 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8886 | bgp_show_type_flap_route_map); |
| 8887 | } |
| 8888 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8889 | ALIAS (show_bgp_ipv4_safi_flap_route_map, |
| 8890 | show_bgp_ipv4_safi_damp_flap_route_map_cmd, |
| 8891 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8892 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8893 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8894 | IP_STR |
| 8895 | "Address Family Modifier\n" |
| 8896 | "Address Family Modifier\n" |
| 8897 | "Address Family Modifier\n" |
| 8898 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8899 | "Display detailed information about dampening\n" |
| 8900 | "Display flap statistics of routes\n" |
| 8901 | "Display routes matching the route-map\n" |
| 8902 | "A route-map to match on\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8903 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8904 | DEFUN (show_bgp_ipv6_safi_flap_route_map, |
| 8905 | show_bgp_ipv6_safi_flap_route_map_cmd, |
| 8906 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8907 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8908 | BGP_STR |
| 8909 | IPV6_STR |
| 8910 | "Address Family Modifier\n" |
| 8911 | "Address Family Modifier\n" |
| 8912 | "Address Family Modifier\n" |
| 8913 | "Address Family Modifier\n" |
| 8914 | "Display flap statistics of routes\n" |
| 8915 | "Display routes matching the route-map\n" |
| 8916 | "A route-map to match on\n") |
| 8917 | { |
| 8918 | safi_t safi; |
| 8919 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8920 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8921 | return CMD_WARNING; |
| 8922 | } |
| 8923 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
| 8924 | bgp_show_type_flap_route_map); |
| 8925 | } |
| 8926 | ALIAS (show_bgp_ipv6_safi_flap_route_map, |
| 8927 | show_bgp_ipv6_safi_damp_flap_route_map_cmd, |
| 8928 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
| 8929 | SHOW_STR |
| 8930 | BGP_STR |
| 8931 | IPV6_STR |
| 8932 | "Address Family Modifier\n" |
| 8933 | "Address Family Modifier\n" |
| 8934 | "Address Family Modifier\n" |
| 8935 | "Address Family Modifier\n" |
| 8936 | "Display detailed information about dampening\n" |
| 8937 | "Display flap statistics of routes\n" |
| 8938 | "Display routes matching the route-map\n" |
| 8939 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8940 | |
| 8941 | DEFUN (show_bgp_ipv4_safi_route_map, |
| 8942 | show_bgp_ipv4_safi_route_map_cmd, |
| 8943 | "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD", |
| 8944 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8945 | BGP_STR |
| 8946 | "Address family\n" |
| 8947 | "Address Family modifier\n" |
| 8948 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8949 | "Address Family modifier\n" |
| 8950 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8951 | "Display routes matching the route-map\n" |
| 8952 | "A route-map to match on\n") |
| 8953 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8954 | safi_t safi; |
| 8955 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8956 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8957 | return CMD_WARNING; |
| 8958 | } |
| 8959 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8960 | bgp_show_type_route_map); |
| 8961 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8962 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8963 | DEFUN (show_bgp_ipv6_safi_route_map, |
| 8964 | show_bgp_ipv6_safi_route_map_cmd, |
| 8965 | "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8966 | SHOW_STR |
| 8967 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8968 | "Address family\n" |
| 8969 | "Address Family modifier\n" |
| 8970 | "Address Family modifier\n" |
| 8971 | "Address Family modifier\n" |
| 8972 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8973 | "Display routes matching the route-map\n" |
| 8974 | "A route-map to match on\n") |
| 8975 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8976 | safi_t safi; |
| 8977 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8978 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8979 | return CMD_WARNING; |
| 8980 | } |
| 8981 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8982 | bgp_show_type_route_map); |
| 8983 | } |
| 8984 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8985 | DEFUN (show_bgp_ipv6_route_map, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8986 | show_bgp_ipv6_route_map_cmd, |
| 8987 | "show bgp ipv6 route-map WORD", |
| 8988 | SHOW_STR |
| 8989 | BGP_STR |
| 8990 | "Address family\n" |
| 8991 | "Display routes matching the route-map\n" |
| 8992 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8993 | { |
| 8994 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8995 | bgp_show_type_route_map); |
| 8996 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 8997 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8998 | DEFUN (show_bgp_ipv4_cidr_only, |
| 8999 | show_bgp_ipv4_cidr_only_cmd, |
| 9000 | "show bgp ipv4 cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9001 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9002 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9003 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9004 | "Display only routes with non-natural netmasks\n") |
| 9005 | { |
| 9006 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9007 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9008 | } |
| 9009 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9010 | DEFUN (show_bgp_ipv4_safi_flap_cidr_only, |
| 9011 | show_bgp_ipv4_safi_flap_cidr_only_cmd, |
| 9012 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9013 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9014 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9015 | "Address Family\n" |
| 9016 | "Address Family Modifier\n" |
| 9017 | "Address Family Modifier\n" |
| 9018 | "Address Family Modifier\n" |
| 9019 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9020 | "Display flap statistics of routes\n" |
| 9021 | "Display only routes with non-natural netmasks\n") |
| 9022 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9023 | safi_t safi; |
| 9024 | |
| 9025 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9026 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9027 | return CMD_WARNING; |
| 9028 | } |
| 9029 | 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] | 9030 | } |
| 9031 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9032 | ALIAS (show_bgp_ipv4_safi_flap_cidr_only, |
| 9033 | show_bgp_ipv4_safi_damp_flap_cidr_only_cmd, |
| 9034 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9035 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9036 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9037 | "Address Family\n" |
| 9038 | "Address Family Modifier\n" |
| 9039 | "Address Family Modifier\n" |
| 9040 | "Address Family Modifier\n" |
| 9041 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9042 | "Display detailed information about dampening\n" |
| 9043 | "Display flap statistics of routes\n" |
| 9044 | "Display only routes with non-natural netmasks\n") |
| 9045 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9046 | DEFUN (show_bgp_ipv4_safi_cidr_only, |
| 9047 | show_bgp_ipv4_safi_cidr_only_cmd, |
| 9048 | "show bgp ipv4 (unicast|multicast) cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9049 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9050 | BGP_STR |
| 9051 | "Address family\n" |
| 9052 | "Address Family modifier\n" |
| 9053 | "Address Family modifier\n" |
| 9054 | "Display only routes with non-natural netmasks\n") |
| 9055 | { |
| 9056 | if (strncmp (argv[0], "m", 1) == 0) |
| 9057 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9058 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9059 | |
| 9060 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9061 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9062 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9063 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9064 | /* new046 */ |
| 9065 | DEFUN (show_bgp_afi_safi_community_all, |
| 9066 | show_bgp_afi_safi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9067 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9068 | SHOW_STR |
| 9069 | BGP_STR |
| 9070 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9071 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9072 | "Address Family modifier\n" |
| 9073 | "Address Family modifier\n" |
| 9074 | "Address Family modifier\n" |
| 9075 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9076 | "Display routes matching the communities\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9077 | { |
| 9078 | safi_t safi; |
| 9079 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9080 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9081 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9082 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9083 | return CMD_WARNING; |
| 9084 | } |
| 9085 | if (bgp_parse_safi(argv[1], &safi)) { |
| 9086 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 9087 | return CMD_WARNING; |
| 9088 | } |
| 9089 | |
| 9090 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
| 9091 | } |
| 9092 | DEFUN (show_bgp_afi_community_all, |
| 9093 | show_bgp_afi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9094 | "show bgp (ipv4|ipv6) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9095 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9096 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9097 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9098 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9099 | "Display routes matching the communities\n") |
| 9100 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9101 | afi_t afi; |
| 9102 | safi_t safi = SAFI_UNICAST; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9103 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9104 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9105 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9106 | return CMD_WARNING; |
| 9107 | } |
| 9108 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9109 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9110 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9111 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9112 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 9113 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9114 | { |
| 9115 | struct community *com; |
| 9116 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9117 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9118 | int i; |
| 9119 | char *str; |
| 9120 | int first = 0; |
| 9121 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9122 | /* BGP structure lookup */ |
| 9123 | if (view_name) |
| 9124 | { |
| 9125 | bgp = bgp_lookup_by_name (view_name); |
| 9126 | if (bgp == NULL) |
| 9127 | { |
| 9128 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9129 | return CMD_WARNING; |
| 9130 | } |
| 9131 | } |
| 9132 | else |
| 9133 | { |
| 9134 | bgp = bgp_get_default (); |
| 9135 | if (bgp == NULL) |
| 9136 | { |
| 9137 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9138 | return CMD_WARNING; |
| 9139 | } |
| 9140 | } |
| 9141 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9142 | b = buffer_new (1024); |
| 9143 | for (i = 0; i < argc; i++) |
| 9144 | { |
| 9145 | if (first) |
| 9146 | buffer_putc (b, ' '); |
| 9147 | else |
| 9148 | { |
| 9149 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 9150 | continue; |
| 9151 | first = 1; |
| 9152 | } |
| 9153 | |
| 9154 | buffer_putstr (b, argv[i]); |
| 9155 | } |
| 9156 | buffer_putc (b, '\0'); |
| 9157 | |
| 9158 | str = buffer_getstr (b); |
| 9159 | buffer_free (b); |
| 9160 | |
| 9161 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 9162 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9163 | if (! com) |
| 9164 | { |
| 9165 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 9166 | return CMD_WARNING; |
| 9167 | } |
| 9168 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9169 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9170 | (exact ? bgp_show_type_community_exact : |
| 9171 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9172 | } |
| 9173 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9174 | DEFUN (show_ip_bgp_community, |
| 9175 | show_ip_bgp_community_cmd, |
| 9176 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9177 | SHOW_STR |
| 9178 | IP_STR |
| 9179 | BGP_STR |
| 9180 | "Display routes matching the communities\n" |
| 9181 | "community number\n" |
| 9182 | "Do not send outside local AS (well-known community)\n" |
| 9183 | "Do not advertise to any peer (well-known community)\n" |
| 9184 | "Do not export to next AS (well-known community)\n") |
| 9185 | { |
| 9186 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9187 | } |
| 9188 | |
| 9189 | ALIAS (show_ip_bgp_community, |
| 9190 | show_ip_bgp_community2_cmd, |
| 9191 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9192 | SHOW_STR |
| 9193 | IP_STR |
| 9194 | BGP_STR |
| 9195 | "Display routes matching the communities\n" |
| 9196 | "community number\n" |
| 9197 | "Do not send outside local AS (well-known community)\n" |
| 9198 | "Do not advertise to any peer (well-known community)\n" |
| 9199 | "Do not export to next AS (well-known community)\n" |
| 9200 | "community number\n" |
| 9201 | "Do not send outside local AS (well-known community)\n" |
| 9202 | "Do not advertise to any peer (well-known community)\n" |
| 9203 | "Do not export to next AS (well-known community)\n") |
| 9204 | |
| 9205 | ALIAS (show_ip_bgp_community, |
| 9206 | show_ip_bgp_community3_cmd, |
| 9207 | "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)", |
| 9208 | SHOW_STR |
| 9209 | IP_STR |
| 9210 | BGP_STR |
| 9211 | "Display routes matching the communities\n" |
| 9212 | "community number\n" |
| 9213 | "Do not send outside local AS (well-known community)\n" |
| 9214 | "Do not advertise to any peer (well-known community)\n" |
| 9215 | "Do not export to next AS (well-known community)\n" |
| 9216 | "community number\n" |
| 9217 | "Do not send outside local AS (well-known community)\n" |
| 9218 | "Do not advertise to any peer (well-known community)\n" |
| 9219 | "Do not export to next AS (well-known community)\n" |
| 9220 | "community number\n" |
| 9221 | "Do not send outside local AS (well-known community)\n" |
| 9222 | "Do not advertise to any peer (well-known community)\n" |
| 9223 | "Do not export to next AS (well-known community)\n") |
| 9224 | |
| 9225 | ALIAS (show_ip_bgp_community, |
| 9226 | show_ip_bgp_community4_cmd, |
| 9227 | "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)", |
| 9228 | SHOW_STR |
| 9229 | IP_STR |
| 9230 | BGP_STR |
| 9231 | "Display routes matching the communities\n" |
| 9232 | "community number\n" |
| 9233 | "Do not send outside local AS (well-known community)\n" |
| 9234 | "Do not advertise to any peer (well-known community)\n" |
| 9235 | "Do not export to next AS (well-known community)\n" |
| 9236 | "community number\n" |
| 9237 | "Do not send outside local AS (well-known community)\n" |
| 9238 | "Do not advertise to any peer (well-known community)\n" |
| 9239 | "Do not export to next AS (well-known community)\n" |
| 9240 | "community number\n" |
| 9241 | "Do not send outside local AS (well-known community)\n" |
| 9242 | "Do not advertise to any peer (well-known community)\n" |
| 9243 | "Do not export to next AS (well-known community)\n" |
| 9244 | "community number\n" |
| 9245 | "Do not send outside local AS (well-known community)\n" |
| 9246 | "Do not advertise to any peer (well-known community)\n" |
| 9247 | "Do not export to next AS (well-known community)\n") |
| 9248 | |
| 9249 | DEFUN (show_ip_bgp_ipv4_community, |
| 9250 | show_ip_bgp_ipv4_community_cmd, |
| 9251 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 9252 | SHOW_STR |
| 9253 | IP_STR |
| 9254 | BGP_STR |
| 9255 | "Address family\n" |
| 9256 | "Address Family modifier\n" |
| 9257 | "Address Family modifier\n" |
| 9258 | "Display routes matching the communities\n" |
| 9259 | "community number\n" |
| 9260 | "Do not send outside local AS (well-known community)\n" |
| 9261 | "Do not advertise to any peer (well-known community)\n" |
| 9262 | "Do not export to next AS (well-known community)\n") |
| 9263 | { |
| 9264 | if (strncmp (argv[0], "m", 1) == 0) |
| 9265 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 9266 | |
| 9267 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9268 | } |
| 9269 | |
| 9270 | ALIAS (show_ip_bgp_ipv4_community, |
| 9271 | show_ip_bgp_ipv4_community2_cmd, |
| 9272 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9273 | SHOW_STR |
| 9274 | IP_STR |
| 9275 | BGP_STR |
| 9276 | "Address family\n" |
| 9277 | "Address Family modifier\n" |
| 9278 | "Address Family modifier\n" |
| 9279 | "Display routes matching the communities\n" |
| 9280 | "community number\n" |
| 9281 | "Do not send outside local AS (well-known community)\n" |
| 9282 | "Do not advertise to any peer (well-known community)\n" |
| 9283 | "Do not export to next AS (well-known community)\n" |
| 9284 | "community number\n" |
| 9285 | "Do not send outside local AS (well-known community)\n" |
| 9286 | "Do not advertise to any peer (well-known community)\n" |
| 9287 | "Do not export to next AS (well-known community)\n") |
| 9288 | |
| 9289 | ALIAS (show_ip_bgp_ipv4_community, |
| 9290 | show_ip_bgp_ipv4_community3_cmd, |
| 9291 | "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)", |
| 9292 | SHOW_STR |
| 9293 | IP_STR |
| 9294 | BGP_STR |
| 9295 | "Address family\n" |
| 9296 | "Address Family modifier\n" |
| 9297 | "Address Family modifier\n" |
| 9298 | "Display routes matching the communities\n" |
| 9299 | "community number\n" |
| 9300 | "Do not send outside local AS (well-known community)\n" |
| 9301 | "Do not advertise to any peer (well-known community)\n" |
| 9302 | "Do not export to next AS (well-known community)\n" |
| 9303 | "community number\n" |
| 9304 | "Do not send outside local AS (well-known community)\n" |
| 9305 | "Do not advertise to any peer (well-known community)\n" |
| 9306 | "Do not export to next AS (well-known community)\n" |
| 9307 | "community number\n" |
| 9308 | "Do not send outside local AS (well-known community)\n" |
| 9309 | "Do not advertise to any peer (well-known community)\n" |
| 9310 | "Do not export to next AS (well-known community)\n") |
| 9311 | |
| 9312 | ALIAS (show_ip_bgp_ipv4_community, |
| 9313 | show_ip_bgp_ipv4_community4_cmd, |
| 9314 | "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)", |
| 9315 | SHOW_STR |
| 9316 | IP_STR |
| 9317 | BGP_STR |
| 9318 | "Address family\n" |
| 9319 | "Address Family modifier\n" |
| 9320 | "Address Family modifier\n" |
| 9321 | "Display routes matching the communities\n" |
| 9322 | "community number\n" |
| 9323 | "Do not send outside local AS (well-known community)\n" |
| 9324 | "Do not advertise to any peer (well-known community)\n" |
| 9325 | "Do not export to next AS (well-known community)\n" |
| 9326 | "community number\n" |
| 9327 | "Do not send outside local AS (well-known community)\n" |
| 9328 | "Do not advertise to any peer (well-known community)\n" |
| 9329 | "Do not export to next AS (well-known community)\n" |
| 9330 | "community number\n" |
| 9331 | "Do not send outside local AS (well-known community)\n" |
| 9332 | "Do not advertise to any peer (well-known community)\n" |
| 9333 | "Do not export to next AS (well-known community)\n" |
| 9334 | "community number\n" |
| 9335 | "Do not send outside local AS (well-known community)\n" |
| 9336 | "Do not advertise to any peer (well-known community)\n" |
| 9337 | "Do not export to next AS (well-known community)\n") |
| 9338 | |
| 9339 | DEFUN (show_ip_bgp_community_exact, |
| 9340 | show_ip_bgp_community_exact_cmd, |
| 9341 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9342 | SHOW_STR |
| 9343 | IP_STR |
| 9344 | BGP_STR |
| 9345 | "Display routes matching the communities\n" |
| 9346 | "community number\n" |
| 9347 | "Do not send outside local AS (well-known community)\n" |
| 9348 | "Do not advertise to any peer (well-known community)\n" |
| 9349 | "Do not export to next AS (well-known community)\n" |
| 9350 | "Exact match of the communities") |
| 9351 | { |
| 9352 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9353 | } |
| 9354 | |
| 9355 | ALIAS (show_ip_bgp_community_exact, |
| 9356 | show_ip_bgp_community2_exact_cmd, |
| 9357 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9358 | SHOW_STR |
| 9359 | IP_STR |
| 9360 | BGP_STR |
| 9361 | "Display routes matching the communities\n" |
| 9362 | "community number\n" |
| 9363 | "Do not send outside local AS (well-known community)\n" |
| 9364 | "Do not advertise to any peer (well-known community)\n" |
| 9365 | "Do not export to next AS (well-known community)\n" |
| 9366 | "community number\n" |
| 9367 | "Do not send outside local AS (well-known community)\n" |
| 9368 | "Do not advertise to any peer (well-known community)\n" |
| 9369 | "Do not export to next AS (well-known community)\n" |
| 9370 | "Exact match of the communities") |
| 9371 | |
| 9372 | ALIAS (show_ip_bgp_community_exact, |
| 9373 | show_ip_bgp_community3_exact_cmd, |
| 9374 | "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", |
| 9375 | SHOW_STR |
| 9376 | IP_STR |
| 9377 | BGP_STR |
| 9378 | "Display routes matching the communities\n" |
| 9379 | "community number\n" |
| 9380 | "Do not send outside local AS (well-known community)\n" |
| 9381 | "Do not advertise to any peer (well-known community)\n" |
| 9382 | "Do not export to next AS (well-known community)\n" |
| 9383 | "community number\n" |
| 9384 | "Do not send outside local AS (well-known community)\n" |
| 9385 | "Do not advertise to any peer (well-known community)\n" |
| 9386 | "Do not export to next AS (well-known community)\n" |
| 9387 | "community number\n" |
| 9388 | "Do not send outside local AS (well-known community)\n" |
| 9389 | "Do not advertise to any peer (well-known community)\n" |
| 9390 | "Do not export to next AS (well-known community)\n" |
| 9391 | "Exact match of the communities") |
| 9392 | |
| 9393 | ALIAS (show_ip_bgp_community_exact, |
| 9394 | show_ip_bgp_community4_exact_cmd, |
| 9395 | "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", |
| 9396 | SHOW_STR |
| 9397 | IP_STR |
| 9398 | BGP_STR |
| 9399 | "Display routes matching the communities\n" |
| 9400 | "community number\n" |
| 9401 | "Do not send outside local AS (well-known community)\n" |
| 9402 | "Do not advertise to any peer (well-known community)\n" |
| 9403 | "Do not export to next AS (well-known community)\n" |
| 9404 | "community number\n" |
| 9405 | "Do not send outside local AS (well-known community)\n" |
| 9406 | "Do not advertise to any peer (well-known community)\n" |
| 9407 | "Do not export to next AS (well-known community)\n" |
| 9408 | "community number\n" |
| 9409 | "Do not send outside local AS (well-known community)\n" |
| 9410 | "Do not advertise to any peer (well-known community)\n" |
| 9411 | "Do not export to next AS (well-known community)\n" |
| 9412 | "community number\n" |
| 9413 | "Do not send outside local AS (well-known community)\n" |
| 9414 | "Do not advertise to any peer (well-known community)\n" |
| 9415 | "Do not export to next AS (well-known community)\n" |
| 9416 | "Exact match of the communities") |
| 9417 | |
| 9418 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 9419 | show_ip_bgp_ipv4_community_exact_cmd, |
| 9420 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9421 | SHOW_STR |
| 9422 | IP_STR |
| 9423 | BGP_STR |
| 9424 | "Address family\n" |
| 9425 | "Address Family modifier\n" |
| 9426 | "Address Family modifier\n" |
| 9427 | "Display routes matching the communities\n" |
| 9428 | "community number\n" |
| 9429 | "Do not send outside local AS (well-known community)\n" |
| 9430 | "Do not advertise to any peer (well-known community)\n" |
| 9431 | "Do not export to next AS (well-known community)\n" |
| 9432 | "Exact match of the communities") |
| 9433 | { |
| 9434 | if (strncmp (argv[0], "m", 1) == 0) |
| 9435 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 9436 | |
| 9437 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9438 | } |
| 9439 | |
| 9440 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9441 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 9442 | "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", |
| 9443 | SHOW_STR |
| 9444 | IP_STR |
| 9445 | BGP_STR |
| 9446 | "Address family\n" |
| 9447 | "Address Family modifier\n" |
| 9448 | "Address Family modifier\n" |
| 9449 | "Display routes matching the communities\n" |
| 9450 | "community number\n" |
| 9451 | "Do not send outside local AS (well-known community)\n" |
| 9452 | "Do not advertise to any peer (well-known community)\n" |
| 9453 | "Do not export to next AS (well-known community)\n" |
| 9454 | "community number\n" |
| 9455 | "Do not send outside local AS (well-known community)\n" |
| 9456 | "Do not advertise to any peer (well-known community)\n" |
| 9457 | "Do not export to next AS (well-known community)\n" |
| 9458 | "Exact match of the communities") |
| 9459 | |
| 9460 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9461 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 9462 | "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", |
| 9463 | SHOW_STR |
| 9464 | IP_STR |
| 9465 | BGP_STR |
| 9466 | "Address family\n" |
| 9467 | "Address Family modifier\n" |
| 9468 | "Address Family modifier\n" |
| 9469 | "Display routes matching the communities\n" |
| 9470 | "community number\n" |
| 9471 | "Do not send outside local AS (well-known community)\n" |
| 9472 | "Do not advertise to any peer (well-known community)\n" |
| 9473 | "Do not export to next AS (well-known community)\n" |
| 9474 | "community number\n" |
| 9475 | "Do not send outside local AS (well-known community)\n" |
| 9476 | "Do not advertise to any peer (well-known community)\n" |
| 9477 | "Do not export to next AS (well-known community)\n" |
| 9478 | "community number\n" |
| 9479 | "Do not send outside local AS (well-known community)\n" |
| 9480 | "Do not advertise to any peer (well-known community)\n" |
| 9481 | "Do not export to next AS (well-known community)\n" |
| 9482 | "Exact match of the communities") |
| 9483 | |
| 9484 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9485 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 9486 | "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", |
| 9487 | SHOW_STR |
| 9488 | IP_STR |
| 9489 | BGP_STR |
| 9490 | "Address family\n" |
| 9491 | "Address Family modifier\n" |
| 9492 | "Address Family modifier\n" |
| 9493 | "Display routes matching the communities\n" |
| 9494 | "community number\n" |
| 9495 | "Do not send outside local AS (well-known community)\n" |
| 9496 | "Do not advertise to any peer (well-known community)\n" |
| 9497 | "Do not export to next AS (well-known community)\n" |
| 9498 | "community number\n" |
| 9499 | "Do not send outside local AS (well-known community)\n" |
| 9500 | "Do not advertise to any peer (well-known community)\n" |
| 9501 | "Do not export to next AS (well-known community)\n" |
| 9502 | "community number\n" |
| 9503 | "Do not send outside local AS (well-known community)\n" |
| 9504 | "Do not advertise to any peer (well-known community)\n" |
| 9505 | "Do not export to next AS (well-known community)\n" |
| 9506 | "community number\n" |
| 9507 | "Do not send outside local AS (well-known community)\n" |
| 9508 | "Do not advertise to any peer (well-known community)\n" |
| 9509 | "Do not export to next AS (well-known community)\n" |
| 9510 | "Exact match of the communities") |
| 9511 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9512 | DEFUN (show_bgp_community, |
| 9513 | show_bgp_community_cmd, |
| 9514 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9515 | SHOW_STR |
| 9516 | BGP_STR |
| 9517 | "Display routes matching the communities\n" |
| 9518 | "community number\n" |
| 9519 | "Do not send outside local AS (well-known community)\n" |
| 9520 | "Do not advertise to any peer (well-known community)\n" |
| 9521 | "Do not export to next AS (well-known community)\n") |
| 9522 | { |
| 9523 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9524 | } |
| 9525 | |
| 9526 | ALIAS (show_bgp_community, |
| 9527 | show_bgp_ipv6_community_cmd, |
| 9528 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 9529 | SHOW_STR |
| 9530 | BGP_STR |
| 9531 | "Address family\n" |
| 9532 | "Display routes matching the communities\n" |
| 9533 | "community number\n" |
| 9534 | "Do not send outside local AS (well-known community)\n" |
| 9535 | "Do not advertise to any peer (well-known community)\n" |
| 9536 | "Do not export to next AS (well-known community)\n") |
| 9537 | |
| 9538 | ALIAS (show_bgp_community, |
| 9539 | show_bgp_community2_cmd, |
| 9540 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9541 | SHOW_STR |
| 9542 | BGP_STR |
| 9543 | "Display routes matching the communities\n" |
| 9544 | "community number\n" |
| 9545 | "Do not send outside local AS (well-known community)\n" |
| 9546 | "Do not advertise to any peer (well-known community)\n" |
| 9547 | "Do not export to next AS (well-known community)\n" |
| 9548 | "community number\n" |
| 9549 | "Do not send outside local AS (well-known community)\n" |
| 9550 | "Do not advertise to any peer (well-known community)\n" |
| 9551 | "Do not export to next AS (well-known community)\n") |
| 9552 | |
| 9553 | ALIAS (show_bgp_community, |
| 9554 | show_bgp_ipv6_community2_cmd, |
| 9555 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9556 | SHOW_STR |
| 9557 | BGP_STR |
| 9558 | "Address family\n" |
| 9559 | "Display routes matching the communities\n" |
| 9560 | "community number\n" |
| 9561 | "Do not send outside local AS (well-known community)\n" |
| 9562 | "Do not advertise to any peer (well-known community)\n" |
| 9563 | "Do not export to next AS (well-known community)\n" |
| 9564 | "community number\n" |
| 9565 | "Do not send outside local AS (well-known community)\n" |
| 9566 | "Do not advertise to any peer (well-known community)\n" |
| 9567 | "Do not export to next AS (well-known community)\n") |
| 9568 | |
| 9569 | ALIAS (show_bgp_community, |
| 9570 | show_bgp_community3_cmd, |
| 9571 | "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)", |
| 9572 | SHOW_STR |
| 9573 | BGP_STR |
| 9574 | "Display routes matching the communities\n" |
| 9575 | "community number\n" |
| 9576 | "Do not send outside local AS (well-known community)\n" |
| 9577 | "Do not advertise to any peer (well-known community)\n" |
| 9578 | "Do not export to next AS (well-known community)\n" |
| 9579 | "community number\n" |
| 9580 | "Do not send outside local AS (well-known community)\n" |
| 9581 | "Do not advertise to any peer (well-known community)\n" |
| 9582 | "Do not export to next AS (well-known community)\n" |
| 9583 | "community number\n" |
| 9584 | "Do not send outside local AS (well-known community)\n" |
| 9585 | "Do not advertise to any peer (well-known community)\n" |
| 9586 | "Do not export to next AS (well-known community)\n") |
| 9587 | |
| 9588 | ALIAS (show_bgp_community, |
| 9589 | show_bgp_ipv6_community3_cmd, |
| 9590 | "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)", |
| 9591 | SHOW_STR |
| 9592 | BGP_STR |
| 9593 | "Address family\n" |
| 9594 | "Display routes matching the communities\n" |
| 9595 | "community number\n" |
| 9596 | "Do not send outside local AS (well-known community)\n" |
| 9597 | "Do not advertise to any peer (well-known community)\n" |
| 9598 | "Do not export to next AS (well-known community)\n" |
| 9599 | "community number\n" |
| 9600 | "Do not send outside local AS (well-known community)\n" |
| 9601 | "Do not advertise to any peer (well-known community)\n" |
| 9602 | "Do not export to next AS (well-known community)\n" |
| 9603 | "community number\n" |
| 9604 | "Do not send outside local AS (well-known community)\n" |
| 9605 | "Do not advertise to any peer (well-known community)\n" |
| 9606 | "Do not export to next AS (well-known community)\n") |
| 9607 | |
| 9608 | ALIAS (show_bgp_community, |
| 9609 | show_bgp_community4_cmd, |
| 9610 | "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)", |
| 9611 | SHOW_STR |
| 9612 | BGP_STR |
| 9613 | "Display routes matching the communities\n" |
| 9614 | "community number\n" |
| 9615 | "Do not send outside local AS (well-known community)\n" |
| 9616 | "Do not advertise to any peer (well-known community)\n" |
| 9617 | "Do not export to next AS (well-known community)\n" |
| 9618 | "community number\n" |
| 9619 | "Do not send outside local AS (well-known community)\n" |
| 9620 | "Do not advertise to any peer (well-known community)\n" |
| 9621 | "Do not export to next AS (well-known community)\n" |
| 9622 | "community number\n" |
| 9623 | "Do not send outside local AS (well-known community)\n" |
| 9624 | "Do not advertise to any peer (well-known community)\n" |
| 9625 | "Do not export to next AS (well-known community)\n" |
| 9626 | "community number\n" |
| 9627 | "Do not send outside local AS (well-known community)\n" |
| 9628 | "Do not advertise to any peer (well-known community)\n" |
| 9629 | "Do not export to next AS (well-known community)\n") |
| 9630 | |
| 9631 | ALIAS (show_bgp_community, |
| 9632 | show_bgp_ipv6_community4_cmd, |
| 9633 | "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)", |
| 9634 | SHOW_STR |
| 9635 | BGP_STR |
| 9636 | "Address family\n" |
| 9637 | "Display routes matching the communities\n" |
| 9638 | "community number\n" |
| 9639 | "Do not send outside local AS (well-known community)\n" |
| 9640 | "Do not advertise to any peer (well-known community)\n" |
| 9641 | "Do not export to next AS (well-known community)\n" |
| 9642 | "community number\n" |
| 9643 | "Do not send outside local AS (well-known community)\n" |
| 9644 | "Do not advertise to any peer (well-known community)\n" |
| 9645 | "Do not export to next AS (well-known community)\n" |
| 9646 | "community number\n" |
| 9647 | "Do not send outside local AS (well-known community)\n" |
| 9648 | "Do not advertise to any peer (well-known community)\n" |
| 9649 | "Do not export to next AS (well-known community)\n" |
| 9650 | "community number\n" |
| 9651 | "Do not send outside local AS (well-known community)\n" |
| 9652 | "Do not advertise to any peer (well-known community)\n" |
| 9653 | "Do not export to next AS (well-known community)\n") |
| 9654 | |
| 9655 | /* old command */ |
| 9656 | DEFUN (show_ipv6_bgp_community, |
| 9657 | show_ipv6_bgp_community_cmd, |
| 9658 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9659 | SHOW_STR |
| 9660 | IPV6_STR |
| 9661 | BGP_STR |
| 9662 | "Display routes matching the communities\n" |
| 9663 | "community number\n" |
| 9664 | "Do not send outside local AS (well-known community)\n" |
| 9665 | "Do not advertise to any peer (well-known community)\n" |
| 9666 | "Do not export to next AS (well-known community)\n") |
| 9667 | { |
| 9668 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9669 | } |
| 9670 | |
| 9671 | /* old command */ |
| 9672 | ALIAS (show_ipv6_bgp_community, |
| 9673 | show_ipv6_bgp_community2_cmd, |
| 9674 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9675 | SHOW_STR |
| 9676 | IPV6_STR |
| 9677 | BGP_STR |
| 9678 | "Display routes matching the communities\n" |
| 9679 | "community number\n" |
| 9680 | "Do not send outside local AS (well-known community)\n" |
| 9681 | "Do not advertise to any peer (well-known community)\n" |
| 9682 | "Do not export to next AS (well-known community)\n" |
| 9683 | "community number\n" |
| 9684 | "Do not send outside local AS (well-known community)\n" |
| 9685 | "Do not advertise to any peer (well-known community)\n" |
| 9686 | "Do not export to next AS (well-known community)\n") |
| 9687 | |
| 9688 | /* old command */ |
| 9689 | ALIAS (show_ipv6_bgp_community, |
| 9690 | show_ipv6_bgp_community3_cmd, |
| 9691 | "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)", |
| 9692 | SHOW_STR |
| 9693 | IPV6_STR |
| 9694 | BGP_STR |
| 9695 | "Display routes matching the communities\n" |
| 9696 | "community number\n" |
| 9697 | "Do not send outside local AS (well-known community)\n" |
| 9698 | "Do not advertise to any peer (well-known community)\n" |
| 9699 | "Do not export to next AS (well-known community)\n" |
| 9700 | "community number\n" |
| 9701 | "Do not send outside local AS (well-known community)\n" |
| 9702 | "Do not advertise to any peer (well-known community)\n" |
| 9703 | "Do not export to next AS (well-known community)\n" |
| 9704 | "community number\n" |
| 9705 | "Do not send outside local AS (well-known community)\n" |
| 9706 | "Do not advertise to any peer (well-known community)\n" |
| 9707 | "Do not export to next AS (well-known community)\n") |
| 9708 | |
| 9709 | /* old command */ |
| 9710 | ALIAS (show_ipv6_bgp_community, |
| 9711 | show_ipv6_bgp_community4_cmd, |
| 9712 | "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)", |
| 9713 | SHOW_STR |
| 9714 | IPV6_STR |
| 9715 | BGP_STR |
| 9716 | "Display routes matching the communities\n" |
| 9717 | "community number\n" |
| 9718 | "Do not send outside local AS (well-known community)\n" |
| 9719 | "Do not advertise to any peer (well-known community)\n" |
| 9720 | "Do not export to next AS (well-known community)\n" |
| 9721 | "community number\n" |
| 9722 | "Do not send outside local AS (well-known community)\n" |
| 9723 | "Do not advertise to any peer (well-known community)\n" |
| 9724 | "Do not export to next AS (well-known community)\n" |
| 9725 | "community number\n" |
| 9726 | "Do not send outside local AS (well-known community)\n" |
| 9727 | "Do not advertise to any peer (well-known community)\n" |
| 9728 | "Do not export to next AS (well-known community)\n" |
| 9729 | "community number\n" |
| 9730 | "Do not send outside local AS (well-known community)\n" |
| 9731 | "Do not advertise to any peer (well-known community)\n" |
| 9732 | "Do not export to next AS (well-known community)\n") |
| 9733 | |
| 9734 | DEFUN (show_bgp_community_exact, |
| 9735 | show_bgp_community_exact_cmd, |
| 9736 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9737 | SHOW_STR |
| 9738 | BGP_STR |
| 9739 | "Display routes matching the communities\n" |
| 9740 | "community number\n" |
| 9741 | "Do not send outside local AS (well-known community)\n" |
| 9742 | "Do not advertise to any peer (well-known community)\n" |
| 9743 | "Do not export to next AS (well-known community)\n" |
| 9744 | "Exact match of the communities") |
| 9745 | { |
| 9746 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 9747 | } |
| 9748 | |
| 9749 | ALIAS (show_bgp_community_exact, |
| 9750 | show_bgp_ipv6_community_exact_cmd, |
| 9751 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9752 | SHOW_STR |
| 9753 | BGP_STR |
| 9754 | "Address family\n" |
| 9755 | "Display routes matching the communities\n" |
| 9756 | "community number\n" |
| 9757 | "Do not send outside local AS (well-known community)\n" |
| 9758 | "Do not advertise to any peer (well-known community)\n" |
| 9759 | "Do not export to next AS (well-known community)\n" |
| 9760 | "Exact match of the communities") |
| 9761 | |
| 9762 | ALIAS (show_bgp_community_exact, |
| 9763 | show_bgp_community2_exact_cmd, |
| 9764 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9765 | SHOW_STR |
| 9766 | BGP_STR |
| 9767 | "Display routes matching the communities\n" |
| 9768 | "community number\n" |
| 9769 | "Do not send outside local AS (well-known community)\n" |
| 9770 | "Do not advertise to any peer (well-known community)\n" |
| 9771 | "Do not export to next AS (well-known community)\n" |
| 9772 | "community number\n" |
| 9773 | "Do not send outside local AS (well-known community)\n" |
| 9774 | "Do not advertise to any peer (well-known community)\n" |
| 9775 | "Do not export to next AS (well-known community)\n" |
| 9776 | "Exact match of the communities") |
| 9777 | |
| 9778 | ALIAS (show_bgp_community_exact, |
| 9779 | show_bgp_ipv6_community2_exact_cmd, |
| 9780 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9781 | SHOW_STR |
| 9782 | BGP_STR |
| 9783 | "Address family\n" |
| 9784 | "Display routes matching the communities\n" |
| 9785 | "community number\n" |
| 9786 | "Do not send outside local AS (well-known community)\n" |
| 9787 | "Do not advertise to any peer (well-known community)\n" |
| 9788 | "Do not export to next AS (well-known community)\n" |
| 9789 | "community number\n" |
| 9790 | "Do not send outside local AS (well-known community)\n" |
| 9791 | "Do not advertise to any peer (well-known community)\n" |
| 9792 | "Do not export to next AS (well-known community)\n" |
| 9793 | "Exact match of the communities") |
| 9794 | |
| 9795 | ALIAS (show_bgp_community_exact, |
| 9796 | show_bgp_community3_exact_cmd, |
| 9797 | "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", |
| 9798 | SHOW_STR |
| 9799 | BGP_STR |
| 9800 | "Display routes matching the communities\n" |
| 9801 | "community number\n" |
| 9802 | "Do not send outside local AS (well-known community)\n" |
| 9803 | "Do not advertise to any peer (well-known community)\n" |
| 9804 | "Do not export to next AS (well-known community)\n" |
| 9805 | "community number\n" |
| 9806 | "Do not send outside local AS (well-known community)\n" |
| 9807 | "Do not advertise to any peer (well-known community)\n" |
| 9808 | "Do not export to next AS (well-known community)\n" |
| 9809 | "community number\n" |
| 9810 | "Do not send outside local AS (well-known community)\n" |
| 9811 | "Do not advertise to any peer (well-known community)\n" |
| 9812 | "Do not export to next AS (well-known community)\n" |
| 9813 | "Exact match of the communities") |
| 9814 | |
| 9815 | ALIAS (show_bgp_community_exact, |
| 9816 | show_bgp_ipv6_community3_exact_cmd, |
| 9817 | "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", |
| 9818 | SHOW_STR |
| 9819 | BGP_STR |
| 9820 | "Address family\n" |
| 9821 | "Display routes matching the communities\n" |
| 9822 | "community number\n" |
| 9823 | "Do not send outside local AS (well-known community)\n" |
| 9824 | "Do not advertise to any peer (well-known community)\n" |
| 9825 | "Do not export to next AS (well-known community)\n" |
| 9826 | "community number\n" |
| 9827 | "Do not send outside local AS (well-known community)\n" |
| 9828 | "Do not advertise to any peer (well-known community)\n" |
| 9829 | "Do not export to next AS (well-known community)\n" |
| 9830 | "community number\n" |
| 9831 | "Do not send outside local AS (well-known community)\n" |
| 9832 | "Do not advertise to any peer (well-known community)\n" |
| 9833 | "Do not export to next AS (well-known community)\n" |
| 9834 | "Exact match of the communities") |
| 9835 | |
| 9836 | ALIAS (show_bgp_community_exact, |
| 9837 | show_bgp_community4_exact_cmd, |
| 9838 | "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", |
| 9839 | SHOW_STR |
| 9840 | BGP_STR |
| 9841 | "Display routes matching the communities\n" |
| 9842 | "community number\n" |
| 9843 | "Do not send outside local AS (well-known community)\n" |
| 9844 | "Do not advertise to any peer (well-known community)\n" |
| 9845 | "Do not export to next AS (well-known community)\n" |
| 9846 | "community number\n" |
| 9847 | "Do not send outside local AS (well-known community)\n" |
| 9848 | "Do not advertise to any peer (well-known community)\n" |
| 9849 | "Do not export to next AS (well-known community)\n" |
| 9850 | "community number\n" |
| 9851 | "Do not send outside local AS (well-known community)\n" |
| 9852 | "Do not advertise to any peer (well-known community)\n" |
| 9853 | "Do not export to next AS (well-known community)\n" |
| 9854 | "community number\n" |
| 9855 | "Do not send outside local AS (well-known community)\n" |
| 9856 | "Do not advertise to any peer (well-known community)\n" |
| 9857 | "Do not export to next AS (well-known community)\n" |
| 9858 | "Exact match of the communities") |
| 9859 | |
| 9860 | ALIAS (show_bgp_community_exact, |
| 9861 | show_bgp_ipv6_community4_exact_cmd, |
| 9862 | "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", |
| 9863 | SHOW_STR |
| 9864 | BGP_STR |
| 9865 | "Address family\n" |
| 9866 | "Display routes matching the communities\n" |
| 9867 | "community number\n" |
| 9868 | "Do not send outside local AS (well-known community)\n" |
| 9869 | "Do not advertise to any peer (well-known community)\n" |
| 9870 | "Do not export to next AS (well-known community)\n" |
| 9871 | "community number\n" |
| 9872 | "Do not send outside local AS (well-known community)\n" |
| 9873 | "Do not advertise to any peer (well-known community)\n" |
| 9874 | "Do not export to next AS (well-known community)\n" |
| 9875 | "community number\n" |
| 9876 | "Do not send outside local AS (well-known community)\n" |
| 9877 | "Do not advertise to any peer (well-known community)\n" |
| 9878 | "Do not export to next AS (well-known community)\n" |
| 9879 | "community number\n" |
| 9880 | "Do not send outside local AS (well-known community)\n" |
| 9881 | "Do not advertise to any peer (well-known community)\n" |
| 9882 | "Do not export to next AS (well-known community)\n" |
| 9883 | "Exact match of the communities") |
| 9884 | |
| 9885 | /* old command */ |
| 9886 | DEFUN (show_ipv6_bgp_community_exact, |
| 9887 | show_ipv6_bgp_community_exact_cmd, |
| 9888 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9889 | SHOW_STR |
| 9890 | IPV6_STR |
| 9891 | BGP_STR |
| 9892 | "Display routes matching the communities\n" |
| 9893 | "community number\n" |
| 9894 | "Do not send outside local AS (well-known community)\n" |
| 9895 | "Do not advertise to any peer (well-known community)\n" |
| 9896 | "Do not export to next AS (well-known community)\n" |
| 9897 | "Exact match of the communities") |
| 9898 | { |
| 9899 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 9900 | } |
| 9901 | |
| 9902 | /* old command */ |
| 9903 | ALIAS (show_ipv6_bgp_community_exact, |
| 9904 | show_ipv6_bgp_community2_exact_cmd, |
| 9905 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9906 | SHOW_STR |
| 9907 | IPV6_STR |
| 9908 | BGP_STR |
| 9909 | "Display routes matching the communities\n" |
| 9910 | "community number\n" |
| 9911 | "Do not send outside local AS (well-known community)\n" |
| 9912 | "Do not advertise to any peer (well-known community)\n" |
| 9913 | "Do not export to next AS (well-known community)\n" |
| 9914 | "community number\n" |
| 9915 | "Do not send outside local AS (well-known community)\n" |
| 9916 | "Do not advertise to any peer (well-known community)\n" |
| 9917 | "Do not export to next AS (well-known community)\n" |
| 9918 | "Exact match of the communities") |
| 9919 | |
| 9920 | /* old command */ |
| 9921 | ALIAS (show_ipv6_bgp_community_exact, |
| 9922 | show_ipv6_bgp_community3_exact_cmd, |
| 9923 | "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", |
| 9924 | SHOW_STR |
| 9925 | IPV6_STR |
| 9926 | BGP_STR |
| 9927 | "Display routes matching the communities\n" |
| 9928 | "community number\n" |
| 9929 | "Do not send outside local AS (well-known community)\n" |
| 9930 | "Do not advertise to any peer (well-known community)\n" |
| 9931 | "Do not export to next AS (well-known community)\n" |
| 9932 | "community number\n" |
| 9933 | "Do not send outside local AS (well-known community)\n" |
| 9934 | "Do not advertise to any peer (well-known community)\n" |
| 9935 | "Do not export to next AS (well-known community)\n" |
| 9936 | "community number\n" |
| 9937 | "Do not send outside local AS (well-known community)\n" |
| 9938 | "Do not advertise to any peer (well-known community)\n" |
| 9939 | "Do not export to next AS (well-known community)\n" |
| 9940 | "Exact match of the communities") |
| 9941 | |
| 9942 | /* old command */ |
| 9943 | ALIAS (show_ipv6_bgp_community_exact, |
| 9944 | show_ipv6_bgp_community4_exact_cmd, |
| 9945 | "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", |
| 9946 | SHOW_STR |
| 9947 | IPV6_STR |
| 9948 | BGP_STR |
| 9949 | "Display routes matching the communities\n" |
| 9950 | "community number\n" |
| 9951 | "Do not send outside local AS (well-known community)\n" |
| 9952 | "Do not advertise to any peer (well-known community)\n" |
| 9953 | "Do not export to next AS (well-known community)\n" |
| 9954 | "community number\n" |
| 9955 | "Do not send outside local AS (well-known community)\n" |
| 9956 | "Do not advertise to any peer (well-known community)\n" |
| 9957 | "Do not export to next AS (well-known community)\n" |
| 9958 | "community number\n" |
| 9959 | "Do not send outside local AS (well-known community)\n" |
| 9960 | "Do not advertise to any peer (well-known community)\n" |
| 9961 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 9967 | |
| 9968 | /* old command */ |
| 9969 | DEFUN (show_ipv6_mbgp_community, |
| 9970 | show_ipv6_mbgp_community_cmd, |
| 9971 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9972 | SHOW_STR |
| 9973 | IPV6_STR |
| 9974 | MBGP_STR |
| 9975 | "Display routes matching the communities\n" |
| 9976 | "community number\n" |
| 9977 | "Do not send outside local AS (well-known community)\n" |
| 9978 | "Do not advertise to any peer (well-known community)\n" |
| 9979 | "Do not export to next AS (well-known community)\n") |
| 9980 | { |
| 9981 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 9982 | } |
| 9983 | |
| 9984 | /* old command */ |
| 9985 | ALIAS (show_ipv6_mbgp_community, |
| 9986 | show_ipv6_mbgp_community2_cmd, |
| 9987 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9988 | SHOW_STR |
| 9989 | IPV6_STR |
| 9990 | MBGP_STR |
| 9991 | "Display routes matching the communities\n" |
| 9992 | "community number\n" |
| 9993 | "Do not send outside local AS (well-known community)\n" |
| 9994 | "Do not advertise to any peer (well-known community)\n" |
| 9995 | "Do not export to next AS (well-known community)\n" |
| 9996 | "community number\n" |
| 9997 | "Do not send outside local AS (well-known community)\n" |
| 9998 | "Do not advertise to any peer (well-known community)\n" |
| 9999 | "Do not export to next AS (well-known community)\n") |
| 10000 | |
| 10001 | /* old command */ |
| 10002 | ALIAS (show_ipv6_mbgp_community, |
| 10003 | show_ipv6_mbgp_community3_cmd, |
| 10004 | "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)", |
| 10005 | SHOW_STR |
| 10006 | IPV6_STR |
| 10007 | MBGP_STR |
| 10008 | "Display routes matching the communities\n" |
| 10009 | "community number\n" |
| 10010 | "Do not send outside local AS (well-known community)\n" |
| 10011 | "Do not advertise to any peer (well-known community)\n" |
| 10012 | "Do not export to next AS (well-known community)\n" |
| 10013 | "community number\n" |
| 10014 | "Do not send outside local AS (well-known community)\n" |
| 10015 | "Do not advertise to any peer (well-known community)\n" |
| 10016 | "Do not export to next AS (well-known community)\n" |
| 10017 | "community number\n" |
| 10018 | "Do not send outside local AS (well-known community)\n" |
| 10019 | "Do not advertise to any peer (well-known community)\n" |
| 10020 | "Do not export to next AS (well-known community)\n") |
| 10021 | |
| 10022 | /* old command */ |
| 10023 | ALIAS (show_ipv6_mbgp_community, |
| 10024 | show_ipv6_mbgp_community4_cmd, |
| 10025 | "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)", |
| 10026 | SHOW_STR |
| 10027 | IPV6_STR |
| 10028 | MBGP_STR |
| 10029 | "Display routes matching the communities\n" |
| 10030 | "community number\n" |
| 10031 | "Do not send outside local AS (well-known community)\n" |
| 10032 | "Do not advertise to any peer (well-known community)\n" |
| 10033 | "Do not export to next AS (well-known community)\n" |
| 10034 | "community number\n" |
| 10035 | "Do not send outside local AS (well-known community)\n" |
| 10036 | "Do not advertise to any peer (well-known community)\n" |
| 10037 | "Do not export to next AS (well-known community)\n" |
| 10038 | "community number\n" |
| 10039 | "Do not send outside local AS (well-known community)\n" |
| 10040 | "Do not advertise to any peer (well-known community)\n" |
| 10041 | "Do not export to next AS (well-known community)\n" |
| 10042 | "community number\n" |
| 10043 | "Do not send outside local AS (well-known community)\n" |
| 10044 | "Do not advertise to any peer (well-known community)\n" |
| 10045 | "Do not export to next AS (well-known community)\n") |
| 10046 | |
| 10047 | /* old command */ |
| 10048 | DEFUN (show_ipv6_mbgp_community_exact, |
| 10049 | show_ipv6_mbgp_community_exact_cmd, |
| 10050 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10051 | SHOW_STR |
| 10052 | IPV6_STR |
| 10053 | MBGP_STR |
| 10054 | "Display routes matching the communities\n" |
| 10055 | "community number\n" |
| 10056 | "Do not send outside local AS (well-known community)\n" |
| 10057 | "Do not advertise to any peer (well-known community)\n" |
| 10058 | "Do not export to next AS (well-known community)\n" |
| 10059 | "Exact match of the communities") |
| 10060 | { |
| 10061 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 10062 | } |
| 10063 | |
| 10064 | /* old command */ |
| 10065 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10066 | show_ipv6_mbgp_community2_exact_cmd, |
| 10067 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10068 | SHOW_STR |
| 10069 | IPV6_STR |
| 10070 | MBGP_STR |
| 10071 | "Display routes matching the communities\n" |
| 10072 | "community number\n" |
| 10073 | "Do not send outside local AS (well-known community)\n" |
| 10074 | "Do not advertise to any peer (well-known community)\n" |
| 10075 | "Do not export to next AS (well-known community)\n" |
| 10076 | "community number\n" |
| 10077 | "Do not send outside local AS (well-known community)\n" |
| 10078 | "Do not advertise to any peer (well-known community)\n" |
| 10079 | "Do not export to next AS (well-known community)\n" |
| 10080 | "Exact match of the communities") |
| 10081 | |
| 10082 | /* old command */ |
| 10083 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10084 | show_ipv6_mbgp_community3_exact_cmd, |
| 10085 | "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", |
| 10086 | SHOW_STR |
| 10087 | IPV6_STR |
| 10088 | MBGP_STR |
| 10089 | "Display routes matching the communities\n" |
| 10090 | "community number\n" |
| 10091 | "Do not send outside local AS (well-known community)\n" |
| 10092 | "Do not advertise to any peer (well-known community)\n" |
| 10093 | "Do not export to next AS (well-known community)\n" |
| 10094 | "community number\n" |
| 10095 | "Do not send outside local AS (well-known community)\n" |
| 10096 | "Do not advertise to any peer (well-known community)\n" |
| 10097 | "Do not export to next AS (well-known community)\n" |
| 10098 | "community number\n" |
| 10099 | "Do not send outside local AS (well-known community)\n" |
| 10100 | "Do not advertise to any peer (well-known community)\n" |
| 10101 | "Do not export to next AS (well-known community)\n" |
| 10102 | "Exact match of the communities") |
| 10103 | |
| 10104 | /* old command */ |
| 10105 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10106 | show_ipv6_mbgp_community4_exact_cmd, |
| 10107 | "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", |
| 10108 | SHOW_STR |
| 10109 | IPV6_STR |
| 10110 | MBGP_STR |
| 10111 | "Display routes matching the communities\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 | "community number\n" |
| 10117 | "Do not send outside local AS (well-known community)\n" |
| 10118 | "Do not advertise to any peer (well-known community)\n" |
| 10119 | "Do not export to next AS (well-known community)\n" |
| 10120 | "community number\n" |
| 10121 | "Do not send outside local AS (well-known community)\n" |
| 10122 | "Do not advertise to any peer (well-known community)\n" |
| 10123 | "Do not export to next AS (well-known community)\n" |
| 10124 | "community number\n" |
| 10125 | "Do not send outside local AS (well-known community)\n" |
| 10126 | "Do not advertise to any peer (well-known community)\n" |
| 10127 | "Do not export to next AS (well-known community)\n" |
| 10128 | "Exact match of the communities") |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10129 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10130 | DEFUN (show_bgp_ipv4_community, |
| 10131 | show_bgp_ipv4_community_cmd, |
| 10132 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10133 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10134 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10135 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10136 | "Display routes matching the communities\n" |
| 10137 | "community number\n" |
| 10138 | "Do not send outside local AS (well-known community)\n" |
| 10139 | "Do not advertise to any peer (well-known community)\n" |
| 10140 | "Do not export to next AS (well-known community)\n") |
| 10141 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10142 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10143 | } |
| 10144 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10145 | ALIAS (show_bgp_ipv4_community, |
| 10146 | show_bgp_ipv4_community2_cmd, |
| 10147 | "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] | 10148 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10149 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10150 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10151 | "Display routes matching the communities\n" |
| 10152 | "community number\n" |
| 10153 | "Do not send outside local AS (well-known community)\n" |
| 10154 | "Do not advertise to any peer (well-known community)\n" |
| 10155 | "Do not export to next AS (well-known community)\n" |
| 10156 | "community number\n" |
| 10157 | "Do not send outside local AS (well-known community)\n" |
| 10158 | "Do not advertise to any peer (well-known community)\n" |
| 10159 | "Do not export to next AS (well-known community)\n") |
| 10160 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10161 | ALIAS (show_bgp_ipv4_community, |
| 10162 | show_bgp_ipv4_community3_cmd, |
| 10163 | "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] | 10164 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10165 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10166 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10167 | "Display routes matching the communities\n" |
| 10168 | "community number\n" |
| 10169 | "Do not send outside local AS (well-known community)\n" |
| 10170 | "Do not advertise to any peer (well-known community)\n" |
| 10171 | "Do not export to next AS (well-known community)\n" |
| 10172 | "community number\n" |
| 10173 | "Do not send outside local AS (well-known community)\n" |
| 10174 | "Do not advertise to any peer (well-known community)\n" |
| 10175 | "Do not export to next AS (well-known community)\n" |
| 10176 | "community number\n" |
| 10177 | "Do not send outside local AS (well-known community)\n" |
| 10178 | "Do not advertise to any peer (well-known community)\n" |
| 10179 | "Do not export to next AS (well-known community)\n") |
| 10180 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10181 | ALIAS (show_bgp_ipv4_community, |
| 10182 | show_bgp_ipv4_community4_cmd, |
| 10183 | "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] | 10184 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10185 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10186 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10187 | "Display routes matching the communities\n" |
| 10188 | "community number\n" |
| 10189 | "Do not send outside local AS (well-known community)\n" |
| 10190 | "Do not advertise to any peer (well-known community)\n" |
| 10191 | "Do not export to next AS (well-known community)\n" |
| 10192 | "community number\n" |
| 10193 | "Do not send outside local AS (well-known community)\n" |
| 10194 | "Do not advertise to any peer (well-known community)\n" |
| 10195 | "Do not export to next AS (well-known community)\n" |
| 10196 | "community number\n" |
| 10197 | "Do not send outside local AS (well-known community)\n" |
| 10198 | "Do not advertise to any peer (well-known community)\n" |
| 10199 | "Do not export to next AS (well-known community)\n" |
| 10200 | "community number\n" |
| 10201 | "Do not send outside local AS (well-known community)\n" |
| 10202 | "Do not advertise to any peer (well-known community)\n" |
| 10203 | "Do not export to next AS (well-known community)\n") |
| 10204 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10205 | DEFUN (show_bgp_ipv4_safi_community, |
| 10206 | show_bgp_ipv4_safi_community_cmd, |
| 10207 | "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] | 10208 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10209 | BGP_STR |
| 10210 | "Address family\n" |
| 10211 | "Address Family modifier\n" |
| 10212 | "Address Family modifier\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 | { |
| 10219 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10220 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10221 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10222 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10223 | } |
| 10224 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10225 | ALIAS (show_bgp_ipv4_safi_community, |
| 10226 | show_bgp_ipv4_safi_community2_cmd, |
| 10227 | "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] | 10228 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10229 | BGP_STR |
| 10230 | "Address family\n" |
| 10231 | "Address Family modifier\n" |
| 10232 | "Address Family modifier\n" |
| 10233 | "Display routes matching the communities\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 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10243 | ALIAS (show_bgp_ipv4_safi_community, |
| 10244 | show_bgp_ipv4_safi_community3_cmd, |
| 10245 | "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] | 10246 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10247 | BGP_STR |
| 10248 | "Address family\n" |
| 10249 | "Address Family modifier\n" |
| 10250 | "Address Family modifier\n" |
| 10251 | "Display routes matching the communities\n" |
| 10252 | "community number\n" |
| 10253 | "Do not send outside local AS (well-known community)\n" |
| 10254 | "Do not advertise to any peer (well-known community)\n" |
| 10255 | "Do not export to next AS (well-known community)\n" |
| 10256 | "community number\n" |
| 10257 | "Do not send outside local AS (well-known community)\n" |
| 10258 | "Do not advertise to any peer (well-known community)\n" |
| 10259 | "Do not export to next AS (well-known community)\n" |
| 10260 | "community number\n" |
| 10261 | "Do not send outside local AS (well-known community)\n" |
| 10262 | "Do not advertise to any peer (well-known community)\n" |
| 10263 | "Do not export to next AS (well-known community)\n") |
| 10264 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10265 | ALIAS (show_bgp_ipv4_safi_community, |
| 10266 | show_bgp_ipv4_safi_community4_cmd, |
| 10267 | "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] | 10268 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10269 | BGP_STR |
| 10270 | "Address family\n" |
| 10271 | "Address Family modifier\n" |
| 10272 | "Address Family modifier\n" |
| 10273 | "Display routes matching the communities\n" |
| 10274 | "community number\n" |
| 10275 | "Do not send outside local AS (well-known community)\n" |
| 10276 | "Do not advertise to any peer (well-known community)\n" |
| 10277 | "Do not export to next AS (well-known community)\n" |
| 10278 | "community number\n" |
| 10279 | "Do not send outside local AS (well-known community)\n" |
| 10280 | "Do not advertise to any peer (well-known community)\n" |
| 10281 | "Do not export to next AS (well-known community)\n" |
| 10282 | "community number\n" |
| 10283 | "Do not send outside local AS (well-known community)\n" |
| 10284 | "Do not advertise to any peer (well-known community)\n" |
| 10285 | "Do not export to next AS (well-known community)\n" |
| 10286 | "community number\n" |
| 10287 | "Do not send outside local AS (well-known community)\n" |
| 10288 | "Do not advertise to any peer (well-known community)\n" |
| 10289 | "Do not export to next AS (well-known community)\n") |
| 10290 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10291 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 10292 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10293 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10294 | SHOW_STR |
| 10295 | BGP_STR |
| 10296 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10297 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10298 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10299 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10300 | "Address Family modifier\n" |
| 10301 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10302 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10303 | { |
| 10304 | int afi; |
| 10305 | int safi; |
| 10306 | struct bgp *bgp; |
| 10307 | |
| 10308 | /* BGP structure lookup. */ |
| 10309 | bgp = bgp_lookup_by_name (argv[0]); |
| 10310 | if (bgp == NULL) |
| 10311 | { |
| 10312 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10313 | return CMD_WARNING; |
| 10314 | } |
| 10315 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10316 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10317 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10318 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 10319 | } |
| 10320 | |
| 10321 | DEFUN (show_bgp_view_afi_safi_community, |
| 10322 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10323 | "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] | 10324 | SHOW_STR |
| 10325 | BGP_STR |
| 10326 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10327 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10328 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10329 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10330 | "Address family modifier\n" |
| 10331 | "Address family modifier\n" |
| 10332 | "Display routes matching the communities\n" |
| 10333 | "community number\n" |
| 10334 | "Do not send outside local AS (well-known community)\n" |
| 10335 | "Do not advertise to any peer (well-known community)\n" |
| 10336 | "Do not export to next AS (well-known community)\n") |
| 10337 | { |
| 10338 | int afi; |
| 10339 | int safi; |
| 10340 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10341 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10342 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10343 | 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] | 10344 | } |
| 10345 | |
| 10346 | ALIAS (show_bgp_view_afi_safi_community, |
| 10347 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10348 | "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] | 10349 | SHOW_STR |
| 10350 | BGP_STR |
| 10351 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10352 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10353 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10354 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10355 | "Address family modifier\n" |
| 10356 | "Address family modifier\n" |
| 10357 | "Display routes matching the communities\n" |
| 10358 | "community number\n" |
| 10359 | "Do not send outside local AS (well-known community)\n" |
| 10360 | "Do not advertise to any peer (well-known community)\n" |
| 10361 | "Do not export to next AS (well-known community)\n" |
| 10362 | "community number\n" |
| 10363 | "Do not send outside local AS (well-known community)\n" |
| 10364 | "Do not advertise to any peer (well-known community)\n" |
| 10365 | "Do not export to next AS (well-known community)\n") |
| 10366 | |
| 10367 | ALIAS (show_bgp_view_afi_safi_community, |
| 10368 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10369 | "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] | 10370 | SHOW_STR |
| 10371 | BGP_STR |
| 10372 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10373 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10374 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10375 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10376 | "Address family modifier\n" |
| 10377 | "Address family modifier\n" |
| 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 | |
| 10392 | ALIAS (show_bgp_view_afi_safi_community, |
| 10393 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10394 | "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] | 10395 | SHOW_STR |
| 10396 | BGP_STR |
| 10397 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10398 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10399 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10400 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10401 | "Address family modifier\n" |
| 10402 | "Address family modifier\n" |
| 10403 | "Display routes matching the communities\n" |
| 10404 | "community number\n" |
| 10405 | "Do not send outside local AS (well-known community)\n" |
| 10406 | "Do not advertise to any peer (well-known community)\n" |
| 10407 | "Do not export to next AS (well-known community)\n" |
| 10408 | "community number\n" |
| 10409 | "Do not send outside local AS (well-known community)\n" |
| 10410 | "Do not advertise to any peer (well-known community)\n" |
| 10411 | "Do not export to next AS (well-known community)\n" |
| 10412 | "community number\n" |
| 10413 | "Do not send outside local AS (well-known community)\n" |
| 10414 | "Do not advertise to any peer (well-known community)\n" |
| 10415 | "Do not export to next AS (well-known community)\n" |
| 10416 | "community number\n" |
| 10417 | "Do not send outside local AS (well-known community)\n" |
| 10418 | "Do not advertise to any peer (well-known community)\n" |
| 10419 | "Do not export to next AS (well-known community)\n") |
| 10420 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10421 | DEFUN (show_bgp_ipv4_community_exact, |
| 10422 | show_bgp_ipv4_community_exact_cmd, |
| 10423 | "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] | 10424 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10425 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10426 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10427 | "Display routes matching the communities\n" |
| 10428 | "community number\n" |
| 10429 | "Do not send outside local AS (well-known community)\n" |
| 10430 | "Do not advertise to any peer (well-known community)\n" |
| 10431 | "Do not export to next AS (well-known community)\n" |
| 10432 | "Exact match of the communities") |
| 10433 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10434 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10435 | } |
| 10436 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10437 | ALIAS (show_bgp_ipv4_community_exact, |
| 10438 | show_bgp_ipv4_community2_exact_cmd, |
| 10439 | "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] | 10440 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10441 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10442 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10443 | "Display routes matching the communities\n" |
| 10444 | "community number\n" |
| 10445 | "Do not send outside local AS (well-known community)\n" |
| 10446 | "Do not advertise to any peer (well-known community)\n" |
| 10447 | "Do not export to next AS (well-known community)\n" |
| 10448 | "community number\n" |
| 10449 | "Do not send outside local AS (well-known community)\n" |
| 10450 | "Do not advertise to any peer (well-known community)\n" |
| 10451 | "Do not export to next AS (well-known community)\n" |
| 10452 | "Exact match of the communities") |
| 10453 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10454 | ALIAS (show_bgp_ipv4_community_exact, |
| 10455 | show_bgp_ipv4_community3_exact_cmd, |
| 10456 | "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] | 10457 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10458 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10459 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10460 | "Display routes matching the communities\n" |
| 10461 | "community number\n" |
| 10462 | "Do not send outside local AS (well-known community)\n" |
| 10463 | "Do not advertise to any peer (well-known community)\n" |
| 10464 | "Do not export to next AS (well-known community)\n" |
| 10465 | "community number\n" |
| 10466 | "Do not send outside local AS (well-known community)\n" |
| 10467 | "Do not advertise to any peer (well-known community)\n" |
| 10468 | "Do not export to next AS (well-known community)\n" |
| 10469 | "community number\n" |
| 10470 | "Do not send outside local AS (well-known community)\n" |
| 10471 | "Do not advertise to any peer (well-known community)\n" |
| 10472 | "Do not export to next AS (well-known community)\n" |
| 10473 | "Exact match of the communities") |
| 10474 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10475 | ALIAS (show_bgp_ipv4_community_exact, |
| 10476 | show_bgp_ipv4_community4_exact_cmd, |
| 10477 | "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] | 10478 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10479 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10480 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10481 | "Display routes matching the communities\n" |
| 10482 | "community number\n" |
| 10483 | "Do not send outside local AS (well-known community)\n" |
| 10484 | "Do not advertise to any peer (well-known community)\n" |
| 10485 | "Do not export to next AS (well-known community)\n" |
| 10486 | "community number\n" |
| 10487 | "Do not send outside local AS (well-known community)\n" |
| 10488 | "Do not advertise to any peer (well-known community)\n" |
| 10489 | "Do not export to next AS (well-known community)\n" |
| 10490 | "community number\n" |
| 10491 | "Do not send outside local AS (well-known community)\n" |
| 10492 | "Do not advertise to any peer (well-known community)\n" |
| 10493 | "Do not export to next AS (well-known community)\n" |
| 10494 | "community number\n" |
| 10495 | "Do not send outside local AS (well-known community)\n" |
| 10496 | "Do not advertise to any peer (well-known community)\n" |
| 10497 | "Do not export to next AS (well-known community)\n" |
| 10498 | "Exact match of the communities") |
| 10499 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10500 | DEFUN (show_bgp_ipv4_safi_community4_exact, |
| 10501 | show_bgp_ipv4_safi_community_exact_cmd, |
| 10502 | "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] | 10503 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10504 | BGP_STR |
| 10505 | "Address family\n" |
| 10506 | "Address Family modifier\n" |
| 10507 | "Address Family modifier\n" |
| 10508 | "Display routes matching the communities\n" |
| 10509 | "community number\n" |
| 10510 | "Do not send outside local AS (well-known community)\n" |
| 10511 | "Do not advertise to any peer (well-known community)\n" |
| 10512 | "Do not export to next AS (well-known community)\n" |
| 10513 | "Exact match of the communities") |
| 10514 | { |
| 10515 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10516 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10517 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10518 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10519 | } |
| 10520 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10521 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10522 | show_bgp_ipv4_safi_community2_exact_cmd, |
| 10523 | "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] | 10524 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10525 | BGP_STR |
| 10526 | "Address family\n" |
| 10527 | "Address Family modifier\n" |
| 10528 | "Address Family modifier\n" |
| 10529 | "Display routes matching the communities\n" |
| 10530 | "community number\n" |
| 10531 | "Do not send outside local AS (well-known community)\n" |
| 10532 | "Do not advertise to any peer (well-known community)\n" |
| 10533 | "Do not export to next AS (well-known community)\n" |
| 10534 | "community number\n" |
| 10535 | "Do not send outside local AS (well-known community)\n" |
| 10536 | "Do not advertise to any peer (well-known community)\n" |
| 10537 | "Do not export to next AS (well-known community)\n" |
| 10538 | "Exact match of the communities") |
| 10539 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10540 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10541 | show_bgp_ipv4_safi_community3_exact_cmd, |
| 10542 | "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] | 10543 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10544 | BGP_STR |
| 10545 | "Address family\n" |
| 10546 | "Address Family modifier\n" |
| 10547 | "Address Family modifier\n" |
| 10548 | "Display routes matching the communities\n" |
| 10549 | "community number\n" |
| 10550 | "Do not send outside local AS (well-known community)\n" |
| 10551 | "Do not advertise to any peer (well-known community)\n" |
| 10552 | "Do not export to next AS (well-known community)\n" |
| 10553 | "community number\n" |
| 10554 | "Do not send outside local AS (well-known community)\n" |
| 10555 | "Do not advertise to any peer (well-known community)\n" |
| 10556 | "Do not export to next AS (well-known community)\n" |
| 10557 | "community number\n" |
| 10558 | "Do not send outside local AS (well-known community)\n" |
| 10559 | "Do not advertise to any peer (well-known community)\n" |
| 10560 | "Do not export to next AS (well-known community)\n" |
| 10561 | "Exact match of the communities") |
| 10562 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10563 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10564 | show_bgp_ipv4_safi_community4_exact_cmd, |
| 10565 | "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] | 10566 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10567 | BGP_STR |
| 10568 | "Address family\n" |
| 10569 | "Address Family modifier\n" |
| 10570 | "Address Family modifier\n" |
| 10571 | "Display routes matching the communities\n" |
| 10572 | "community number\n" |
| 10573 | "Do not send outside local AS (well-known community)\n" |
| 10574 | "Do not advertise to any peer (well-known community)\n" |
| 10575 | "Do not export to next AS (well-known community)\n" |
| 10576 | "community number\n" |
| 10577 | "Do not send outside local AS (well-known community)\n" |
| 10578 | "Do not advertise to any peer (well-known community)\n" |
| 10579 | "Do not export to next AS (well-known community)\n" |
| 10580 | "community number\n" |
| 10581 | "Do not send outside local AS (well-known community)\n" |
| 10582 | "Do not advertise to any peer (well-known community)\n" |
| 10583 | "Do not export to next AS (well-known community)\n" |
| 10584 | "community number\n" |
| 10585 | "Do not send outside local AS (well-known community)\n" |
| 10586 | "Do not advertise to any peer (well-known community)\n" |
| 10587 | "Do not export to next AS (well-known community)\n" |
| 10588 | "Exact match of the communities") |
| 10589 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10590 | DEFUN (show_bgp_ipv6_safi_community, |
| 10591 | show_bgp_ipv6_safi_community_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10592 | "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] | 10593 | SHOW_STR |
| 10594 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10595 | "Address family\n" |
| 10596 | "Address family modifier\n" |
| 10597 | "Address family modifier\n" |
| 10598 | "Address family modifier\n" |
| 10599 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10600 | "Display routes matching the communities\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 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10606 | safi_t safi; |
| 10607 | |
| 10608 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10609 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10610 | return CMD_WARNING; |
| 10611 | } |
| 10612 | 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] | 10613 | } |
| 10614 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10615 | ALIAS (show_bgp_ipv6_safi_community, |
| 10616 | show_bgp_ipv6_safi_community2_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10617 | "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] | 10618 | SHOW_STR |
| 10619 | BGP_STR |
| 10620 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10621 | "Address family modifier\n" |
| 10622 | "Address family modifier\n" |
| 10623 | "Address family modifier\n" |
| 10624 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10625 | "Display routes matching the communities\n" |
| 10626 | "community number\n" |
| 10627 | "Do not send outside local AS (well-known community)\n" |
| 10628 | "Do not advertise to any peer (well-known community)\n" |
| 10629 | "Do not export to next AS (well-known community)\n" |
| 10630 | "community number\n" |
| 10631 | "Do not send outside local AS (well-known community)\n" |
| 10632 | "Do not advertise to any peer (well-known community)\n" |
| 10633 | "Do not export to next AS (well-known community)\n") |
| 10634 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10635 | ALIAS (show_bgp_ipv6_safi_community, |
| 10636 | show_bgp_ipv6_safi_community3_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10637 | "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] | 10638 | SHOW_STR |
| 10639 | BGP_STR |
| 10640 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10641 | "Address family modifier\n" |
| 10642 | "Address family modifier\n" |
| 10643 | "Address family modifier\n" |
| 10644 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10645 | "Display routes matching the communities\n" |
| 10646 | "community number\n" |
| 10647 | "Do not send outside local AS (well-known community)\n" |
| 10648 | "Do not advertise to any peer (well-known community)\n" |
| 10649 | "Do not export to next AS (well-known community)\n" |
| 10650 | "community number\n" |
| 10651 | "Do not send outside local AS (well-known community)\n" |
| 10652 | "Do not advertise to any peer (well-known community)\n" |
| 10653 | "Do not export to next AS (well-known community)\n" |
| 10654 | "community number\n" |
| 10655 | "Do not send outside local AS (well-known community)\n" |
| 10656 | "Do not advertise to any peer (well-known community)\n" |
| 10657 | "Do not export to next AS (well-known community)\n") |
| 10658 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10659 | ALIAS (show_bgp_ipv6_safi_community, |
| 10660 | show_bgp_ipv6_safi_community4_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10661 | "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] | 10662 | SHOW_STR |
| 10663 | BGP_STR |
| 10664 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10665 | "Address family modifier\n" |
| 10666 | "Address family modifier\n" |
| 10667 | "Address family modifier\n" |
| 10668 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10669 | "Display routes matching the communities\n" |
| 10670 | "community number\n" |
| 10671 | "Do not send outside local AS (well-known community)\n" |
| 10672 | "Do not advertise to any peer (well-known community)\n" |
| 10673 | "Do not export to next AS (well-known community)\n" |
| 10674 | "community number\n" |
| 10675 | "Do not send outside local AS (well-known community)\n" |
| 10676 | "Do not advertise to any peer (well-known community)\n" |
| 10677 | "Do not export to next AS (well-known community)\n" |
| 10678 | "community number\n" |
| 10679 | "Do not send outside local AS (well-known community)\n" |
| 10680 | "Do not advertise to any peer (well-known community)\n" |
| 10681 | "Do not export to next AS (well-known community)\n" |
| 10682 | "community number\n" |
| 10683 | "Do not send outside local AS (well-known community)\n" |
| 10684 | "Do not advertise to any peer (well-known community)\n" |
| 10685 | "Do not export to next AS (well-known community)\n") |
| 10686 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10687 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10688 | DEFUN (show_bgp_ipv6_safi_community_exact, |
| 10689 | show_bgp_ipv6_safi_community_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10690 | "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] | 10691 | SHOW_STR |
| 10692 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10693 | "Address family\n" |
| 10694 | "Address family modifier\n" |
| 10695 | "Address family modifier\n" |
| 10696 | "Address family modifier\n" |
| 10697 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10698 | "Display routes matching the communities\n" |
| 10699 | "community number\n" |
| 10700 | "Do not send outside local AS (well-known community)\n" |
| 10701 | "Do not advertise to any peer (well-known community)\n" |
| 10702 | "Do not export to next AS (well-known community)\n" |
| 10703 | "Exact match of the communities") |
| 10704 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10705 | safi_t safi; |
| 10706 | |
| 10707 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10708 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10709 | return CMD_WARNING; |
| 10710 | } |
| 10711 | 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] | 10712 | } |
| 10713 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10714 | |
| 10715 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10716 | show_bgp_ipv6_safi_community2_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10717 | "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] | 10718 | SHOW_STR |
| 10719 | BGP_STR |
| 10720 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10721 | "Address family modifier\n" |
| 10722 | "Address family modifier\n" |
| 10723 | "Address family modifier\n" |
| 10724 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10725 | "Display routes matching the communities\n" |
| 10726 | "community number\n" |
| 10727 | "Do not send outside local AS (well-known community)\n" |
| 10728 | "Do not advertise to any peer (well-known community)\n" |
| 10729 | "Do not export to next AS (well-known community)\n" |
| 10730 | "community number\n" |
| 10731 | "Do not send outside local AS (well-known community)\n" |
| 10732 | "Do not advertise to any peer (well-known community)\n" |
| 10733 | "Do not export to next AS (well-known community)\n" |
| 10734 | "Exact match of the communities") |
| 10735 | |
| 10736 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10737 | show_bgp_ipv6_safi_community3_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10738 | "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] | 10739 | SHOW_STR |
| 10740 | BGP_STR |
| 10741 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10742 | "Address family modifier\n" |
| 10743 | "Address family modifier\n" |
| 10744 | "Address family modifier\n" |
| 10745 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10746 | "Display routes matching the communities\n" |
| 10747 | "community number\n" |
| 10748 | "Do not send outside local AS (well-known community)\n" |
| 10749 | "Do not advertise to any peer (well-known community)\n" |
| 10750 | "Do not export to next AS (well-known community)\n" |
| 10751 | "community number\n" |
| 10752 | "Do not send outside local AS (well-known community)\n" |
| 10753 | "Do not advertise to any peer (well-known community)\n" |
| 10754 | "Do not export to next AS (well-known community)\n" |
| 10755 | "community number\n" |
| 10756 | "Do not send outside local AS (well-known community)\n" |
| 10757 | "Do not advertise to any peer (well-known community)\n" |
| 10758 | "Do not export to next AS (well-known community)\n" |
| 10759 | "Exact match of the communities") |
| 10760 | |
| 10761 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10762 | show_bgp_ipv6_safi_community4_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10763 | "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] | 10764 | SHOW_STR |
| 10765 | BGP_STR |
| 10766 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10767 | "Address family modifier\n" |
| 10768 | "Address family modifier\n" |
| 10769 | "Address family modifier\n" |
| 10770 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10771 | "Display routes matching the communities\n" |
| 10772 | "community number\n" |
| 10773 | "Do not send outside local AS (well-known community)\n" |
| 10774 | "Do not advertise to any peer (well-known community)\n" |
| 10775 | "Do not export to next AS (well-known community)\n" |
| 10776 | "community number\n" |
| 10777 | "Do not send outside local AS (well-known community)\n" |
| 10778 | "Do not advertise to any peer (well-known community)\n" |
| 10779 | "Do not export to next AS (well-known community)\n" |
| 10780 | "community number\n" |
| 10781 | "Do not send outside local AS (well-known community)\n" |
| 10782 | "Do not advertise to any peer (well-known community)\n" |
| 10783 | "Do not export to next AS (well-known community)\n" |
| 10784 | "community number\n" |
| 10785 | "Do not send outside local AS (well-known community)\n" |
| 10786 | "Do not advertise to any peer (well-known community)\n" |
| 10787 | "Do not export to next AS (well-known community)\n" |
| 10788 | "Exact match of the communities") |
| 10789 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10790 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10791 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 10792 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10793 | { |
| 10794 | struct community_list *list; |
| 10795 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 10796 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10797 | if (list == NULL) |
| 10798 | { |
| 10799 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 10800 | VTY_NEWLINE); |
| 10801 | return CMD_WARNING; |
| 10802 | } |
| 10803 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10804 | return bgp_show (vty, NULL, afi, safi, |
| 10805 | (exact ? bgp_show_type_community_list_exact : |
| 10806 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10807 | } |
| 10808 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10809 | DEFUN (show_ip_bgp_community_list, |
| 10810 | show_ip_bgp_community_list_cmd, |
| 10811 | "show ip bgp community-list (<1-500>|WORD)", |
| 10812 | SHOW_STR |
| 10813 | IP_STR |
| 10814 | BGP_STR |
| 10815 | "Display routes matching the community-list\n" |
| 10816 | "community-list number\n" |
| 10817 | "community-list name\n") |
| 10818 | { |
| 10819 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 10820 | } |
| 10821 | |
| 10822 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 10823 | show_ip_bgp_ipv4_community_list_cmd, |
| 10824 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
| 10825 | SHOW_STR |
| 10826 | IP_STR |
| 10827 | BGP_STR |
| 10828 | "Address family\n" |
| 10829 | "Address Family modifier\n" |
| 10830 | "Address Family modifier\n" |
| 10831 | "Display routes matching the community-list\n" |
| 10832 | "community-list number\n" |
| 10833 | "community-list name\n") |
| 10834 | { |
| 10835 | if (strncmp (argv[0], "m", 1) == 0) |
| 10836 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 10837 | |
| 10838 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 10839 | } |
| 10840 | |
| 10841 | DEFUN (show_ip_bgp_community_list_exact, |
| 10842 | show_ip_bgp_community_list_exact_cmd, |
| 10843 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
| 10844 | SHOW_STR |
| 10845 | IP_STR |
| 10846 | BGP_STR |
| 10847 | "Display routes matching the community-list\n" |
| 10848 | "community-list number\n" |
| 10849 | "community-list name\n" |
| 10850 | "Exact match of the communities\n") |
| 10851 | { |
| 10852 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 10853 | } |
| 10854 | |
| 10855 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 10856 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 10857 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
| 10858 | SHOW_STR |
| 10859 | IP_STR |
| 10860 | BGP_STR |
| 10861 | "Address family\n" |
| 10862 | "Address Family modifier\n" |
| 10863 | "Address Family modifier\n" |
| 10864 | "Display routes matching the community-list\n" |
| 10865 | "community-list number\n" |
| 10866 | "community-list name\n" |
| 10867 | "Exact match of the communities\n") |
| 10868 | { |
| 10869 | if (strncmp (argv[0], "m", 1) == 0) |
| 10870 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 10871 | |
| 10872 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 10873 | } |
| 10874 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10875 | DEFUN (show_bgp_community_list, |
| 10876 | show_bgp_community_list_cmd, |
| 10877 | "show bgp community-list (<1-500>|WORD)", |
| 10878 | SHOW_STR |
| 10879 | BGP_STR |
| 10880 | "Display routes matching the community-list\n" |
| 10881 | "community-list number\n" |
| 10882 | "community-list name\n") |
| 10883 | { |
| 10884 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 10885 | } |
| 10886 | |
| 10887 | ALIAS (show_bgp_community_list, |
| 10888 | show_bgp_ipv6_community_list_cmd, |
| 10889 | "show bgp ipv6 community-list (<1-500>|WORD)", |
| 10890 | SHOW_STR |
| 10891 | BGP_STR |
| 10892 | "Address family\n" |
| 10893 | "Display routes matching the community-list\n" |
| 10894 | "community-list number\n" |
| 10895 | "community-list name\n") |
| 10896 | |
| 10897 | /* old command */ |
| 10898 | DEFUN (show_ipv6_bgp_community_list, |
| 10899 | show_ipv6_bgp_community_list_cmd, |
| 10900 | "show ipv6 bgp community-list WORD", |
| 10901 | SHOW_STR |
| 10902 | IPV6_STR |
| 10903 | BGP_STR |
| 10904 | "Display routes matching the community-list\n" |
| 10905 | "community-list name\n") |
| 10906 | { |
| 10907 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 10908 | } |
| 10909 | |
| 10910 | /* old command */ |
| 10911 | DEFUN (show_ipv6_mbgp_community_list, |
| 10912 | show_ipv6_mbgp_community_list_cmd, |
| 10913 | "show ipv6 mbgp community-list WORD", |
| 10914 | SHOW_STR |
| 10915 | IPV6_STR |
| 10916 | MBGP_STR |
| 10917 | "Display routes matching the community-list\n" |
| 10918 | "community-list name\n") |
| 10919 | { |
| 10920 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 10921 | } |
| 10922 | |
| 10923 | DEFUN (show_bgp_community_list_exact, |
| 10924 | show_bgp_community_list_exact_cmd, |
| 10925 | "show bgp community-list (<1-500>|WORD) exact-match", |
| 10926 | SHOW_STR |
| 10927 | BGP_STR |
| 10928 | "Display routes matching the community-list\n" |
| 10929 | "community-list number\n" |
| 10930 | "community-list name\n" |
| 10931 | "Exact match of the communities\n") |
| 10932 | { |
| 10933 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 10934 | } |
| 10935 | |
| 10936 | ALIAS (show_bgp_community_list_exact, |
| 10937 | show_bgp_ipv6_community_list_exact_cmd, |
| 10938 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
| 10939 | SHOW_STR |
| 10940 | BGP_STR |
| 10941 | "Address family\n" |
| 10942 | "Display routes matching the community-list\n" |
| 10943 | "community-list number\n" |
| 10944 | "community-list name\n" |
| 10945 | "Exact match of the communities\n") |
| 10946 | |
| 10947 | /* old command */ |
| 10948 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 10949 | show_ipv6_bgp_community_list_exact_cmd, |
| 10950 | "show ipv6 bgp community-list WORD exact-match", |
| 10951 | SHOW_STR |
| 10952 | IPV6_STR |
| 10953 | BGP_STR |
| 10954 | "Display routes matching the community-list\n" |
| 10955 | "community-list name\n" |
| 10956 | "Exact match of the communities\n") |
| 10957 | { |
| 10958 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 10959 | } |
| 10960 | |
| 10961 | /* old command */ |
| 10962 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 10963 | show_ipv6_mbgp_community_list_exact_cmd, |
| 10964 | "show ipv6 mbgp community-list WORD exact-match", |
| 10965 | SHOW_STR |
| 10966 | IPV6_STR |
| 10967 | MBGP_STR |
| 10968 | "Display routes matching the community-list\n" |
| 10969 | "community-list name\n" |
| 10970 | "Exact match of the communities\n") |
| 10971 | { |
| 10972 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 10973 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10974 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10975 | DEFUN (show_bgp_ipv4_community_list, |
| 10976 | show_bgp_ipv4_community_list_cmd, |
| 10977 | "show bgp ipv4 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10978 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10979 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10980 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10981 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 10982 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10983 | "community-list name\n") |
| 10984 | { |
| 10985 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 10986 | } |
| 10987 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10988 | DEFUN (show_bgp_ipv4_safi_community_list, |
| 10989 | show_bgp_ipv4_safi_community_list_cmd, |
| 10990 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10991 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10992 | BGP_STR |
| 10993 | "Address family\n" |
| 10994 | "Address Family modifier\n" |
| 10995 | "Address Family modifier\n" |
| 10996 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 10997 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10998 | "community-list name\n") |
| 10999 | { |
| 11000 | if (strncmp (argv[0], "m", 1) == 0) |
| 11001 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11002 | |
| 11003 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11004 | } |
| 11005 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11006 | DEFUN (show_bgp_ipv4_community_list_exact, |
| 11007 | show_bgp_ipv4_community_list_exact_cmd, |
| 11008 | "show bgp ipv4 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11009 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11010 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11011 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11012 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11013 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11014 | "community-list name\n" |
| 11015 | "Exact match of the communities\n") |
| 11016 | { |
| 11017 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11018 | } |
| 11019 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11020 | DEFUN (show_bgp_ipv4_safi_community_list_exact, |
| 11021 | show_bgp_ipv4_safi_community_list_exact_cmd, |
| 11022 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11023 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11024 | BGP_STR |
| 11025 | "Address family\n" |
| 11026 | "Address Family modifier\n" |
| 11027 | "Address Family modifier\n" |
| 11028 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11029 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11030 | "community-list name\n" |
| 11031 | "Exact match of the communities\n") |
| 11032 | { |
| 11033 | if (strncmp (argv[0], "m", 1) == 0) |
| 11034 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11035 | |
| 11036 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11037 | } |
| 11038 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11039 | DEFUN (show_bgp_ipv6_safi_community_list, |
| 11040 | show_bgp_ipv6_safi_community_list_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11041 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11042 | SHOW_STR |
| 11043 | BGP_STR |
| 11044 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11045 | "Address family modifier\n" |
| 11046 | "Address family modifier\n" |
| 11047 | "Address family modifier\n" |
| 11048 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11049 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11050 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 11051 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11052 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11053 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11054 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11055 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11056 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11057 | return CMD_WARNING; |
| 11058 | } |
| 11059 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11060 | } |
| 11061 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11062 | DEFUN (show_bgp_ipv6_safi_community_list_exact, |
| 11063 | show_bgp_ipv6_safi_community_list_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11064 | "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] | 11065 | SHOW_STR |
| 11066 | BGP_STR |
| 11067 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11068 | "Address family modifier\n" |
| 11069 | "Address family modifier\n" |
| 11070 | "Address family modifier\n" |
| 11071 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11072 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11073 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11074 | "community-list name\n" |
| 11075 | "Exact match of the communities\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11076 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11077 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11078 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11079 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11080 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11081 | return CMD_WARNING; |
| 11082 | } |
| 11083 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11084 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11085 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11086 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11087 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11088 | safi_t safi, enum bgp_show_type type) |
| 11089 | { |
| 11090 | int ret; |
| 11091 | struct prefix *p; |
| 11092 | |
| 11093 | p = prefix_new(); |
| 11094 | |
| 11095 | ret = str2prefix (prefix, p); |
| 11096 | if (! ret) |
| 11097 | { |
| 11098 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 11099 | return CMD_WARNING; |
| 11100 | } |
| 11101 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11102 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 11103 | prefix_free(p); |
| 11104 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11105 | } |
| 11106 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11107 | DEFUN (show_ip_bgp_prefix_longer, |
| 11108 | show_ip_bgp_prefix_longer_cmd, |
| 11109 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 11110 | SHOW_STR |
| 11111 | IP_STR |
| 11112 | BGP_STR |
| 11113 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11114 | "Display route and more specific routes\n") |
| 11115 | { |
| 11116 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11117 | bgp_show_type_prefix_longer); |
| 11118 | } |
| 11119 | |
| 11120 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 11121 | show_ip_bgp_flap_prefix_longer_cmd, |
| 11122 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 11123 | SHOW_STR |
| 11124 | IP_STR |
| 11125 | BGP_STR |
| 11126 | "Display flap statistics of routes\n" |
| 11127 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11128 | "Display route and more specific routes\n") |
| 11129 | { |
| 11130 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11131 | bgp_show_type_flap_prefix_longer); |
| 11132 | } |
| 11133 | |
| 11134 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 11135 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 11136 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 11137 | SHOW_STR |
| 11138 | IP_STR |
| 11139 | BGP_STR |
| 11140 | "Display detailed information about dampening\n" |
| 11141 | "Display flap statistics of routes\n" |
| 11142 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11143 | "Display route and more specific routes\n") |
| 11144 | |
| 11145 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 11146 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 11147 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 11148 | SHOW_STR |
| 11149 | IP_STR |
| 11150 | BGP_STR |
| 11151 | "Address family\n" |
| 11152 | "Address Family modifier\n" |
| 11153 | "Address Family modifier\n" |
| 11154 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11155 | "Display route and more specific routes\n") |
| 11156 | { |
| 11157 | if (strncmp (argv[0], "m", 1) == 0) |
| 11158 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 11159 | bgp_show_type_prefix_longer); |
| 11160 | |
| 11161 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 11162 | bgp_show_type_prefix_longer); |
| 11163 | } |
| 11164 | |
| 11165 | DEFUN (show_ip_bgp_flap_address, |
| 11166 | show_ip_bgp_flap_address_cmd, |
| 11167 | "show ip bgp flap-statistics A.B.C.D", |
| 11168 | SHOW_STR |
| 11169 | IP_STR |
| 11170 | BGP_STR |
| 11171 | "Display flap statistics of routes\n" |
| 11172 | "Network in the BGP routing table to display\n") |
| 11173 | { |
| 11174 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11175 | bgp_show_type_flap_address); |
| 11176 | } |
| 11177 | |
| 11178 | ALIAS (show_ip_bgp_flap_address, |
| 11179 | show_ip_bgp_damp_flap_address_cmd, |
| 11180 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 11181 | SHOW_STR |
| 11182 | IP_STR |
| 11183 | BGP_STR |
| 11184 | "Display detailed information about dampening\n" |
| 11185 | "Display flap statistics of routes\n" |
| 11186 | "Network in the BGP routing table to display\n") |
| 11187 | |
| 11188 | DEFUN (show_ip_bgp_flap_prefix, |
| 11189 | show_ip_bgp_flap_prefix_cmd, |
| 11190 | "show ip bgp flap-statistics A.B.C.D/M", |
| 11191 | SHOW_STR |
| 11192 | IP_STR |
| 11193 | BGP_STR |
| 11194 | "Display flap statistics of routes\n" |
| 11195 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11196 | { |
| 11197 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11198 | bgp_show_type_flap_prefix); |
| 11199 | } |
| 11200 | |
| 11201 | ALIAS (show_ip_bgp_flap_prefix, |
| 11202 | show_ip_bgp_damp_flap_prefix_cmd, |
| 11203 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 11204 | SHOW_STR |
| 11205 | IP_STR |
| 11206 | BGP_STR |
| 11207 | "Display detailed information about dampening\n" |
| 11208 | "Display flap statistics of routes\n" |
| 11209 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11210 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11211 | DEFUN (show_bgp_prefix_longer, |
| 11212 | show_bgp_prefix_longer_cmd, |
| 11213 | "show bgp X:X::X:X/M longer-prefixes", |
| 11214 | SHOW_STR |
| 11215 | BGP_STR |
| 11216 | "IPv6 prefix <network>/<length>\n" |
| 11217 | "Display route and more specific routes\n") |
| 11218 | { |
| 11219 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11220 | bgp_show_type_prefix_longer); |
| 11221 | } |
| 11222 | |
| 11223 | /* old command */ |
| 11224 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 11225 | show_ipv6_bgp_prefix_longer_cmd, |
| 11226 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 11227 | SHOW_STR |
| 11228 | IPV6_STR |
| 11229 | BGP_STR |
| 11230 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11231 | "Display route and more specific routes\n") |
| 11232 | { |
| 11233 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11234 | bgp_show_type_prefix_longer); |
| 11235 | } |
| 11236 | |
| 11237 | /* old command */ |
| 11238 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 11239 | show_ipv6_mbgp_prefix_longer_cmd, |
| 11240 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 11241 | SHOW_STR |
| 11242 | IPV6_STR |
| 11243 | MBGP_STR |
| 11244 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11245 | "Display route and more specific routes\n") |
| 11246 | { |
| 11247 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 11248 | bgp_show_type_prefix_longer); |
| 11249 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11250 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11251 | DEFUN (show_bgp_ipv4_prefix_longer, |
| 11252 | show_bgp_ipv4_prefix_longer_cmd, |
| 11253 | "show bgp ipv4 A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11254 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11255 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11256 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11257 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11258 | "Display route and more specific routes\n") |
| 11259 | { |
| 11260 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11261 | bgp_show_type_prefix_longer); |
| 11262 | } |
| 11263 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11264 | DEFUN (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11265 | show_bgp_ipv4_safi_flap_prefix_longer_cmd, |
| 11266 | "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] | 11267 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11268 | BGP_STR |
| 11269 | "Address family\n" |
| 11270 | "Address Family modifier\n" |
| 11271 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11272 | "Address Family modifier\n" |
| 11273 | "Address Family modifier\n" |
| 11274 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11275 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11276 | "Display route and more specific routes\n") |
| 11277 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11278 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11279 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11280 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11281 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11282 | return CMD_WARNING; |
| 11283 | } |
| 11284 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11285 | bgp_show_type_flap_prefix_longer); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11286 | } |
| 11287 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11288 | ALIAS (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11289 | show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd, |
| 11290 | "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] | 11291 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11292 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11293 | "Address family\n" |
| 11294 | "Address Family modifier\n" |
| 11295 | "Address Family modifier\n" |
| 11296 | "Address Family modifier\n" |
| 11297 | "Address Family modifier\n" |
| 11298 | "Display detailed information about dampening\n" |
| 11299 | "Display flap statistics of routes\n" |
| 11300 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11301 | "Display route and more specific routes\n") |
| 11302 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11303 | DEFUN (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11304 | show_bgp_ipv6_safi_flap_prefix_longer_cmd, |
| 11305 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes", |
| 11306 | SHOW_STR |
| 11307 | BGP_STR |
| 11308 | "Address family\n" |
| 11309 | "Address Family modifier\n" |
| 11310 | "Address Family modifier\n" |
| 11311 | "Address Family modifier\n" |
| 11312 | "Address Family modifier\n" |
| 11313 | "Display flap statistics of routes\n" |
| 11314 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11315 | "Display route and more specific routes\n") |
| 11316 | { |
| 11317 | safi_t safi; |
| 11318 | |
| 11319 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11320 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11321 | return CMD_WARNING; |
| 11322 | } |
| 11323 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11324 | bgp_show_type_flap_prefix_longer); |
| 11325 | } |
| 11326 | ALIAS (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11327 | show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd, |
| 11328 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes", |
| 11329 | SHOW_STR |
| 11330 | BGP_STR |
| 11331 | "Address family\n" |
| 11332 | "Address Family modifier\n" |
| 11333 | "Address Family modifier\n" |
| 11334 | "Address Family modifier\n" |
| 11335 | "Address Family modifier\n" |
| 11336 | "Display detailed information about dampening\n" |
| 11337 | "Display flap statistics of routes\n" |
| 11338 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11339 | "Display route and more specific routes\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11340 | |
| 11341 | DEFUN (show_bgp_ipv4_safi_prefix_longer, |
| 11342 | show_bgp_ipv4_safi_prefix_longer_cmd, |
| 11343 | "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes", |
| 11344 | SHOW_STR |
| 11345 | BGP_STR |
| 11346 | "Address family\n" |
| 11347 | "Address Family modifier\n" |
| 11348 | "Address Family modifier\n" |
| 11349 | "Address Family modifier\n" |
| 11350 | "Address Family modifier\n" |
| 11351 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11352 | "Display route and more specific routes\n") |
| 11353 | { |
| 11354 | safi_t safi; |
| 11355 | |
| 11356 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11357 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11358 | return CMD_WARNING; |
| 11359 | } |
| 11360 | |
| 11361 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11362 | bgp_show_type_prefix_longer); |
| 11363 | } |
| 11364 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11365 | DEFUN (show_bgp_ipv6_safi_prefix_longer, |
| 11366 | show_bgp_ipv6_safi_prefix_longer_cmd, |
| 11367 | "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes", |
| 11368 | SHOW_STR |
| 11369 | BGP_STR |
| 11370 | "Address family\n" |
| 11371 | "Address Family modifier\n" |
| 11372 | "Address Family modifier\n" |
| 11373 | "Address Family modifier\n" |
| 11374 | "Address Family modifier\n" |
| 11375 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11376 | "Display route and more specific routes\n") |
| 11377 | { |
| 11378 | safi_t safi; |
| 11379 | |
| 11380 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11381 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11382 | return CMD_WARNING; |
| 11383 | } |
| 11384 | |
| 11385 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11386 | bgp_show_type_prefix_longer); |
| 11387 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11388 | |
| 11389 | DEFUN (show_bgp_ipv4_safi_flap_address, |
| 11390 | show_bgp_ipv4_safi_flap_address_cmd, |
| 11391 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
| 11392 | SHOW_STR |
| 11393 | BGP_STR |
| 11394 | "Address family\n" |
| 11395 | "Address Family modifier\n" |
| 11396 | "Address Family modifier\n" |
| 11397 | "Address Family modifier\n" |
| 11398 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11399 | "Display flap statistics of routes\n" |
| 11400 | "Network in the BGP routing table to display\n") |
| 11401 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11402 | safi_t safi; |
| 11403 | |
| 11404 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11405 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11406 | return CMD_WARNING; |
| 11407 | } |
| 11408 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11409 | bgp_show_type_flap_address); |
| 11410 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11411 | ALIAS (show_bgp_ipv4_safi_flap_address, |
| 11412 | show_bgp_ipv4_safi_damp_flap_address_cmd, |
| 11413 | "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] | 11414 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11415 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11416 | "Address family\n" |
| 11417 | "Address Family modifier\n" |
| 11418 | "Address Family modifier\n" |
| 11419 | "Address Family modifier\n" |
| 11420 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11421 | "Display detailed information about dampening\n" |
| 11422 | "Display flap statistics of routes\n" |
| 11423 | "Network in the BGP routing table to display\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 11424 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11425 | DEFUN (show_bgp_ipv6_flap_address, |
| 11426 | show_bgp_ipv6_flap_address_cmd, |
| 11427 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11428 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11429 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11430 | "Address family\n" |
| 11431 | "Address Family modifier\n" |
| 11432 | "Address Family modifier\n" |
| 11433 | "Address Family modifier\n" |
| 11434 | "Address Family modifier\n" |
| 11435 | "Display flap statistics of routes\n" |
| 11436 | "Network in the BGP routing table to display\n") |
| 11437 | { |
| 11438 | safi_t safi; |
| 11439 | |
| 11440 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11441 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11442 | return CMD_WARNING; |
| 11443 | } |
| 11444 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11445 | bgp_show_type_flap_address); |
| 11446 | } |
| 11447 | ALIAS (show_bgp_ipv6_flap_address, |
| 11448 | show_bgp_ipv6_damp_flap_address_cmd, |
| 11449 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D", |
| 11450 | SHOW_STR |
| 11451 | BGP_STR |
| 11452 | "Address family\n" |
| 11453 | "Address Family modifier\n" |
| 11454 | "Address Family modifier\n" |
| 11455 | "Address Family modifier\n" |
| 11456 | "Address Family modifier\n" |
| 11457 | "Display detailed information about dampening\n" |
| 11458 | "Display flap statistics of routes\n" |
| 11459 | "Network in the BGP routing table to display\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11460 | |
| 11461 | DEFUN (show_bgp_ipv4_safi_flap_prefix, |
| 11462 | show_bgp_ipv4_safi_flap_prefix_cmd, |
| 11463 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M", |
| 11464 | SHOW_STR |
| 11465 | BGP_STR |
| 11466 | "Address family\n" |
| 11467 | "Address Family modifier\n" |
| 11468 | "Address Family modifier\n" |
| 11469 | "Address Family modifier\n" |
| 11470 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11471 | "Display flap statistics of routes\n" |
| 11472 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11473 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11474 | safi_t safi; |
| 11475 | |
| 11476 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11477 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11478 | return CMD_WARNING; |
| 11479 | } |
| 11480 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11481 | bgp_show_type_flap_prefix); |
| 11482 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11483 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11484 | ALIAS (show_bgp_ipv4_safi_flap_prefix, |
| 11485 | show_bgp_ipv4_safi_damp_flap_prefix_cmd, |
| 11486 | "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] | 11487 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11488 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11489 | "Address family\n" |
| 11490 | "Address Family modifier\n" |
| 11491 | "Address Family modifier\n" |
| 11492 | "Address Family modifier\n" |
| 11493 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11494 | "Display detailed information about dampening\n" |
| 11495 | "Display flap statistics of routes\n" |
| 11496 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11497 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11498 | DEFUN (show_bgp_ipv6_safi_flap_prefix, |
| 11499 | show_bgp_ipv6_safi_flap_prefix_cmd, |
| 11500 | "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] | 11501 | SHOW_STR |
| 11502 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11503 | "Address family\n" |
| 11504 | "Address Family modifier\n" |
| 11505 | "Address Family modifier\n" |
| 11506 | "Address Family modifier\n" |
| 11507 | "Address Family modifier\n" |
| 11508 | "Display flap statistics of routes\n" |
| 11509 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11510 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11511 | safi_t safi; |
| 11512 | |
| 11513 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11514 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11515 | return CMD_WARNING; |
| 11516 | } |
| 11517 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi, |
| 11518 | bgp_show_type_flap_prefix); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11519 | } |
| 11520 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11521 | ALIAS (show_bgp_ipv6_safi_flap_prefix, |
| 11522 | show_bgp_ipv6_safi_damp_flap_prefix_cmd, |
| 11523 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M", |
| 11524 | SHOW_STR |
| 11525 | BGP_STR |
| 11526 | "Address family\n" |
| 11527 | "Address Family modifier\n" |
| 11528 | "Address Family modifier\n" |
| 11529 | "Address Family modifier\n" |
| 11530 | "Address Family modifier\n" |
| 11531 | "Display detailed information about dampening\n" |
| 11532 | "Display flap statistics of routes\n" |
| 11533 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11534 | |
| 11535 | DEFUN (show_bgp_ipv6_prefix_longer, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11536 | show_bgp_ipv6_prefix_longer_cmd, |
| 11537 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 11538 | SHOW_STR |
| 11539 | BGP_STR |
| 11540 | "Address family\n" |
| 11541 | "IPv6 prefix <network>/<length>\n" |
| 11542 | "Display route and more specific routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11543 | { |
| 11544 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11545 | bgp_show_type_prefix_longer); |
| 11546 | } |
| 11547 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11548 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11549 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 11550 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11551 | { |
| 11552 | int ret; |
| 11553 | struct bgp *bgp; |
| 11554 | struct peer *peer; |
| 11555 | union sockunion su; |
| 11556 | |
| 11557 | /* BGP structure lookup. */ |
| 11558 | if (view_name) |
| 11559 | { |
| 11560 | bgp = bgp_lookup_by_name (view_name); |
| 11561 | if (! bgp) |
| 11562 | { |
| 11563 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 11564 | return NULL; |
| 11565 | } |
| 11566 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 11567 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11568 | { |
| 11569 | bgp = bgp_get_default (); |
| 11570 | if (! bgp) |
| 11571 | { |
| 11572 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11573 | return NULL; |
| 11574 | } |
| 11575 | } |
| 11576 | |
| 11577 | /* Get peer sockunion. */ |
| 11578 | ret = str2sockunion (ip_str, &su); |
| 11579 | if (ret < 0) |
| 11580 | { |
| 11581 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 11582 | return NULL; |
| 11583 | } |
| 11584 | |
| 11585 | /* Peer structure lookup. */ |
| 11586 | peer = peer_lookup (bgp, &su); |
| 11587 | if (! peer) |
| 11588 | { |
| 11589 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 11590 | return NULL; |
| 11591 | } |
| 11592 | |
| 11593 | return peer; |
| 11594 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11595 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11596 | enum bgp_stats |
| 11597 | { |
| 11598 | BGP_STATS_MAXBITLEN = 0, |
| 11599 | BGP_STATS_RIB, |
| 11600 | BGP_STATS_PREFIXES, |
| 11601 | BGP_STATS_TOTPLEN, |
| 11602 | BGP_STATS_UNAGGREGATEABLE, |
| 11603 | BGP_STATS_MAX_AGGREGATEABLE, |
| 11604 | BGP_STATS_AGGREGATES, |
| 11605 | BGP_STATS_SPACE, |
| 11606 | BGP_STATS_ASPATH_COUNT, |
| 11607 | BGP_STATS_ASPATH_MAXHOPS, |
| 11608 | BGP_STATS_ASPATH_TOTHOPS, |
| 11609 | BGP_STATS_ASPATH_MAXSIZE, |
| 11610 | BGP_STATS_ASPATH_TOTSIZE, |
| 11611 | BGP_STATS_ASN_HIGHEST, |
| 11612 | BGP_STATS_MAX, |
| 11613 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11614 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11615 | static const char *table_stats_strs[] = |
| 11616 | { |
| 11617 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 11618 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 11619 | [BGP_STATS_RIB] = "Total Advertisements", |
| 11620 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 11621 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 11622 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 11623 | [BGP_STATS_SPACE] = "Address space advertised", |
| 11624 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 11625 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 11626 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 11627 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 11628 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 11629 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 11630 | [BGP_STATS_MAX] = NULL, |
| 11631 | }; |
| 11632 | |
| 11633 | struct bgp_table_stats |
| 11634 | { |
| 11635 | struct bgp_table *table; |
| 11636 | unsigned long long counts[BGP_STATS_MAX]; |
| 11637 | }; |
| 11638 | |
| 11639 | #if 0 |
| 11640 | #define TALLY_SIGFIG 100000 |
| 11641 | static unsigned long |
| 11642 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 11643 | { |
| 11644 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 11645 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 11646 | unsigned long ret = newtot / count; |
| 11647 | |
| 11648 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 11649 | return ret + 1; |
| 11650 | else |
| 11651 | return ret; |
| 11652 | } |
| 11653 | #endif |
| 11654 | |
| 11655 | static int |
| 11656 | bgp_table_stats_walker (struct thread *t) |
| 11657 | { |
| 11658 | struct bgp_node *rn; |
| 11659 | struct bgp_node *top; |
| 11660 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 11661 | unsigned int space = 0; |
| 11662 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 11663 | if (!(top = bgp_table_top (ts->table))) |
| 11664 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11665 | |
| 11666 | switch (top->p.family) |
| 11667 | { |
| 11668 | case AF_INET: |
| 11669 | space = IPV4_MAX_BITLEN; |
| 11670 | break; |
| 11671 | case AF_INET6: |
| 11672 | space = IPV6_MAX_BITLEN; |
| 11673 | break; |
| 11674 | } |
| 11675 | |
| 11676 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 11677 | |
| 11678 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 11679 | { |
| 11680 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11681 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11682 | unsigned int rinum = 0; |
| 11683 | |
| 11684 | if (rn == top) |
| 11685 | continue; |
| 11686 | |
| 11687 | if (!rn->info) |
| 11688 | continue; |
| 11689 | |
| 11690 | ts->counts[BGP_STATS_PREFIXES]++; |
| 11691 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 11692 | |
| 11693 | #if 0 |
| 11694 | ts->counts[BGP_STATS_AVGPLEN] |
| 11695 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 11696 | ts->counts[BGP_STATS_AVGPLEN], |
| 11697 | rn->p.prefixlen); |
| 11698 | #endif |
| 11699 | |
| 11700 | /* check if the prefix is included by any other announcements */ |
| 11701 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11702 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11703 | |
| 11704 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 11705 | { |
| 11706 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 11707 | /* announced address space */ |
| 11708 | if (space) |
| 11709 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 11710 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11711 | else if (prn->info) |
| 11712 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 11713 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11714 | for (ri = rn->info; ri; ri = ri->next) |
| 11715 | { |
| 11716 | rinum++; |
| 11717 | ts->counts[BGP_STATS_RIB]++; |
| 11718 | |
| 11719 | if (ri->attr && |
| 11720 | (CHECK_FLAG (ri->attr->flag, |
| 11721 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 11722 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 11723 | |
| 11724 | /* as-path stats */ |
| 11725 | if (ri->attr && ri->attr->aspath) |
| 11726 | { |
| 11727 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 11728 | unsigned int size = aspath_size (ri->attr->aspath); |
| 11729 | as_t highest = aspath_highest (ri->attr->aspath); |
| 11730 | |
| 11731 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 11732 | |
| 11733 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 11734 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 11735 | |
| 11736 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 11737 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 11738 | |
| 11739 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 11740 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 11741 | #if 0 |
| 11742 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 11743 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 11744 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 11745 | hops); |
| 11746 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 11747 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 11748 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 11749 | size); |
| 11750 | #endif |
| 11751 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 11752 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 11753 | } |
| 11754 | } |
| 11755 | } |
| 11756 | return 0; |
| 11757 | } |
| 11758 | |
| 11759 | static int |
| 11760 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 11761 | { |
| 11762 | struct bgp_table_stats ts; |
| 11763 | unsigned int i; |
| 11764 | |
| 11765 | if (!bgp->rib[afi][safi]) |
| 11766 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 11767 | vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11768 | return CMD_WARNING; |
| 11769 | } |
| 11770 | |
| 11771 | memset (&ts, 0, sizeof (ts)); |
| 11772 | ts.table = bgp->rib[afi][safi]; |
| 11773 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 11774 | |
| 11775 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 11776 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 11777 | |
| 11778 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 11779 | { |
| 11780 | if (!table_stats_strs[i]) |
| 11781 | continue; |
| 11782 | |
| 11783 | switch (i) |
| 11784 | { |
| 11785 | #if 0 |
| 11786 | case BGP_STATS_ASPATH_AVGHOPS: |
| 11787 | case BGP_STATS_ASPATH_AVGSIZE: |
| 11788 | case BGP_STATS_AVGPLEN: |
| 11789 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11790 | vty_out (vty, "%12.2f", |
| 11791 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 11792 | break; |
| 11793 | #endif |
| 11794 | case BGP_STATS_ASPATH_TOTHOPS: |
| 11795 | case BGP_STATS_ASPATH_TOTSIZE: |
| 11796 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11797 | vty_out (vty, "%12.2f", |
| 11798 | ts.counts[i] ? |
| 11799 | (float)ts.counts[i] / |
| 11800 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 11801 | : 0); |
| 11802 | break; |
| 11803 | case BGP_STATS_TOTPLEN: |
| 11804 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11805 | vty_out (vty, "%12.2f", |
| 11806 | ts.counts[i] ? |
| 11807 | (float)ts.counts[i] / |
| 11808 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 11809 | : 0); |
| 11810 | break; |
| 11811 | case BGP_STATS_SPACE: |
| 11812 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11813 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 11814 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 11815 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 11816 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11817 | vty_out (vty, "%12.2f%s", |
| 11818 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 11819 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11820 | VTY_NEWLINE); |
| 11821 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 11822 | vty_out (vty, "%12.2f%s", |
| 11823 | (float)ts.counts[BGP_STATS_SPACE] / |
| 11824 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 11825 | VTY_NEWLINE); |
| 11826 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 11827 | break; |
| 11828 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 11829 | vty_out (vty, "%12.2f", |
| 11830 | (float)ts.counts[BGP_STATS_SPACE] / |
| 11831 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 11832 | break; |
| 11833 | default: |
| 11834 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11835 | vty_out (vty, "%12llu", ts.counts[i]); |
| 11836 | } |
| 11837 | |
| 11838 | vty_out (vty, "%s", VTY_NEWLINE); |
| 11839 | } |
| 11840 | return CMD_SUCCESS; |
| 11841 | } |
| 11842 | |
| 11843 | static int |
| 11844 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 11845 | const char *afi_str, const char *safi_str) |
| 11846 | { |
| 11847 | struct bgp *bgp; |
| 11848 | afi_t afi; |
| 11849 | safi_t safi; |
| 11850 | |
| 11851 | if (name) |
| 11852 | bgp = bgp_lookup_by_name (name); |
| 11853 | else |
| 11854 | bgp = bgp_get_default (); |
| 11855 | |
| 11856 | if (!bgp) |
| 11857 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 11858 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11859 | return CMD_WARNING; |
| 11860 | } |
| 11861 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 11862 | { |
| 11863 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 11864 | afi = AFI_IP; |
| 11865 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 11866 | afi = AFI_IP6; |
| 11867 | else |
| 11868 | { |
| 11869 | vty_out (vty, "%% Invalid address family %s%s", |
| 11870 | afi_str, VTY_NEWLINE); |
| 11871 | return CMD_WARNING; |
| 11872 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11873 | switch (safi_str[0]) { |
| 11874 | case 'm': |
| 11875 | safi = SAFI_MULTICAST; |
| 11876 | break; |
| 11877 | case 'u': |
| 11878 | safi = SAFI_UNICAST; |
| 11879 | break; |
| 11880 | case 'v': |
| 11881 | safi = SAFI_MPLS_LABELED_VPN; |
| 11882 | break; |
| 11883 | case 'e': |
| 11884 | safi = SAFI_ENCAP; |
| 11885 | break; |
| 11886 | default: |
| 11887 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11888 | safi_str, VTY_NEWLINE); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11889 | return CMD_WARNING; |
| 11890 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11891 | } |
| 11892 | else |
| 11893 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11894 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11895 | afi_str, VTY_NEWLINE); |
| 11896 | return CMD_WARNING; |
| 11897 | } |
| 11898 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11899 | return bgp_table_stats (vty, bgp, afi, safi); |
| 11900 | } |
| 11901 | |
| 11902 | DEFUN (show_bgp_statistics, |
| 11903 | show_bgp_statistics_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11904 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11905 | SHOW_STR |
| 11906 | BGP_STR |
| 11907 | "Address family\n" |
| 11908 | "Address family\n" |
| 11909 | "Address Family modifier\n" |
| 11910 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11911 | "Address Family modifier\n" |
| 11912 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11913 | "BGP RIB advertisement statistics\n") |
| 11914 | { |
| 11915 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 11916 | } |
| 11917 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11918 | ALIAS (show_bgp_statistics, |
| 11919 | show_bgp_statistics_vpnv4_cmd, |
| 11920 | "show bgp (ipv4) (vpnv4) statistics", |
| 11921 | SHOW_STR |
| 11922 | BGP_STR |
| 11923 | "Address family\n" |
| 11924 | "Address Family modifier\n" |
| 11925 | "BGP RIB advertisement statistics\n") |
| 11926 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11927 | DEFUN (show_bgp_statistics_view, |
| 11928 | show_bgp_statistics_view_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11929 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11930 | SHOW_STR |
| 11931 | BGP_STR |
| 11932 | "BGP view\n" |
| 11933 | "Address family\n" |
| 11934 | "Address family\n" |
| 11935 | "Address Family modifier\n" |
| 11936 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11937 | "Address Family modifier\n" |
| 11938 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11939 | "BGP RIB advertisement statistics\n") |
| 11940 | { |
| 11941 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 11942 | } |
| 11943 | |
| 11944 | ALIAS (show_bgp_statistics_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11945 | show_bgp_statistics_view_vpnv4_cmd, |
| 11946 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11947 | SHOW_STR |
| 11948 | BGP_STR |
| 11949 | "BGP view\n" |
| 11950 | "Address family\n" |
| 11951 | "Address Family modifier\n" |
| 11952 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11953 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11954 | enum bgp_pcounts |
| 11955 | { |
| 11956 | PCOUNT_ADJ_IN = 0, |
| 11957 | PCOUNT_DAMPED, |
| 11958 | PCOUNT_REMOVED, |
| 11959 | PCOUNT_HISTORY, |
| 11960 | PCOUNT_STALE, |
| 11961 | PCOUNT_VALID, |
| 11962 | PCOUNT_ALL, |
| 11963 | PCOUNT_COUNTED, |
| 11964 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 11965 | PCOUNT_MAX, |
| 11966 | }; |
| 11967 | |
| 11968 | static const char *pcount_strs[] = |
| 11969 | { |
| 11970 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 11971 | [PCOUNT_DAMPED] = "Damped", |
| 11972 | [PCOUNT_REMOVED] = "Removed", |
| 11973 | [PCOUNT_HISTORY] = "History", |
| 11974 | [PCOUNT_STALE] = "Stale", |
| 11975 | [PCOUNT_VALID] = "Valid", |
| 11976 | [PCOUNT_ALL] = "All RIB", |
| 11977 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 11978 | [PCOUNT_PFCNT] = "Useable", |
| 11979 | [PCOUNT_MAX] = NULL, |
| 11980 | }; |
| 11981 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11982 | struct peer_pcounts |
| 11983 | { |
| 11984 | unsigned int count[PCOUNT_MAX]; |
| 11985 | const struct peer *peer; |
| 11986 | const struct bgp_table *table; |
| 11987 | }; |
| 11988 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11989 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11990 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11991 | { |
| 11992 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11993 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 11994 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11995 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11996 | 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] | 11997 | { |
| 11998 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11999 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12000 | |
| 12001 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12002 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12003 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12004 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12005 | for (ri = rn->info; ri; ri = ri->next) |
| 12006 | { |
| 12007 | char buf[SU_ADDRSTRLEN]; |
| 12008 | |
| 12009 | if (ri->peer != peer) |
| 12010 | continue; |
| 12011 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12012 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12013 | |
| 12014 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12015 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12016 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12017 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12018 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12019 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12020 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12021 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12022 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12023 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12024 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12025 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12026 | |
| 12027 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 12028 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12029 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12030 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12031 | plog_warn (peer->log, |
| 12032 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 12033 | peer->host, |
| 12034 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12035 | buf, SU_ADDRSTRLEN), |
| 12036 | rn->p.prefixlen, |
| 12037 | ri->flags); |
| 12038 | } |
| 12039 | else |
| 12040 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12041 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12042 | plog_warn (peer->log, |
| 12043 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 12044 | peer->host, |
| 12045 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12046 | buf, SU_ADDRSTRLEN), |
| 12047 | rn->p.prefixlen, |
| 12048 | ri->flags); |
| 12049 | } |
| 12050 | } |
| 12051 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12052 | return 0; |
| 12053 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12054 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12055 | static int |
| 12056 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 12057 | { |
| 12058 | struct peer_pcounts pcounts = { .peer = peer }; |
| 12059 | unsigned int i; |
| 12060 | |
| 12061 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 12062 | || !peer->bgp->rib[afi][safi]) |
| 12063 | { |
| 12064 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12065 | return CMD_WARNING; |
| 12066 | } |
| 12067 | |
| 12068 | memset (&pcounts, 0, sizeof(pcounts)); |
| 12069 | pcounts.peer = peer; |
| 12070 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 12071 | |
| 12072 | /* in-place call via thread subsystem so as to record execution time |
| 12073 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 12074 | * on just vty_read()). |
| 12075 | */ |
| 12076 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 12077 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12078 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 12079 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 12080 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 12081 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 12082 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 12083 | |
| 12084 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12085 | vty_out (vty, "%20s: %-10d%s", |
| 12086 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12087 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12088 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12089 | { |
| 12090 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 12091 | peer->host, VTY_NEWLINE); |
| 12092 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 12093 | VTY_NEWLINE); |
| 12094 | } |
| 12095 | |
| 12096 | return CMD_SUCCESS; |
| 12097 | } |
| 12098 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12099 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 12100 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 12101 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12102 | SHOW_STR |
| 12103 | IP_STR |
| 12104 | BGP_STR |
| 12105 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12106 | "Neighbor to display information about\n" |
| 12107 | "Neighbor to display information about\n" |
| 12108 | "Display detailed prefix count information\n") |
| 12109 | { |
| 12110 | struct peer *peer; |
| 12111 | |
| 12112 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12113 | if (! peer) |
| 12114 | return CMD_WARNING; |
| 12115 | |
| 12116 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12117 | } |
| 12118 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12119 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 12120 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 12121 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12122 | SHOW_STR |
| 12123 | BGP_STR |
| 12124 | "Address family\n" |
| 12125 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12126 | "Neighbor to display information about\n" |
| 12127 | "Neighbor to display information about\n" |
| 12128 | "Display detailed prefix count information\n") |
| 12129 | { |
| 12130 | struct peer *peer; |
| 12131 | |
| 12132 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12133 | if (! peer) |
| 12134 | return CMD_WARNING; |
| 12135 | |
| 12136 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 12137 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12138 | |
| 12139 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 12140 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 12141 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12142 | SHOW_STR |
| 12143 | IP_STR |
| 12144 | BGP_STR |
| 12145 | "Address family\n" |
| 12146 | "Address Family modifier\n" |
| 12147 | "Address Family modifier\n" |
| 12148 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12149 | "Neighbor to display information about\n" |
| 12150 | "Neighbor to display information about\n" |
| 12151 | "Display detailed prefix count information\n") |
| 12152 | { |
| 12153 | struct peer *peer; |
| 12154 | |
| 12155 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12156 | if (! peer) |
| 12157 | return CMD_WARNING; |
| 12158 | |
| 12159 | if (strncmp (argv[0], "m", 1) == 0) |
| 12160 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 12161 | |
| 12162 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12163 | } |
| 12164 | |
| 12165 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 12166 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 12167 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12168 | SHOW_STR |
| 12169 | IP_STR |
| 12170 | BGP_STR |
| 12171 | "Address family\n" |
| 12172 | "Address Family modifier\n" |
| 12173 | "Address Family modifier\n" |
| 12174 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12175 | "Neighbor to display information about\n" |
| 12176 | "Neighbor to display information about\n" |
| 12177 | "Display detailed prefix count information\n") |
| 12178 | { |
| 12179 | struct peer *peer; |
| 12180 | |
| 12181 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12182 | if (! peer) |
| 12183 | return CMD_WARNING; |
| 12184 | |
| 12185 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 12186 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12187 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12188 | DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts, |
| 12189 | show_bgp_ipv4_safi_neighbor_prefix_counts_cmd, |
| 12190 | "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] | 12191 | SHOW_STR |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12192 | BGP_STR |
| 12193 | "Address family\n" |
| 12194 | "Address Family modifier\n" |
| 12195 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12196 | "Address Family modifier\n" |
| 12197 | "Address Family modifier\n" |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12198 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12199 | "Neighbor to display information about\n" |
| 12200 | "Neighbor to display information about\n" |
| 12201 | "Display detailed prefix count information\n") |
| 12202 | { |
| 12203 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12204 | safi_t safi; |
| 12205 | |
| 12206 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12207 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12208 | return CMD_WARNING; |
| 12209 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12210 | |
| 12211 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12212 | if (! peer) |
| 12213 | return CMD_WARNING; |
| 12214 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12215 | return bgp_peer_counts (vty, peer, AFI_IP, safi); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12216 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12217 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12218 | DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts, |
| 12219 | show_bgp_ipv6_safi_neighbor_prefix_counts_cmd, |
| 12220 | "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12221 | SHOW_STR |
| 12222 | BGP_STR |
| 12223 | "Address family\n" |
| 12224 | "Address Family modifier\n" |
| 12225 | "Address Family modifier\n" |
| 12226 | "Address Family modifier\n" |
| 12227 | "Address Family modifier\n" |
| 12228 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12229 | "Neighbor to display information about\n" |
| 12230 | "Neighbor to display information about\n" |
| 12231 | "Display detailed prefix count information\n") |
| 12232 | { |
| 12233 | struct peer *peer; |
| 12234 | safi_t safi; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12235 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12236 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12237 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12238 | return CMD_WARNING; |
| 12239 | } |
| 12240 | |
| 12241 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12242 | if (! peer) |
| 12243 | return CMD_WARNING; |
| 12244 | |
| 12245 | return bgp_peer_counts (vty, peer, AFI_IP6, safi); |
| 12246 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12247 | |
| 12248 | DEFUN (show_ip_bgp_encap_neighbor_prefix_counts, |
| 12249 | show_ip_bgp_encap_neighbor_prefix_counts_cmd, |
| 12250 | "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] | 12251 | SHOW_STR |
| 12252 | IP_STR |
| 12253 | BGP_STR |
| 12254 | "Address family\n" |
| 12255 | "Address Family modifier\n" |
| 12256 | "Address Family modifier\n" |
| 12257 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12258 | "Neighbor to display information about\n" |
| 12259 | "Neighbor to display information about\n" |
| 12260 | "Display detailed prefix count information\n") |
| 12261 | { |
| 12262 | struct peer *peer; |
| 12263 | |
| 12264 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12265 | if (! peer) |
| 12266 | return CMD_WARNING; |
| 12267 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12268 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12269 | } |
| 12270 | |
| 12271 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12272 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12273 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 12274 | int in) |
| 12275 | { |
| 12276 | struct bgp_table *table; |
| 12277 | struct bgp_adj_in *ain; |
| 12278 | struct bgp_adj_out *adj; |
| 12279 | unsigned long output_count; |
| 12280 | struct bgp_node *rn; |
| 12281 | int header1 = 1; |
| 12282 | struct bgp *bgp; |
| 12283 | int header2 = 1; |
| 12284 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12285 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12286 | |
| 12287 | if (! bgp) |
| 12288 | return; |
| 12289 | |
| 12290 | table = bgp->rib[afi][safi]; |
| 12291 | |
| 12292 | output_count = 0; |
| 12293 | |
| 12294 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 12295 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 12296 | { |
| 12297 | 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] | 12298 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12299 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12300 | |
| 12301 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 12302 | VTY_NEWLINE, VTY_NEWLINE); |
| 12303 | header1 = 0; |
| 12304 | } |
| 12305 | |
| 12306 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12307 | if (in) |
| 12308 | { |
| 12309 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12310 | if (ain->peer == peer) |
| 12311 | { |
| 12312 | if (header1) |
| 12313 | { |
| 12314 | 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] | 12315 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12316 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12317 | header1 = 0; |
| 12318 | } |
| 12319 | if (header2) |
| 12320 | { |
| 12321 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12322 | header2 = 0; |
| 12323 | } |
| 12324 | if (ain->attr) |
| 12325 | { |
| 12326 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 12327 | output_count++; |
| 12328 | } |
| 12329 | } |
| 12330 | } |
| 12331 | else |
| 12332 | { |
| 12333 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 12334 | if (adj->peer == peer) |
| 12335 | { |
| 12336 | if (header1) |
| 12337 | { |
| 12338 | 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] | 12339 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12340 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12341 | header1 = 0; |
| 12342 | } |
| 12343 | if (header2) |
| 12344 | { |
| 12345 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12346 | header2 = 0; |
| 12347 | } |
| 12348 | if (adj->attr) |
| 12349 | { |
| 12350 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 12351 | output_count++; |
| 12352 | } |
| 12353 | } |
| 12354 | } |
| 12355 | |
| 12356 | if (output_count != 0) |
| 12357 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 12358 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 12359 | } |
| 12360 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12361 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12362 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 12363 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12364 | if (! peer || ! peer->afc[afi][safi]) |
| 12365 | { |
| 12366 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12367 | return CMD_WARNING; |
| 12368 | } |
| 12369 | |
| 12370 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 12371 | { |
| 12372 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 12373 | VTY_NEWLINE); |
| 12374 | return CMD_WARNING; |
| 12375 | } |
| 12376 | |
| 12377 | show_adj_route (vty, peer, afi, safi, in); |
| 12378 | |
| 12379 | return CMD_SUCCESS; |
| 12380 | } |
| 12381 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12382 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 12383 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 12384 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12385 | SHOW_STR |
| 12386 | IP_STR |
| 12387 | BGP_STR |
| 12388 | "BGP view\n" |
| 12389 | "View name\n" |
| 12390 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12391 | "Neighbor to display information about\n" |
| 12392 | "Neighbor to display information about\n" |
| 12393 | "Display the routes advertised to a BGP neighbor\n") |
| 12394 | { |
| 12395 | struct peer *peer; |
| 12396 | |
| 12397 | if (argc == 2) |
| 12398 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12399 | else |
| 12400 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12401 | |
| 12402 | if (! peer) |
| 12403 | return CMD_WARNING; |
| 12404 | |
| 12405 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12406 | } |
| 12407 | |
| 12408 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
| 12409 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 12410 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12411 | SHOW_STR |
| 12412 | IP_STR |
| 12413 | BGP_STR |
| 12414 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12415 | "Neighbor to display information about\n" |
| 12416 | "Neighbor to display information about\n" |
| 12417 | "Display the routes advertised to a BGP neighbor\n") |
| 12418 | |
| 12419 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 12420 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 12421 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12422 | SHOW_STR |
| 12423 | IP_STR |
| 12424 | BGP_STR |
| 12425 | "Address family\n" |
| 12426 | "Address Family modifier\n" |
| 12427 | "Address Family modifier\n" |
| 12428 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12429 | "Neighbor to display information about\n" |
| 12430 | "Neighbor to display information about\n" |
| 12431 | "Display the routes advertised to a BGP neighbor\n") |
| 12432 | { |
| 12433 | struct peer *peer; |
| 12434 | |
| 12435 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12436 | if (! peer) |
| 12437 | return CMD_WARNING; |
| 12438 | |
| 12439 | if (strncmp (argv[0], "m", 1) == 0) |
| 12440 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 12441 | |
| 12442 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12443 | } |
| 12444 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12445 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 12446 | show_bgp_view_neighbor_advertised_route_cmd, |
| 12447 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12448 | SHOW_STR |
| 12449 | BGP_STR |
| 12450 | "BGP view\n" |
| 12451 | "View name\n" |
| 12452 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12453 | "Neighbor to display information about\n" |
| 12454 | "Neighbor to display information about\n" |
| 12455 | "Display the routes advertised to a BGP neighbor\n") |
| 12456 | { |
| 12457 | struct peer *peer; |
| 12458 | |
| 12459 | if (argc == 2) |
| 12460 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12461 | else |
| 12462 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12463 | |
| 12464 | if (! peer) |
| 12465 | return CMD_WARNING; |
| 12466 | |
| 12467 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 12468 | } |
| 12469 | |
| 12470 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 12471 | show_bgp_view_neighbor_received_routes_cmd, |
| 12472 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12473 | SHOW_STR |
| 12474 | BGP_STR |
| 12475 | "BGP view\n" |
| 12476 | "View name\n" |
| 12477 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12478 | "Neighbor to display information about\n" |
| 12479 | "Neighbor to display information about\n" |
| 12480 | "Display the received routes from neighbor\n") |
| 12481 | { |
| 12482 | struct peer *peer; |
| 12483 | |
| 12484 | if (argc == 2) |
| 12485 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12486 | else |
| 12487 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12488 | |
| 12489 | if (! peer) |
| 12490 | return CMD_WARNING; |
| 12491 | |
| 12492 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 12493 | } |
| 12494 | |
| 12495 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12496 | show_bgp_neighbor_advertised_route_cmd, |
| 12497 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12498 | SHOW_STR |
| 12499 | BGP_STR |
| 12500 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12501 | "Neighbor to display information about\n" |
| 12502 | "Neighbor to display information about\n" |
| 12503 | "Display the routes advertised to a BGP neighbor\n") |
| 12504 | |
| 12505 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12506 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 12507 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12508 | SHOW_STR |
| 12509 | BGP_STR |
| 12510 | "Address family\n" |
| 12511 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12512 | "Neighbor to display information about\n" |
| 12513 | "Neighbor to display information about\n" |
| 12514 | "Display the routes advertised to a BGP neighbor\n") |
| 12515 | |
| 12516 | /* old command */ |
| 12517 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12518 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 12519 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12520 | SHOW_STR |
| 12521 | IPV6_STR |
| 12522 | BGP_STR |
| 12523 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12524 | "Neighbor to display information about\n" |
| 12525 | "Neighbor to display information about\n" |
| 12526 | "Display the routes advertised to a BGP neighbor\n") |
| 12527 | |
| 12528 | /* old command */ |
| 12529 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 12530 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 12531 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12532 | SHOW_STR |
| 12533 | IPV6_STR |
| 12534 | MBGP_STR |
| 12535 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12536 | "Neighbor to display information about\n" |
| 12537 | "Neighbor to display information about\n" |
| 12538 | "Display the routes advertised to a BGP neighbor\n") |
| 12539 | { |
| 12540 | struct peer *peer; |
| 12541 | |
| 12542 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12543 | if (! peer) |
| 12544 | return CMD_WARNING; |
| 12545 | |
| 12546 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
| 12547 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12548 | |
| 12549 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 12550 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 12551 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12552 | SHOW_STR |
| 12553 | IP_STR |
| 12554 | BGP_STR |
| 12555 | "BGP view\n" |
| 12556 | "View name\n" |
| 12557 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12558 | "Neighbor to display information about\n" |
| 12559 | "Neighbor to display information about\n" |
| 12560 | "Display the received routes from neighbor\n") |
| 12561 | { |
| 12562 | struct peer *peer; |
| 12563 | |
| 12564 | if (argc == 2) |
| 12565 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12566 | else |
| 12567 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12568 | |
| 12569 | if (! peer) |
| 12570 | return CMD_WARNING; |
| 12571 | |
| 12572 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12573 | } |
| 12574 | |
| 12575 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
| 12576 | show_ip_bgp_neighbor_received_routes_cmd, |
| 12577 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12578 | SHOW_STR |
| 12579 | IP_STR |
| 12580 | BGP_STR |
| 12581 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12582 | "Neighbor to display information about\n" |
| 12583 | "Neighbor to display information about\n" |
| 12584 | "Display the received routes from neighbor\n") |
| 12585 | |
| 12586 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12587 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 12588 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12589 | SHOW_STR |
| 12590 | BGP_STR |
| 12591 | "Address family\n" |
| 12592 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12593 | "Neighbor to display information about\n" |
| 12594 | "Neighbor to display information about\n" |
| 12595 | "Display the received routes from neighbor\n") |
| 12596 | |
| 12597 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 12598 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 12599 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12600 | SHOW_STR |
| 12601 | BGP_STR |
| 12602 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12603 | "Neighbor to display information about\n" |
| 12604 | "Neighbor to display information about\n" |
| 12605 | "Display information received from a BGP neighbor\n" |
| 12606 | "Display the prefixlist filter\n") |
| 12607 | { |
| 12608 | char name[BUFSIZ]; |
| 12609 | union sockunion su; |
| 12610 | struct peer *peer; |
| 12611 | int count, ret; |
| 12612 | |
| 12613 | ret = str2sockunion (argv[0], &su); |
| 12614 | if (ret < 0) |
| 12615 | { |
| 12616 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 12617 | return CMD_WARNING; |
| 12618 | } |
| 12619 | |
| 12620 | peer = peer_lookup (NULL, &su); |
| 12621 | if (! peer) |
| 12622 | return CMD_WARNING; |
| 12623 | |
| 12624 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12625 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12626 | if (count) |
| 12627 | { |
| 12628 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12629 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12630 | } |
| 12631 | |
| 12632 | return CMD_SUCCESS; |
| 12633 | } |
| 12634 | |
| 12635 | /* old command */ |
| 12636 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12637 | ipv6_bgp_neighbor_received_routes_cmd, |
| 12638 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12639 | SHOW_STR |
| 12640 | IPV6_STR |
| 12641 | BGP_STR |
| 12642 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12643 | "Neighbor to display information about\n" |
| 12644 | "Neighbor to display information about\n" |
| 12645 | "Display the received routes from neighbor\n") |
| 12646 | |
| 12647 | /* old command */ |
| 12648 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 12649 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 12650 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12651 | SHOW_STR |
| 12652 | IPV6_STR |
| 12653 | MBGP_STR |
| 12654 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12655 | "Neighbor to display information about\n" |
| 12656 | "Neighbor to display information about\n" |
| 12657 | "Display the received routes from neighbor\n") |
| 12658 | { |
| 12659 | struct peer *peer; |
| 12660 | |
| 12661 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12662 | if (! peer) |
| 12663 | return CMD_WARNING; |
| 12664 | |
| 12665 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
| 12666 | } |
| 12667 | |
| 12668 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 12669 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 12670 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12671 | SHOW_STR |
| 12672 | BGP_STR |
| 12673 | "BGP view\n" |
| 12674 | "View name\n" |
| 12675 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12676 | "Neighbor to display information about\n" |
| 12677 | "Neighbor to display information about\n" |
| 12678 | "Display information received from a BGP neighbor\n" |
| 12679 | "Display the prefixlist filter\n") |
| 12680 | { |
| 12681 | char name[BUFSIZ]; |
| 12682 | union sockunion su; |
| 12683 | struct peer *peer; |
| 12684 | struct bgp *bgp; |
| 12685 | int count, ret; |
| 12686 | |
| 12687 | /* BGP structure lookup. */ |
| 12688 | bgp = bgp_lookup_by_name (argv[0]); |
| 12689 | if (bgp == NULL) |
| 12690 | { |
| 12691 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 12692 | return CMD_WARNING; |
| 12693 | } |
| 12694 | |
| 12695 | ret = str2sockunion (argv[1], &su); |
| 12696 | if (ret < 0) |
| 12697 | { |
| 12698 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 12699 | return CMD_WARNING; |
| 12700 | } |
| 12701 | |
| 12702 | peer = peer_lookup (bgp, &su); |
| 12703 | if (! peer) |
| 12704 | return CMD_WARNING; |
| 12705 | |
| 12706 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12707 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12708 | if (count) |
| 12709 | { |
| 12710 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12711 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12712 | } |
| 12713 | |
| 12714 | return CMD_SUCCESS; |
| 12715 | } |
| 12716 | |
| 12717 | |
| 12718 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 12719 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 12720 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12721 | SHOW_STR |
| 12722 | IP_STR |
| 12723 | BGP_STR |
| 12724 | "Address family\n" |
| 12725 | "Address Family modifier\n" |
| 12726 | "Address Family modifier\n" |
| 12727 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12728 | "Neighbor to display information about\n" |
| 12729 | "Neighbor to display information about\n" |
| 12730 | "Display the received routes from neighbor\n") |
| 12731 | { |
| 12732 | struct peer *peer; |
| 12733 | |
| 12734 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12735 | if (! peer) |
| 12736 | return CMD_WARNING; |
| 12737 | |
| 12738 | if (strncmp (argv[0], "m", 1) == 0) |
| 12739 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 12740 | |
| 12741 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12742 | } |
| 12743 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12744 | DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route, |
| 12745 | show_bgp_ipv4_safi_neighbor_advertised_route_cmd, |
| 12746 | "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] | 12747 | SHOW_STR |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12748 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12749 | "Address Family modifier\n" |
| 12750 | "Address Family modifier\n" |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12751 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12752 | "Neighbor to display information about\n" |
| 12753 | "Neighbor to display information about\n" |
| 12754 | "Display the routes advertised to a BGP neighbor\n") |
| 12755 | { |
| 12756 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12757 | safi_t safi; |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12758 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12759 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12760 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12761 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12762 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12763 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12764 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12765 | if (! peer) |
| 12766 | return CMD_WARNING; |
| 12767 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12768 | return peer_adj_routes (vty, peer, AFI_IP, safi, 0); |
| 12769 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12770 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12771 | DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route, |
| 12772 | show_bgp_ipv6_safi_neighbor_advertised_route_cmd, |
| 12773 | "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12774 | SHOW_STR |
| 12775 | BGP_STR |
| 12776 | "Address Family modifier\n" |
| 12777 | "Address Family modifier\n" |
| 12778 | "Address Family modifier\n" |
| 12779 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12780 | "Neighbor to display information about\n" |
| 12781 | "Neighbor to display information about\n" |
| 12782 | "Display the routes advertised to a BGP neighbor\n") |
| 12783 | { |
| 12784 | struct peer *peer; |
| 12785 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12786 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12787 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12788 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12789 | return CMD_WARNING; |
| 12790 | } |
| 12791 | |
| 12792 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12793 | if (! peer) |
| 12794 | return CMD_WARNING; |
| 12795 | |
| 12796 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12797 | } |
| 12798 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12799 | DEFUN (show_bgp_view_ipv6_neighbor_advertised_route, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12800 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 12801 | "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] | 12802 | SHOW_STR |
| 12803 | BGP_STR |
| 12804 | "BGP view\n" |
| 12805 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12806 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12807 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12808 | "Neighbor to display information about\n" |
| 12809 | "Neighbor to display information about\n" |
| 12810 | "Display the routes advertised to a BGP neighbor\n") |
| 12811 | { |
| 12812 | struct peer *peer; |
| 12813 | |
| 12814 | if (argc == 2) |
| 12815 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12816 | else |
| 12817 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12818 | |
| 12819 | if (! peer) |
| 12820 | return CMD_WARNING; |
| 12821 | |
| 12822 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 12823 | } |
| 12824 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12825 | DEFUN (show_bgp_view_ipv6_neighbor_received_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12826 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 12827 | "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] | 12828 | SHOW_STR |
| 12829 | BGP_STR |
| 12830 | "BGP view\n" |
| 12831 | "View name\n" |
| 12832 | "Address family\n" |
| 12833 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12834 | "Neighbor to display information about\n" |
| 12835 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12836 | "Display the received routes from neighbor\n") |
| 12837 | { |
| 12838 | struct peer *peer; |
| 12839 | |
| 12840 | if (argc == 2) |
| 12841 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12842 | else |
| 12843 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12844 | |
| 12845 | if (! peer) |
| 12846 | return CMD_WARNING; |
| 12847 | |
| 12848 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 12849 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12850 | |
| 12851 | DEFUN (show_bgp_ipv4_safi_neighbor_received_routes, |
| 12852 | show_bgp_ipv4_safi_neighbor_received_routes_cmd, |
| 12853 | "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] | 12854 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12855 | BGP_STR |
| 12856 | "Address family\n" |
| 12857 | "Address Family modifier\n" |
| 12858 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12859 | "Address Family modifier\n" |
| 12860 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12861 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12862 | "Neighbor to display information about\n" |
| 12863 | "Neighbor to display information about\n" |
| 12864 | "Display the received routes from neighbor\n") |
| 12865 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12866 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12867 | safi_t safi; |
| 12868 | |
| 12869 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12870 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12871 | return CMD_WARNING; |
| 12872 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12873 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12874 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12875 | if (! peer) |
| 12876 | return CMD_WARNING; |
| 12877 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12878 | return peer_adj_routes (vty, peer, AFI_IP, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12879 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12880 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12881 | DEFUN (show_bgp_ipv6_safi_neighbor_received_routes, |
| 12882 | show_bgp_ipv6_safi_neighbor_received_routes_cmd, |
| 12883 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12884 | SHOW_STR |
| 12885 | BGP_STR |
| 12886 | "Address family\n" |
| 12887 | "Address Family modifier\n" |
| 12888 | "Address Family modifier\n" |
| 12889 | "Address Family modifier\n" |
| 12890 | "Address Family modifier\n" |
| 12891 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12892 | "Neighbor to display information about\n" |
| 12893 | "Neighbor to display information about\n" |
| 12894 | "Display the received routes from neighbor\n") |
| 12895 | { |
| 12896 | struct peer *peer; |
| 12897 | safi_t safi; |
| 12898 | |
| 12899 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12900 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12901 | return CMD_WARNING; |
| 12902 | } |
| 12903 | |
| 12904 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12905 | if (! peer) |
| 12906 | return CMD_WARNING; |
| 12907 | |
| 12908 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 1); |
| 12909 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12910 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12911 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 12912 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12913 | "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] | 12914 | SHOW_STR |
| 12915 | BGP_STR |
| 12916 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 12917 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12918 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12919 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12920 | "Address family modifier\n" |
| 12921 | "Address family modifier\n" |
| 12922 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12923 | "Neighbor to display information about\n" |
| 12924 | "Neighbor to display information about\n" |
| 12925 | "Display the advertised routes to neighbor\n" |
| 12926 | "Display the received routes from neighbor\n") |
| 12927 | { |
| 12928 | int afi; |
| 12929 | int safi; |
| 12930 | int in; |
| 12931 | struct peer *peer; |
| 12932 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 12933 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12934 | |
| 12935 | if (! peer) |
| 12936 | return CMD_WARNING; |
| 12937 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12938 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 12939 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 12940 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12941 | |
| 12942 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 12943 | } |
| 12944 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12945 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 12946 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 12947 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12948 | SHOW_STR |
| 12949 | IP_STR |
| 12950 | BGP_STR |
| 12951 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12952 | "Neighbor to display information about\n" |
| 12953 | "Neighbor to display information about\n" |
| 12954 | "Display information received from a BGP neighbor\n" |
| 12955 | "Display the prefixlist filter\n") |
| 12956 | { |
| 12957 | char name[BUFSIZ]; |
| 12958 | union sockunion su; |
| 12959 | struct peer *peer; |
| 12960 | int count, ret; |
| 12961 | |
| 12962 | ret = str2sockunion (argv[0], &su); |
| 12963 | if (ret < 0) |
| 12964 | { |
| 12965 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 12966 | return CMD_WARNING; |
| 12967 | } |
| 12968 | |
| 12969 | peer = peer_lookup (NULL, &su); |
| 12970 | if (! peer) |
| 12971 | return CMD_WARNING; |
| 12972 | |
| 12973 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 12974 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 12975 | if (count) |
| 12976 | { |
| 12977 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 12978 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 12979 | } |
| 12980 | |
| 12981 | return CMD_SUCCESS; |
| 12982 | } |
| 12983 | |
| 12984 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 12985 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 12986 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12987 | SHOW_STR |
| 12988 | IP_STR |
| 12989 | BGP_STR |
| 12990 | "Address family\n" |
| 12991 | "Address Family modifier\n" |
| 12992 | "Address Family modifier\n" |
| 12993 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12994 | "Neighbor to display information about\n" |
| 12995 | "Neighbor to display information about\n" |
| 12996 | "Display information received from a BGP neighbor\n" |
| 12997 | "Display the prefixlist filter\n") |
| 12998 | { |
| 12999 | char name[BUFSIZ]; |
| 13000 | union sockunion su; |
| 13001 | struct peer *peer; |
| 13002 | int count, ret; |
| 13003 | |
| 13004 | ret = str2sockunion (argv[1], &su); |
| 13005 | if (ret < 0) |
| 13006 | { |
| 13007 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13008 | return CMD_WARNING; |
| 13009 | } |
| 13010 | |
| 13011 | peer = peer_lookup (NULL, &su); |
| 13012 | if (! peer) |
| 13013 | return CMD_WARNING; |
| 13014 | |
| 13015 | if (strncmp (argv[0], "m", 1) == 0) |
| 13016 | { |
| 13017 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 13018 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13019 | if (count) |
| 13020 | { |
| 13021 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 13022 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13023 | } |
| 13024 | } |
| 13025 | else |
| 13026 | { |
| 13027 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13028 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13029 | if (count) |
| 13030 | { |
| 13031 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13032 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13033 | } |
| 13034 | } |
| 13035 | |
| 13036 | return CMD_SUCCESS; |
| 13037 | } |
| 13038 | |
| 13039 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 13040 | show_bgp_neighbor_received_routes_cmd, |
| 13041 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13042 | SHOW_STR |
| 13043 | BGP_STR |
| 13044 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13045 | "Neighbor to display information about\n" |
| 13046 | "Neighbor to display information about\n" |
| 13047 | "Display the received routes from neighbor\n") |
| 13048 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13049 | DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter, |
| 13050 | show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd, |
| 13051 | "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] | 13052 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13053 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13054 | IP_STR |
| 13055 | "Address Family modifier\n" |
| 13056 | "Address Family modifier\n" |
| 13057 | "Address Family modifier\n" |
| 13058 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13059 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13060 | "Neighbor to display information about\n" |
| 13061 | "Neighbor to display information about\n" |
| 13062 | "Display information received from a BGP neighbor\n" |
| 13063 | "Display the prefixlist filter\n") |
| 13064 | { |
| 13065 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13066 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13067 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13068 | int count, ret; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13069 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13070 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13071 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13072 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13073 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13074 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13075 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13076 | ret = str2sockunion (argv[1], &su); |
| 13077 | if (ret < 0) |
| 13078 | { |
| 13079 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13080 | return CMD_WARNING; |
| 13081 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13082 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13083 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13084 | if (! peer) |
| 13085 | return CMD_WARNING; |
| 13086 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13087 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi); |
| 13088 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13089 | if (count) { |
| 13090 | vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13091 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13092 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13093 | |
| 13094 | return CMD_SUCCESS; |
| 13095 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13096 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13097 | DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter, |
| 13098 | show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd, |
| 13099 | "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] | 13100 | SHOW_STR |
| 13101 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13102 | IP_STR |
| 13103 | "Address Family modifier\n" |
| 13104 | "Address Family modifier\n" |
| 13105 | "Address Family modifier\n" |
| 13106 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13107 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13108 | "Neighbor to display information about\n" |
| 13109 | "Neighbor to display information about\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13110 | "Display information received from a BGP neighbor\n" |
| 13111 | "Display the prefixlist filter\n") |
| 13112 | { |
| 13113 | char name[BUFSIZ]; |
| 13114 | union sockunion su; |
| 13115 | struct peer *peer; |
| 13116 | int count, ret; |
| 13117 | safi_t safi; |
| 13118 | |
| 13119 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13120 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13121 | return CMD_WARNING; |
| 13122 | } |
| 13123 | |
| 13124 | ret = str2sockunion (argv[1], &su); |
| 13125 | if (ret < 0) |
| 13126 | { |
| 13127 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13128 | return CMD_WARNING; |
| 13129 | } |
| 13130 | |
| 13131 | peer = peer_lookup (NULL, &su); |
| 13132 | if (! peer) |
| 13133 | return CMD_WARNING; |
| 13134 | |
| 13135 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi); |
| 13136 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13137 | if (count) { |
| 13138 | vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13139 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13140 | } |
| 13141 | |
| 13142 | return CMD_SUCCESS; |
| 13143 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13144 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13145 | DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13146 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 13147 | "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] | 13148 | SHOW_STR |
| 13149 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13150 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13151 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13152 | "Neighbor to display information about\n" |
| 13153 | "Neighbor to display information about\n" |
| 13154 | "Display information received from a BGP neighbor\n" |
| 13155 | "Display the prefixlist filter\n") |
| 13156 | { |
| 13157 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13158 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13159 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13160 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13161 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13162 | ret = str2sockunion (argv[0], &su); |
| 13163 | if (ret < 0) |
| 13164 | { |
| 13165 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13166 | return CMD_WARNING; |
| 13167 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13168 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13169 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13170 | if (! peer) |
| 13171 | return CMD_WARNING; |
| 13172 | |
| 13173 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13174 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13175 | if (count) |
| 13176 | { |
| 13177 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13178 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13179 | } |
| 13180 | |
| 13181 | return CMD_SUCCESS; |
| 13182 | } |
| 13183 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13184 | DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13185 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 13186 | "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] | 13187 | SHOW_STR |
| 13188 | BGP_STR |
| 13189 | "BGP view\n" |
| 13190 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13191 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13192 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13193 | "Neighbor to display information about\n" |
| 13194 | "Neighbor to display information about\n" |
| 13195 | "Display information received from a BGP neighbor\n" |
| 13196 | "Display the prefixlist filter\n") |
| 13197 | { |
| 13198 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13199 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13200 | struct peer *peer; |
| 13201 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13202 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13203 | |
| 13204 | /* BGP structure lookup. */ |
| 13205 | bgp = bgp_lookup_by_name (argv[0]); |
| 13206 | if (bgp == NULL) |
| 13207 | { |
| 13208 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13209 | return CMD_WARNING; |
| 13210 | } |
| 13211 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13212 | ret = str2sockunion (argv[1], &su); |
| 13213 | if (ret < 0) |
| 13214 | { |
| 13215 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13216 | return CMD_WARNING; |
| 13217 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13218 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13219 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13220 | if (! peer) |
| 13221 | return CMD_WARNING; |
| 13222 | |
| 13223 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13224 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13225 | if (count) |
| 13226 | { |
| 13227 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13228 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13229 | } |
| 13230 | |
| 13231 | return CMD_SUCCESS; |
| 13232 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 13233 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 13234 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13235 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13236 | safi_t safi, enum bgp_show_type type) |
| 13237 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13238 | if (! peer || ! peer->afc[afi][safi]) |
| 13239 | { |
| 13240 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13241 | return CMD_WARNING; |
| 13242 | } |
| 13243 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 13244 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13245 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13246 | DEFUN (show_ip_bgp_neighbor_routes, |
| 13247 | show_ip_bgp_neighbor_routes_cmd, |
| 13248 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 13249 | SHOW_STR |
| 13250 | IP_STR |
| 13251 | BGP_STR |
| 13252 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13253 | "Neighbor to display information about\n" |
| 13254 | "Neighbor to display information about\n" |
| 13255 | "Display routes learned from neighbor\n") |
| 13256 | { |
| 13257 | struct peer *peer; |
| 13258 | |
| 13259 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13260 | if (! peer) |
| 13261 | return CMD_WARNING; |
| 13262 | |
| 13263 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13264 | bgp_show_type_neighbor); |
| 13265 | } |
| 13266 | |
| 13267 | DEFUN (show_ip_bgp_neighbor_flap, |
| 13268 | show_ip_bgp_neighbor_flap_cmd, |
| 13269 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 13270 | SHOW_STR |
| 13271 | IP_STR |
| 13272 | BGP_STR |
| 13273 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13274 | "Neighbor to display information about\n" |
| 13275 | "Neighbor to display information about\n" |
| 13276 | "Display flap statistics of the routes learned from neighbor\n") |
| 13277 | { |
| 13278 | struct peer *peer; |
| 13279 | |
| 13280 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13281 | if (! peer) |
| 13282 | return CMD_WARNING; |
| 13283 | |
| 13284 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13285 | bgp_show_type_flap_neighbor); |
| 13286 | } |
| 13287 | |
| 13288 | DEFUN (show_ip_bgp_neighbor_damp, |
| 13289 | show_ip_bgp_neighbor_damp_cmd, |
| 13290 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13291 | SHOW_STR |
| 13292 | IP_STR |
| 13293 | BGP_STR |
| 13294 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13295 | "Neighbor to display information about\n" |
| 13296 | "Neighbor to display information about\n" |
| 13297 | "Display the dampened routes received from neighbor\n") |
| 13298 | { |
| 13299 | struct peer *peer; |
| 13300 | |
| 13301 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13302 | if (! peer) |
| 13303 | return CMD_WARNING; |
| 13304 | |
| 13305 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13306 | bgp_show_type_damp_neighbor); |
| 13307 | } |
| 13308 | |
| 13309 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 13310 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 13311 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13312 | SHOW_STR |
| 13313 | IP_STR |
| 13314 | BGP_STR |
| 13315 | "Address family\n" |
| 13316 | "Address Family modifier\n" |
| 13317 | "Address Family modifier\n" |
| 13318 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13319 | "Neighbor to display information about\n" |
| 13320 | "Neighbor to display information about\n" |
| 13321 | "Display routes learned from neighbor\n") |
| 13322 | { |
| 13323 | struct peer *peer; |
| 13324 | |
| 13325 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13326 | if (! peer) |
| 13327 | return CMD_WARNING; |
| 13328 | |
| 13329 | if (strncmp (argv[0], "m", 1) == 0) |
| 13330 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
| 13331 | bgp_show_type_neighbor); |
| 13332 | |
| 13333 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13334 | bgp_show_type_neighbor); |
| 13335 | } |
| 13336 | |
| 13337 | DEFUN (show_ip_bgp_view_rsclient, |
| 13338 | show_ip_bgp_view_rsclient_cmd, |
| 13339 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 13340 | SHOW_STR |
| 13341 | IP_STR |
| 13342 | BGP_STR |
| 13343 | "BGP view\n" |
| 13344 | "View name\n" |
| 13345 | "Information about Route Server Client\n" |
| 13346 | NEIGHBOR_ADDR_STR) |
| 13347 | { |
| 13348 | struct bgp_table *table; |
| 13349 | struct peer *peer; |
| 13350 | |
| 13351 | if (argc == 2) |
| 13352 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13353 | else |
| 13354 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13355 | |
| 13356 | if (! peer) |
| 13357 | return CMD_WARNING; |
| 13358 | |
| 13359 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13360 | { |
| 13361 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13362 | VTY_NEWLINE); |
| 13363 | return CMD_WARNING; |
| 13364 | } |
| 13365 | |
| 13366 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13367 | PEER_FLAG_RSERVER_CLIENT)) |
| 13368 | { |
| 13369 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13370 | VTY_NEWLINE); |
| 13371 | return CMD_WARNING; |
| 13372 | } |
| 13373 | |
| 13374 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 13375 | |
| 13376 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13377 | } |
| 13378 | |
| 13379 | ALIAS (show_ip_bgp_view_rsclient, |
| 13380 | show_ip_bgp_rsclient_cmd, |
| 13381 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 13382 | SHOW_STR |
| 13383 | IP_STR |
| 13384 | BGP_STR |
| 13385 | "Information about Route Server Client\n" |
| 13386 | NEIGHBOR_ADDR_STR) |
| 13387 | |
| 13388 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 13389 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 13390 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13391 | SHOW_STR |
| 13392 | BGP_STR |
| 13393 | "BGP view\n" |
| 13394 | "View name\n" |
| 13395 | "Address family\n" |
| 13396 | "Address Family modifier\n" |
| 13397 | "Address Family modifier\n" |
| 13398 | "Information about Route Server Client\n" |
| 13399 | NEIGHBOR_ADDR_STR) |
| 13400 | { |
| 13401 | struct bgp_table *table; |
| 13402 | struct peer *peer; |
| 13403 | safi_t safi; |
| 13404 | |
| 13405 | if (argc == 3) { |
| 13406 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13407 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13408 | } else { |
| 13409 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13410 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13411 | } |
| 13412 | |
| 13413 | if (! peer) |
| 13414 | return CMD_WARNING; |
| 13415 | |
| 13416 | if (! peer->afc[AFI_IP][safi]) |
| 13417 | { |
| 13418 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13419 | VTY_NEWLINE); |
| 13420 | return CMD_WARNING; |
| 13421 | } |
| 13422 | |
| 13423 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13424 | PEER_FLAG_RSERVER_CLIENT)) |
| 13425 | { |
| 13426 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13427 | VTY_NEWLINE); |
| 13428 | return CMD_WARNING; |
| 13429 | } |
| 13430 | |
| 13431 | table = peer->rib[AFI_IP][safi]; |
| 13432 | |
| 13433 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13434 | } |
| 13435 | |
| 13436 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 13437 | show_bgp_ipv4_safi_rsclient_cmd, |
| 13438 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13439 | SHOW_STR |
| 13440 | BGP_STR |
| 13441 | "Address family\n" |
| 13442 | "Address Family modifier\n" |
| 13443 | "Address Family modifier\n" |
| 13444 | "Information about Route Server Client\n" |
| 13445 | NEIGHBOR_ADDR_STR) |
| 13446 | |
| 13447 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 13448 | show_ip_bgp_view_rsclient_route_cmd, |
| 13449 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13450 | SHOW_STR |
| 13451 | IP_STR |
| 13452 | BGP_STR |
| 13453 | "BGP view\n" |
| 13454 | "View name\n" |
| 13455 | "Information about Route Server Client\n" |
| 13456 | NEIGHBOR_ADDR_STR |
| 13457 | "Network in the BGP routing table to display\n") |
| 13458 | { |
| 13459 | struct bgp *bgp; |
| 13460 | struct peer *peer; |
| 13461 | |
| 13462 | /* BGP structure lookup. */ |
| 13463 | if (argc == 3) |
| 13464 | { |
| 13465 | bgp = bgp_lookup_by_name (argv[0]); |
| 13466 | if (bgp == NULL) |
| 13467 | { |
| 13468 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13469 | return CMD_WARNING; |
| 13470 | } |
| 13471 | } |
| 13472 | else |
| 13473 | { |
| 13474 | bgp = bgp_get_default (); |
| 13475 | if (bgp == NULL) |
| 13476 | { |
| 13477 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13478 | return CMD_WARNING; |
| 13479 | } |
| 13480 | } |
| 13481 | |
| 13482 | if (argc == 3) |
| 13483 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13484 | else |
| 13485 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13486 | |
| 13487 | if (! peer) |
| 13488 | return CMD_WARNING; |
| 13489 | |
| 13490 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13491 | { |
| 13492 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13493 | VTY_NEWLINE); |
| 13494 | return CMD_WARNING; |
| 13495 | } |
| 13496 | |
| 13497 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13498 | PEER_FLAG_RSERVER_CLIENT)) |
| 13499 | { |
| 13500 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13501 | VTY_NEWLINE); |
| 13502 | return CMD_WARNING; |
| 13503 | } |
| 13504 | |
| 13505 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 13506 | (argc == 3) ? argv[2] : argv[1], |
| 13507 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 13508 | } |
| 13509 | |
| 13510 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 13511 | show_ip_bgp_rsclient_route_cmd, |
| 13512 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13513 | SHOW_STR |
| 13514 | IP_STR |
| 13515 | BGP_STR |
| 13516 | "Information about Route Server Client\n" |
| 13517 | NEIGHBOR_ADDR_STR |
| 13518 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13519 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13520 | DEFUN (show_bgp_ipv4_safi_neighbor_flap, |
| 13521 | show_bgp_ipv4_safi_neighbor_flap_cmd, |
| 13522 | "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] | 13523 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13524 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13525 | "Address Family Modifier\n" |
| 13526 | "Address Family Modifier\n" |
| 13527 | "Address Family Modifier\n" |
| 13528 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13529 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13530 | "Neighbor to display information about\n" |
| 13531 | "Neighbor to display information about\n" |
| 13532 | "Display flap statistics of the routes learned from neighbor\n") |
| 13533 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13534 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13535 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13536 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13537 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13538 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13539 | return CMD_WARNING; |
| 13540 | } |
| 13541 | |
| 13542 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13543 | if (! peer) |
| 13544 | return CMD_WARNING; |
| 13545 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13546 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13547 | bgp_show_type_flap_neighbor); |
| 13548 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13549 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13550 | DEFUN (show_bgp_ipv6_safi_neighbor_flap, |
| 13551 | show_bgp_ipv6_safi_neighbor_flap_cmd, |
| 13552 | "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] | 13553 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13554 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13555 | "Address Family Modifier\n" |
| 13556 | "Address Family Modifier\n" |
| 13557 | "Address Family Modifier\n" |
| 13558 | "Address Family Modifier\n" |
| 13559 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13560 | "Neighbor to display information about\n" |
| 13561 | "Neighbor to display information about\n" |
| 13562 | "Display flap statistics of the routes learned from neighbor\n") |
| 13563 | { |
| 13564 | struct peer *peer; |
| 13565 | safi_t safi; |
| 13566 | |
| 13567 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13568 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13569 | return CMD_WARNING; |
| 13570 | } |
| 13571 | |
| 13572 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13573 | if (! peer) |
| 13574 | return CMD_WARNING; |
| 13575 | |
| 13576 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13577 | bgp_show_type_flap_neighbor); |
| 13578 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13579 | |
| 13580 | DEFUN (show_bgp_ipv4_safi_neighbor_damp, |
| 13581 | show_bgp_ipv4_safi_neighbor_damp_cmd, |
| 13582 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13583 | SHOW_STR |
| 13584 | BGP_STR |
| 13585 | "Address Family Modifier\n" |
| 13586 | "Address Family Modifier\n" |
| 13587 | "Address Family Modifier\n" |
| 13588 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13589 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13590 | "Neighbor to display information about\n" |
| 13591 | "Neighbor to display information about\n" |
| 13592 | "Display the dampened routes received from neighbor\n") |
| 13593 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13594 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13595 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13596 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13597 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13598 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13599 | return CMD_WARNING; |
| 13600 | } |
| 13601 | |
| 13602 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13603 | if (! peer) |
| 13604 | return CMD_WARNING; |
| 13605 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13606 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13607 | bgp_show_type_damp_neighbor); |
| 13608 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13609 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13610 | DEFUN (show_bgp_ipv6_safi_neighbor_damp, |
| 13611 | show_bgp_ipv6_safi_neighbor_damp_cmd, |
| 13612 | "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] | 13613 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13614 | BGP_STR |
| 13615 | "Address Family Modifier\n" |
| 13616 | "Address Family Modifier\n" |
| 13617 | "Address Family Modifier\n" |
| 13618 | "Address Family Modifier\n" |
| 13619 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13620 | "Neighbor to display information about\n" |
| 13621 | "Neighbor to display information about\n" |
| 13622 | "Display the dampened routes received from neighbor\n") |
| 13623 | { |
| 13624 | struct peer *peer; |
| 13625 | safi_t safi; |
| 13626 | |
| 13627 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13628 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13629 | return CMD_WARNING; |
| 13630 | } |
| 13631 | |
| 13632 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13633 | if (! peer) |
| 13634 | return CMD_WARNING; |
| 13635 | |
| 13636 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13637 | bgp_show_type_damp_neighbor); |
| 13638 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13639 | |
| 13640 | DEFUN (show_bgp_ipv4_safi_neighbor_routes, |
| 13641 | show_bgp_ipv4_safi_neighbor_routes_cmd, |
| 13642 | "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13643 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13644 | BGP_STR |
| 13645 | "Address family\n" |
| 13646 | "Address Family modifier\n" |
| 13647 | "Address Family modifier\n" |
| 13648 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13649 | "Neighbor to display information about\n" |
| 13650 | "Neighbor to display information about\n" |
| 13651 | "Display routes learned from neighbor\n") |
| 13652 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13653 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13654 | safi_t safi; |
| 13655 | |
| 13656 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13657 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13658 | return CMD_WARNING; |
| 13659 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13660 | |
| 13661 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13662 | if (! peer) |
| 13663 | return CMD_WARNING; |
| 13664 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13665 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13666 | bgp_show_type_neighbor); |
| 13667 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13668 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13669 | DEFUN (show_bgp_ipv6_safi_neighbor_routes, |
| 13670 | show_bgp_ipv6_safi_neighbor_routes_cmd, |
| 13671 | "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] | 13672 | SHOW_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13673 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13674 | "Address family\n" |
| 13675 | "Address Family modifier\n" |
| 13676 | "Address Family modifier\n" |
| 13677 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13678 | NEIGHBOR_ADDR_STR |
| 13679 | NEIGHBOR_ADDR_STR |
| 13680 | "Display routes learned from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13681 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13682 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13683 | safi_t safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13684 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13685 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13686 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13687 | return CMD_WARNING; |
| 13688 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13689 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13690 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13691 | if (! peer) |
| 13692 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13693 | |
| 13694 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13695 | bgp_show_type_neighbor); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13696 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13697 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13698 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 13699 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 13700 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13701 | SHOW_STR |
| 13702 | BGP_STR |
| 13703 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13704 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13705 | "Address family\n" |
| 13706 | "Address Family modifier\n" |
| 13707 | "Address Family modifier\n" |
| 13708 | "Information about Route Server Client\n" |
| 13709 | NEIGHBOR_ADDR_STR |
| 13710 | "Network in the BGP routing table to display\n") |
| 13711 | { |
| 13712 | struct bgp *bgp; |
| 13713 | struct peer *peer; |
| 13714 | safi_t safi; |
| 13715 | |
| 13716 | /* BGP structure lookup. */ |
| 13717 | if (argc == 4) |
| 13718 | { |
| 13719 | bgp = bgp_lookup_by_name (argv[0]); |
| 13720 | if (bgp == NULL) |
| 13721 | { |
| 13722 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13723 | return CMD_WARNING; |
| 13724 | } |
| 13725 | } |
| 13726 | else |
| 13727 | { |
| 13728 | bgp = bgp_get_default (); |
| 13729 | if (bgp == NULL) |
| 13730 | { |
| 13731 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13732 | return CMD_WARNING; |
| 13733 | } |
| 13734 | } |
| 13735 | |
| 13736 | if (argc == 4) { |
| 13737 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13738 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13739 | } else { |
| 13740 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13741 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13742 | } |
| 13743 | |
| 13744 | if (! peer) |
| 13745 | return CMD_WARNING; |
| 13746 | |
| 13747 | if (! peer->afc[AFI_IP][safi]) |
| 13748 | { |
| 13749 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13750 | VTY_NEWLINE); |
| 13751 | return CMD_WARNING; |
| 13752 | } |
| 13753 | |
| 13754 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13755 | PEER_FLAG_RSERVER_CLIENT)) |
| 13756 | { |
| 13757 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13758 | VTY_NEWLINE); |
| 13759 | return CMD_WARNING; |
| 13760 | } |
| 13761 | |
| 13762 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 13763 | (argc == 4) ? argv[3] : argv[2], |
| 13764 | AFI_IP, safi, NULL, 0); |
| 13765 | } |
| 13766 | |
| 13767 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 13768 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 13769 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13770 | SHOW_STR |
| 13771 | BGP_STR |
| 13772 | "Address family\n" |
| 13773 | "Address Family modifier\n" |
| 13774 | "Address Family modifier\n" |
| 13775 | "Information about Route Server Client\n" |
| 13776 | NEIGHBOR_ADDR_STR |
| 13777 | "Network in the BGP routing table to display\n") |
| 13778 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13779 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13780 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 13781 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 13782 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 13783 | SHOW_STR |
| 13784 | BGP_STR |
| 13785 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13786 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13787 | "Address family\n" |
| 13788 | "Address Family modifier\n" |
| 13789 | "Address Family modifier\n" |
| 13790 | "Information about Route Server Client\n" |
| 13791 | NEIGHBOR_ADDR_STR |
| 13792 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 13793 | { |
| 13794 | struct bgp *bgp; |
| 13795 | struct peer *peer; |
| 13796 | safi_t safi; |
| 13797 | |
| 13798 | /* BGP structure lookup. */ |
| 13799 | if (argc == 4) |
| 13800 | { |
| 13801 | bgp = bgp_lookup_by_name (argv[0]); |
| 13802 | if (bgp == NULL) |
| 13803 | { |
| 13804 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13805 | return CMD_WARNING; |
| 13806 | } |
| 13807 | } |
| 13808 | else |
| 13809 | { |
| 13810 | bgp = bgp_get_default (); |
| 13811 | if (bgp == NULL) |
| 13812 | { |
| 13813 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13814 | return CMD_WARNING; |
| 13815 | } |
| 13816 | } |
| 13817 | |
| 13818 | if (argc == 4) { |
| 13819 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13820 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13821 | } else { |
| 13822 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13823 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13824 | } |
| 13825 | |
| 13826 | if (! peer) |
| 13827 | return CMD_WARNING; |
| 13828 | |
| 13829 | if (! peer->afc[AFI_IP][safi]) |
| 13830 | { |
| 13831 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13832 | VTY_NEWLINE); |
| 13833 | return CMD_WARNING; |
| 13834 | } |
| 13835 | |
| 13836 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13837 | PEER_FLAG_RSERVER_CLIENT)) |
| 13838 | { |
| 13839 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13840 | VTY_NEWLINE); |
| 13841 | return CMD_WARNING; |
| 13842 | } |
| 13843 | |
| 13844 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 13845 | (argc == 4) ? argv[3] : argv[2], |
| 13846 | AFI_IP, safi, NULL, 1); |
| 13847 | } |
| 13848 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13849 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 13850 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 13851 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 13852 | SHOW_STR |
| 13853 | IP_STR |
| 13854 | BGP_STR |
| 13855 | "BGP view\n" |
| 13856 | "View name\n" |
| 13857 | "Information about Route Server Client\n" |
| 13858 | NEIGHBOR_ADDR_STR |
| 13859 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 13860 | { |
| 13861 | struct bgp *bgp; |
| 13862 | struct peer *peer; |
| 13863 | |
| 13864 | /* BGP structure lookup. */ |
| 13865 | if (argc == 3) |
| 13866 | { |
| 13867 | bgp = bgp_lookup_by_name (argv[0]); |
| 13868 | if (bgp == NULL) |
| 13869 | { |
| 13870 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13871 | return CMD_WARNING; |
| 13872 | } |
| 13873 | } |
| 13874 | else |
| 13875 | { |
| 13876 | bgp = bgp_get_default (); |
| 13877 | if (bgp == NULL) |
| 13878 | { |
| 13879 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13880 | return CMD_WARNING; |
| 13881 | } |
| 13882 | } |
| 13883 | |
| 13884 | if (argc == 3) |
| 13885 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13886 | else |
| 13887 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13888 | |
| 13889 | if (! peer) |
| 13890 | return CMD_WARNING; |
| 13891 | |
| 13892 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13893 | { |
| 13894 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13895 | VTY_NEWLINE); |
| 13896 | return CMD_WARNING; |
| 13897 | } |
| 13898 | |
| 13899 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13900 | PEER_FLAG_RSERVER_CLIENT)) |
| 13901 | { |
| 13902 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13903 | VTY_NEWLINE); |
| 13904 | return CMD_WARNING; |
| 13905 | } |
| 13906 | |
| 13907 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 13908 | (argc == 3) ? argv[2] : argv[1], |
| 13909 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 13910 | } |
| 13911 | |
| 13912 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 13913 | show_ip_bgp_rsclient_prefix_cmd, |
| 13914 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 13915 | SHOW_STR |
| 13916 | IP_STR |
| 13917 | BGP_STR |
| 13918 | "Information about Route Server Client\n" |
| 13919 | NEIGHBOR_ADDR_STR |
| 13920 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 13921 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13922 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 13923 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 13924 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 13925 | SHOW_STR |
| 13926 | BGP_STR |
| 13927 | "Address family\n" |
| 13928 | "Address Family modifier\n" |
| 13929 | "Address Family modifier\n" |
| 13930 | "Information about Route Server Client\n" |
| 13931 | NEIGHBOR_ADDR_STR |
| 13932 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13933 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13934 | DEFUN (show_bgp_view_ipv6_neighbor_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13935 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 13936 | "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] | 13937 | SHOW_STR |
| 13938 | BGP_STR |
| 13939 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13940 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13941 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13942 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13943 | "Neighbor to display information about\n" |
| 13944 | "Neighbor to display information about\n" |
| 13945 | "Display routes learned from neighbor\n") |
| 13946 | { |
| 13947 | struct peer *peer; |
| 13948 | |
| 13949 | if (argc == 2) |
| 13950 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13951 | else |
| 13952 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13953 | |
| 13954 | if (! peer) |
| 13955 | return CMD_WARNING; |
| 13956 | |
| 13957 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 13958 | bgp_show_type_neighbor); |
| 13959 | } |
| 13960 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13961 | DEFUN (show_bgp_view_neighbor_damp, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13962 | show_bgp_view_neighbor_damp_cmd, |
| 13963 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13964 | SHOW_STR |
| 13965 | BGP_STR |
| 13966 | "BGP view\n" |
| 13967 | "View name\n" |
| 13968 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13969 | "Neighbor to display information about\n" |
| 13970 | "Neighbor to display information about\n" |
| 13971 | "Display the dampened routes received from neighbor\n") |
| 13972 | { |
| 13973 | struct peer *peer; |
| 13974 | |
| 13975 | if (argc == 2) |
| 13976 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13977 | else |
| 13978 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13979 | |
| 13980 | if (! peer) |
| 13981 | return CMD_WARNING; |
| 13982 | |
| 13983 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 13984 | bgp_show_type_damp_neighbor); |
| 13985 | } |
| 13986 | |
| 13987 | DEFUN (show_bgp_view_ipv6_neighbor_damp, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13988 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 13989 | "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] | 13990 | SHOW_STR |
| 13991 | BGP_STR |
| 13992 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13993 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13994 | "Address family\n" |
| 13995 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13996 | "Neighbor to display information about\n" |
| 13997 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13998 | "Display the dampened routes received from neighbor\n") |
| 13999 | { |
| 14000 | struct peer *peer; |
| 14001 | |
| 14002 | if (argc == 2) |
| 14003 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14004 | else |
| 14005 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14006 | |
| 14007 | if (! peer) |
| 14008 | return CMD_WARNING; |
| 14009 | |
| 14010 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14011 | bgp_show_type_damp_neighbor); |
| 14012 | } |
| 14013 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14014 | DEFUN (show_bgp_view_ipv6_neighbor_flap, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14015 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 14016 | "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] | 14017 | SHOW_STR |
| 14018 | BGP_STR |
| 14019 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14020 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14021 | "Address family\n" |
| 14022 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14023 | "Neighbor to display information about\n" |
| 14024 | "Neighbor to display information about\n" |
| 14025 | "Display the dampened routes received from neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14026 | { |
| 14027 | struct peer *peer; |
| 14028 | |
| 14029 | if (argc == 2) |
| 14030 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14031 | else |
| 14032 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14033 | |
| 14034 | if (! peer) |
| 14035 | return CMD_WARNING; |
| 14036 | |
| 14037 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14038 | bgp_show_type_flap_neighbor); |
| 14039 | } |
| 14040 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14041 | DEFUN (show_bgp_view_neighbor_flap, |
| 14042 | show_bgp_view_neighbor_flap_cmd, |
| 14043 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14044 | SHOW_STR |
| 14045 | BGP_STR |
| 14046 | "BGP view\n" |
| 14047 | "View name\n" |
| 14048 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14049 | "Neighbor to display information about\n" |
| 14050 | "Neighbor to display information about\n" |
| 14051 | "Display flap statistics of the routes learned from neighbor\n") |
| 14052 | { |
| 14053 | struct peer *peer; |
| 14054 | |
| 14055 | if (argc == 2) |
| 14056 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14057 | else |
| 14058 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14059 | |
| 14060 | if (! peer) |
| 14061 | return CMD_WARNING; |
| 14062 | |
| 14063 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14064 | bgp_show_type_flap_neighbor); |
| 14065 | } |
| 14066 | |
| 14067 | ALIAS (show_bgp_view_neighbor_flap, |
| 14068 | show_bgp_neighbor_flap_cmd, |
| 14069 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14070 | SHOW_STR |
| 14071 | BGP_STR |
| 14072 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14073 | "Neighbor to display information about\n" |
| 14074 | "Neighbor to display information about\n" |
| 14075 | "Display flap statistics of the routes learned from neighbor\n") |
| 14076 | |
| 14077 | ALIAS (show_bgp_view_neighbor_damp, |
| 14078 | show_bgp_neighbor_damp_cmd, |
| 14079 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14080 | SHOW_STR |
| 14081 | BGP_STR |
| 14082 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14083 | "Neighbor to display information about\n" |
| 14084 | "Neighbor to display information about\n" |
| 14085 | "Display the dampened routes received from neighbor\n") |
| 14086 | |
| 14087 | DEFUN (show_bgp_view_neighbor_routes, |
| 14088 | show_bgp_view_neighbor_routes_cmd, |
| 14089 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 14090 | SHOW_STR |
| 14091 | BGP_STR |
| 14092 | "BGP view\n" |
| 14093 | "View name\n" |
| 14094 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14095 | "Neighbor to display information about\n" |
| 14096 | "Neighbor to display information about\n" |
| 14097 | "Display routes learned from neighbor\n") |
| 14098 | { |
| 14099 | struct peer *peer; |
| 14100 | |
| 14101 | if (argc == 2) |
| 14102 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14103 | else |
| 14104 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14105 | |
| 14106 | if (! peer) |
| 14107 | return CMD_WARNING; |
| 14108 | |
| 14109 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14110 | bgp_show_type_neighbor); |
| 14111 | } |
| 14112 | |
| 14113 | ALIAS (show_bgp_view_neighbor_routes, |
| 14114 | show_bgp_neighbor_routes_cmd, |
| 14115 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14116 | SHOW_STR |
| 14117 | BGP_STR |
| 14118 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14119 | "Neighbor to display information about\n" |
| 14120 | "Neighbor to display information about\n" |
| 14121 | "Display routes learned from neighbor\n") |
| 14122 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14123 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14124 | show_bgp_ipv6_neighbor_routes_cmd, |
| 14125 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 14126 | SHOW_STR |
| 14127 | BGP_STR |
| 14128 | "Address family\n" |
| 14129 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14130 | "Neighbor to display information about\n" |
| 14131 | "Neighbor to display information about\n" |
| 14132 | "Display routes learned from neighbor\n") |
| 14133 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14134 | /* old command */ |
| 14135 | ALIAS (show_bgp_view_neighbor_routes, |
| 14136 | ipv6_bgp_neighbor_routes_cmd, |
| 14137 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14138 | SHOW_STR |
| 14139 | IPV6_STR |
| 14140 | BGP_STR |
| 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 routes learned from neighbor\n") |
| 14145 | |
| 14146 | /* old command */ |
| 14147 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 14148 | ipv6_mbgp_neighbor_routes_cmd, |
| 14149 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14150 | SHOW_STR |
| 14151 | IPV6_STR |
| 14152 | MBGP_STR |
| 14153 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14154 | "Neighbor to display information about\n" |
| 14155 | "Neighbor to display information about\n" |
| 14156 | "Display routes learned from neighbor\n") |
| 14157 | { |
| 14158 | struct peer *peer; |
| 14159 | |
| 14160 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14161 | if (! peer) |
| 14162 | return CMD_WARNING; |
| 14163 | |
| 14164 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
| 14165 | bgp_show_type_neighbor); |
| 14166 | } |
| 14167 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14168 | ALIAS (show_bgp_view_neighbor_flap, |
| 14169 | show_bgp_ipv6_neighbor_flap_cmd, |
| 14170 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14171 | SHOW_STR |
| 14172 | BGP_STR |
| 14173 | "Address family\n" |
| 14174 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14175 | "Neighbor to display information about\n" |
| 14176 | "Neighbor to display information about\n" |
| 14177 | "Display flap statistics of the routes learned from neighbor\n") |
| 14178 | |
| 14179 | ALIAS (show_bgp_view_neighbor_damp, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14180 | show_bgp_ipv6_neighbor_damp_cmd, |
| 14181 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14182 | SHOW_STR |
| 14183 | BGP_STR |
| 14184 | "Address family\n" |
| 14185 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14186 | "Neighbor to display information about\n" |
| 14187 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 14188 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14189 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14190 | DEFUN (show_bgp_view_rsclient, |
| 14191 | show_bgp_view_rsclient_cmd, |
| 14192 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 14193 | SHOW_STR |
| 14194 | BGP_STR |
| 14195 | "BGP view\n" |
| 14196 | "View name\n" |
| 14197 | "Information about Route Server Client\n" |
| 14198 | NEIGHBOR_ADDR_STR) |
| 14199 | { |
| 14200 | struct bgp_table *table; |
| 14201 | struct peer *peer; |
| 14202 | |
| 14203 | if (argc == 2) |
| 14204 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14205 | else |
| 14206 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14207 | |
| 14208 | if (! peer) |
| 14209 | return CMD_WARNING; |
| 14210 | |
| 14211 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14212 | { |
| 14213 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14214 | VTY_NEWLINE); |
| 14215 | return CMD_WARNING; |
| 14216 | } |
| 14217 | |
| 14218 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14219 | PEER_FLAG_RSERVER_CLIENT)) |
| 14220 | { |
| 14221 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14222 | VTY_NEWLINE); |
| 14223 | return CMD_WARNING; |
| 14224 | } |
| 14225 | |
| 14226 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14227 | |
| 14228 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14229 | } |
| 14230 | |
| 14231 | ALIAS (show_bgp_view_rsclient, |
| 14232 | show_bgp_rsclient_cmd, |
| 14233 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 14234 | SHOW_STR |
| 14235 | BGP_STR |
| 14236 | "Information about Route Server Client\n" |
| 14237 | NEIGHBOR_ADDR_STR) |
| 14238 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14239 | DEFUN (show_bgp_view_ipv4_rsclient, |
| 14240 | show_bgp_view_ipv4_rsclient_cmd, |
| 14241 | "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] | 14242 | SHOW_STR |
| 14243 | BGP_STR |
| 14244 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14245 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14246 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14247 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14248 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14249 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14250 | struct bgp_table *table; |
| 14251 | struct peer *peer; |
| 14252 | |
| 14253 | if (argc == 2) |
| 14254 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14255 | else |
| 14256 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14257 | |
| 14258 | if (! peer) |
| 14259 | return CMD_WARNING; |
| 14260 | |
| 14261 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14262 | { |
| 14263 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14264 | VTY_NEWLINE); |
| 14265 | return CMD_WARNING; |
| 14266 | } |
| 14267 | |
| 14268 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14269 | PEER_FLAG_RSERVER_CLIENT)) |
| 14270 | { |
| 14271 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14272 | VTY_NEWLINE); |
| 14273 | return CMD_WARNING; |
| 14274 | } |
| 14275 | |
| 14276 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 14277 | |
| 14278 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14279 | } |
| 14280 | DEFUN (show_bgp_view_ipv6_rsclient, |
| 14281 | show_bgp_view_ipv6_rsclient_cmd, |
| 14282 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14283 | SHOW_STR |
| 14284 | BGP_STR |
| 14285 | "BGP view\n" |
| 14286 | "BGP view name\n" |
| 14287 | "Address Family\n" |
| 14288 | "Information about Route Server Client\n" |
| 14289 | NEIGHBOR_ADDR_STR2) |
| 14290 | { |
| 14291 | struct bgp_table *table; |
| 14292 | struct peer *peer; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14293 | |
| 14294 | if (argc == 2) |
| 14295 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14296 | else |
| 14297 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14298 | |
| 14299 | if (! peer) |
| 14300 | return CMD_WARNING; |
| 14301 | |
| 14302 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14303 | { |
| 14304 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14305 | VTY_NEWLINE); |
| 14306 | return CMD_WARNING; |
| 14307 | } |
| 14308 | |
| 14309 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14310 | PEER_FLAG_RSERVER_CLIENT)) |
| 14311 | { |
| 14312 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14313 | VTY_NEWLINE); |
| 14314 | return CMD_WARNING; |
| 14315 | } |
| 14316 | |
| 14317 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14318 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 14319 | 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] | 14320 | } |
| 14321 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14322 | ALIAS (show_bgp_view_ipv4_rsclient, |
| 14323 | show_bgp_ipv4_rsclient_cmd, |
| 14324 | "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14325 | SHOW_STR |
| 14326 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14327 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14328 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14329 | NEIGHBOR_ADDR_STR2) |
| 14330 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14331 | ALIAS (show_bgp_view_ipv6_rsclient, |
| 14332 | show_bgp_ipv6_rsclient_cmd, |
| 14333 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14334 | SHOW_STR |
| 14335 | BGP_STR |
| 14336 | "Address Family\n" |
| 14337 | "Information about Route Server Client\n" |
| 14338 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14339 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14340 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 14341 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 14342 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14343 | SHOW_STR |
| 14344 | BGP_STR |
| 14345 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14346 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14347 | "Address family\n" |
| 14348 | "Address Family modifier\n" |
| 14349 | "Address Family modifier\n" |
| 14350 | "Information about Route Server Client\n" |
| 14351 | NEIGHBOR_ADDR_STR) |
| 14352 | { |
| 14353 | struct bgp_table *table; |
| 14354 | struct peer *peer; |
| 14355 | safi_t safi; |
| 14356 | |
| 14357 | if (argc == 3) { |
| 14358 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14359 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14360 | } else { |
| 14361 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14362 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14363 | } |
| 14364 | |
| 14365 | if (! peer) |
| 14366 | return CMD_WARNING; |
| 14367 | |
| 14368 | if (! peer->afc[AFI_IP6][safi]) |
| 14369 | { |
| 14370 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14371 | VTY_NEWLINE); |
| 14372 | return CMD_WARNING; |
| 14373 | } |
| 14374 | |
| 14375 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14376 | PEER_FLAG_RSERVER_CLIENT)) |
| 14377 | { |
| 14378 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14379 | VTY_NEWLINE); |
| 14380 | return CMD_WARNING; |
| 14381 | } |
| 14382 | |
| 14383 | table = peer->rib[AFI_IP6][safi]; |
| 14384 | |
| 14385 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14386 | } |
| 14387 | |
| 14388 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 14389 | show_bgp_ipv6_safi_rsclient_cmd, |
| 14390 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14391 | SHOW_STR |
| 14392 | BGP_STR |
| 14393 | "Address family\n" |
| 14394 | "Address Family modifier\n" |
| 14395 | "Address Family modifier\n" |
| 14396 | "Information about Route Server Client\n" |
| 14397 | NEIGHBOR_ADDR_STR) |
| 14398 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14399 | DEFUN (show_bgp_view_rsclient_route, |
| 14400 | show_bgp_view_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14401 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14402 | SHOW_STR |
| 14403 | BGP_STR |
| 14404 | "BGP view\n" |
| 14405 | "View name\n" |
| 14406 | "Information about Route Server Client\n" |
| 14407 | NEIGHBOR_ADDR_STR |
| 14408 | "Network in the BGP routing table to display\n") |
| 14409 | { |
| 14410 | struct bgp *bgp; |
| 14411 | struct peer *peer; |
| 14412 | |
| 14413 | /* BGP structure lookup. */ |
| 14414 | if (argc == 3) |
| 14415 | { |
| 14416 | bgp = bgp_lookup_by_name (argv[0]); |
| 14417 | if (bgp == NULL) |
| 14418 | { |
| 14419 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14420 | return CMD_WARNING; |
| 14421 | } |
| 14422 | } |
| 14423 | else |
| 14424 | { |
| 14425 | bgp = bgp_get_default (); |
| 14426 | if (bgp == NULL) |
| 14427 | { |
| 14428 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14429 | return CMD_WARNING; |
| 14430 | } |
| 14431 | } |
| 14432 | |
| 14433 | if (argc == 3) |
| 14434 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14435 | else |
| 14436 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14437 | |
| 14438 | if (! peer) |
| 14439 | return CMD_WARNING; |
| 14440 | |
| 14441 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14442 | { |
| 14443 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14444 | VTY_NEWLINE); |
| 14445 | return CMD_WARNING; |
| 14446 | } |
| 14447 | |
| 14448 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14449 | PEER_FLAG_RSERVER_CLIENT)) |
| 14450 | { |
| 14451 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14452 | VTY_NEWLINE); |
| 14453 | return CMD_WARNING; |
| 14454 | } |
| 14455 | |
| 14456 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14457 | (argc == 3) ? argv[2] : argv[1], |
| 14458 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 14459 | } |
| 14460 | |
| 14461 | DEFUN (show_bgp_view_ipv6_rsclient_route, |
| 14462 | show_bgp_view_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14463 | "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] | 14464 | SHOW_STR |
| 14465 | BGP_STR |
| 14466 | "BGP view\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14467 | "BGP view name\n" |
| 14468 | "IP6_STR" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14469 | "Information about Route Server Client\n" |
| 14470 | NEIGHBOR_ADDR_STR |
| 14471 | "Network in the BGP routing table to display\n") |
| 14472 | { |
| 14473 | struct bgp *bgp; |
| 14474 | struct peer *peer; |
| 14475 | |
| 14476 | /* BGP structure lookup. */ |
| 14477 | if (argc == 3) |
| 14478 | { |
| 14479 | bgp = bgp_lookup_by_name (argv[0]); |
| 14480 | if (bgp == NULL) |
| 14481 | { |
| 14482 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14483 | return CMD_WARNING; |
| 14484 | } |
| 14485 | } |
| 14486 | else |
| 14487 | { |
| 14488 | bgp = bgp_get_default (); |
| 14489 | if (bgp == NULL) |
| 14490 | { |
| 14491 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14492 | return CMD_WARNING; |
| 14493 | } |
| 14494 | } |
| 14495 | |
| 14496 | if (argc == 3) |
| 14497 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14498 | else |
| 14499 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14500 | |
| 14501 | if (! peer) |
| 14502 | return CMD_WARNING; |
| 14503 | |
| 14504 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14505 | { |
| 14506 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14507 | VTY_NEWLINE); |
| 14508 | return CMD_WARNING; |
| 14509 | } |
| 14510 | |
| 14511 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14512 | PEER_FLAG_RSERVER_CLIENT)) |
| 14513 | { |
| 14514 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14515 | VTY_NEWLINE); |
| 14516 | return CMD_WARNING; |
| 14517 | } |
| 14518 | |
| 14519 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14520 | (argc == 3) ? argv[2] : argv[1], |
| 14521 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 14522 | } |
| 14523 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14524 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14525 | show_bgp_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14526 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14527 | SHOW_STR |
| 14528 | BGP_STR |
| 14529 | "Information about Route Server Client\n" |
| 14530 | NEIGHBOR_ADDR_STR |
| 14531 | "Network in the BGP routing table to display\n") |
| 14532 | |
| 14533 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
| 14534 | show_bgp_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14535 | "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] | 14536 | SHOW_STR |
| 14537 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14538 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14539 | "Information about Route Server Client\n" |
| 14540 | NEIGHBOR_ADDR_STR |
| 14541 | "Network in the BGP routing table to display\n") |
| 14542 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14543 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 14544 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 14545 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14546 | SHOW_STR |
| 14547 | BGP_STR |
| 14548 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14549 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14550 | "Address family\n" |
| 14551 | "Address Family modifier\n" |
| 14552 | "Address Family modifier\n" |
| 14553 | "Information about Route Server Client\n" |
| 14554 | NEIGHBOR_ADDR_STR |
| 14555 | "Network in the BGP routing table to display\n") |
| 14556 | { |
| 14557 | struct bgp *bgp; |
| 14558 | struct peer *peer; |
| 14559 | safi_t safi; |
| 14560 | |
| 14561 | /* BGP structure lookup. */ |
| 14562 | if (argc == 4) |
| 14563 | { |
| 14564 | bgp = bgp_lookup_by_name (argv[0]); |
| 14565 | if (bgp == NULL) |
| 14566 | { |
| 14567 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14568 | return CMD_WARNING; |
| 14569 | } |
| 14570 | } |
| 14571 | else |
| 14572 | { |
| 14573 | bgp = bgp_get_default (); |
| 14574 | if (bgp == NULL) |
| 14575 | { |
| 14576 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14577 | return CMD_WARNING; |
| 14578 | } |
| 14579 | } |
| 14580 | |
| 14581 | if (argc == 4) { |
| 14582 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14583 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14584 | } else { |
| 14585 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14586 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14587 | } |
| 14588 | |
| 14589 | if (! peer) |
| 14590 | return CMD_WARNING; |
| 14591 | |
| 14592 | if (! peer->afc[AFI_IP6][safi]) |
| 14593 | { |
| 14594 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14595 | VTY_NEWLINE); |
| 14596 | return CMD_WARNING; |
| 14597 | } |
| 14598 | |
| 14599 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14600 | PEER_FLAG_RSERVER_CLIENT)) |
| 14601 | { |
| 14602 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14603 | VTY_NEWLINE); |
| 14604 | return CMD_WARNING; |
| 14605 | } |
| 14606 | |
| 14607 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 14608 | (argc == 4) ? argv[3] : argv[2], |
| 14609 | AFI_IP6, safi, NULL, 0); |
| 14610 | } |
| 14611 | |
| 14612 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 14613 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 14614 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14615 | SHOW_STR |
| 14616 | BGP_STR |
| 14617 | "Address family\n" |
| 14618 | "Address Family modifier\n" |
| 14619 | "Address Family modifier\n" |
| 14620 | "Information about Route Server Client\n" |
| 14621 | NEIGHBOR_ADDR_STR |
| 14622 | "Network in the BGP routing table to display\n") |
| 14623 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14624 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14625 | DEFUN (show_bgp_view_rsclient_prefix, |
| 14626 | show_bgp_view_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14627 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14628 | SHOW_STR |
| 14629 | BGP_STR |
| 14630 | "BGP view\n" |
| 14631 | "View name\n" |
| 14632 | "Information about Route Server Client\n" |
| 14633 | NEIGHBOR_ADDR_STR |
| 14634 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14635 | { |
| 14636 | struct bgp *bgp; |
| 14637 | struct peer *peer; |
| 14638 | |
| 14639 | /* BGP structure lookup. */ |
| 14640 | if (argc == 3) |
| 14641 | { |
| 14642 | bgp = bgp_lookup_by_name (argv[0]); |
| 14643 | if (bgp == NULL) |
| 14644 | { |
| 14645 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14646 | return CMD_WARNING; |
| 14647 | } |
| 14648 | } |
| 14649 | else |
| 14650 | { |
| 14651 | bgp = bgp_get_default (); |
| 14652 | if (bgp == NULL) |
| 14653 | { |
| 14654 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14655 | return CMD_WARNING; |
| 14656 | } |
| 14657 | } |
| 14658 | |
| 14659 | if (argc == 3) |
| 14660 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14661 | else |
| 14662 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14663 | |
| 14664 | if (! peer) |
| 14665 | return CMD_WARNING; |
| 14666 | |
| 14667 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14668 | { |
| 14669 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14670 | VTY_NEWLINE); |
| 14671 | return CMD_WARNING; |
| 14672 | } |
| 14673 | |
| 14674 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14675 | PEER_FLAG_RSERVER_CLIENT)) |
| 14676 | { |
| 14677 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14678 | VTY_NEWLINE); |
| 14679 | return CMD_WARNING; |
| 14680 | } |
| 14681 | |
| 14682 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14683 | (argc == 3) ? argv[2] : argv[1], |
| 14684 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 14685 | } |
| 14686 | |
| 14687 | DEFUN (show_bgp_view_ipv6_rsclient_prefix, |
| 14688 | show_bgp_view_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14689 | "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] | 14690 | SHOW_STR |
| 14691 | BGP_STR |
| 14692 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14693 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14694 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14695 | "Information about Route Server Client\n" |
| 14696 | NEIGHBOR_ADDR_STR |
| 14697 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14698 | { |
| 14699 | struct bgp *bgp; |
| 14700 | struct peer *peer; |
| 14701 | |
| 14702 | /* BGP structure lookup. */ |
| 14703 | if (argc == 3) |
| 14704 | { |
| 14705 | bgp = bgp_lookup_by_name (argv[0]); |
| 14706 | if (bgp == NULL) |
| 14707 | { |
| 14708 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14709 | return CMD_WARNING; |
| 14710 | } |
| 14711 | } |
| 14712 | else |
| 14713 | { |
| 14714 | bgp = bgp_get_default (); |
| 14715 | if (bgp == NULL) |
| 14716 | { |
| 14717 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14718 | return CMD_WARNING; |
| 14719 | } |
| 14720 | } |
| 14721 | |
| 14722 | if (argc == 3) |
| 14723 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14724 | else |
| 14725 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14726 | |
| 14727 | if (! peer) |
| 14728 | return CMD_WARNING; |
| 14729 | |
| 14730 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14731 | { |
| 14732 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14733 | VTY_NEWLINE); |
| 14734 | return CMD_WARNING; |
| 14735 | } |
| 14736 | |
| 14737 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14738 | PEER_FLAG_RSERVER_CLIENT)) |
| 14739 | { |
| 14740 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14741 | VTY_NEWLINE); |
| 14742 | return CMD_WARNING; |
| 14743 | } |
| 14744 | |
| 14745 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14746 | (argc == 3) ? argv[2] : argv[1], |
| 14747 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 14748 | } |
| 14749 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14750 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14751 | show_bgp_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14752 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14753 | SHOW_STR |
| 14754 | BGP_STR |
| 14755 | "Information about Route Server Client\n" |
| 14756 | NEIGHBOR_ADDR_STR |
| 14757 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14758 | |
| 14759 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
| 14760 | show_bgp_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14761 | "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] | 14762 | SHOW_STR |
| 14763 | BGP_STR |
| 14764 | "Information about Route Server Client\n" |
| 14765 | NEIGHBOR_ADDR_STR |
| 14766 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14767 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14768 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 14769 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 14770 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14771 | SHOW_STR |
| 14772 | BGP_STR |
| 14773 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14774 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14775 | "Address family\n" |
| 14776 | "Address Family modifier\n" |
| 14777 | "Address Family modifier\n" |
| 14778 | "Information about Route Server Client\n" |
| 14779 | NEIGHBOR_ADDR_STR |
| 14780 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14781 | { |
| 14782 | struct bgp *bgp; |
| 14783 | struct peer *peer; |
| 14784 | safi_t safi; |
| 14785 | |
| 14786 | /* BGP structure lookup. */ |
| 14787 | if (argc == 4) |
| 14788 | { |
| 14789 | bgp = bgp_lookup_by_name (argv[0]); |
| 14790 | if (bgp == NULL) |
| 14791 | { |
| 14792 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14793 | return CMD_WARNING; |
| 14794 | } |
| 14795 | } |
| 14796 | else |
| 14797 | { |
| 14798 | bgp = bgp_get_default (); |
| 14799 | if (bgp == NULL) |
| 14800 | { |
| 14801 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14802 | return CMD_WARNING; |
| 14803 | } |
| 14804 | } |
| 14805 | |
| 14806 | if (argc == 4) { |
| 14807 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14808 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14809 | } else { |
| 14810 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14811 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14812 | } |
| 14813 | |
| 14814 | if (! peer) |
| 14815 | return CMD_WARNING; |
| 14816 | |
| 14817 | if (! peer->afc[AFI_IP6][safi]) |
| 14818 | { |
| 14819 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14820 | VTY_NEWLINE); |
| 14821 | return CMD_WARNING; |
| 14822 | } |
| 14823 | |
| 14824 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14825 | PEER_FLAG_RSERVER_CLIENT)) |
| 14826 | { |
| 14827 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14828 | VTY_NEWLINE); |
| 14829 | return CMD_WARNING; |
| 14830 | } |
| 14831 | |
| 14832 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 14833 | (argc == 4) ? argv[3] : argv[2], |
| 14834 | AFI_IP6, safi, NULL, 1); |
| 14835 | } |
| 14836 | |
| 14837 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 14838 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 14839 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14840 | SHOW_STR |
| 14841 | BGP_STR |
| 14842 | "Address family\n" |
| 14843 | "Address Family modifier\n" |
| 14844 | "Address Family modifier\n" |
| 14845 | "Information about Route Server Client\n" |
| 14846 | NEIGHBOR_ADDR_STR |
| 14847 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14848 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14849 | struct bgp_table *bgp_distance_table; |
| 14850 | |
| 14851 | struct bgp_distance |
| 14852 | { |
| 14853 | /* Distance value for the IP source prefix. */ |
| 14854 | u_char distance; |
| 14855 | |
| 14856 | /* Name of the access-list to be matched. */ |
| 14857 | char *access_list; |
| 14858 | }; |
| 14859 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14860 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 14861 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14862 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 14863 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14864 | } |
| 14865 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14866 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14867 | bgp_distance_free (struct bgp_distance *bdistance) |
| 14868 | { |
| 14869 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 14870 | } |
| 14871 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14872 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 14873 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 14874 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14875 | { |
| 14876 | int ret; |
| 14877 | struct prefix_ipv4 p; |
| 14878 | u_char distance; |
| 14879 | struct bgp_node *rn; |
| 14880 | struct bgp_distance *bdistance; |
| 14881 | |
| 14882 | ret = str2prefix_ipv4 (ip_str, &p); |
| 14883 | if (ret == 0) |
| 14884 | { |
| 14885 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 14886 | return CMD_WARNING; |
| 14887 | } |
| 14888 | |
| 14889 | distance = atoi (distance_str); |
| 14890 | |
| 14891 | /* Get BGP distance node. */ |
| 14892 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 14893 | if (rn->info) |
| 14894 | { |
| 14895 | bdistance = rn->info; |
| 14896 | bgp_unlock_node (rn); |
| 14897 | } |
| 14898 | else |
| 14899 | { |
| 14900 | bdistance = bgp_distance_new (); |
| 14901 | rn->info = bdistance; |
| 14902 | } |
| 14903 | |
| 14904 | /* Set distance value. */ |
| 14905 | bdistance->distance = distance; |
| 14906 | |
| 14907 | /* Reset access-list configuration. */ |
| 14908 | if (bdistance->access_list) |
| 14909 | { |
| 14910 | free (bdistance->access_list); |
| 14911 | bdistance->access_list = NULL; |
| 14912 | } |
| 14913 | if (access_list_str) |
| 14914 | bdistance->access_list = strdup (access_list_str); |
| 14915 | |
| 14916 | return CMD_SUCCESS; |
| 14917 | } |
| 14918 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14919 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 14920 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 14921 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14922 | { |
| 14923 | int ret; |
| 14924 | struct prefix_ipv4 p; |
| 14925 | u_char distance; |
| 14926 | struct bgp_node *rn; |
| 14927 | struct bgp_distance *bdistance; |
| 14928 | |
| 14929 | ret = str2prefix_ipv4 (ip_str, &p); |
| 14930 | if (ret == 0) |
| 14931 | { |
| 14932 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 14933 | return CMD_WARNING; |
| 14934 | } |
| 14935 | |
| 14936 | distance = atoi (distance_str); |
| 14937 | |
| 14938 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 14939 | if (! rn) |
| 14940 | { |
| 14941 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 14942 | return CMD_WARNING; |
| 14943 | } |
| 14944 | |
| 14945 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 14946 | |
| 14947 | if (bdistance->distance != distance) |
| 14948 | { |
| 14949 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 14950 | return CMD_WARNING; |
| 14951 | } |
| 14952 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14953 | if (bdistance->access_list) |
| 14954 | free (bdistance->access_list); |
| 14955 | bgp_distance_free (bdistance); |
| 14956 | |
| 14957 | rn->info = NULL; |
| 14958 | bgp_unlock_node (rn); |
| 14959 | bgp_unlock_node (rn); |
| 14960 | |
| 14961 | return CMD_SUCCESS; |
| 14962 | } |
| 14963 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14964 | /* Apply BGP information to distance method. */ |
| 14965 | u_char |
| 14966 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 14967 | { |
| 14968 | struct bgp_node *rn; |
| 14969 | struct prefix_ipv4 q; |
| 14970 | struct peer *peer; |
| 14971 | struct bgp_distance *bdistance; |
| 14972 | struct access_list *alist; |
| 14973 | struct bgp_static *bgp_static; |
| 14974 | |
| 14975 | if (! bgp) |
| 14976 | return 0; |
| 14977 | |
| 14978 | if (p->family != AF_INET) |
| 14979 | return 0; |
| 14980 | |
| 14981 | peer = rinfo->peer; |
| 14982 | |
| 14983 | if (peer->su.sa.sa_family != AF_INET) |
| 14984 | return 0; |
| 14985 | |
| 14986 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 14987 | q.family = AF_INET; |
| 14988 | q.prefix = peer->su.sin.sin_addr; |
| 14989 | q.prefixlen = IPV4_MAX_BITLEN; |
| 14990 | |
| 14991 | /* Check source address. */ |
| 14992 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 14993 | if (rn) |
| 14994 | { |
| 14995 | bdistance = rn->info; |
| 14996 | bgp_unlock_node (rn); |
| 14997 | |
| 14998 | if (bdistance->access_list) |
| 14999 | { |
| 15000 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 15001 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15002 | return bdistance->distance; |
| 15003 | } |
| 15004 | else |
| 15005 | return bdistance->distance; |
| 15006 | } |
| 15007 | |
| 15008 | /* Backdoor check. */ |
| 15009 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 15010 | if (rn) |
| 15011 | { |
| 15012 | bgp_static = rn->info; |
| 15013 | bgp_unlock_node (rn); |
| 15014 | |
| 15015 | if (bgp_static->backdoor) |
| 15016 | { |
| 15017 | if (bgp->distance_local) |
| 15018 | return bgp->distance_local; |
| 15019 | else |
| 15020 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15021 | } |
| 15022 | } |
| 15023 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 15024 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15025 | { |
| 15026 | if (bgp->distance_ebgp) |
| 15027 | return bgp->distance_ebgp; |
| 15028 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15029 | } |
| 15030 | else |
| 15031 | { |
| 15032 | if (bgp->distance_ibgp) |
| 15033 | return bgp->distance_ibgp; |
| 15034 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15035 | } |
| 15036 | } |
| 15037 | |
| 15038 | DEFUN (bgp_distance, |
| 15039 | bgp_distance_cmd, |
| 15040 | "distance bgp <1-255> <1-255> <1-255>", |
| 15041 | "Define an administrative distance\n" |
| 15042 | "BGP distance\n" |
| 15043 | "Distance for routes external to the AS\n" |
| 15044 | "Distance for routes internal to the AS\n" |
| 15045 | "Distance for local routes\n") |
| 15046 | { |
| 15047 | struct bgp *bgp; |
| 15048 | |
| 15049 | bgp = vty->index; |
| 15050 | |
| 15051 | bgp->distance_ebgp = atoi (argv[0]); |
| 15052 | bgp->distance_ibgp = atoi (argv[1]); |
| 15053 | bgp->distance_local = atoi (argv[2]); |
| 15054 | return CMD_SUCCESS; |
| 15055 | } |
| 15056 | |
| 15057 | DEFUN (no_bgp_distance, |
| 15058 | no_bgp_distance_cmd, |
| 15059 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15060 | NO_STR |
| 15061 | "Define an administrative distance\n" |
| 15062 | "BGP distance\n" |
| 15063 | "Distance for routes external to the AS\n" |
| 15064 | "Distance for routes internal to the AS\n" |
| 15065 | "Distance for local routes\n") |
| 15066 | { |
| 15067 | struct bgp *bgp; |
| 15068 | |
| 15069 | bgp = vty->index; |
| 15070 | |
| 15071 | bgp->distance_ebgp= 0; |
| 15072 | bgp->distance_ibgp = 0; |
| 15073 | bgp->distance_local = 0; |
| 15074 | return CMD_SUCCESS; |
| 15075 | } |
| 15076 | |
| 15077 | ALIAS (no_bgp_distance, |
| 15078 | no_bgp_distance2_cmd, |
| 15079 | "no distance bgp", |
| 15080 | NO_STR |
| 15081 | "Define an administrative distance\n" |
| 15082 | "BGP distance\n") |
| 15083 | |
| 15084 | DEFUN (bgp_distance_source, |
| 15085 | bgp_distance_source_cmd, |
| 15086 | "distance <1-255> A.B.C.D/M", |
| 15087 | "Define an administrative distance\n" |
| 15088 | "Administrative distance\n" |
| 15089 | "IP source prefix\n") |
| 15090 | { |
| 15091 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15092 | return CMD_SUCCESS; |
| 15093 | } |
| 15094 | |
| 15095 | DEFUN (no_bgp_distance_source, |
| 15096 | no_bgp_distance_source_cmd, |
| 15097 | "no distance <1-255> A.B.C.D/M", |
| 15098 | NO_STR |
| 15099 | "Define an administrative distance\n" |
| 15100 | "Administrative distance\n" |
| 15101 | "IP source prefix\n") |
| 15102 | { |
| 15103 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15104 | return CMD_SUCCESS; |
| 15105 | } |
| 15106 | |
| 15107 | DEFUN (bgp_distance_source_access_list, |
| 15108 | bgp_distance_source_access_list_cmd, |
| 15109 | "distance <1-255> A.B.C.D/M WORD", |
| 15110 | "Define an administrative distance\n" |
| 15111 | "Administrative distance\n" |
| 15112 | "IP source prefix\n" |
| 15113 | "Access list name\n") |
| 15114 | { |
| 15115 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15116 | return CMD_SUCCESS; |
| 15117 | } |
| 15118 | |
| 15119 | DEFUN (no_bgp_distance_source_access_list, |
| 15120 | no_bgp_distance_source_access_list_cmd, |
| 15121 | "no distance <1-255> A.B.C.D/M WORD", |
| 15122 | NO_STR |
| 15123 | "Define an administrative distance\n" |
| 15124 | "Administrative distance\n" |
| 15125 | "IP source prefix\n" |
| 15126 | "Access list name\n") |
| 15127 | { |
| 15128 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15129 | return CMD_SUCCESS; |
| 15130 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15131 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15132 | DEFUN (bgp_damp_set, |
| 15133 | bgp_damp_set_cmd, |
| 15134 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15135 | "BGP Specific commands\n" |
| 15136 | "Enable route-flap dampening\n" |
| 15137 | "Half-life time for the penalty\n" |
| 15138 | "Value to start reusing a route\n" |
| 15139 | "Value to start suppressing a route\n" |
| 15140 | "Maximum duration to suppress a stable route\n") |
| 15141 | { |
| 15142 | struct bgp *bgp; |
| 15143 | int half = DEFAULT_HALF_LIFE * 60; |
| 15144 | int reuse = DEFAULT_REUSE; |
| 15145 | int suppress = DEFAULT_SUPPRESS; |
| 15146 | int max = 4 * half; |
| 15147 | |
| 15148 | if (argc == 4) |
| 15149 | { |
| 15150 | half = atoi (argv[0]) * 60; |
| 15151 | reuse = atoi (argv[1]); |
| 15152 | suppress = atoi (argv[2]); |
| 15153 | max = atoi (argv[3]) * 60; |
| 15154 | } |
| 15155 | else if (argc == 1) |
| 15156 | { |
| 15157 | half = atoi (argv[0]) * 60; |
| 15158 | max = 4 * half; |
| 15159 | } |
| 15160 | |
| 15161 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 15162 | |
| 15163 | if (suppress < reuse) |
| 15164 | { |
| 15165 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 15166 | VTY_NEWLINE); |
| 15167 | return 0; |
| 15168 | } |
| 15169 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15170 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 15171 | half, reuse, suppress, max); |
| 15172 | } |
| 15173 | |
| 15174 | ALIAS (bgp_damp_set, |
| 15175 | bgp_damp_set2_cmd, |
| 15176 | "bgp dampening <1-45>", |
| 15177 | "BGP Specific commands\n" |
| 15178 | "Enable route-flap dampening\n" |
| 15179 | "Half-life time for the penalty\n") |
| 15180 | |
| 15181 | ALIAS (bgp_damp_set, |
| 15182 | bgp_damp_set3_cmd, |
| 15183 | "bgp dampening", |
| 15184 | "BGP Specific commands\n" |
| 15185 | "Enable route-flap dampening\n") |
| 15186 | |
| 15187 | DEFUN (bgp_damp_unset, |
| 15188 | bgp_damp_unset_cmd, |
| 15189 | "no bgp dampening", |
| 15190 | NO_STR |
| 15191 | "BGP Specific commands\n" |
| 15192 | "Enable route-flap dampening\n") |
| 15193 | { |
| 15194 | struct bgp *bgp; |
| 15195 | |
| 15196 | bgp = vty->index; |
| 15197 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 15198 | } |
| 15199 | |
| 15200 | ALIAS (bgp_damp_unset, |
| 15201 | bgp_damp_unset2_cmd, |
| 15202 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15203 | NO_STR |
| 15204 | "BGP Specific commands\n" |
| 15205 | "Enable route-flap dampening\n" |
| 15206 | "Half-life time for the penalty\n" |
| 15207 | "Value to start reusing a route\n" |
| 15208 | "Value to start suppressing a route\n" |
| 15209 | "Maximum duration to suppress a stable route\n") |
| 15210 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15211 | DEFUN (show_ip_bgp_dampened_paths, |
| 15212 | show_ip_bgp_dampened_paths_cmd, |
| 15213 | "show ip bgp dampened-paths", |
| 15214 | SHOW_STR |
| 15215 | IP_STR |
| 15216 | BGP_STR |
| 15217 | "Display paths suppressed due to dampening\n") |
| 15218 | { |
| 15219 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 15220 | NULL); |
| 15221 | } |
| 15222 | |
| 15223 | ALIAS (show_ip_bgp_dampened_paths, |
| 15224 | show_ip_bgp_damp_dampened_paths_cmd, |
| 15225 | "show ip bgp dampening dampened-paths", |
| 15226 | SHOW_STR |
| 15227 | IP_STR |
| 15228 | BGP_STR |
| 15229 | "Display detailed information about dampening\n" |
| 15230 | "Display paths suppressed due to dampening\n") |
| 15231 | |
| 15232 | DEFUN (show_ip_bgp_flap_statistics, |
| 15233 | show_ip_bgp_flap_statistics_cmd, |
| 15234 | "show ip bgp flap-statistics", |
| 15235 | SHOW_STR |
| 15236 | IP_STR |
| 15237 | BGP_STR |
| 15238 | "Display flap statistics of routes\n") |
| 15239 | { |
| 15240 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 15241 | bgp_show_type_flap_statistics, NULL); |
| 15242 | } |
| 15243 | |
| 15244 | ALIAS (show_ip_bgp_flap_statistics, |
| 15245 | show_ip_bgp_damp_flap_statistics_cmd, |
| 15246 | "show ip bgp dampening flap-statistics", |
| 15247 | SHOW_STR |
| 15248 | IP_STR |
| 15249 | BGP_STR |
| 15250 | "Display detailed information about dampening\n" |
| 15251 | "Display flap statistics of routes\n") |
| 15252 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15253 | DEFUN (show_bgp_ipv4_safi_dampened_paths, |
| 15254 | show_bgp_ipv4_safi_dampened_paths_cmd, |
| 15255 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15256 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15257 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15258 | IP_STR |
| 15259 | "Address Family modifier\n" |
| 15260 | "Address Family modifier\n" |
| 15261 | "Address Family modifier\n" |
| 15262 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15263 | "Display paths suppressed due to dampening\n") |
| 15264 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15265 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15266 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15267 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15268 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15269 | return CMD_WARNING; |
| 15270 | } |
| 15271 | |
| 15272 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL); |
| 15273 | } |
| 15274 | ALIAS (show_bgp_ipv4_safi_dampened_paths, |
| 15275 | show_bgp_ipv4_safi_damp_dampened_paths_cmd, |
| 15276 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15277 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15278 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15279 | IP_STR |
| 15280 | "Address Family modifier\n" |
| 15281 | "Address Family modifier\n" |
| 15282 | "Address Family modifier\n" |
| 15283 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15284 | "Display detailed information about dampening\n" |
| 15285 | "Display paths suppressed due to dampening\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15286 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15287 | DEFUN (show_bgp_ipv6_safi_dampened_paths, |
| 15288 | show_bgp_ipv6_safi_dampened_paths_cmd, |
| 15289 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15290 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15291 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15292 | IPV6_STR |
| 15293 | "Address Family modifier\n" |
| 15294 | "Address Family modifier\n" |
| 15295 | "Address Family modifier\n" |
| 15296 | "Address Family modifier\n" |
| 15297 | "Display paths suppressed due to dampening\n") |
| 15298 | { |
| 15299 | safi_t safi; |
| 15300 | |
| 15301 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15302 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15303 | return CMD_WARNING; |
| 15304 | } |
| 15305 | |
| 15306 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL); |
| 15307 | } |
| 15308 | ALIAS (show_bgp_ipv6_safi_dampened_paths, |
| 15309 | show_bgp_ipv6_safi_damp_dampened_paths_cmd, |
| 15310 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths", |
| 15311 | SHOW_STR |
| 15312 | BGP_STR |
| 15313 | IPV6_STR |
| 15314 | "Address Family modifier\n" |
| 15315 | "Address Family modifier\n" |
| 15316 | "Address Family modifier\n" |
| 15317 | "Address Family modifier\n" |
| 15318 | "Display detailed information about dampening\n" |
| 15319 | "Display paths suppressed due to dampening\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15320 | |
| 15321 | DEFUN (show_bgp_ipv4_safi_flap_statistics, |
| 15322 | show_bgp_ipv4_safi_flap_statistics_cmd, |
| 15323 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics", |
| 15324 | SHOW_STR |
| 15325 | BGP_STR |
| 15326 | "Address Family\n" |
| 15327 | "Address Family modifier\n" |
| 15328 | "Address Family modifier\n" |
| 15329 | "Address Family modifier\n" |
| 15330 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15331 | "Display flap statistics of routes\n") |
| 15332 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15333 | safi_t safi; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15334 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15335 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15336 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15337 | return CMD_WARNING; |
| 15338 | } |
| 15339 | |
| 15340 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL); |
| 15341 | } |
| 15342 | ALIAS (show_bgp_ipv4_safi_flap_statistics, |
| 15343 | show_bgp_ipv4_safi_damp_flap_statistics_cmd, |
| 15344 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15345 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15346 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15347 | "Address Family\n" |
| 15348 | "Address Family modifier\n" |
| 15349 | "Address Family modifier\n" |
| 15350 | "Address Family modifier\n" |
| 15351 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15352 | "Display detailed information about dampening\n" |
| 15353 | "Display flap statistics of routes\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15354 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15355 | DEFUN (show_bgp_ipv6_safi_flap_statistics, |
| 15356 | show_bgp_ipv6_safi_flap_statistics_cmd, |
| 15357 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics", |
| 15358 | SHOW_STR |
| 15359 | BGP_STR |
| 15360 | "Address Family\n" |
| 15361 | "Address Family modifier\n" |
| 15362 | "Address Family modifier\n" |
| 15363 | "Address Family modifier\n" |
| 15364 | "Address Family modifier\n" |
| 15365 | "Display flap statistics of routes\n") |
| 15366 | { |
| 15367 | safi_t safi; |
| 15368 | |
| 15369 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15370 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15371 | return CMD_WARNING; |
| 15372 | } |
| 15373 | |
| 15374 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL); |
| 15375 | } |
| 15376 | ALIAS (show_bgp_ipv6_safi_flap_statistics, |
| 15377 | show_bgp_ipv6_safi_damp_flap_statistics_cmd, |
| 15378 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics", |
| 15379 | SHOW_STR |
| 15380 | BGP_STR |
| 15381 | "Address Family\n" |
| 15382 | "Address Family modifier\n" |
| 15383 | "Address Family modifier\n" |
| 15384 | "Address Family modifier\n" |
| 15385 | "Address Family modifier\n" |
| 15386 | "Display detailed information about dampening\n" |
| 15387 | "Display flap statistics of routes\n") |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15388 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15389 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15390 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15391 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 15392 | const char *ip_str, afi_t afi, safi_t safi, |
| 15393 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15394 | { |
| 15395 | int ret; |
| 15396 | struct prefix match; |
| 15397 | struct bgp_node *rn; |
| 15398 | struct bgp_node *rm; |
| 15399 | struct bgp_info *ri; |
| 15400 | struct bgp_info *ri_temp; |
| 15401 | struct bgp *bgp; |
| 15402 | struct bgp_table *table; |
| 15403 | |
| 15404 | /* BGP structure lookup. */ |
| 15405 | if (view_name) |
| 15406 | { |
| 15407 | bgp = bgp_lookup_by_name (view_name); |
| 15408 | if (bgp == NULL) |
| 15409 | { |
| 15410 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 15411 | return CMD_WARNING; |
| 15412 | } |
| 15413 | } |
| 15414 | else |
| 15415 | { |
| 15416 | bgp = bgp_get_default (); |
| 15417 | if (bgp == NULL) |
| 15418 | { |
| 15419 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 15420 | return CMD_WARNING; |
| 15421 | } |
| 15422 | } |
| 15423 | |
| 15424 | /* Check IP address argument. */ |
| 15425 | ret = str2prefix (ip_str, &match); |
| 15426 | if (! ret) |
| 15427 | { |
| 15428 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 15429 | return CMD_WARNING; |
| 15430 | } |
| 15431 | |
| 15432 | match.family = afi2family (afi); |
| 15433 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15434 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15435 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15436 | 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] | 15437 | { |
| 15438 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 15439 | continue; |
| 15440 | |
| 15441 | if ((table = rn->info) != NULL) |
| 15442 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15443 | { |
| 15444 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 15445 | { |
| 15446 | ri = rm->info; |
| 15447 | while (ri) |
| 15448 | { |
| 15449 | if (ri->extra && ri->extra->damp_info) |
| 15450 | { |
| 15451 | ri_temp = ri->next; |
| 15452 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15453 | ri = ri_temp; |
| 15454 | } |
| 15455 | else |
| 15456 | ri = ri->next; |
| 15457 | } |
| 15458 | } |
| 15459 | |
| 15460 | bgp_unlock_node (rm); |
| 15461 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15462 | } |
| 15463 | } |
| 15464 | else |
| 15465 | { |
| 15466 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15467 | { |
| 15468 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 15469 | { |
| 15470 | ri = rn->info; |
| 15471 | while (ri) |
| 15472 | { |
| 15473 | if (ri->extra && ri->extra->damp_info) |
| 15474 | { |
| 15475 | ri_temp = ri->next; |
| 15476 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15477 | ri = ri_temp; |
| 15478 | } |
| 15479 | else |
| 15480 | ri = ri->next; |
| 15481 | } |
| 15482 | } |
| 15483 | |
| 15484 | bgp_unlock_node (rn); |
| 15485 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15486 | } |
| 15487 | |
| 15488 | return CMD_SUCCESS; |
| 15489 | } |
| 15490 | |
| 15491 | DEFUN (clear_ip_bgp_dampening, |
| 15492 | clear_ip_bgp_dampening_cmd, |
| 15493 | "clear ip bgp dampening", |
| 15494 | CLEAR_STR |
| 15495 | IP_STR |
| 15496 | BGP_STR |
| 15497 | "Clear route flap dampening information\n") |
| 15498 | { |
| 15499 | bgp_damp_info_clean (); |
| 15500 | return CMD_SUCCESS; |
| 15501 | } |
| 15502 | |
| 15503 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 15504 | clear_ip_bgp_dampening_prefix_cmd, |
| 15505 | "clear ip bgp dampening A.B.C.D/M", |
| 15506 | CLEAR_STR |
| 15507 | IP_STR |
| 15508 | BGP_STR |
| 15509 | "Clear route flap dampening information\n" |
| 15510 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 15511 | { |
| 15512 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15513 | SAFI_UNICAST, NULL, 1); |
| 15514 | } |
| 15515 | |
| 15516 | DEFUN (clear_ip_bgp_dampening_address, |
| 15517 | clear_ip_bgp_dampening_address_cmd, |
| 15518 | "clear ip bgp dampening A.B.C.D", |
| 15519 | CLEAR_STR |
| 15520 | IP_STR |
| 15521 | BGP_STR |
| 15522 | "Clear route flap dampening information\n" |
| 15523 | "Network to clear damping information\n") |
| 15524 | { |
| 15525 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15526 | SAFI_UNICAST, NULL, 0); |
| 15527 | } |
| 15528 | |
| 15529 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 15530 | clear_ip_bgp_dampening_address_mask_cmd, |
| 15531 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 15532 | CLEAR_STR |
| 15533 | IP_STR |
| 15534 | BGP_STR |
| 15535 | "Clear route flap dampening information\n" |
| 15536 | "Network to clear damping information\n" |
| 15537 | "Network mask\n") |
| 15538 | { |
| 15539 | int ret; |
| 15540 | char prefix_str[BUFSIZ]; |
| 15541 | |
| 15542 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 15543 | if (! ret) |
| 15544 | { |
| 15545 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 15546 | return CMD_WARNING; |
| 15547 | } |
| 15548 | |
| 15549 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 15550 | SAFI_UNICAST, NULL, 0); |
| 15551 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15552 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15553 | /* also used for encap safi */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15554 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15555 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 15556 | afi_t afi, safi_t safi, int *write) |
| 15557 | { |
| 15558 | struct bgp_node *prn; |
| 15559 | struct bgp_node *rn; |
| 15560 | struct bgp_table *table; |
| 15561 | struct prefix *p; |
| 15562 | struct prefix_rd *prd; |
| 15563 | struct bgp_static *bgp_static; |
| 15564 | u_int32_t label; |
| 15565 | char buf[SU_ADDRSTRLEN]; |
| 15566 | char rdbuf[RD_ADDRSTRLEN]; |
| 15567 | |
| 15568 | /* Network configuration. */ |
| 15569 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 15570 | if ((table = prn->info) != NULL) |
| 15571 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 15572 | if ((bgp_static = rn->info) != NULL) |
| 15573 | { |
| 15574 | p = &rn->p; |
| 15575 | prd = (struct prefix_rd *) &prn->p; |
| 15576 | |
| 15577 | /* "address-family" display. */ |
| 15578 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15579 | |
| 15580 | /* "network" configuration display. */ |
| 15581 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 15582 | label = decode_label (bgp_static->tag); |
| 15583 | |
| 15584 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 15585 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15586 | p->prefixlen, |
| 15587 | rdbuf, label); |
| 15588 | vty_out (vty, "%s", VTY_NEWLINE); |
| 15589 | } |
| 15590 | return 0; |
| 15591 | } |
| 15592 | |
| 15593 | /* Configuration of static route announcement and aggregate |
| 15594 | information. */ |
| 15595 | int |
| 15596 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 15597 | afi_t afi, safi_t safi, int *write) |
| 15598 | { |
| 15599 | struct bgp_node *rn; |
| 15600 | struct prefix *p; |
| 15601 | struct bgp_static *bgp_static; |
| 15602 | struct bgp_aggregate *bgp_aggregate; |
| 15603 | char buf[SU_ADDRSTRLEN]; |
| 15604 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15605 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15606 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 15607 | |
| 15608 | /* Network configuration. */ |
| 15609 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 15610 | if ((bgp_static = rn->info) != NULL) |
| 15611 | { |
| 15612 | p = &rn->p; |
| 15613 | |
| 15614 | /* "address-family" display. */ |
| 15615 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15616 | |
| 15617 | /* "network" configuration display. */ |
| 15618 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 15619 | { |
| 15620 | u_int32_t destination; |
| 15621 | struct in_addr netmask; |
| 15622 | |
| 15623 | destination = ntohl (p->u.prefix4.s_addr); |
| 15624 | masklen2ip (p->prefixlen, &netmask); |
| 15625 | vty_out (vty, " network %s", |
| 15626 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 15627 | |
| 15628 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 15629 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 15630 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 15631 | || p->u.prefix4.s_addr == 0) |
| 15632 | { |
| 15633 | /* Natural mask is not display. */ |
| 15634 | } |
| 15635 | else |
| 15636 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 15637 | } |
| 15638 | else |
| 15639 | { |
| 15640 | vty_out (vty, " network %s/%d", |
| 15641 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15642 | p->prefixlen); |
| 15643 | } |
| 15644 | |
| 15645 | if (bgp_static->rmap.name) |
| 15646 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 15647 | else |
| 15648 | { |
| 15649 | if (bgp_static->backdoor) |
| 15650 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 15651 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15652 | |
| 15653 | vty_out (vty, "%s", VTY_NEWLINE); |
| 15654 | } |
| 15655 | |
| 15656 | /* Aggregate-address configuration. */ |
| 15657 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 15658 | if ((bgp_aggregate = rn->info) != NULL) |
| 15659 | { |
| 15660 | p = &rn->p; |
| 15661 | |
| 15662 | /* "address-family" display. */ |
| 15663 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15664 | |
| 15665 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 15666 | { |
| 15667 | struct in_addr netmask; |
| 15668 | |
| 15669 | masklen2ip (p->prefixlen, &netmask); |
| 15670 | vty_out (vty, " aggregate-address %s %s", |
| 15671 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15672 | inet_ntoa (netmask)); |
| 15673 | } |
| 15674 | else |
| 15675 | { |
| 15676 | vty_out (vty, " aggregate-address %s/%d", |
| 15677 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15678 | p->prefixlen); |
| 15679 | } |
| 15680 | |
| 15681 | if (bgp_aggregate->as_set) |
| 15682 | vty_out (vty, " as-set"); |
| 15683 | |
| 15684 | if (bgp_aggregate->summary_only) |
| 15685 | vty_out (vty, " summary-only"); |
| 15686 | |
| 15687 | vty_out (vty, "%s", VTY_NEWLINE); |
| 15688 | } |
| 15689 | |
| 15690 | return 0; |
| 15691 | } |
| 15692 | |
| 15693 | int |
| 15694 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 15695 | { |
| 15696 | struct bgp_node *rn; |
| 15697 | struct bgp_distance *bdistance; |
| 15698 | |
| 15699 | /* Distance configuration. */ |
| 15700 | if (bgp->distance_ebgp |
| 15701 | && bgp->distance_ibgp |
| 15702 | && bgp->distance_local |
| 15703 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 15704 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 15705 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 15706 | vty_out (vty, " distance bgp %d %d %d%s", |
| 15707 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 15708 | VTY_NEWLINE); |
| 15709 | |
| 15710 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 15711 | if ((bdistance = rn->info) != NULL) |
| 15712 | { |
| 15713 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 15714 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 15715 | bdistance->access_list ? bdistance->access_list : "", |
| 15716 | VTY_NEWLINE); |
| 15717 | } |
| 15718 | |
| 15719 | return 0; |
| 15720 | } |
| 15721 | |
| 15722 | /* Allocate routing table structure and install commands. */ |
| 15723 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 15724 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15725 | { |
| 15726 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 15727 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15728 | |
| 15729 | /* IPv4 BGP commands. */ |
| 15730 | install_element (BGP_NODE, &bgp_network_cmd); |
| 15731 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 15732 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 15733 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 15734 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 15735 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 15736 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 15737 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 15738 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 15739 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 15740 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 15741 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 15742 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 15743 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 15744 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 15745 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 15746 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 15747 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 15748 | |
| 15749 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 15750 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 15751 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 15752 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 15753 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 15754 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 15755 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 15756 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 15757 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 15758 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 15759 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 15760 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 15761 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 15762 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 15763 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 15764 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 15765 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 15766 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 15767 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 15768 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 15769 | |
| 15770 | /* IPv4 unicast configuration. */ |
| 15771 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 15772 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 15773 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 15774 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 15775 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 15776 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 15777 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15778 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 15779 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 15780 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 15781 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 15782 | 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] | 15783 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15784 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 15785 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 15786 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 15787 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 15788 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 15789 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 15790 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 15791 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 15792 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 15793 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 15794 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 15795 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 15796 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 15797 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 15798 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 15799 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 15800 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 15801 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 15802 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 15803 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 15804 | |
| 15805 | /* IPv4 multicast configuration. */ |
| 15806 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 15807 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 15808 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 15809 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 15810 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 15811 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 15812 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 15813 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 15814 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 15815 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 15816 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 15817 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 15818 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 15819 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 15820 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 15821 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 15822 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 15823 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 15824 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 15825 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 15826 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 15827 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 15828 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 15829 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 15830 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 15831 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 15832 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 15833 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 15834 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 15835 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 15836 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 15837 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 15838 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15839 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15840 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15841 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); |
| 15842 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); |
| 15843 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 15844 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 15845 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd); |
| 15846 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd); |
| 15847 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 15848 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 15849 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15850 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15851 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 15852 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 15853 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 15854 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 15855 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 15856 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 15857 | install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd); |
| 15858 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 15859 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 15860 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd); |
| 15861 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd); |
| 15862 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd); |
| 15863 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd); |
| 15864 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd); |
| 15865 | install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd); |
| 15866 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd); |
| 15867 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd); |
| 15868 | install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd); |
| 15869 | install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd); |
| 15870 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd); |
| 15871 | install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd); |
| 15872 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd); |
| 15873 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd); |
| 15874 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd); |
| 15875 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 15876 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 15877 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 15878 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15879 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 15880 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 15881 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 15882 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 15883 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15884 | install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 15885 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 15886 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 15887 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 15888 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 15889 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 15890 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 15891 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
| 15892 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd); |
| 15893 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd); |
| 15894 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd); |
| 15895 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd); |
| 15896 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd); |
| 15897 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd); |
| 15898 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd); |
| 15899 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd); |
| 15900 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd); |
| 15901 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd); |
| 15902 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15903 | 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] | 15904 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd); |
| 15905 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd); |
| 15906 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd); |
| 15907 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd); |
| 15908 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd); |
| 15909 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd); |
| 15910 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd); |
| 15911 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd); |
| 15912 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd); |
| 15913 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd); |
| 15914 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd); |
| 15915 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd); |
| 15916 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd); |
| 15917 | install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd); |
| 15918 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd); |
| 15919 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd); |
| 15920 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd); |
| 15921 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd); |
| 15922 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd); |
| 15923 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd); |
| 15924 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd); |
| 15925 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd); |
| 15926 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd); |
| 15927 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd); |
| 15928 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd); |
| 15929 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd); |
| 15930 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd); |
| 15931 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd); |
| 15932 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd); |
| 15933 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd); |
| 15934 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd); |
| 15935 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd); |
| 15936 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd); |
| 15937 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd); |
| 15938 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd); |
| 15939 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd); |
| 15940 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd); |
| 15941 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd); |
| 15942 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd); |
| 15943 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd); |
| 15944 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd); |
| 15945 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd); |
| 15946 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd); |
| 15947 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd); |
| 15948 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15949 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15950 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15951 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15952 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15953 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15954 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 15955 | |
| 15956 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15957 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15958 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 15959 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 15960 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 15961 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 15962 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15963 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15964 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 15965 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 15966 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 15967 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 15968 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 15969 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 15970 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 15971 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 15972 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd); |
| 15973 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd); |
| 15974 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd); |
| 15975 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd); |
| 15976 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 15977 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 15978 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 15979 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15980 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 15981 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 15982 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 15983 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 15984 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15985 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 15986 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 15987 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 15988 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 15989 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 15990 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 15991 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 15992 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15993 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15994 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15995 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15996 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15997 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15998 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15999 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16000 | install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd); |
| 16001 | install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd); |
| 16002 | install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16003 | install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16004 | install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd); |
| 16005 | install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd); |
| 16006 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16007 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16008 | install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16009 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16010 | install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16011 | install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16012 | install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16013 | install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16014 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16015 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16016 | install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd); |
| 16017 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16018 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16019 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd); |
| 16020 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd); |
| 16021 | install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd); |
| 16022 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd); |
| 16023 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd); |
| 16024 | install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd); |
| 16025 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd); |
| 16026 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd); |
| 16027 | install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd); |
| 16028 | install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd); |
| 16029 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd); |
| 16030 | install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd); |
| 16031 | install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd); |
| 16032 | install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd); |
| 16033 | install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd); |
| 16034 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16035 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16036 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16037 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16038 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16039 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16040 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16041 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16042 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16043 | install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16044 | install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16045 | install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16046 | install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16047 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16048 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16049 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16050 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
| 16051 | install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd); |
| 16052 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd); |
| 16053 | install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd); |
| 16054 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd); |
| 16055 | install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd); |
| 16056 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd); |
| 16057 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd); |
| 16058 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd); |
| 16059 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd); |
| 16060 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd); |
| 16061 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16062 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16063 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd); |
| 16064 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd); |
| 16065 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd); |
| 16066 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd); |
| 16067 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd); |
| 16068 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd); |
| 16069 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd); |
| 16070 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd); |
| 16071 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd); |
| 16072 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd); |
| 16073 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd); |
| 16074 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd); |
| 16075 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd); |
| 16076 | install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd); |
| 16077 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd); |
| 16078 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd); |
| 16079 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd); |
| 16080 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd); |
| 16081 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd); |
| 16082 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd); |
| 16083 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd); |
| 16084 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd); |
| 16085 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd); |
| 16086 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd); |
| 16087 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd); |
| 16088 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd); |
| 16089 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd); |
| 16090 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd); |
| 16091 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd); |
| 16092 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd); |
| 16093 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd); |
| 16094 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd); |
| 16095 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd); |
| 16096 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd); |
| 16097 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd); |
| 16098 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd); |
| 16099 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd); |
| 16100 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd); |
| 16101 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd); |
| 16102 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd); |
| 16103 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd); |
| 16104 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd); |
| 16105 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd); |
| 16106 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd); |
| 16107 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16108 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16109 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16110 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16111 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16112 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16113 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16114 | |
| 16115 | /* BGP dampening clear commands */ |
| 16116 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 16117 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 16118 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 16119 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 16120 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 16121 | /* prefix count */ |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16122 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd); |
| 16123 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 16124 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 16125 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16126 | /* New config IPv6 BGP commands. */ |
| 16127 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 16128 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 16129 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 16130 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 16131 | |
| 16132 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 16133 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 16134 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 16135 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 16136 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 16137 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 16138 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 16139 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16140 | /* Old config IPv6 BGP commands. */ |
| 16141 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 16142 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 16143 | |
| 16144 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 16145 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 16146 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 16147 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 16148 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16149 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16150 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16151 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16152 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16153 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16154 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16155 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16156 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16157 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16158 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16159 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16160 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16161 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16162 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16163 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16164 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16165 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16166 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16167 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16168 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16169 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16170 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16171 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16172 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16173 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16174 | install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 16175 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16176 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16177 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16178 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16179 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16180 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16181 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16182 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16183 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16184 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16185 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16186 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16187 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16188 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16189 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16190 | install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 16191 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16192 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16193 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16194 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16195 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16196 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16197 | |
| 16198 | /* Restricted: |
| 16199 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 16200 | */ |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16201 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16202 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16203 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16204 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16205 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16206 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16207 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16208 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16209 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16210 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16211 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16212 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
| 16213 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16214 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16215 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16216 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16217 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16218 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16219 | 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] | 16220 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16221 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16222 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16223 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16224 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16225 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16226 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16227 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16228 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16229 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16230 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16231 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16232 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16233 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16234 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16235 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16236 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16237 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16238 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16239 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16240 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16241 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16242 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16243 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16244 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16245 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16246 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16247 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16248 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16249 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16250 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16251 | install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 16252 | install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16253 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16254 | install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16255 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16256 | install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16257 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16258 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16259 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16260 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16261 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16262 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16263 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16264 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16265 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16266 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16267 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 16268 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16269 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16270 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16271 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16272 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16273 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 16274 | |
| 16275 | /* Statistics */ |
| 16276 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16277 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16278 | |
| 16279 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 16280 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 16281 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 16282 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 16283 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 16284 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 16285 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 16286 | |
| 16287 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 16288 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 16289 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 16290 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 16291 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 16292 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 16293 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 16294 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 16295 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 16296 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16297 | |
| 16298 | /* Deprecated AS-Pathlimit commands */ |
| 16299 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 16300 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 16301 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16302 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16303 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16304 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16305 | |
| 16306 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 16307 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16308 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16309 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16310 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16311 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16312 | |
| 16313 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 16314 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 16315 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16316 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16317 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16318 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16319 | |
| 16320 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 16321 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16322 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16323 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16324 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16325 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16326 | |
| 16327 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 16328 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 16329 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16330 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16331 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16332 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16333 | |
| 16334 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 16335 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16336 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16337 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16338 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16339 | 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] | 16340 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16341 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 16342 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16343 | |
| 16344 | /* old style commands */ |
| 16345 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 16346 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 16347 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 16348 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16349 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 16350 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16351 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 16352 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 16353 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16354 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16355 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 16356 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 16357 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16358 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 16359 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 16360 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 16361 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 16362 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 16363 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 16364 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 16365 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 16366 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 16367 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 16368 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 16369 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 16370 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 16371 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 16372 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 16373 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 16374 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16375 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16376 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16377 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16378 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 16379 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16380 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16381 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16382 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16383 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16384 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16385 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16386 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 16387 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 16388 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 16389 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 16390 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 16391 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 16392 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 16393 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 16394 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 16395 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 16396 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 16397 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 16398 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 16399 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 16400 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
| 16401 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 16402 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
| 16403 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 16404 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
| 16405 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 16406 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
| 16407 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 16408 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 16409 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
| 16410 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 16411 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 16412 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
| 16413 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 16414 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 16415 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 16416 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
| 16417 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 16418 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
| 16419 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 16420 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 16421 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 16422 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16423 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16424 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 16425 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
| 16426 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 16427 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16428 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
| 16429 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 16430 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16431 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16432 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 16433 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 16434 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16435 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16436 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 16437 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16438 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 16439 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 16440 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 16441 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 16442 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16443 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16444 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16445 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16446 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 16447 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16448 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16449 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16450 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16451 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16452 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16453 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16454 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16455 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16456 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16457 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
| 16458 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 16459 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 16460 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 16461 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16462 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 16463 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16464 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 16465 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 16466 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16467 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16468 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 16469 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 16470 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16471 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 16472 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 16473 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 16474 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 16475 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 16476 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 16477 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 16478 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 16479 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 16480 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 16481 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 16482 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 16483 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 16484 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 16485 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 16486 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 16487 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16488 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16489 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16490 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16491 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 16492 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16493 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16494 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16495 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16496 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16497 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16498 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16499 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 16500 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 16501 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 16502 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 16503 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 16504 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 16505 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 16506 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 16507 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 16508 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 16509 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 16510 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 16511 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 16512 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 16513 | install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); |
| 16514 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 16515 | install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
| 16516 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 16517 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
| 16518 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 16519 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd); |
| 16520 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 16521 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 16522 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
| 16523 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 16524 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd); |
| 16525 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 16526 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
| 16527 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 16528 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 16529 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 16530 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
| 16531 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 16532 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
| 16533 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 16534 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 16535 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 16536 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16537 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16538 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 16539 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
| 16540 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 16541 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16542 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
| 16543 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 16544 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 16545 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
| 16546 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 16547 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 16548 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 16549 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 16550 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 16551 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 16552 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 16553 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 16554 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 16555 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 16556 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 16557 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 16558 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 16559 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 16560 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 16561 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 16562 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 16563 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 16564 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd); |
| 16565 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 16566 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd); |
| 16567 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 16568 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 16569 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 16570 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 16571 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 16572 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 16573 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 16574 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 16575 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 16576 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 16577 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 16578 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 16579 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 16580 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 16581 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16582 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 16583 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 16584 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 16585 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 16586 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 16587 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 16588 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 16589 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 16590 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 16591 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 16592 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 16593 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 16594 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 16595 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 16596 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 16597 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16598 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 16599 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 16600 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 16601 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 16602 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 16603 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 16604 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 16605 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 16606 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 16607 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 16608 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 16609 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 16610 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 16611 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 16612 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 16613 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 16614 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 16615 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 16616 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd); |
| 16617 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 16618 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 16619 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 16620 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 16621 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 16622 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 16623 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 16624 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 16625 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 16626 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 16627 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 16628 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 16629 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 16630 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 16631 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 16632 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16633 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 16634 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 16635 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 16636 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 16637 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 16638 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 16639 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 16640 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 16641 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 16642 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 16643 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 16644 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 16645 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 16646 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 16647 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 16648 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 16649 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 16650 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 16651 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 16652 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 16653 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 16654 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 16655 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 16656 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 16657 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 16658 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 16659 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 16660 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 16661 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 16662 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 16663 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 16664 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 16665 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 16666 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 16667 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 16668 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 16669 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 16670 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 16671 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 16672 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 16673 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 16674 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 16675 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 16676 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 16677 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 16678 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 16679 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 16680 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 16681 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 16682 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 16683 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 16684 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 16685 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 16686 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 16687 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 16688 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 16689 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 16690 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 16691 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 16692 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 16693 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 16694 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 16695 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 16696 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 16697 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 16698 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 16699 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 16700 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 16701 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 16702 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 16703 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 16704 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 16705 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 16706 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 16707 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 16708 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 16709 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 16710 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 16711 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 16712 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 16713 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 16714 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 16715 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 16716 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 16717 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 16718 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 16719 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 16720 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 16721 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 16722 | /* old with name safi collision */ |
| 16723 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 16724 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 16725 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 16726 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 16727 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16728 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16729 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16730 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16731 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 16732 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 16733 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 16734 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 16735 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16736 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16737 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16738 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16739 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 16740 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 16741 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 16742 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 16743 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16744 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16745 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16746 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16747 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 16748 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 16749 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 16750 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 16751 | |
| 16752 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 16753 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
| 16754 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
| 16755 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
| 16756 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 16757 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
| 16758 | |
| 16759 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16760 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
| 16761 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16762 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
| 16763 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16764 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16765 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 16766 | |
| 16767 | void |
| 16768 | bgp_route_finish (void) |
| 16769 | { |
| 16770 | bgp_table_unlock (bgp_distance_table); |
| 16771 | bgp_distance_table = NULL; |
| 16772 | } |