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 | |
Lou Berger | 370b7e5 | 2016-02-04 21:29:49 -0500 | [diff] [blame] | 2124 | memset (&new_attr, 0, sizeof(struct attr)); |
| 2125 | memset (&new_extra, 0, sizeof(struct attr_extra)); |
| 2126 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2127 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2128 | 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] | 2129 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2130 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2131 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2132 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2133 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2134 | bgp_adj_in_set (rn, peer, attr); |
| 2135 | |
| 2136 | /* Check previously received route. */ |
| 2137 | for (ri = rn->info; ri; ri = ri->next) |
| 2138 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2139 | break; |
| 2140 | |
| 2141 | /* AS path local-as loop check. */ |
| 2142 | if (peer->change_local_as) |
| 2143 | { |
| 2144 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2145 | aspath_loop_count = 1; |
| 2146 | |
| 2147 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2148 | { |
| 2149 | reason = "as-path contains our own AS;"; |
| 2150 | goto filtered; |
| 2151 | } |
| 2152 | } |
| 2153 | |
| 2154 | /* AS path loop check. */ |
| 2155 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2156 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2157 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2158 | > peer->allowas_in[afi][safi])) |
| 2159 | { |
| 2160 | reason = "as-path contains our own AS;"; |
| 2161 | goto filtered; |
| 2162 | } |
| 2163 | |
| 2164 | /* Route reflector originator ID check. */ |
| 2165 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2166 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2167 | { |
| 2168 | reason = "originator is us;"; |
| 2169 | goto filtered; |
| 2170 | } |
| 2171 | |
| 2172 | /* Route reflector cluster ID check. */ |
| 2173 | if (bgp_cluster_filter (peer, attr)) |
| 2174 | { |
| 2175 | reason = "reflected from the same cluster;"; |
| 2176 | goto filtered; |
| 2177 | } |
| 2178 | |
| 2179 | /* Apply incoming filter. */ |
| 2180 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2181 | { |
| 2182 | reason = "filter;"; |
| 2183 | goto filtered; |
| 2184 | } |
| 2185 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2186 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2187 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2188 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2189 | /* Apply incoming route-map. |
| 2190 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2191 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2192 | * the attr (which takes over the memory references) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2193 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2194 | { |
| 2195 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2196 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2197 | goto filtered; |
| 2198 | } |
| 2199 | |
| 2200 | /* IPv4 unicast next hop check. */ |
| 2201 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2202 | { |
| 2203 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2204 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2205 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2206 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2207 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2208 | { |
| 2209 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2210 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2211 | goto filtered; |
| 2212 | } |
| 2213 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2214 | /* 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] | 2215 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2216 | if (new_attr.nexthop.s_addr == 0 |
| 2217 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2218 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2219 | { |
| 2220 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2221 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2222 | goto filtered; |
| 2223 | } |
| 2224 | } |
| 2225 | |
| 2226 | attr_new = bgp_attr_intern (&new_attr); |
| 2227 | |
| 2228 | /* If the update is implicit withdraw. */ |
| 2229 | if (ri) |
| 2230 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2231 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2232 | |
| 2233 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2234 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2235 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2236 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2237 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2238 | |
| 2239 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2240 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2241 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2242 | { |
| 2243 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2244 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2245 | peer->host, |
| 2246 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2247 | p->prefixlen); |
| 2248 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2249 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2250 | { |
| 2251 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2252 | bgp_process (bgp, rn, afi, safi); |
| 2253 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2255 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2256 | { |
| 2257 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2258 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2259 | "%s rcvd %s/%d...duplicate ignored", |
| 2260 | peer->host, |
| 2261 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2262 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2263 | |
| 2264 | /* graceful restart STALE flag unset. */ |
| 2265 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2266 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2267 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2268 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2269 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2270 | } |
| 2271 | |
| 2272 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2273 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2274 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2275 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2276 | return 0; |
| 2277 | } |
| 2278 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2279 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2280 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2281 | { |
| 2282 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2283 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2284 | peer->host, |
| 2285 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2286 | p->prefixlen); |
| 2287 | bgp_info_restore (rn, ri); |
| 2288 | } |
| 2289 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2290 | /* Received Logging. */ |
| 2291 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2292 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2293 | peer->host, |
| 2294 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2295 | p->prefixlen); |
| 2296 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2297 | /* graceful restart STALE flag unset. */ |
| 2298 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2299 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2300 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2301 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2302 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2303 | |
| 2304 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2305 | * only if update is accepted, they'll increment below. |
| 2306 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2307 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2308 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2309 | /* Update bgp route dampening information. */ |
| 2310 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2311 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2312 | { |
| 2313 | /* This is implicit withdraw so we should update dampening |
| 2314 | information. */ |
| 2315 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2316 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2317 | } |
| 2318 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2319 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2320 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2321 | ri->attr = attr_new; |
| 2322 | |
| 2323 | /* Update MPLS tag. */ |
| 2324 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2325 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2326 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2327 | bgp_attr_flush (&new_attr); |
| 2328 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2329 | /* Update bgp route dampening information. */ |
| 2330 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2331 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2332 | { |
| 2333 | /* Now we do normal update dampening. */ |
| 2334 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2335 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2336 | { |
| 2337 | bgp_unlock_node (rn); |
| 2338 | return 0; |
| 2339 | } |
| 2340 | } |
| 2341 | |
| 2342 | /* Nexthop reachability check. */ |
| 2343 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2344 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2345 | && (peer->sort == BGP_PEER_IBGP |
| 2346 | || peer->sort == BGP_PEER_CONFED |
| 2347 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2348 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2349 | { |
| 2350 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2351 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2352 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2353 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2354 | } |
| 2355 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2356 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2357 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2358 | bgp_attr_flush (&new_attr); |
| 2359 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2360 | /* Process change. */ |
| 2361 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2362 | |
| 2363 | bgp_process (bgp, rn, afi, safi); |
| 2364 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2365 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2366 | return 0; |
| 2367 | } |
| 2368 | |
| 2369 | /* Received Logging. */ |
| 2370 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2371 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2372 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2373 | peer->host, |
| 2374 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2375 | p->prefixlen); |
| 2376 | } |
| 2377 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2378 | /* Make new BGP info. */ |
| 2379 | new = bgp_info_new (); |
| 2380 | new->type = type; |
| 2381 | new->sub_type = sub_type; |
| 2382 | new->peer = peer; |
| 2383 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2384 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2385 | |
| 2386 | /* Update MPLS tag. */ |
| 2387 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2388 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2389 | |
| 2390 | /* Nexthop reachability check. */ |
| 2391 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2392 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2393 | && (peer->sort == BGP_PEER_IBGP |
| 2394 | || peer->sort == BGP_PEER_CONFED |
| 2395 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2396 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2397 | { |
| 2398 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2399 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2400 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2401 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2402 | } |
| 2403 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2404 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2405 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2406 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2407 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2408 | |
| 2409 | /* Register new BGP information. */ |
| 2410 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2411 | |
| 2412 | /* route_node_get lock */ |
| 2413 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2414 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2415 | bgp_attr_flush (&new_attr); |
| 2416 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2417 | /* If maximum prefix count is configured and current prefix |
| 2418 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2419 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2420 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2421 | |
| 2422 | /* Process change. */ |
| 2423 | bgp_process (bgp, rn, afi, safi); |
| 2424 | |
| 2425 | return 0; |
| 2426 | |
| 2427 | /* This BGP update is filtered. Log the reason then update BGP |
| 2428 | entry. */ |
| 2429 | filtered: |
| 2430 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2431 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2432 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2433 | peer->host, |
| 2434 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2435 | p->prefixlen, reason); |
| 2436 | |
| 2437 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2438 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2439 | |
| 2440 | bgp_unlock_node (rn); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2441 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2442 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2443 | return 0; |
| 2444 | } |
| 2445 | |
| 2446 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2447 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2448 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2449 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2450 | { |
| 2451 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2452 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2453 | struct bgp *bgp; |
| 2454 | int ret; |
| 2455 | |
| 2456 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2457 | soft_reconfig); |
| 2458 | |
| 2459 | bgp = peer->bgp; |
| 2460 | |
| 2461 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2462 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2463 | { |
| 2464 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2465 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2466 | sub_type, prd, tag); |
| 2467 | } |
| 2468 | |
| 2469 | return ret; |
| 2470 | } |
| 2471 | |
| 2472 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2473 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2474 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2475 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2476 | { |
| 2477 | struct bgp *bgp; |
| 2478 | char buf[SU_ADDRSTRLEN]; |
| 2479 | struct bgp_node *rn; |
| 2480 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2481 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2482 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2483 | |
| 2484 | bgp = peer->bgp; |
| 2485 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2486 | /* Lookup node. */ |
| 2487 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2488 | |
| 2489 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2490 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2491 | * the iteration over all RS clients. |
| 2492 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2493 | * if there was no entry, we don't need to do anything more. */ |
| 2494 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2495 | && peer != bgp->peer_self) |
| 2496 | if (!bgp_adj_in_unset (rn, peer)) |
| 2497 | { |
| 2498 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2499 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2500 | "not in adj-in", peer->host, |
| 2501 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2502 | p->prefixlen); |
| 2503 | bgp_unlock_node (rn); |
| 2504 | return 0; |
| 2505 | } |
| 2506 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2507 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2508 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2509 | { |
| 2510 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2511 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2512 | } |
| 2513 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2514 | /* Logging. */ |
| 2515 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2516 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2517 | peer->host, |
| 2518 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2519 | p->prefixlen); |
| 2520 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2521 | /* Lookup withdrawn route. */ |
| 2522 | for (ri = rn->info; ri; ri = ri->next) |
| 2523 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2524 | break; |
| 2525 | |
| 2526 | /* Withdraw specified route from routing table. */ |
| 2527 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2528 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2529 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2530 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2531 | "%s Can't find the route %s/%d", peer->host, |
| 2532 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2533 | p->prefixlen); |
| 2534 | |
| 2535 | /* Unlock bgp_node_get() lock. */ |
| 2536 | bgp_unlock_node (rn); |
| 2537 | |
| 2538 | return 0; |
| 2539 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2540 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2541 | void |
| 2542 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2543 | { |
| 2544 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2545 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2546 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2547 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2548 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2549 | struct bgp_node *rn; |
| 2550 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2551 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2552 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2553 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2554 | return; |
| 2555 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2556 | bgp = peer->bgp; |
| 2557 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2558 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2559 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2560 | aspath = attr.aspath; |
| 2561 | attr.local_pref = bgp->default_local_pref; |
| 2562 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2563 | |
| 2564 | if (afi == AFI_IP) |
| 2565 | str2prefix ("0.0.0.0/0", &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | else if (afi == AFI_IP6) |
| 2567 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2568 | struct attr_extra *ae = attr.extra; |
| 2569 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2570 | str2prefix ("::/0", &p); |
| 2571 | |
| 2572 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2573 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2574 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2575 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2576 | |
| 2577 | /* If the peer is on shared nextwork and we have link-local |
| 2578 | nexthop set it. */ |
| 2579 | if (peer->shared_network |
| 2580 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2581 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2582 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2583 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2584 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2585 | } |
| 2586 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2587 | |
| 2588 | if (peer->default_rmap[afi][safi].name) |
| 2589 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2590 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2591 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2592 | { |
| 2593 | for (ri = rn->info; ri; ri = ri->next) |
| 2594 | { |
| 2595 | struct attr dummy_attr; |
| 2596 | struct attr_extra dummy_extra; |
| 2597 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2598 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2599 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2600 | dummy_attr.extra = &dummy_extra; |
| 2601 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2602 | info.peer = ri->peer; |
| 2603 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2604 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2605 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2606 | RMAP_BGP, &info); |
| 2607 | |
| 2608 | /* The route map might have set attributes. If we don't flush them |
| 2609 | * here, they will be leaked. */ |
| 2610 | bgp_attr_flush(&dummy_attr); |
| 2611 | if (ret != RMAP_DENYMATCH) |
| 2612 | break; |
| 2613 | } |
| 2614 | if (ret != RMAP_DENYMATCH) |
| 2615 | break; |
| 2616 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2617 | bgp->peer_self->rmap_type = 0; |
| 2618 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2619 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2620 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2621 | } |
| 2622 | |
| 2623 | if (withdraw) |
| 2624 | { |
| 2625 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2626 | bgp_default_withdraw_send (peer, afi, safi); |
| 2627 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2628 | } |
| 2629 | else |
| 2630 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2631 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2632 | { |
| 2633 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2634 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2635 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2636 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2637 | |
| 2638 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2639 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2640 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2641 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | static void |
| 2643 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2644 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2645 | { |
| 2646 | struct bgp_node *rn; |
| 2647 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2648 | struct attr attr; |
| 2649 | struct attr_extra extra; |
| 2650 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2651 | memset(&extra, 0, sizeof(extra)); |
| 2652 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2653 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2654 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2655 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2656 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2657 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2658 | bgp_default_originate (peer, afi, safi, 0); |
| 2659 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2660 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2661 | attr.extra = &extra; |
| 2662 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2663 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2664 | for (ri = rn->info; ri; ri = ri->next) |
| 2665 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2666 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2667 | if ( (rsclient) ? |
| 2668 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2669 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2670 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2671 | else |
| 2672 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2673 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2674 | |
| 2675 | bgp_attr_flush_encap(&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2676 | } |
| 2677 | |
| 2678 | void |
| 2679 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2680 | { |
| 2681 | struct bgp_node *rn; |
| 2682 | struct bgp_table *table; |
| 2683 | |
| 2684 | if (peer->status != Established) |
| 2685 | return; |
| 2686 | |
| 2687 | if (! peer->afc_nego[afi][safi]) |
| 2688 | return; |
| 2689 | |
| 2690 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2691 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2692 | return; |
| 2693 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2694 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2695 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2696 | else |
| 2697 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2698 | rn = bgp_route_next(rn)) |
| 2699 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2700 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2701 | |
| 2702 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2703 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2704 | } |
| 2705 | |
| 2706 | void |
| 2707 | bgp_announce_route_all (struct peer *peer) |
| 2708 | { |
| 2709 | afi_t afi; |
| 2710 | safi_t safi; |
| 2711 | |
| 2712 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2713 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2714 | bgp_announce_route (peer, afi, safi); |
| 2715 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2716 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2717 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2718 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2719 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2720 | { |
| 2721 | struct bgp_node *rn; |
| 2722 | struct bgp_adj_in *ain; |
| 2723 | |
| 2724 | if (! table) |
| 2725 | table = rsclient->bgp->rib[afi][safi]; |
| 2726 | |
| 2727 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2728 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2729 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2730 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2731 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2732 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2733 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2734 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2735 | } |
| 2736 | } |
| 2737 | |
| 2738 | void |
| 2739 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2740 | { |
| 2741 | struct bgp_table *table; |
| 2742 | struct bgp_node *rn; |
| 2743 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2744 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2745 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2746 | |
| 2747 | else |
| 2748 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2749 | rn = bgp_route_next (rn)) |
| 2750 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2751 | { |
| 2752 | struct prefix_rd prd; |
| 2753 | prd.family = AF_UNSPEC; |
| 2754 | prd.prefixlen = 64; |
| 2755 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2756 | |
| 2757 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2758 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2759 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2760 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2761 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2762 | 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] | 2763 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2764 | { |
| 2765 | int ret; |
| 2766 | struct bgp_node *rn; |
| 2767 | struct bgp_adj_in *ain; |
| 2768 | |
| 2769 | if (! table) |
| 2770 | table = peer->bgp->rib[afi][safi]; |
| 2771 | |
| 2772 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2773 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2774 | { |
| 2775 | if (ain->peer == peer) |
| 2776 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2777 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2778 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2779 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2780 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2781 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2782 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2783 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2784 | if (ret < 0) |
| 2785 | { |
| 2786 | bgp_unlock_node (rn); |
| 2787 | return; |
| 2788 | } |
| 2789 | continue; |
| 2790 | } |
| 2791 | } |
| 2792 | } |
| 2793 | |
| 2794 | void |
| 2795 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2796 | { |
| 2797 | struct bgp_node *rn; |
| 2798 | struct bgp_table *table; |
| 2799 | |
| 2800 | if (peer->status != Established) |
| 2801 | return; |
| 2802 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2803 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2804 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2805 | else |
| 2806 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2807 | rn = bgp_route_next (rn)) |
| 2808 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2809 | { |
| 2810 | struct prefix_rd prd; |
| 2811 | prd.family = AF_UNSPEC; |
| 2812 | prd.prefixlen = 64; |
| 2813 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2814 | |
| 2815 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2816 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2817 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2818 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2819 | |
| 2820 | struct bgp_clear_node_queue |
| 2821 | { |
| 2822 | struct bgp_node *rn; |
| 2823 | enum bgp_clear_route_type purpose; |
| 2824 | }; |
| 2825 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2826 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2827 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2828 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2829 | struct bgp_clear_node_queue *cnq = data; |
| 2830 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2831 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2832 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2833 | afi_t afi = bgp_node_table (rn)->afi; |
| 2834 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2835 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2836 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2837 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2838 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2839 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2840 | { |
| 2841 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2842 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2843 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2844 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2845 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2846 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2847 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2848 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2849 | break; |
| 2850 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2851 | return WQ_SUCCESS; |
| 2852 | } |
| 2853 | |
| 2854 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2855 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2856 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2857 | struct bgp_clear_node_queue *cnq = data; |
| 2858 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2859 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2860 | |
| 2861 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2862 | bgp_table_unlock (table); |
| 2863 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2864 | } |
| 2865 | |
| 2866 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2867 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2868 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2869 | struct peer *peer = wq->spec.data; |
| 2870 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2871 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2872 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2873 | |
| 2874 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2875 | } |
| 2876 | |
| 2877 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2878 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2879 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2880 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2881 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2882 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2883 | #undef CLEAR_QUEUE_NAME_LEN |
| 2884 | |
| 2885 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2886 | { |
| 2887 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2888 | exit (1); |
| 2889 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2890 | peer->clear_node_queue->spec.hold = 10; |
| 2891 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2892 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2893 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2894 | peer->clear_node_queue->spec.max_retries = 0; |
| 2895 | |
| 2896 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2897 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2898 | } |
| 2899 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2900 | static void |
| 2901 | 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] | 2902 | struct bgp_table *table, struct peer *rsclient, |
| 2903 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2904 | { |
| 2905 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2906 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2907 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2908 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2909 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2910 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2911 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2912 | if (! table) |
| 2913 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2914 | |
| 2915 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2916 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2917 | struct bgp_info *ri; |
| 2918 | struct bgp_adj_in *ain; |
| 2919 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2920 | |
| 2921 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2922 | * queued for every clearing peer, regardless of whether it is |
| 2923 | * relevant to the peer at hand. |
| 2924 | * |
| 2925 | * Overview: There are 3 different indices which need to be |
| 2926 | * scrubbed, potentially, when a peer is removed: |
| 2927 | * |
| 2928 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2929 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2930 | * 3 other routes visible by the peer's adj-out index |
| 2931 | * |
| 2932 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2933 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2934 | * adj-outs at our leisure. |
| 2935 | * |
| 2936 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2937 | * invisible via RIB index before peer session is allowed to be |
| 2938 | * brought back up. So one needs to know when such a 'search' is |
| 2939 | * complete. |
| 2940 | * |
| 2941 | * Ideally: |
| 2942 | * |
| 2943 | * - there'd be a single global queue or a single RIB walker |
| 2944 | * - rather than tracking which route_nodes still need to be |
| 2945 | * examined on a peer basis, we'd track which peers still |
| 2946 | * aren't cleared |
| 2947 | * |
| 2948 | * Given that our per-peer prefix-counts now should be reliable, |
| 2949 | * this may actually be achievable. It doesn't seem to be a huge |
| 2950 | * problem at this time, |
| 2951 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2952 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2953 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2954 | { |
| 2955 | bgp_adj_in_remove (rn, ain); |
| 2956 | bgp_unlock_node (rn); |
| 2957 | break; |
| 2958 | } |
| 2959 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2960 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2961 | { |
| 2962 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2963 | bgp_unlock_node (rn); |
| 2964 | break; |
| 2965 | } |
| 2966 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2967 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2968 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2969 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2970 | struct bgp_clear_node_queue *cnq; |
| 2971 | |
| 2972 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2973 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2974 | bgp_lock_node (rn); |
| 2975 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2976 | sizeof (struct bgp_clear_node_queue)); |
| 2977 | cnq->rn = rn; |
| 2978 | cnq->purpose = purpose; |
| 2979 | work_queue_add (peer->clear_node_queue, cnq); |
| 2980 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2981 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2982 | } |
| 2983 | return; |
| 2984 | } |
| 2985 | |
| 2986 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2987 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2988 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2989 | { |
| 2990 | struct bgp_node *rn; |
| 2991 | struct bgp_table *table; |
| 2992 | struct peer *rsclient; |
| 2993 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2994 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2995 | if (peer->clear_node_queue == NULL) |
| 2996 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2997 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2998 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2999 | * Idle until it receives a Clearing_Completed event. This protects |
| 3000 | * against peers which flap faster than we can we clear, which could |
| 3001 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3002 | * |
| 3003 | * a) race with routes from the new session being installed before |
| 3004 | * clear_route_node visits the node (to delete the route of that |
| 3005 | * peer) |
| 3006 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 3007 | * on the process_main queue. Fast-flapping could cause that queue |
| 3008 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3009 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3010 | |
| 3011 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 3012 | * the unlock will happen upon work-queue completion; other wise, the |
| 3013 | * unlock happens at the end of this function. |
| 3014 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3015 | if (!peer->clear_node_queue->thread) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3016 | peer_lock (peer); /* bgp_clear_node_complete */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3017 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3018 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3019 | case BGP_CLEAR_ROUTE_NORMAL: |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3020 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3021 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3022 | else |
| 3023 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3024 | rn = bgp_route_next (rn)) |
| 3025 | if ((table = rn->info) != NULL) |
| 3026 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3027 | |
| 3028 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3029 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3030 | PEER_FLAG_RSERVER_CLIENT)) |
| 3031 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3032 | break; |
| 3033 | |
| 3034 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3035 | /* |
| 3036 | * gpz 091009: TBD why don't we have special handling for |
| 3037 | * SAFI_MPLS_VPN here in the original quagga code? |
| 3038 | * (and, by extension, for SAFI_ENCAP) |
| 3039 | */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3040 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3041 | break; |
| 3042 | |
| 3043 | default: |
| 3044 | assert (0); |
| 3045 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3046 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3047 | |
| 3048 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3049 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3050 | peer_unlock (peer); |
| 3051 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3052 | } |
| 3053 | |
| 3054 | void |
| 3055 | bgp_clear_route_all (struct peer *peer) |
| 3056 | { |
| 3057 | afi_t afi; |
| 3058 | safi_t safi; |
| 3059 | |
| 3060 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3061 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3062 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3063 | } |
| 3064 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3065 | /* |
| 3066 | * Finish freeing things when exiting |
| 3067 | */ |
| 3068 | static void |
| 3069 | bgp_drain_workqueue_immediate (struct work_queue *wq) |
| 3070 | { |
| 3071 | if (!wq) |
| 3072 | return; |
| 3073 | |
| 3074 | if (!wq->thread) |
| 3075 | { |
| 3076 | /* |
| 3077 | * no thread implies no queued items |
| 3078 | */ |
| 3079 | assert(!wq->items->count); |
| 3080 | return; |
| 3081 | } |
| 3082 | |
| 3083 | while (wq->items->count) |
| 3084 | { |
| 3085 | if (wq->thread) |
| 3086 | thread_cancel(wq->thread); |
| 3087 | work_queue_run(wq->thread); |
| 3088 | } |
| 3089 | } |
| 3090 | |
| 3091 | /* |
| 3092 | * Special function to process clear node queue when bgpd is exiting |
| 3093 | * and the thread scheduler is no longer running. |
| 3094 | */ |
| 3095 | void |
| 3096 | bgp_peer_clear_node_queue_drain_immediate(struct peer *peer) |
| 3097 | { |
| 3098 | if (!peer) |
| 3099 | return; |
| 3100 | |
| 3101 | bgp_drain_workqueue_immediate(peer->clear_node_queue); |
| 3102 | } |
| 3103 | |
| 3104 | /* |
| 3105 | * The work queues are not specific to a BGP instance, but the |
| 3106 | * items in them refer to BGP instances, so this should be called |
| 3107 | * before each BGP instance is deleted. |
| 3108 | */ |
| 3109 | void |
| 3110 | bgp_process_queues_drain_immediate(void) |
| 3111 | { |
| 3112 | bgp_drain_workqueue_immediate(bm->process_main_queue); |
| 3113 | bgp_drain_workqueue_immediate(bm->process_rsclient_queue); |
| 3114 | } |
| 3115 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3116 | void |
| 3117 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3118 | { |
| 3119 | struct bgp_table *table; |
| 3120 | struct bgp_node *rn; |
| 3121 | struct bgp_adj_in *ain; |
| 3122 | |
| 3123 | table = peer->bgp->rib[afi][safi]; |
| 3124 | |
| 3125 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3126 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3127 | if (ain->peer == peer) |
| 3128 | { |
| 3129 | bgp_adj_in_remove (rn, ain); |
| 3130 | bgp_unlock_node (rn); |
| 3131 | break; |
| 3132 | } |
| 3133 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3134 | |
| 3135 | void |
| 3136 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3137 | { |
| 3138 | struct bgp_node *rn; |
| 3139 | struct bgp_info *ri; |
| 3140 | struct bgp_table *table; |
| 3141 | |
| 3142 | table = peer->bgp->rib[afi][safi]; |
| 3143 | |
| 3144 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3145 | { |
| 3146 | for (ri = rn->info; ri; ri = ri->next) |
| 3147 | if (ri->peer == peer) |
| 3148 | { |
| 3149 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3150 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3151 | break; |
| 3152 | } |
| 3153 | } |
| 3154 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3155 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3156 | static void |
| 3157 | bgp_cleanup_table(struct bgp_table *table, safi_t safi) |
| 3158 | { |
| 3159 | struct bgp_node *rn; |
| 3160 | struct bgp_info *ri; |
| 3161 | struct bgp_info *next; |
| 3162 | |
| 3163 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3164 | for (ri = rn->info; ri; ri = next) |
| 3165 | { |
| 3166 | next = ri->next; |
| 3167 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3168 | && ri->type == ZEBRA_ROUTE_BGP |
| 3169 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 3170 | bgp_zebra_withdraw (&rn->p, ri, safi); |
| 3171 | } |
| 3172 | } |
| 3173 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3174 | /* Delete all kernel routes. */ |
| 3175 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3176 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3177 | { |
| 3178 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3179 | struct listnode *node, *nnode; |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3180 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3181 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3182 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3183 | { |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3184 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
| 3185 | { |
| 3186 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3187 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3188 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3189 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3190 | /* |
| 3191 | * VPN and ENCAP tables are two-level (RD is top level) |
| 3192 | */ |
| 3193 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn; |
| 3194 | rn = bgp_route_next (rn)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3195 | { |
| 3196 | if (rn->info) |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3197 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3198 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN); |
| 3199 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3200 | rn->info = NULL; |
| 3201 | bgp_unlock_node(rn); |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3202 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3203 | } |
| 3204 | |
| 3205 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn; |
| 3206 | rn = bgp_route_next (rn)) |
| 3207 | { |
| 3208 | if (rn->info) |
| 3209 | { |
| 3210 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP); |
| 3211 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3212 | rn->info = NULL; |
| 3213 | bgp_unlock_node(rn); |
| 3214 | } |
| 3215 | } |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3216 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3217 | } |
| 3218 | } |
| 3219 | |
| 3220 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3221 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3222 | { |
| 3223 | vty_reset (); |
| 3224 | bgp_zclient_reset (); |
| 3225 | access_list_reset (); |
| 3226 | prefix_list_reset (); |
| 3227 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3228 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3229 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3230 | value. */ |
| 3231 | int |
Paul Jakma | 518a4b7 | 2016-02-04 13:27:04 +0000 | [diff] [blame] | 3232 | bgp_nlri_parse_ip (struct peer *peer, struct attr *attr, |
| 3233 | struct bgp_nlri *packet) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3234 | { |
| 3235 | u_char *pnt; |
| 3236 | u_char *lim; |
| 3237 | struct prefix p; |
| 3238 | int psize; |
| 3239 | int ret; |
| 3240 | |
| 3241 | /* Check peer status. */ |
| 3242 | if (peer->status != Established) |
| 3243 | return 0; |
| 3244 | |
| 3245 | pnt = packet->nlri; |
| 3246 | lim = pnt + packet->length; |
| 3247 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3248 | /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for |
| 3249 | syntactic validity. If the field is syntactically incorrect, |
| 3250 | then the Error Subcode is set to Invalid Network Field. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3251 | for (; pnt < lim; pnt += psize) |
| 3252 | { |
| 3253 | /* Clear prefix structure. */ |
| 3254 | memset (&p, 0, sizeof (struct prefix)); |
| 3255 | |
| 3256 | /* Fetch prefix length. */ |
| 3257 | p.prefixlen = *pnt++; |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3258 | /* afi/safi validity already verified by caller, bgp_update_receive */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3259 | p.family = afi2family (packet->afi); |
| 3260 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3261 | /* Prefix length check. */ |
| 3262 | if (p.prefixlen > prefix_blen (&p) * 8) |
| 3263 | { |
| 3264 | plog_err (peer->log, |
| 3265 | "%s [Error] Update packet error" |
| 3266 | " (wrong prefix length %u for afi %u)", |
| 3267 | peer->host, p.prefixlen, packet->afi); |
| 3268 | return -1; |
| 3269 | } |
| 3270 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3271 | /* Packet size overflow check. */ |
| 3272 | psize = PSIZE (p.prefixlen); |
| 3273 | |
| 3274 | /* When packet overflow occur return immediately. */ |
| 3275 | if (pnt + psize > lim) |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3276 | { |
| 3277 | plog_err (peer->log, |
| 3278 | "%s [Error] Update packet error" |
| 3279 | " (prefix length %u overflows packet)", |
| 3280 | peer->host, p.prefixlen); |
| 3281 | return -1; |
| 3282 | } |
| 3283 | |
| 3284 | /* Defensive coding, double-check the psize fits in a struct prefix */ |
| 3285 | if (psize > (ssize_t) sizeof(p.u)) |
| 3286 | { |
| 3287 | plog_err (peer->log, |
| 3288 | "%s [Error] Update packet error" |
| 3289 | " (prefix length %u too large for prefix storage %zu!?!!", |
| 3290 | peer->host, p.prefixlen, sizeof(p.u)); |
| 3291 | return -1; |
| 3292 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3293 | |
| 3294 | /* Fetch prefix from NLRI packet. */ |
| 3295 | memcpy (&p.u.prefix, pnt, psize); |
| 3296 | |
| 3297 | /* Check address. */ |
| 3298 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3299 | { |
| 3300 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3301 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3302 | /* |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3303 | * From RFC4271 Section 6.3: |
| 3304 | * |
| 3305 | * If a prefix in the NLRI field is semantically incorrect |
| 3306 | * (e.g., an unexpected multicast IP address), an error SHOULD |
| 3307 | * be logged locally, and the prefix SHOULD be ignored. |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3308 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3309 | zlog (peer->log, LOG_ERR, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3310 | "%s: IPv4 unicast NLRI is multicast address %s, ignoring", |
| 3311 | peer->host, inet_ntoa (p.u.prefix4)); |
| 3312 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3313 | } |
| 3314 | } |
| 3315 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3316 | /* Check address. */ |
| 3317 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3318 | { |
| 3319 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3320 | { |
| 3321 | char buf[BUFSIZ]; |
| 3322 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3323 | zlog (peer->log, LOG_ERR, |
| 3324 | "%s: IPv6 unicast NLRI is link-local address %s, ignoring", |
| 3325 | peer->host, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3326 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3327 | continue; |
| 3328 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3329 | if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6)) |
| 3330 | { |
| 3331 | char buf[BUFSIZ]; |
| 3332 | |
| 3333 | zlog (peer->log, LOG_ERR, |
| 3334 | "%s: IPv6 unicast NLRI is multicast address %s, ignoring", |
| 3335 | peer->host, |
| 3336 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3337 | continue; |
| 3338 | } |
| 3339 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3340 | |
| 3341 | /* Normal process. */ |
| 3342 | if (attr) |
| 3343 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3344 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3345 | else |
| 3346 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3347 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3348 | |
| 3349 | /* Address family configuration mismatch or maximum-prefix count |
| 3350 | overflow. */ |
| 3351 | if (ret < 0) |
| 3352 | return -1; |
| 3353 | } |
| 3354 | |
| 3355 | /* Packet length consistency check. */ |
| 3356 | if (pnt != lim) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3357 | { |
| 3358 | plog_err (peer->log, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3359 | "%s [Error] Update packet error" |
| 3360 | " (prefix length mismatch with total length)", |
| 3361 | peer->host); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3362 | return -1; |
| 3363 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3364 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3365 | return 0; |
| 3366 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3367 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3368 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3369 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3370 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3371 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3372 | } |
| 3373 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3374 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3375 | bgp_static_free (struct bgp_static *bgp_static) |
| 3376 | { |
| 3377 | if (bgp_static->rmap.name) |
| 3378 | free (bgp_static->rmap.name); |
| 3379 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3380 | } |
| 3381 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3382 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3383 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3384 | struct prefix *p, afi_t afi, safi_t safi) |
| 3385 | { |
| 3386 | struct bgp_node *rn; |
| 3387 | struct bgp_info *ri; |
| 3388 | |
| 3389 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3390 | |
| 3391 | /* Check selected route and self inserted route. */ |
| 3392 | for (ri = rn->info; ri; ri = ri->next) |
| 3393 | if (ri->peer == bgp->peer_self |
| 3394 | && ri->type == ZEBRA_ROUTE_BGP |
| 3395 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3396 | break; |
| 3397 | |
| 3398 | /* Withdraw static BGP route from routing table. */ |
| 3399 | if (ri) |
| 3400 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3401 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3402 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3403 | } |
| 3404 | |
| 3405 | /* Unlock bgp_node_lookup. */ |
| 3406 | bgp_unlock_node (rn); |
| 3407 | } |
| 3408 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3409 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3410 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3411 | struct bgp_static *bgp_static, |
| 3412 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3413 | { |
| 3414 | struct bgp_node *rn; |
| 3415 | struct bgp_info *ri; |
| 3416 | struct bgp_info *new; |
| 3417 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3418 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3419 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3420 | struct attr new_attr; |
| 3421 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3422 | struct bgp *bgp; |
| 3423 | int ret; |
| 3424 | char buf[SU_ADDRSTRLEN]; |
| 3425 | |
| 3426 | bgp = rsclient->bgp; |
| 3427 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3428 | assert (bgp_static); |
| 3429 | if (!bgp_static) |
| 3430 | return; |
| 3431 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3432 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3433 | |
| 3434 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3435 | |
| 3436 | attr.nexthop = bgp_static->igpnexthop; |
| 3437 | attr.med = bgp_static->igpmetric; |
| 3438 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3439 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3440 | if (bgp_static->atomic) |
| 3441 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3442 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3443 | /* Apply network route-map for export to this rsclient. */ |
| 3444 | if (bgp_static->rmap.name) |
| 3445 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3446 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3447 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3448 | info.attr = &attr_tmp; |
| 3449 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3450 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3451 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3452 | |
| 3453 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3454 | |
| 3455 | rsclient->rmap_type = 0; |
| 3456 | |
| 3457 | if (ret == RMAP_DENYMATCH) |
| 3458 | { |
| 3459 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3460 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3461 | |
| 3462 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3463 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3464 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3465 | bgp_attr_extra_free (&attr); |
| 3466 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3467 | return; |
| 3468 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3469 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3470 | } |
| 3471 | else |
| 3472 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3473 | |
| 3474 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3475 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3476 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3477 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3478 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3479 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3480 | == RMAP_DENY) |
| 3481 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3482 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3483 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3484 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3485 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3486 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3487 | p->prefixlen, rsclient->host); |
| 3488 | |
| 3489 | bgp->peer_self->rmap_type = 0; |
| 3490 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3491 | bgp_attr_unintern (&attr_new); |
| 3492 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3493 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3494 | |
| 3495 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3496 | |
| 3497 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3498 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3499 | |
| 3500 | bgp->peer_self->rmap_type = 0; |
| 3501 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3502 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3503 | attr_new = bgp_attr_intern (&new_attr); |
| 3504 | |
| 3505 | for (ri = rn->info; ri; ri = ri->next) |
| 3506 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3507 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3508 | break; |
| 3509 | |
| 3510 | if (ri) |
| 3511 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3512 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3513 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3514 | { |
| 3515 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3516 | bgp_attr_unintern (&attr_new); |
| 3517 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3518 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3519 | return; |
| 3520 | } |
| 3521 | else |
| 3522 | { |
| 3523 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3524 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3525 | |
| 3526 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3527 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3528 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3529 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3530 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3531 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3532 | |
| 3533 | /* Process change. */ |
| 3534 | bgp_process (bgp, rn, afi, safi); |
| 3535 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3536 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3537 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3538 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3539 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3540 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3541 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3542 | /* Make new BGP info. */ |
| 3543 | new = bgp_info_new (); |
| 3544 | new->type = ZEBRA_ROUTE_BGP; |
| 3545 | new->sub_type = BGP_ROUTE_STATIC; |
| 3546 | new->peer = bgp->peer_self; |
| 3547 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3548 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3549 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3550 | |
| 3551 | /* Register new BGP information. */ |
| 3552 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3553 | |
| 3554 | /* route_node_get lock */ |
| 3555 | bgp_unlock_node (rn); |
| 3556 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3557 | /* Process change. */ |
| 3558 | bgp_process (bgp, rn, afi, safi); |
| 3559 | |
| 3560 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3561 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3562 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3563 | } |
| 3564 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3565 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3566 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3567 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3568 | { |
| 3569 | struct bgp_node *rn; |
| 3570 | struct bgp_info *ri; |
| 3571 | struct bgp_info *new; |
| 3572 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3573 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3574 | struct attr *attr_new; |
| 3575 | int ret; |
| 3576 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3577 | assert (bgp_static); |
| 3578 | if (!bgp_static) |
| 3579 | return; |
| 3580 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3581 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3582 | |
| 3583 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3584 | |
| 3585 | attr.nexthop = bgp_static->igpnexthop; |
| 3586 | attr.med = bgp_static->igpmetric; |
| 3587 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3588 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3589 | if (bgp_static->atomic) |
| 3590 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3591 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3592 | /* Apply route-map. */ |
| 3593 | if (bgp_static->rmap.name) |
| 3594 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3595 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3596 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3597 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3598 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3599 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3600 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3601 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3602 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3603 | bgp->peer_self->rmap_type = 0; |
| 3604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3605 | if (ret == RMAP_DENYMATCH) |
| 3606 | { |
| 3607 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3608 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3609 | |
| 3610 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3611 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3612 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3613 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3614 | return; |
| 3615 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3616 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3617 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3618 | else |
| 3619 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3620 | |
| 3621 | for (ri = rn->info; ri; ri = ri->next) |
| 3622 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3623 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3624 | break; |
| 3625 | |
| 3626 | if (ri) |
| 3627 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3628 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3629 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3630 | { |
| 3631 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3632 | bgp_attr_unintern (&attr_new); |
| 3633 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3634 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3635 | return; |
| 3636 | } |
| 3637 | else |
| 3638 | { |
| 3639 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3640 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3641 | |
| 3642 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3643 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3644 | bgp_info_restore(rn, ri); |
| 3645 | else |
| 3646 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3647 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3648 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3649 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3650 | |
| 3651 | /* Process change. */ |
| 3652 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3653 | bgp_process (bgp, rn, afi, safi); |
| 3654 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3655 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3656 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3657 | return; |
| 3658 | } |
| 3659 | } |
| 3660 | |
| 3661 | /* Make new BGP info. */ |
| 3662 | new = bgp_info_new (); |
| 3663 | new->type = ZEBRA_ROUTE_BGP; |
| 3664 | new->sub_type = BGP_ROUTE_STATIC; |
| 3665 | new->peer = bgp->peer_self; |
| 3666 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3667 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3668 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3669 | |
| 3670 | /* Aggregate address increment. */ |
| 3671 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3672 | |
| 3673 | /* Register new BGP information. */ |
| 3674 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3675 | |
| 3676 | /* route_node_get lock */ |
| 3677 | bgp_unlock_node (rn); |
| 3678 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3679 | /* Process change. */ |
| 3680 | bgp_process (bgp, rn, afi, safi); |
| 3681 | |
| 3682 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3683 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3684 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3685 | } |
| 3686 | |
| 3687 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3688 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3689 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3690 | { |
| 3691 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3692 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3693 | |
| 3694 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3695 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3696 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3697 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3698 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3699 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3700 | } |
| 3701 | } |
| 3702 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3703 | void |
| 3704 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3705 | safi_t safi) |
| 3706 | { |
| 3707 | struct bgp_node *rn; |
| 3708 | struct bgp_info *ri; |
| 3709 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3710 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3711 | |
| 3712 | /* Check selected route and self inserted route. */ |
| 3713 | for (ri = rn->info; ri; ri = ri->next) |
| 3714 | if (ri->peer == bgp->peer_self |
| 3715 | && ri->type == ZEBRA_ROUTE_BGP |
| 3716 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3717 | break; |
| 3718 | |
| 3719 | /* Withdraw static BGP route from routing table. */ |
| 3720 | if (ri) |
| 3721 | { |
| 3722 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3723 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3724 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3725 | } |
| 3726 | |
| 3727 | /* Unlock bgp_node_lookup. */ |
| 3728 | bgp_unlock_node (rn); |
| 3729 | } |
| 3730 | |
| 3731 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3732 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3733 | { |
| 3734 | struct bgp_static *bgp_static; |
| 3735 | struct bgp *bgp; |
| 3736 | struct bgp_node *rn; |
| 3737 | struct prefix *p; |
| 3738 | |
| 3739 | bgp = rsclient->bgp; |
| 3740 | |
| 3741 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3742 | if ((bgp_static = rn->info) != NULL) |
| 3743 | { |
| 3744 | p = &rn->p; |
| 3745 | |
| 3746 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3747 | afi, safi); |
| 3748 | } |
| 3749 | } |
| 3750 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3751 | /* |
| 3752 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP |
| 3753 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3754 | static void |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3755 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3756 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3757 | { |
| 3758 | struct bgp_node *rn; |
| 3759 | struct bgp_info *ri; |
| 3760 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3761 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3762 | |
| 3763 | /* Check selected route and self inserted route. */ |
| 3764 | for (ri = rn->info; ri; ri = ri->next) |
| 3765 | if (ri->peer == bgp->peer_self |
| 3766 | && ri->type == ZEBRA_ROUTE_BGP |
| 3767 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3768 | break; |
| 3769 | |
| 3770 | /* Withdraw static BGP route from routing table. */ |
| 3771 | if (ri) |
| 3772 | { |
| 3773 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3774 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3775 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3776 | } |
| 3777 | |
| 3778 | /* Unlock bgp_node_lookup. */ |
| 3779 | bgp_unlock_node (rn); |
| 3780 | } |
| 3781 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3782 | static void |
| 3783 | bgp_static_update_safi (struct bgp *bgp, struct prefix *p, |
| 3784 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3785 | { |
| 3786 | struct bgp_node *rn; |
| 3787 | struct bgp_info *new; |
| 3788 | struct attr *attr_new; |
| 3789 | struct attr attr = { 0 }; |
| 3790 | struct bgp_info *ri; |
| 3791 | |
| 3792 | assert (bgp_static); |
| 3793 | |
| 3794 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd); |
| 3795 | |
| 3796 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 3797 | |
| 3798 | attr.nexthop = bgp_static->igpnexthop; |
| 3799 | attr.med = bgp_static->igpmetric; |
| 3800 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3801 | |
| 3802 | /* Apply route-map. */ |
| 3803 | if (bgp_static->rmap.name) |
| 3804 | { |
| 3805 | struct attr attr_tmp = attr; |
| 3806 | struct bgp_info info; |
| 3807 | int ret; |
| 3808 | |
| 3809 | info.peer = bgp->peer_self; |
| 3810 | info.attr = &attr_tmp; |
| 3811 | |
| 3812 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3813 | |
| 3814 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3815 | |
| 3816 | bgp->peer_self->rmap_type = 0; |
| 3817 | |
| 3818 | if (ret == RMAP_DENYMATCH) |
| 3819 | { |
| 3820 | /* Free uninterned attribute. */ |
| 3821 | bgp_attr_flush (&attr_tmp); |
| 3822 | |
| 3823 | /* Unintern original. */ |
| 3824 | aspath_unintern (&attr.aspath); |
| 3825 | bgp_attr_extra_free (&attr); |
| 3826 | bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd, |
| 3827 | bgp_static->tag); |
| 3828 | return; |
| 3829 | } |
| 3830 | |
| 3831 | attr_new = bgp_attr_intern (&attr_tmp); |
| 3832 | } |
| 3833 | else |
| 3834 | { |
| 3835 | attr_new = bgp_attr_intern (&attr); |
| 3836 | } |
| 3837 | |
| 3838 | for (ri = rn->info; ri; ri = ri->next) |
| 3839 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3840 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3841 | break; |
| 3842 | |
| 3843 | if (ri) |
| 3844 | { |
| 3845 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3846 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3847 | { |
| 3848 | bgp_unlock_node (rn); |
| 3849 | bgp_attr_unintern (&attr_new); |
| 3850 | aspath_unintern (&attr.aspath); |
| 3851 | bgp_attr_extra_free (&attr); |
| 3852 | return; |
| 3853 | } |
| 3854 | else |
| 3855 | { |
| 3856 | /* The attribute is changed. */ |
| 3857 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
| 3858 | |
| 3859 | /* Rewrite BGP route information. */ |
| 3860 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3861 | bgp_info_restore(rn, ri); |
| 3862 | else |
| 3863 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3864 | bgp_attr_unintern (&ri->attr); |
| 3865 | ri->attr = attr_new; |
| 3866 | ri->uptime = bgp_clock (); |
| 3867 | |
| 3868 | /* Process change. */ |
| 3869 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3870 | bgp_process (bgp, rn, afi, safi); |
| 3871 | bgp_unlock_node (rn); |
| 3872 | aspath_unintern (&attr.aspath); |
| 3873 | bgp_attr_extra_free (&attr); |
| 3874 | return; |
| 3875 | } |
| 3876 | } |
| 3877 | |
| 3878 | |
| 3879 | /* Make new BGP info. */ |
| 3880 | new = bgp_info_new (); |
| 3881 | new->type = ZEBRA_ROUTE_BGP; |
| 3882 | new->sub_type = BGP_ROUTE_STATIC; |
| 3883 | new->peer = bgp->peer_self; |
| 3884 | new->attr = attr_new; |
| 3885 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3886 | new->uptime = bgp_clock (); |
| 3887 | new->extra = bgp_info_extra_new(); |
| 3888 | memcpy (new->extra->tag, bgp_static->tag, 3); |
| 3889 | |
| 3890 | /* Aggregate address increment. */ |
| 3891 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3892 | |
| 3893 | /* Register new BGP information. */ |
| 3894 | bgp_info_add (rn, new); |
| 3895 | |
| 3896 | /* route_node_get lock */ |
| 3897 | bgp_unlock_node (rn); |
| 3898 | |
| 3899 | /* Process change. */ |
| 3900 | bgp_process (bgp, rn, afi, safi); |
| 3901 | |
| 3902 | /* Unintern original. */ |
| 3903 | aspath_unintern (&attr.aspath); |
| 3904 | bgp_attr_extra_free (&attr); |
| 3905 | } |
| 3906 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3907 | /* Configure static BGP network. When user don't run zebra, static |
| 3908 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3909 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3910 | 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] | 3911 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3912 | { |
| 3913 | int ret; |
| 3914 | struct prefix p; |
| 3915 | struct bgp_static *bgp_static; |
| 3916 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3917 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3918 | |
| 3919 | /* Convert IP prefix string to struct prefix. */ |
| 3920 | ret = str2prefix (ip_str, &p); |
| 3921 | if (! ret) |
| 3922 | { |
| 3923 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3924 | return CMD_WARNING; |
| 3925 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3926 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3927 | { |
| 3928 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3929 | VTY_NEWLINE); |
| 3930 | return CMD_WARNING; |
| 3931 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3932 | |
| 3933 | apply_mask (&p); |
| 3934 | |
| 3935 | /* Set BGP static route configuration. */ |
| 3936 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3937 | |
| 3938 | if (rn->info) |
| 3939 | { |
| 3940 | /* Configuration change. */ |
| 3941 | bgp_static = rn->info; |
| 3942 | |
| 3943 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3944 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3945 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3946 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3947 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3948 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3949 | if (rmap) |
| 3950 | { |
| 3951 | if (bgp_static->rmap.name) |
| 3952 | free (bgp_static->rmap.name); |
| 3953 | bgp_static->rmap.name = strdup (rmap); |
| 3954 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3955 | } |
| 3956 | else |
| 3957 | { |
| 3958 | if (bgp_static->rmap.name) |
| 3959 | free (bgp_static->rmap.name); |
| 3960 | bgp_static->rmap.name = NULL; |
| 3961 | bgp_static->rmap.map = NULL; |
| 3962 | bgp_static->valid = 0; |
| 3963 | } |
| 3964 | bgp_unlock_node (rn); |
| 3965 | } |
| 3966 | else |
| 3967 | { |
| 3968 | /* New configuration. */ |
| 3969 | bgp_static = bgp_static_new (); |
| 3970 | bgp_static->backdoor = backdoor; |
| 3971 | bgp_static->valid = 0; |
| 3972 | bgp_static->igpmetric = 0; |
| 3973 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3974 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3975 | if (rmap) |
| 3976 | { |
| 3977 | if (bgp_static->rmap.name) |
| 3978 | free (bgp_static->rmap.name); |
| 3979 | bgp_static->rmap.name = strdup (rmap); |
| 3980 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3981 | } |
| 3982 | rn->info = bgp_static; |
| 3983 | } |
| 3984 | |
| 3985 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3986 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3987 | { |
| 3988 | bgp_static->valid = 1; |
| 3989 | |
| 3990 | if (need_update) |
| 3991 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3992 | |
| 3993 | if (! bgp_static->backdoor) |
| 3994 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3995 | } |
| 3996 | |
| 3997 | return CMD_SUCCESS; |
| 3998 | } |
| 3999 | |
| 4000 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4001 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4002 | 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] | 4003 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4004 | { |
| 4005 | int ret; |
| 4006 | struct prefix p; |
| 4007 | struct bgp_static *bgp_static; |
| 4008 | struct bgp_node *rn; |
| 4009 | |
| 4010 | /* Convert IP prefix string to struct prefix. */ |
| 4011 | ret = str2prefix (ip_str, &p); |
| 4012 | if (! ret) |
| 4013 | { |
| 4014 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4015 | return CMD_WARNING; |
| 4016 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4017 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 4018 | { |
| 4019 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 4020 | VTY_NEWLINE); |
| 4021 | return CMD_WARNING; |
| 4022 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4023 | |
| 4024 | apply_mask (&p); |
| 4025 | |
| 4026 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 4027 | if (! rn) |
| 4028 | { |
| 4029 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 4030 | VTY_NEWLINE); |
| 4031 | return CMD_WARNING; |
| 4032 | } |
| 4033 | |
| 4034 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4035 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4036 | /* Update BGP RIB. */ |
| 4037 | if (! bgp_static->backdoor) |
| 4038 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 4039 | |
| 4040 | /* Clear configuration. */ |
| 4041 | bgp_static_free (bgp_static); |
| 4042 | rn->info = NULL; |
| 4043 | bgp_unlock_node (rn); |
| 4044 | bgp_unlock_node (rn); |
| 4045 | |
| 4046 | return CMD_SUCCESS; |
| 4047 | } |
| 4048 | |
| 4049 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 4050 | instance. */ |
| 4051 | void |
| 4052 | bgp_static_delete (struct bgp *bgp) |
| 4053 | { |
| 4054 | afi_t afi; |
| 4055 | safi_t safi; |
| 4056 | struct bgp_node *rn; |
| 4057 | struct bgp_node *rm; |
| 4058 | struct bgp_table *table; |
| 4059 | struct bgp_static *bgp_static; |
| 4060 | |
| 4061 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 4062 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 4063 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 4064 | if (rn->info != NULL) |
| 4065 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4066 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4067 | { |
| 4068 | table = rn->info; |
| 4069 | |
| 4070 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 4071 | { |
| 4072 | bgp_static = rn->info; |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4073 | bgp_static_withdraw_safi (bgp, &rm->p, |
| 4074 | AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4075 | (struct prefix_rd *)&rn->p, |
| 4076 | bgp_static->tag); |
| 4077 | bgp_static_free (bgp_static); |
| 4078 | rn->info = NULL; |
| 4079 | bgp_unlock_node (rn); |
| 4080 | } |
| 4081 | } |
| 4082 | else |
| 4083 | { |
| 4084 | bgp_static = rn->info; |
| 4085 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 4086 | bgp_static_free (bgp_static); |
| 4087 | rn->info = NULL; |
| 4088 | bgp_unlock_node (rn); |
| 4089 | } |
| 4090 | } |
| 4091 | } |
| 4092 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4093 | /* |
| 4094 | * gpz 110624 |
| 4095 | * Currently this is used to set static routes for VPN and ENCAP. |
| 4096 | * I think it can probably be factored with bgp_static_set. |
| 4097 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4098 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4099 | bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, |
| 4100 | const char *rd_str, const char *tag_str, |
| 4101 | const char *rmap_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4102 | { |
| 4103 | int ret; |
| 4104 | struct prefix p; |
| 4105 | struct prefix_rd prd; |
| 4106 | struct bgp *bgp; |
| 4107 | struct bgp_node *prn; |
| 4108 | struct bgp_node *rn; |
| 4109 | struct bgp_table *table; |
| 4110 | struct bgp_static *bgp_static; |
| 4111 | u_char tag[3]; |
| 4112 | |
| 4113 | bgp = vty->index; |
| 4114 | |
| 4115 | ret = str2prefix (ip_str, &p); |
| 4116 | if (! ret) |
| 4117 | { |
| 4118 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4119 | return CMD_WARNING; |
| 4120 | } |
| 4121 | apply_mask (&p); |
| 4122 | |
| 4123 | ret = str2prefix_rd (rd_str, &prd); |
| 4124 | if (! ret) |
| 4125 | { |
| 4126 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4127 | return CMD_WARNING; |
| 4128 | } |
| 4129 | |
| 4130 | ret = str2tag (tag_str, tag); |
| 4131 | if (! ret) |
| 4132 | { |
| 4133 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4134 | return CMD_WARNING; |
| 4135 | } |
| 4136 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4137 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4138 | (struct prefix *)&prd); |
| 4139 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4140 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4141 | else |
| 4142 | bgp_unlock_node (prn); |
| 4143 | table = prn->info; |
| 4144 | |
| 4145 | rn = bgp_node_get (table, &p); |
| 4146 | |
| 4147 | if (rn->info) |
| 4148 | { |
| 4149 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 4150 | bgp_unlock_node (rn); |
| 4151 | } |
| 4152 | else |
| 4153 | { |
| 4154 | /* New configuration. */ |
| 4155 | bgp_static = bgp_static_new (); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4156 | bgp_static->backdoor = 0; |
| 4157 | bgp_static->valid = 0; |
| 4158 | bgp_static->igpmetric = 0; |
| 4159 | bgp_static->igpnexthop.s_addr = 0; |
| 4160 | memcpy(bgp_static->tag, tag, 3); |
| 4161 | bgp_static->prd = prd; |
| 4162 | |
| 4163 | if (rmap_str) |
| 4164 | { |
| 4165 | if (bgp_static->rmap.name) |
| 4166 | free (bgp_static->rmap.name); |
| 4167 | bgp_static->rmap.name = strdup (rmap_str); |
| 4168 | bgp_static->rmap.map = route_map_lookup_by_name (rmap_str); |
| 4169 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4170 | rn->info = bgp_static; |
| 4171 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4172 | bgp_static->valid = 1; |
| 4173 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4174 | } |
| 4175 | |
| 4176 | return CMD_SUCCESS; |
| 4177 | } |
| 4178 | |
| 4179 | /* Configure static BGP network. */ |
| 4180 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4181 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
| 4182 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4183 | { |
| 4184 | int ret; |
| 4185 | struct bgp *bgp; |
| 4186 | struct prefix p; |
| 4187 | struct prefix_rd prd; |
| 4188 | struct bgp_node *prn; |
| 4189 | struct bgp_node *rn; |
| 4190 | struct bgp_table *table; |
| 4191 | struct bgp_static *bgp_static; |
| 4192 | u_char tag[3]; |
| 4193 | |
| 4194 | bgp = vty->index; |
| 4195 | |
| 4196 | /* Convert IP prefix string to struct prefix. */ |
| 4197 | ret = str2prefix (ip_str, &p); |
| 4198 | if (! ret) |
| 4199 | { |
| 4200 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4201 | return CMD_WARNING; |
| 4202 | } |
| 4203 | apply_mask (&p); |
| 4204 | |
| 4205 | ret = str2prefix_rd (rd_str, &prd); |
| 4206 | if (! ret) |
| 4207 | { |
| 4208 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4209 | return CMD_WARNING; |
| 4210 | } |
| 4211 | |
| 4212 | ret = str2tag (tag_str, tag); |
| 4213 | if (! ret) |
| 4214 | { |
| 4215 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4216 | return CMD_WARNING; |
| 4217 | } |
| 4218 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4219 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4220 | (struct prefix *)&prd); |
| 4221 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4222 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4223 | else |
| 4224 | bgp_unlock_node (prn); |
| 4225 | table = prn->info; |
| 4226 | |
| 4227 | rn = bgp_node_lookup (table, &p); |
| 4228 | |
| 4229 | if (rn) |
| 4230 | { |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4231 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4232 | |
| 4233 | bgp_static = rn->info; |
| 4234 | bgp_static_free (bgp_static); |
| 4235 | rn->info = NULL; |
| 4236 | bgp_unlock_node (rn); |
| 4237 | bgp_unlock_node (rn); |
| 4238 | } |
| 4239 | else |
| 4240 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4241 | |
| 4242 | return CMD_SUCCESS; |
| 4243 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4244 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4245 | DEFUN (bgp_network, |
| 4246 | bgp_network_cmd, |
| 4247 | "network A.B.C.D/M", |
| 4248 | "Specify a network to announce via BGP\n" |
| 4249 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4250 | { |
| 4251 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4252 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4253 | } |
| 4254 | |
| 4255 | DEFUN (bgp_network_route_map, |
| 4256 | bgp_network_route_map_cmd, |
| 4257 | "network A.B.C.D/M route-map WORD", |
| 4258 | "Specify a network to announce via BGP\n" |
| 4259 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4260 | "Route-map to modify the attributes\n" |
| 4261 | "Name of the route map\n") |
| 4262 | { |
| 4263 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4264 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4265 | } |
| 4266 | |
| 4267 | DEFUN (bgp_network_backdoor, |
| 4268 | bgp_network_backdoor_cmd, |
| 4269 | "network A.B.C.D/M backdoor", |
| 4270 | "Specify a network to announce via BGP\n" |
| 4271 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4272 | "Specify a BGP backdoor route\n") |
| 4273 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4274 | 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] | 4275 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4276 | } |
| 4277 | |
| 4278 | DEFUN (bgp_network_mask, |
| 4279 | bgp_network_mask_cmd, |
| 4280 | "network A.B.C.D mask A.B.C.D", |
| 4281 | "Specify a network to announce via BGP\n" |
| 4282 | "Network number\n" |
| 4283 | "Network mask\n" |
| 4284 | "Network mask\n") |
| 4285 | { |
| 4286 | int ret; |
| 4287 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4288 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4289 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4290 | if (! ret) |
| 4291 | { |
| 4292 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4293 | return CMD_WARNING; |
| 4294 | } |
| 4295 | |
| 4296 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4297 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4298 | } |
| 4299 | |
| 4300 | DEFUN (bgp_network_mask_route_map, |
| 4301 | bgp_network_mask_route_map_cmd, |
| 4302 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4303 | "Specify a network to announce via BGP\n" |
| 4304 | "Network number\n" |
| 4305 | "Network mask\n" |
| 4306 | "Network mask\n" |
| 4307 | "Route-map to modify the attributes\n" |
| 4308 | "Name of the route map\n") |
| 4309 | { |
| 4310 | int ret; |
| 4311 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4312 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4313 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4314 | if (! ret) |
| 4315 | { |
| 4316 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4317 | return CMD_WARNING; |
| 4318 | } |
| 4319 | |
| 4320 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4321 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4322 | } |
| 4323 | |
| 4324 | DEFUN (bgp_network_mask_backdoor, |
| 4325 | bgp_network_mask_backdoor_cmd, |
| 4326 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4327 | "Specify a network to announce via BGP\n" |
| 4328 | "Network number\n" |
| 4329 | "Network mask\n" |
| 4330 | "Network mask\n" |
| 4331 | "Specify a BGP backdoor route\n") |
| 4332 | { |
| 4333 | int ret; |
| 4334 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4335 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4336 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4337 | if (! ret) |
| 4338 | { |
| 4339 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4340 | return CMD_WARNING; |
| 4341 | } |
| 4342 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4343 | 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] | 4344 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4345 | } |
| 4346 | |
| 4347 | DEFUN (bgp_network_mask_natural, |
| 4348 | bgp_network_mask_natural_cmd, |
| 4349 | "network A.B.C.D", |
| 4350 | "Specify a network to announce via BGP\n" |
| 4351 | "Network number\n") |
| 4352 | { |
| 4353 | int ret; |
| 4354 | char prefix_str[BUFSIZ]; |
| 4355 | |
| 4356 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4357 | if (! ret) |
| 4358 | { |
| 4359 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4360 | return CMD_WARNING; |
| 4361 | } |
| 4362 | |
| 4363 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4364 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4365 | } |
| 4366 | |
| 4367 | DEFUN (bgp_network_mask_natural_route_map, |
| 4368 | bgp_network_mask_natural_route_map_cmd, |
| 4369 | "network A.B.C.D route-map WORD", |
| 4370 | "Specify a network to announce via BGP\n" |
| 4371 | "Network number\n" |
| 4372 | "Route-map to modify the attributes\n" |
| 4373 | "Name of the route map\n") |
| 4374 | { |
| 4375 | int ret; |
| 4376 | char prefix_str[BUFSIZ]; |
| 4377 | |
| 4378 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4379 | if (! ret) |
| 4380 | { |
| 4381 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4382 | return CMD_WARNING; |
| 4383 | } |
| 4384 | |
| 4385 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4386 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4387 | } |
| 4388 | |
| 4389 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4390 | bgp_network_mask_natural_backdoor_cmd, |
| 4391 | "network A.B.C.D backdoor", |
| 4392 | "Specify a network to announce via BGP\n" |
| 4393 | "Network number\n" |
| 4394 | "Specify a BGP backdoor route\n") |
| 4395 | { |
| 4396 | int ret; |
| 4397 | char prefix_str[BUFSIZ]; |
| 4398 | |
| 4399 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4400 | if (! ret) |
| 4401 | { |
| 4402 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4403 | return CMD_WARNING; |
| 4404 | } |
| 4405 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4406 | 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] | 4407 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4408 | } |
| 4409 | |
| 4410 | DEFUN (no_bgp_network, |
| 4411 | no_bgp_network_cmd, |
| 4412 | "no network A.B.C.D/M", |
| 4413 | NO_STR |
| 4414 | "Specify a network to announce via BGP\n" |
| 4415 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4416 | { |
| 4417 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4418 | bgp_node_safi (vty)); |
| 4419 | } |
| 4420 | |
| 4421 | ALIAS (no_bgp_network, |
| 4422 | no_bgp_network_route_map_cmd, |
| 4423 | "no network A.B.C.D/M route-map WORD", |
| 4424 | NO_STR |
| 4425 | "Specify a network to announce via BGP\n" |
| 4426 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4427 | "Route-map to modify the attributes\n" |
| 4428 | "Name of the route map\n") |
| 4429 | |
| 4430 | ALIAS (no_bgp_network, |
| 4431 | no_bgp_network_backdoor_cmd, |
| 4432 | "no network A.B.C.D/M backdoor", |
| 4433 | NO_STR |
| 4434 | "Specify a network to announce via BGP\n" |
| 4435 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4436 | "Specify a BGP backdoor route\n") |
| 4437 | |
| 4438 | DEFUN (no_bgp_network_mask, |
| 4439 | no_bgp_network_mask_cmd, |
| 4440 | "no network A.B.C.D mask A.B.C.D", |
| 4441 | NO_STR |
| 4442 | "Specify a network to announce via BGP\n" |
| 4443 | "Network number\n" |
| 4444 | "Network mask\n" |
| 4445 | "Network mask\n") |
| 4446 | { |
| 4447 | int ret; |
| 4448 | char prefix_str[BUFSIZ]; |
| 4449 | |
| 4450 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4451 | if (! ret) |
| 4452 | { |
| 4453 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4454 | return CMD_WARNING; |
| 4455 | } |
| 4456 | |
| 4457 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4458 | bgp_node_safi (vty)); |
| 4459 | } |
| 4460 | |
| 4461 | ALIAS (no_bgp_network_mask, |
| 4462 | no_bgp_network_mask_route_map_cmd, |
| 4463 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4464 | NO_STR |
| 4465 | "Specify a network to announce via BGP\n" |
| 4466 | "Network number\n" |
| 4467 | "Network mask\n" |
| 4468 | "Network mask\n" |
| 4469 | "Route-map to modify the attributes\n" |
| 4470 | "Name of the route map\n") |
| 4471 | |
| 4472 | ALIAS (no_bgp_network_mask, |
| 4473 | no_bgp_network_mask_backdoor_cmd, |
| 4474 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4475 | NO_STR |
| 4476 | "Specify a network to announce via BGP\n" |
| 4477 | "Network number\n" |
| 4478 | "Network mask\n" |
| 4479 | "Network mask\n" |
| 4480 | "Specify a BGP backdoor route\n") |
| 4481 | |
| 4482 | DEFUN (no_bgp_network_mask_natural, |
| 4483 | no_bgp_network_mask_natural_cmd, |
| 4484 | "no network A.B.C.D", |
| 4485 | NO_STR |
| 4486 | "Specify a network to announce via BGP\n" |
| 4487 | "Network number\n") |
| 4488 | { |
| 4489 | int ret; |
| 4490 | char prefix_str[BUFSIZ]; |
| 4491 | |
| 4492 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4493 | if (! ret) |
| 4494 | { |
| 4495 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4496 | return CMD_WARNING; |
| 4497 | } |
| 4498 | |
| 4499 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4500 | bgp_node_safi (vty)); |
| 4501 | } |
| 4502 | |
| 4503 | ALIAS (no_bgp_network_mask_natural, |
| 4504 | no_bgp_network_mask_natural_route_map_cmd, |
| 4505 | "no network A.B.C.D route-map WORD", |
| 4506 | NO_STR |
| 4507 | "Specify a network to announce via BGP\n" |
| 4508 | "Network number\n" |
| 4509 | "Route-map to modify the attributes\n" |
| 4510 | "Name of the route map\n") |
| 4511 | |
| 4512 | ALIAS (no_bgp_network_mask_natural, |
| 4513 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4514 | "no network A.B.C.D backdoor", |
| 4515 | NO_STR |
| 4516 | "Specify a network to announce via BGP\n" |
| 4517 | "Network number\n" |
| 4518 | "Specify a BGP backdoor route\n") |
| 4519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4520 | DEFUN (ipv6_bgp_network, |
| 4521 | ipv6_bgp_network_cmd, |
| 4522 | "network X:X::X:X/M", |
| 4523 | "Specify a network to announce via BGP\n" |
| 4524 | "IPv6 prefix <network>/<length>\n") |
| 4525 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4526 | 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] | 4527 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4528 | } |
| 4529 | |
| 4530 | DEFUN (ipv6_bgp_network_route_map, |
| 4531 | ipv6_bgp_network_route_map_cmd, |
| 4532 | "network X:X::X:X/M route-map WORD", |
| 4533 | "Specify a network to announce via BGP\n" |
| 4534 | "IPv6 prefix <network>/<length>\n" |
| 4535 | "Route-map to modify the attributes\n" |
| 4536 | "Name of the route map\n") |
| 4537 | { |
| 4538 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4539 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4540 | } |
| 4541 | |
| 4542 | DEFUN (no_ipv6_bgp_network, |
| 4543 | no_ipv6_bgp_network_cmd, |
| 4544 | "no network X:X::X:X/M", |
| 4545 | NO_STR |
| 4546 | "Specify a network to announce via BGP\n" |
| 4547 | "IPv6 prefix <network>/<length>\n") |
| 4548 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4549 | 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] | 4550 | } |
| 4551 | |
| 4552 | ALIAS (no_ipv6_bgp_network, |
| 4553 | no_ipv6_bgp_network_route_map_cmd, |
| 4554 | "no network X:X::X:X/M route-map WORD", |
| 4555 | NO_STR |
| 4556 | "Specify a network to announce via BGP\n" |
| 4557 | "IPv6 prefix <network>/<length>\n" |
| 4558 | "Route-map to modify the attributes\n" |
| 4559 | "Name of the route map\n") |
| 4560 | |
| 4561 | ALIAS (ipv6_bgp_network, |
| 4562 | old_ipv6_bgp_network_cmd, |
| 4563 | "ipv6 bgp network X:X::X:X/M", |
| 4564 | IPV6_STR |
| 4565 | BGP_STR |
| 4566 | "Specify a network to announce via BGP\n" |
| 4567 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4568 | |
| 4569 | ALIAS (no_ipv6_bgp_network, |
| 4570 | old_no_ipv6_bgp_network_cmd, |
| 4571 | "no ipv6 bgp network X:X::X:X/M", |
| 4572 | NO_STR |
| 4573 | IPV6_STR |
| 4574 | BGP_STR |
| 4575 | "Specify a network to announce via BGP\n" |
| 4576 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4577 | |
| 4578 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4579 | ALIAS_DEPRECATED (bgp_network, |
| 4580 | bgp_network_ttl_cmd, |
| 4581 | "network A.B.C.D/M pathlimit <0-255>", |
| 4582 | "Specify a network to announce via BGP\n" |
| 4583 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4584 | "AS-Path hopcount limit attribute\n" |
| 4585 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4586 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4587 | bgp_network_backdoor_ttl_cmd, |
| 4588 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4589 | "Specify a network to announce via BGP\n" |
| 4590 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4591 | "Specify a BGP backdoor route\n" |
| 4592 | "AS-Path hopcount limit attribute\n" |
| 4593 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4594 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4595 | bgp_network_mask_ttl_cmd, |
| 4596 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4597 | "Specify a network to announce via BGP\n" |
| 4598 | "Network number\n" |
| 4599 | "Network mask\n" |
| 4600 | "Network mask\n" |
| 4601 | "AS-Path hopcount limit attribute\n" |
| 4602 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4603 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4604 | bgp_network_mask_backdoor_ttl_cmd, |
| 4605 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4606 | "Specify a network to announce via BGP\n" |
| 4607 | "Network number\n" |
| 4608 | "Network mask\n" |
| 4609 | "Network mask\n" |
| 4610 | "Specify a BGP backdoor route\n" |
| 4611 | "AS-Path hopcount limit attribute\n" |
| 4612 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4613 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4614 | bgp_network_mask_natural_ttl_cmd, |
| 4615 | "network A.B.C.D pathlimit <0-255>", |
| 4616 | "Specify a network to announce via BGP\n" |
| 4617 | "Network number\n" |
| 4618 | "AS-Path hopcount limit attribute\n" |
| 4619 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4620 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4621 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4622 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4623 | "Specify a network to announce via BGP\n" |
| 4624 | "Network number\n" |
| 4625 | "Specify a BGP backdoor route\n" |
| 4626 | "AS-Path hopcount limit attribute\n" |
| 4627 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4628 | ALIAS_DEPRECATED (no_bgp_network, |
| 4629 | no_bgp_network_ttl_cmd, |
| 4630 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4631 | NO_STR |
| 4632 | "Specify a network to announce via BGP\n" |
| 4633 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4634 | "AS-Path hopcount limit attribute\n" |
| 4635 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4636 | ALIAS_DEPRECATED (no_bgp_network, |
| 4637 | no_bgp_network_backdoor_ttl_cmd, |
| 4638 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4639 | NO_STR |
| 4640 | "Specify a network to announce via BGP\n" |
| 4641 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4642 | "Specify a BGP backdoor route\n" |
| 4643 | "AS-Path hopcount limit attribute\n" |
| 4644 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4645 | ALIAS_DEPRECATED (no_bgp_network, |
| 4646 | no_bgp_network_mask_ttl_cmd, |
| 4647 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4648 | NO_STR |
| 4649 | "Specify a network to announce via BGP\n" |
| 4650 | "Network number\n" |
| 4651 | "Network mask\n" |
| 4652 | "Network mask\n" |
| 4653 | "AS-Path hopcount limit attribute\n" |
| 4654 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4655 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4656 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4657 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4658 | NO_STR |
| 4659 | "Specify a network to announce via BGP\n" |
| 4660 | "Network number\n" |
| 4661 | "Network mask\n" |
| 4662 | "Network mask\n" |
| 4663 | "Specify a BGP backdoor route\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_mask_natural, |
| 4667 | no_bgp_network_mask_natural_ttl_cmd, |
| 4668 | "no network A.B.C.D pathlimit <0-255>", |
| 4669 | NO_STR |
| 4670 | "Specify a network to announce via BGP\n" |
| 4671 | "Network number\n" |
| 4672 | "AS-Path hopcount limit attribute\n" |
| 4673 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4674 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4675 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4676 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4677 | NO_STR |
| 4678 | "Specify a network to announce via BGP\n" |
| 4679 | "Network number\n" |
| 4680 | "Specify a BGP backdoor route\n" |
| 4681 | "AS-Path hopcount limit attribute\n" |
| 4682 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4683 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4684 | ipv6_bgp_network_ttl_cmd, |
| 4685 | "network X:X::X:X/M pathlimit <0-255>", |
| 4686 | "Specify a network to announce via BGP\n" |
| 4687 | "IPv6 prefix <network>/<length>\n" |
| 4688 | "AS-Path hopcount limit attribute\n" |
| 4689 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4690 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4691 | no_ipv6_bgp_network_ttl_cmd, |
| 4692 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4693 | NO_STR |
| 4694 | "Specify a network to announce via BGP\n" |
| 4695 | "IPv6 prefix <network>/<length>\n" |
| 4696 | "AS-Path hopcount limit attribute\n" |
| 4697 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4698 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4699 | /* Aggreagete address: |
| 4700 | |
| 4701 | advertise-map Set condition to advertise attribute |
| 4702 | as-set Generate AS set path information |
| 4703 | attribute-map Set attributes of aggregate |
| 4704 | route-map Set parameters of aggregate |
| 4705 | summary-only Filter more specific routes from updates |
| 4706 | suppress-map Conditionally filter more specific routes from updates |
| 4707 | <cr> |
| 4708 | */ |
| 4709 | struct bgp_aggregate |
| 4710 | { |
| 4711 | /* Summary-only flag. */ |
| 4712 | u_char summary_only; |
| 4713 | |
| 4714 | /* AS set generation. */ |
| 4715 | u_char as_set; |
| 4716 | |
| 4717 | /* Route-map for aggregated route. */ |
| 4718 | struct route_map *map; |
| 4719 | |
| 4720 | /* Suppress-count. */ |
| 4721 | unsigned long count; |
| 4722 | |
| 4723 | /* SAFI configuration. */ |
| 4724 | safi_t safi; |
| 4725 | }; |
| 4726 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4727 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4728 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4729 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4730 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4731 | } |
| 4732 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4733 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4734 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4735 | { |
| 4736 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4737 | } |
| 4738 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4739 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4740 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4741 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4742 | struct bgp_aggregate *aggregate) |
| 4743 | { |
| 4744 | struct bgp_table *table; |
| 4745 | struct bgp_node *top; |
| 4746 | struct bgp_node *rn; |
| 4747 | u_char origin; |
| 4748 | struct aspath *aspath = NULL; |
| 4749 | struct aspath *asmerge = NULL; |
| 4750 | struct community *community = NULL; |
| 4751 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4752 | struct bgp_info *ri; |
| 4753 | struct bgp_info *new; |
| 4754 | int first = 1; |
| 4755 | unsigned long match = 0; |
| 4756 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4757 | /* ORIGIN attribute: If at least one route among routes that are |
| 4758 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4759 | aggregated route must have the ORIGIN attribute with the value |
| 4760 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4761 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4762 | route must have the origin attribute with the value EGP. In all |
| 4763 | other case the value of the ORIGIN attribute of the aggregated |
| 4764 | route is INTERNAL. */ |
| 4765 | origin = BGP_ORIGIN_IGP; |
| 4766 | |
| 4767 | table = bgp->rib[afi][safi]; |
| 4768 | |
| 4769 | top = bgp_node_get (table, p); |
| 4770 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4771 | if (rn->p.prefixlen > p->prefixlen) |
| 4772 | { |
| 4773 | match = 0; |
| 4774 | |
| 4775 | for (ri = rn->info; ri; ri = ri->next) |
| 4776 | { |
| 4777 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4778 | continue; |
| 4779 | |
| 4780 | if (del && ri == del) |
| 4781 | continue; |
| 4782 | |
| 4783 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4784 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4785 | |
| 4786 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4787 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4788 | || ri->attr->med != med) |
| 4789 | { |
| 4790 | if (aspath) |
| 4791 | aspath_free (aspath); |
| 4792 | if (community) |
| 4793 | community_free (community); |
| 4794 | bgp_unlock_node (rn); |
| 4795 | bgp_unlock_node (top); |
| 4796 | return; |
| 4797 | } |
| 4798 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4799 | |
| 4800 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4801 | { |
| 4802 | if (aggregate->summary_only) |
| 4803 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4804 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4805 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4806 | match++; |
| 4807 | } |
| 4808 | |
| 4809 | aggregate->count++; |
| 4810 | |
| 4811 | if (aggregate->as_set) |
| 4812 | { |
| 4813 | if (origin < ri->attr->origin) |
| 4814 | origin = ri->attr->origin; |
| 4815 | |
| 4816 | if (aspath) |
| 4817 | { |
| 4818 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4819 | aspath_free (aspath); |
| 4820 | aspath = asmerge; |
| 4821 | } |
| 4822 | else |
| 4823 | aspath = aspath_dup (ri->attr->aspath); |
| 4824 | |
| 4825 | if (ri->attr->community) |
| 4826 | { |
| 4827 | if (community) |
| 4828 | { |
| 4829 | commerge = community_merge (community, |
| 4830 | ri->attr->community); |
| 4831 | community = community_uniq_sort (commerge); |
| 4832 | community_free (commerge); |
| 4833 | } |
| 4834 | else |
| 4835 | community = community_dup (ri->attr->community); |
| 4836 | } |
| 4837 | } |
| 4838 | } |
| 4839 | } |
| 4840 | if (match) |
| 4841 | bgp_process (bgp, rn, afi, safi); |
| 4842 | } |
| 4843 | bgp_unlock_node (top); |
| 4844 | |
| 4845 | if (rinew) |
| 4846 | { |
| 4847 | aggregate->count++; |
| 4848 | |
| 4849 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4850 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4851 | |
| 4852 | if (aggregate->as_set) |
| 4853 | { |
| 4854 | if (origin < rinew->attr->origin) |
| 4855 | origin = rinew->attr->origin; |
| 4856 | |
| 4857 | if (aspath) |
| 4858 | { |
| 4859 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4860 | aspath_free (aspath); |
| 4861 | aspath = asmerge; |
| 4862 | } |
| 4863 | else |
| 4864 | aspath = aspath_dup (rinew->attr->aspath); |
| 4865 | |
| 4866 | if (rinew->attr->community) |
| 4867 | { |
| 4868 | if (community) |
| 4869 | { |
| 4870 | commerge = community_merge (community, |
| 4871 | rinew->attr->community); |
| 4872 | community = community_uniq_sort (commerge); |
| 4873 | community_free (commerge); |
| 4874 | } |
| 4875 | else |
| 4876 | community = community_dup (rinew->attr->community); |
| 4877 | } |
| 4878 | } |
| 4879 | } |
| 4880 | |
| 4881 | if (aggregate->count > 0) |
| 4882 | { |
| 4883 | rn = bgp_node_get (table, p); |
| 4884 | new = bgp_info_new (); |
| 4885 | new->type = ZEBRA_ROUTE_BGP; |
| 4886 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4887 | new->peer = bgp->peer_self; |
| 4888 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4889 | 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] | 4890 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4891 | |
| 4892 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4893 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4894 | bgp_process (bgp, rn, afi, safi); |
| 4895 | } |
| 4896 | else |
| 4897 | { |
| 4898 | if (aspath) |
| 4899 | aspath_free (aspath); |
| 4900 | if (community) |
| 4901 | community_free (community); |
| 4902 | } |
| 4903 | } |
| 4904 | |
| 4905 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4906 | struct bgp_aggregate *); |
| 4907 | |
| 4908 | void |
| 4909 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4910 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4911 | { |
| 4912 | struct bgp_node *child; |
| 4913 | struct bgp_node *rn; |
| 4914 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4915 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4916 | |
| 4917 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4918 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4919 | return; |
| 4920 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4921 | table = bgp->aggregate[afi][safi]; |
| 4922 | |
| 4923 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4924 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4925 | return; |
| 4926 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4927 | if (p->prefixlen == 0) |
| 4928 | return; |
| 4929 | |
| 4930 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4931 | return; |
| 4932 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4933 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4934 | |
| 4935 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4936 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4937 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4938 | { |
| 4939 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4940 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4941 | } |
| 4942 | bgp_unlock_node (child); |
| 4943 | } |
| 4944 | |
| 4945 | void |
| 4946 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4947 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4948 | { |
| 4949 | struct bgp_node *child; |
| 4950 | struct bgp_node *rn; |
| 4951 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4952 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4953 | |
| 4954 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4955 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4956 | return; |
| 4957 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4958 | table = bgp->aggregate[afi][safi]; |
| 4959 | |
| 4960 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4961 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4962 | return; |
| 4963 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4964 | if (p->prefixlen == 0) |
| 4965 | return; |
| 4966 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4967 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4968 | |
| 4969 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4970 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4971 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4972 | { |
| 4973 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4974 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4975 | } |
| 4976 | bgp_unlock_node (child); |
| 4977 | } |
| 4978 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4979 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4980 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4981 | struct bgp_aggregate *aggregate) |
| 4982 | { |
| 4983 | struct bgp_table *table; |
| 4984 | struct bgp_node *top; |
| 4985 | struct bgp_node *rn; |
| 4986 | struct bgp_info *new; |
| 4987 | struct bgp_info *ri; |
| 4988 | unsigned long match; |
| 4989 | u_char origin = BGP_ORIGIN_IGP; |
| 4990 | struct aspath *aspath = NULL; |
| 4991 | struct aspath *asmerge = NULL; |
| 4992 | struct community *community = NULL; |
| 4993 | struct community *commerge = NULL; |
| 4994 | |
| 4995 | table = bgp->rib[afi][safi]; |
| 4996 | |
| 4997 | /* Sanity check. */ |
| 4998 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4999 | return; |
| 5000 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5001 | return; |
| 5002 | |
| 5003 | /* If routes exists below this node, generate aggregate routes. */ |
| 5004 | top = bgp_node_get (table, p); |
| 5005 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5006 | if (rn->p.prefixlen > p->prefixlen) |
| 5007 | { |
| 5008 | match = 0; |
| 5009 | |
| 5010 | for (ri = rn->info; ri; ri = ri->next) |
| 5011 | { |
| 5012 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5013 | continue; |
| 5014 | |
| 5015 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5016 | { |
| 5017 | /* summary-only aggregate route suppress aggregated |
| 5018 | route announcement. */ |
| 5019 | if (aggregate->summary_only) |
| 5020 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5021 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5022 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5023 | match++; |
| 5024 | } |
| 5025 | /* as-set aggregate route generate origin, as path, |
| 5026 | community aggregation. */ |
| 5027 | if (aggregate->as_set) |
| 5028 | { |
| 5029 | if (origin < ri->attr->origin) |
| 5030 | origin = ri->attr->origin; |
| 5031 | |
| 5032 | if (aspath) |
| 5033 | { |
| 5034 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 5035 | aspath_free (aspath); |
| 5036 | aspath = asmerge; |
| 5037 | } |
| 5038 | else |
| 5039 | aspath = aspath_dup (ri->attr->aspath); |
| 5040 | |
| 5041 | if (ri->attr->community) |
| 5042 | { |
| 5043 | if (community) |
| 5044 | { |
| 5045 | commerge = community_merge (community, |
| 5046 | ri->attr->community); |
| 5047 | community = community_uniq_sort (commerge); |
| 5048 | community_free (commerge); |
| 5049 | } |
| 5050 | else |
| 5051 | community = community_dup (ri->attr->community); |
| 5052 | } |
| 5053 | } |
| 5054 | aggregate->count++; |
| 5055 | } |
| 5056 | } |
| 5057 | |
| 5058 | /* If this node is suppressed, process the change. */ |
| 5059 | if (match) |
| 5060 | bgp_process (bgp, rn, afi, safi); |
| 5061 | } |
| 5062 | bgp_unlock_node (top); |
| 5063 | |
| 5064 | /* Add aggregate route to BGP table. */ |
| 5065 | if (aggregate->count) |
| 5066 | { |
| 5067 | rn = bgp_node_get (table, p); |
| 5068 | |
| 5069 | new = bgp_info_new (); |
| 5070 | new->type = ZEBRA_ROUTE_BGP; |
| 5071 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 5072 | new->peer = bgp->peer_self; |
| 5073 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5074 | 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] | 5075 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5076 | |
| 5077 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5078 | bgp_unlock_node (rn); |
| 5079 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5080 | /* Process change. */ |
| 5081 | bgp_process (bgp, rn, afi, safi); |
| 5082 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 5083 | else |
| 5084 | { |
| 5085 | if (aspath) |
| 5086 | aspath_free (aspath); |
| 5087 | if (community) |
| 5088 | community_free (community); |
| 5089 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5090 | } |
| 5091 | |
| 5092 | void |
| 5093 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 5094 | safi_t safi, struct bgp_aggregate *aggregate) |
| 5095 | { |
| 5096 | struct bgp_table *table; |
| 5097 | struct bgp_node *top; |
| 5098 | struct bgp_node *rn; |
| 5099 | struct bgp_info *ri; |
| 5100 | unsigned long match; |
| 5101 | |
| 5102 | table = bgp->rib[afi][safi]; |
| 5103 | |
| 5104 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5105 | return; |
| 5106 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5107 | return; |
| 5108 | |
| 5109 | /* If routes exists below this node, generate aggregate routes. */ |
| 5110 | top = bgp_node_get (table, p); |
| 5111 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5112 | if (rn->p.prefixlen > p->prefixlen) |
| 5113 | { |
| 5114 | match = 0; |
| 5115 | |
| 5116 | for (ri = rn->info; ri; ri = ri->next) |
| 5117 | { |
| 5118 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5119 | continue; |
| 5120 | |
| 5121 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5122 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5123 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5124 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5125 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5126 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5127 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5128 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5129 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5130 | match++; |
| 5131 | } |
| 5132 | } |
| 5133 | aggregate->count--; |
| 5134 | } |
| 5135 | } |
| 5136 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5137 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5138 | if (match) |
| 5139 | bgp_process (bgp, rn, afi, safi); |
| 5140 | } |
| 5141 | bgp_unlock_node (top); |
| 5142 | |
| 5143 | /* Delete aggregate route from BGP table. */ |
| 5144 | rn = bgp_node_get (table, p); |
| 5145 | |
| 5146 | for (ri = rn->info; ri; ri = ri->next) |
| 5147 | if (ri->peer == bgp->peer_self |
| 5148 | && ri->type == ZEBRA_ROUTE_BGP |
| 5149 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 5150 | break; |
| 5151 | |
| 5152 | /* Withdraw static BGP route from routing table. */ |
| 5153 | if (ri) |
| 5154 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5155 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5156 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5157 | } |
| 5158 | |
| 5159 | /* Unlock bgp_node_lookup. */ |
| 5160 | bgp_unlock_node (rn); |
| 5161 | } |
| 5162 | |
| 5163 | /* Aggregate route attribute. */ |
| 5164 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 5165 | #define AGGREGATE_AS_SET 1 |
| 5166 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5167 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5168 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 5169 | afi_t afi, safi_t safi) |
| 5170 | { |
| 5171 | int ret; |
| 5172 | struct prefix p; |
| 5173 | struct bgp_node *rn; |
| 5174 | struct bgp *bgp; |
| 5175 | struct bgp_aggregate *aggregate; |
| 5176 | |
| 5177 | /* Convert string to prefix structure. */ |
| 5178 | ret = str2prefix (prefix_str, &p); |
| 5179 | if (!ret) |
| 5180 | { |
| 5181 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5182 | return CMD_WARNING; |
| 5183 | } |
| 5184 | apply_mask (&p); |
| 5185 | |
| 5186 | /* Get BGP structure. */ |
| 5187 | bgp = vty->index; |
| 5188 | |
| 5189 | /* Old configuration check. */ |
| 5190 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 5191 | if (! rn) |
| 5192 | { |
| 5193 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 5194 | VTY_NEWLINE); |
| 5195 | return CMD_WARNING; |
| 5196 | } |
| 5197 | |
| 5198 | aggregate = rn->info; |
| 5199 | if (aggregate->safi & SAFI_UNICAST) |
| 5200 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5201 | if (aggregate->safi & SAFI_MULTICAST) |
| 5202 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5203 | |
| 5204 | /* Unlock aggregate address configuration. */ |
| 5205 | rn->info = NULL; |
| 5206 | bgp_aggregate_free (aggregate); |
| 5207 | bgp_unlock_node (rn); |
| 5208 | bgp_unlock_node (rn); |
| 5209 | |
| 5210 | return CMD_SUCCESS; |
| 5211 | } |
| 5212 | |
| 5213 | static int |
| 5214 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5215 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5216 | u_char summary_only, u_char as_set) |
| 5217 | { |
| 5218 | int ret; |
| 5219 | struct prefix p; |
| 5220 | struct bgp_node *rn; |
| 5221 | struct bgp *bgp; |
| 5222 | struct bgp_aggregate *aggregate; |
| 5223 | |
| 5224 | /* Convert string to prefix structure. */ |
| 5225 | ret = str2prefix (prefix_str, &p); |
| 5226 | if (!ret) |
| 5227 | { |
| 5228 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5229 | return CMD_WARNING; |
| 5230 | } |
| 5231 | apply_mask (&p); |
| 5232 | |
| 5233 | /* Get BGP structure. */ |
| 5234 | bgp = vty->index; |
| 5235 | |
| 5236 | /* Old configuration check. */ |
| 5237 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5238 | |
| 5239 | if (rn->info) |
| 5240 | { |
| 5241 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5242 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5243 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5244 | if (ret) |
| 5245 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5246 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5247 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5248 | return CMD_WARNING; |
| 5249 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5250 | } |
| 5251 | |
| 5252 | /* Make aggregate address structure. */ |
| 5253 | aggregate = bgp_aggregate_new (); |
| 5254 | aggregate->summary_only = summary_only; |
| 5255 | aggregate->as_set = as_set; |
| 5256 | aggregate->safi = safi; |
| 5257 | rn->info = aggregate; |
| 5258 | |
| 5259 | /* Aggregate address insert into BGP routing table. */ |
| 5260 | if (safi & SAFI_UNICAST) |
| 5261 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5262 | if (safi & SAFI_MULTICAST) |
| 5263 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5264 | |
| 5265 | return CMD_SUCCESS; |
| 5266 | } |
| 5267 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5268 | DEFUN (aggregate_address, |
| 5269 | aggregate_address_cmd, |
| 5270 | "aggregate-address A.B.C.D/M", |
| 5271 | "Configure BGP aggregate entries\n" |
| 5272 | "Aggregate prefix\n") |
| 5273 | { |
| 5274 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5275 | } |
| 5276 | |
| 5277 | DEFUN (aggregate_address_mask, |
| 5278 | aggregate_address_mask_cmd, |
| 5279 | "aggregate-address A.B.C.D A.B.C.D", |
| 5280 | "Configure BGP aggregate entries\n" |
| 5281 | "Aggregate address\n" |
| 5282 | "Aggregate mask\n") |
| 5283 | { |
| 5284 | int ret; |
| 5285 | char prefix_str[BUFSIZ]; |
| 5286 | |
| 5287 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5288 | |
| 5289 | if (! ret) |
| 5290 | { |
| 5291 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5292 | return CMD_WARNING; |
| 5293 | } |
| 5294 | |
| 5295 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5296 | 0, 0); |
| 5297 | } |
| 5298 | |
| 5299 | DEFUN (aggregate_address_summary_only, |
| 5300 | aggregate_address_summary_only_cmd, |
| 5301 | "aggregate-address A.B.C.D/M summary-only", |
| 5302 | "Configure BGP aggregate entries\n" |
| 5303 | "Aggregate prefix\n" |
| 5304 | "Filter more specific routes from updates\n") |
| 5305 | { |
| 5306 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5307 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5308 | } |
| 5309 | |
| 5310 | DEFUN (aggregate_address_mask_summary_only, |
| 5311 | aggregate_address_mask_summary_only_cmd, |
| 5312 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5313 | "Configure BGP aggregate entries\n" |
| 5314 | "Aggregate address\n" |
| 5315 | "Aggregate mask\n" |
| 5316 | "Filter more specific routes from updates\n") |
| 5317 | { |
| 5318 | int ret; |
| 5319 | char prefix_str[BUFSIZ]; |
| 5320 | |
| 5321 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5322 | |
| 5323 | if (! ret) |
| 5324 | { |
| 5325 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5326 | return CMD_WARNING; |
| 5327 | } |
| 5328 | |
| 5329 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5330 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5331 | } |
| 5332 | |
| 5333 | DEFUN (aggregate_address_as_set, |
| 5334 | aggregate_address_as_set_cmd, |
| 5335 | "aggregate-address A.B.C.D/M as-set", |
| 5336 | "Configure BGP aggregate entries\n" |
| 5337 | "Aggregate prefix\n" |
| 5338 | "Generate AS set path information\n") |
| 5339 | { |
| 5340 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5341 | 0, AGGREGATE_AS_SET); |
| 5342 | } |
| 5343 | |
| 5344 | DEFUN (aggregate_address_mask_as_set, |
| 5345 | aggregate_address_mask_as_set_cmd, |
| 5346 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5347 | "Configure BGP aggregate entries\n" |
| 5348 | "Aggregate address\n" |
| 5349 | "Aggregate mask\n" |
| 5350 | "Generate AS set path information\n") |
| 5351 | { |
| 5352 | int ret; |
| 5353 | char prefix_str[BUFSIZ]; |
| 5354 | |
| 5355 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5356 | |
| 5357 | if (! ret) |
| 5358 | { |
| 5359 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5360 | return CMD_WARNING; |
| 5361 | } |
| 5362 | |
| 5363 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5364 | 0, AGGREGATE_AS_SET); |
| 5365 | } |
| 5366 | |
| 5367 | |
| 5368 | DEFUN (aggregate_address_as_set_summary, |
| 5369 | aggregate_address_as_set_summary_cmd, |
| 5370 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5371 | "Configure BGP aggregate entries\n" |
| 5372 | "Aggregate prefix\n" |
| 5373 | "Generate AS set path information\n" |
| 5374 | "Filter more specific routes from updates\n") |
| 5375 | { |
| 5376 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5377 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5378 | } |
| 5379 | |
| 5380 | ALIAS (aggregate_address_as_set_summary, |
| 5381 | aggregate_address_summary_as_set_cmd, |
| 5382 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5383 | "Configure BGP aggregate entries\n" |
| 5384 | "Aggregate prefix\n" |
| 5385 | "Filter more specific routes from updates\n" |
| 5386 | "Generate AS set path information\n") |
| 5387 | |
| 5388 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5389 | aggregate_address_mask_as_set_summary_cmd, |
| 5390 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5391 | "Configure BGP aggregate entries\n" |
| 5392 | "Aggregate address\n" |
| 5393 | "Aggregate mask\n" |
| 5394 | "Generate AS set path information\n" |
| 5395 | "Filter more specific routes from updates\n") |
| 5396 | { |
| 5397 | int ret; |
| 5398 | char prefix_str[BUFSIZ]; |
| 5399 | |
| 5400 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5401 | |
| 5402 | if (! ret) |
| 5403 | { |
| 5404 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5405 | return CMD_WARNING; |
| 5406 | } |
| 5407 | |
| 5408 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5409 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5410 | } |
| 5411 | |
| 5412 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5413 | aggregate_address_mask_summary_as_set_cmd, |
| 5414 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5415 | "Configure BGP aggregate entries\n" |
| 5416 | "Aggregate address\n" |
| 5417 | "Aggregate mask\n" |
| 5418 | "Filter more specific routes from updates\n" |
| 5419 | "Generate AS set path information\n") |
| 5420 | |
| 5421 | DEFUN (no_aggregate_address, |
| 5422 | no_aggregate_address_cmd, |
| 5423 | "no aggregate-address A.B.C.D/M", |
| 5424 | NO_STR |
| 5425 | "Configure BGP aggregate entries\n" |
| 5426 | "Aggregate prefix\n") |
| 5427 | { |
| 5428 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5429 | } |
| 5430 | |
| 5431 | ALIAS (no_aggregate_address, |
| 5432 | no_aggregate_address_summary_only_cmd, |
| 5433 | "no aggregate-address A.B.C.D/M summary-only", |
| 5434 | NO_STR |
| 5435 | "Configure BGP aggregate entries\n" |
| 5436 | "Aggregate prefix\n" |
| 5437 | "Filter more specific routes from updates\n") |
| 5438 | |
| 5439 | ALIAS (no_aggregate_address, |
| 5440 | no_aggregate_address_as_set_cmd, |
| 5441 | "no aggregate-address A.B.C.D/M as-set", |
| 5442 | NO_STR |
| 5443 | "Configure BGP aggregate entries\n" |
| 5444 | "Aggregate prefix\n" |
| 5445 | "Generate AS set path information\n") |
| 5446 | |
| 5447 | ALIAS (no_aggregate_address, |
| 5448 | no_aggregate_address_as_set_summary_cmd, |
| 5449 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5450 | NO_STR |
| 5451 | "Configure BGP aggregate entries\n" |
| 5452 | "Aggregate prefix\n" |
| 5453 | "Generate AS set path information\n" |
| 5454 | "Filter more specific routes from updates\n") |
| 5455 | |
| 5456 | ALIAS (no_aggregate_address, |
| 5457 | no_aggregate_address_summary_as_set_cmd, |
| 5458 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5459 | NO_STR |
| 5460 | "Configure BGP aggregate entries\n" |
| 5461 | "Aggregate prefix\n" |
| 5462 | "Filter more specific routes from updates\n" |
| 5463 | "Generate AS set path information\n") |
| 5464 | |
| 5465 | DEFUN (no_aggregate_address_mask, |
| 5466 | no_aggregate_address_mask_cmd, |
| 5467 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5468 | NO_STR |
| 5469 | "Configure BGP aggregate entries\n" |
| 5470 | "Aggregate address\n" |
| 5471 | "Aggregate mask\n") |
| 5472 | { |
| 5473 | int ret; |
| 5474 | char prefix_str[BUFSIZ]; |
| 5475 | |
| 5476 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5477 | |
| 5478 | if (! ret) |
| 5479 | { |
| 5480 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5481 | return CMD_WARNING; |
| 5482 | } |
| 5483 | |
| 5484 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5485 | } |
| 5486 | |
| 5487 | ALIAS (no_aggregate_address_mask, |
| 5488 | no_aggregate_address_mask_summary_only_cmd, |
| 5489 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5490 | NO_STR |
| 5491 | "Configure BGP aggregate entries\n" |
| 5492 | "Aggregate address\n" |
| 5493 | "Aggregate mask\n" |
| 5494 | "Filter more specific routes from updates\n") |
| 5495 | |
| 5496 | ALIAS (no_aggregate_address_mask, |
| 5497 | no_aggregate_address_mask_as_set_cmd, |
| 5498 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5499 | NO_STR |
| 5500 | "Configure BGP aggregate entries\n" |
| 5501 | "Aggregate address\n" |
| 5502 | "Aggregate mask\n" |
| 5503 | "Generate AS set path information\n") |
| 5504 | |
| 5505 | ALIAS (no_aggregate_address_mask, |
| 5506 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5507 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5508 | NO_STR |
| 5509 | "Configure BGP aggregate entries\n" |
| 5510 | "Aggregate address\n" |
| 5511 | "Aggregate mask\n" |
| 5512 | "Generate AS set path information\n" |
| 5513 | "Filter more specific routes from updates\n") |
| 5514 | |
| 5515 | ALIAS (no_aggregate_address_mask, |
| 5516 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5517 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5518 | NO_STR |
| 5519 | "Configure BGP aggregate entries\n" |
| 5520 | "Aggregate address\n" |
| 5521 | "Aggregate mask\n" |
| 5522 | "Filter more specific routes from updates\n" |
| 5523 | "Generate AS set path information\n") |
| 5524 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5525 | DEFUN (ipv6_aggregate_address, |
| 5526 | ipv6_aggregate_address_cmd, |
| 5527 | "aggregate-address X:X::X:X/M", |
| 5528 | "Configure BGP aggregate entries\n" |
| 5529 | "Aggregate prefix\n") |
| 5530 | { |
| 5531 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5532 | } |
| 5533 | |
| 5534 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5535 | ipv6_aggregate_address_summary_only_cmd, |
| 5536 | "aggregate-address X:X::X:X/M summary-only", |
| 5537 | "Configure BGP aggregate entries\n" |
| 5538 | "Aggregate prefix\n" |
| 5539 | "Filter more specific routes from updates\n") |
| 5540 | { |
| 5541 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5542 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5543 | } |
| 5544 | |
| 5545 | DEFUN (no_ipv6_aggregate_address, |
| 5546 | no_ipv6_aggregate_address_cmd, |
| 5547 | "no aggregate-address X:X::X:X/M", |
| 5548 | NO_STR |
| 5549 | "Configure BGP aggregate entries\n" |
| 5550 | "Aggregate prefix\n") |
| 5551 | { |
| 5552 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5553 | } |
| 5554 | |
| 5555 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5556 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5557 | "no aggregate-address X:X::X:X/M summary-only", |
| 5558 | NO_STR |
| 5559 | "Configure BGP aggregate entries\n" |
| 5560 | "Aggregate prefix\n" |
| 5561 | "Filter more specific routes from updates\n") |
| 5562 | { |
| 5563 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5564 | } |
| 5565 | |
| 5566 | ALIAS (ipv6_aggregate_address, |
| 5567 | old_ipv6_aggregate_address_cmd, |
| 5568 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5569 | IPV6_STR |
| 5570 | BGP_STR |
| 5571 | "Configure BGP aggregate entries\n" |
| 5572 | "Aggregate prefix\n") |
| 5573 | |
| 5574 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5575 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5576 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5577 | IPV6_STR |
| 5578 | BGP_STR |
| 5579 | "Configure BGP aggregate entries\n" |
| 5580 | "Aggregate prefix\n" |
| 5581 | "Filter more specific routes from updates\n") |
| 5582 | |
| 5583 | ALIAS (no_ipv6_aggregate_address, |
| 5584 | old_no_ipv6_aggregate_address_cmd, |
| 5585 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5586 | NO_STR |
| 5587 | IPV6_STR |
| 5588 | BGP_STR |
| 5589 | "Configure BGP aggregate entries\n" |
| 5590 | "Aggregate prefix\n") |
| 5591 | |
| 5592 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5593 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5594 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5595 | NO_STR |
| 5596 | IPV6_STR |
| 5597 | BGP_STR |
| 5598 | "Configure BGP aggregate entries\n" |
| 5599 | "Aggregate prefix\n" |
| 5600 | "Filter more specific routes from updates\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5601 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5602 | /* Redistribute route treatment. */ |
| 5603 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5604 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5605 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5606 | u_int32_t metric, u_char type) |
| 5607 | { |
| 5608 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5609 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5610 | struct bgp_info *new; |
| 5611 | struct bgp_info *bi; |
| 5612 | struct bgp_info info; |
| 5613 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5614 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5615 | struct attr *new_attr; |
| 5616 | afi_t afi; |
| 5617 | int ret; |
| 5618 | |
| 5619 | /* Make default attribute. */ |
| 5620 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5621 | if (nexthop) |
| 5622 | attr.nexthop = *nexthop; |
| 5623 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5624 | if (nexthop6) |
| 5625 | { |
| 5626 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5627 | extra->mp_nexthop_global = *nexthop6; |
| 5628 | extra->mp_nexthop_len = 16; |
| 5629 | } |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5630 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5631 | attr.med = metric; |
| 5632 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5633 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5634 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5635 | { |
| 5636 | afi = family2afi (p->family); |
| 5637 | |
| 5638 | if (bgp->redist[afi][type]) |
| 5639 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5640 | struct attr attr_new; |
| 5641 | struct attr_extra extra_new; |
| 5642 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5643 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5644 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5645 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5646 | |
| 5647 | if (bgp->redist_metric_flag[afi][type]) |
| 5648 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5649 | |
| 5650 | /* Apply route-map. */ |
Daniel Walton | 1994dc8 | 2015-09-17 10:15:59 -0400 | [diff] [blame] | 5651 | if (bgp->rmap[afi][type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5652 | { |
| 5653 | info.peer = bgp->peer_self; |
| 5654 | info.attr = &attr_new; |
| 5655 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5656 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5657 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5658 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5659 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5660 | |
| 5661 | bgp->peer_self->rmap_type = 0; |
| 5662 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5663 | if (ret == RMAP_DENYMATCH) |
| 5664 | { |
| 5665 | /* Free uninterned attribute. */ |
| 5666 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5667 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5668 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5669 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5670 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5671 | bgp_redistribute_delete (p, type); |
| 5672 | return; |
| 5673 | } |
| 5674 | } |
| 5675 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5676 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5677 | afi, SAFI_UNICAST, p, NULL); |
| 5678 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5679 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5680 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5681 | for (bi = bn->info; bi; bi = bi->next) |
| 5682 | if (bi->peer == bgp->peer_self |
| 5683 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5684 | break; |
| 5685 | |
| 5686 | if (bi) |
| 5687 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5688 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5689 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5690 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5691 | bgp_attr_unintern (&new_attr); |
| 5692 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5693 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5694 | bgp_unlock_node (bn); |
| 5695 | return; |
| 5696 | } |
| 5697 | else |
| 5698 | { |
| 5699 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5700 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5701 | |
| 5702 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5703 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5704 | bgp_info_restore(bn, bi); |
| 5705 | else |
| 5706 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5707 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5708 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5709 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5710 | |
| 5711 | /* Process change. */ |
| 5712 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5713 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5714 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5715 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5716 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5717 | return; |
| 5718 | } |
| 5719 | } |
| 5720 | |
| 5721 | new = bgp_info_new (); |
| 5722 | new->type = type; |
| 5723 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5724 | new->peer = bgp->peer_self; |
| 5725 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5726 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5727 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5728 | |
| 5729 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5730 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5731 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5732 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5733 | } |
| 5734 | } |
| 5735 | |
| 5736 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5737 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5738 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5739 | } |
| 5740 | |
| 5741 | void |
| 5742 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5743 | { |
| 5744 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5745 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5746 | afi_t afi; |
| 5747 | struct bgp_node *rn; |
| 5748 | struct bgp_info *ri; |
| 5749 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5750 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5751 | { |
| 5752 | afi = family2afi (p->family); |
| 5753 | |
| 5754 | if (bgp->redist[afi][type]) |
| 5755 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5756 | 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] | 5757 | |
| 5758 | for (ri = rn->info; ri; ri = ri->next) |
| 5759 | if (ri->peer == bgp->peer_self |
| 5760 | && ri->type == type) |
| 5761 | break; |
| 5762 | |
| 5763 | if (ri) |
| 5764 | { |
| 5765 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5766 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5767 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5768 | } |
| 5769 | bgp_unlock_node (rn); |
| 5770 | } |
| 5771 | } |
| 5772 | } |
| 5773 | |
| 5774 | /* Withdraw specified route type's route. */ |
| 5775 | void |
| 5776 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5777 | { |
| 5778 | struct bgp_node *rn; |
| 5779 | struct bgp_info *ri; |
| 5780 | struct bgp_table *table; |
| 5781 | |
| 5782 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5783 | |
| 5784 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5785 | { |
| 5786 | for (ri = rn->info; ri; ri = ri->next) |
| 5787 | if (ri->peer == bgp->peer_self |
| 5788 | && ri->type == type) |
| 5789 | break; |
| 5790 | |
| 5791 | if (ri) |
| 5792 | { |
| 5793 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5794 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5795 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5796 | } |
| 5797 | } |
| 5798 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5799 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5800 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5801 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5802 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5803 | { |
| 5804 | int len; |
| 5805 | u_int32_t destination; |
| 5806 | char buf[BUFSIZ]; |
| 5807 | |
| 5808 | if (p->family == AF_INET) |
| 5809 | { |
| 5810 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5811 | destination = ntohl (p->u.prefix4.s_addr); |
| 5812 | |
| 5813 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5814 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5815 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5816 | || p->u.prefix4.s_addr == 0) |
| 5817 | { |
| 5818 | /* When mask is natural, mask is not displayed. */ |
| 5819 | } |
| 5820 | else |
| 5821 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5822 | } |
| 5823 | else |
| 5824 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5825 | p->prefixlen); |
| 5826 | |
| 5827 | len = 17 - len; |
| 5828 | if (len < 1) |
| 5829 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5830 | else |
| 5831 | vty_out (vty, "%*s", len, " "); |
| 5832 | } |
| 5833 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5834 | enum bgp_display_type |
| 5835 | { |
| 5836 | normal_list, |
| 5837 | }; |
| 5838 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5839 | /* Print the short form route status for a bgp_info */ |
| 5840 | static void |
| 5841 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5842 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5843 | /* Route status display. */ |
| 5844 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5845 | vty_out (vty, "R"); |
| 5846 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5847 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5848 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5849 | vty_out (vty, "s"); |
| 5850 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5851 | vty_out (vty, "*"); |
| 5852 | else |
| 5853 | vty_out (vty, " "); |
| 5854 | |
| 5855 | /* Selected */ |
| 5856 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5857 | vty_out (vty, "h"); |
| 5858 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5859 | vty_out (vty, "d"); |
| 5860 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5861 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5862 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5863 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5864 | else |
| 5865 | vty_out (vty, " "); |
| 5866 | |
| 5867 | /* Internal route. */ |
| 5868 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5869 | vty_out (vty, "i"); |
| 5870 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5871 | vty_out (vty, " "); |
| 5872 | } |
| 5873 | |
| 5874 | /* called from terminal list command */ |
| 5875 | void |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5876 | route_vty_out( |
| 5877 | struct vty *vty, |
| 5878 | struct prefix *p, |
| 5879 | struct bgp_info *binfo, |
| 5880 | int display, |
| 5881 | safi_t safi) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5882 | { |
| 5883 | struct attr *attr; |
| 5884 | |
| 5885 | /* short status lead text */ |
| 5886 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5887 | |
| 5888 | /* print prefix and mask */ |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5889 | if (!display) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5890 | route_vty_out_route (p, vty); |
| 5891 | else |
| 5892 | vty_out (vty, "%*s", 17, " "); |
| 5893 | |
| 5894 | /* Print attribute */ |
| 5895 | attr = binfo->attr; |
| 5896 | if (attr) |
| 5897 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5898 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5899 | /* |
| 5900 | * NEXTHOP start |
| 5901 | */ |
| 5902 | |
| 5903 | /* |
| 5904 | * For ENCAP routes, nexthop address family is not |
| 5905 | * neccessarily the same as the prefix address family. |
| 5906 | * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field |
| 5907 | */ |
| 5908 | if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) { |
| 5909 | if (attr->extra) { |
| 5910 | char buf[BUFSIZ]; |
| 5911 | int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); |
| 5912 | |
| 5913 | switch (af) { |
| 5914 | case AF_INET: |
| 5915 | vty_out (vty, "%s", inet_ntop(af, |
| 5916 | &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); |
| 5917 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5918 | case AF_INET6: |
| 5919 | vty_out (vty, "%s", inet_ntop(af, |
| 5920 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); |
| 5921 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5922 | default: |
| 5923 | vty_out(vty, "?"); |
| 5924 | } |
| 5925 | } else { |
| 5926 | vty_out(vty, "?"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5927 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5928 | } else { |
| 5929 | |
| 5930 | if (p->family == AF_INET) |
| 5931 | { |
| 5932 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5933 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5934 | else if (p->family == AF_INET6) |
| 5935 | { |
| 5936 | int len; |
| 5937 | char buf[BUFSIZ]; |
| 5938 | |
| 5939 | len = vty_out (vty, "%s", |
| 5940 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5941 | buf, BUFSIZ)); |
| 5942 | len = 16 - len; |
| 5943 | if (len < 1) |
| 5944 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5945 | else |
| 5946 | vty_out (vty, "%*s", len, " "); |
| 5947 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5948 | else |
| 5949 | { |
| 5950 | vty_out(vty, "?"); |
| 5951 | } |
| 5952 | } |
| 5953 | |
| 5954 | /* |
| 5955 | * NEXTHOP end |
| 5956 | */ |
| 5957 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5958 | |
| 5959 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5960 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5962 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5963 | |
| 5964 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5965 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5966 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5967 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5968 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5969 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5970 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5971 | /* Print aspath */ |
| 5972 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5973 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5974 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5975 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5976 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5977 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5978 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5979 | } |
| 5980 | |
| 5981 | /* called from terminal list command */ |
| 5982 | void |
| 5983 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5984 | struct attr *attr, safi_t safi) |
| 5985 | { |
| 5986 | /* Route status display. */ |
| 5987 | vty_out (vty, "*"); |
| 5988 | vty_out (vty, ">"); |
| 5989 | vty_out (vty, " "); |
| 5990 | |
| 5991 | /* print prefix and mask */ |
| 5992 | route_vty_out_route (p, vty); |
| 5993 | |
| 5994 | /* Print attribute */ |
| 5995 | if (attr) |
| 5996 | { |
| 5997 | if (p->family == AF_INET) |
| 5998 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5999 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6000 | vty_out (vty, "%-16s", |
| 6001 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6002 | else |
| 6003 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6004 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6005 | else if (p->family == AF_INET6) |
| 6006 | { |
| 6007 | int len; |
| 6008 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6009 | |
| 6010 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6011 | |
| 6012 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6013 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6014 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6015 | len = 16 - len; |
| 6016 | if (len < 1) |
| 6017 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 6018 | else |
| 6019 | vty_out (vty, "%*s", len, " "); |
| 6020 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6021 | |
| 6022 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6023 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6024 | else |
| 6025 | vty_out (vty, " "); |
| 6026 | |
| 6027 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6028 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6029 | else |
| 6030 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6031 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6032 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6033 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6034 | /* Print aspath */ |
| 6035 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6036 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6038 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6039 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6040 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6041 | |
| 6042 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6043 | } |
| 6044 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6045 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6046 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 6047 | struct bgp_info *binfo, int display, safi_t safi) |
| 6048 | { |
| 6049 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6050 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6051 | |
| 6052 | if (!binfo->extra) |
| 6053 | return; |
| 6054 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6055 | /* short status lead text */ |
| 6056 | route_vty_short_status_out (vty, binfo); |
| 6057 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6058 | /* print prefix and mask */ |
| 6059 | if (! display) |
| 6060 | route_vty_out_route (p, vty); |
| 6061 | else |
| 6062 | vty_out (vty, "%*s", 17, " "); |
| 6063 | |
| 6064 | /* Print attribute */ |
| 6065 | attr = binfo->attr; |
| 6066 | if (attr) |
| 6067 | { |
| 6068 | if (p->family == AF_INET) |
| 6069 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6070 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6071 | vty_out (vty, "%-16s", |
| 6072 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6073 | else |
| 6074 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6075 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6076 | else if (p->family == AF_INET6) |
| 6077 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6078 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6079 | char buf[BUFSIZ]; |
| 6080 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6081 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6082 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6083 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6084 | buf, BUFSIZ)); |
| 6085 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6086 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6087 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6088 | buf, BUFSIZ), |
| 6089 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 6090 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6091 | |
| 6092 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6093 | } |
| 6094 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6095 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6096 | |
| 6097 | vty_out (vty, "notag/%d", label); |
| 6098 | |
| 6099 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6100 | } |
| 6101 | |
| 6102 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6103 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6104 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 6105 | struct bgp_info *binfo, int display, safi_t safi) |
| 6106 | { |
| 6107 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6108 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6109 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6110 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6111 | /* short status lead text */ |
| 6112 | route_vty_short_status_out (vty, binfo); |
| 6113 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6114 | /* print prefix and mask */ |
| 6115 | if (! display) |
| 6116 | route_vty_out_route (p, vty); |
| 6117 | else |
| 6118 | vty_out (vty, "%*s", 17, " "); |
| 6119 | |
| 6120 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6121 | len = 17 - len; |
| 6122 | if (len < 1) |
| 6123 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 6124 | else |
| 6125 | vty_out (vty, "%*s", len, " "); |
| 6126 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6127 | 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] | 6128 | |
| 6129 | /* Print attribute */ |
| 6130 | attr = binfo->attr; |
| 6131 | if (attr) |
| 6132 | { |
| 6133 | /* Print aspath */ |
| 6134 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6135 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6136 | |
| 6137 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6138 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6139 | } |
| 6140 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6141 | } |
| 6142 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6143 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6144 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6145 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 6146 | struct bgp_info *binfo, int display, safi_t safi) |
| 6147 | { |
| 6148 | struct attr *attr; |
| 6149 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6150 | char timebuf[BGP_UPTIME_LEN]; |
| 6151 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6152 | |
| 6153 | if (!binfo->extra) |
| 6154 | return; |
| 6155 | |
| 6156 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6157 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6158 | /* short status lead text */ |
| 6159 | route_vty_short_status_out (vty, binfo); |
| 6160 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6161 | /* print prefix and mask */ |
| 6162 | if (! display) |
| 6163 | route_vty_out_route (p, vty); |
| 6164 | else |
| 6165 | vty_out (vty, "%*s", 17, " "); |
| 6166 | |
| 6167 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6168 | len = 16 - len; |
| 6169 | if (len < 1) |
| 6170 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 6171 | else |
| 6172 | vty_out (vty, "%*s", len, " "); |
| 6173 | |
| 6174 | len = vty_out (vty, "%d", bdi->flap); |
| 6175 | len = 5 - len; |
| 6176 | if (len < 1) |
| 6177 | vty_out (vty, " "); |
| 6178 | else |
| 6179 | vty_out (vty, "%*s ", len, " "); |
| 6180 | |
| 6181 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 6182 | timebuf, BGP_UPTIME_LEN)); |
| 6183 | |
| 6184 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 6185 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6186 | 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] | 6187 | else |
| 6188 | vty_out (vty, "%*s ", 8, " "); |
| 6189 | |
| 6190 | /* Print attribute */ |
| 6191 | attr = binfo->attr; |
| 6192 | if (attr) |
| 6193 | { |
| 6194 | /* Print aspath */ |
| 6195 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6196 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6197 | |
| 6198 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6199 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6200 | } |
| 6201 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6202 | } |
| 6203 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6204 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6205 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 6206 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 6207 | { |
| 6208 | char buf[INET6_ADDRSTRLEN]; |
| 6209 | char buf1[BUFSIZ]; |
| 6210 | struct attr *attr; |
| 6211 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6212 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6213 | time_t tbuf; |
| 6214 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6215 | |
| 6216 | attr = binfo->attr; |
| 6217 | |
| 6218 | if (attr) |
| 6219 | { |
| 6220 | /* Line1 display AS-path, Aggregator */ |
| 6221 | if (attr->aspath) |
| 6222 | { |
| 6223 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6224 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6225 | vty_out (vty, "Local"); |
| 6226 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6227 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6228 | } |
| 6229 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6230 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6231 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6232 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6233 | vty_out (vty, ", (stale)"); |
| 6234 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6235 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6236 | attr->extra->aggregator_as, |
| 6237 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6238 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6239 | vty_out (vty, ", (Received from a RR-client)"); |
| 6240 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6241 | vty_out (vty, ", (Received from a RS-client)"); |
| 6242 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6243 | vty_out (vty, ", (history entry)"); |
| 6244 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6245 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6246 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6247 | |
| 6248 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6249 | if (p->family == AF_INET) |
| 6250 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6251 | vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6252 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6253 | inet_ntoa (attr->nexthop)); |
| 6254 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6255 | else |
| 6256 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6257 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6258 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6259 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6260 | buf, INET6_ADDRSTRLEN)); |
| 6261 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6262 | |
| 6263 | if (binfo->peer == bgp->peer_self) |
| 6264 | { |
| 6265 | vty_out (vty, " from %s ", |
| 6266 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6267 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6268 | } |
| 6269 | else |
| 6270 | { |
| 6271 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6272 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6273 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6274 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6275 | if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) { |
| 6276 | buf[0] = '?'; |
| 6277 | buf[1] = 0; |
| 6278 | } |
| 6279 | vty_out (vty, " from %s", buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6280 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6281 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6282 | else |
| 6283 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6284 | } |
| 6285 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6286 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6287 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6288 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6289 | { |
| 6290 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6291 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6292 | buf, INET6_ADDRSTRLEN), |
| 6293 | VTY_NEWLINE); |
| 6294 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6295 | |
| 6296 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6297 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6298 | |
| 6299 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6300 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6301 | |
| 6302 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6303 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6304 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6305 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6306 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6307 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6308 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6309 | |
| 6310 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6311 | vty_out (vty, ", valid"); |
| 6312 | |
| 6313 | if (binfo->peer != bgp->peer_self) |
| 6314 | { |
| 6315 | if (binfo->peer->as == binfo->peer->local_as) |
| 6316 | vty_out (vty, ", internal"); |
| 6317 | else |
| 6318 | vty_out (vty, ", %s", |
| 6319 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6320 | } |
| 6321 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6322 | vty_out (vty, ", aggregated, local"); |
| 6323 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6324 | vty_out (vty, ", sourced"); |
| 6325 | else |
| 6326 | vty_out (vty, ", sourced, local"); |
| 6327 | |
| 6328 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6329 | vty_out (vty, ", atomic-aggregate"); |
| 6330 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6331 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6332 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6333 | bgp_info_mpath_count (binfo))) |
| 6334 | vty_out (vty, ", multipath"); |
| 6335 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6336 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6337 | vty_out (vty, ", best"); |
| 6338 | |
| 6339 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6340 | |
| 6341 | /* Line 4 display Community */ |
| 6342 | if (attr->community) |
| 6343 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6344 | VTY_NEWLINE); |
| 6345 | |
| 6346 | /* Line 5 display Extended-community */ |
| 6347 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6348 | vty_out (vty, " Extended Community: %s%s", |
| 6349 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6350 | |
| 6351 | /* Line 6 display Originator, Cluster-id */ |
| 6352 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6353 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6354 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6355 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6356 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6357 | vty_out (vty, " Originator: %s", |
| 6358 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6359 | |
| 6360 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6361 | { |
| 6362 | int i; |
| 6363 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6364 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6365 | vty_out (vty, "%s ", |
| 6366 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6367 | } |
| 6368 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6369 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6370 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6371 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6372 | bgp_damp_info_vty (vty, binfo); |
| 6373 | |
| 6374 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6375 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6376 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6377 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6378 | #else |
| 6379 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6380 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6381 | } |
| 6382 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6383 | } |
| 6384 | |
| 6385 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6386 | "h history, * valid, > best, = multipath,%s"\ |
| 6387 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6388 | #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] | 6389 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6390 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6391 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6392 | |
| 6393 | enum bgp_show_type |
| 6394 | { |
| 6395 | bgp_show_type_normal, |
| 6396 | bgp_show_type_regexp, |
| 6397 | bgp_show_type_prefix_list, |
| 6398 | bgp_show_type_filter_list, |
| 6399 | bgp_show_type_route_map, |
| 6400 | bgp_show_type_neighbor, |
| 6401 | bgp_show_type_cidr_only, |
| 6402 | bgp_show_type_prefix_longer, |
| 6403 | bgp_show_type_community_all, |
| 6404 | bgp_show_type_community, |
| 6405 | bgp_show_type_community_exact, |
| 6406 | bgp_show_type_community_list, |
| 6407 | bgp_show_type_community_list_exact, |
| 6408 | bgp_show_type_flap_statistics, |
| 6409 | bgp_show_type_flap_address, |
| 6410 | bgp_show_type_flap_prefix, |
| 6411 | bgp_show_type_flap_cidr_only, |
| 6412 | bgp_show_type_flap_regexp, |
| 6413 | bgp_show_type_flap_filter_list, |
| 6414 | bgp_show_type_flap_prefix_list, |
| 6415 | bgp_show_type_flap_prefix_longer, |
| 6416 | bgp_show_type_flap_route_map, |
| 6417 | bgp_show_type_flap_neighbor, |
| 6418 | bgp_show_type_dampend_paths, |
| 6419 | bgp_show_type_damp_neighbor |
| 6420 | }; |
| 6421 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6422 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6423 | 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] | 6424 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6425 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6426 | struct bgp_info *ri; |
| 6427 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6428 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6429 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6430 | unsigned long output_count; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6431 | unsigned long total_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6432 | |
| 6433 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6434 | output_count = 0; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6435 | total_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6436 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6437 | /* Start processing of routes. */ |
| 6438 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6439 | if (rn->info != NULL) |
| 6440 | { |
| 6441 | display = 0; |
| 6442 | |
| 6443 | for (ri = rn->info; ri; ri = ri->next) |
| 6444 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6445 | total_count++; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6446 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6447 | || type == bgp_show_type_flap_address |
| 6448 | || type == bgp_show_type_flap_prefix |
| 6449 | || type == bgp_show_type_flap_cidr_only |
| 6450 | || type == bgp_show_type_flap_regexp |
| 6451 | || type == bgp_show_type_flap_filter_list |
| 6452 | || type == bgp_show_type_flap_prefix_list |
| 6453 | || type == bgp_show_type_flap_prefix_longer |
| 6454 | || type == bgp_show_type_flap_route_map |
| 6455 | || type == bgp_show_type_flap_neighbor |
| 6456 | || type == bgp_show_type_dampend_paths |
| 6457 | || type == bgp_show_type_damp_neighbor) |
| 6458 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6459 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6460 | continue; |
| 6461 | } |
| 6462 | if (type == bgp_show_type_regexp |
| 6463 | || type == bgp_show_type_flap_regexp) |
| 6464 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6465 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6466 | |
| 6467 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6468 | continue; |
| 6469 | } |
| 6470 | if (type == bgp_show_type_prefix_list |
| 6471 | || type == bgp_show_type_flap_prefix_list) |
| 6472 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6473 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6474 | |
| 6475 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6476 | continue; |
| 6477 | } |
| 6478 | if (type == bgp_show_type_filter_list |
| 6479 | || type == bgp_show_type_flap_filter_list) |
| 6480 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6481 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6482 | |
| 6483 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6484 | continue; |
| 6485 | } |
| 6486 | if (type == bgp_show_type_route_map |
| 6487 | || type == bgp_show_type_flap_route_map) |
| 6488 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6489 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6490 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6491 | struct attr dummy_attr; |
| 6492 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6493 | int ret; |
| 6494 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6495 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6496 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6497 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6498 | binfo.peer = ri->peer; |
| 6499 | binfo.attr = &dummy_attr; |
| 6500 | |
| 6501 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6502 | if (ret == RMAP_DENYMATCH) |
| 6503 | continue; |
| 6504 | } |
| 6505 | if (type == bgp_show_type_neighbor |
| 6506 | || type == bgp_show_type_flap_neighbor |
| 6507 | || type == bgp_show_type_damp_neighbor) |
| 6508 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6509 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6510 | |
| 6511 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6512 | continue; |
| 6513 | } |
| 6514 | if (type == bgp_show_type_cidr_only |
| 6515 | || type == bgp_show_type_flap_cidr_only) |
| 6516 | { |
| 6517 | u_int32_t destination; |
| 6518 | |
| 6519 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6520 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6521 | continue; |
| 6522 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6523 | continue; |
| 6524 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6525 | continue; |
| 6526 | } |
| 6527 | if (type == bgp_show_type_prefix_longer |
| 6528 | || type == bgp_show_type_flap_prefix_longer) |
| 6529 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6530 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6531 | |
| 6532 | if (! prefix_match (p, &rn->p)) |
| 6533 | continue; |
| 6534 | } |
| 6535 | if (type == bgp_show_type_community_all) |
| 6536 | { |
| 6537 | if (! ri->attr->community) |
| 6538 | continue; |
| 6539 | } |
| 6540 | if (type == bgp_show_type_community) |
| 6541 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6542 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6543 | |
| 6544 | if (! ri->attr->community || |
| 6545 | ! community_match (ri->attr->community, com)) |
| 6546 | continue; |
| 6547 | } |
| 6548 | if (type == bgp_show_type_community_exact) |
| 6549 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6550 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6551 | |
| 6552 | if (! ri->attr->community || |
| 6553 | ! community_cmp (ri->attr->community, com)) |
| 6554 | continue; |
| 6555 | } |
| 6556 | if (type == bgp_show_type_community_list) |
| 6557 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6558 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6559 | |
| 6560 | if (! community_list_match (ri->attr->community, list)) |
| 6561 | continue; |
| 6562 | } |
| 6563 | if (type == bgp_show_type_community_list_exact) |
| 6564 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6565 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6566 | |
| 6567 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6568 | continue; |
| 6569 | } |
| 6570 | if (type == bgp_show_type_flap_address |
| 6571 | || type == bgp_show_type_flap_prefix) |
| 6572 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6573 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6574 | |
| 6575 | if (! prefix_match (&rn->p, p)) |
| 6576 | continue; |
| 6577 | |
| 6578 | if (type == bgp_show_type_flap_prefix) |
| 6579 | if (p->prefixlen != rn->p.prefixlen) |
| 6580 | continue; |
| 6581 | } |
| 6582 | if (type == bgp_show_type_dampend_paths |
| 6583 | || type == bgp_show_type_damp_neighbor) |
| 6584 | { |
| 6585 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6586 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6587 | continue; |
| 6588 | } |
| 6589 | |
| 6590 | if (header) |
| 6591 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6592 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6593 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6594 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6595 | if (type == bgp_show_type_dampend_paths |
| 6596 | || type == bgp_show_type_damp_neighbor) |
| 6597 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6598 | else if (type == bgp_show_type_flap_statistics |
| 6599 | || type == bgp_show_type_flap_address |
| 6600 | || type == bgp_show_type_flap_prefix |
| 6601 | || type == bgp_show_type_flap_cidr_only |
| 6602 | || type == bgp_show_type_flap_regexp |
| 6603 | || type == bgp_show_type_flap_filter_list |
| 6604 | || type == bgp_show_type_flap_prefix_list |
| 6605 | || type == bgp_show_type_flap_prefix_longer |
| 6606 | || type == bgp_show_type_flap_route_map |
| 6607 | || type == bgp_show_type_flap_neighbor) |
| 6608 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6609 | else |
| 6610 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6611 | header = 0; |
| 6612 | } |
| 6613 | |
| 6614 | if (type == bgp_show_type_dampend_paths |
| 6615 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6616 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6617 | else if (type == bgp_show_type_flap_statistics |
| 6618 | || type == bgp_show_type_flap_address |
| 6619 | || type == bgp_show_type_flap_prefix |
| 6620 | || type == bgp_show_type_flap_cidr_only |
| 6621 | || type == bgp_show_type_flap_regexp |
| 6622 | || type == bgp_show_type_flap_filter_list |
| 6623 | || type == bgp_show_type_flap_prefix_list |
| 6624 | || type == bgp_show_type_flap_prefix_longer |
| 6625 | || type == bgp_show_type_flap_route_map |
| 6626 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6627 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6628 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6629 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6630 | display++; |
| 6631 | } |
| 6632 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6633 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6634 | } |
| 6635 | |
| 6636 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6637 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6638 | { |
| 6639 | if (type == bgp_show_type_normal) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6640 | 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] | 6641 | } |
| 6642 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6643 | vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", |
| 6644 | VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6645 | |
| 6646 | return CMD_SUCCESS; |
| 6647 | } |
| 6648 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6649 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6650 | 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] | 6651 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6652 | { |
| 6653 | struct bgp_table *table; |
| 6654 | |
| 6655 | if (bgp == NULL) { |
| 6656 | bgp = bgp_get_default (); |
| 6657 | } |
| 6658 | |
| 6659 | if (bgp == NULL) |
| 6660 | { |
| 6661 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6662 | return CMD_WARNING; |
| 6663 | } |
| 6664 | |
| 6665 | |
| 6666 | table = bgp->rib[afi][safi]; |
| 6667 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6668 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6669 | } |
| 6670 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6671 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6672 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6673 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6674 | struct bgp_node *rn, |
| 6675 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6676 | { |
| 6677 | struct bgp_info *ri; |
| 6678 | struct prefix *p; |
| 6679 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6680 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6681 | char buf1[INET6_ADDRSTRLEN]; |
| 6682 | char buf2[INET6_ADDRSTRLEN]; |
| 6683 | int count = 0; |
| 6684 | int best = 0; |
| 6685 | int suppress = 0; |
| 6686 | int no_export = 0; |
| 6687 | int no_advertise = 0; |
| 6688 | int local_as = 0; |
| 6689 | int first = 0; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6690 | int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6691 | |
| 6692 | p = &rn->p; |
| 6693 | 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] | 6694 | (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6695 | printrd ? ":" : "", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6696 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6697 | p->prefixlen, VTY_NEWLINE); |
| 6698 | |
| 6699 | for (ri = rn->info; ri; ri = ri->next) |
| 6700 | { |
| 6701 | count++; |
| 6702 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6703 | { |
| 6704 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6705 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6706 | suppress = 1; |
| 6707 | if (ri->attr->community != NULL) |
| 6708 | { |
| 6709 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6710 | no_advertise = 1; |
| 6711 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6712 | no_export = 1; |
| 6713 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6714 | local_as = 1; |
| 6715 | } |
| 6716 | } |
| 6717 | } |
| 6718 | |
| 6719 | vty_out (vty, "Paths: (%d available", count); |
| 6720 | if (best) |
| 6721 | { |
| 6722 | vty_out (vty, ", best #%d", best); |
| 6723 | if (safi == SAFI_UNICAST) |
| 6724 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6725 | } |
| 6726 | else |
| 6727 | vty_out (vty, ", no best path"); |
| 6728 | if (no_advertise) |
| 6729 | vty_out (vty, ", not advertised to any peer"); |
| 6730 | else if (no_export) |
| 6731 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6732 | else if (local_as) |
| 6733 | vty_out (vty, ", not advertised outside local AS"); |
| 6734 | if (suppress) |
| 6735 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6736 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6737 | |
| 6738 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6739 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6740 | { |
| 6741 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6742 | { |
| 6743 | if (! first) |
| 6744 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6745 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6746 | first = 1; |
| 6747 | } |
| 6748 | } |
| 6749 | if (! first) |
| 6750 | vty_out (vty, " Not advertised to any peer"); |
| 6751 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6752 | } |
| 6753 | |
| 6754 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6755 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6756 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6757 | struct bgp_table *rib, const char *ip_str, |
| 6758 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6759 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6760 | { |
| 6761 | int ret; |
| 6762 | int header; |
| 6763 | int display = 0; |
| 6764 | struct prefix match; |
| 6765 | struct bgp_node *rn; |
| 6766 | struct bgp_node *rm; |
| 6767 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6768 | struct bgp_table *table; |
| 6769 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 6770 | memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6771 | /* Check IP address argument. */ |
| 6772 | ret = str2prefix (ip_str, &match); |
| 6773 | if (! ret) |
| 6774 | { |
| 6775 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6776 | return CMD_WARNING; |
| 6777 | } |
| 6778 | |
| 6779 | match.family = afi2family (afi); |
| 6780 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6781 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6782 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6783 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6784 | { |
| 6785 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6786 | continue; |
| 6787 | |
| 6788 | if ((table = rn->info) != NULL) |
| 6789 | { |
| 6790 | header = 1; |
| 6791 | |
| 6792 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6793 | { |
| 6794 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6795 | { |
| 6796 | bgp_unlock_node (rm); |
| 6797 | continue; |
| 6798 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6799 | |
| 6800 | for (ri = rm->info; ri; ri = ri->next) |
| 6801 | { |
| 6802 | if (header) |
| 6803 | { |
| 6804 | 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] | 6805 | AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6806 | |
| 6807 | header = 0; |
| 6808 | } |
| 6809 | display++; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6810 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6811 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6812 | |
| 6813 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6814 | } |
| 6815 | } |
| 6816 | } |
| 6817 | } |
| 6818 | else |
| 6819 | { |
| 6820 | header = 1; |
| 6821 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6822 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6823 | { |
| 6824 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6825 | { |
| 6826 | for (ri = rn->info; ri; ri = ri->next) |
| 6827 | { |
| 6828 | if (header) |
| 6829 | { |
| 6830 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6831 | header = 0; |
| 6832 | } |
| 6833 | display++; |
| 6834 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6835 | } |
| 6836 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6837 | |
| 6838 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6839 | } |
| 6840 | } |
| 6841 | |
| 6842 | if (! display) |
| 6843 | { |
| 6844 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6845 | return CMD_WARNING; |
| 6846 | } |
| 6847 | |
| 6848 | return CMD_SUCCESS; |
| 6849 | } |
| 6850 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6851 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6852 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6853 | 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] | 6854 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6855 | int prefix_check) |
| 6856 | { |
| 6857 | struct bgp *bgp; |
| 6858 | |
| 6859 | /* BGP structure lookup. */ |
| 6860 | if (view_name) |
| 6861 | { |
| 6862 | bgp = bgp_lookup_by_name (view_name); |
| 6863 | if (bgp == NULL) |
| 6864 | { |
| 6865 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6866 | return CMD_WARNING; |
| 6867 | } |
| 6868 | } |
| 6869 | else |
| 6870 | { |
| 6871 | bgp = bgp_get_default (); |
| 6872 | if (bgp == NULL) |
| 6873 | { |
| 6874 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6875 | return CMD_WARNING; |
| 6876 | } |
| 6877 | } |
| 6878 | |
| 6879 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6880 | afi, safi, prd, prefix_check); |
| 6881 | } |
| 6882 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6883 | /* BGP route print out function. */ |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 6884 | DEFUN (show_ip_bgp, |
| 6885 | show_ip_bgp_cmd, |
| 6886 | "show ip bgp", |
| 6887 | SHOW_STR |
| 6888 | IP_STR |
| 6889 | BGP_STR) |
| 6890 | { |
| 6891 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6892 | } |
| 6893 | |
| 6894 | DEFUN (show_ip_bgp_ipv4, |
| 6895 | show_ip_bgp_ipv4_cmd, |
| 6896 | "show ip bgp ipv4 (unicast|multicast)", |
| 6897 | SHOW_STR |
| 6898 | IP_STR |
| 6899 | BGP_STR |
| 6900 | "Address family\n" |
| 6901 | "Address Family modifier\n" |
| 6902 | "Address Family modifier\n") |
| 6903 | { |
| 6904 | if (strncmp (argv[0], "m", 1) == 0) |
| 6905 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6906 | NULL); |
| 6907 | |
| 6908 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6909 | } |
| 6910 | |
| 6911 | DEFUN (show_ip_bgp_route, |
| 6912 | show_ip_bgp_route_cmd, |
| 6913 | "show ip bgp A.B.C.D", |
| 6914 | SHOW_STR |
| 6915 | IP_STR |
| 6916 | BGP_STR |
| 6917 | "Network in the BGP routing table to display\n") |
| 6918 | { |
| 6919 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6920 | } |
| 6921 | |
| 6922 | DEFUN (show_ip_bgp_ipv4_route, |
| 6923 | show_ip_bgp_ipv4_route_cmd, |
| 6924 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6925 | SHOW_STR |
| 6926 | IP_STR |
| 6927 | BGP_STR |
| 6928 | "Address family\n" |
| 6929 | "Address Family modifier\n" |
| 6930 | "Address Family modifier\n" |
| 6931 | "Network in the BGP routing table to display\n") |
| 6932 | { |
| 6933 | if (strncmp (argv[0], "m", 1) == 0) |
| 6934 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6935 | |
| 6936 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6937 | } |
| 6938 | |
| 6939 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6940 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6941 | "show ip bgp vpnv4 all A.B.C.D", |
| 6942 | SHOW_STR |
| 6943 | IP_STR |
| 6944 | BGP_STR |
| 6945 | "Display VPNv4 NLRI specific information\n" |
| 6946 | "Display information about all VPNv4 NLRIs\n" |
| 6947 | "Network in the BGP routing table to display\n") |
| 6948 | { |
| 6949 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6950 | } |
| 6951 | |
| 6952 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6953 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6954 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6955 | SHOW_STR |
| 6956 | IP_STR |
| 6957 | BGP_STR |
| 6958 | "Display VPNv4 NLRI specific information\n" |
| 6959 | "Display information for a route distinguisher\n" |
| 6960 | "VPN Route Distinguisher\n" |
| 6961 | "Network in the BGP routing table to display\n") |
| 6962 | { |
| 6963 | int ret; |
| 6964 | struct prefix_rd prd; |
| 6965 | |
| 6966 | ret = str2prefix_rd (argv[0], &prd); |
| 6967 | if (! ret) |
| 6968 | { |
| 6969 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6970 | return CMD_WARNING; |
| 6971 | } |
| 6972 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6973 | } |
| 6974 | |
| 6975 | DEFUN (show_ip_bgp_prefix, |
| 6976 | show_ip_bgp_prefix_cmd, |
| 6977 | "show ip bgp A.B.C.D/M", |
| 6978 | SHOW_STR |
| 6979 | IP_STR |
| 6980 | BGP_STR |
| 6981 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6982 | { |
| 6983 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6984 | } |
| 6985 | |
| 6986 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6987 | show_ip_bgp_ipv4_prefix_cmd, |
| 6988 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6989 | SHOW_STR |
| 6990 | IP_STR |
| 6991 | BGP_STR |
| 6992 | "Address family\n" |
| 6993 | "Address Family modifier\n" |
| 6994 | "Address Family modifier\n" |
| 6995 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6996 | { |
| 6997 | if (strncmp (argv[0], "m", 1) == 0) |
| 6998 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6999 | |
| 7000 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 7001 | } |
| 7002 | |
| 7003 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 7004 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 7005 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 7006 | SHOW_STR |
| 7007 | IP_STR |
| 7008 | BGP_STR |
| 7009 | "Display VPNv4 NLRI specific information\n" |
| 7010 | "Display information about all VPNv4 NLRIs\n" |
| 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_MPLS_VPN, NULL, 1); |
| 7014 | } |
| 7015 | |
| 7016 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 7017 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 7018 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7019 | SHOW_STR |
| 7020 | IP_STR |
| 7021 | BGP_STR |
| 7022 | "Display VPNv4 NLRI specific information\n" |
| 7023 | "Display information for a route distinguisher\n" |
| 7024 | "VPN Route Distinguisher\n" |
| 7025 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7026 | { |
| 7027 | int ret; |
| 7028 | struct prefix_rd prd; |
| 7029 | |
| 7030 | ret = str2prefix_rd (argv[0], &prd); |
| 7031 | if (! ret) |
| 7032 | { |
| 7033 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7034 | return CMD_WARNING; |
| 7035 | } |
| 7036 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 7037 | } |
| 7038 | |
| 7039 | DEFUN (show_ip_bgp_view, |
| 7040 | show_ip_bgp_view_cmd, |
| 7041 | "show ip bgp view WORD", |
| 7042 | SHOW_STR |
| 7043 | IP_STR |
| 7044 | BGP_STR |
| 7045 | "BGP view\n" |
| 7046 | "View name\n") |
| 7047 | { |
| 7048 | struct bgp *bgp; |
| 7049 | |
| 7050 | /* BGP structure lookup. */ |
| 7051 | bgp = bgp_lookup_by_name (argv[0]); |
| 7052 | if (bgp == NULL) |
| 7053 | { |
| 7054 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7055 | return CMD_WARNING; |
| 7056 | } |
| 7057 | |
| 7058 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7059 | } |
| 7060 | |
| 7061 | DEFUN (show_ip_bgp_view_route, |
| 7062 | show_ip_bgp_view_route_cmd, |
| 7063 | "show ip bgp view WORD A.B.C.D", |
| 7064 | SHOW_STR |
| 7065 | IP_STR |
| 7066 | BGP_STR |
| 7067 | "BGP view\n" |
| 7068 | "View name\n" |
| 7069 | "Network in the BGP routing table to display\n") |
| 7070 | { |
| 7071 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 7072 | } |
| 7073 | |
| 7074 | DEFUN (show_ip_bgp_view_prefix, |
| 7075 | show_ip_bgp_view_prefix_cmd, |
| 7076 | "show ip bgp view WORD A.B.C.D/M", |
| 7077 | SHOW_STR |
| 7078 | IP_STR |
| 7079 | BGP_STR |
| 7080 | "BGP view\n" |
| 7081 | "View name\n" |
| 7082 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7083 | { |
| 7084 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 7085 | } |
| 7086 | |
| 7087 | DEFUN (show_bgp, |
| 7088 | show_bgp_cmd, |
| 7089 | "show bgp", |
| 7090 | SHOW_STR |
| 7091 | BGP_STR) |
| 7092 | { |
| 7093 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7094 | NULL); |
| 7095 | } |
| 7096 | |
| 7097 | ALIAS (show_bgp, |
| 7098 | show_bgp_ipv6_cmd, |
| 7099 | "show bgp ipv6", |
| 7100 | SHOW_STR |
| 7101 | BGP_STR |
| 7102 | "Address family\n") |
| 7103 | |
| 7104 | /* old command */ |
| 7105 | DEFUN (show_ipv6_bgp, |
| 7106 | show_ipv6_bgp_cmd, |
| 7107 | "show ipv6 bgp", |
| 7108 | SHOW_STR |
| 7109 | IP_STR |
| 7110 | BGP_STR) |
| 7111 | { |
| 7112 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7113 | NULL); |
| 7114 | } |
| 7115 | |
| 7116 | DEFUN (show_bgp_route, |
| 7117 | show_bgp_route_cmd, |
| 7118 | "show bgp X:X::X:X", |
| 7119 | SHOW_STR |
| 7120 | BGP_STR |
| 7121 | "Network in the BGP routing table to display\n") |
| 7122 | { |
| 7123 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7124 | } |
| 7125 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7126 | DEFUN (show_bgp_ipv4_safi, |
| 7127 | show_bgp_ipv4_safi_cmd, |
| 7128 | "show bgp ipv4 (unicast|multicast)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7129 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7130 | BGP_STR |
| 7131 | "Address family\n" |
| 7132 | "Address Family modifier\n" |
| 7133 | "Address Family modifier\n") |
| 7134 | { |
| 7135 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7136 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 7137 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7138 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7139 | 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] | 7140 | } |
| 7141 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7142 | DEFUN (show_bgp_ipv4_safi_route, |
| 7143 | show_bgp_ipv4_safi_route_cmd, |
| 7144 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7145 | SHOW_STR |
| 7146 | BGP_STR |
| 7147 | "Address family\n" |
| 7148 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7149 | "Address Family modifier\n" |
| 7150 | "Network in the BGP routing table to display\n") |
| 7151 | { |
| 7152 | if (strncmp (argv[0], "m", 1) == 0) |
| 7153 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 7154 | |
| 7155 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 7156 | } |
| 7157 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7158 | DEFUN (show_bgp_ipv4_vpn_route, |
| 7159 | show_bgp_ipv4_vpn_route_cmd, |
| 7160 | "show bgp ipv4 vpn A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7161 | SHOW_STR |
| 7162 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7163 | "Address Family\n" |
| 7164 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7165 | "Network in the BGP routing table to display\n") |
| 7166 | { |
| 7167 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 7168 | } |
| 7169 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7170 | DEFUN (show_bgp_ipv6_vpn_route, |
| 7171 | show_bgp_ipv6_vpn_route_cmd, |
| 7172 | "show bgp ipv6 vpn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7173 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7174 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7175 | "Address Family\n" |
| 7176 | "Display VPN NLRI specific information\n" |
| 7177 | "Network in the BGP routing table to display\n") |
| 7178 | { |
| 7179 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0); |
| 7180 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7181 | |
| 7182 | DEFUN (show_bgp_ipv4_vpn_rd_route, |
| 7183 | show_bgp_ipv4_vpn_rd_route_cmd, |
| 7184 | "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7185 | SHOW_STR |
| 7186 | BGP_STR |
| 7187 | IP_STR |
| 7188 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7189 | "Display information for a route distinguisher\n" |
| 7190 | "VPN Route Distinguisher\n" |
| 7191 | "Network in the BGP routing table to display\n") |
| 7192 | { |
| 7193 | int ret; |
| 7194 | struct prefix_rd prd; |
| 7195 | |
| 7196 | ret = str2prefix_rd (argv[0], &prd); |
| 7197 | if (! ret) |
| 7198 | { |
| 7199 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7200 | return CMD_WARNING; |
| 7201 | } |
| 7202 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 7203 | } |
| 7204 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7205 | DEFUN (show_bgp_ipv6_vpn_rd_route, |
| 7206 | show_bgp_ipv6_vpn_rd_route_cmd, |
| 7207 | "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] | 7208 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7209 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7210 | "Address Family\n" |
| 7211 | "Display VPN NLRI specific information\n" |
| 7212 | "Display information for a route distinguisher\n" |
| 7213 | "VPN Route Distinguisher\n" |
| 7214 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7215 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7216 | int ret; |
| 7217 | struct prefix_rd prd; |
| 7218 | |
| 7219 | ret = str2prefix_rd (argv[0], &prd); |
| 7220 | if (! ret) |
| 7221 | { |
| 7222 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7223 | return CMD_WARNING; |
| 7224 | } |
| 7225 | 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] | 7226 | } |
| 7227 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7228 | DEFUN (show_bgp_ipv4_encap_route, |
| 7229 | show_bgp_ipv4_encap_route_cmd, |
| 7230 | "show bgp ipv4 encap A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7231 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7232 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7233 | IP_STR |
| 7234 | "Display ENCAP NLRI specific information\n" |
| 7235 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7236 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7237 | 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] | 7238 | } |
| 7239 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7240 | DEFUN (show_bgp_ipv6_encap_route, |
| 7241 | show_bgp_ipv6_encap_route_cmd, |
| 7242 | "show bgp ipv6 encap X:X::X:X", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7243 | SHOW_STR |
| 7244 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7245 | IP6_STR |
| 7246 | "Display ENCAP NLRI specific information\n" |
| 7247 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7248 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7249 | 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] | 7250 | } |
| 7251 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7252 | DEFUN (show_bgp_ipv4_safi_rd_route, |
| 7253 | show_bgp_ipv4_safi_rd_route_cmd, |
| 7254 | "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] | 7255 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7256 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7257 | "Address Family\n" |
| 7258 | "Address Family Modifier\n" |
| 7259 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7260 | "Display information for a route distinguisher\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7261 | "ENCAP Route Distinguisher\n" |
| 7262 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7263 | { |
| 7264 | int ret; |
| 7265 | struct prefix_rd prd; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7266 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7267 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7268 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7269 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7270 | return CMD_WARNING; |
| 7271 | } |
| 7272 | ret = str2prefix_rd (argv[1], &prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7273 | if (! ret) |
| 7274 | { |
| 7275 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7276 | return CMD_WARNING; |
| 7277 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7278 | return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7279 | } |
| 7280 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7281 | DEFUN (show_bgp_ipv6_safi_rd_route, |
| 7282 | show_bgp_ipv6_safi_rd_route_cmd, |
| 7283 | "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] | 7284 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7285 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7286 | "Address Family\n" |
| 7287 | "Address Family Modifier\n" |
| 7288 | "Address Family Modifier\n" |
| 7289 | "Display information for a route distinguisher\n" |
| 7290 | "ENCAP Route Distinguisher\n" |
| 7291 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7292 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7293 | int ret; |
| 7294 | struct prefix_rd prd; |
| 7295 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7296 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7297 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7298 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7299 | return CMD_WARNING; |
| 7300 | } |
| 7301 | ret = str2prefix_rd (argv[1], &prd); |
| 7302 | if (! ret) |
| 7303 | { |
| 7304 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7305 | return CMD_WARNING; |
| 7306 | } |
| 7307 | 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] | 7308 | } |
| 7309 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7310 | DEFUN (show_bgp_ipv4_prefix, |
| 7311 | show_bgp_ipv4_prefix_cmd, |
| 7312 | "show bgp ipv4 A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7313 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7314 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7315 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7316 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7317 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7318 | 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] | 7319 | } |
| 7320 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7321 | DEFUN (show_bgp_ipv4_safi_prefix, |
| 7322 | show_bgp_ipv4_safi_prefix_cmd, |
| 7323 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7324 | SHOW_STR |
| 7325 | BGP_STR |
| 7326 | "Address family\n" |
| 7327 | "Address Family modifier\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7328 | "Address Family modifier\n" |
| 7329 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7330 | { |
| 7331 | if (strncmp (argv[0], "m", 1) == 0) |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7332 | 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] | 7333 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7334 | 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] | 7335 | } |
| 7336 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7337 | DEFUN (show_bgp_ipv4_vpn_prefix, |
| 7338 | show_bgp_ipv4_vpn_prefix_cmd, |
| 7339 | "show bgp ipv4 vpn A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7340 | SHOW_STR |
| 7341 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7342 | IP_STR |
| 7343 | "Display VPN NLRI specific information\n" |
| 7344 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7345 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7346 | 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] | 7347 | } |
| 7348 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7349 | DEFUN (show_bgp_ipv6_vpn_prefix, |
| 7350 | show_bgp_ipv6_vpn_prefix_cmd, |
| 7351 | "show bgp ipv6 vpn X:X::X:X/M", |
| 7352 | SHOW_STR |
| 7353 | BGP_STR |
| 7354 | "Address Family\n" |
| 7355 | "Display VPN NLRI specific information\n" |
| 7356 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7357 | { |
| 7358 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1); |
| 7359 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7360 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7361 | DEFUN (show_bgp_ipv4_encap_prefix, |
| 7362 | show_bgp_ipv4_encap_prefix_cmd, |
| 7363 | "show bgp ipv4 encap A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7364 | SHOW_STR |
| 7365 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7366 | IP_STR |
| 7367 | "Display ENCAP NLRI specific information\n" |
| 7368 | "Display information about ENCAP NLRIs\n" |
| 7369 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7370 | { |
| 7371 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1); |
| 7372 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7373 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7374 | DEFUN (show_bgp_ipv6_encap_prefix, |
| 7375 | show_bgp_ipv6_encap_prefix_cmd, |
| 7376 | "show bgp ipv6 encap X:X::X:X/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7377 | SHOW_STR |
| 7378 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7379 | IP_STR |
| 7380 | "Display ENCAP NLRI specific information\n" |
| 7381 | "Display information about ENCAP NLRIs\n" |
| 7382 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7383 | { |
| 7384 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1); |
| 7385 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7386 | |
| 7387 | DEFUN (show_bgp_ipv4_safi_rd_prefix, |
| 7388 | show_bgp_ipv4_safi_rd_prefix_cmd, |
| 7389 | "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7390 | SHOW_STR |
| 7391 | BGP_STR |
| 7392 | "Address Family\n" |
| 7393 | "Address Family Modifier\n" |
| 7394 | "Address Family Modifier\n" |
| 7395 | "Display information for a route distinguisher\n" |
| 7396 | "ENCAP Route Distinguisher\n" |
| 7397 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7398 | { |
| 7399 | int ret; |
| 7400 | struct prefix_rd prd; |
| 7401 | safi_t safi; |
| 7402 | |
| 7403 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7404 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7405 | return CMD_WARNING; |
| 7406 | } |
| 7407 | |
| 7408 | ret = str2prefix_rd (argv[1], &prd); |
| 7409 | if (! ret) |
| 7410 | { |
| 7411 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7412 | return CMD_WARNING; |
| 7413 | } |
| 7414 | return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1); |
| 7415 | } |
| 7416 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7417 | DEFUN (show_bgp_ipv6_safi_rd_prefix, |
| 7418 | show_bgp_ipv6_safi_rd_prefix_cmd, |
| 7419 | "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/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_IP6, safi, &prd, 1); |
| 7445 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7446 | |
| 7447 | DEFUN (show_bgp_afi_safi_view, |
| 7448 | show_bgp_afi_safi_view_cmd, |
| 7449 | "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)", |
| 7450 | SHOW_STR |
| 7451 | BGP_STR |
| 7452 | "BGP view\n" |
| 7453 | "BGP view name\n" |
| 7454 | "Address Family\n" |
| 7455 | "Address Family\n" |
| 7456 | "Address Family Modifier\n" |
| 7457 | "Address Family Modifier\n" |
| 7458 | "Address Family Modifier\n" |
| 7459 | "Address Family Modifier\n" |
| 7460 | ) |
| 7461 | { |
| 7462 | struct bgp *bgp; |
| 7463 | safi_t safi; |
| 7464 | afi_t afi; |
| 7465 | |
| 7466 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7467 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7468 | return CMD_WARNING; |
| 7469 | } |
| 7470 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7471 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7472 | return CMD_WARNING; |
| 7473 | } |
| 7474 | |
| 7475 | /* BGP structure lookup. */ |
| 7476 | bgp = bgp_lookup_by_name (argv[0]); |
| 7477 | if (bgp == NULL) |
| 7478 | { |
| 7479 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7480 | return CMD_WARNING; |
| 7481 | } |
| 7482 | |
| 7483 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL); |
| 7484 | } |
| 7485 | |
| 7486 | DEFUN (show_bgp_view_afi_safi_route, |
| 7487 | show_bgp_view_afi_safi_route_cmd, |
| 7488 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D", |
| 7489 | SHOW_STR |
| 7490 | BGP_STR |
| 7491 | "BGP view\n" |
| 7492 | "View name\n" |
| 7493 | "Address Family\n" |
| 7494 | "Address Family\n" |
| 7495 | "Address Family Modifier\n" |
| 7496 | "Address Family Modifier\n" |
| 7497 | "Address Family Modifier\n" |
| 7498 | "Address Family Modifier\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7499 | "Network in the BGP routing table to display\n") |
| 7500 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7501 | safi_t safi; |
| 7502 | afi_t afi; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7503 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7504 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7505 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7506 | return CMD_WARNING; |
| 7507 | } |
| 7508 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7509 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7510 | return CMD_WARNING; |
| 7511 | } |
| 7512 | return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0); |
| 7513 | } |
| 7514 | |
| 7515 | DEFUN (show_bgp_view_afi_safi_prefix, |
| 7516 | show_bgp_view_afi_safi_prefix_cmd, |
| 7517 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M", |
| 7518 | SHOW_STR |
| 7519 | BGP_STR |
| 7520 | "BGP view\n" |
| 7521 | "View name\n" |
| 7522 | "Address Family\n" |
| 7523 | "Address Family\n" |
| 7524 | "Address Family Modifier\n" |
| 7525 | "Address Family Modifier\n" |
| 7526 | "Address Family Modifier\n" |
| 7527 | "Address Family Modifier\n" |
| 7528 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7529 | { |
| 7530 | safi_t safi; |
| 7531 | afi_t afi; |
| 7532 | |
| 7533 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7534 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7535 | return CMD_WARNING; |
| 7536 | } |
| 7537 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7538 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7539 | return CMD_WARNING; |
| 7540 | } |
| 7541 | return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1); |
| 7542 | } |
| 7543 | |
| 7544 | /* new001 */ |
| 7545 | DEFUN (show_bgp_afi, |
| 7546 | show_bgp_afi_cmd, |
| 7547 | "show bgp (ipv4|ipv6)", |
| 7548 | SHOW_STR |
| 7549 | BGP_STR |
| 7550 | "Address family\n" |
| 7551 | "Address family\n") |
| 7552 | { |
| 7553 | afi_t afi; |
| 7554 | |
| 7555 | if (bgp_parse_afi(argv[0], &afi)) { |
| 7556 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7557 | return CMD_WARNING; |
| 7558 | } |
| 7559 | return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal, |
| 7560 | NULL); |
| 7561 | } |
| 7562 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7563 | DEFUN (show_bgp_ipv6_safi, |
| 7564 | show_bgp_ipv6_safi_cmd, |
| 7565 | "show bgp ipv6 (unicast|multicast)", |
| 7566 | SHOW_STR |
| 7567 | BGP_STR |
| 7568 | "Address family\n" |
| 7569 | "Address Family modifier\n" |
| 7570 | "Address Family modifier\n") |
| 7571 | { |
| 7572 | if (strncmp (argv[0], "m", 1) == 0) |
| 7573 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7574 | NULL); |
| 7575 | |
| 7576 | 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] | 7577 | } |
| 7578 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7579 | DEFUN (show_bgp_ipv6_route, |
| 7580 | show_bgp_ipv6_route_cmd, |
| 7581 | "show bgp ipv6 X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7582 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7583 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7584 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7585 | "Network in the BGP routing table to display\n") |
| 7586 | { |
| 7587 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7588 | } |
| 7589 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7590 | DEFUN (show_bgp_ipv6_safi_route, |
| 7591 | show_bgp_ipv6_safi_route_cmd, |
| 7592 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7593 | SHOW_STR |
| 7594 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7595 | "Address family\n" |
| 7596 | "Address Family modifier\n" |
| 7597 | "Address Family modifier\n" |
| 7598 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7599 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7600 | if (strncmp (argv[0], "m", 1) == 0) |
| 7601 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7602 | |
| 7603 | 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] | 7604 | } |
| 7605 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7606 | /* old command */ |
| 7607 | DEFUN (show_ipv6_bgp_route, |
| 7608 | show_ipv6_bgp_route_cmd, |
| 7609 | "show ipv6 bgp X:X::X:X", |
| 7610 | SHOW_STR |
| 7611 | IP_STR |
| 7612 | BGP_STR |
| 7613 | "Network in the BGP routing table to display\n") |
| 7614 | { |
| 7615 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7616 | } |
| 7617 | |
| 7618 | DEFUN (show_bgp_prefix, |
| 7619 | show_bgp_prefix_cmd, |
| 7620 | "show bgp X:X::X:X/M", |
| 7621 | SHOW_STR |
| 7622 | BGP_STR |
| 7623 | "IPv6 prefix <network>/<length>\n") |
| 7624 | { |
| 7625 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7626 | } |
| 7627 | |
| 7628 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7629 | /* new002 */ |
| 7630 | DEFUN (show_bgp_ipv6_prefix, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7631 | show_bgp_ipv6_prefix_cmd, |
| 7632 | "show bgp ipv6 X:X::X:X/M", |
| 7633 | SHOW_STR |
| 7634 | BGP_STR |
| 7635 | "Address family\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7636 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7637 | { |
| 7638 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7639 | } |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7640 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 7641 | show_bgp_ipv6_safi_prefix_cmd, |
| 7642 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 7643 | SHOW_STR |
| 7644 | BGP_STR |
| 7645 | "Address family\n" |
| 7646 | "Address Family modifier\n" |
| 7647 | "Address Family modifier\n" |
| 7648 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7649 | { |
| 7650 | if (strncmp (argv[0], "m", 1) == 0) |
| 7651 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7652 | |
| 7653 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7654 | } |
| 7655 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7656 | /* old command */ |
| 7657 | DEFUN (show_ipv6_bgp_prefix, |
| 7658 | show_ipv6_bgp_prefix_cmd, |
| 7659 | "show ipv6 bgp X:X::X:X/M", |
| 7660 | SHOW_STR |
| 7661 | IP_STR |
| 7662 | BGP_STR |
| 7663 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7664 | { |
| 7665 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7666 | } |
| 7667 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7668 | DEFUN (show_bgp_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7669 | show_bgp_view_cmd, |
| 7670 | "show bgp view WORD", |
| 7671 | SHOW_STR |
| 7672 | BGP_STR |
| 7673 | "BGP view\n" |
| 7674 | "View name\n") |
| 7675 | { |
| 7676 | struct bgp *bgp; |
| 7677 | |
| 7678 | /* BGP structure lookup. */ |
| 7679 | bgp = bgp_lookup_by_name (argv[0]); |
| 7680 | if (bgp == NULL) |
| 7681 | { |
| 7682 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7683 | return CMD_WARNING; |
| 7684 | } |
| 7685 | |
| 7686 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7687 | } |
| 7688 | |
| 7689 | DEFUN (show_bgp_view_ipv6, |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7690 | show_bgp_view_ipv6_cmd, |
| 7691 | "show bgp view WORD ipv6", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7692 | SHOW_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7693 | BGP_STR |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7694 | "BGP view\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7695 | "View name\n" |
| 7696 | "Address family\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7697 | { |
| 7698 | struct bgp *bgp; |
| 7699 | |
| 7700 | /* BGP structure lookup. */ |
| 7701 | bgp = bgp_lookup_by_name (argv[0]); |
| 7702 | if (bgp == NULL) |
| 7703 | { |
| 7704 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7705 | return CMD_WARNING; |
| 7706 | } |
| 7707 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7708 | 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] | 7709 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7710 | |
| 7711 | DEFUN (show_bgp_view_route, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7712 | show_bgp_view_route_cmd, |
| 7713 | "show bgp view WORD X:X::X:X", |
| 7714 | SHOW_STR |
| 7715 | BGP_STR |
| 7716 | "BGP view\n" |
| 7717 | "View name\n" |
| 7718 | "Network in the BGP routing table to display\n") |
| 7719 | { |
| 7720 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7721 | } |
| 7722 | |
| 7723 | DEFUN (show_bgp_view_ipv6_route, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7724 | show_bgp_view_ipv6_route_cmd, |
| 7725 | "show bgp view WORD ipv6 X:X::X:X", |
| 7726 | SHOW_STR |
| 7727 | BGP_STR |
| 7728 | "BGP view\n" |
| 7729 | "View name\n" |
| 7730 | "Address family\n" |
| 7731 | "Network in the BGP routing table to display\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7732 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7733 | 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] | 7734 | } |
| 7735 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7736 | /* old command */ |
| 7737 | DEFUN (show_ipv6_mbgp, |
| 7738 | show_ipv6_mbgp_cmd, |
| 7739 | "show ipv6 mbgp", |
| 7740 | SHOW_STR |
| 7741 | IP_STR |
| 7742 | MBGP_STR) |
| 7743 | { |
| 7744 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7745 | NULL); |
| 7746 | } |
| 7747 | |
| 7748 | /* old command */ |
| 7749 | DEFUN (show_ipv6_mbgp_route, |
| 7750 | show_ipv6_mbgp_route_cmd, |
| 7751 | "show ipv6 mbgp X:X::X:X", |
| 7752 | SHOW_STR |
| 7753 | IP_STR |
| 7754 | MBGP_STR |
| 7755 | "Network in the MBGP routing table to display\n") |
| 7756 | { |
| 7757 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7758 | } |
| 7759 | |
| 7760 | /* old command */ |
| 7761 | DEFUN (show_ipv6_mbgp_prefix, |
| 7762 | show_ipv6_mbgp_prefix_cmd, |
| 7763 | "show ipv6 mbgp X:X::X:X/M", |
| 7764 | SHOW_STR |
| 7765 | IP_STR |
| 7766 | MBGP_STR |
| 7767 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7768 | { |
| 7769 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7770 | } |
| 7771 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7772 | DEFUN (show_bgp_view_prefix, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7773 | show_bgp_view_prefix_cmd, |
| 7774 | "show bgp view WORD X:X::X:X/M", |
| 7775 | SHOW_STR |
| 7776 | BGP_STR |
| 7777 | "BGP view\n" |
| 7778 | "View name\n" |
| 7779 | "IPv6 prefix <network>/<length>\n") |
| 7780 | { |
| 7781 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7782 | } |
| 7783 | |
| 7784 | DEFUN (show_bgp_view_ipv6_prefix, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7785 | show_bgp_view_ipv6_prefix_cmd, |
| 7786 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7787 | SHOW_STR |
| 7788 | BGP_STR |
| 7789 | "BGP view\n" |
| 7790 | "View name\n" |
| 7791 | "Address family\n" |
| 7792 | "IPv6 prefix <network>/<length>\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7793 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7794 | 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] | 7795 | } |
| 7796 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7797 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7798 | 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] | 7799 | safi_t safi, enum bgp_show_type type) |
| 7800 | { |
| 7801 | int i; |
| 7802 | struct buffer *b; |
| 7803 | char *regstr; |
| 7804 | int first; |
| 7805 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7806 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7807 | |
| 7808 | first = 0; |
| 7809 | b = buffer_new (1024); |
| 7810 | for (i = 0; i < argc; i++) |
| 7811 | { |
| 7812 | if (first) |
| 7813 | buffer_putc (b, ' '); |
| 7814 | else |
| 7815 | { |
| 7816 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7817 | continue; |
| 7818 | first = 1; |
| 7819 | } |
| 7820 | |
| 7821 | buffer_putstr (b, argv[i]); |
| 7822 | } |
| 7823 | buffer_putc (b, '\0'); |
| 7824 | |
| 7825 | regstr = buffer_getstr (b); |
| 7826 | buffer_free (b); |
| 7827 | |
| 7828 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7829 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7830 | if (! regex) |
| 7831 | { |
| 7832 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7833 | VTY_NEWLINE); |
| 7834 | return CMD_WARNING; |
| 7835 | } |
| 7836 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7837 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7838 | bgp_regex_free (regex); |
| 7839 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7840 | } |
| 7841 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7842 | |
| 7843 | DEFUN (show_ip_bgp_regexp, |
| 7844 | show_ip_bgp_regexp_cmd, |
| 7845 | "show ip bgp regexp .LINE", |
| 7846 | SHOW_STR |
| 7847 | IP_STR |
| 7848 | BGP_STR |
| 7849 | "Display routes matching the AS path regular expression\n" |
| 7850 | "A regular-expression to match the BGP AS paths\n") |
| 7851 | { |
| 7852 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7853 | bgp_show_type_regexp); |
| 7854 | } |
| 7855 | |
| 7856 | DEFUN (show_ip_bgp_flap_regexp, |
| 7857 | show_ip_bgp_flap_regexp_cmd, |
| 7858 | "show ip bgp flap-statistics regexp .LINE", |
| 7859 | SHOW_STR |
| 7860 | IP_STR |
| 7861 | BGP_STR |
| 7862 | "Display flap statistics of routes\n" |
| 7863 | "Display routes matching the AS path regular expression\n" |
| 7864 | "A regular-expression to match the BGP AS paths\n") |
| 7865 | { |
| 7866 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7867 | bgp_show_type_flap_regexp); |
| 7868 | } |
| 7869 | |
| 7870 | ALIAS (show_ip_bgp_flap_regexp, |
| 7871 | show_ip_bgp_damp_flap_regexp_cmd, |
| 7872 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 7873 | SHOW_STR |
| 7874 | IP_STR |
| 7875 | BGP_STR |
| 7876 | "Display detailed information about dampening\n" |
| 7877 | "Display flap statistics of routes\n" |
| 7878 | "Display routes matching the AS path regular expression\n" |
| 7879 | "A regular-expression to match the BGP AS paths\n") |
| 7880 | |
| 7881 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7882 | show_ip_bgp_ipv4_regexp_cmd, |
| 7883 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7884 | SHOW_STR |
| 7885 | IP_STR |
| 7886 | BGP_STR |
| 7887 | "Address family\n" |
| 7888 | "Address Family modifier\n" |
| 7889 | "Address Family modifier\n" |
| 7890 | "Display routes matching the AS path regular expression\n" |
| 7891 | "A regular-expression to match the BGP AS paths\n") |
| 7892 | { |
| 7893 | if (strncmp (argv[0], "m", 1) == 0) |
| 7894 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7895 | bgp_show_type_regexp); |
| 7896 | |
| 7897 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7898 | bgp_show_type_regexp); |
| 7899 | } |
| 7900 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7901 | DEFUN (show_bgp_regexp, |
| 7902 | show_bgp_regexp_cmd, |
| 7903 | "show bgp regexp .LINE", |
| 7904 | SHOW_STR |
| 7905 | BGP_STR |
| 7906 | "Display routes matching the AS path regular expression\n" |
| 7907 | "A regular-expression to match the BGP AS paths\n") |
| 7908 | { |
| 7909 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7910 | bgp_show_type_regexp); |
| 7911 | } |
| 7912 | |
| 7913 | /* old command */ |
| 7914 | DEFUN (show_ipv6_bgp_regexp, |
| 7915 | show_ipv6_bgp_regexp_cmd, |
| 7916 | "show ipv6 bgp regexp .LINE", |
| 7917 | SHOW_STR |
| 7918 | IP_STR |
| 7919 | BGP_STR |
| 7920 | "Display routes matching the AS path regular expression\n" |
| 7921 | "A regular-expression to match the BGP AS paths\n") |
| 7922 | { |
| 7923 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7924 | bgp_show_type_regexp); |
| 7925 | } |
| 7926 | |
| 7927 | /* old command */ |
| 7928 | DEFUN (show_ipv6_mbgp_regexp, |
| 7929 | show_ipv6_mbgp_regexp_cmd, |
| 7930 | "show ipv6 mbgp regexp .LINE", |
| 7931 | SHOW_STR |
| 7932 | IP_STR |
| 7933 | BGP_STR |
| 7934 | "Display routes matching the AS path regular expression\n" |
| 7935 | "A regular-expression to match the MBGP AS paths\n") |
| 7936 | { |
| 7937 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7938 | bgp_show_type_regexp); |
| 7939 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7940 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7941 | DEFUN (show_bgp_ipv4_safi_flap_regexp, |
| 7942 | show_bgp_ipv4_safi_flap_regexp_cmd, |
| 7943 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7944 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7945 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7946 | IP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7947 | "Address Family Modifier\n" |
| 7948 | "Address Family Modifier\n" |
| 7949 | "Address Family Modifier\n" |
| 7950 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7951 | "Display flap statistics of routes\n" |
| 7952 | "Display routes matching the AS path regular expression\n" |
| 7953 | "A regular-expression to match the BGP AS paths\n") |
| 7954 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7955 | safi_t safi; |
| 7956 | |
| 7957 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7958 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7959 | return CMD_WARNING; |
| 7960 | } |
| 7961 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
| 7962 | bgp_show_type_flap_regexp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7963 | } |
| 7964 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7965 | ALIAS (show_bgp_ipv4_safi_flap_regexp, |
| 7966 | show_bgp_ipv4_safi_damp_flap_regexp_cmd, |
| 7967 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7968 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7969 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7970 | IP_STR |
| 7971 | "Address Family Modifier\n" |
| 7972 | "Address Family Modifier\n" |
| 7973 | "Address Family Modifier\n" |
| 7974 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7975 | "Display detailed information about dampening\n" |
| 7976 | "Display flap statistics of routes\n" |
| 7977 | "Display routes matching the AS path regular expression\n" |
| 7978 | "A regular-expression to match the BGP AS paths\n") |
| 7979 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7980 | DEFUN (show_bgp_ipv6_safi_flap_regexp, |
| 7981 | show_bgp_ipv6_safi_flap_regexp_cmd, |
| 7982 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7983 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7984 | BGP_STR |
| 7985 | IPV6_STR |
| 7986 | "Address Family Modifier\n" |
| 7987 | "Address Family Modifier\n" |
| 7988 | "Address Family Modifier\n" |
| 7989 | "Address Family Modifier\n" |
| 7990 | "Display flap statistics of routes\n" |
| 7991 | "Display routes matching the AS path regular expression\n" |
| 7992 | "A regular-expression to match the BGP AS paths\n") |
| 7993 | { |
| 7994 | safi_t safi; |
| 7995 | |
| 7996 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7997 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7998 | return CMD_WARNING; |
| 7999 | } |
| 8000 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
| 8001 | bgp_show_type_flap_regexp); |
| 8002 | } |
| 8003 | |
| 8004 | ALIAS (show_bgp_ipv6_safi_flap_regexp, |
| 8005 | show_bgp_ipv6_safi_damp_flap_regexp_cmd, |
| 8006 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
| 8007 | SHOW_STR |
| 8008 | BGP_STR |
| 8009 | IPV6_STR |
| 8010 | "Address Family Modifier\n" |
| 8011 | "Address Family Modifier\n" |
| 8012 | "Address Family Modifier\n" |
| 8013 | "Address Family Modifier\n" |
| 8014 | "Display detailed information about dampening\n" |
| 8015 | "Display flap statistics of routes\n" |
| 8016 | "Display routes matching the AS path regular expression\n" |
| 8017 | "A regular-expression to match the BGP AS paths\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8018 | |
| 8019 | DEFUN (show_bgp_ipv4_safi_regexp, |
| 8020 | show_bgp_ipv4_safi_regexp_cmd, |
| 8021 | "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE", |
| 8022 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8023 | BGP_STR |
| 8024 | "Address family\n" |
| 8025 | "Address Family modifier\n" |
| 8026 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8027 | "Address Family modifier\n" |
| 8028 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8029 | "Display routes matching the AS path regular expression\n" |
| 8030 | "A regular-expression to match the BGP AS paths\n") |
| 8031 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8032 | safi_t safi; |
| 8033 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8034 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8035 | return CMD_WARNING; |
| 8036 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8037 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8038 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8039 | bgp_show_type_regexp); |
| 8040 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8041 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8042 | DEFUN (show_bgp_ipv6_safi_regexp, |
| 8043 | show_bgp_ipv6_safi_regexp_cmd, |
| 8044 | "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8045 | SHOW_STR |
| 8046 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8047 | "Address family\n" |
| 8048 | "Address Family modifier\n" |
| 8049 | "Address Family modifier\n" |
| 8050 | "Address Family modifier\n" |
| 8051 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8052 | "Display routes matching the AS path regular expression\n" |
| 8053 | "A regular-expression to match the BGP AS paths\n") |
| 8054 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8055 | safi_t safi; |
| 8056 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8057 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8058 | return CMD_WARNING; |
| 8059 | } |
| 8060 | |
| 8061 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8062 | bgp_show_type_regexp); |
| 8063 | } |
| 8064 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8065 | DEFUN (show_bgp_ipv6_regexp, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8066 | show_bgp_ipv6_regexp_cmd, |
| 8067 | "show bgp ipv6 regexp .LINE", |
| 8068 | SHOW_STR |
| 8069 | BGP_STR |
| 8070 | "Address family\n" |
| 8071 | "Display routes matching the AS path regular expression\n" |
| 8072 | "A regular-expression to match the BGP AS paths\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8073 | { |
| 8074 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8075 | bgp_show_type_regexp); |
| 8076 | } |
| 8077 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8078 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8079 | 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] | 8080 | safi_t safi, enum bgp_show_type type) |
| 8081 | { |
| 8082 | struct prefix_list *plist; |
| 8083 | |
| 8084 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 8085 | if (plist == NULL) |
| 8086 | { |
| 8087 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 8088 | prefix_list_str, VTY_NEWLINE); |
| 8089 | return CMD_WARNING; |
| 8090 | } |
| 8091 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8092 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8093 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8094 | DEFUN (show_ip_bgp_prefix_list, |
| 8095 | show_ip_bgp_prefix_list_cmd, |
| 8096 | "show ip bgp prefix-list WORD", |
| 8097 | SHOW_STR |
| 8098 | IP_STR |
| 8099 | BGP_STR |
| 8100 | "Display routes conforming to the prefix-list\n" |
| 8101 | "IP prefix-list name\n") |
| 8102 | { |
| 8103 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8104 | bgp_show_type_prefix_list); |
| 8105 | } |
| 8106 | |
| 8107 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 8108 | show_ip_bgp_flap_prefix_list_cmd, |
| 8109 | "show ip bgp flap-statistics prefix-list WORD", |
| 8110 | SHOW_STR |
| 8111 | IP_STR |
| 8112 | BGP_STR |
| 8113 | "Display flap statistics of routes\n" |
| 8114 | "Display routes conforming to the prefix-list\n" |
| 8115 | "IP prefix-list name\n") |
| 8116 | { |
| 8117 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8118 | bgp_show_type_flap_prefix_list); |
| 8119 | } |
| 8120 | |
| 8121 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 8122 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 8123 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 8124 | SHOW_STR |
| 8125 | IP_STR |
| 8126 | BGP_STR |
| 8127 | "Display detailed information about dampening\n" |
| 8128 | "Display flap statistics of routes\n" |
| 8129 | "Display routes conforming to the prefix-list\n" |
| 8130 | "IP prefix-list name\n") |
| 8131 | |
| 8132 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 8133 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 8134 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 8135 | SHOW_STR |
| 8136 | IP_STR |
| 8137 | BGP_STR |
| 8138 | "Address family\n" |
| 8139 | "Address Family modifier\n" |
| 8140 | "Address Family modifier\n" |
| 8141 | "Display routes conforming to the prefix-list\n" |
| 8142 | "IP prefix-list name\n") |
| 8143 | { |
| 8144 | if (strncmp (argv[0], "m", 1) == 0) |
| 8145 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8146 | bgp_show_type_prefix_list); |
| 8147 | |
| 8148 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8149 | bgp_show_type_prefix_list); |
| 8150 | } |
| 8151 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8152 | DEFUN (show_bgp_prefix_list, |
| 8153 | show_bgp_prefix_list_cmd, |
| 8154 | "show bgp prefix-list WORD", |
| 8155 | SHOW_STR |
| 8156 | BGP_STR |
| 8157 | "Display routes conforming to the prefix-list\n" |
| 8158 | "IPv6 prefix-list name\n") |
| 8159 | { |
| 8160 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8161 | bgp_show_type_prefix_list); |
| 8162 | } |
| 8163 | |
| 8164 | ALIAS (show_bgp_prefix_list, |
| 8165 | show_bgp_ipv6_prefix_list_cmd, |
| 8166 | "show bgp ipv6 prefix-list WORD", |
| 8167 | SHOW_STR |
| 8168 | BGP_STR |
| 8169 | "Address family\n" |
| 8170 | "Display routes conforming to the prefix-list\n" |
| 8171 | "IPv6 prefix-list name\n") |
| 8172 | |
| 8173 | /* old command */ |
| 8174 | DEFUN (show_ipv6_bgp_prefix_list, |
| 8175 | show_ipv6_bgp_prefix_list_cmd, |
| 8176 | "show ipv6 bgp prefix-list WORD", |
| 8177 | SHOW_STR |
| 8178 | IPV6_STR |
| 8179 | BGP_STR |
| 8180 | "Display routes matching the prefix-list\n" |
| 8181 | "IPv6 prefix-list name\n") |
| 8182 | { |
| 8183 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8184 | bgp_show_type_prefix_list); |
| 8185 | } |
| 8186 | |
| 8187 | /* old command */ |
| 8188 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 8189 | show_ipv6_mbgp_prefix_list_cmd, |
| 8190 | "show ipv6 mbgp prefix-list WORD", |
| 8191 | SHOW_STR |
| 8192 | IPV6_STR |
| 8193 | MBGP_STR |
| 8194 | "Display routes matching the prefix-list\n" |
| 8195 | "IPv6 prefix-list name\n") |
| 8196 | { |
| 8197 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8198 | bgp_show_type_prefix_list); |
| 8199 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8200 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8201 | DEFUN (show_bgp_ipv4_prefix_list, |
| 8202 | show_bgp_ipv4_prefix_list_cmd, |
| 8203 | "show bgp ipv4 prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8204 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8205 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8206 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8207 | "Display routes conforming to the prefix-list\n" |
| 8208 | "IP prefix-list name\n") |
| 8209 | { |
| 8210 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8211 | bgp_show_type_prefix_list); |
| 8212 | } |
| 8213 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8214 | DEFUN (show_bgp_ipv4_safi_flap_prefix_list, |
| 8215 | show_bgp_ipv4_safi_flap_prefix_list_cmd, |
| 8216 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8217 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8218 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8219 | IP_STR |
| 8220 | "Address Family Modifier\n" |
| 8221 | "Address Family Modifier\n" |
| 8222 | "Address Family Modifier\n" |
| 8223 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8224 | "Display flap statistics of routes\n" |
| 8225 | "Display routes conforming to the prefix-list\n" |
| 8226 | "IP prefix-list name\n") |
| 8227 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8228 | safi_t safi; |
| 8229 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8230 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8231 | return CMD_WARNING; |
| 8232 | } |
| 8233 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8234 | bgp_show_type_flap_prefix_list); |
| 8235 | } |
| 8236 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8237 | ALIAS (show_bgp_ipv4_safi_flap_prefix_list, |
| 8238 | show_bgp_ipv4_safi_damp_flap_prefix_list_cmd, |
| 8239 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8240 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8241 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8242 | IP_STR |
| 8243 | "Address Family Modifier\n" |
| 8244 | "Address Family Modifier\n" |
| 8245 | "Address Family Modifier\n" |
| 8246 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8247 | "Display detailed information about dampening\n" |
| 8248 | "Display flap statistics of routes\n" |
| 8249 | "Display routes conforming to the prefix-list\n" |
| 8250 | "IP prefix-list name\n") |
| 8251 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8252 | DEFUN (show_bgp_ipv6_safi_flap_prefix_list, |
| 8253 | show_bgp_ipv6_safi_flap_prefix_list_cmd, |
| 8254 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8255 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8256 | BGP_STR |
| 8257 | IPV6_STR |
| 8258 | "Address Family Modifier\n" |
| 8259 | "Address Family Modifier\n" |
| 8260 | "Address Family Modifier\n" |
| 8261 | "Address Family Modifier\n" |
| 8262 | "Display flap statistics of routes\n" |
| 8263 | "Display routes conforming to the prefix-list\n" |
| 8264 | "IP prefix-list name\n") |
| 8265 | { |
| 8266 | safi_t safi; |
| 8267 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8268 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8269 | return CMD_WARNING; |
| 8270 | } |
| 8271 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
| 8272 | bgp_show_type_flap_prefix_list); |
| 8273 | } |
| 8274 | ALIAS (show_bgp_ipv6_safi_flap_prefix_list, |
| 8275 | show_bgp_ipv6_safi_damp_flap_prefix_list_cmd, |
| 8276 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
| 8277 | SHOW_STR |
| 8278 | BGP_STR |
| 8279 | IPV6_STR |
| 8280 | "Address Family Modifier\n" |
| 8281 | "Address Family Modifier\n" |
| 8282 | "Address Family Modifier\n" |
| 8283 | "Address Family Modifier\n" |
| 8284 | "Display detailed information about dampening\n" |
| 8285 | "Display flap statistics of routes\n" |
| 8286 | "Display routes conforming to the prefix-list\n" |
| 8287 | "IP prefix-list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8288 | |
| 8289 | DEFUN (show_bgp_ipv4_safi_prefix_list, |
| 8290 | show_bgp_ipv4_safi_prefix_list_cmd, |
| 8291 | "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD", |
| 8292 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8293 | BGP_STR |
| 8294 | "Address family\n" |
| 8295 | "Address Family modifier\n" |
| 8296 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8297 | "Address Family modifier\n" |
| 8298 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8299 | "Display routes conforming to the prefix-list\n" |
| 8300 | "IP prefix-list name\n") |
| 8301 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8302 | safi_t safi; |
| 8303 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8304 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8305 | return CMD_WARNING; |
| 8306 | } |
| 8307 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8308 | bgp_show_type_prefix_list); |
| 8309 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8310 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8311 | DEFUN (show_bgp_ipv6_safi_prefix_list, |
| 8312 | show_bgp_ipv6_safi_prefix_list_cmd, |
| 8313 | "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8314 | SHOW_STR |
| 8315 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8316 | "Address family\n" |
| 8317 | "Address Family modifier\n" |
| 8318 | "Address Family modifier\n" |
| 8319 | "Address Family modifier\n" |
| 8320 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8321 | "Display routes conforming to the prefix-list\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8322 | "IP prefix-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8323 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8324 | safi_t safi; |
| 8325 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8326 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8327 | return CMD_WARNING; |
| 8328 | } |
| 8329 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8330 | bgp_show_type_prefix_list); |
| 8331 | } |
| 8332 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8333 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8334 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8335 | safi_t safi, enum bgp_show_type type) |
| 8336 | { |
| 8337 | struct as_list *as_list; |
| 8338 | |
| 8339 | as_list = as_list_lookup (filter); |
| 8340 | if (as_list == NULL) |
| 8341 | { |
| 8342 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 8343 | return CMD_WARNING; |
| 8344 | } |
| 8345 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8346 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8347 | } |
| 8348 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8349 | DEFUN (show_ip_bgp_filter_list, |
| 8350 | show_ip_bgp_filter_list_cmd, |
| 8351 | "show ip bgp filter-list WORD", |
| 8352 | SHOW_STR |
| 8353 | IP_STR |
| 8354 | BGP_STR |
| 8355 | "Display routes conforming to the filter-list\n" |
| 8356 | "Regular expression access list name\n") |
| 8357 | { |
| 8358 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8359 | bgp_show_type_filter_list); |
| 8360 | } |
| 8361 | |
| 8362 | DEFUN (show_ip_bgp_flap_filter_list, |
| 8363 | show_ip_bgp_flap_filter_list_cmd, |
| 8364 | "show ip bgp flap-statistics filter-list WORD", |
| 8365 | SHOW_STR |
| 8366 | IP_STR |
| 8367 | BGP_STR |
| 8368 | "Display flap statistics of routes\n" |
| 8369 | "Display routes conforming to the filter-list\n" |
| 8370 | "Regular expression access list name\n") |
| 8371 | { |
| 8372 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8373 | bgp_show_type_flap_filter_list); |
| 8374 | } |
| 8375 | |
| 8376 | ALIAS (show_ip_bgp_flap_filter_list, |
| 8377 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 8378 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 8379 | SHOW_STR |
| 8380 | IP_STR |
| 8381 | BGP_STR |
| 8382 | "Display detailed information about dampening\n" |
| 8383 | "Display flap statistics of routes\n" |
| 8384 | "Display routes conforming to the filter-list\n" |
| 8385 | "Regular expression access list name\n") |
| 8386 | |
| 8387 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 8388 | show_ip_bgp_ipv4_filter_list_cmd, |
| 8389 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 8390 | SHOW_STR |
| 8391 | IP_STR |
| 8392 | BGP_STR |
| 8393 | "Address family\n" |
| 8394 | "Address Family modifier\n" |
| 8395 | "Address Family modifier\n" |
| 8396 | "Display routes conforming to the filter-list\n" |
| 8397 | "Regular expression access list name\n") |
| 8398 | { |
| 8399 | if (strncmp (argv[0], "m", 1) == 0) |
| 8400 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8401 | bgp_show_type_filter_list); |
| 8402 | |
| 8403 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8404 | bgp_show_type_filter_list); |
| 8405 | } |
| 8406 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8407 | DEFUN (show_bgp_filter_list, |
| 8408 | show_bgp_filter_list_cmd, |
| 8409 | "show bgp filter-list WORD", |
| 8410 | SHOW_STR |
| 8411 | BGP_STR |
| 8412 | "Display routes conforming to the filter-list\n" |
| 8413 | "Regular expression access list name\n") |
| 8414 | { |
| 8415 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8416 | bgp_show_type_filter_list); |
| 8417 | } |
| 8418 | |
| 8419 | /* old command */ |
| 8420 | DEFUN (show_ipv6_bgp_filter_list, |
| 8421 | show_ipv6_bgp_filter_list_cmd, |
| 8422 | "show ipv6 bgp filter-list WORD", |
| 8423 | SHOW_STR |
| 8424 | IPV6_STR |
| 8425 | BGP_STR |
| 8426 | "Display routes conforming to the filter-list\n" |
| 8427 | "Regular expression access list name\n") |
| 8428 | { |
| 8429 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8430 | bgp_show_type_filter_list); |
| 8431 | } |
| 8432 | |
| 8433 | /* old command */ |
| 8434 | DEFUN (show_ipv6_mbgp_filter_list, |
| 8435 | show_ipv6_mbgp_filter_list_cmd, |
| 8436 | "show ipv6 mbgp filter-list WORD", |
| 8437 | SHOW_STR |
| 8438 | IPV6_STR |
| 8439 | MBGP_STR |
| 8440 | "Display routes conforming to the filter-list\n" |
| 8441 | "Regular expression access list name\n") |
| 8442 | { |
| 8443 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8444 | bgp_show_type_filter_list); |
| 8445 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8446 | |
| 8447 | DEFUN (show_ip_bgp_dampening_info, |
| 8448 | show_ip_bgp_dampening_params_cmd, |
| 8449 | "show ip bgp dampening parameters", |
| 8450 | SHOW_STR |
| 8451 | IP_STR |
| 8452 | BGP_STR |
| 8453 | "Display detailed information about dampening\n" |
| 8454 | "Display detail of configured dampening parameters\n") |
| 8455 | { |
| 8456 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8457 | } |
| 8458 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8459 | DEFUN (show_bgp_ipv4_filter_list, |
| 8460 | show_bgp_ipv4_filter_list_cmd, |
| 8461 | "show bgp ipv4 filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8462 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8463 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8464 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8465 | "Display routes conforming to the filter-list\n" |
| 8466 | "Regular expression access list name\n") |
| 8467 | { |
| 8468 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8469 | bgp_show_type_filter_list); |
| 8470 | } |
| 8471 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8472 | DEFUN (show_bgp_ipv4_safi_flap_filter_list, |
| 8473 | show_bgp_ipv4_safi_flap_filter_list_cmd, |
| 8474 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8475 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8476 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8477 | IP_STR |
| 8478 | "Address Family modifier\n" |
| 8479 | "Address Family modifier\n" |
| 8480 | "Address Family modifier\n" |
| 8481 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8482 | "Display flap statistics of routes\n" |
| 8483 | "Display routes conforming to the filter-list\n" |
| 8484 | "Regular expression access list name\n") |
| 8485 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8486 | safi_t safi; |
| 8487 | |
| 8488 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8489 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8490 | return CMD_WARNING; |
| 8491 | } |
| 8492 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8493 | bgp_show_type_flap_filter_list); |
| 8494 | } |
| 8495 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8496 | ALIAS (show_bgp_ipv4_safi_flap_filter_list, |
| 8497 | show_bgp_ipv4_safi_damp_flap_filter_list_cmd, |
| 8498 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8499 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8500 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8501 | IP_STR |
| 8502 | "Address Family modifier\n" |
| 8503 | "Address Family modifier\n" |
| 8504 | "Address Family modifier\n" |
| 8505 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8506 | "Display detailed information about dampening\n" |
| 8507 | "Display flap statistics of routes\n" |
| 8508 | "Display routes conforming to the filter-list\n" |
| 8509 | "Regular expression access list name\n") |
| 8510 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8511 | DEFUN (show_bgp_ipv6_safi_flap_filter_list, |
| 8512 | show_bgp_ipv6_safi_flap_filter_list_cmd, |
| 8513 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8514 | SHOW_STR |
| 8515 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8516 | IPV6_STR |
| 8517 | "Address Family modifier\n" |
| 8518 | "Address Family modifier\n" |
| 8519 | "Address Family modifier\n" |
| 8520 | "Address Family modifier\n" |
| 8521 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8522 | "Display routes conforming to the filter-list\n" |
| 8523 | "Regular expression access list name\n") |
| 8524 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8525 | safi_t safi; |
| 8526 | |
| 8527 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8528 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8529 | return CMD_WARNING; |
| 8530 | } |
| 8531 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8532 | bgp_show_type_flap_filter_list); |
| 8533 | } |
| 8534 | ALIAS (show_bgp_ipv6_safi_flap_filter_list, |
| 8535 | show_bgp_ipv6_safi_damp_flap_filter_list_cmd, |
| 8536 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
| 8537 | SHOW_STR |
| 8538 | BGP_STR |
| 8539 | IPV6_STR |
| 8540 | "Address Family modifier\n" |
| 8541 | "Address Family modifier\n" |
| 8542 | "Address Family modifier\n" |
| 8543 | "Address Family modifier\n" |
| 8544 | "Display detailed information about dampening\n" |
| 8545 | "Display flap statistics of routes\n" |
| 8546 | "Display routes conforming to the filter-list\n" |
| 8547 | "Regular expression access list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8548 | |
| 8549 | DEFUN (show_bgp_ipv4_safi_filter_list, |
| 8550 | show_bgp_ipv4_safi_filter_list_cmd, |
| 8551 | "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8552 | SHOW_STR |
| 8553 | BGP_STR |
| 8554 | "Address Family modifier\n" |
| 8555 | "Address Family modifier\n" |
| 8556 | "Address Family modifier\n" |
| 8557 | "Address Family modifier\n" |
| 8558 | "Display routes conforming to the filter-list\n" |
| 8559 | "Regular expression access list name\n") |
| 8560 | { |
| 8561 | safi_t safi; |
| 8562 | |
| 8563 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8564 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8565 | return CMD_WARNING; |
| 8566 | } |
| 8567 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
| 8568 | bgp_show_type_filter_list); |
| 8569 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8570 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8571 | DEFUN (show_bgp_ipv6_safi_filter_list, |
| 8572 | show_bgp_ipv6_safi_filter_list_cmd, |
| 8573 | "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8574 | SHOW_STR |
| 8575 | BGP_STR |
| 8576 | "Address Family modifier\n" |
| 8577 | "Address Family modifier\n" |
| 8578 | "Address Family modifier\n" |
| 8579 | "Address Family modifier\n" |
| 8580 | "Display routes conforming to the filter-list\n" |
| 8581 | "Regular expression access list name\n") |
| 8582 | { |
| 8583 | safi_t safi; |
| 8584 | |
| 8585 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8586 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8587 | return CMD_WARNING; |
| 8588 | } |
| 8589 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8590 | bgp_show_type_filter_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8591 | } |
| 8592 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8593 | DEFUN (show_bgp_ipv6_filter_list, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8594 | show_bgp_ipv6_filter_list_cmd, |
| 8595 | "show bgp ipv6 filter-list WORD", |
| 8596 | SHOW_STR |
| 8597 | BGP_STR |
| 8598 | "Address family\n" |
| 8599 | "Display routes conforming to the filter-list\n" |
| 8600 | "Regular expression access list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8601 | { |
| 8602 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8603 | bgp_show_type_filter_list); |
| 8604 | } |
| 8605 | |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 8606 | |
| 8607 | DEFUN (show_ip_bgp_ipv4_dampening_parameters, |
| 8608 | show_ip_bgp_ipv4_dampening_parameters_cmd, |
| 8609 | "show ip bgp ipv4 (unicast|multicast) dampening parameters", |
| 8610 | SHOW_STR |
| 8611 | IP_STR |
| 8612 | BGP_STR |
| 8613 | "Address family\n" |
| 8614 | "Address Family modifier\n" |
| 8615 | "Address Family modifier\n" |
| 8616 | "Display detailed information about dampening\n" |
| 8617 | "Display detail of configured dampening parameters\n") |
| 8618 | { |
| 8619 | if (strncmp(argv[0], "m", 1) == 0) |
| 8620 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); |
| 8621 | |
| 8622 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8623 | } |
| 8624 | |
| 8625 | |
| 8626 | DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, |
| 8627 | show_ip_bgp_ipv4_dampening_flap_stats_cmd, |
| 8628 | "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", |
| 8629 | SHOW_STR |
| 8630 | IP_STR |
| 8631 | BGP_STR |
| 8632 | "Address family\n" |
| 8633 | "Address Family modifier\n" |
| 8634 | "Address Family modifier\n" |
| 8635 | "Display detailed information about dampening\n" |
| 8636 | "Display flap statistics of routes\n") |
| 8637 | { |
| 8638 | if (strncmp(argv[0], "m", 1) == 0) |
| 8639 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8640 | bgp_show_type_flap_statistics, NULL); |
| 8641 | |
| 8642 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8643 | bgp_show_type_flap_statistics, NULL); |
| 8644 | } |
| 8645 | |
| 8646 | DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, |
| 8647 | show_ip_bgp_ipv4_dampening_dampd_paths_cmd, |
| 8648 | "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", |
| 8649 | SHOW_STR |
| 8650 | IP_STR |
| 8651 | BGP_STR |
| 8652 | "Address family\n" |
| 8653 | "Address Family modifier\n" |
| 8654 | "Address Family modifier\n" |
| 8655 | "Display detailed information about dampening\n" |
| 8656 | "Display paths suppressed due to dampening\n") |
| 8657 | { |
| 8658 | if (strncmp(argv[0], "m", 1) == 0) |
| 8659 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8660 | bgp_show_type_dampend_paths, NULL); |
| 8661 | |
| 8662 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8663 | bgp_show_type_dampend_paths, NULL); |
| 8664 | } |
| 8665 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8666 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8667 | 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] | 8668 | safi_t safi, enum bgp_show_type type) |
| 8669 | { |
| 8670 | struct route_map *rmap; |
| 8671 | |
| 8672 | rmap = route_map_lookup_by_name (rmap_str); |
| 8673 | if (! rmap) |
| 8674 | { |
| 8675 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 8676 | rmap_str, VTY_NEWLINE); |
| 8677 | return CMD_WARNING; |
| 8678 | } |
| 8679 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8680 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8681 | } |
| 8682 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8683 | DEFUN (show_ip_bgp_route_map, |
| 8684 | show_ip_bgp_route_map_cmd, |
| 8685 | "show ip bgp route-map WORD", |
| 8686 | SHOW_STR |
| 8687 | IP_STR |
| 8688 | BGP_STR |
| 8689 | "Display routes matching the route-map\n" |
| 8690 | "A route-map to match on\n") |
| 8691 | { |
| 8692 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8693 | bgp_show_type_route_map); |
| 8694 | } |
| 8695 | |
| 8696 | DEFUN (show_ip_bgp_flap_route_map, |
| 8697 | show_ip_bgp_flap_route_map_cmd, |
| 8698 | "show ip bgp flap-statistics route-map WORD", |
| 8699 | SHOW_STR |
| 8700 | IP_STR |
| 8701 | BGP_STR |
| 8702 | "Display flap statistics of routes\n" |
| 8703 | "Display routes matching the route-map\n" |
| 8704 | "A route-map to match on\n") |
| 8705 | { |
| 8706 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8707 | bgp_show_type_flap_route_map); |
| 8708 | } |
| 8709 | |
| 8710 | ALIAS (show_ip_bgp_flap_route_map, |
| 8711 | show_ip_bgp_damp_flap_route_map_cmd, |
| 8712 | "show ip bgp dampening flap-statistics route-map WORD", |
| 8713 | SHOW_STR |
| 8714 | IP_STR |
| 8715 | BGP_STR |
| 8716 | "Display detailed information about dampening\n" |
| 8717 | "Display flap statistics of routes\n" |
| 8718 | "Display routes matching the route-map\n" |
| 8719 | "A route-map to match on\n") |
| 8720 | |
| 8721 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 8722 | show_ip_bgp_ipv4_route_map_cmd, |
| 8723 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 8724 | SHOW_STR |
| 8725 | IP_STR |
| 8726 | BGP_STR |
| 8727 | "Address family\n" |
| 8728 | "Address Family modifier\n" |
| 8729 | "Address Family modifier\n" |
| 8730 | "Display routes matching the route-map\n" |
| 8731 | "A route-map to match on\n") |
| 8732 | { |
| 8733 | if (strncmp (argv[0], "m", 1) == 0) |
| 8734 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8735 | bgp_show_type_route_map); |
| 8736 | |
| 8737 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8738 | bgp_show_type_route_map); |
| 8739 | } |
| 8740 | |
| 8741 | DEFUN (show_bgp_route_map, |
| 8742 | show_bgp_route_map_cmd, |
| 8743 | "show bgp route-map WORD", |
| 8744 | SHOW_STR |
| 8745 | BGP_STR |
| 8746 | "Display routes matching the route-map\n" |
| 8747 | "A route-map to match on\n") |
| 8748 | { |
| 8749 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8750 | bgp_show_type_route_map); |
| 8751 | } |
| 8752 | |
| 8753 | DEFUN (show_ip_bgp_cidr_only, |
| 8754 | show_ip_bgp_cidr_only_cmd, |
| 8755 | "show ip bgp cidr-only", |
| 8756 | SHOW_STR |
| 8757 | IP_STR |
| 8758 | BGP_STR |
| 8759 | "Display only routes with non-natural netmasks\n") |
| 8760 | { |
| 8761 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8762 | bgp_show_type_cidr_only, NULL); |
| 8763 | } |
| 8764 | |
| 8765 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 8766 | show_ip_bgp_flap_cidr_only_cmd, |
| 8767 | "show ip bgp flap-statistics cidr-only", |
| 8768 | SHOW_STR |
| 8769 | IP_STR |
| 8770 | BGP_STR |
| 8771 | "Display flap statistics of routes\n" |
| 8772 | "Display only routes with non-natural netmasks\n") |
| 8773 | { |
| 8774 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8775 | bgp_show_type_flap_cidr_only, NULL); |
| 8776 | } |
| 8777 | |
| 8778 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 8779 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 8780 | "show ip bgp dampening flap-statistics cidr-only", |
| 8781 | SHOW_STR |
| 8782 | IP_STR |
| 8783 | BGP_STR |
| 8784 | "Display detailed information about dampening\n" |
| 8785 | "Display flap statistics of routes\n" |
| 8786 | "Display only routes with non-natural netmasks\n") |
| 8787 | |
| 8788 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 8789 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 8790 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 8791 | SHOW_STR |
| 8792 | IP_STR |
| 8793 | BGP_STR |
| 8794 | "Address family\n" |
| 8795 | "Address Family modifier\n" |
| 8796 | "Address Family modifier\n" |
| 8797 | "Display only routes with non-natural netmasks\n") |
| 8798 | { |
| 8799 | if (strncmp (argv[0], "m", 1) == 0) |
| 8800 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8801 | bgp_show_type_cidr_only, NULL); |
| 8802 | |
| 8803 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8804 | bgp_show_type_cidr_only, NULL); |
| 8805 | } |
| 8806 | |
| 8807 | DEFUN (show_ip_bgp_community_all, |
| 8808 | show_ip_bgp_community_all_cmd, |
| 8809 | "show ip bgp community", |
| 8810 | SHOW_STR |
| 8811 | IP_STR |
| 8812 | BGP_STR |
| 8813 | "Display routes matching the communities\n") |
| 8814 | { |
| 8815 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8816 | bgp_show_type_community_all, NULL); |
| 8817 | } |
| 8818 | |
| 8819 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 8820 | show_ip_bgp_ipv4_community_all_cmd, |
| 8821 | "show ip bgp ipv4 (unicast|multicast) community", |
| 8822 | SHOW_STR |
| 8823 | IP_STR |
| 8824 | BGP_STR |
| 8825 | "Address family\n" |
| 8826 | "Address Family modifier\n" |
| 8827 | "Address Family modifier\n" |
| 8828 | "Display routes matching the communities\n") |
| 8829 | { |
| 8830 | if (strncmp (argv[0], "m", 1) == 0) |
| 8831 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8832 | bgp_show_type_community_all, NULL); |
| 8833 | |
| 8834 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8835 | bgp_show_type_community_all, NULL); |
| 8836 | } |
| 8837 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8838 | DEFUN (show_bgp_community_all, |
| 8839 | show_bgp_community_all_cmd, |
| 8840 | "show bgp community", |
| 8841 | SHOW_STR |
| 8842 | BGP_STR |
| 8843 | "Display routes matching the communities\n") |
| 8844 | { |
| 8845 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 8846 | bgp_show_type_community_all, NULL); |
| 8847 | } |
| 8848 | |
| 8849 | ALIAS (show_bgp_community_all, |
| 8850 | show_bgp_ipv6_community_all_cmd, |
| 8851 | "show bgp ipv6 community", |
| 8852 | SHOW_STR |
| 8853 | BGP_STR |
| 8854 | "Address family\n" |
| 8855 | "Display routes matching the communities\n") |
| 8856 | |
| 8857 | /* old command */ |
| 8858 | DEFUN (show_ipv6_bgp_community_all, |
| 8859 | show_ipv6_bgp_community_all_cmd, |
| 8860 | "show ipv6 bgp community", |
| 8861 | SHOW_STR |
| 8862 | IPV6_STR |
| 8863 | BGP_STR |
| 8864 | "Display routes matching the communities\n") |
| 8865 | { |
| 8866 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 8867 | bgp_show_type_community_all, NULL); |
| 8868 | } |
| 8869 | |
| 8870 | /* old command */ |
| 8871 | DEFUN (show_ipv6_mbgp_community_all, |
| 8872 | show_ipv6_mbgp_community_all_cmd, |
| 8873 | "show ipv6 mbgp community", |
| 8874 | SHOW_STR |
| 8875 | IPV6_STR |
| 8876 | MBGP_STR |
| 8877 | "Display routes matching the communities\n") |
| 8878 | { |
| 8879 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
| 8880 | bgp_show_type_community_all, NULL); |
| 8881 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8882 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8883 | DEFUN (show_bgp_ipv4_route_map, |
| 8884 | show_bgp_ipv4_route_map_cmd, |
| 8885 | "show bgp ipv4 route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8886 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8887 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8888 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8889 | "Display routes matching the route-map\n" |
| 8890 | "A route-map to match on\n") |
| 8891 | { |
| 8892 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8893 | bgp_show_type_route_map); |
| 8894 | } |
| 8895 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8896 | DEFUN (show_bgp_ipv4_safi_flap_route_map, |
| 8897 | show_bgp_ipv4_safi_flap_route_map_cmd, |
| 8898 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8899 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8900 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8901 | IP_STR |
| 8902 | "Address Family Modifier\n" |
| 8903 | "Address Family Modifier\n" |
| 8904 | "Address Family Modifier\n" |
| 8905 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8906 | "Display flap statistics of routes\n" |
| 8907 | "Display routes matching the route-map\n" |
| 8908 | "A route-map to match on\n") |
| 8909 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8910 | safi_t safi; |
| 8911 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8912 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8913 | return CMD_WARNING; |
| 8914 | } |
| 8915 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8916 | bgp_show_type_flap_route_map); |
| 8917 | } |
| 8918 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8919 | ALIAS (show_bgp_ipv4_safi_flap_route_map, |
| 8920 | show_bgp_ipv4_safi_damp_flap_route_map_cmd, |
| 8921 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8922 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8923 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8924 | IP_STR |
| 8925 | "Address Family Modifier\n" |
| 8926 | "Address Family Modifier\n" |
| 8927 | "Address Family Modifier\n" |
| 8928 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8929 | "Display detailed information about dampening\n" |
| 8930 | "Display flap statistics of routes\n" |
| 8931 | "Display routes matching the route-map\n" |
| 8932 | "A route-map to match on\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8933 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8934 | DEFUN (show_bgp_ipv6_safi_flap_route_map, |
| 8935 | show_bgp_ipv6_safi_flap_route_map_cmd, |
| 8936 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8937 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8938 | BGP_STR |
| 8939 | IPV6_STR |
| 8940 | "Address Family Modifier\n" |
| 8941 | "Address Family Modifier\n" |
| 8942 | "Address Family Modifier\n" |
| 8943 | "Address Family Modifier\n" |
| 8944 | "Display flap statistics of routes\n" |
| 8945 | "Display routes matching the route-map\n" |
| 8946 | "A route-map to match on\n") |
| 8947 | { |
| 8948 | safi_t safi; |
| 8949 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8950 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8951 | return CMD_WARNING; |
| 8952 | } |
| 8953 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
| 8954 | bgp_show_type_flap_route_map); |
| 8955 | } |
| 8956 | ALIAS (show_bgp_ipv6_safi_flap_route_map, |
| 8957 | show_bgp_ipv6_safi_damp_flap_route_map_cmd, |
| 8958 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
| 8959 | SHOW_STR |
| 8960 | BGP_STR |
| 8961 | IPV6_STR |
| 8962 | "Address Family Modifier\n" |
| 8963 | "Address Family Modifier\n" |
| 8964 | "Address Family Modifier\n" |
| 8965 | "Address Family Modifier\n" |
| 8966 | "Display detailed information about dampening\n" |
| 8967 | "Display flap statistics of routes\n" |
| 8968 | "Display routes matching the route-map\n" |
| 8969 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8970 | |
| 8971 | DEFUN (show_bgp_ipv4_safi_route_map, |
| 8972 | show_bgp_ipv4_safi_route_map_cmd, |
| 8973 | "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD", |
| 8974 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8975 | BGP_STR |
| 8976 | "Address family\n" |
| 8977 | "Address Family modifier\n" |
| 8978 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8979 | "Address Family modifier\n" |
| 8980 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8981 | "Display routes matching the route-map\n" |
| 8982 | "A route-map to match on\n") |
| 8983 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8984 | safi_t safi; |
| 8985 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8986 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8987 | return CMD_WARNING; |
| 8988 | } |
| 8989 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8990 | bgp_show_type_route_map); |
| 8991 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8992 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8993 | DEFUN (show_bgp_ipv6_safi_route_map, |
| 8994 | show_bgp_ipv6_safi_route_map_cmd, |
| 8995 | "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8996 | SHOW_STR |
| 8997 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8998 | "Address family\n" |
| 8999 | "Address Family modifier\n" |
| 9000 | "Address Family modifier\n" |
| 9001 | "Address Family modifier\n" |
| 9002 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9003 | "Display routes matching the route-map\n" |
| 9004 | "A route-map to match on\n") |
| 9005 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9006 | safi_t safi; |
| 9007 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9008 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9009 | return CMD_WARNING; |
| 9010 | } |
| 9011 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9012 | bgp_show_type_route_map); |
| 9013 | } |
| 9014 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9015 | DEFUN (show_bgp_ipv6_route_map, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9016 | show_bgp_ipv6_route_map_cmd, |
| 9017 | "show bgp ipv6 route-map WORD", |
| 9018 | SHOW_STR |
| 9019 | BGP_STR |
| 9020 | "Address family\n" |
| 9021 | "Display routes matching the route-map\n" |
| 9022 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9023 | { |
| 9024 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9025 | bgp_show_type_route_map); |
| 9026 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9027 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9028 | DEFUN (show_bgp_ipv4_cidr_only, |
| 9029 | show_bgp_ipv4_cidr_only_cmd, |
| 9030 | "show bgp ipv4 cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9031 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9032 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9033 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9034 | "Display only routes with non-natural netmasks\n") |
| 9035 | { |
| 9036 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9037 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9038 | } |
| 9039 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9040 | DEFUN (show_bgp_ipv4_safi_flap_cidr_only, |
| 9041 | show_bgp_ipv4_safi_flap_cidr_only_cmd, |
| 9042 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9043 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9044 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9045 | "Address Family\n" |
| 9046 | "Address Family Modifier\n" |
| 9047 | "Address Family Modifier\n" |
| 9048 | "Address Family Modifier\n" |
| 9049 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9050 | "Display flap statistics of routes\n" |
| 9051 | "Display only routes with non-natural netmasks\n") |
| 9052 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9053 | safi_t safi; |
| 9054 | |
| 9055 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9056 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9057 | return CMD_WARNING; |
| 9058 | } |
| 9059 | 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] | 9060 | } |
| 9061 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9062 | ALIAS (show_bgp_ipv4_safi_flap_cidr_only, |
| 9063 | show_bgp_ipv4_safi_damp_flap_cidr_only_cmd, |
| 9064 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9065 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9066 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9067 | "Address Family\n" |
| 9068 | "Address Family Modifier\n" |
| 9069 | "Address Family Modifier\n" |
| 9070 | "Address Family Modifier\n" |
| 9071 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9072 | "Display detailed information about dampening\n" |
| 9073 | "Display flap statistics of routes\n" |
| 9074 | "Display only routes with non-natural netmasks\n") |
| 9075 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9076 | DEFUN (show_bgp_ipv4_safi_cidr_only, |
| 9077 | show_bgp_ipv4_safi_cidr_only_cmd, |
| 9078 | "show bgp ipv4 (unicast|multicast) cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9079 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9080 | BGP_STR |
| 9081 | "Address family\n" |
| 9082 | "Address Family modifier\n" |
| 9083 | "Address Family modifier\n" |
| 9084 | "Display only routes with non-natural netmasks\n") |
| 9085 | { |
| 9086 | if (strncmp (argv[0], "m", 1) == 0) |
| 9087 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9088 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9089 | |
| 9090 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9091 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9092 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9093 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9094 | /* new046 */ |
| 9095 | DEFUN (show_bgp_afi_safi_community_all, |
| 9096 | show_bgp_afi_safi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9097 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9098 | SHOW_STR |
| 9099 | BGP_STR |
| 9100 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9101 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9102 | "Address Family modifier\n" |
| 9103 | "Address Family modifier\n" |
| 9104 | "Address Family modifier\n" |
| 9105 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9106 | "Display routes matching the communities\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9107 | { |
| 9108 | safi_t safi; |
| 9109 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9110 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9111 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9112 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9113 | return CMD_WARNING; |
| 9114 | } |
| 9115 | if (bgp_parse_safi(argv[1], &safi)) { |
| 9116 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 9117 | return CMD_WARNING; |
| 9118 | } |
| 9119 | |
| 9120 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
| 9121 | } |
| 9122 | DEFUN (show_bgp_afi_community_all, |
| 9123 | show_bgp_afi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9124 | "show bgp (ipv4|ipv6) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9125 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9126 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9127 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9128 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9129 | "Display routes matching the communities\n") |
| 9130 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9131 | afi_t afi; |
| 9132 | safi_t safi = SAFI_UNICAST; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9133 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9134 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9135 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9136 | return CMD_WARNING; |
| 9137 | } |
| 9138 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9139 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9140 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9141 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9142 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 9143 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9144 | { |
| 9145 | struct community *com; |
| 9146 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9147 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9148 | int i; |
| 9149 | char *str; |
| 9150 | int first = 0; |
| 9151 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9152 | /* BGP structure lookup */ |
| 9153 | if (view_name) |
| 9154 | { |
| 9155 | bgp = bgp_lookup_by_name (view_name); |
| 9156 | if (bgp == NULL) |
| 9157 | { |
| 9158 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9159 | return CMD_WARNING; |
| 9160 | } |
| 9161 | } |
| 9162 | else |
| 9163 | { |
| 9164 | bgp = bgp_get_default (); |
| 9165 | if (bgp == NULL) |
| 9166 | { |
| 9167 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9168 | return CMD_WARNING; |
| 9169 | } |
| 9170 | } |
| 9171 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9172 | b = buffer_new (1024); |
| 9173 | for (i = 0; i < argc; i++) |
| 9174 | { |
| 9175 | if (first) |
| 9176 | buffer_putc (b, ' '); |
| 9177 | else |
| 9178 | { |
| 9179 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 9180 | continue; |
| 9181 | first = 1; |
| 9182 | } |
| 9183 | |
| 9184 | buffer_putstr (b, argv[i]); |
| 9185 | } |
| 9186 | buffer_putc (b, '\0'); |
| 9187 | |
| 9188 | str = buffer_getstr (b); |
| 9189 | buffer_free (b); |
| 9190 | |
| 9191 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 9192 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9193 | if (! com) |
| 9194 | { |
| 9195 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 9196 | return CMD_WARNING; |
| 9197 | } |
| 9198 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9199 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9200 | (exact ? bgp_show_type_community_exact : |
| 9201 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9202 | } |
| 9203 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9204 | DEFUN (show_ip_bgp_community, |
| 9205 | show_ip_bgp_community_cmd, |
| 9206 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9207 | SHOW_STR |
| 9208 | IP_STR |
| 9209 | BGP_STR |
| 9210 | "Display routes matching the communities\n" |
| 9211 | "community number\n" |
| 9212 | "Do not send outside local AS (well-known community)\n" |
| 9213 | "Do not advertise to any peer (well-known community)\n" |
| 9214 | "Do not export to next AS (well-known community)\n") |
| 9215 | { |
| 9216 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9217 | } |
| 9218 | |
| 9219 | ALIAS (show_ip_bgp_community, |
| 9220 | show_ip_bgp_community2_cmd, |
| 9221 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9222 | SHOW_STR |
| 9223 | IP_STR |
| 9224 | BGP_STR |
| 9225 | "Display routes matching the communities\n" |
| 9226 | "community number\n" |
| 9227 | "Do not send outside local AS (well-known community)\n" |
| 9228 | "Do not advertise to any peer (well-known community)\n" |
| 9229 | "Do not export to next AS (well-known community)\n" |
| 9230 | "community number\n" |
| 9231 | "Do not send outside local AS (well-known community)\n" |
| 9232 | "Do not advertise to any peer (well-known community)\n" |
| 9233 | "Do not export to next AS (well-known community)\n") |
| 9234 | |
| 9235 | ALIAS (show_ip_bgp_community, |
| 9236 | show_ip_bgp_community3_cmd, |
| 9237 | "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)", |
| 9238 | SHOW_STR |
| 9239 | IP_STR |
| 9240 | BGP_STR |
| 9241 | "Display routes matching the communities\n" |
| 9242 | "community number\n" |
| 9243 | "Do not send outside local AS (well-known community)\n" |
| 9244 | "Do not advertise to any peer (well-known community)\n" |
| 9245 | "Do not export to next AS (well-known community)\n" |
| 9246 | "community number\n" |
| 9247 | "Do not send outside local AS (well-known community)\n" |
| 9248 | "Do not advertise to any peer (well-known community)\n" |
| 9249 | "Do not export to next AS (well-known community)\n" |
| 9250 | "community number\n" |
| 9251 | "Do not send outside local AS (well-known community)\n" |
| 9252 | "Do not advertise to any peer (well-known community)\n" |
| 9253 | "Do not export to next AS (well-known community)\n") |
| 9254 | |
| 9255 | ALIAS (show_ip_bgp_community, |
| 9256 | show_ip_bgp_community4_cmd, |
| 9257 | "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)", |
| 9258 | SHOW_STR |
| 9259 | IP_STR |
| 9260 | BGP_STR |
| 9261 | "Display routes matching the communities\n" |
| 9262 | "community number\n" |
| 9263 | "Do not send outside local AS (well-known community)\n" |
| 9264 | "Do not advertise to any peer (well-known community)\n" |
| 9265 | "Do not export to next AS (well-known community)\n" |
| 9266 | "community number\n" |
| 9267 | "Do not send outside local AS (well-known community)\n" |
| 9268 | "Do not advertise to any peer (well-known community)\n" |
| 9269 | "Do not export to next AS (well-known community)\n" |
| 9270 | "community number\n" |
| 9271 | "Do not send outside local AS (well-known community)\n" |
| 9272 | "Do not advertise to any peer (well-known community)\n" |
| 9273 | "Do not export to next AS (well-known community)\n" |
| 9274 | "community number\n" |
| 9275 | "Do not send outside local AS (well-known community)\n" |
| 9276 | "Do not advertise to any peer (well-known community)\n" |
| 9277 | "Do not export to next AS (well-known community)\n") |
| 9278 | |
| 9279 | DEFUN (show_ip_bgp_ipv4_community, |
| 9280 | show_ip_bgp_ipv4_community_cmd, |
| 9281 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 9282 | SHOW_STR |
| 9283 | IP_STR |
| 9284 | BGP_STR |
| 9285 | "Address family\n" |
| 9286 | "Address Family modifier\n" |
| 9287 | "Address Family modifier\n" |
| 9288 | "Display routes matching the communities\n" |
| 9289 | "community number\n" |
| 9290 | "Do not send outside local AS (well-known community)\n" |
| 9291 | "Do not advertise to any peer (well-known community)\n" |
| 9292 | "Do not export to next AS (well-known community)\n") |
| 9293 | { |
| 9294 | if (strncmp (argv[0], "m", 1) == 0) |
| 9295 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 9296 | |
| 9297 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9298 | } |
| 9299 | |
| 9300 | ALIAS (show_ip_bgp_ipv4_community, |
| 9301 | show_ip_bgp_ipv4_community2_cmd, |
| 9302 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9303 | SHOW_STR |
| 9304 | IP_STR |
| 9305 | BGP_STR |
| 9306 | "Address family\n" |
| 9307 | "Address Family modifier\n" |
| 9308 | "Address Family modifier\n" |
| 9309 | "Display routes matching the communities\n" |
| 9310 | "community number\n" |
| 9311 | "Do not send outside local AS (well-known community)\n" |
| 9312 | "Do not advertise to any peer (well-known community)\n" |
| 9313 | "Do not export to next AS (well-known community)\n" |
| 9314 | "community number\n" |
| 9315 | "Do not send outside local AS (well-known community)\n" |
| 9316 | "Do not advertise to any peer (well-known community)\n" |
| 9317 | "Do not export to next AS (well-known community)\n") |
| 9318 | |
| 9319 | ALIAS (show_ip_bgp_ipv4_community, |
| 9320 | show_ip_bgp_ipv4_community3_cmd, |
| 9321 | "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)", |
| 9322 | SHOW_STR |
| 9323 | IP_STR |
| 9324 | BGP_STR |
| 9325 | "Address family\n" |
| 9326 | "Address Family modifier\n" |
| 9327 | "Address Family modifier\n" |
| 9328 | "Display routes matching the communities\n" |
| 9329 | "community number\n" |
| 9330 | "Do not send outside local AS (well-known community)\n" |
| 9331 | "Do not advertise to any peer (well-known community)\n" |
| 9332 | "Do not export to next AS (well-known community)\n" |
| 9333 | "community number\n" |
| 9334 | "Do not send outside local AS (well-known community)\n" |
| 9335 | "Do not advertise to any peer (well-known community)\n" |
| 9336 | "Do not export to next AS (well-known community)\n" |
| 9337 | "community number\n" |
| 9338 | "Do not send outside local AS (well-known community)\n" |
| 9339 | "Do not advertise to any peer (well-known community)\n" |
| 9340 | "Do not export to next AS (well-known community)\n") |
| 9341 | |
| 9342 | ALIAS (show_ip_bgp_ipv4_community, |
| 9343 | show_ip_bgp_ipv4_community4_cmd, |
| 9344 | "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)", |
| 9345 | SHOW_STR |
| 9346 | IP_STR |
| 9347 | BGP_STR |
| 9348 | "Address family\n" |
| 9349 | "Address Family modifier\n" |
| 9350 | "Address Family modifier\n" |
| 9351 | "Display routes matching the communities\n" |
| 9352 | "community number\n" |
| 9353 | "Do not send outside local AS (well-known community)\n" |
| 9354 | "Do not advertise to any peer (well-known community)\n" |
| 9355 | "Do not export to next AS (well-known community)\n" |
| 9356 | "community number\n" |
| 9357 | "Do not send outside local AS (well-known community)\n" |
| 9358 | "Do not advertise to any peer (well-known community)\n" |
| 9359 | "Do not export to next AS (well-known community)\n" |
| 9360 | "community number\n" |
| 9361 | "Do not send outside local AS (well-known community)\n" |
| 9362 | "Do not advertise to any peer (well-known community)\n" |
| 9363 | "Do not export to next AS (well-known community)\n" |
| 9364 | "community number\n" |
| 9365 | "Do not send outside local AS (well-known community)\n" |
| 9366 | "Do not advertise to any peer (well-known community)\n" |
| 9367 | "Do not export to next AS (well-known community)\n") |
| 9368 | |
| 9369 | DEFUN (show_ip_bgp_community_exact, |
| 9370 | show_ip_bgp_community_exact_cmd, |
| 9371 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9372 | SHOW_STR |
| 9373 | IP_STR |
| 9374 | BGP_STR |
| 9375 | "Display routes matching the communities\n" |
| 9376 | "community number\n" |
| 9377 | "Do not send outside local AS (well-known community)\n" |
| 9378 | "Do not advertise to any peer (well-known community)\n" |
| 9379 | "Do not export to next AS (well-known community)\n" |
| 9380 | "Exact match of the communities") |
| 9381 | { |
| 9382 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9383 | } |
| 9384 | |
| 9385 | ALIAS (show_ip_bgp_community_exact, |
| 9386 | show_ip_bgp_community2_exact_cmd, |
| 9387 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9388 | SHOW_STR |
| 9389 | IP_STR |
| 9390 | BGP_STR |
| 9391 | "Display routes matching the communities\n" |
| 9392 | "community number\n" |
| 9393 | "Do not send outside local AS (well-known community)\n" |
| 9394 | "Do not advertise to any peer (well-known community)\n" |
| 9395 | "Do not export to next AS (well-known community)\n" |
| 9396 | "community number\n" |
| 9397 | "Do not send outside local AS (well-known community)\n" |
| 9398 | "Do not advertise to any peer (well-known community)\n" |
| 9399 | "Do not export to next AS (well-known community)\n" |
| 9400 | "Exact match of the communities") |
| 9401 | |
| 9402 | ALIAS (show_ip_bgp_community_exact, |
| 9403 | show_ip_bgp_community3_exact_cmd, |
| 9404 | "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", |
| 9405 | SHOW_STR |
| 9406 | IP_STR |
| 9407 | BGP_STR |
| 9408 | "Display routes matching the communities\n" |
| 9409 | "community number\n" |
| 9410 | "Do not send outside local AS (well-known community)\n" |
| 9411 | "Do not advertise to any peer (well-known community)\n" |
| 9412 | "Do not export to next AS (well-known community)\n" |
| 9413 | "community number\n" |
| 9414 | "Do not send outside local AS (well-known community)\n" |
| 9415 | "Do not advertise to any peer (well-known community)\n" |
| 9416 | "Do not export to next AS (well-known community)\n" |
| 9417 | "community number\n" |
| 9418 | "Do not send outside local AS (well-known community)\n" |
| 9419 | "Do not advertise to any peer (well-known community)\n" |
| 9420 | "Do not export to next AS (well-known community)\n" |
| 9421 | "Exact match of the communities") |
| 9422 | |
| 9423 | ALIAS (show_ip_bgp_community_exact, |
| 9424 | show_ip_bgp_community4_exact_cmd, |
| 9425 | "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", |
| 9426 | SHOW_STR |
| 9427 | IP_STR |
| 9428 | BGP_STR |
| 9429 | "Display routes matching the communities\n" |
| 9430 | "community number\n" |
| 9431 | "Do not send outside local AS (well-known community)\n" |
| 9432 | "Do not advertise to any peer (well-known community)\n" |
| 9433 | "Do not export to next AS (well-known community)\n" |
| 9434 | "community number\n" |
| 9435 | "Do not send outside local AS (well-known community)\n" |
| 9436 | "Do not advertise to any peer (well-known community)\n" |
| 9437 | "Do not export to next AS (well-known community)\n" |
| 9438 | "community number\n" |
| 9439 | "Do not send outside local AS (well-known community)\n" |
| 9440 | "Do not advertise to any peer (well-known community)\n" |
| 9441 | "Do not export to next AS (well-known community)\n" |
| 9442 | "community number\n" |
| 9443 | "Do not send outside local AS (well-known community)\n" |
| 9444 | "Do not advertise to any peer (well-known community)\n" |
| 9445 | "Do not export to next AS (well-known community)\n" |
| 9446 | "Exact match of the communities") |
| 9447 | |
| 9448 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 9449 | show_ip_bgp_ipv4_community_exact_cmd, |
| 9450 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9451 | SHOW_STR |
| 9452 | IP_STR |
| 9453 | BGP_STR |
| 9454 | "Address family\n" |
| 9455 | "Address Family modifier\n" |
| 9456 | "Address Family modifier\n" |
| 9457 | "Display routes matching the communities\n" |
| 9458 | "community number\n" |
| 9459 | "Do not send outside local AS (well-known community)\n" |
| 9460 | "Do not advertise to any peer (well-known community)\n" |
| 9461 | "Do not export to next AS (well-known community)\n" |
| 9462 | "Exact match of the communities") |
| 9463 | { |
| 9464 | if (strncmp (argv[0], "m", 1) == 0) |
| 9465 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 9466 | |
| 9467 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9468 | } |
| 9469 | |
| 9470 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9471 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 9472 | "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", |
| 9473 | SHOW_STR |
| 9474 | IP_STR |
| 9475 | BGP_STR |
| 9476 | "Address family\n" |
| 9477 | "Address Family modifier\n" |
| 9478 | "Address Family modifier\n" |
| 9479 | "Display routes matching the communities\n" |
| 9480 | "community number\n" |
| 9481 | "Do not send outside local AS (well-known community)\n" |
| 9482 | "Do not advertise to any peer (well-known community)\n" |
| 9483 | "Do not export to next AS (well-known community)\n" |
| 9484 | "community number\n" |
| 9485 | "Do not send outside local AS (well-known community)\n" |
| 9486 | "Do not advertise to any peer (well-known community)\n" |
| 9487 | "Do not export to next AS (well-known community)\n" |
| 9488 | "Exact match of the communities") |
| 9489 | |
| 9490 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9491 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 9492 | "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", |
| 9493 | SHOW_STR |
| 9494 | IP_STR |
| 9495 | BGP_STR |
| 9496 | "Address family\n" |
| 9497 | "Address Family modifier\n" |
| 9498 | "Address Family modifier\n" |
| 9499 | "Display routes matching the communities\n" |
| 9500 | "community number\n" |
| 9501 | "Do not send outside local AS (well-known community)\n" |
| 9502 | "Do not advertise to any peer (well-known community)\n" |
| 9503 | "Do not export to next AS (well-known community)\n" |
| 9504 | "community number\n" |
| 9505 | "Do not send outside local AS (well-known community)\n" |
| 9506 | "Do not advertise to any peer (well-known community)\n" |
| 9507 | "Do not export to next AS (well-known community)\n" |
| 9508 | "community number\n" |
| 9509 | "Do not send outside local AS (well-known community)\n" |
| 9510 | "Do not advertise to any peer (well-known community)\n" |
| 9511 | "Do not export to next AS (well-known community)\n" |
| 9512 | "Exact match of the communities") |
| 9513 | |
| 9514 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9515 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 9516 | "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", |
| 9517 | SHOW_STR |
| 9518 | IP_STR |
| 9519 | BGP_STR |
| 9520 | "Address family\n" |
| 9521 | "Address Family modifier\n" |
| 9522 | "Address Family modifier\n" |
| 9523 | "Display routes matching the communities\n" |
| 9524 | "community number\n" |
| 9525 | "Do not send outside local AS (well-known community)\n" |
| 9526 | "Do not advertise to any peer (well-known community)\n" |
| 9527 | "Do not export to next AS (well-known community)\n" |
| 9528 | "community number\n" |
| 9529 | "Do not send outside local AS (well-known community)\n" |
| 9530 | "Do not advertise to any peer (well-known community)\n" |
| 9531 | "Do not export to next AS (well-known community)\n" |
| 9532 | "community number\n" |
| 9533 | "Do not send outside local AS (well-known community)\n" |
| 9534 | "Do not advertise to any peer (well-known community)\n" |
| 9535 | "Do not export to next AS (well-known community)\n" |
| 9536 | "community number\n" |
| 9537 | "Do not send outside local AS (well-known community)\n" |
| 9538 | "Do not advertise to any peer (well-known community)\n" |
| 9539 | "Do not export to next AS (well-known community)\n" |
| 9540 | "Exact match of the communities") |
| 9541 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9542 | DEFUN (show_bgp_community, |
| 9543 | show_bgp_community_cmd, |
| 9544 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9545 | SHOW_STR |
| 9546 | BGP_STR |
| 9547 | "Display routes matching the communities\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 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9554 | } |
| 9555 | |
| 9556 | ALIAS (show_bgp_community, |
| 9557 | show_bgp_ipv6_community_cmd, |
| 9558 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 9559 | SHOW_STR |
| 9560 | BGP_STR |
| 9561 | "Address family\n" |
| 9562 | "Display routes matching the communities\n" |
| 9563 | "community number\n" |
| 9564 | "Do not send outside local AS (well-known community)\n" |
| 9565 | "Do not advertise to any peer (well-known community)\n" |
| 9566 | "Do not export to next AS (well-known community)\n") |
| 9567 | |
| 9568 | ALIAS (show_bgp_community, |
| 9569 | show_bgp_community2_cmd, |
| 9570 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9571 | SHOW_STR |
| 9572 | BGP_STR |
| 9573 | "Display routes matching the communities\n" |
| 9574 | "community number\n" |
| 9575 | "Do not send outside local AS (well-known community)\n" |
| 9576 | "Do not advertise to any peer (well-known community)\n" |
| 9577 | "Do not export to next AS (well-known community)\n" |
| 9578 | "community number\n" |
| 9579 | "Do not send outside local AS (well-known community)\n" |
| 9580 | "Do not advertise to any peer (well-known community)\n" |
| 9581 | "Do not export to next AS (well-known community)\n") |
| 9582 | |
| 9583 | ALIAS (show_bgp_community, |
| 9584 | show_bgp_ipv6_community2_cmd, |
| 9585 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9586 | SHOW_STR |
| 9587 | BGP_STR |
| 9588 | "Address family\n" |
| 9589 | "Display routes matching the communities\n" |
| 9590 | "community number\n" |
| 9591 | "Do not send outside local AS (well-known community)\n" |
| 9592 | "Do not advertise to any peer (well-known community)\n" |
| 9593 | "Do not export to next AS (well-known community)\n" |
| 9594 | "community number\n" |
| 9595 | "Do not send outside local AS (well-known community)\n" |
| 9596 | "Do not advertise to any peer (well-known community)\n" |
| 9597 | "Do not export to next AS (well-known community)\n") |
| 9598 | |
| 9599 | ALIAS (show_bgp_community, |
| 9600 | show_bgp_community3_cmd, |
| 9601 | "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)", |
| 9602 | SHOW_STR |
| 9603 | BGP_STR |
| 9604 | "Display routes matching the communities\n" |
| 9605 | "community number\n" |
| 9606 | "Do not send outside local AS (well-known community)\n" |
| 9607 | "Do not advertise to any peer (well-known community)\n" |
| 9608 | "Do not export to next AS (well-known community)\n" |
| 9609 | "community number\n" |
| 9610 | "Do not send outside local AS (well-known community)\n" |
| 9611 | "Do not advertise to any peer (well-known community)\n" |
| 9612 | "Do not export to next AS (well-known community)\n" |
| 9613 | "community number\n" |
| 9614 | "Do not send outside local AS (well-known community)\n" |
| 9615 | "Do not advertise to any peer (well-known community)\n" |
| 9616 | "Do not export to next AS (well-known community)\n") |
| 9617 | |
| 9618 | ALIAS (show_bgp_community, |
| 9619 | show_bgp_ipv6_community3_cmd, |
| 9620 | "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)", |
| 9621 | SHOW_STR |
| 9622 | BGP_STR |
| 9623 | "Address family\n" |
| 9624 | "Display routes matching the communities\n" |
| 9625 | "community number\n" |
| 9626 | "Do not send outside local AS (well-known community)\n" |
| 9627 | "Do not advertise to any peer (well-known community)\n" |
| 9628 | "Do not export to next AS (well-known community)\n" |
| 9629 | "community number\n" |
| 9630 | "Do not send outside local AS (well-known community)\n" |
| 9631 | "Do not advertise to any peer (well-known community)\n" |
| 9632 | "Do not export to next AS (well-known community)\n" |
| 9633 | "community number\n" |
| 9634 | "Do not send outside local AS (well-known community)\n" |
| 9635 | "Do not advertise to any peer (well-known community)\n" |
| 9636 | "Do not export to next AS (well-known community)\n") |
| 9637 | |
| 9638 | ALIAS (show_bgp_community, |
| 9639 | show_bgp_community4_cmd, |
| 9640 | "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)", |
| 9641 | SHOW_STR |
| 9642 | BGP_STR |
| 9643 | "Display routes matching the communities\n" |
| 9644 | "community number\n" |
| 9645 | "Do not send outside local AS (well-known community)\n" |
| 9646 | "Do not advertise to any peer (well-known community)\n" |
| 9647 | "Do not export to next AS (well-known community)\n" |
| 9648 | "community number\n" |
| 9649 | "Do not send outside local AS (well-known community)\n" |
| 9650 | "Do not advertise to any peer (well-known community)\n" |
| 9651 | "Do not export to next AS (well-known community)\n" |
| 9652 | "community number\n" |
| 9653 | "Do not send outside local AS (well-known community)\n" |
| 9654 | "Do not advertise to any peer (well-known community)\n" |
| 9655 | "Do not export to next AS (well-known community)\n" |
| 9656 | "community number\n" |
| 9657 | "Do not send outside local AS (well-known community)\n" |
| 9658 | "Do not advertise to any peer (well-known community)\n" |
| 9659 | "Do not export to next AS (well-known community)\n") |
| 9660 | |
| 9661 | ALIAS (show_bgp_community, |
| 9662 | show_bgp_ipv6_community4_cmd, |
| 9663 | "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)", |
| 9664 | SHOW_STR |
| 9665 | BGP_STR |
| 9666 | "Address family\n" |
| 9667 | "Display routes matching the communities\n" |
| 9668 | "community number\n" |
| 9669 | "Do not send outside local AS (well-known community)\n" |
| 9670 | "Do not advertise to any peer (well-known community)\n" |
| 9671 | "Do not export to next AS (well-known community)\n" |
| 9672 | "community number\n" |
| 9673 | "Do not send outside local AS (well-known community)\n" |
| 9674 | "Do not advertise to any peer (well-known community)\n" |
| 9675 | "Do not export to next AS (well-known community)\n" |
| 9676 | "community number\n" |
| 9677 | "Do not send outside local AS (well-known community)\n" |
| 9678 | "Do not advertise to any peer (well-known community)\n" |
| 9679 | "Do not export to next AS (well-known community)\n" |
| 9680 | "community number\n" |
| 9681 | "Do not send outside local AS (well-known community)\n" |
| 9682 | "Do not advertise to any peer (well-known community)\n" |
| 9683 | "Do not export to next AS (well-known community)\n") |
| 9684 | |
| 9685 | /* old command */ |
| 9686 | DEFUN (show_ipv6_bgp_community, |
| 9687 | show_ipv6_bgp_community_cmd, |
| 9688 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9689 | SHOW_STR |
| 9690 | IPV6_STR |
| 9691 | BGP_STR |
| 9692 | "Display routes matching the communities\n" |
| 9693 | "community number\n" |
| 9694 | "Do not send outside local AS (well-known community)\n" |
| 9695 | "Do not advertise to any peer (well-known community)\n" |
| 9696 | "Do not export to next AS (well-known community)\n") |
| 9697 | { |
| 9698 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9699 | } |
| 9700 | |
| 9701 | /* old command */ |
| 9702 | ALIAS (show_ipv6_bgp_community, |
| 9703 | show_ipv6_bgp_community2_cmd, |
| 9704 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9705 | SHOW_STR |
| 9706 | IPV6_STR |
| 9707 | BGP_STR |
| 9708 | "Display routes matching the communities\n" |
| 9709 | "community number\n" |
| 9710 | "Do not send outside local AS (well-known community)\n" |
| 9711 | "Do not advertise to any peer (well-known community)\n" |
| 9712 | "Do not export to next AS (well-known community)\n" |
| 9713 | "community number\n" |
| 9714 | "Do not send outside local AS (well-known community)\n" |
| 9715 | "Do not advertise to any peer (well-known community)\n" |
| 9716 | "Do not export to next AS (well-known community)\n") |
| 9717 | |
| 9718 | /* old command */ |
| 9719 | ALIAS (show_ipv6_bgp_community, |
| 9720 | show_ipv6_bgp_community3_cmd, |
| 9721 | "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)", |
| 9722 | SHOW_STR |
| 9723 | IPV6_STR |
| 9724 | BGP_STR |
| 9725 | "Display routes matching the communities\n" |
| 9726 | "community number\n" |
| 9727 | "Do not send outside local AS (well-known community)\n" |
| 9728 | "Do not advertise to any peer (well-known community)\n" |
| 9729 | "Do not export to next AS (well-known community)\n" |
| 9730 | "community number\n" |
| 9731 | "Do not send outside local AS (well-known community)\n" |
| 9732 | "Do not advertise to any peer (well-known community)\n" |
| 9733 | "Do not export to next AS (well-known community)\n" |
| 9734 | "community number\n" |
| 9735 | "Do not send outside local AS (well-known community)\n" |
| 9736 | "Do not advertise to any peer (well-known community)\n" |
| 9737 | "Do not export to next AS (well-known community)\n") |
| 9738 | |
| 9739 | /* old command */ |
| 9740 | ALIAS (show_ipv6_bgp_community, |
| 9741 | show_ipv6_bgp_community4_cmd, |
| 9742 | "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)", |
| 9743 | SHOW_STR |
| 9744 | IPV6_STR |
| 9745 | BGP_STR |
| 9746 | "Display routes matching the communities\n" |
| 9747 | "community number\n" |
| 9748 | "Do not send outside local AS (well-known community)\n" |
| 9749 | "Do not advertise to any peer (well-known community)\n" |
| 9750 | "Do not export to next AS (well-known community)\n" |
| 9751 | "community number\n" |
| 9752 | "Do not send outside local AS (well-known community)\n" |
| 9753 | "Do not advertise to any peer (well-known community)\n" |
| 9754 | "Do not export to next AS (well-known community)\n" |
| 9755 | "community number\n" |
| 9756 | "Do not send outside local AS (well-known community)\n" |
| 9757 | "Do not advertise to any peer (well-known community)\n" |
| 9758 | "Do not export to next AS (well-known community)\n" |
| 9759 | "community number\n" |
| 9760 | "Do not send outside local AS (well-known community)\n" |
| 9761 | "Do not advertise to any peer (well-known community)\n" |
| 9762 | "Do not export to next AS (well-known community)\n") |
| 9763 | |
| 9764 | DEFUN (show_bgp_community_exact, |
| 9765 | show_bgp_community_exact_cmd, |
| 9766 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9767 | SHOW_STR |
| 9768 | BGP_STR |
| 9769 | "Display routes matching the communities\n" |
| 9770 | "community number\n" |
| 9771 | "Do not send outside local AS (well-known community)\n" |
| 9772 | "Do not advertise to any peer (well-known community)\n" |
| 9773 | "Do not export to next AS (well-known community)\n" |
| 9774 | "Exact match of the communities") |
| 9775 | { |
| 9776 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 9777 | } |
| 9778 | |
| 9779 | ALIAS (show_bgp_community_exact, |
| 9780 | show_bgp_ipv6_community_exact_cmd, |
| 9781 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9782 | SHOW_STR |
| 9783 | BGP_STR |
| 9784 | "Address family\n" |
| 9785 | "Display routes matching the communities\n" |
| 9786 | "community number\n" |
| 9787 | "Do not send outside local AS (well-known community)\n" |
| 9788 | "Do not advertise to any peer (well-known community)\n" |
| 9789 | "Do not export to next AS (well-known community)\n" |
| 9790 | "Exact match of the communities") |
| 9791 | |
| 9792 | ALIAS (show_bgp_community_exact, |
| 9793 | show_bgp_community2_exact_cmd, |
| 9794 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9795 | SHOW_STR |
| 9796 | BGP_STR |
| 9797 | "Display routes matching the communities\n" |
| 9798 | "community number\n" |
| 9799 | "Do not send outside local AS (well-known community)\n" |
| 9800 | "Do not advertise to any peer (well-known community)\n" |
| 9801 | "Do not export to next AS (well-known community)\n" |
| 9802 | "community number\n" |
| 9803 | "Do not send outside local AS (well-known community)\n" |
| 9804 | "Do not advertise to any peer (well-known community)\n" |
| 9805 | "Do not export to next AS (well-known community)\n" |
| 9806 | "Exact match of the communities") |
| 9807 | |
| 9808 | ALIAS (show_bgp_community_exact, |
| 9809 | show_bgp_ipv6_community2_exact_cmd, |
| 9810 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9811 | SHOW_STR |
| 9812 | BGP_STR |
| 9813 | "Address family\n" |
| 9814 | "Display routes matching the communities\n" |
| 9815 | "community number\n" |
| 9816 | "Do not send outside local AS (well-known community)\n" |
| 9817 | "Do not advertise to any peer (well-known community)\n" |
| 9818 | "Do not export to next AS (well-known community)\n" |
| 9819 | "community number\n" |
| 9820 | "Do not send outside local AS (well-known community)\n" |
| 9821 | "Do not advertise to any peer (well-known community)\n" |
| 9822 | "Do not export to next AS (well-known community)\n" |
| 9823 | "Exact match of the communities") |
| 9824 | |
| 9825 | ALIAS (show_bgp_community_exact, |
| 9826 | show_bgp_community3_exact_cmd, |
| 9827 | "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", |
| 9828 | SHOW_STR |
| 9829 | BGP_STR |
| 9830 | "Display routes matching the communities\n" |
| 9831 | "community number\n" |
| 9832 | "Do not send outside local AS (well-known community)\n" |
| 9833 | "Do not advertise to any peer (well-known community)\n" |
| 9834 | "Do not export to next AS (well-known community)\n" |
| 9835 | "community number\n" |
| 9836 | "Do not send outside local AS (well-known community)\n" |
| 9837 | "Do not advertise to any peer (well-known community)\n" |
| 9838 | "Do not export to next AS (well-known community)\n" |
| 9839 | "community number\n" |
| 9840 | "Do not send outside local AS (well-known community)\n" |
| 9841 | "Do not advertise to any peer (well-known community)\n" |
| 9842 | "Do not export to next AS (well-known community)\n" |
| 9843 | "Exact match of the communities") |
| 9844 | |
| 9845 | ALIAS (show_bgp_community_exact, |
| 9846 | show_bgp_ipv6_community3_exact_cmd, |
| 9847 | "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", |
| 9848 | SHOW_STR |
| 9849 | BGP_STR |
| 9850 | "Address family\n" |
| 9851 | "Display routes matching the communities\n" |
| 9852 | "community number\n" |
| 9853 | "Do not send outside local AS (well-known community)\n" |
| 9854 | "Do not advertise to any peer (well-known community)\n" |
| 9855 | "Do not export to next AS (well-known community)\n" |
| 9856 | "community number\n" |
| 9857 | "Do not send outside local AS (well-known community)\n" |
| 9858 | "Do not advertise to any peer (well-known community)\n" |
| 9859 | "Do not export to next AS (well-known community)\n" |
| 9860 | "community number\n" |
| 9861 | "Do not send outside local AS (well-known community)\n" |
| 9862 | "Do not advertise to any peer (well-known community)\n" |
| 9863 | "Do not export to next AS (well-known community)\n" |
| 9864 | "Exact match of the communities") |
| 9865 | |
| 9866 | ALIAS (show_bgp_community_exact, |
| 9867 | show_bgp_community4_exact_cmd, |
| 9868 | "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", |
| 9869 | SHOW_STR |
| 9870 | BGP_STR |
| 9871 | "Display routes matching the communities\n" |
| 9872 | "community number\n" |
| 9873 | "Do not send outside local AS (well-known community)\n" |
| 9874 | "Do not advertise to any peer (well-known community)\n" |
| 9875 | "Do not export to next AS (well-known community)\n" |
| 9876 | "community number\n" |
| 9877 | "Do not send outside local AS (well-known community)\n" |
| 9878 | "Do not advertise to any peer (well-known community)\n" |
| 9879 | "Do not export to next AS (well-known community)\n" |
| 9880 | "community number\n" |
| 9881 | "Do not send outside local AS (well-known community)\n" |
| 9882 | "Do not advertise to any peer (well-known community)\n" |
| 9883 | "Do not export to next AS (well-known community)\n" |
| 9884 | "community number\n" |
| 9885 | "Do not send outside local AS (well-known community)\n" |
| 9886 | "Do not advertise to any peer (well-known community)\n" |
| 9887 | "Do not export to next AS (well-known community)\n" |
| 9888 | "Exact match of the communities") |
| 9889 | |
| 9890 | ALIAS (show_bgp_community_exact, |
| 9891 | show_bgp_ipv6_community4_exact_cmd, |
| 9892 | "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", |
| 9893 | SHOW_STR |
| 9894 | BGP_STR |
| 9895 | "Address family\n" |
| 9896 | "Display routes matching the communities\n" |
| 9897 | "community number\n" |
| 9898 | "Do not send outside local AS (well-known community)\n" |
| 9899 | "Do not advertise to any peer (well-known community)\n" |
| 9900 | "Do not export to next AS (well-known community)\n" |
| 9901 | "community number\n" |
| 9902 | "Do not send outside local AS (well-known community)\n" |
| 9903 | "Do not advertise to any peer (well-known community)\n" |
| 9904 | "Do not export to next AS (well-known community)\n" |
| 9905 | "community number\n" |
| 9906 | "Do not send outside local AS (well-known community)\n" |
| 9907 | "Do not advertise to any peer (well-known community)\n" |
| 9908 | "Do not export to next AS (well-known community)\n" |
| 9909 | "community number\n" |
| 9910 | "Do not send outside local AS (well-known community)\n" |
| 9911 | "Do not advertise to any peer (well-known community)\n" |
| 9912 | "Do not export to next AS (well-known community)\n" |
| 9913 | "Exact match of the communities") |
| 9914 | |
| 9915 | /* old command */ |
| 9916 | DEFUN (show_ipv6_bgp_community_exact, |
| 9917 | show_ipv6_bgp_community_exact_cmd, |
| 9918 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9919 | SHOW_STR |
| 9920 | IPV6_STR |
| 9921 | BGP_STR |
| 9922 | "Display routes matching the communities\n" |
| 9923 | "community number\n" |
| 9924 | "Do not send outside local AS (well-known community)\n" |
| 9925 | "Do not advertise to any peer (well-known community)\n" |
| 9926 | "Do not export to next AS (well-known community)\n" |
| 9927 | "Exact match of the communities") |
| 9928 | { |
| 9929 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 9930 | } |
| 9931 | |
| 9932 | /* old command */ |
| 9933 | ALIAS (show_ipv6_bgp_community_exact, |
| 9934 | show_ipv6_bgp_community2_exact_cmd, |
| 9935 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9936 | SHOW_STR |
| 9937 | IPV6_STR |
| 9938 | BGP_STR |
| 9939 | "Display routes matching the communities\n" |
| 9940 | "community number\n" |
| 9941 | "Do not send outside local AS (well-known community)\n" |
| 9942 | "Do not advertise to any peer (well-known community)\n" |
| 9943 | "Do not export to next AS (well-known community)\n" |
| 9944 | "community number\n" |
| 9945 | "Do not send outside local AS (well-known community)\n" |
| 9946 | "Do not advertise to any peer (well-known community)\n" |
| 9947 | "Do not export to next AS (well-known community)\n" |
| 9948 | "Exact match of the communities") |
| 9949 | |
| 9950 | /* old command */ |
| 9951 | ALIAS (show_ipv6_bgp_community_exact, |
| 9952 | show_ipv6_bgp_community3_exact_cmd, |
| 9953 | "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", |
| 9954 | SHOW_STR |
| 9955 | IPV6_STR |
| 9956 | BGP_STR |
| 9957 | "Display routes matching the communities\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 | "community number\n" |
| 9967 | "Do not send outside local AS (well-known community)\n" |
| 9968 | "Do not advertise to any peer (well-known community)\n" |
| 9969 | "Do not export to next AS (well-known community)\n" |
| 9970 | "Exact match of the communities") |
| 9971 | |
| 9972 | /* old command */ |
| 9973 | ALIAS (show_ipv6_bgp_community_exact, |
| 9974 | show_ipv6_bgp_community4_exact_cmd, |
| 9975 | "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", |
| 9976 | SHOW_STR |
| 9977 | IPV6_STR |
| 9978 | BGP_STR |
| 9979 | "Display routes matching the communities\n" |
| 9980 | "community number\n" |
| 9981 | "Do not send outside local AS (well-known community)\n" |
| 9982 | "Do not advertise to any peer (well-known community)\n" |
| 9983 | "Do not export to next AS (well-known community)\n" |
| 9984 | "community number\n" |
| 9985 | "Do not send outside local AS (well-known community)\n" |
| 9986 | "Do not advertise to any peer (well-known community)\n" |
| 9987 | "Do not export to next AS (well-known community)\n" |
| 9988 | "community number\n" |
| 9989 | "Do not send outside local AS (well-known community)\n" |
| 9990 | "Do not advertise to any peer (well-known community)\n" |
| 9991 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 9997 | |
| 9998 | /* old command */ |
| 9999 | DEFUN (show_ipv6_mbgp_community, |
| 10000 | show_ipv6_mbgp_community_cmd, |
| 10001 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 10002 | SHOW_STR |
| 10003 | IPV6_STR |
| 10004 | MBGP_STR |
| 10005 | "Display routes matching the communities\n" |
| 10006 | "community number\n" |
| 10007 | "Do not send outside local AS (well-known community)\n" |
| 10008 | "Do not advertise to any peer (well-known community)\n" |
| 10009 | "Do not export to next AS (well-known community)\n") |
| 10010 | { |
| 10011 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 10012 | } |
| 10013 | |
| 10014 | /* old command */ |
| 10015 | ALIAS (show_ipv6_mbgp_community, |
| 10016 | show_ipv6_mbgp_community2_cmd, |
| 10017 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 10018 | SHOW_STR |
| 10019 | IPV6_STR |
| 10020 | MBGP_STR |
| 10021 | "Display routes matching the communities\n" |
| 10022 | "community number\n" |
| 10023 | "Do not send outside local AS (well-known community)\n" |
| 10024 | "Do not advertise to any peer (well-known community)\n" |
| 10025 | "Do not export to next AS (well-known community)\n" |
| 10026 | "community number\n" |
| 10027 | "Do not send outside local AS (well-known community)\n" |
| 10028 | "Do not advertise to any peer (well-known community)\n" |
| 10029 | "Do not export to next AS (well-known community)\n") |
| 10030 | |
| 10031 | /* old command */ |
| 10032 | ALIAS (show_ipv6_mbgp_community, |
| 10033 | show_ipv6_mbgp_community3_cmd, |
| 10034 | "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)", |
| 10035 | SHOW_STR |
| 10036 | IPV6_STR |
| 10037 | MBGP_STR |
| 10038 | "Display routes matching the communities\n" |
| 10039 | "community number\n" |
| 10040 | "Do not send outside local AS (well-known community)\n" |
| 10041 | "Do not advertise to any peer (well-known community)\n" |
| 10042 | "Do not export to next AS (well-known community)\n" |
| 10043 | "community number\n" |
| 10044 | "Do not send outside local AS (well-known community)\n" |
| 10045 | "Do not advertise to any peer (well-known community)\n" |
| 10046 | "Do not export to next AS (well-known community)\n" |
| 10047 | "community number\n" |
| 10048 | "Do not send outside local AS (well-known community)\n" |
| 10049 | "Do not advertise to any peer (well-known community)\n" |
| 10050 | "Do not export to next AS (well-known community)\n") |
| 10051 | |
| 10052 | /* old command */ |
| 10053 | ALIAS (show_ipv6_mbgp_community, |
| 10054 | show_ipv6_mbgp_community4_cmd, |
| 10055 | "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)", |
| 10056 | SHOW_STR |
| 10057 | IPV6_STR |
| 10058 | MBGP_STR |
| 10059 | "Display routes matching the communities\n" |
| 10060 | "community number\n" |
| 10061 | "Do not send outside local AS (well-known community)\n" |
| 10062 | "Do not advertise to any peer (well-known community)\n" |
| 10063 | "Do not export to next AS (well-known community)\n" |
| 10064 | "community number\n" |
| 10065 | "Do not send outside local AS (well-known community)\n" |
| 10066 | "Do not advertise to any peer (well-known community)\n" |
| 10067 | "Do not export to next AS (well-known community)\n" |
| 10068 | "community number\n" |
| 10069 | "Do not send outside local AS (well-known community)\n" |
| 10070 | "Do not advertise to any peer (well-known community)\n" |
| 10071 | "Do not export to next AS (well-known community)\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 | |
| 10077 | /* old command */ |
| 10078 | DEFUN (show_ipv6_mbgp_community_exact, |
| 10079 | show_ipv6_mbgp_community_exact_cmd, |
| 10080 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10081 | SHOW_STR |
| 10082 | IPV6_STR |
| 10083 | MBGP_STR |
| 10084 | "Display routes matching the communities\n" |
| 10085 | "community number\n" |
| 10086 | "Do not send outside local AS (well-known community)\n" |
| 10087 | "Do not advertise to any peer (well-known community)\n" |
| 10088 | "Do not export to next AS (well-known community)\n" |
| 10089 | "Exact match of the communities") |
| 10090 | { |
| 10091 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 10092 | } |
| 10093 | |
| 10094 | /* old command */ |
| 10095 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10096 | show_ipv6_mbgp_community2_exact_cmd, |
| 10097 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10098 | SHOW_STR |
| 10099 | IPV6_STR |
| 10100 | MBGP_STR |
| 10101 | "Display routes matching the communities\n" |
| 10102 | "community number\n" |
| 10103 | "Do not send outside local AS (well-known community)\n" |
| 10104 | "Do not advertise to any peer (well-known community)\n" |
| 10105 | "Do not export to next AS (well-known community)\n" |
| 10106 | "community number\n" |
| 10107 | "Do not send outside local AS (well-known community)\n" |
| 10108 | "Do not advertise to any peer (well-known community)\n" |
| 10109 | "Do not export to next AS (well-known community)\n" |
| 10110 | "Exact match of the communities") |
| 10111 | |
| 10112 | /* old command */ |
| 10113 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10114 | show_ipv6_mbgp_community3_exact_cmd, |
| 10115 | "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", |
| 10116 | SHOW_STR |
| 10117 | IPV6_STR |
| 10118 | MBGP_STR |
| 10119 | "Display routes matching the communities\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 | "community number\n" |
| 10129 | "Do not send outside local AS (well-known community)\n" |
| 10130 | "Do not advertise to any peer (well-known community)\n" |
| 10131 | "Do not export to next AS (well-known community)\n" |
| 10132 | "Exact match of the communities") |
| 10133 | |
| 10134 | /* old command */ |
| 10135 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10136 | show_ipv6_mbgp_community4_exact_cmd, |
| 10137 | "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", |
| 10138 | SHOW_STR |
| 10139 | IPV6_STR |
| 10140 | MBGP_STR |
| 10141 | "Display routes matching the communities\n" |
| 10142 | "community number\n" |
| 10143 | "Do not send outside local AS (well-known community)\n" |
| 10144 | "Do not advertise to any peer (well-known community)\n" |
| 10145 | "Do not export to next AS (well-known community)\n" |
| 10146 | "community number\n" |
| 10147 | "Do not send outside local AS (well-known community)\n" |
| 10148 | "Do not advertise to any peer (well-known community)\n" |
| 10149 | "Do not export to next AS (well-known community)\n" |
| 10150 | "community number\n" |
| 10151 | "Do not send outside local AS (well-known community)\n" |
| 10152 | "Do not advertise to any peer (well-known community)\n" |
| 10153 | "Do not export to next AS (well-known community)\n" |
| 10154 | "community number\n" |
| 10155 | "Do not send outside local AS (well-known community)\n" |
| 10156 | "Do not advertise to any peer (well-known community)\n" |
| 10157 | "Do not export to next AS (well-known community)\n" |
| 10158 | "Exact match of the communities") |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10159 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10160 | DEFUN (show_bgp_ipv4_community, |
| 10161 | show_bgp_ipv4_community_cmd, |
| 10162 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10163 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10164 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10165 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10166 | "Display routes matching the communities\n" |
| 10167 | "community number\n" |
| 10168 | "Do not send outside local AS (well-known community)\n" |
| 10169 | "Do not advertise to any peer (well-known community)\n" |
| 10170 | "Do not export to next AS (well-known community)\n") |
| 10171 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10172 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10173 | } |
| 10174 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10175 | ALIAS (show_bgp_ipv4_community, |
| 10176 | show_bgp_ipv4_community2_cmd, |
| 10177 | "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] | 10178 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10179 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10180 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10181 | "Display routes matching the communities\n" |
| 10182 | "community number\n" |
| 10183 | "Do not send outside local AS (well-known community)\n" |
| 10184 | "Do not advertise to any peer (well-known community)\n" |
| 10185 | "Do not export to next AS (well-known community)\n" |
| 10186 | "community number\n" |
| 10187 | "Do not send outside local AS (well-known community)\n" |
| 10188 | "Do not advertise to any peer (well-known community)\n" |
| 10189 | "Do not export to next AS (well-known community)\n") |
| 10190 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10191 | ALIAS (show_bgp_ipv4_community, |
| 10192 | show_bgp_ipv4_community3_cmd, |
| 10193 | "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] | 10194 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10195 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10196 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10197 | "Display routes matching the communities\n" |
| 10198 | "community number\n" |
| 10199 | "Do not send outside local AS (well-known community)\n" |
| 10200 | "Do not advertise to any peer (well-known community)\n" |
| 10201 | "Do not export to next AS (well-known community)\n" |
| 10202 | "community number\n" |
| 10203 | "Do not send outside local AS (well-known community)\n" |
| 10204 | "Do not advertise to any peer (well-known community)\n" |
| 10205 | "Do not export to next AS (well-known community)\n" |
| 10206 | "community number\n" |
| 10207 | "Do not send outside local AS (well-known community)\n" |
| 10208 | "Do not advertise to any peer (well-known community)\n" |
| 10209 | "Do not export to next AS (well-known community)\n") |
| 10210 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10211 | ALIAS (show_bgp_ipv4_community, |
| 10212 | show_bgp_ipv4_community4_cmd, |
| 10213 | "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] | 10214 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10215 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10216 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10217 | "Display routes matching the communities\n" |
| 10218 | "community number\n" |
| 10219 | "Do not send outside local AS (well-known community)\n" |
| 10220 | "Do not advertise to any peer (well-known community)\n" |
| 10221 | "Do not export to next AS (well-known community)\n" |
| 10222 | "community number\n" |
| 10223 | "Do not send outside local AS (well-known community)\n" |
| 10224 | "Do not advertise to any peer (well-known community)\n" |
| 10225 | "Do not export to next AS (well-known community)\n" |
| 10226 | "community number\n" |
| 10227 | "Do not send outside local AS (well-known community)\n" |
| 10228 | "Do not advertise to any peer (well-known community)\n" |
| 10229 | "Do not export to next AS (well-known community)\n" |
| 10230 | "community number\n" |
| 10231 | "Do not send outside local AS (well-known community)\n" |
| 10232 | "Do not advertise to any peer (well-known community)\n" |
| 10233 | "Do not export to next AS (well-known community)\n") |
| 10234 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10235 | DEFUN (show_bgp_ipv4_safi_community, |
| 10236 | show_bgp_ipv4_safi_community_cmd, |
| 10237 | "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] | 10238 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10239 | BGP_STR |
| 10240 | "Address family\n" |
| 10241 | "Address Family modifier\n" |
| 10242 | "Address Family modifier\n" |
| 10243 | "Display routes matching the communities\n" |
| 10244 | "community number\n" |
| 10245 | "Do not send outside local AS (well-known community)\n" |
| 10246 | "Do not advertise to any peer (well-known community)\n" |
| 10247 | "Do not export to next AS (well-known community)\n") |
| 10248 | { |
| 10249 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10250 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10251 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10252 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10253 | } |
| 10254 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10255 | ALIAS (show_bgp_ipv4_safi_community, |
| 10256 | show_bgp_ipv4_safi_community2_cmd, |
| 10257 | "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] | 10258 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10259 | BGP_STR |
| 10260 | "Address family\n" |
| 10261 | "Address Family modifier\n" |
| 10262 | "Address Family modifier\n" |
| 10263 | "Display routes matching the communities\n" |
| 10264 | "community number\n" |
| 10265 | "Do not send outside local AS (well-known community)\n" |
| 10266 | "Do not advertise to any peer (well-known community)\n" |
| 10267 | "Do not export to next AS (well-known community)\n" |
| 10268 | "community number\n" |
| 10269 | "Do not send outside local AS (well-known community)\n" |
| 10270 | "Do not advertise to any peer (well-known community)\n" |
| 10271 | "Do not export to next AS (well-known community)\n") |
| 10272 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10273 | ALIAS (show_bgp_ipv4_safi_community, |
| 10274 | show_bgp_ipv4_safi_community3_cmd, |
| 10275 | "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] | 10276 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10277 | BGP_STR |
| 10278 | "Address family\n" |
| 10279 | "Address Family modifier\n" |
| 10280 | "Address Family modifier\n" |
| 10281 | "Display routes matching the communities\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 | "community number\n" |
| 10291 | "Do not send outside local AS (well-known community)\n" |
| 10292 | "Do not advertise to any peer (well-known community)\n" |
| 10293 | "Do not export to next AS (well-known community)\n") |
| 10294 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10295 | ALIAS (show_bgp_ipv4_safi_community, |
| 10296 | show_bgp_ipv4_safi_community4_cmd, |
| 10297 | "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] | 10298 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10299 | BGP_STR |
| 10300 | "Address family\n" |
| 10301 | "Address Family modifier\n" |
| 10302 | "Address Family modifier\n" |
| 10303 | "Display routes matching the communities\n" |
| 10304 | "community number\n" |
| 10305 | "Do not send outside local AS (well-known community)\n" |
| 10306 | "Do not advertise to any peer (well-known community)\n" |
| 10307 | "Do not export to next AS (well-known community)\n" |
| 10308 | "community number\n" |
| 10309 | "Do not send outside local AS (well-known community)\n" |
| 10310 | "Do not advertise to any peer (well-known community)\n" |
| 10311 | "Do not export to next AS (well-known community)\n" |
| 10312 | "community number\n" |
| 10313 | "Do not send outside local AS (well-known community)\n" |
| 10314 | "Do not advertise to any peer (well-known community)\n" |
| 10315 | "Do not export to next AS (well-known community)\n" |
| 10316 | "community number\n" |
| 10317 | "Do not send outside local AS (well-known community)\n" |
| 10318 | "Do not advertise to any peer (well-known community)\n" |
| 10319 | "Do not export to next AS (well-known community)\n") |
| 10320 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10321 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 10322 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10323 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
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" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10332 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10333 | { |
| 10334 | int afi; |
| 10335 | int safi; |
| 10336 | struct bgp *bgp; |
| 10337 | |
| 10338 | /* BGP structure lookup. */ |
| 10339 | bgp = bgp_lookup_by_name (argv[0]); |
| 10340 | if (bgp == NULL) |
| 10341 | { |
| 10342 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10343 | return CMD_WARNING; |
| 10344 | } |
| 10345 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10346 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10347 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10348 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 10349 | } |
| 10350 | |
| 10351 | DEFUN (show_bgp_view_afi_safi_community, |
| 10352 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10353 | "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] | 10354 | SHOW_STR |
| 10355 | BGP_STR |
| 10356 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10357 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10358 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10359 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10360 | "Address family modifier\n" |
| 10361 | "Address family modifier\n" |
| 10362 | "Display routes matching the communities\n" |
| 10363 | "community number\n" |
| 10364 | "Do not send outside local AS (well-known community)\n" |
| 10365 | "Do not advertise to any peer (well-known community)\n" |
| 10366 | "Do not export to next AS (well-known community)\n") |
| 10367 | { |
| 10368 | int afi; |
| 10369 | int safi; |
| 10370 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10371 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10372 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10373 | 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] | 10374 | } |
| 10375 | |
| 10376 | ALIAS (show_bgp_view_afi_safi_community, |
| 10377 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10378 | "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] | 10379 | SHOW_STR |
| 10380 | BGP_STR |
| 10381 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10382 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10383 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10384 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10385 | "Address family modifier\n" |
| 10386 | "Address family modifier\n" |
| 10387 | "Display routes matching the communities\n" |
| 10388 | "community number\n" |
| 10389 | "Do not send outside local AS (well-known community)\n" |
| 10390 | "Do not advertise to any peer (well-known community)\n" |
| 10391 | "Do not export to next AS (well-known community)\n" |
| 10392 | "community number\n" |
| 10393 | "Do not send outside local AS (well-known community)\n" |
| 10394 | "Do not advertise to any peer (well-known community)\n" |
| 10395 | "Do not export to next AS (well-known community)\n") |
| 10396 | |
| 10397 | ALIAS (show_bgp_view_afi_safi_community, |
| 10398 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10399 | "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] | 10400 | SHOW_STR |
| 10401 | BGP_STR |
| 10402 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10403 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10404 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10405 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10406 | "Address family modifier\n" |
| 10407 | "Address family modifier\n" |
| 10408 | "Display routes matching the communities\n" |
| 10409 | "community number\n" |
| 10410 | "Do not send outside local AS (well-known community)\n" |
| 10411 | "Do not advertise to any peer (well-known community)\n" |
| 10412 | "Do not export to next AS (well-known community)\n" |
| 10413 | "community number\n" |
| 10414 | "Do not send outside local AS (well-known community)\n" |
| 10415 | "Do not advertise to any peer (well-known community)\n" |
| 10416 | "Do not export to next AS (well-known community)\n" |
| 10417 | "community number\n" |
| 10418 | "Do not send outside local AS (well-known community)\n" |
| 10419 | "Do not advertise to any peer (well-known community)\n" |
| 10420 | "Do not export to next AS (well-known community)\n") |
| 10421 | |
| 10422 | ALIAS (show_bgp_view_afi_safi_community, |
| 10423 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10424 | "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] | 10425 | SHOW_STR |
| 10426 | BGP_STR |
| 10427 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10428 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10429 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10430 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10431 | "Address family modifier\n" |
| 10432 | "Address family modifier\n" |
| 10433 | "Display routes matching the communities\n" |
| 10434 | "community number\n" |
| 10435 | "Do not send outside local AS (well-known community)\n" |
| 10436 | "Do not advertise to any peer (well-known community)\n" |
| 10437 | "Do not export to next AS (well-known community)\n" |
| 10438 | "community number\n" |
| 10439 | "Do not send outside local AS (well-known community)\n" |
| 10440 | "Do not advertise to any peer (well-known community)\n" |
| 10441 | "Do not export to next AS (well-known community)\n" |
| 10442 | "community number\n" |
| 10443 | "Do not send outside local AS (well-known community)\n" |
| 10444 | "Do not advertise to any peer (well-known community)\n" |
| 10445 | "Do not export to next AS (well-known community)\n" |
| 10446 | "community number\n" |
| 10447 | "Do not send outside local AS (well-known community)\n" |
| 10448 | "Do not advertise to any peer (well-known community)\n" |
| 10449 | "Do not export to next AS (well-known community)\n") |
| 10450 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10451 | DEFUN (show_bgp_ipv4_community_exact, |
| 10452 | show_bgp_ipv4_community_exact_cmd, |
| 10453 | "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] | 10454 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10455 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10456 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10457 | "Display routes matching the communities\n" |
| 10458 | "community number\n" |
| 10459 | "Do not send outside local AS (well-known community)\n" |
| 10460 | "Do not advertise to any peer (well-known community)\n" |
| 10461 | "Do not export to next AS (well-known community)\n" |
| 10462 | "Exact match of the communities") |
| 10463 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10464 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10465 | } |
| 10466 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10467 | ALIAS (show_bgp_ipv4_community_exact, |
| 10468 | show_bgp_ipv4_community2_exact_cmd, |
| 10469 | "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] | 10470 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10471 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10472 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10473 | "Display routes matching the communities\n" |
| 10474 | "community number\n" |
| 10475 | "Do not send outside local AS (well-known community)\n" |
| 10476 | "Do not advertise to any peer (well-known community)\n" |
| 10477 | "Do not export to next AS (well-known community)\n" |
| 10478 | "community number\n" |
| 10479 | "Do not send outside local AS (well-known community)\n" |
| 10480 | "Do not advertise to any peer (well-known community)\n" |
| 10481 | "Do not export to next AS (well-known community)\n" |
| 10482 | "Exact match of the communities") |
| 10483 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10484 | ALIAS (show_bgp_ipv4_community_exact, |
| 10485 | show_bgp_ipv4_community3_exact_cmd, |
| 10486 | "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] | 10487 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10488 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10489 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10490 | "Display routes matching the communities\n" |
| 10491 | "community number\n" |
| 10492 | "Do not send outside local AS (well-known community)\n" |
| 10493 | "Do not advertise to any peer (well-known community)\n" |
| 10494 | "Do not export to next AS (well-known community)\n" |
| 10495 | "community number\n" |
| 10496 | "Do not send outside local AS (well-known community)\n" |
| 10497 | "Do not advertise to any peer (well-known community)\n" |
| 10498 | "Do not export to next AS (well-known community)\n" |
| 10499 | "community number\n" |
| 10500 | "Do not send outside local AS (well-known community)\n" |
| 10501 | "Do not advertise to any peer (well-known community)\n" |
| 10502 | "Do not export to next AS (well-known community)\n" |
| 10503 | "Exact match of the communities") |
| 10504 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10505 | ALIAS (show_bgp_ipv4_community_exact, |
| 10506 | show_bgp_ipv4_community4_exact_cmd, |
| 10507 | "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] | 10508 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10509 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10510 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10511 | "Display routes matching the communities\n" |
| 10512 | "community number\n" |
| 10513 | "Do not send outside local AS (well-known community)\n" |
| 10514 | "Do not advertise to any peer (well-known community)\n" |
| 10515 | "Do not export to next AS (well-known community)\n" |
| 10516 | "community number\n" |
| 10517 | "Do not send outside local AS (well-known community)\n" |
| 10518 | "Do not advertise to any peer (well-known community)\n" |
| 10519 | "Do not export to next AS (well-known community)\n" |
| 10520 | "community number\n" |
| 10521 | "Do not send outside local AS (well-known community)\n" |
| 10522 | "Do not advertise to any peer (well-known community)\n" |
| 10523 | "Do not export to next AS (well-known community)\n" |
| 10524 | "community number\n" |
| 10525 | "Do not send outside local AS (well-known community)\n" |
| 10526 | "Do not advertise to any peer (well-known community)\n" |
| 10527 | "Do not export to next AS (well-known community)\n" |
| 10528 | "Exact match of the communities") |
| 10529 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10530 | DEFUN (show_bgp_ipv4_safi_community4_exact, |
| 10531 | show_bgp_ipv4_safi_community_exact_cmd, |
| 10532 | "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] | 10533 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10534 | BGP_STR |
| 10535 | "Address family\n" |
| 10536 | "Address Family modifier\n" |
| 10537 | "Address Family modifier\n" |
| 10538 | "Display routes matching the communities\n" |
| 10539 | "community number\n" |
| 10540 | "Do not send outside local AS (well-known community)\n" |
| 10541 | "Do not advertise to any peer (well-known community)\n" |
| 10542 | "Do not export to next AS (well-known community)\n" |
| 10543 | "Exact match of the communities") |
| 10544 | { |
| 10545 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10546 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10547 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10548 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10549 | } |
| 10550 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10551 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10552 | show_bgp_ipv4_safi_community2_exact_cmd, |
| 10553 | "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] | 10554 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10555 | BGP_STR |
| 10556 | "Address family\n" |
| 10557 | "Address Family modifier\n" |
| 10558 | "Address Family modifier\n" |
| 10559 | "Display routes matching the communities\n" |
| 10560 | "community number\n" |
| 10561 | "Do not send outside local AS (well-known community)\n" |
| 10562 | "Do not advertise to any peer (well-known community)\n" |
| 10563 | "Do not export to next AS (well-known community)\n" |
| 10564 | "community number\n" |
| 10565 | "Do not send outside local AS (well-known community)\n" |
| 10566 | "Do not advertise to any peer (well-known community)\n" |
| 10567 | "Do not export to next AS (well-known community)\n" |
| 10568 | "Exact match of the communities") |
| 10569 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10570 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10571 | show_bgp_ipv4_safi_community3_exact_cmd, |
| 10572 | "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] | 10573 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10574 | BGP_STR |
| 10575 | "Address family\n" |
| 10576 | "Address Family modifier\n" |
| 10577 | "Address Family modifier\n" |
| 10578 | "Display routes matching the communities\n" |
| 10579 | "community number\n" |
| 10580 | "Do not send outside local AS (well-known community)\n" |
| 10581 | "Do not advertise to any peer (well-known community)\n" |
| 10582 | "Do not export to next AS (well-known community)\n" |
| 10583 | "community number\n" |
| 10584 | "Do not send outside local AS (well-known community)\n" |
| 10585 | "Do not advertise to any peer (well-known community)\n" |
| 10586 | "Do not export to next AS (well-known community)\n" |
| 10587 | "community number\n" |
| 10588 | "Do not send outside local AS (well-known community)\n" |
| 10589 | "Do not advertise to any peer (well-known community)\n" |
| 10590 | "Do not export to next AS (well-known community)\n" |
| 10591 | "Exact match of the communities") |
| 10592 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10593 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10594 | show_bgp_ipv4_safi_community4_exact_cmd, |
| 10595 | "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] | 10596 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10597 | BGP_STR |
| 10598 | "Address family\n" |
| 10599 | "Address Family modifier\n" |
| 10600 | "Address Family modifier\n" |
| 10601 | "Display routes matching the communities\n" |
| 10602 | "community number\n" |
| 10603 | "Do not send outside local AS (well-known community)\n" |
| 10604 | "Do not advertise to any peer (well-known community)\n" |
| 10605 | "Do not export to next AS (well-known community)\n" |
| 10606 | "community number\n" |
| 10607 | "Do not send outside local AS (well-known community)\n" |
| 10608 | "Do not advertise to any peer (well-known community)\n" |
| 10609 | "Do not export to next AS (well-known community)\n" |
| 10610 | "community number\n" |
| 10611 | "Do not send outside local AS (well-known community)\n" |
| 10612 | "Do not advertise to any peer (well-known community)\n" |
| 10613 | "Do not export to next AS (well-known community)\n" |
| 10614 | "community number\n" |
| 10615 | "Do not send outside local AS (well-known community)\n" |
| 10616 | "Do not advertise to any peer (well-known community)\n" |
| 10617 | "Do not export to next AS (well-known community)\n" |
| 10618 | "Exact match of the communities") |
| 10619 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10620 | DEFUN (show_bgp_ipv6_safi_community, |
| 10621 | show_bgp_ipv6_safi_community_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10622 | "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] | 10623 | SHOW_STR |
| 10624 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10625 | "Address family\n" |
| 10626 | "Address family modifier\n" |
| 10627 | "Address family modifier\n" |
| 10628 | "Address family modifier\n" |
| 10629 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10630 | "Display routes matching the communities\n" |
| 10631 | "community number\n" |
| 10632 | "Do not send outside local AS (well-known community)\n" |
| 10633 | "Do not advertise to any peer (well-known community)\n" |
| 10634 | "Do not export to next AS (well-known community)\n") |
| 10635 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10636 | safi_t safi; |
| 10637 | |
| 10638 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10639 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10640 | return CMD_WARNING; |
| 10641 | } |
| 10642 | 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] | 10643 | } |
| 10644 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10645 | ALIAS (show_bgp_ipv6_safi_community, |
| 10646 | show_bgp_ipv6_safi_community2_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10647 | "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] | 10648 | SHOW_STR |
| 10649 | BGP_STR |
| 10650 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10651 | "Address family modifier\n" |
| 10652 | "Address family modifier\n" |
| 10653 | "Address family modifier\n" |
| 10654 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10655 | "Display routes matching the communities\n" |
| 10656 | "community number\n" |
| 10657 | "Do not send outside local AS (well-known community)\n" |
| 10658 | "Do not advertise to any peer (well-known community)\n" |
| 10659 | "Do not export to next AS (well-known community)\n" |
| 10660 | "community number\n" |
| 10661 | "Do not send outside local AS (well-known community)\n" |
| 10662 | "Do not advertise to any peer (well-known community)\n" |
| 10663 | "Do not export to next AS (well-known community)\n") |
| 10664 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10665 | ALIAS (show_bgp_ipv6_safi_community, |
| 10666 | show_bgp_ipv6_safi_community3_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10667 | "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] | 10668 | SHOW_STR |
| 10669 | BGP_STR |
| 10670 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10671 | "Address family modifier\n" |
| 10672 | "Address family modifier\n" |
| 10673 | "Address family modifier\n" |
| 10674 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10675 | "Display routes matching the communities\n" |
| 10676 | "community number\n" |
| 10677 | "Do not send outside local AS (well-known community)\n" |
| 10678 | "Do not advertise to any peer (well-known community)\n" |
| 10679 | "Do not export to next AS (well-known community)\n" |
| 10680 | "community number\n" |
| 10681 | "Do not send outside local AS (well-known community)\n" |
| 10682 | "Do not advertise to any peer (well-known community)\n" |
| 10683 | "Do not export to next AS (well-known community)\n" |
| 10684 | "community number\n" |
| 10685 | "Do not send outside local AS (well-known community)\n" |
| 10686 | "Do not advertise to any peer (well-known community)\n" |
| 10687 | "Do not export to next AS (well-known community)\n") |
| 10688 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10689 | ALIAS (show_bgp_ipv6_safi_community, |
| 10690 | show_bgp_ipv6_safi_community4_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10691 | "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] | 10692 | SHOW_STR |
| 10693 | BGP_STR |
| 10694 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10695 | "Address family modifier\n" |
| 10696 | "Address family modifier\n" |
| 10697 | "Address family modifier\n" |
| 10698 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10699 | "Display routes matching the communities\n" |
| 10700 | "community number\n" |
| 10701 | "Do not send outside local AS (well-known community)\n" |
| 10702 | "Do not advertise to any peer (well-known community)\n" |
| 10703 | "Do not export to next AS (well-known community)\n" |
| 10704 | "community number\n" |
| 10705 | "Do not send outside local AS (well-known community)\n" |
| 10706 | "Do not advertise to any peer (well-known community)\n" |
| 10707 | "Do not export to next AS (well-known community)\n" |
| 10708 | "community number\n" |
| 10709 | "Do not send outside local AS (well-known community)\n" |
| 10710 | "Do not advertise to any peer (well-known community)\n" |
| 10711 | "Do not export to next AS (well-known community)\n" |
| 10712 | "community number\n" |
| 10713 | "Do not send outside local AS (well-known community)\n" |
| 10714 | "Do not advertise to any peer (well-known community)\n" |
| 10715 | "Do not export to next AS (well-known community)\n") |
| 10716 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10717 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10718 | DEFUN (show_bgp_ipv6_safi_community_exact, |
| 10719 | show_bgp_ipv6_safi_community_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10720 | "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] | 10721 | SHOW_STR |
| 10722 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10723 | "Address family\n" |
| 10724 | "Address family modifier\n" |
| 10725 | "Address family modifier\n" |
| 10726 | "Address family modifier\n" |
| 10727 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10728 | "Display routes matching the communities\n" |
| 10729 | "community number\n" |
| 10730 | "Do not send outside local AS (well-known community)\n" |
| 10731 | "Do not advertise to any peer (well-known community)\n" |
| 10732 | "Do not export to next AS (well-known community)\n" |
| 10733 | "Exact match of the communities") |
| 10734 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10735 | safi_t safi; |
| 10736 | |
| 10737 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10738 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10739 | return CMD_WARNING; |
| 10740 | } |
| 10741 | 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] | 10742 | } |
| 10743 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10744 | |
| 10745 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10746 | show_bgp_ipv6_safi_community2_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10747 | "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] | 10748 | SHOW_STR |
| 10749 | BGP_STR |
| 10750 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10751 | "Address family modifier\n" |
| 10752 | "Address family modifier\n" |
| 10753 | "Address family modifier\n" |
| 10754 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10755 | "Display routes matching the communities\n" |
| 10756 | "community number\n" |
| 10757 | "Do not send outside local AS (well-known community)\n" |
| 10758 | "Do not advertise to any peer (well-known community)\n" |
| 10759 | "Do not export to next AS (well-known community)\n" |
| 10760 | "community number\n" |
| 10761 | "Do not send outside local AS (well-known community)\n" |
| 10762 | "Do not advertise to any peer (well-known community)\n" |
| 10763 | "Do not export to next AS (well-known community)\n" |
| 10764 | "Exact match of the communities") |
| 10765 | |
| 10766 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10767 | show_bgp_ipv6_safi_community3_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10768 | "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] | 10769 | SHOW_STR |
| 10770 | BGP_STR |
| 10771 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10772 | "Address family modifier\n" |
| 10773 | "Address family modifier\n" |
| 10774 | "Address family modifier\n" |
| 10775 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10776 | "Display routes matching the communities\n" |
| 10777 | "community number\n" |
| 10778 | "Do not send outside local AS (well-known community)\n" |
| 10779 | "Do not advertise to any peer (well-known community)\n" |
| 10780 | "Do not export to next AS (well-known community)\n" |
| 10781 | "community number\n" |
| 10782 | "Do not send outside local AS (well-known community)\n" |
| 10783 | "Do not advertise to any peer (well-known community)\n" |
| 10784 | "Do not export to next AS (well-known community)\n" |
| 10785 | "community number\n" |
| 10786 | "Do not send outside local AS (well-known community)\n" |
| 10787 | "Do not advertise to any peer (well-known community)\n" |
| 10788 | "Do not export to next AS (well-known community)\n" |
| 10789 | "Exact match of the communities") |
| 10790 | |
| 10791 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10792 | show_bgp_ipv6_safi_community4_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10793 | "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] | 10794 | SHOW_STR |
| 10795 | BGP_STR |
| 10796 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10797 | "Address family modifier\n" |
| 10798 | "Address family modifier\n" |
| 10799 | "Address family modifier\n" |
| 10800 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10801 | "Display routes matching the communities\n" |
| 10802 | "community number\n" |
| 10803 | "Do not send outside local AS (well-known community)\n" |
| 10804 | "Do not advertise to any peer (well-known community)\n" |
| 10805 | "Do not export to next AS (well-known community)\n" |
| 10806 | "community number\n" |
| 10807 | "Do not send outside local AS (well-known community)\n" |
| 10808 | "Do not advertise to any peer (well-known community)\n" |
| 10809 | "Do not export to next AS (well-known community)\n" |
| 10810 | "community number\n" |
| 10811 | "Do not send outside local AS (well-known community)\n" |
| 10812 | "Do not advertise to any peer (well-known community)\n" |
| 10813 | "Do not export to next AS (well-known community)\n" |
| 10814 | "community number\n" |
| 10815 | "Do not send outside local AS (well-known community)\n" |
| 10816 | "Do not advertise to any peer (well-known community)\n" |
| 10817 | "Do not export to next AS (well-known community)\n" |
| 10818 | "Exact match of the communities") |
| 10819 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10820 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10821 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 10822 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10823 | { |
| 10824 | struct community_list *list; |
| 10825 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 10826 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10827 | if (list == NULL) |
| 10828 | { |
| 10829 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 10830 | VTY_NEWLINE); |
| 10831 | return CMD_WARNING; |
| 10832 | } |
| 10833 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10834 | return bgp_show (vty, NULL, afi, safi, |
| 10835 | (exact ? bgp_show_type_community_list_exact : |
| 10836 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10837 | } |
| 10838 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10839 | DEFUN (show_ip_bgp_community_list, |
| 10840 | show_ip_bgp_community_list_cmd, |
| 10841 | "show ip bgp community-list (<1-500>|WORD)", |
| 10842 | SHOW_STR |
| 10843 | IP_STR |
| 10844 | BGP_STR |
| 10845 | "Display routes matching the community-list\n" |
| 10846 | "community-list number\n" |
| 10847 | "community-list name\n") |
| 10848 | { |
| 10849 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 10850 | } |
| 10851 | |
| 10852 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 10853 | show_ip_bgp_ipv4_community_list_cmd, |
| 10854 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
| 10855 | SHOW_STR |
| 10856 | IP_STR |
| 10857 | BGP_STR |
| 10858 | "Address family\n" |
| 10859 | "Address Family modifier\n" |
| 10860 | "Address Family modifier\n" |
| 10861 | "Display routes matching the community-list\n" |
| 10862 | "community-list number\n" |
| 10863 | "community-list name\n") |
| 10864 | { |
| 10865 | if (strncmp (argv[0], "m", 1) == 0) |
| 10866 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 10867 | |
| 10868 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 10869 | } |
| 10870 | |
| 10871 | DEFUN (show_ip_bgp_community_list_exact, |
| 10872 | show_ip_bgp_community_list_exact_cmd, |
| 10873 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
| 10874 | SHOW_STR |
| 10875 | IP_STR |
| 10876 | BGP_STR |
| 10877 | "Display routes matching the community-list\n" |
| 10878 | "community-list number\n" |
| 10879 | "community-list name\n" |
| 10880 | "Exact match of the communities\n") |
| 10881 | { |
| 10882 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 10883 | } |
| 10884 | |
| 10885 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 10886 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 10887 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
| 10888 | SHOW_STR |
| 10889 | IP_STR |
| 10890 | BGP_STR |
| 10891 | "Address family\n" |
| 10892 | "Address Family modifier\n" |
| 10893 | "Address Family modifier\n" |
| 10894 | "Display routes matching the community-list\n" |
| 10895 | "community-list number\n" |
| 10896 | "community-list name\n" |
| 10897 | "Exact match of the communities\n") |
| 10898 | { |
| 10899 | if (strncmp (argv[0], "m", 1) == 0) |
| 10900 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 10901 | |
| 10902 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 10903 | } |
| 10904 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10905 | DEFUN (show_bgp_community_list, |
| 10906 | show_bgp_community_list_cmd, |
| 10907 | "show bgp community-list (<1-500>|WORD)", |
| 10908 | SHOW_STR |
| 10909 | BGP_STR |
| 10910 | "Display routes matching the community-list\n" |
| 10911 | "community-list number\n" |
| 10912 | "community-list name\n") |
| 10913 | { |
| 10914 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 10915 | } |
| 10916 | |
| 10917 | ALIAS (show_bgp_community_list, |
| 10918 | show_bgp_ipv6_community_list_cmd, |
| 10919 | "show bgp ipv6 community-list (<1-500>|WORD)", |
| 10920 | SHOW_STR |
| 10921 | BGP_STR |
| 10922 | "Address family\n" |
| 10923 | "Display routes matching the community-list\n" |
| 10924 | "community-list number\n" |
| 10925 | "community-list name\n") |
| 10926 | |
| 10927 | /* old command */ |
| 10928 | DEFUN (show_ipv6_bgp_community_list, |
| 10929 | show_ipv6_bgp_community_list_cmd, |
| 10930 | "show ipv6 bgp community-list WORD", |
| 10931 | SHOW_STR |
| 10932 | IPV6_STR |
| 10933 | BGP_STR |
| 10934 | "Display routes matching the community-list\n" |
| 10935 | "community-list name\n") |
| 10936 | { |
| 10937 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 10938 | } |
| 10939 | |
| 10940 | /* old command */ |
| 10941 | DEFUN (show_ipv6_mbgp_community_list, |
| 10942 | show_ipv6_mbgp_community_list_cmd, |
| 10943 | "show ipv6 mbgp community-list WORD", |
| 10944 | SHOW_STR |
| 10945 | IPV6_STR |
| 10946 | MBGP_STR |
| 10947 | "Display routes matching the community-list\n" |
| 10948 | "community-list name\n") |
| 10949 | { |
| 10950 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 10951 | } |
| 10952 | |
| 10953 | DEFUN (show_bgp_community_list_exact, |
| 10954 | show_bgp_community_list_exact_cmd, |
| 10955 | "show bgp community-list (<1-500>|WORD) exact-match", |
| 10956 | SHOW_STR |
| 10957 | BGP_STR |
| 10958 | "Display routes matching the community-list\n" |
| 10959 | "community-list number\n" |
| 10960 | "community-list name\n" |
| 10961 | "Exact match of the communities\n") |
| 10962 | { |
| 10963 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 10964 | } |
| 10965 | |
| 10966 | ALIAS (show_bgp_community_list_exact, |
| 10967 | show_bgp_ipv6_community_list_exact_cmd, |
| 10968 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
| 10969 | SHOW_STR |
| 10970 | BGP_STR |
| 10971 | "Address family\n" |
| 10972 | "Display routes matching the community-list\n" |
| 10973 | "community-list number\n" |
| 10974 | "community-list name\n" |
| 10975 | "Exact match of the communities\n") |
| 10976 | |
| 10977 | /* old command */ |
| 10978 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 10979 | show_ipv6_bgp_community_list_exact_cmd, |
| 10980 | "show ipv6 bgp community-list WORD exact-match", |
| 10981 | SHOW_STR |
| 10982 | IPV6_STR |
| 10983 | BGP_STR |
| 10984 | "Display routes matching the community-list\n" |
| 10985 | "community-list name\n" |
| 10986 | "Exact match of the communities\n") |
| 10987 | { |
| 10988 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 10989 | } |
| 10990 | |
| 10991 | /* old command */ |
| 10992 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 10993 | show_ipv6_mbgp_community_list_exact_cmd, |
| 10994 | "show ipv6 mbgp community-list WORD exact-match", |
| 10995 | SHOW_STR |
| 10996 | IPV6_STR |
| 10997 | MBGP_STR |
| 10998 | "Display routes matching the community-list\n" |
| 10999 | "community-list name\n" |
| 11000 | "Exact match of the communities\n") |
| 11001 | { |
| 11002 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 11003 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11004 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11005 | DEFUN (show_bgp_ipv4_community_list, |
| 11006 | show_bgp_ipv4_community_list_cmd, |
| 11007 | "show bgp ipv4 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11008 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11009 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11010 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11011 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11012 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11013 | "community-list name\n") |
| 11014 | { |
| 11015 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11016 | } |
| 11017 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11018 | DEFUN (show_bgp_ipv4_safi_community_list, |
| 11019 | show_bgp_ipv4_safi_community_list_cmd, |
| 11020 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11021 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11022 | BGP_STR |
| 11023 | "Address family\n" |
| 11024 | "Address Family modifier\n" |
| 11025 | "Address Family modifier\n" |
| 11026 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11027 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11028 | "community-list name\n") |
| 11029 | { |
| 11030 | if (strncmp (argv[0], "m", 1) == 0) |
| 11031 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11032 | |
| 11033 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11034 | } |
| 11035 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11036 | DEFUN (show_bgp_ipv4_community_list_exact, |
| 11037 | show_bgp_ipv4_community_list_exact_cmd, |
| 11038 | "show bgp ipv4 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11039 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11040 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11041 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11042 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11043 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11044 | "community-list name\n" |
| 11045 | "Exact match of the communities\n") |
| 11046 | { |
| 11047 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11048 | } |
| 11049 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11050 | DEFUN (show_bgp_ipv4_safi_community_list_exact, |
| 11051 | show_bgp_ipv4_safi_community_list_exact_cmd, |
| 11052 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11053 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11054 | BGP_STR |
| 11055 | "Address family\n" |
| 11056 | "Address Family modifier\n" |
| 11057 | "Address Family modifier\n" |
| 11058 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11059 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11060 | "community-list name\n" |
| 11061 | "Exact match of the communities\n") |
| 11062 | { |
| 11063 | if (strncmp (argv[0], "m", 1) == 0) |
| 11064 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11065 | |
| 11066 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11067 | } |
| 11068 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11069 | DEFUN (show_bgp_ipv6_safi_community_list, |
| 11070 | show_bgp_ipv6_safi_community_list_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11071 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11072 | SHOW_STR |
| 11073 | BGP_STR |
| 11074 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11075 | "Address family modifier\n" |
| 11076 | "Address family modifier\n" |
| 11077 | "Address family modifier\n" |
| 11078 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11079 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11080 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 11081 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11082 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11083 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11084 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11085 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11086 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11087 | return CMD_WARNING; |
| 11088 | } |
| 11089 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11090 | } |
| 11091 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11092 | DEFUN (show_bgp_ipv6_safi_community_list_exact, |
| 11093 | show_bgp_ipv6_safi_community_list_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11094 | "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] | 11095 | SHOW_STR |
| 11096 | BGP_STR |
| 11097 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11098 | "Address family modifier\n" |
| 11099 | "Address family modifier\n" |
| 11100 | "Address family modifier\n" |
| 11101 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11102 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11103 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11104 | "community-list name\n" |
| 11105 | "Exact match of the communities\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11106 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11107 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11108 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11109 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11110 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11111 | return CMD_WARNING; |
| 11112 | } |
| 11113 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11114 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11115 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11116 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11117 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11118 | safi_t safi, enum bgp_show_type type) |
| 11119 | { |
| 11120 | int ret; |
| 11121 | struct prefix *p; |
| 11122 | |
| 11123 | p = prefix_new(); |
| 11124 | |
| 11125 | ret = str2prefix (prefix, p); |
| 11126 | if (! ret) |
| 11127 | { |
| 11128 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 11129 | return CMD_WARNING; |
| 11130 | } |
| 11131 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11132 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 11133 | prefix_free(p); |
| 11134 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11135 | } |
| 11136 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11137 | DEFUN (show_ip_bgp_prefix_longer, |
| 11138 | show_ip_bgp_prefix_longer_cmd, |
| 11139 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 11140 | SHOW_STR |
| 11141 | IP_STR |
| 11142 | BGP_STR |
| 11143 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11144 | "Display route and more specific routes\n") |
| 11145 | { |
| 11146 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11147 | bgp_show_type_prefix_longer); |
| 11148 | } |
| 11149 | |
| 11150 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 11151 | show_ip_bgp_flap_prefix_longer_cmd, |
| 11152 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 11153 | SHOW_STR |
| 11154 | IP_STR |
| 11155 | BGP_STR |
| 11156 | "Display flap statistics of routes\n" |
| 11157 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11158 | "Display route and more specific routes\n") |
| 11159 | { |
| 11160 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11161 | bgp_show_type_flap_prefix_longer); |
| 11162 | } |
| 11163 | |
| 11164 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 11165 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 11166 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 11167 | SHOW_STR |
| 11168 | IP_STR |
| 11169 | BGP_STR |
| 11170 | "Display detailed information about dampening\n" |
| 11171 | "Display flap statistics of routes\n" |
| 11172 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11173 | "Display route and more specific routes\n") |
| 11174 | |
| 11175 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 11176 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 11177 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 11178 | SHOW_STR |
| 11179 | IP_STR |
| 11180 | BGP_STR |
| 11181 | "Address family\n" |
| 11182 | "Address Family modifier\n" |
| 11183 | "Address Family modifier\n" |
| 11184 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11185 | "Display route and more specific routes\n") |
| 11186 | { |
| 11187 | if (strncmp (argv[0], "m", 1) == 0) |
| 11188 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 11189 | bgp_show_type_prefix_longer); |
| 11190 | |
| 11191 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 11192 | bgp_show_type_prefix_longer); |
| 11193 | } |
| 11194 | |
| 11195 | DEFUN (show_ip_bgp_flap_address, |
| 11196 | show_ip_bgp_flap_address_cmd, |
| 11197 | "show ip bgp flap-statistics A.B.C.D", |
| 11198 | SHOW_STR |
| 11199 | IP_STR |
| 11200 | BGP_STR |
| 11201 | "Display flap statistics of routes\n" |
| 11202 | "Network in the BGP routing table to display\n") |
| 11203 | { |
| 11204 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11205 | bgp_show_type_flap_address); |
| 11206 | } |
| 11207 | |
| 11208 | ALIAS (show_ip_bgp_flap_address, |
| 11209 | show_ip_bgp_damp_flap_address_cmd, |
| 11210 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 11211 | SHOW_STR |
| 11212 | IP_STR |
| 11213 | BGP_STR |
| 11214 | "Display detailed information about dampening\n" |
| 11215 | "Display flap statistics of routes\n" |
| 11216 | "Network in the BGP routing table to display\n") |
| 11217 | |
| 11218 | DEFUN (show_ip_bgp_flap_prefix, |
| 11219 | show_ip_bgp_flap_prefix_cmd, |
| 11220 | "show ip bgp flap-statistics A.B.C.D/M", |
| 11221 | SHOW_STR |
| 11222 | IP_STR |
| 11223 | BGP_STR |
| 11224 | "Display flap statistics of routes\n" |
| 11225 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11226 | { |
| 11227 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11228 | bgp_show_type_flap_prefix); |
| 11229 | } |
| 11230 | |
| 11231 | ALIAS (show_ip_bgp_flap_prefix, |
| 11232 | show_ip_bgp_damp_flap_prefix_cmd, |
| 11233 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 11234 | SHOW_STR |
| 11235 | IP_STR |
| 11236 | BGP_STR |
| 11237 | "Display detailed information about dampening\n" |
| 11238 | "Display flap statistics of routes\n" |
| 11239 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11240 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11241 | DEFUN (show_bgp_prefix_longer, |
| 11242 | show_bgp_prefix_longer_cmd, |
| 11243 | "show bgp X:X::X:X/M longer-prefixes", |
| 11244 | SHOW_STR |
| 11245 | BGP_STR |
| 11246 | "IPv6 prefix <network>/<length>\n" |
| 11247 | "Display route and more specific routes\n") |
| 11248 | { |
| 11249 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11250 | bgp_show_type_prefix_longer); |
| 11251 | } |
| 11252 | |
| 11253 | /* old command */ |
| 11254 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 11255 | show_ipv6_bgp_prefix_longer_cmd, |
| 11256 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 11257 | SHOW_STR |
| 11258 | IPV6_STR |
| 11259 | BGP_STR |
| 11260 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11261 | "Display route and more specific routes\n") |
| 11262 | { |
| 11263 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11264 | bgp_show_type_prefix_longer); |
| 11265 | } |
| 11266 | |
| 11267 | /* old command */ |
| 11268 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 11269 | show_ipv6_mbgp_prefix_longer_cmd, |
| 11270 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 11271 | SHOW_STR |
| 11272 | IPV6_STR |
| 11273 | MBGP_STR |
| 11274 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11275 | "Display route and more specific routes\n") |
| 11276 | { |
| 11277 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 11278 | bgp_show_type_prefix_longer); |
| 11279 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11280 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11281 | DEFUN (show_bgp_ipv4_prefix_longer, |
| 11282 | show_bgp_ipv4_prefix_longer_cmd, |
| 11283 | "show bgp ipv4 A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11284 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11285 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11286 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11287 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11288 | "Display route and more specific routes\n") |
| 11289 | { |
| 11290 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11291 | bgp_show_type_prefix_longer); |
| 11292 | } |
| 11293 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11294 | DEFUN (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11295 | show_bgp_ipv4_safi_flap_prefix_longer_cmd, |
| 11296 | "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] | 11297 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11298 | BGP_STR |
| 11299 | "Address family\n" |
| 11300 | "Address Family modifier\n" |
| 11301 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11302 | "Address Family modifier\n" |
| 11303 | "Address Family modifier\n" |
| 11304 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11305 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11306 | "Display route and more specific routes\n") |
| 11307 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11308 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11309 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11310 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11311 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11312 | return CMD_WARNING; |
| 11313 | } |
| 11314 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11315 | bgp_show_type_flap_prefix_longer); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11316 | } |
| 11317 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11318 | ALIAS (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11319 | show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd, |
| 11320 | "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] | 11321 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11322 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11323 | "Address family\n" |
| 11324 | "Address Family modifier\n" |
| 11325 | "Address Family modifier\n" |
| 11326 | "Address Family modifier\n" |
| 11327 | "Address Family modifier\n" |
| 11328 | "Display detailed information about dampening\n" |
| 11329 | "Display flap statistics of routes\n" |
| 11330 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11331 | "Display route and more specific routes\n") |
| 11332 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11333 | DEFUN (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11334 | show_bgp_ipv6_safi_flap_prefix_longer_cmd, |
| 11335 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes", |
| 11336 | SHOW_STR |
| 11337 | BGP_STR |
| 11338 | "Address family\n" |
| 11339 | "Address Family modifier\n" |
| 11340 | "Address Family modifier\n" |
| 11341 | "Address Family modifier\n" |
| 11342 | "Address Family modifier\n" |
| 11343 | "Display flap statistics of routes\n" |
| 11344 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11345 | "Display route and more specific routes\n") |
| 11346 | { |
| 11347 | safi_t safi; |
| 11348 | |
| 11349 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11350 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11351 | return CMD_WARNING; |
| 11352 | } |
| 11353 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11354 | bgp_show_type_flap_prefix_longer); |
| 11355 | } |
| 11356 | ALIAS (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11357 | show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd, |
| 11358 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes", |
| 11359 | SHOW_STR |
| 11360 | BGP_STR |
| 11361 | "Address family\n" |
| 11362 | "Address Family modifier\n" |
| 11363 | "Address Family modifier\n" |
| 11364 | "Address Family modifier\n" |
| 11365 | "Address Family modifier\n" |
| 11366 | "Display detailed information about dampening\n" |
| 11367 | "Display flap statistics of routes\n" |
| 11368 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11369 | "Display route and more specific routes\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11370 | |
| 11371 | DEFUN (show_bgp_ipv4_safi_prefix_longer, |
| 11372 | show_bgp_ipv4_safi_prefix_longer_cmd, |
| 11373 | "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes", |
| 11374 | SHOW_STR |
| 11375 | BGP_STR |
| 11376 | "Address family\n" |
| 11377 | "Address Family modifier\n" |
| 11378 | "Address Family modifier\n" |
| 11379 | "Address Family modifier\n" |
| 11380 | "Address Family modifier\n" |
| 11381 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11382 | "Display route and more specific routes\n") |
| 11383 | { |
| 11384 | safi_t safi; |
| 11385 | |
| 11386 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11387 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11388 | return CMD_WARNING; |
| 11389 | } |
| 11390 | |
| 11391 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11392 | bgp_show_type_prefix_longer); |
| 11393 | } |
| 11394 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11395 | DEFUN (show_bgp_ipv6_safi_prefix_longer, |
| 11396 | show_bgp_ipv6_safi_prefix_longer_cmd, |
| 11397 | "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes", |
| 11398 | SHOW_STR |
| 11399 | BGP_STR |
| 11400 | "Address family\n" |
| 11401 | "Address Family modifier\n" |
| 11402 | "Address Family modifier\n" |
| 11403 | "Address Family modifier\n" |
| 11404 | "Address Family modifier\n" |
| 11405 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11406 | "Display route and more specific routes\n") |
| 11407 | { |
| 11408 | safi_t safi; |
| 11409 | |
| 11410 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11411 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11412 | return CMD_WARNING; |
| 11413 | } |
| 11414 | |
| 11415 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11416 | bgp_show_type_prefix_longer); |
| 11417 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11418 | |
| 11419 | DEFUN (show_bgp_ipv4_safi_flap_address, |
| 11420 | show_bgp_ipv4_safi_flap_address_cmd, |
| 11421 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
| 11422 | SHOW_STR |
| 11423 | BGP_STR |
| 11424 | "Address family\n" |
| 11425 | "Address Family modifier\n" |
| 11426 | "Address Family modifier\n" |
| 11427 | "Address Family modifier\n" |
| 11428 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11429 | "Display flap statistics of routes\n" |
| 11430 | "Network in the BGP routing table to display\n") |
| 11431 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11432 | safi_t safi; |
| 11433 | |
| 11434 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11435 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11436 | return CMD_WARNING; |
| 11437 | } |
| 11438 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11439 | bgp_show_type_flap_address); |
| 11440 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11441 | ALIAS (show_bgp_ipv4_safi_flap_address, |
| 11442 | show_bgp_ipv4_safi_damp_flap_address_cmd, |
| 11443 | "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] | 11444 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11445 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11446 | "Address family\n" |
| 11447 | "Address Family modifier\n" |
| 11448 | "Address Family modifier\n" |
| 11449 | "Address Family modifier\n" |
| 11450 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11451 | "Display detailed information about dampening\n" |
| 11452 | "Display flap statistics of routes\n" |
| 11453 | "Network in the BGP routing table to display\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 11454 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11455 | DEFUN (show_bgp_ipv6_flap_address, |
| 11456 | show_bgp_ipv6_flap_address_cmd, |
| 11457 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11458 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11459 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11460 | "Address family\n" |
| 11461 | "Address Family modifier\n" |
| 11462 | "Address Family modifier\n" |
| 11463 | "Address Family modifier\n" |
| 11464 | "Address Family modifier\n" |
| 11465 | "Display flap statistics of routes\n" |
| 11466 | "Network in the BGP routing table to display\n") |
| 11467 | { |
| 11468 | safi_t safi; |
| 11469 | |
| 11470 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11471 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11472 | return CMD_WARNING; |
| 11473 | } |
| 11474 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11475 | bgp_show_type_flap_address); |
| 11476 | } |
| 11477 | ALIAS (show_bgp_ipv6_flap_address, |
| 11478 | show_bgp_ipv6_damp_flap_address_cmd, |
| 11479 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D", |
| 11480 | SHOW_STR |
| 11481 | BGP_STR |
| 11482 | "Address family\n" |
| 11483 | "Address Family modifier\n" |
| 11484 | "Address Family modifier\n" |
| 11485 | "Address Family modifier\n" |
| 11486 | "Address Family modifier\n" |
| 11487 | "Display detailed information about dampening\n" |
| 11488 | "Display flap statistics of routes\n" |
| 11489 | "Network in the BGP routing table to display\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11490 | |
| 11491 | DEFUN (show_bgp_ipv4_safi_flap_prefix, |
| 11492 | show_bgp_ipv4_safi_flap_prefix_cmd, |
| 11493 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M", |
| 11494 | SHOW_STR |
| 11495 | BGP_STR |
| 11496 | "Address family\n" |
| 11497 | "Address Family modifier\n" |
| 11498 | "Address Family modifier\n" |
| 11499 | "Address Family modifier\n" |
| 11500 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11501 | "Display flap statistics of routes\n" |
| 11502 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11503 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11504 | safi_t safi; |
| 11505 | |
| 11506 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11507 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11508 | return CMD_WARNING; |
| 11509 | } |
| 11510 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11511 | bgp_show_type_flap_prefix); |
| 11512 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11513 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11514 | ALIAS (show_bgp_ipv4_safi_flap_prefix, |
| 11515 | show_bgp_ipv4_safi_damp_flap_prefix_cmd, |
| 11516 | "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] | 11517 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11518 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11519 | "Address family\n" |
| 11520 | "Address Family modifier\n" |
| 11521 | "Address Family modifier\n" |
| 11522 | "Address Family modifier\n" |
| 11523 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11524 | "Display detailed information about dampening\n" |
| 11525 | "Display flap statistics of routes\n" |
| 11526 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11527 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11528 | DEFUN (show_bgp_ipv6_safi_flap_prefix, |
| 11529 | show_bgp_ipv6_safi_flap_prefix_cmd, |
| 11530 | "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] | 11531 | SHOW_STR |
| 11532 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11533 | "Address family\n" |
| 11534 | "Address Family modifier\n" |
| 11535 | "Address Family modifier\n" |
| 11536 | "Address Family modifier\n" |
| 11537 | "Address Family modifier\n" |
| 11538 | "Display flap statistics of routes\n" |
| 11539 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11540 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11541 | safi_t safi; |
| 11542 | |
| 11543 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11544 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11545 | return CMD_WARNING; |
| 11546 | } |
| 11547 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi, |
| 11548 | bgp_show_type_flap_prefix); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11549 | } |
| 11550 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11551 | ALIAS (show_bgp_ipv6_safi_flap_prefix, |
| 11552 | show_bgp_ipv6_safi_damp_flap_prefix_cmd, |
| 11553 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M", |
| 11554 | SHOW_STR |
| 11555 | BGP_STR |
| 11556 | "Address family\n" |
| 11557 | "Address Family modifier\n" |
| 11558 | "Address Family modifier\n" |
| 11559 | "Address Family modifier\n" |
| 11560 | "Address Family modifier\n" |
| 11561 | "Display detailed information about dampening\n" |
| 11562 | "Display flap statistics of routes\n" |
| 11563 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11564 | |
| 11565 | DEFUN (show_bgp_ipv6_prefix_longer, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11566 | show_bgp_ipv6_prefix_longer_cmd, |
| 11567 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 11568 | SHOW_STR |
| 11569 | BGP_STR |
| 11570 | "Address family\n" |
| 11571 | "IPv6 prefix <network>/<length>\n" |
| 11572 | "Display route and more specific routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11573 | { |
| 11574 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11575 | bgp_show_type_prefix_longer); |
| 11576 | } |
| 11577 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11578 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11579 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 11580 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11581 | { |
| 11582 | int ret; |
| 11583 | struct bgp *bgp; |
| 11584 | struct peer *peer; |
| 11585 | union sockunion su; |
| 11586 | |
| 11587 | /* BGP structure lookup. */ |
| 11588 | if (view_name) |
| 11589 | { |
| 11590 | bgp = bgp_lookup_by_name (view_name); |
| 11591 | if (! bgp) |
| 11592 | { |
| 11593 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 11594 | return NULL; |
| 11595 | } |
| 11596 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 11597 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11598 | { |
| 11599 | bgp = bgp_get_default (); |
| 11600 | if (! bgp) |
| 11601 | { |
| 11602 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11603 | return NULL; |
| 11604 | } |
| 11605 | } |
| 11606 | |
| 11607 | /* Get peer sockunion. */ |
| 11608 | ret = str2sockunion (ip_str, &su); |
| 11609 | if (ret < 0) |
| 11610 | { |
| 11611 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 11612 | return NULL; |
| 11613 | } |
| 11614 | |
| 11615 | /* Peer structure lookup. */ |
| 11616 | peer = peer_lookup (bgp, &su); |
| 11617 | if (! peer) |
| 11618 | { |
| 11619 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 11620 | return NULL; |
| 11621 | } |
| 11622 | |
| 11623 | return peer; |
| 11624 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11625 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11626 | enum bgp_stats |
| 11627 | { |
| 11628 | BGP_STATS_MAXBITLEN = 0, |
| 11629 | BGP_STATS_RIB, |
| 11630 | BGP_STATS_PREFIXES, |
| 11631 | BGP_STATS_TOTPLEN, |
| 11632 | BGP_STATS_UNAGGREGATEABLE, |
| 11633 | BGP_STATS_MAX_AGGREGATEABLE, |
| 11634 | BGP_STATS_AGGREGATES, |
| 11635 | BGP_STATS_SPACE, |
| 11636 | BGP_STATS_ASPATH_COUNT, |
| 11637 | BGP_STATS_ASPATH_MAXHOPS, |
| 11638 | BGP_STATS_ASPATH_TOTHOPS, |
| 11639 | BGP_STATS_ASPATH_MAXSIZE, |
| 11640 | BGP_STATS_ASPATH_TOTSIZE, |
| 11641 | BGP_STATS_ASN_HIGHEST, |
| 11642 | BGP_STATS_MAX, |
| 11643 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11644 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11645 | static const char *table_stats_strs[] = |
| 11646 | { |
| 11647 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 11648 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 11649 | [BGP_STATS_RIB] = "Total Advertisements", |
| 11650 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 11651 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 11652 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 11653 | [BGP_STATS_SPACE] = "Address space advertised", |
| 11654 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 11655 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 11656 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 11657 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 11658 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 11659 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 11660 | [BGP_STATS_MAX] = NULL, |
| 11661 | }; |
| 11662 | |
| 11663 | struct bgp_table_stats |
| 11664 | { |
| 11665 | struct bgp_table *table; |
| 11666 | unsigned long long counts[BGP_STATS_MAX]; |
| 11667 | }; |
| 11668 | |
| 11669 | #if 0 |
| 11670 | #define TALLY_SIGFIG 100000 |
| 11671 | static unsigned long |
| 11672 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 11673 | { |
| 11674 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 11675 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 11676 | unsigned long ret = newtot / count; |
| 11677 | |
| 11678 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 11679 | return ret + 1; |
| 11680 | else |
| 11681 | return ret; |
| 11682 | } |
| 11683 | #endif |
| 11684 | |
| 11685 | static int |
| 11686 | bgp_table_stats_walker (struct thread *t) |
| 11687 | { |
| 11688 | struct bgp_node *rn; |
| 11689 | struct bgp_node *top; |
| 11690 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 11691 | unsigned int space = 0; |
| 11692 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 11693 | if (!(top = bgp_table_top (ts->table))) |
| 11694 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11695 | |
| 11696 | switch (top->p.family) |
| 11697 | { |
| 11698 | case AF_INET: |
| 11699 | space = IPV4_MAX_BITLEN; |
| 11700 | break; |
| 11701 | case AF_INET6: |
| 11702 | space = IPV6_MAX_BITLEN; |
| 11703 | break; |
| 11704 | } |
| 11705 | |
| 11706 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 11707 | |
| 11708 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 11709 | { |
| 11710 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11711 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11712 | unsigned int rinum = 0; |
| 11713 | |
| 11714 | if (rn == top) |
| 11715 | continue; |
| 11716 | |
| 11717 | if (!rn->info) |
| 11718 | continue; |
| 11719 | |
| 11720 | ts->counts[BGP_STATS_PREFIXES]++; |
| 11721 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 11722 | |
| 11723 | #if 0 |
| 11724 | ts->counts[BGP_STATS_AVGPLEN] |
| 11725 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 11726 | ts->counts[BGP_STATS_AVGPLEN], |
| 11727 | rn->p.prefixlen); |
| 11728 | #endif |
| 11729 | |
| 11730 | /* check if the prefix is included by any other announcements */ |
| 11731 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11732 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11733 | |
| 11734 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 11735 | { |
| 11736 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 11737 | /* announced address space */ |
| 11738 | if (space) |
| 11739 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 11740 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11741 | else if (prn->info) |
| 11742 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 11743 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11744 | for (ri = rn->info; ri; ri = ri->next) |
| 11745 | { |
| 11746 | rinum++; |
| 11747 | ts->counts[BGP_STATS_RIB]++; |
| 11748 | |
| 11749 | if (ri->attr && |
| 11750 | (CHECK_FLAG (ri->attr->flag, |
| 11751 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 11752 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 11753 | |
| 11754 | /* as-path stats */ |
| 11755 | if (ri->attr && ri->attr->aspath) |
| 11756 | { |
| 11757 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 11758 | unsigned int size = aspath_size (ri->attr->aspath); |
| 11759 | as_t highest = aspath_highest (ri->attr->aspath); |
| 11760 | |
| 11761 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 11762 | |
| 11763 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 11764 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 11765 | |
| 11766 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 11767 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 11768 | |
| 11769 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 11770 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 11771 | #if 0 |
| 11772 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 11773 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 11774 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 11775 | hops); |
| 11776 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 11777 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 11778 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 11779 | size); |
| 11780 | #endif |
| 11781 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 11782 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 11783 | } |
| 11784 | } |
| 11785 | } |
| 11786 | return 0; |
| 11787 | } |
| 11788 | |
| 11789 | static int |
| 11790 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 11791 | { |
| 11792 | struct bgp_table_stats ts; |
| 11793 | unsigned int i; |
| 11794 | |
| 11795 | if (!bgp->rib[afi][safi]) |
| 11796 | { |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 11797 | vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s", |
| 11798 | afi, safi, VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11799 | return CMD_WARNING; |
| 11800 | } |
| 11801 | |
| 11802 | memset (&ts, 0, sizeof (ts)); |
| 11803 | ts.table = bgp->rib[afi][safi]; |
| 11804 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 11805 | |
| 11806 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 11807 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 11808 | |
| 11809 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 11810 | { |
| 11811 | if (!table_stats_strs[i]) |
| 11812 | continue; |
| 11813 | |
| 11814 | switch (i) |
| 11815 | { |
| 11816 | #if 0 |
| 11817 | case BGP_STATS_ASPATH_AVGHOPS: |
| 11818 | case BGP_STATS_ASPATH_AVGSIZE: |
| 11819 | case BGP_STATS_AVGPLEN: |
| 11820 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11821 | vty_out (vty, "%12.2f", |
| 11822 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 11823 | break; |
| 11824 | #endif |
| 11825 | case BGP_STATS_ASPATH_TOTHOPS: |
| 11826 | case BGP_STATS_ASPATH_TOTSIZE: |
| 11827 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11828 | vty_out (vty, "%12.2f", |
| 11829 | ts.counts[i] ? |
| 11830 | (float)ts.counts[i] / |
| 11831 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 11832 | : 0); |
| 11833 | break; |
| 11834 | case BGP_STATS_TOTPLEN: |
| 11835 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11836 | vty_out (vty, "%12.2f", |
| 11837 | ts.counts[i] ? |
| 11838 | (float)ts.counts[i] / |
| 11839 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 11840 | : 0); |
| 11841 | break; |
| 11842 | case BGP_STATS_SPACE: |
| 11843 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11844 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 11845 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 11846 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 11847 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11848 | vty_out (vty, "%12.2f%s", |
| 11849 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 11850 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11851 | VTY_NEWLINE); |
| 11852 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 11853 | vty_out (vty, "%12.2f%s", |
| 11854 | (float)ts.counts[BGP_STATS_SPACE] / |
| 11855 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 11856 | VTY_NEWLINE); |
| 11857 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 11858 | break; |
| 11859 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 11860 | vty_out (vty, "%12.2f", |
| 11861 | (float)ts.counts[BGP_STATS_SPACE] / |
| 11862 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 11863 | break; |
| 11864 | default: |
| 11865 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 11866 | vty_out (vty, "%12llu", ts.counts[i]); |
| 11867 | } |
| 11868 | |
| 11869 | vty_out (vty, "%s", VTY_NEWLINE); |
| 11870 | } |
| 11871 | return CMD_SUCCESS; |
| 11872 | } |
| 11873 | |
| 11874 | static int |
| 11875 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 11876 | const char *afi_str, const char *safi_str) |
| 11877 | { |
| 11878 | struct bgp *bgp; |
| 11879 | afi_t afi; |
| 11880 | safi_t safi; |
| 11881 | |
| 11882 | if (name) |
| 11883 | bgp = bgp_lookup_by_name (name); |
| 11884 | else |
| 11885 | bgp = bgp_get_default (); |
| 11886 | |
| 11887 | if (!bgp) |
| 11888 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 11889 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11890 | return CMD_WARNING; |
| 11891 | } |
| 11892 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 11893 | { |
| 11894 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 11895 | afi = AFI_IP; |
| 11896 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 11897 | afi = AFI_IP6; |
| 11898 | else |
| 11899 | { |
| 11900 | vty_out (vty, "%% Invalid address family %s%s", |
| 11901 | afi_str, VTY_NEWLINE); |
| 11902 | return CMD_WARNING; |
| 11903 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11904 | switch (safi_str[0]) { |
| 11905 | case 'm': |
| 11906 | safi = SAFI_MULTICAST; |
| 11907 | break; |
| 11908 | case 'u': |
| 11909 | safi = SAFI_UNICAST; |
| 11910 | break; |
| 11911 | case 'v': |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 11912 | safi = SAFI_MPLS_VPN; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11913 | break; |
| 11914 | case 'e': |
| 11915 | safi = SAFI_ENCAP; |
| 11916 | break; |
| 11917 | default: |
| 11918 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11919 | safi_str, VTY_NEWLINE); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11920 | return CMD_WARNING; |
| 11921 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11922 | } |
| 11923 | else |
| 11924 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11925 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11926 | afi_str, VTY_NEWLINE); |
| 11927 | return CMD_WARNING; |
| 11928 | } |
| 11929 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11930 | return bgp_table_stats (vty, bgp, afi, safi); |
| 11931 | } |
| 11932 | |
| 11933 | DEFUN (show_bgp_statistics, |
| 11934 | show_bgp_statistics_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11935 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11936 | SHOW_STR |
| 11937 | BGP_STR |
| 11938 | "Address family\n" |
| 11939 | "Address family\n" |
| 11940 | "Address Family modifier\n" |
| 11941 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11942 | "Address Family modifier\n" |
| 11943 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11944 | "BGP RIB advertisement statistics\n") |
| 11945 | { |
| 11946 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 11947 | } |
| 11948 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11949 | ALIAS (show_bgp_statistics, |
| 11950 | show_bgp_statistics_vpnv4_cmd, |
| 11951 | "show bgp (ipv4) (vpnv4) statistics", |
| 11952 | SHOW_STR |
| 11953 | BGP_STR |
| 11954 | "Address family\n" |
| 11955 | "Address Family modifier\n" |
| 11956 | "BGP RIB advertisement statistics\n") |
| 11957 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11958 | DEFUN (show_bgp_statistics_view, |
| 11959 | show_bgp_statistics_view_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11960 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11961 | SHOW_STR |
| 11962 | BGP_STR |
| 11963 | "BGP view\n" |
| 11964 | "Address family\n" |
| 11965 | "Address family\n" |
| 11966 | "Address Family modifier\n" |
| 11967 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 11968 | "Address Family modifier\n" |
| 11969 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11970 | "BGP RIB advertisement statistics\n") |
| 11971 | { |
| 11972 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 11973 | } |
| 11974 | |
| 11975 | ALIAS (show_bgp_statistics_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11976 | show_bgp_statistics_view_vpnv4_cmd, |
| 11977 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11978 | SHOW_STR |
| 11979 | BGP_STR |
| 11980 | "BGP view\n" |
| 11981 | "Address family\n" |
| 11982 | "Address Family modifier\n" |
| 11983 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11984 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11985 | enum bgp_pcounts |
| 11986 | { |
| 11987 | PCOUNT_ADJ_IN = 0, |
| 11988 | PCOUNT_DAMPED, |
| 11989 | PCOUNT_REMOVED, |
| 11990 | PCOUNT_HISTORY, |
| 11991 | PCOUNT_STALE, |
| 11992 | PCOUNT_VALID, |
| 11993 | PCOUNT_ALL, |
| 11994 | PCOUNT_COUNTED, |
| 11995 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 11996 | PCOUNT_MAX, |
| 11997 | }; |
| 11998 | |
| 11999 | static const char *pcount_strs[] = |
| 12000 | { |
| 12001 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 12002 | [PCOUNT_DAMPED] = "Damped", |
| 12003 | [PCOUNT_REMOVED] = "Removed", |
| 12004 | [PCOUNT_HISTORY] = "History", |
| 12005 | [PCOUNT_STALE] = "Stale", |
| 12006 | [PCOUNT_VALID] = "Valid", |
| 12007 | [PCOUNT_ALL] = "All RIB", |
| 12008 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 12009 | [PCOUNT_PFCNT] = "Useable", |
| 12010 | [PCOUNT_MAX] = NULL, |
| 12011 | }; |
| 12012 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12013 | struct peer_pcounts |
| 12014 | { |
| 12015 | unsigned int count[PCOUNT_MAX]; |
| 12016 | const struct peer *peer; |
| 12017 | const struct bgp_table *table; |
| 12018 | }; |
| 12019 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12020 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12021 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12022 | { |
| 12023 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12024 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 12025 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12026 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12027 | 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] | 12028 | { |
| 12029 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12030 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12031 | |
| 12032 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12033 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12034 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12035 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12036 | for (ri = rn->info; ri; ri = ri->next) |
| 12037 | { |
| 12038 | char buf[SU_ADDRSTRLEN]; |
| 12039 | |
| 12040 | if (ri->peer != peer) |
| 12041 | continue; |
| 12042 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12043 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12044 | |
| 12045 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12046 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12047 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12048 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12049 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12050 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12051 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12052 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12053 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12054 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12055 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12056 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12057 | |
| 12058 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 12059 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12060 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12061 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12062 | plog_warn (peer->log, |
| 12063 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 12064 | peer->host, |
| 12065 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12066 | buf, SU_ADDRSTRLEN), |
| 12067 | rn->p.prefixlen, |
| 12068 | ri->flags); |
| 12069 | } |
| 12070 | else |
| 12071 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12072 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12073 | plog_warn (peer->log, |
| 12074 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 12075 | peer->host, |
| 12076 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12077 | buf, SU_ADDRSTRLEN), |
| 12078 | rn->p.prefixlen, |
| 12079 | ri->flags); |
| 12080 | } |
| 12081 | } |
| 12082 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12083 | return 0; |
| 12084 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12085 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12086 | static int |
| 12087 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 12088 | { |
| 12089 | struct peer_pcounts pcounts = { .peer = peer }; |
| 12090 | unsigned int i; |
| 12091 | |
| 12092 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 12093 | || !peer->bgp->rib[afi][safi]) |
| 12094 | { |
| 12095 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12096 | return CMD_WARNING; |
| 12097 | } |
| 12098 | |
| 12099 | memset (&pcounts, 0, sizeof(pcounts)); |
| 12100 | pcounts.peer = peer; |
| 12101 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 12102 | |
| 12103 | /* in-place call via thread subsystem so as to record execution time |
| 12104 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 12105 | * on just vty_read()). |
| 12106 | */ |
| 12107 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 12108 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12109 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 12110 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 12111 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 12112 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 12113 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 12114 | |
| 12115 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12116 | vty_out (vty, "%20s: %-10d%s", |
| 12117 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12118 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12119 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12120 | { |
| 12121 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 12122 | peer->host, VTY_NEWLINE); |
| 12123 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 12124 | VTY_NEWLINE); |
| 12125 | } |
| 12126 | |
| 12127 | return CMD_SUCCESS; |
| 12128 | } |
| 12129 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12130 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 12131 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 12132 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12133 | SHOW_STR |
| 12134 | IP_STR |
| 12135 | BGP_STR |
| 12136 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12137 | "Neighbor to display information about\n" |
| 12138 | "Neighbor to display information about\n" |
| 12139 | "Display detailed prefix count information\n") |
| 12140 | { |
| 12141 | struct peer *peer; |
| 12142 | |
| 12143 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12144 | if (! peer) |
| 12145 | return CMD_WARNING; |
| 12146 | |
| 12147 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12148 | } |
| 12149 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12150 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 12151 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 12152 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12153 | SHOW_STR |
| 12154 | BGP_STR |
| 12155 | "Address family\n" |
| 12156 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12157 | "Neighbor to display information about\n" |
| 12158 | "Neighbor to display information about\n" |
| 12159 | "Display detailed prefix count information\n") |
| 12160 | { |
| 12161 | struct peer *peer; |
| 12162 | |
| 12163 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12164 | if (! peer) |
| 12165 | return CMD_WARNING; |
| 12166 | |
| 12167 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 12168 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12169 | |
| 12170 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 12171 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 12172 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12173 | SHOW_STR |
| 12174 | IP_STR |
| 12175 | BGP_STR |
| 12176 | "Address family\n" |
| 12177 | "Address Family modifier\n" |
| 12178 | "Address Family modifier\n" |
| 12179 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12180 | "Neighbor to display information about\n" |
| 12181 | "Neighbor to display information about\n" |
| 12182 | "Display detailed prefix count information\n") |
| 12183 | { |
| 12184 | struct peer *peer; |
| 12185 | |
| 12186 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12187 | if (! peer) |
| 12188 | return CMD_WARNING; |
| 12189 | |
| 12190 | if (strncmp (argv[0], "m", 1) == 0) |
| 12191 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 12192 | |
| 12193 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12194 | } |
| 12195 | |
| 12196 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 12197 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 12198 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12199 | SHOW_STR |
| 12200 | IP_STR |
| 12201 | BGP_STR |
| 12202 | "Address family\n" |
| 12203 | "Address Family modifier\n" |
| 12204 | "Address Family modifier\n" |
| 12205 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12206 | "Neighbor to display information about\n" |
| 12207 | "Neighbor to display information about\n" |
| 12208 | "Display detailed prefix count information\n") |
| 12209 | { |
| 12210 | struct peer *peer; |
| 12211 | |
| 12212 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12213 | if (! peer) |
| 12214 | return CMD_WARNING; |
| 12215 | |
| 12216 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 12217 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12218 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12219 | DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts, |
| 12220 | show_bgp_ipv4_safi_neighbor_prefix_counts_cmd, |
| 12221 | "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] | 12222 | SHOW_STR |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12223 | BGP_STR |
| 12224 | "Address family\n" |
| 12225 | "Address Family modifier\n" |
| 12226 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12227 | "Address Family modifier\n" |
| 12228 | "Address Family modifier\n" |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12229 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12230 | "Neighbor to display information about\n" |
| 12231 | "Neighbor to display information about\n" |
| 12232 | "Display detailed prefix count information\n") |
| 12233 | { |
| 12234 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12235 | safi_t safi; |
| 12236 | |
| 12237 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12238 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12239 | return CMD_WARNING; |
| 12240 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12241 | |
| 12242 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12243 | if (! peer) |
| 12244 | return CMD_WARNING; |
| 12245 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12246 | return bgp_peer_counts (vty, peer, AFI_IP, safi); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12247 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12248 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12249 | DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts, |
| 12250 | show_bgp_ipv6_safi_neighbor_prefix_counts_cmd, |
| 12251 | "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12252 | SHOW_STR |
| 12253 | BGP_STR |
| 12254 | "Address family\n" |
| 12255 | "Address Family modifier\n" |
| 12256 | "Address Family modifier\n" |
| 12257 | "Address Family modifier\n" |
| 12258 | "Address Family modifier\n" |
| 12259 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12260 | "Neighbor to display information about\n" |
| 12261 | "Neighbor to display information about\n" |
| 12262 | "Display detailed prefix count information\n") |
| 12263 | { |
| 12264 | struct peer *peer; |
| 12265 | safi_t safi; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12266 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12267 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12268 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12269 | return CMD_WARNING; |
| 12270 | } |
| 12271 | |
| 12272 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12273 | if (! peer) |
| 12274 | return CMD_WARNING; |
| 12275 | |
| 12276 | return bgp_peer_counts (vty, peer, AFI_IP6, safi); |
| 12277 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12278 | |
| 12279 | DEFUN (show_ip_bgp_encap_neighbor_prefix_counts, |
| 12280 | show_ip_bgp_encap_neighbor_prefix_counts_cmd, |
| 12281 | "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] | 12282 | SHOW_STR |
| 12283 | IP_STR |
| 12284 | BGP_STR |
| 12285 | "Address family\n" |
| 12286 | "Address Family modifier\n" |
| 12287 | "Address Family modifier\n" |
| 12288 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12289 | "Neighbor to display information about\n" |
| 12290 | "Neighbor to display information about\n" |
| 12291 | "Display detailed prefix count information\n") |
| 12292 | { |
| 12293 | struct peer *peer; |
| 12294 | |
| 12295 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12296 | if (! peer) |
| 12297 | return CMD_WARNING; |
| 12298 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12299 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12300 | } |
| 12301 | |
| 12302 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12303 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12304 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 12305 | int in) |
| 12306 | { |
| 12307 | struct bgp_table *table; |
| 12308 | struct bgp_adj_in *ain; |
| 12309 | struct bgp_adj_out *adj; |
| 12310 | unsigned long output_count; |
| 12311 | struct bgp_node *rn; |
| 12312 | int header1 = 1; |
| 12313 | struct bgp *bgp; |
| 12314 | int header2 = 1; |
| 12315 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12316 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12317 | |
| 12318 | if (! bgp) |
| 12319 | return; |
| 12320 | |
| 12321 | table = bgp->rib[afi][safi]; |
| 12322 | |
| 12323 | output_count = 0; |
| 12324 | |
| 12325 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 12326 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 12327 | { |
| 12328 | 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] | 12329 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12330 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12331 | |
| 12332 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 12333 | VTY_NEWLINE, VTY_NEWLINE); |
| 12334 | header1 = 0; |
| 12335 | } |
| 12336 | |
| 12337 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12338 | if (in) |
| 12339 | { |
| 12340 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12341 | if (ain->peer == peer) |
| 12342 | { |
| 12343 | if (header1) |
| 12344 | { |
| 12345 | 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] | 12346 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12347 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12348 | header1 = 0; |
| 12349 | } |
| 12350 | if (header2) |
| 12351 | { |
| 12352 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12353 | header2 = 0; |
| 12354 | } |
| 12355 | if (ain->attr) |
| 12356 | { |
| 12357 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 12358 | output_count++; |
| 12359 | } |
| 12360 | } |
| 12361 | } |
| 12362 | else |
| 12363 | { |
| 12364 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 12365 | if (adj->peer == peer) |
| 12366 | { |
| 12367 | if (header1) |
| 12368 | { |
| 12369 | 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] | 12370 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12371 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12372 | header1 = 0; |
| 12373 | } |
| 12374 | if (header2) |
| 12375 | { |
| 12376 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12377 | header2 = 0; |
| 12378 | } |
| 12379 | if (adj->attr) |
| 12380 | { |
| 12381 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 12382 | output_count++; |
| 12383 | } |
| 12384 | } |
| 12385 | } |
| 12386 | |
| 12387 | if (output_count != 0) |
| 12388 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 12389 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 12390 | } |
| 12391 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12392 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12393 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 12394 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12395 | if (! peer || ! peer->afc[afi][safi]) |
| 12396 | { |
| 12397 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12398 | return CMD_WARNING; |
| 12399 | } |
| 12400 | |
| 12401 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 12402 | { |
| 12403 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 12404 | VTY_NEWLINE); |
| 12405 | return CMD_WARNING; |
| 12406 | } |
| 12407 | |
| 12408 | show_adj_route (vty, peer, afi, safi, in); |
| 12409 | |
| 12410 | return CMD_SUCCESS; |
| 12411 | } |
| 12412 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12413 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 12414 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 12415 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12416 | SHOW_STR |
| 12417 | IP_STR |
| 12418 | BGP_STR |
| 12419 | "BGP view\n" |
| 12420 | "View name\n" |
| 12421 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12422 | "Neighbor to display information about\n" |
| 12423 | "Neighbor to display information about\n" |
| 12424 | "Display the routes advertised to a BGP neighbor\n") |
| 12425 | { |
| 12426 | struct peer *peer; |
| 12427 | |
| 12428 | if (argc == 2) |
| 12429 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12430 | else |
| 12431 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12432 | |
| 12433 | if (! peer) |
| 12434 | return CMD_WARNING; |
| 12435 | |
| 12436 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12437 | } |
| 12438 | |
| 12439 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
| 12440 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 12441 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12442 | SHOW_STR |
| 12443 | IP_STR |
| 12444 | BGP_STR |
| 12445 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12446 | "Neighbor to display information about\n" |
| 12447 | "Neighbor to display information about\n" |
| 12448 | "Display the routes advertised to a BGP neighbor\n") |
| 12449 | |
| 12450 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 12451 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 12452 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12453 | SHOW_STR |
| 12454 | IP_STR |
| 12455 | BGP_STR |
| 12456 | "Address family\n" |
| 12457 | "Address Family modifier\n" |
| 12458 | "Address Family modifier\n" |
| 12459 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12460 | "Neighbor to display information about\n" |
| 12461 | "Neighbor to display information about\n" |
| 12462 | "Display the routes advertised to a BGP neighbor\n") |
| 12463 | { |
| 12464 | struct peer *peer; |
| 12465 | |
| 12466 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12467 | if (! peer) |
| 12468 | return CMD_WARNING; |
| 12469 | |
| 12470 | if (strncmp (argv[0], "m", 1) == 0) |
| 12471 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 12472 | |
| 12473 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12474 | } |
| 12475 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12476 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 12477 | show_bgp_view_neighbor_advertised_route_cmd, |
| 12478 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12479 | SHOW_STR |
| 12480 | BGP_STR |
| 12481 | "BGP view\n" |
| 12482 | "View name\n" |
| 12483 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12484 | "Neighbor to display information about\n" |
| 12485 | "Neighbor to display information about\n" |
| 12486 | "Display the routes advertised to a BGP neighbor\n") |
| 12487 | { |
| 12488 | struct peer *peer; |
| 12489 | |
| 12490 | if (argc == 2) |
| 12491 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12492 | else |
| 12493 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12494 | |
| 12495 | if (! peer) |
| 12496 | return CMD_WARNING; |
| 12497 | |
| 12498 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 12499 | } |
| 12500 | |
| 12501 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 12502 | show_bgp_view_neighbor_received_routes_cmd, |
| 12503 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12504 | SHOW_STR |
| 12505 | BGP_STR |
| 12506 | "BGP view\n" |
| 12507 | "View name\n" |
| 12508 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12509 | "Neighbor to display information about\n" |
| 12510 | "Neighbor to display information about\n" |
| 12511 | "Display the received routes from neighbor\n") |
| 12512 | { |
| 12513 | struct peer *peer; |
| 12514 | |
| 12515 | if (argc == 2) |
| 12516 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12517 | else |
| 12518 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12519 | |
| 12520 | if (! peer) |
| 12521 | return CMD_WARNING; |
| 12522 | |
| 12523 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 12524 | } |
| 12525 | |
| 12526 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12527 | show_bgp_neighbor_advertised_route_cmd, |
| 12528 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12529 | SHOW_STR |
| 12530 | BGP_STR |
| 12531 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12532 | "Neighbor to display information about\n" |
| 12533 | "Neighbor to display information about\n" |
| 12534 | "Display the routes advertised to a BGP neighbor\n") |
| 12535 | |
| 12536 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12537 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 12538 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12539 | SHOW_STR |
| 12540 | BGP_STR |
| 12541 | "Address family\n" |
| 12542 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12543 | "Neighbor to display information about\n" |
| 12544 | "Neighbor to display information about\n" |
| 12545 | "Display the routes advertised to a BGP neighbor\n") |
| 12546 | |
| 12547 | /* old command */ |
| 12548 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12549 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 12550 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12551 | SHOW_STR |
| 12552 | IPV6_STR |
| 12553 | BGP_STR |
| 12554 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12555 | "Neighbor to display information about\n" |
| 12556 | "Neighbor to display information about\n" |
| 12557 | "Display the routes advertised to a BGP neighbor\n") |
| 12558 | |
| 12559 | /* old command */ |
| 12560 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 12561 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 12562 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12563 | SHOW_STR |
| 12564 | IPV6_STR |
| 12565 | MBGP_STR |
| 12566 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12567 | "Neighbor to display information about\n" |
| 12568 | "Neighbor to display information about\n" |
| 12569 | "Display the routes advertised to a BGP neighbor\n") |
| 12570 | { |
| 12571 | struct peer *peer; |
| 12572 | |
| 12573 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12574 | if (! peer) |
| 12575 | return CMD_WARNING; |
| 12576 | |
| 12577 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
| 12578 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12579 | |
| 12580 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 12581 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 12582 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12583 | SHOW_STR |
| 12584 | IP_STR |
| 12585 | BGP_STR |
| 12586 | "BGP view\n" |
| 12587 | "View name\n" |
| 12588 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12589 | "Neighbor to display information about\n" |
| 12590 | "Neighbor to display information about\n" |
| 12591 | "Display the received routes from neighbor\n") |
| 12592 | { |
| 12593 | struct peer *peer; |
| 12594 | |
| 12595 | if (argc == 2) |
| 12596 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12597 | else |
| 12598 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12599 | |
| 12600 | if (! peer) |
| 12601 | return CMD_WARNING; |
| 12602 | |
| 12603 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12604 | } |
| 12605 | |
| 12606 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
| 12607 | show_ip_bgp_neighbor_received_routes_cmd, |
| 12608 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12609 | SHOW_STR |
| 12610 | IP_STR |
| 12611 | BGP_STR |
| 12612 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12613 | "Neighbor to display information about\n" |
| 12614 | "Neighbor to display information about\n" |
| 12615 | "Display the received routes from neighbor\n") |
| 12616 | |
| 12617 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12618 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 12619 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12620 | SHOW_STR |
| 12621 | BGP_STR |
| 12622 | "Address family\n" |
| 12623 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12624 | "Neighbor to display information about\n" |
| 12625 | "Neighbor to display information about\n" |
| 12626 | "Display the received routes from neighbor\n") |
| 12627 | |
| 12628 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 12629 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 12630 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12631 | SHOW_STR |
| 12632 | BGP_STR |
| 12633 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12634 | "Neighbor to display information about\n" |
| 12635 | "Neighbor to display information about\n" |
| 12636 | "Display information received from a BGP neighbor\n" |
| 12637 | "Display the prefixlist filter\n") |
| 12638 | { |
| 12639 | char name[BUFSIZ]; |
| 12640 | union sockunion su; |
| 12641 | struct peer *peer; |
| 12642 | int count, ret; |
| 12643 | |
| 12644 | ret = str2sockunion (argv[0], &su); |
| 12645 | if (ret < 0) |
| 12646 | { |
| 12647 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 12648 | return CMD_WARNING; |
| 12649 | } |
| 12650 | |
| 12651 | peer = peer_lookup (NULL, &su); |
| 12652 | if (! peer) |
| 12653 | return CMD_WARNING; |
| 12654 | |
| 12655 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12656 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12657 | if (count) |
| 12658 | { |
| 12659 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12660 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12661 | } |
| 12662 | |
| 12663 | return CMD_SUCCESS; |
| 12664 | } |
| 12665 | |
| 12666 | /* old command */ |
| 12667 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12668 | ipv6_bgp_neighbor_received_routes_cmd, |
| 12669 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12670 | SHOW_STR |
| 12671 | IPV6_STR |
| 12672 | BGP_STR |
| 12673 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12674 | "Neighbor to display information about\n" |
| 12675 | "Neighbor to display information about\n" |
| 12676 | "Display the received routes from neighbor\n") |
| 12677 | |
| 12678 | /* old command */ |
| 12679 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 12680 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 12681 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12682 | SHOW_STR |
| 12683 | IPV6_STR |
| 12684 | MBGP_STR |
| 12685 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12686 | "Neighbor to display information about\n" |
| 12687 | "Neighbor to display information about\n" |
| 12688 | "Display the received routes from neighbor\n") |
| 12689 | { |
| 12690 | struct peer *peer; |
| 12691 | |
| 12692 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12693 | if (! peer) |
| 12694 | return CMD_WARNING; |
| 12695 | |
| 12696 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
| 12697 | } |
| 12698 | |
| 12699 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 12700 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 12701 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12702 | SHOW_STR |
| 12703 | BGP_STR |
| 12704 | "BGP view\n" |
| 12705 | "View name\n" |
| 12706 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12707 | "Neighbor to display information about\n" |
| 12708 | "Neighbor to display information about\n" |
| 12709 | "Display information received from a BGP neighbor\n" |
| 12710 | "Display the prefixlist filter\n") |
| 12711 | { |
| 12712 | char name[BUFSIZ]; |
| 12713 | union sockunion su; |
| 12714 | struct peer *peer; |
| 12715 | struct bgp *bgp; |
| 12716 | int count, ret; |
| 12717 | |
| 12718 | /* BGP structure lookup. */ |
| 12719 | bgp = bgp_lookup_by_name (argv[0]); |
| 12720 | if (bgp == NULL) |
| 12721 | { |
| 12722 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 12723 | return CMD_WARNING; |
| 12724 | } |
| 12725 | |
| 12726 | ret = str2sockunion (argv[1], &su); |
| 12727 | if (ret < 0) |
| 12728 | { |
| 12729 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 12730 | return CMD_WARNING; |
| 12731 | } |
| 12732 | |
| 12733 | peer = peer_lookup (bgp, &su); |
| 12734 | if (! peer) |
| 12735 | return CMD_WARNING; |
| 12736 | |
| 12737 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12738 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12739 | if (count) |
| 12740 | { |
| 12741 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12742 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12743 | } |
| 12744 | |
| 12745 | return CMD_SUCCESS; |
| 12746 | } |
| 12747 | |
| 12748 | |
| 12749 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 12750 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 12751 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12752 | SHOW_STR |
| 12753 | IP_STR |
| 12754 | BGP_STR |
| 12755 | "Address family\n" |
| 12756 | "Address Family modifier\n" |
| 12757 | "Address Family modifier\n" |
| 12758 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12759 | "Neighbor to display information about\n" |
| 12760 | "Neighbor to display information about\n" |
| 12761 | "Display the received routes from neighbor\n") |
| 12762 | { |
| 12763 | struct peer *peer; |
| 12764 | |
| 12765 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12766 | if (! peer) |
| 12767 | return CMD_WARNING; |
| 12768 | |
| 12769 | if (strncmp (argv[0], "m", 1) == 0) |
| 12770 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 12771 | |
| 12772 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12773 | } |
| 12774 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12775 | DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route, |
| 12776 | show_bgp_ipv4_safi_neighbor_advertised_route_cmd, |
| 12777 | "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] | 12778 | SHOW_STR |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12779 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12780 | "Address Family modifier\n" |
| 12781 | "Address Family modifier\n" |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12782 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12783 | "Neighbor to display information about\n" |
| 12784 | "Neighbor to display information about\n" |
| 12785 | "Display the routes advertised to a BGP neighbor\n") |
| 12786 | { |
| 12787 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12788 | safi_t safi; |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12789 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12790 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12791 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12792 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12793 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12794 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12795 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12796 | if (! peer) |
| 12797 | return CMD_WARNING; |
| 12798 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12799 | return peer_adj_routes (vty, peer, AFI_IP, safi, 0); |
| 12800 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12801 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12802 | DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route, |
| 12803 | show_bgp_ipv6_safi_neighbor_advertised_route_cmd, |
| 12804 | "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12805 | SHOW_STR |
| 12806 | BGP_STR |
| 12807 | "Address Family modifier\n" |
| 12808 | "Address Family modifier\n" |
| 12809 | "Address Family modifier\n" |
| 12810 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12811 | "Neighbor to display information about\n" |
| 12812 | "Neighbor to display information about\n" |
| 12813 | "Display the routes advertised to a BGP neighbor\n") |
| 12814 | { |
| 12815 | struct peer *peer; |
| 12816 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12817 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12818 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12819 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12820 | return CMD_WARNING; |
| 12821 | } |
| 12822 | |
| 12823 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12824 | if (! peer) |
| 12825 | return CMD_WARNING; |
| 12826 | |
| 12827 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12828 | } |
| 12829 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12830 | DEFUN (show_bgp_view_ipv6_neighbor_advertised_route, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12831 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 12832 | "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] | 12833 | SHOW_STR |
| 12834 | BGP_STR |
| 12835 | "BGP view\n" |
| 12836 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12837 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12838 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12839 | "Neighbor to display information about\n" |
| 12840 | "Neighbor to display information about\n" |
| 12841 | "Display the routes advertised to a BGP neighbor\n") |
| 12842 | { |
| 12843 | struct peer *peer; |
| 12844 | |
| 12845 | if (argc == 2) |
| 12846 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12847 | else |
| 12848 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12849 | |
| 12850 | if (! peer) |
| 12851 | return CMD_WARNING; |
| 12852 | |
| 12853 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 12854 | } |
| 12855 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12856 | DEFUN (show_bgp_view_ipv6_neighbor_received_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12857 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 12858 | "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] | 12859 | SHOW_STR |
| 12860 | BGP_STR |
| 12861 | "BGP view\n" |
| 12862 | "View name\n" |
| 12863 | "Address family\n" |
| 12864 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12865 | "Neighbor to display information about\n" |
| 12866 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12867 | "Display the received routes from neighbor\n") |
| 12868 | { |
| 12869 | struct peer *peer; |
| 12870 | |
| 12871 | if (argc == 2) |
| 12872 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12873 | else |
| 12874 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12875 | |
| 12876 | if (! peer) |
| 12877 | return CMD_WARNING; |
| 12878 | |
| 12879 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 12880 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12881 | |
| 12882 | DEFUN (show_bgp_ipv4_safi_neighbor_received_routes, |
| 12883 | show_bgp_ipv4_safi_neighbor_received_routes_cmd, |
| 12884 | "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] | 12885 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12886 | BGP_STR |
| 12887 | "Address family\n" |
| 12888 | "Address Family modifier\n" |
| 12889 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12890 | "Address Family modifier\n" |
| 12891 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12892 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12893 | "Neighbor to display information about\n" |
| 12894 | "Neighbor to display information about\n" |
| 12895 | "Display the received routes from neighbor\n") |
| 12896 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12897 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12898 | safi_t safi; |
| 12899 | |
| 12900 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12901 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12902 | return CMD_WARNING; |
| 12903 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12904 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12905 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12906 | if (! peer) |
| 12907 | return CMD_WARNING; |
| 12908 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12909 | return peer_adj_routes (vty, peer, AFI_IP, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12910 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12911 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12912 | DEFUN (show_bgp_ipv6_safi_neighbor_received_routes, |
| 12913 | show_bgp_ipv6_safi_neighbor_received_routes_cmd, |
| 12914 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12915 | SHOW_STR |
| 12916 | BGP_STR |
| 12917 | "Address family\n" |
| 12918 | "Address Family modifier\n" |
| 12919 | "Address Family modifier\n" |
| 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 received routes from neighbor\n") |
| 12926 | { |
| 12927 | struct peer *peer; |
| 12928 | safi_t safi; |
| 12929 | |
| 12930 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12931 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12932 | return CMD_WARNING; |
| 12933 | } |
| 12934 | |
| 12935 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12936 | if (! peer) |
| 12937 | return CMD_WARNING; |
| 12938 | |
| 12939 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 1); |
| 12940 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12941 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12942 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 12943 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12944 | "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] | 12945 | SHOW_STR |
| 12946 | BGP_STR |
| 12947 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 12948 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12949 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12950 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12951 | "Address family modifier\n" |
| 12952 | "Address family modifier\n" |
| 12953 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12954 | "Neighbor to display information about\n" |
| 12955 | "Neighbor to display information about\n" |
| 12956 | "Display the advertised routes to neighbor\n" |
| 12957 | "Display the received routes from neighbor\n") |
| 12958 | { |
| 12959 | int afi; |
| 12960 | int safi; |
| 12961 | int in; |
| 12962 | struct peer *peer; |
| 12963 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 12964 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12965 | |
| 12966 | if (! peer) |
| 12967 | return CMD_WARNING; |
| 12968 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12969 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 12970 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 12971 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12972 | |
| 12973 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 12974 | } |
| 12975 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12976 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 12977 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 12978 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12979 | SHOW_STR |
| 12980 | IP_STR |
| 12981 | BGP_STR |
| 12982 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12983 | "Neighbor to display information about\n" |
| 12984 | "Neighbor to display information about\n" |
| 12985 | "Display information received from a BGP neighbor\n" |
| 12986 | "Display the prefixlist filter\n") |
| 12987 | { |
| 12988 | char name[BUFSIZ]; |
| 12989 | union sockunion su; |
| 12990 | struct peer *peer; |
| 12991 | int count, ret; |
| 12992 | |
| 12993 | ret = str2sockunion (argv[0], &su); |
| 12994 | if (ret < 0) |
| 12995 | { |
| 12996 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 12997 | return CMD_WARNING; |
| 12998 | } |
| 12999 | |
| 13000 | peer = peer_lookup (NULL, &su); |
| 13001 | if (! peer) |
| 13002 | return CMD_WARNING; |
| 13003 | |
| 13004 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13005 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13006 | if (count) |
| 13007 | { |
| 13008 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13009 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13010 | } |
| 13011 | |
| 13012 | return CMD_SUCCESS; |
| 13013 | } |
| 13014 | |
| 13015 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 13016 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 13017 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13018 | SHOW_STR |
| 13019 | IP_STR |
| 13020 | BGP_STR |
| 13021 | "Address family\n" |
| 13022 | "Address Family modifier\n" |
| 13023 | "Address Family modifier\n" |
| 13024 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13025 | "Neighbor to display information about\n" |
| 13026 | "Neighbor to display information about\n" |
| 13027 | "Display information received from a BGP neighbor\n" |
| 13028 | "Display the prefixlist filter\n") |
| 13029 | { |
| 13030 | char name[BUFSIZ]; |
| 13031 | union sockunion su; |
| 13032 | struct peer *peer; |
| 13033 | int count, ret; |
| 13034 | |
| 13035 | ret = str2sockunion (argv[1], &su); |
| 13036 | if (ret < 0) |
| 13037 | { |
| 13038 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13039 | return CMD_WARNING; |
| 13040 | } |
| 13041 | |
| 13042 | peer = peer_lookup (NULL, &su); |
| 13043 | if (! peer) |
| 13044 | return CMD_WARNING; |
| 13045 | |
| 13046 | if (strncmp (argv[0], "m", 1) == 0) |
| 13047 | { |
| 13048 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 13049 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13050 | if (count) |
| 13051 | { |
| 13052 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 13053 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13054 | } |
| 13055 | } |
| 13056 | else |
| 13057 | { |
| 13058 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13059 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13060 | if (count) |
| 13061 | { |
| 13062 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13063 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13064 | } |
| 13065 | } |
| 13066 | |
| 13067 | return CMD_SUCCESS; |
| 13068 | } |
| 13069 | |
| 13070 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 13071 | show_bgp_neighbor_received_routes_cmd, |
| 13072 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13073 | SHOW_STR |
| 13074 | BGP_STR |
| 13075 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13076 | "Neighbor to display information about\n" |
| 13077 | "Neighbor to display information about\n" |
| 13078 | "Display the received routes from neighbor\n") |
| 13079 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13080 | DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter, |
| 13081 | show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd, |
| 13082 | "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] | 13083 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13084 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13085 | IP_STR |
| 13086 | "Address Family modifier\n" |
| 13087 | "Address Family modifier\n" |
| 13088 | "Address Family modifier\n" |
| 13089 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13090 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13091 | "Neighbor to display information about\n" |
| 13092 | "Neighbor to display information about\n" |
| 13093 | "Display information received from a BGP neighbor\n" |
| 13094 | "Display the prefixlist filter\n") |
| 13095 | { |
| 13096 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13097 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13098 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13099 | int count, ret; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13100 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13101 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13102 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13103 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13104 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13105 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13106 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13107 | ret = str2sockunion (argv[1], &su); |
| 13108 | if (ret < 0) |
| 13109 | { |
| 13110 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13111 | return CMD_WARNING; |
| 13112 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13113 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13114 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13115 | if (! peer) |
| 13116 | return CMD_WARNING; |
| 13117 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13118 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi); |
| 13119 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13120 | if (count) { |
| 13121 | vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13122 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13123 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13124 | |
| 13125 | return CMD_SUCCESS; |
| 13126 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13127 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13128 | DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter, |
| 13129 | show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd, |
| 13130 | "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] | 13131 | SHOW_STR |
| 13132 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13133 | IP_STR |
| 13134 | "Address Family modifier\n" |
| 13135 | "Address Family modifier\n" |
| 13136 | "Address Family modifier\n" |
| 13137 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13138 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13139 | "Neighbor to display information about\n" |
| 13140 | "Neighbor to display information about\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13141 | "Display information received from a BGP neighbor\n" |
| 13142 | "Display the prefixlist filter\n") |
| 13143 | { |
| 13144 | char name[BUFSIZ]; |
| 13145 | union sockunion su; |
| 13146 | struct peer *peer; |
| 13147 | int count, ret; |
| 13148 | safi_t safi; |
| 13149 | |
| 13150 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13151 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13152 | return CMD_WARNING; |
| 13153 | } |
| 13154 | |
| 13155 | ret = str2sockunion (argv[1], &su); |
| 13156 | if (ret < 0) |
| 13157 | { |
| 13158 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13159 | return CMD_WARNING; |
| 13160 | } |
| 13161 | |
| 13162 | peer = peer_lookup (NULL, &su); |
| 13163 | if (! peer) |
| 13164 | return CMD_WARNING; |
| 13165 | |
| 13166 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi); |
| 13167 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13168 | if (count) { |
| 13169 | vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13170 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13171 | } |
| 13172 | |
| 13173 | return CMD_SUCCESS; |
| 13174 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13175 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13176 | DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13177 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 13178 | "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] | 13179 | SHOW_STR |
| 13180 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13181 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13182 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13183 | "Neighbor to display information about\n" |
| 13184 | "Neighbor to display information about\n" |
| 13185 | "Display information received from a BGP neighbor\n" |
| 13186 | "Display the prefixlist filter\n") |
| 13187 | { |
| 13188 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13189 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13190 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13191 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13192 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13193 | ret = str2sockunion (argv[0], &su); |
| 13194 | if (ret < 0) |
| 13195 | { |
| 13196 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13197 | return CMD_WARNING; |
| 13198 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13199 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13200 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13201 | if (! peer) |
| 13202 | return CMD_WARNING; |
| 13203 | |
| 13204 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13205 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13206 | if (count) |
| 13207 | { |
| 13208 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13209 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13210 | } |
| 13211 | |
| 13212 | return CMD_SUCCESS; |
| 13213 | } |
| 13214 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13215 | DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13216 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 13217 | "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] | 13218 | SHOW_STR |
| 13219 | BGP_STR |
| 13220 | "BGP view\n" |
| 13221 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13222 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13223 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13224 | "Neighbor to display information about\n" |
| 13225 | "Neighbor to display information about\n" |
| 13226 | "Display information received from a BGP neighbor\n" |
| 13227 | "Display the prefixlist filter\n") |
| 13228 | { |
| 13229 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13230 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13231 | struct peer *peer; |
| 13232 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13233 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13234 | |
| 13235 | /* BGP structure lookup. */ |
| 13236 | bgp = bgp_lookup_by_name (argv[0]); |
| 13237 | if (bgp == NULL) |
| 13238 | { |
| 13239 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13240 | return CMD_WARNING; |
| 13241 | } |
| 13242 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13243 | ret = str2sockunion (argv[1], &su); |
| 13244 | if (ret < 0) |
| 13245 | { |
| 13246 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13247 | return CMD_WARNING; |
| 13248 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13249 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13250 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13251 | if (! peer) |
| 13252 | return CMD_WARNING; |
| 13253 | |
| 13254 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13255 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13256 | if (count) |
| 13257 | { |
| 13258 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13259 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13260 | } |
| 13261 | |
| 13262 | return CMD_SUCCESS; |
| 13263 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 13264 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 13265 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13266 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13267 | safi_t safi, enum bgp_show_type type) |
| 13268 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13269 | if (! peer || ! peer->afc[afi][safi]) |
| 13270 | { |
| 13271 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13272 | return CMD_WARNING; |
| 13273 | } |
| 13274 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 13275 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13276 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13277 | DEFUN (show_ip_bgp_neighbor_routes, |
| 13278 | show_ip_bgp_neighbor_routes_cmd, |
| 13279 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 13280 | SHOW_STR |
| 13281 | IP_STR |
| 13282 | BGP_STR |
| 13283 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13284 | "Neighbor to display information about\n" |
| 13285 | "Neighbor to display information about\n" |
| 13286 | "Display routes learned from neighbor\n") |
| 13287 | { |
| 13288 | struct peer *peer; |
| 13289 | |
| 13290 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13291 | if (! peer) |
| 13292 | return CMD_WARNING; |
| 13293 | |
| 13294 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13295 | bgp_show_type_neighbor); |
| 13296 | } |
| 13297 | |
| 13298 | DEFUN (show_ip_bgp_neighbor_flap, |
| 13299 | show_ip_bgp_neighbor_flap_cmd, |
| 13300 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 13301 | SHOW_STR |
| 13302 | IP_STR |
| 13303 | BGP_STR |
| 13304 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13305 | "Neighbor to display information about\n" |
| 13306 | "Neighbor to display information about\n" |
| 13307 | "Display flap statistics of the routes learned from neighbor\n") |
| 13308 | { |
| 13309 | struct peer *peer; |
| 13310 | |
| 13311 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13312 | if (! peer) |
| 13313 | return CMD_WARNING; |
| 13314 | |
| 13315 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13316 | bgp_show_type_flap_neighbor); |
| 13317 | } |
| 13318 | |
| 13319 | DEFUN (show_ip_bgp_neighbor_damp, |
| 13320 | show_ip_bgp_neighbor_damp_cmd, |
| 13321 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13322 | SHOW_STR |
| 13323 | IP_STR |
| 13324 | BGP_STR |
| 13325 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13326 | "Neighbor to display information about\n" |
| 13327 | "Neighbor to display information about\n" |
| 13328 | "Display the dampened routes received from neighbor\n") |
| 13329 | { |
| 13330 | struct peer *peer; |
| 13331 | |
| 13332 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13333 | if (! peer) |
| 13334 | return CMD_WARNING; |
| 13335 | |
| 13336 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13337 | bgp_show_type_damp_neighbor); |
| 13338 | } |
| 13339 | |
| 13340 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 13341 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 13342 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13343 | SHOW_STR |
| 13344 | IP_STR |
| 13345 | BGP_STR |
| 13346 | "Address family\n" |
| 13347 | "Address Family modifier\n" |
| 13348 | "Address Family modifier\n" |
| 13349 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13350 | "Neighbor to display information about\n" |
| 13351 | "Neighbor to display information about\n" |
| 13352 | "Display routes learned from neighbor\n") |
| 13353 | { |
| 13354 | struct peer *peer; |
| 13355 | |
| 13356 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13357 | if (! peer) |
| 13358 | return CMD_WARNING; |
| 13359 | |
| 13360 | if (strncmp (argv[0], "m", 1) == 0) |
| 13361 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
| 13362 | bgp_show_type_neighbor); |
| 13363 | |
| 13364 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13365 | bgp_show_type_neighbor); |
| 13366 | } |
| 13367 | |
| 13368 | DEFUN (show_ip_bgp_view_rsclient, |
| 13369 | show_ip_bgp_view_rsclient_cmd, |
| 13370 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 13371 | SHOW_STR |
| 13372 | IP_STR |
| 13373 | BGP_STR |
| 13374 | "BGP view\n" |
| 13375 | "View name\n" |
| 13376 | "Information about Route Server Client\n" |
| 13377 | NEIGHBOR_ADDR_STR) |
| 13378 | { |
| 13379 | struct bgp_table *table; |
| 13380 | struct peer *peer; |
| 13381 | |
| 13382 | if (argc == 2) |
| 13383 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13384 | else |
| 13385 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13386 | |
| 13387 | if (! peer) |
| 13388 | return CMD_WARNING; |
| 13389 | |
| 13390 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13391 | { |
| 13392 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13393 | VTY_NEWLINE); |
| 13394 | return CMD_WARNING; |
| 13395 | } |
| 13396 | |
| 13397 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13398 | PEER_FLAG_RSERVER_CLIENT)) |
| 13399 | { |
| 13400 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13401 | VTY_NEWLINE); |
| 13402 | return CMD_WARNING; |
| 13403 | } |
| 13404 | |
| 13405 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 13406 | |
| 13407 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13408 | } |
| 13409 | |
| 13410 | ALIAS (show_ip_bgp_view_rsclient, |
| 13411 | show_ip_bgp_rsclient_cmd, |
| 13412 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 13413 | SHOW_STR |
| 13414 | IP_STR |
| 13415 | BGP_STR |
| 13416 | "Information about Route Server Client\n" |
| 13417 | NEIGHBOR_ADDR_STR) |
| 13418 | |
| 13419 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 13420 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 13421 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13422 | SHOW_STR |
| 13423 | BGP_STR |
| 13424 | "BGP view\n" |
| 13425 | "View name\n" |
| 13426 | "Address family\n" |
| 13427 | "Address Family modifier\n" |
| 13428 | "Address Family modifier\n" |
| 13429 | "Information about Route Server Client\n" |
| 13430 | NEIGHBOR_ADDR_STR) |
| 13431 | { |
| 13432 | struct bgp_table *table; |
| 13433 | struct peer *peer; |
| 13434 | safi_t safi; |
| 13435 | |
| 13436 | if (argc == 3) { |
| 13437 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13438 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13439 | } else { |
| 13440 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13441 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13442 | } |
| 13443 | |
| 13444 | if (! peer) |
| 13445 | return CMD_WARNING; |
| 13446 | |
| 13447 | if (! peer->afc[AFI_IP][safi]) |
| 13448 | { |
| 13449 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13450 | VTY_NEWLINE); |
| 13451 | return CMD_WARNING; |
| 13452 | } |
| 13453 | |
| 13454 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13455 | PEER_FLAG_RSERVER_CLIENT)) |
| 13456 | { |
| 13457 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13458 | VTY_NEWLINE); |
| 13459 | return CMD_WARNING; |
| 13460 | } |
| 13461 | |
| 13462 | table = peer->rib[AFI_IP][safi]; |
| 13463 | |
| 13464 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13465 | } |
| 13466 | |
| 13467 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 13468 | show_bgp_ipv4_safi_rsclient_cmd, |
| 13469 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13470 | SHOW_STR |
| 13471 | BGP_STR |
| 13472 | "Address family\n" |
| 13473 | "Address Family modifier\n" |
| 13474 | "Address Family modifier\n" |
| 13475 | "Information about Route Server Client\n" |
| 13476 | NEIGHBOR_ADDR_STR) |
| 13477 | |
| 13478 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 13479 | show_ip_bgp_view_rsclient_route_cmd, |
| 13480 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13481 | SHOW_STR |
| 13482 | IP_STR |
| 13483 | BGP_STR |
| 13484 | "BGP view\n" |
| 13485 | "View name\n" |
| 13486 | "Information about Route Server Client\n" |
| 13487 | NEIGHBOR_ADDR_STR |
| 13488 | "Network in the BGP routing table to display\n") |
| 13489 | { |
| 13490 | struct bgp *bgp; |
| 13491 | struct peer *peer; |
| 13492 | |
| 13493 | /* BGP structure lookup. */ |
| 13494 | if (argc == 3) |
| 13495 | { |
| 13496 | bgp = bgp_lookup_by_name (argv[0]); |
| 13497 | if (bgp == NULL) |
| 13498 | { |
| 13499 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13500 | return CMD_WARNING; |
| 13501 | } |
| 13502 | } |
| 13503 | else |
| 13504 | { |
| 13505 | bgp = bgp_get_default (); |
| 13506 | if (bgp == NULL) |
| 13507 | { |
| 13508 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13509 | return CMD_WARNING; |
| 13510 | } |
| 13511 | } |
| 13512 | |
| 13513 | if (argc == 3) |
| 13514 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13515 | else |
| 13516 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13517 | |
| 13518 | if (! peer) |
| 13519 | return CMD_WARNING; |
| 13520 | |
| 13521 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13522 | { |
| 13523 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13524 | VTY_NEWLINE); |
| 13525 | return CMD_WARNING; |
| 13526 | } |
| 13527 | |
| 13528 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13529 | PEER_FLAG_RSERVER_CLIENT)) |
| 13530 | { |
| 13531 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13532 | VTY_NEWLINE); |
| 13533 | return CMD_WARNING; |
| 13534 | } |
| 13535 | |
| 13536 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 13537 | (argc == 3) ? argv[2] : argv[1], |
| 13538 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 13539 | } |
| 13540 | |
| 13541 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 13542 | show_ip_bgp_rsclient_route_cmd, |
| 13543 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13544 | SHOW_STR |
| 13545 | IP_STR |
| 13546 | BGP_STR |
| 13547 | "Information about Route Server Client\n" |
| 13548 | NEIGHBOR_ADDR_STR |
| 13549 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13550 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13551 | DEFUN (show_bgp_ipv4_safi_neighbor_flap, |
| 13552 | show_bgp_ipv4_safi_neighbor_flap_cmd, |
| 13553 | "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] | 13554 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13555 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13556 | "Address Family Modifier\n" |
| 13557 | "Address Family Modifier\n" |
| 13558 | "Address Family Modifier\n" |
| 13559 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13560 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13561 | "Neighbor to display information about\n" |
| 13562 | "Neighbor to display information about\n" |
| 13563 | "Display flap statistics of the routes learned from neighbor\n") |
| 13564 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13565 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13566 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13567 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13568 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13569 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13570 | return CMD_WARNING; |
| 13571 | } |
| 13572 | |
| 13573 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13574 | if (! peer) |
| 13575 | return CMD_WARNING; |
| 13576 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13577 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13578 | bgp_show_type_flap_neighbor); |
| 13579 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13580 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13581 | DEFUN (show_bgp_ipv6_safi_neighbor_flap, |
| 13582 | show_bgp_ipv6_safi_neighbor_flap_cmd, |
| 13583 | "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] | 13584 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13585 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13586 | "Address Family Modifier\n" |
| 13587 | "Address Family Modifier\n" |
| 13588 | "Address Family Modifier\n" |
| 13589 | "Address Family Modifier\n" |
| 13590 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13591 | "Neighbor to display information about\n" |
| 13592 | "Neighbor to display information about\n" |
| 13593 | "Display flap statistics of the routes learned from neighbor\n") |
| 13594 | { |
| 13595 | struct peer *peer; |
| 13596 | safi_t safi; |
| 13597 | |
| 13598 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13599 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13600 | return CMD_WARNING; |
| 13601 | } |
| 13602 | |
| 13603 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13604 | if (! peer) |
| 13605 | return CMD_WARNING; |
| 13606 | |
| 13607 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13608 | bgp_show_type_flap_neighbor); |
| 13609 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13610 | |
| 13611 | DEFUN (show_bgp_ipv4_safi_neighbor_damp, |
| 13612 | show_bgp_ipv4_safi_neighbor_damp_cmd, |
| 13613 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13614 | SHOW_STR |
| 13615 | BGP_STR |
| 13616 | "Address Family Modifier\n" |
| 13617 | "Address Family Modifier\n" |
| 13618 | "Address Family Modifier\n" |
| 13619 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13620 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13621 | "Neighbor to display information about\n" |
| 13622 | "Neighbor to display information about\n" |
| 13623 | "Display the dampened routes received from neighbor\n") |
| 13624 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13625 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13626 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13627 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13628 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13629 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13630 | return CMD_WARNING; |
| 13631 | } |
| 13632 | |
| 13633 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13634 | if (! peer) |
| 13635 | return CMD_WARNING; |
| 13636 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13637 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13638 | bgp_show_type_damp_neighbor); |
| 13639 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13640 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13641 | DEFUN (show_bgp_ipv6_safi_neighbor_damp, |
| 13642 | show_bgp_ipv6_safi_neighbor_damp_cmd, |
| 13643 | "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] | 13644 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13645 | BGP_STR |
| 13646 | "Address Family Modifier\n" |
| 13647 | "Address Family Modifier\n" |
| 13648 | "Address Family Modifier\n" |
| 13649 | "Address Family Modifier\n" |
| 13650 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13651 | "Neighbor to display information about\n" |
| 13652 | "Neighbor to display information about\n" |
| 13653 | "Display the dampened routes received from neighbor\n") |
| 13654 | { |
| 13655 | struct peer *peer; |
| 13656 | safi_t safi; |
| 13657 | |
| 13658 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13659 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13660 | return CMD_WARNING; |
| 13661 | } |
| 13662 | |
| 13663 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13664 | if (! peer) |
| 13665 | return CMD_WARNING; |
| 13666 | |
| 13667 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13668 | bgp_show_type_damp_neighbor); |
| 13669 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13670 | |
| 13671 | DEFUN (show_bgp_ipv4_safi_neighbor_routes, |
| 13672 | show_bgp_ipv4_safi_neighbor_routes_cmd, |
| 13673 | "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13674 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13675 | BGP_STR |
| 13676 | "Address family\n" |
| 13677 | "Address Family modifier\n" |
| 13678 | "Address Family modifier\n" |
| 13679 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13680 | "Neighbor to display information about\n" |
| 13681 | "Neighbor to display information about\n" |
| 13682 | "Display routes learned from neighbor\n") |
| 13683 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13684 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13685 | safi_t safi; |
| 13686 | |
| 13687 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13688 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13689 | return CMD_WARNING; |
| 13690 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13691 | |
| 13692 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13693 | if (! peer) |
| 13694 | return CMD_WARNING; |
| 13695 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13696 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13697 | bgp_show_type_neighbor); |
| 13698 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13699 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13700 | DEFUN (show_bgp_ipv6_safi_neighbor_routes, |
| 13701 | show_bgp_ipv6_safi_neighbor_routes_cmd, |
| 13702 | "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] | 13703 | SHOW_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13704 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13705 | "Address family\n" |
| 13706 | "Address Family modifier\n" |
| 13707 | "Address Family modifier\n" |
| 13708 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13709 | NEIGHBOR_ADDR_STR |
| 13710 | NEIGHBOR_ADDR_STR |
| 13711 | "Display routes learned from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13712 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13713 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13714 | safi_t safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13715 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13716 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13717 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13718 | return CMD_WARNING; |
| 13719 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13720 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13721 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13722 | if (! peer) |
| 13723 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13724 | |
| 13725 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13726 | bgp_show_type_neighbor); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13727 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13728 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13729 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 13730 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 13731 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13732 | SHOW_STR |
| 13733 | BGP_STR |
| 13734 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13735 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13736 | "Address family\n" |
| 13737 | "Address Family modifier\n" |
| 13738 | "Address Family modifier\n" |
| 13739 | "Information about Route Server Client\n" |
| 13740 | NEIGHBOR_ADDR_STR |
| 13741 | "Network in the BGP routing table to display\n") |
| 13742 | { |
| 13743 | struct bgp *bgp; |
| 13744 | struct peer *peer; |
| 13745 | safi_t safi; |
| 13746 | |
| 13747 | /* BGP structure lookup. */ |
| 13748 | if (argc == 4) |
| 13749 | { |
| 13750 | bgp = bgp_lookup_by_name (argv[0]); |
| 13751 | if (bgp == NULL) |
| 13752 | { |
| 13753 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13754 | return CMD_WARNING; |
| 13755 | } |
| 13756 | } |
| 13757 | else |
| 13758 | { |
| 13759 | bgp = bgp_get_default (); |
| 13760 | if (bgp == NULL) |
| 13761 | { |
| 13762 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13763 | return CMD_WARNING; |
| 13764 | } |
| 13765 | } |
| 13766 | |
| 13767 | if (argc == 4) { |
| 13768 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13769 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13770 | } else { |
| 13771 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13772 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13773 | } |
| 13774 | |
| 13775 | if (! peer) |
| 13776 | return CMD_WARNING; |
| 13777 | |
| 13778 | if (! peer->afc[AFI_IP][safi]) |
| 13779 | { |
| 13780 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13781 | VTY_NEWLINE); |
| 13782 | return CMD_WARNING; |
| 13783 | } |
| 13784 | |
| 13785 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13786 | PEER_FLAG_RSERVER_CLIENT)) |
| 13787 | { |
| 13788 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13789 | VTY_NEWLINE); |
| 13790 | return CMD_WARNING; |
| 13791 | } |
| 13792 | |
| 13793 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 13794 | (argc == 4) ? argv[3] : argv[2], |
| 13795 | AFI_IP, safi, NULL, 0); |
| 13796 | } |
| 13797 | |
| 13798 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 13799 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 13800 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13801 | SHOW_STR |
| 13802 | BGP_STR |
| 13803 | "Address family\n" |
| 13804 | "Address Family modifier\n" |
| 13805 | "Address Family modifier\n" |
| 13806 | "Information about Route Server Client\n" |
| 13807 | NEIGHBOR_ADDR_STR |
| 13808 | "Network in the BGP routing table to display\n") |
| 13809 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13810 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13811 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 13812 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 13813 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 13814 | SHOW_STR |
| 13815 | BGP_STR |
| 13816 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13817 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13818 | "Address family\n" |
| 13819 | "Address Family modifier\n" |
| 13820 | "Address Family modifier\n" |
| 13821 | "Information about Route Server Client\n" |
| 13822 | NEIGHBOR_ADDR_STR |
| 13823 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 13824 | { |
| 13825 | struct bgp *bgp; |
| 13826 | struct peer *peer; |
| 13827 | safi_t safi; |
| 13828 | |
| 13829 | /* BGP structure lookup. */ |
| 13830 | if (argc == 4) |
| 13831 | { |
| 13832 | bgp = bgp_lookup_by_name (argv[0]); |
| 13833 | if (bgp == NULL) |
| 13834 | { |
| 13835 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13836 | return CMD_WARNING; |
| 13837 | } |
| 13838 | } |
| 13839 | else |
| 13840 | { |
| 13841 | bgp = bgp_get_default (); |
| 13842 | if (bgp == NULL) |
| 13843 | { |
| 13844 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13845 | return CMD_WARNING; |
| 13846 | } |
| 13847 | } |
| 13848 | |
| 13849 | if (argc == 4) { |
| 13850 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13851 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13852 | } else { |
| 13853 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13854 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13855 | } |
| 13856 | |
| 13857 | if (! peer) |
| 13858 | return CMD_WARNING; |
| 13859 | |
| 13860 | if (! peer->afc[AFI_IP][safi]) |
| 13861 | { |
| 13862 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13863 | VTY_NEWLINE); |
| 13864 | return CMD_WARNING; |
| 13865 | } |
| 13866 | |
| 13867 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13868 | PEER_FLAG_RSERVER_CLIENT)) |
| 13869 | { |
| 13870 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13871 | VTY_NEWLINE); |
| 13872 | return CMD_WARNING; |
| 13873 | } |
| 13874 | |
| 13875 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 13876 | (argc == 4) ? argv[3] : argv[2], |
| 13877 | AFI_IP, safi, NULL, 1); |
| 13878 | } |
| 13879 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13880 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 13881 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 13882 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 13883 | SHOW_STR |
| 13884 | IP_STR |
| 13885 | BGP_STR |
| 13886 | "BGP view\n" |
| 13887 | "View name\n" |
| 13888 | "Information about Route Server Client\n" |
| 13889 | NEIGHBOR_ADDR_STR |
| 13890 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 13891 | { |
| 13892 | struct bgp *bgp; |
| 13893 | struct peer *peer; |
| 13894 | |
| 13895 | /* BGP structure lookup. */ |
| 13896 | if (argc == 3) |
| 13897 | { |
| 13898 | bgp = bgp_lookup_by_name (argv[0]); |
| 13899 | if (bgp == NULL) |
| 13900 | { |
| 13901 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13902 | return CMD_WARNING; |
| 13903 | } |
| 13904 | } |
| 13905 | else |
| 13906 | { |
| 13907 | bgp = bgp_get_default (); |
| 13908 | if (bgp == NULL) |
| 13909 | { |
| 13910 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13911 | return CMD_WARNING; |
| 13912 | } |
| 13913 | } |
| 13914 | |
| 13915 | if (argc == 3) |
| 13916 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13917 | else |
| 13918 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13919 | |
| 13920 | if (! peer) |
| 13921 | return CMD_WARNING; |
| 13922 | |
| 13923 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13924 | { |
| 13925 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13926 | VTY_NEWLINE); |
| 13927 | return CMD_WARNING; |
| 13928 | } |
| 13929 | |
| 13930 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13931 | PEER_FLAG_RSERVER_CLIENT)) |
| 13932 | { |
| 13933 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13934 | VTY_NEWLINE); |
| 13935 | return CMD_WARNING; |
| 13936 | } |
| 13937 | |
| 13938 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 13939 | (argc == 3) ? argv[2] : argv[1], |
| 13940 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 13941 | } |
| 13942 | |
| 13943 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 13944 | show_ip_bgp_rsclient_prefix_cmd, |
| 13945 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 13946 | SHOW_STR |
| 13947 | IP_STR |
| 13948 | BGP_STR |
| 13949 | "Information about Route Server Client\n" |
| 13950 | NEIGHBOR_ADDR_STR |
| 13951 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 13952 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13953 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 13954 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 13955 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 13956 | SHOW_STR |
| 13957 | BGP_STR |
| 13958 | "Address family\n" |
| 13959 | "Address Family modifier\n" |
| 13960 | "Address Family modifier\n" |
| 13961 | "Information about Route Server Client\n" |
| 13962 | NEIGHBOR_ADDR_STR |
| 13963 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13964 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13965 | DEFUN (show_bgp_view_ipv6_neighbor_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13966 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 13967 | "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] | 13968 | SHOW_STR |
| 13969 | BGP_STR |
| 13970 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13971 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13972 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13973 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13974 | "Neighbor to display information about\n" |
| 13975 | "Neighbor to display information about\n" |
| 13976 | "Display routes learned from neighbor\n") |
| 13977 | { |
| 13978 | struct peer *peer; |
| 13979 | |
| 13980 | if (argc == 2) |
| 13981 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13982 | else |
| 13983 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13984 | |
| 13985 | if (! peer) |
| 13986 | return CMD_WARNING; |
| 13987 | |
| 13988 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 13989 | bgp_show_type_neighbor); |
| 13990 | } |
| 13991 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13992 | DEFUN (show_bgp_view_neighbor_damp, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13993 | show_bgp_view_neighbor_damp_cmd, |
| 13994 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13995 | SHOW_STR |
| 13996 | BGP_STR |
| 13997 | "BGP view\n" |
| 13998 | "View name\n" |
| 13999 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14000 | "Neighbor to display information about\n" |
| 14001 | "Neighbor to display information about\n" |
| 14002 | "Display the dampened routes received from neighbor\n") |
| 14003 | { |
| 14004 | struct peer *peer; |
| 14005 | |
| 14006 | if (argc == 2) |
| 14007 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14008 | else |
| 14009 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14010 | |
| 14011 | if (! peer) |
| 14012 | return CMD_WARNING; |
| 14013 | |
| 14014 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14015 | bgp_show_type_damp_neighbor); |
| 14016 | } |
| 14017 | |
| 14018 | DEFUN (show_bgp_view_ipv6_neighbor_damp, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14019 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 14020 | "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] | 14021 | SHOW_STR |
| 14022 | BGP_STR |
| 14023 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14024 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14025 | "Address family\n" |
| 14026 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14027 | "Neighbor to display information about\n" |
| 14028 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14029 | "Display the dampened routes received from neighbor\n") |
| 14030 | { |
| 14031 | struct peer *peer; |
| 14032 | |
| 14033 | if (argc == 2) |
| 14034 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14035 | else |
| 14036 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14037 | |
| 14038 | if (! peer) |
| 14039 | return CMD_WARNING; |
| 14040 | |
| 14041 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14042 | bgp_show_type_damp_neighbor); |
| 14043 | } |
| 14044 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14045 | DEFUN (show_bgp_view_ipv6_neighbor_flap, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14046 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 14047 | "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] | 14048 | SHOW_STR |
| 14049 | BGP_STR |
| 14050 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14051 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14052 | "Address family\n" |
| 14053 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14054 | "Neighbor to display information about\n" |
| 14055 | "Neighbor to display information about\n" |
| 14056 | "Display the dampened routes received from neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14057 | { |
| 14058 | struct peer *peer; |
| 14059 | |
| 14060 | if (argc == 2) |
| 14061 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14062 | else |
| 14063 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14064 | |
| 14065 | if (! peer) |
| 14066 | return CMD_WARNING; |
| 14067 | |
| 14068 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14069 | bgp_show_type_flap_neighbor); |
| 14070 | } |
| 14071 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14072 | DEFUN (show_bgp_view_neighbor_flap, |
| 14073 | show_bgp_view_neighbor_flap_cmd, |
| 14074 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14075 | SHOW_STR |
| 14076 | BGP_STR |
| 14077 | "BGP view\n" |
| 14078 | "View name\n" |
| 14079 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14080 | "Neighbor to display information about\n" |
| 14081 | "Neighbor to display information about\n" |
| 14082 | "Display flap statistics of the routes learned from neighbor\n") |
| 14083 | { |
| 14084 | struct peer *peer; |
| 14085 | |
| 14086 | if (argc == 2) |
| 14087 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14088 | else |
| 14089 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14090 | |
| 14091 | if (! peer) |
| 14092 | return CMD_WARNING; |
| 14093 | |
| 14094 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14095 | bgp_show_type_flap_neighbor); |
| 14096 | } |
| 14097 | |
| 14098 | ALIAS (show_bgp_view_neighbor_flap, |
| 14099 | show_bgp_neighbor_flap_cmd, |
| 14100 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14101 | SHOW_STR |
| 14102 | BGP_STR |
| 14103 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14104 | "Neighbor to display information about\n" |
| 14105 | "Neighbor to display information about\n" |
| 14106 | "Display flap statistics of the routes learned from neighbor\n") |
| 14107 | |
| 14108 | ALIAS (show_bgp_view_neighbor_damp, |
| 14109 | show_bgp_neighbor_damp_cmd, |
| 14110 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14111 | SHOW_STR |
| 14112 | BGP_STR |
| 14113 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14114 | "Neighbor to display information about\n" |
| 14115 | "Neighbor to display information about\n" |
| 14116 | "Display the dampened routes received from neighbor\n") |
| 14117 | |
| 14118 | DEFUN (show_bgp_view_neighbor_routes, |
| 14119 | show_bgp_view_neighbor_routes_cmd, |
| 14120 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 14121 | SHOW_STR |
| 14122 | BGP_STR |
| 14123 | "BGP view\n" |
| 14124 | "View name\n" |
| 14125 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14126 | "Neighbor to display information about\n" |
| 14127 | "Neighbor to display information about\n" |
| 14128 | "Display routes learned from neighbor\n") |
| 14129 | { |
| 14130 | struct peer *peer; |
| 14131 | |
| 14132 | if (argc == 2) |
| 14133 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14134 | else |
| 14135 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14136 | |
| 14137 | if (! peer) |
| 14138 | return CMD_WARNING; |
| 14139 | |
| 14140 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14141 | bgp_show_type_neighbor); |
| 14142 | } |
| 14143 | |
| 14144 | ALIAS (show_bgp_view_neighbor_routes, |
| 14145 | show_bgp_neighbor_routes_cmd, |
| 14146 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14147 | SHOW_STR |
| 14148 | BGP_STR |
| 14149 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14150 | "Neighbor to display information about\n" |
| 14151 | "Neighbor to display information about\n" |
| 14152 | "Display routes learned from neighbor\n") |
| 14153 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14154 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14155 | show_bgp_ipv6_neighbor_routes_cmd, |
| 14156 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 14157 | SHOW_STR |
| 14158 | BGP_STR |
| 14159 | "Address family\n" |
| 14160 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14161 | "Neighbor to display information about\n" |
| 14162 | "Neighbor to display information about\n" |
| 14163 | "Display routes learned from neighbor\n") |
| 14164 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14165 | /* old command */ |
| 14166 | ALIAS (show_bgp_view_neighbor_routes, |
| 14167 | ipv6_bgp_neighbor_routes_cmd, |
| 14168 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14169 | SHOW_STR |
| 14170 | IPV6_STR |
| 14171 | BGP_STR |
| 14172 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14173 | "Neighbor to display information about\n" |
| 14174 | "Neighbor to display information about\n" |
| 14175 | "Display routes learned from neighbor\n") |
| 14176 | |
| 14177 | /* old command */ |
| 14178 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 14179 | ipv6_mbgp_neighbor_routes_cmd, |
| 14180 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14181 | SHOW_STR |
| 14182 | IPV6_STR |
| 14183 | MBGP_STR |
| 14184 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14185 | "Neighbor to display information about\n" |
| 14186 | "Neighbor to display information about\n" |
| 14187 | "Display routes learned from neighbor\n") |
| 14188 | { |
| 14189 | struct peer *peer; |
| 14190 | |
| 14191 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14192 | if (! peer) |
| 14193 | return CMD_WARNING; |
| 14194 | |
| 14195 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
| 14196 | bgp_show_type_neighbor); |
| 14197 | } |
| 14198 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14199 | ALIAS (show_bgp_view_neighbor_flap, |
| 14200 | show_bgp_ipv6_neighbor_flap_cmd, |
| 14201 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14202 | SHOW_STR |
| 14203 | BGP_STR |
| 14204 | "Address family\n" |
| 14205 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14206 | "Neighbor to display information about\n" |
| 14207 | "Neighbor to display information about\n" |
| 14208 | "Display flap statistics of the routes learned from neighbor\n") |
| 14209 | |
| 14210 | ALIAS (show_bgp_view_neighbor_damp, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14211 | show_bgp_ipv6_neighbor_damp_cmd, |
| 14212 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14213 | SHOW_STR |
| 14214 | BGP_STR |
| 14215 | "Address family\n" |
| 14216 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14217 | "Neighbor to display information about\n" |
| 14218 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 14219 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14220 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14221 | DEFUN (show_bgp_view_rsclient, |
| 14222 | show_bgp_view_rsclient_cmd, |
| 14223 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 14224 | SHOW_STR |
| 14225 | BGP_STR |
| 14226 | "BGP view\n" |
| 14227 | "View name\n" |
| 14228 | "Information about Route Server Client\n" |
| 14229 | NEIGHBOR_ADDR_STR) |
| 14230 | { |
| 14231 | struct bgp_table *table; |
| 14232 | struct peer *peer; |
| 14233 | |
| 14234 | if (argc == 2) |
| 14235 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14236 | else |
| 14237 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14238 | |
| 14239 | if (! peer) |
| 14240 | return CMD_WARNING; |
| 14241 | |
| 14242 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14243 | { |
| 14244 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14245 | VTY_NEWLINE); |
| 14246 | return CMD_WARNING; |
| 14247 | } |
| 14248 | |
| 14249 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14250 | PEER_FLAG_RSERVER_CLIENT)) |
| 14251 | { |
| 14252 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14253 | VTY_NEWLINE); |
| 14254 | return CMD_WARNING; |
| 14255 | } |
| 14256 | |
| 14257 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14258 | |
| 14259 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14260 | } |
| 14261 | |
| 14262 | ALIAS (show_bgp_view_rsclient, |
| 14263 | show_bgp_rsclient_cmd, |
| 14264 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 14265 | SHOW_STR |
| 14266 | BGP_STR |
| 14267 | "Information about Route Server Client\n" |
| 14268 | NEIGHBOR_ADDR_STR) |
| 14269 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14270 | DEFUN (show_bgp_view_ipv4_rsclient, |
| 14271 | show_bgp_view_ipv4_rsclient_cmd, |
| 14272 | "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] | 14273 | SHOW_STR |
| 14274 | BGP_STR |
| 14275 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14276 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14277 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14278 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14279 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14280 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14281 | struct bgp_table *table; |
| 14282 | struct peer *peer; |
| 14283 | |
| 14284 | if (argc == 2) |
| 14285 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14286 | else |
| 14287 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14288 | |
| 14289 | if (! peer) |
| 14290 | return CMD_WARNING; |
| 14291 | |
| 14292 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14293 | { |
| 14294 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14295 | VTY_NEWLINE); |
| 14296 | return CMD_WARNING; |
| 14297 | } |
| 14298 | |
| 14299 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14300 | PEER_FLAG_RSERVER_CLIENT)) |
| 14301 | { |
| 14302 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14303 | VTY_NEWLINE); |
| 14304 | return CMD_WARNING; |
| 14305 | } |
| 14306 | |
| 14307 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 14308 | |
| 14309 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14310 | } |
| 14311 | DEFUN (show_bgp_view_ipv6_rsclient, |
| 14312 | show_bgp_view_ipv6_rsclient_cmd, |
| 14313 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14314 | SHOW_STR |
| 14315 | BGP_STR |
| 14316 | "BGP view\n" |
| 14317 | "BGP view name\n" |
| 14318 | "Address Family\n" |
| 14319 | "Information about Route Server Client\n" |
| 14320 | NEIGHBOR_ADDR_STR2) |
| 14321 | { |
| 14322 | struct bgp_table *table; |
| 14323 | struct peer *peer; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14324 | |
| 14325 | if (argc == 2) |
| 14326 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14327 | else |
| 14328 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14329 | |
| 14330 | if (! peer) |
| 14331 | return CMD_WARNING; |
| 14332 | |
| 14333 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14334 | { |
| 14335 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14336 | VTY_NEWLINE); |
| 14337 | return CMD_WARNING; |
| 14338 | } |
| 14339 | |
| 14340 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14341 | PEER_FLAG_RSERVER_CLIENT)) |
| 14342 | { |
| 14343 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14344 | VTY_NEWLINE); |
| 14345 | return CMD_WARNING; |
| 14346 | } |
| 14347 | |
| 14348 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14349 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 14350 | 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] | 14351 | } |
| 14352 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14353 | ALIAS (show_bgp_view_ipv4_rsclient, |
| 14354 | show_bgp_ipv4_rsclient_cmd, |
| 14355 | "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14356 | SHOW_STR |
| 14357 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14358 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14359 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14360 | NEIGHBOR_ADDR_STR2) |
| 14361 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14362 | ALIAS (show_bgp_view_ipv6_rsclient, |
| 14363 | show_bgp_ipv6_rsclient_cmd, |
| 14364 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14365 | SHOW_STR |
| 14366 | BGP_STR |
| 14367 | "Address Family\n" |
| 14368 | "Information about Route Server Client\n" |
| 14369 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14370 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14371 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 14372 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 14373 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14374 | SHOW_STR |
| 14375 | BGP_STR |
| 14376 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14377 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14378 | "Address family\n" |
| 14379 | "Address Family modifier\n" |
| 14380 | "Address Family modifier\n" |
| 14381 | "Information about Route Server Client\n" |
| 14382 | NEIGHBOR_ADDR_STR) |
| 14383 | { |
| 14384 | struct bgp_table *table; |
| 14385 | struct peer *peer; |
| 14386 | safi_t safi; |
| 14387 | |
| 14388 | if (argc == 3) { |
| 14389 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14390 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14391 | } else { |
| 14392 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14393 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14394 | } |
| 14395 | |
| 14396 | if (! peer) |
| 14397 | return CMD_WARNING; |
| 14398 | |
| 14399 | if (! peer->afc[AFI_IP6][safi]) |
| 14400 | { |
| 14401 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14402 | VTY_NEWLINE); |
| 14403 | return CMD_WARNING; |
| 14404 | } |
| 14405 | |
| 14406 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14407 | PEER_FLAG_RSERVER_CLIENT)) |
| 14408 | { |
| 14409 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14410 | VTY_NEWLINE); |
| 14411 | return CMD_WARNING; |
| 14412 | } |
| 14413 | |
| 14414 | table = peer->rib[AFI_IP6][safi]; |
| 14415 | |
| 14416 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14417 | } |
| 14418 | |
| 14419 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 14420 | show_bgp_ipv6_safi_rsclient_cmd, |
| 14421 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14422 | SHOW_STR |
| 14423 | BGP_STR |
| 14424 | "Address family\n" |
| 14425 | "Address Family modifier\n" |
| 14426 | "Address Family modifier\n" |
| 14427 | "Information about Route Server Client\n" |
| 14428 | NEIGHBOR_ADDR_STR) |
| 14429 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14430 | DEFUN (show_bgp_view_rsclient_route, |
| 14431 | show_bgp_view_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14432 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14433 | SHOW_STR |
| 14434 | BGP_STR |
| 14435 | "BGP view\n" |
| 14436 | "View name\n" |
| 14437 | "Information about Route Server Client\n" |
| 14438 | NEIGHBOR_ADDR_STR |
| 14439 | "Network in the BGP routing table to display\n") |
| 14440 | { |
| 14441 | struct bgp *bgp; |
| 14442 | struct peer *peer; |
| 14443 | |
| 14444 | /* BGP structure lookup. */ |
| 14445 | if (argc == 3) |
| 14446 | { |
| 14447 | bgp = bgp_lookup_by_name (argv[0]); |
| 14448 | if (bgp == NULL) |
| 14449 | { |
| 14450 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14451 | return CMD_WARNING; |
| 14452 | } |
| 14453 | } |
| 14454 | else |
| 14455 | { |
| 14456 | bgp = bgp_get_default (); |
| 14457 | if (bgp == NULL) |
| 14458 | { |
| 14459 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14460 | return CMD_WARNING; |
| 14461 | } |
| 14462 | } |
| 14463 | |
| 14464 | if (argc == 3) |
| 14465 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14466 | else |
| 14467 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14468 | |
| 14469 | if (! peer) |
| 14470 | return CMD_WARNING; |
| 14471 | |
| 14472 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14473 | { |
| 14474 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14475 | VTY_NEWLINE); |
| 14476 | return CMD_WARNING; |
| 14477 | } |
| 14478 | |
| 14479 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14480 | PEER_FLAG_RSERVER_CLIENT)) |
| 14481 | { |
| 14482 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14483 | VTY_NEWLINE); |
| 14484 | return CMD_WARNING; |
| 14485 | } |
| 14486 | |
| 14487 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14488 | (argc == 3) ? argv[2] : argv[1], |
| 14489 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 14490 | } |
| 14491 | |
| 14492 | DEFUN (show_bgp_view_ipv6_rsclient_route, |
| 14493 | show_bgp_view_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14494 | "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] | 14495 | SHOW_STR |
| 14496 | BGP_STR |
| 14497 | "BGP view\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14498 | "BGP view name\n" |
| 14499 | "IP6_STR" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14500 | "Information about Route Server Client\n" |
| 14501 | NEIGHBOR_ADDR_STR |
| 14502 | "Network in the BGP routing table to display\n") |
| 14503 | { |
| 14504 | struct bgp *bgp; |
| 14505 | struct peer *peer; |
| 14506 | |
| 14507 | /* BGP structure lookup. */ |
| 14508 | if (argc == 3) |
| 14509 | { |
| 14510 | bgp = bgp_lookup_by_name (argv[0]); |
| 14511 | if (bgp == NULL) |
| 14512 | { |
| 14513 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14514 | return CMD_WARNING; |
| 14515 | } |
| 14516 | } |
| 14517 | else |
| 14518 | { |
| 14519 | bgp = bgp_get_default (); |
| 14520 | if (bgp == NULL) |
| 14521 | { |
| 14522 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14523 | return CMD_WARNING; |
| 14524 | } |
| 14525 | } |
| 14526 | |
| 14527 | if (argc == 3) |
| 14528 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14529 | else |
| 14530 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14531 | |
| 14532 | if (! peer) |
| 14533 | return CMD_WARNING; |
| 14534 | |
| 14535 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14536 | { |
| 14537 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14538 | VTY_NEWLINE); |
| 14539 | return CMD_WARNING; |
| 14540 | } |
| 14541 | |
| 14542 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14543 | PEER_FLAG_RSERVER_CLIENT)) |
| 14544 | { |
| 14545 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14546 | VTY_NEWLINE); |
| 14547 | return CMD_WARNING; |
| 14548 | } |
| 14549 | |
| 14550 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14551 | (argc == 3) ? argv[2] : argv[1], |
| 14552 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 14553 | } |
| 14554 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14555 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14556 | show_bgp_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14557 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14558 | SHOW_STR |
| 14559 | BGP_STR |
| 14560 | "Information about Route Server Client\n" |
| 14561 | NEIGHBOR_ADDR_STR |
| 14562 | "Network in the BGP routing table to display\n") |
| 14563 | |
| 14564 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
| 14565 | show_bgp_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14566 | "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] | 14567 | SHOW_STR |
| 14568 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14569 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14570 | "Information about Route Server Client\n" |
| 14571 | NEIGHBOR_ADDR_STR |
| 14572 | "Network in the BGP routing table to display\n") |
| 14573 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14574 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 14575 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 14576 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14577 | SHOW_STR |
| 14578 | BGP_STR |
| 14579 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14580 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14581 | "Address family\n" |
| 14582 | "Address Family modifier\n" |
| 14583 | "Address Family modifier\n" |
| 14584 | "Information about Route Server Client\n" |
| 14585 | NEIGHBOR_ADDR_STR |
| 14586 | "Network in the BGP routing table to display\n") |
| 14587 | { |
| 14588 | struct bgp *bgp; |
| 14589 | struct peer *peer; |
| 14590 | safi_t safi; |
| 14591 | |
| 14592 | /* BGP structure lookup. */ |
| 14593 | if (argc == 4) |
| 14594 | { |
| 14595 | bgp = bgp_lookup_by_name (argv[0]); |
| 14596 | if (bgp == NULL) |
| 14597 | { |
| 14598 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14599 | return CMD_WARNING; |
| 14600 | } |
| 14601 | } |
| 14602 | else |
| 14603 | { |
| 14604 | bgp = bgp_get_default (); |
| 14605 | if (bgp == NULL) |
| 14606 | { |
| 14607 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14608 | return CMD_WARNING; |
| 14609 | } |
| 14610 | } |
| 14611 | |
| 14612 | if (argc == 4) { |
| 14613 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14614 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14615 | } else { |
| 14616 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14617 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14618 | } |
| 14619 | |
| 14620 | if (! peer) |
| 14621 | return CMD_WARNING; |
| 14622 | |
| 14623 | if (! peer->afc[AFI_IP6][safi]) |
| 14624 | { |
| 14625 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14626 | VTY_NEWLINE); |
| 14627 | return CMD_WARNING; |
| 14628 | } |
| 14629 | |
| 14630 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14631 | PEER_FLAG_RSERVER_CLIENT)) |
| 14632 | { |
| 14633 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14634 | VTY_NEWLINE); |
| 14635 | return CMD_WARNING; |
| 14636 | } |
| 14637 | |
| 14638 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 14639 | (argc == 4) ? argv[3] : argv[2], |
| 14640 | AFI_IP6, safi, NULL, 0); |
| 14641 | } |
| 14642 | |
| 14643 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 14644 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 14645 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14646 | SHOW_STR |
| 14647 | BGP_STR |
| 14648 | "Address family\n" |
| 14649 | "Address Family modifier\n" |
| 14650 | "Address Family modifier\n" |
| 14651 | "Information about Route Server Client\n" |
| 14652 | NEIGHBOR_ADDR_STR |
| 14653 | "Network in the BGP routing table to display\n") |
| 14654 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14655 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14656 | DEFUN (show_bgp_view_rsclient_prefix, |
| 14657 | show_bgp_view_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14658 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14659 | SHOW_STR |
| 14660 | BGP_STR |
| 14661 | "BGP view\n" |
| 14662 | "View name\n" |
| 14663 | "Information about Route Server Client\n" |
| 14664 | NEIGHBOR_ADDR_STR |
| 14665 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14666 | { |
| 14667 | struct bgp *bgp; |
| 14668 | struct peer *peer; |
| 14669 | |
| 14670 | /* BGP structure lookup. */ |
| 14671 | if (argc == 3) |
| 14672 | { |
| 14673 | bgp = bgp_lookup_by_name (argv[0]); |
| 14674 | if (bgp == NULL) |
| 14675 | { |
| 14676 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14677 | return CMD_WARNING; |
| 14678 | } |
| 14679 | } |
| 14680 | else |
| 14681 | { |
| 14682 | bgp = bgp_get_default (); |
| 14683 | if (bgp == NULL) |
| 14684 | { |
| 14685 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14686 | return CMD_WARNING; |
| 14687 | } |
| 14688 | } |
| 14689 | |
| 14690 | if (argc == 3) |
| 14691 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14692 | else |
| 14693 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14694 | |
| 14695 | if (! peer) |
| 14696 | return CMD_WARNING; |
| 14697 | |
| 14698 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14699 | { |
| 14700 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14701 | VTY_NEWLINE); |
| 14702 | return CMD_WARNING; |
| 14703 | } |
| 14704 | |
| 14705 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14706 | PEER_FLAG_RSERVER_CLIENT)) |
| 14707 | { |
| 14708 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14709 | VTY_NEWLINE); |
| 14710 | return CMD_WARNING; |
| 14711 | } |
| 14712 | |
| 14713 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14714 | (argc == 3) ? argv[2] : argv[1], |
| 14715 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 14716 | } |
| 14717 | |
| 14718 | DEFUN (show_bgp_view_ipv6_rsclient_prefix, |
| 14719 | show_bgp_view_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14720 | "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] | 14721 | SHOW_STR |
| 14722 | BGP_STR |
| 14723 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14724 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14725 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14726 | "Information about Route Server Client\n" |
| 14727 | NEIGHBOR_ADDR_STR |
| 14728 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14729 | { |
| 14730 | struct bgp *bgp; |
| 14731 | struct peer *peer; |
| 14732 | |
| 14733 | /* BGP structure lookup. */ |
| 14734 | if (argc == 3) |
| 14735 | { |
| 14736 | bgp = bgp_lookup_by_name (argv[0]); |
| 14737 | if (bgp == NULL) |
| 14738 | { |
| 14739 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14740 | return CMD_WARNING; |
| 14741 | } |
| 14742 | } |
| 14743 | else |
| 14744 | { |
| 14745 | bgp = bgp_get_default (); |
| 14746 | if (bgp == NULL) |
| 14747 | { |
| 14748 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14749 | return CMD_WARNING; |
| 14750 | } |
| 14751 | } |
| 14752 | |
| 14753 | if (argc == 3) |
| 14754 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14755 | else |
| 14756 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14757 | |
| 14758 | if (! peer) |
| 14759 | return CMD_WARNING; |
| 14760 | |
| 14761 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14762 | { |
| 14763 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14764 | VTY_NEWLINE); |
| 14765 | return CMD_WARNING; |
| 14766 | } |
| 14767 | |
| 14768 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14769 | PEER_FLAG_RSERVER_CLIENT)) |
| 14770 | { |
| 14771 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14772 | VTY_NEWLINE); |
| 14773 | return CMD_WARNING; |
| 14774 | } |
| 14775 | |
| 14776 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14777 | (argc == 3) ? argv[2] : argv[1], |
| 14778 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 14779 | } |
| 14780 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14781 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14782 | show_bgp_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14783 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14784 | SHOW_STR |
| 14785 | BGP_STR |
| 14786 | "Information about Route Server Client\n" |
| 14787 | NEIGHBOR_ADDR_STR |
| 14788 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14789 | |
| 14790 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
| 14791 | show_bgp_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14792 | "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] | 14793 | SHOW_STR |
| 14794 | BGP_STR |
| 14795 | "Information about Route Server Client\n" |
| 14796 | NEIGHBOR_ADDR_STR |
| 14797 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14798 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14799 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 14800 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 14801 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14802 | SHOW_STR |
| 14803 | BGP_STR |
| 14804 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14805 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14806 | "Address family\n" |
| 14807 | "Address Family modifier\n" |
| 14808 | "Address Family modifier\n" |
| 14809 | "Information about Route Server Client\n" |
| 14810 | NEIGHBOR_ADDR_STR |
| 14811 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14812 | { |
| 14813 | struct bgp *bgp; |
| 14814 | struct peer *peer; |
| 14815 | safi_t safi; |
| 14816 | |
| 14817 | /* BGP structure lookup. */ |
| 14818 | if (argc == 4) |
| 14819 | { |
| 14820 | bgp = bgp_lookup_by_name (argv[0]); |
| 14821 | if (bgp == NULL) |
| 14822 | { |
| 14823 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14824 | return CMD_WARNING; |
| 14825 | } |
| 14826 | } |
| 14827 | else |
| 14828 | { |
| 14829 | bgp = bgp_get_default (); |
| 14830 | if (bgp == NULL) |
| 14831 | { |
| 14832 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14833 | return CMD_WARNING; |
| 14834 | } |
| 14835 | } |
| 14836 | |
| 14837 | if (argc == 4) { |
| 14838 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14839 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14840 | } else { |
| 14841 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14842 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14843 | } |
| 14844 | |
| 14845 | if (! peer) |
| 14846 | return CMD_WARNING; |
| 14847 | |
| 14848 | if (! peer->afc[AFI_IP6][safi]) |
| 14849 | { |
| 14850 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14851 | VTY_NEWLINE); |
| 14852 | return CMD_WARNING; |
| 14853 | } |
| 14854 | |
| 14855 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14856 | PEER_FLAG_RSERVER_CLIENT)) |
| 14857 | { |
| 14858 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14859 | VTY_NEWLINE); |
| 14860 | return CMD_WARNING; |
| 14861 | } |
| 14862 | |
| 14863 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 14864 | (argc == 4) ? argv[3] : argv[2], |
| 14865 | AFI_IP6, safi, NULL, 1); |
| 14866 | } |
| 14867 | |
| 14868 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 14869 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 14870 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14871 | SHOW_STR |
| 14872 | BGP_STR |
| 14873 | "Address family\n" |
| 14874 | "Address Family modifier\n" |
| 14875 | "Address Family modifier\n" |
| 14876 | "Information about Route Server Client\n" |
| 14877 | NEIGHBOR_ADDR_STR |
| 14878 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14879 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14880 | struct bgp_table *bgp_distance_table; |
| 14881 | |
| 14882 | struct bgp_distance |
| 14883 | { |
| 14884 | /* Distance value for the IP source prefix. */ |
| 14885 | u_char distance; |
| 14886 | |
| 14887 | /* Name of the access-list to be matched. */ |
| 14888 | char *access_list; |
| 14889 | }; |
| 14890 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14891 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 14892 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14893 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 14894 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14895 | } |
| 14896 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14897 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14898 | bgp_distance_free (struct bgp_distance *bdistance) |
| 14899 | { |
| 14900 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 14901 | } |
| 14902 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14903 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 14904 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 14905 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14906 | { |
| 14907 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 14908 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14909 | u_char distance; |
| 14910 | struct bgp_node *rn; |
| 14911 | struct bgp_distance *bdistance; |
| 14912 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 14913 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14914 | if (ret == 0) |
| 14915 | { |
| 14916 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 14917 | return CMD_WARNING; |
| 14918 | } |
| 14919 | |
| 14920 | distance = atoi (distance_str); |
| 14921 | |
| 14922 | /* Get BGP distance node. */ |
| 14923 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 14924 | if (rn->info) |
| 14925 | { |
| 14926 | bdistance = rn->info; |
| 14927 | bgp_unlock_node (rn); |
| 14928 | } |
| 14929 | else |
| 14930 | { |
| 14931 | bdistance = bgp_distance_new (); |
| 14932 | rn->info = bdistance; |
| 14933 | } |
| 14934 | |
| 14935 | /* Set distance value. */ |
| 14936 | bdistance->distance = distance; |
| 14937 | |
| 14938 | /* Reset access-list configuration. */ |
| 14939 | if (bdistance->access_list) |
| 14940 | { |
| 14941 | free (bdistance->access_list); |
| 14942 | bdistance->access_list = NULL; |
| 14943 | } |
| 14944 | if (access_list_str) |
| 14945 | bdistance->access_list = strdup (access_list_str); |
| 14946 | |
| 14947 | return CMD_SUCCESS; |
| 14948 | } |
| 14949 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 14950 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 14951 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 14952 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14953 | { |
| 14954 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 14955 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14956 | u_char distance; |
| 14957 | struct bgp_node *rn; |
| 14958 | struct bgp_distance *bdistance; |
| 14959 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 14960 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14961 | if (ret == 0) |
| 14962 | { |
| 14963 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 14964 | return CMD_WARNING; |
| 14965 | } |
| 14966 | |
| 14967 | distance = atoi (distance_str); |
| 14968 | |
| 14969 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 14970 | if (! rn) |
| 14971 | { |
| 14972 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 14973 | return CMD_WARNING; |
| 14974 | } |
| 14975 | |
| 14976 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 14977 | |
| 14978 | if (bdistance->distance != distance) |
| 14979 | { |
| 14980 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 14981 | return CMD_WARNING; |
| 14982 | } |
| 14983 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14984 | if (bdistance->access_list) |
| 14985 | free (bdistance->access_list); |
| 14986 | bgp_distance_free (bdistance); |
| 14987 | |
| 14988 | rn->info = NULL; |
| 14989 | bgp_unlock_node (rn); |
| 14990 | bgp_unlock_node (rn); |
| 14991 | |
| 14992 | return CMD_SUCCESS; |
| 14993 | } |
| 14994 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14995 | /* Apply BGP information to distance method. */ |
| 14996 | u_char |
| 14997 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 14998 | { |
| 14999 | struct bgp_node *rn; |
| 15000 | struct prefix_ipv4 q; |
| 15001 | struct peer *peer; |
| 15002 | struct bgp_distance *bdistance; |
| 15003 | struct access_list *alist; |
| 15004 | struct bgp_static *bgp_static; |
| 15005 | |
| 15006 | if (! bgp) |
| 15007 | return 0; |
| 15008 | |
| 15009 | if (p->family != AF_INET) |
| 15010 | return 0; |
| 15011 | |
| 15012 | peer = rinfo->peer; |
| 15013 | |
| 15014 | if (peer->su.sa.sa_family != AF_INET) |
| 15015 | return 0; |
| 15016 | |
| 15017 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 15018 | q.family = AF_INET; |
| 15019 | q.prefix = peer->su.sin.sin_addr; |
| 15020 | q.prefixlen = IPV4_MAX_BITLEN; |
| 15021 | |
| 15022 | /* Check source address. */ |
| 15023 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15024 | if (rn) |
| 15025 | { |
| 15026 | bdistance = rn->info; |
| 15027 | bgp_unlock_node (rn); |
| 15028 | |
| 15029 | if (bdistance->access_list) |
| 15030 | { |
| 15031 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 15032 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15033 | return bdistance->distance; |
| 15034 | } |
| 15035 | else |
| 15036 | return bdistance->distance; |
| 15037 | } |
| 15038 | |
| 15039 | /* Backdoor check. */ |
| 15040 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 15041 | if (rn) |
| 15042 | { |
| 15043 | bgp_static = rn->info; |
| 15044 | bgp_unlock_node (rn); |
| 15045 | |
| 15046 | if (bgp_static->backdoor) |
| 15047 | { |
| 15048 | if (bgp->distance_local) |
| 15049 | return bgp->distance_local; |
| 15050 | else |
| 15051 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15052 | } |
| 15053 | } |
| 15054 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 15055 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15056 | { |
| 15057 | if (bgp->distance_ebgp) |
| 15058 | return bgp->distance_ebgp; |
| 15059 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15060 | } |
| 15061 | else |
| 15062 | { |
| 15063 | if (bgp->distance_ibgp) |
| 15064 | return bgp->distance_ibgp; |
| 15065 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15066 | } |
| 15067 | } |
| 15068 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15069 | #ifdef HAVE_IPV6 |
| 15070 | /* Apply BGP information to ipv6 distance method. */ |
| 15071 | u_char |
| 15072 | ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15073 | { |
| 15074 | struct bgp_node *rn; |
| 15075 | struct prefix_ipv6 q; |
| 15076 | struct peer *peer; |
| 15077 | struct bgp_distance *bdistance; |
| 15078 | struct access_list *alist; |
| 15079 | struct bgp_static *bgp_static; |
| 15080 | |
| 15081 | if (! bgp) |
| 15082 | return 0; |
| 15083 | |
| 15084 | if (p->family != AF_INET6) |
| 15085 | return 0; |
| 15086 | |
| 15087 | peer = rinfo->peer; |
| 15088 | |
| 15089 | if (peer->su.sa.sa_family != AF_INET6) |
| 15090 | return 0; |
| 15091 | |
| 15092 | memset (&q, 0, sizeof (struct prefix_ipv6)); |
| 15093 | q.family = AF_INET; |
| 15094 | q.prefix = peer->su.sin6.sin6_addr; |
| 15095 | q.prefixlen = IPV6_MAX_BITLEN; |
| 15096 | |
| 15097 | /* Check source address. */ |
| 15098 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15099 | if (rn) |
| 15100 | { |
| 15101 | bdistance = rn->info; |
| 15102 | bgp_unlock_node (rn); |
| 15103 | |
| 15104 | if (bdistance->access_list) |
| 15105 | { |
| 15106 | alist = access_list_lookup (AFI_IP6, bdistance->access_list); |
| 15107 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15108 | return bdistance->distance; |
| 15109 | } |
| 15110 | else |
| 15111 | return bdistance->distance; |
| 15112 | } |
| 15113 | /* Backdoor check. */ |
| 15114 | rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p); |
| 15115 | if (rn) |
| 15116 | { |
| 15117 | bgp_static = rn->info; |
| 15118 | bgp_unlock_node (rn); |
| 15119 | |
| 15120 | if (bgp_static->backdoor) |
| 15121 | { |
| 15122 | if (bgp->ipv6_distance_local) |
| 15123 | return bgp->ipv6_distance_local; |
| 15124 | else |
| 15125 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15126 | } |
| 15127 | } |
| 15128 | |
| 15129 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 15130 | { |
| 15131 | if (bgp->ipv6_distance_ebgp) |
| 15132 | return bgp->ipv6_distance_ebgp; |
| 15133 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15134 | } |
| 15135 | else |
| 15136 | { |
| 15137 | if (bgp->ipv6_distance_ibgp) |
| 15138 | return bgp->ipv6_distance_ibgp; |
| 15139 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15140 | } |
| 15141 | } |
| 15142 | #endif /* HAVE_IPV6 */ |
| 15143 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15144 | DEFUN (bgp_distance, |
| 15145 | bgp_distance_cmd, |
| 15146 | "distance bgp <1-255> <1-255> <1-255>", |
| 15147 | "Define an administrative distance\n" |
| 15148 | "BGP distance\n" |
| 15149 | "Distance for routes external to the AS\n" |
| 15150 | "Distance for routes internal to the AS\n" |
| 15151 | "Distance for local routes\n") |
| 15152 | { |
| 15153 | struct bgp *bgp; |
| 15154 | |
| 15155 | bgp = vty->index; |
| 15156 | |
| 15157 | bgp->distance_ebgp = atoi (argv[0]); |
| 15158 | bgp->distance_ibgp = atoi (argv[1]); |
| 15159 | bgp->distance_local = atoi (argv[2]); |
| 15160 | return CMD_SUCCESS; |
| 15161 | } |
| 15162 | |
| 15163 | DEFUN (no_bgp_distance, |
| 15164 | no_bgp_distance_cmd, |
| 15165 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15166 | NO_STR |
| 15167 | "Define an administrative distance\n" |
| 15168 | "BGP distance\n" |
| 15169 | "Distance for routes external to the AS\n" |
| 15170 | "Distance for routes internal to the AS\n" |
| 15171 | "Distance for local routes\n") |
| 15172 | { |
| 15173 | struct bgp *bgp; |
| 15174 | |
| 15175 | bgp = vty->index; |
| 15176 | |
| 15177 | bgp->distance_ebgp= 0; |
| 15178 | bgp->distance_ibgp = 0; |
| 15179 | bgp->distance_local = 0; |
| 15180 | return CMD_SUCCESS; |
| 15181 | } |
| 15182 | |
| 15183 | ALIAS (no_bgp_distance, |
| 15184 | no_bgp_distance2_cmd, |
| 15185 | "no distance bgp", |
| 15186 | NO_STR |
| 15187 | "Define an administrative distance\n" |
| 15188 | "BGP distance\n") |
| 15189 | |
| 15190 | DEFUN (bgp_distance_source, |
| 15191 | bgp_distance_source_cmd, |
| 15192 | "distance <1-255> A.B.C.D/M", |
| 15193 | "Define an administrative distance\n" |
| 15194 | "Administrative distance\n" |
| 15195 | "IP source prefix\n") |
| 15196 | { |
| 15197 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15198 | return CMD_SUCCESS; |
| 15199 | } |
| 15200 | |
| 15201 | DEFUN (no_bgp_distance_source, |
| 15202 | no_bgp_distance_source_cmd, |
| 15203 | "no distance <1-255> A.B.C.D/M", |
| 15204 | NO_STR |
| 15205 | "Define an administrative distance\n" |
| 15206 | "Administrative distance\n" |
| 15207 | "IP source prefix\n") |
| 15208 | { |
| 15209 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15210 | return CMD_SUCCESS; |
| 15211 | } |
| 15212 | |
| 15213 | DEFUN (bgp_distance_source_access_list, |
| 15214 | bgp_distance_source_access_list_cmd, |
| 15215 | "distance <1-255> A.B.C.D/M WORD", |
| 15216 | "Define an administrative distance\n" |
| 15217 | "Administrative distance\n" |
| 15218 | "IP source prefix\n" |
| 15219 | "Access list name\n") |
| 15220 | { |
| 15221 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15222 | return CMD_SUCCESS; |
| 15223 | } |
| 15224 | |
| 15225 | DEFUN (no_bgp_distance_source_access_list, |
| 15226 | no_bgp_distance_source_access_list_cmd, |
| 15227 | "no distance <1-255> A.B.C.D/M WORD", |
| 15228 | NO_STR |
| 15229 | "Define an administrative distance\n" |
| 15230 | "Administrative distance\n" |
| 15231 | "IP source prefix\n" |
| 15232 | "Access list name\n") |
| 15233 | { |
| 15234 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15235 | return CMD_SUCCESS; |
| 15236 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15237 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15238 | #ifdef HAVE_IPV6 |
| 15239 | DEFUN (ipv6_bgp_distance, |
| 15240 | ipv6_bgp_distance_cmd, |
| 15241 | "distance bgp <1-255> <1-255> <1-255>", |
| 15242 | "Define an administrative distance\n" |
| 15243 | "BGP distance\n" |
| 15244 | "Distance for routes external to the AS\n" |
| 15245 | "Distance for routes internal to the AS\n" |
| 15246 | "Distance for local routes\n") |
| 15247 | { |
| 15248 | struct bgp *bgp; |
| 15249 | |
| 15250 | bgp = vty->index; |
| 15251 | |
| 15252 | bgp->ipv6_distance_ebgp = atoi (argv[0]); |
| 15253 | bgp->ipv6_distance_ibgp = atoi (argv[1]); |
| 15254 | bgp->ipv6_distance_local = atoi (argv[2]); |
| 15255 | return CMD_SUCCESS; |
| 15256 | } |
| 15257 | |
| 15258 | DEFUN (no_ipv6_bgp_distance, |
| 15259 | no_ipv6_bgp_distance_cmd, |
| 15260 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15261 | NO_STR |
| 15262 | "Define an administrative distance\n" |
| 15263 | "BGP distance\n" |
| 15264 | "Distance for routes external to the AS\n" |
| 15265 | "Distance for routes internal to the AS\n" |
| 15266 | "Distance for local routes\n") |
| 15267 | { |
| 15268 | struct bgp *bgp; |
| 15269 | |
| 15270 | bgp = vty->index; |
| 15271 | |
| 15272 | bgp->ipv6_distance_ebgp= 0; |
| 15273 | bgp->ipv6_distance_ibgp = 0; |
| 15274 | bgp->ipv6_distance_local = 0; |
| 15275 | return CMD_SUCCESS; |
| 15276 | } |
| 15277 | |
| 15278 | ALIAS (no_ipv6_bgp_distance, |
| 15279 | no_ipv6_bgp_distance2_cmd, |
| 15280 | "no distance bgp", |
| 15281 | NO_STR |
| 15282 | "Define an administrative distance\n" |
| 15283 | "BGP distance\n") |
| 15284 | |
| 15285 | DEFUN (ipv6_bgp_distance_source, |
| 15286 | ipv6_bgp_distance_source_cmd, |
| 15287 | "distance <1-255> X:X::X:X/M", |
| 15288 | "Define an administrative distance\n" |
| 15289 | "Administrative distance\n" |
| 15290 | "IP source prefix\n") |
| 15291 | { |
| 15292 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15293 | return CMD_SUCCESS; |
| 15294 | } |
| 15295 | |
| 15296 | DEFUN (no_ipv6_bgp_distance_source, |
| 15297 | no_ipv6_bgp_distance_source_cmd, |
| 15298 | "no distance <1-255> X:X::X:X/M", |
| 15299 | NO_STR |
| 15300 | "Define an administrative distance\n" |
| 15301 | "Administrative distance\n" |
| 15302 | "IP source prefix\n") |
| 15303 | { |
| 15304 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15305 | return CMD_SUCCESS; |
| 15306 | } |
| 15307 | |
| 15308 | DEFUN (ipv6_bgp_distance_source_access_list, |
| 15309 | ipv6_bgp_distance_source_access_list_cmd, |
| 15310 | "distance <1-255> X:X::X:X/M WORD", |
| 15311 | "Define an administrative distance\n" |
| 15312 | "Administrative distance\n" |
| 15313 | "IP source prefix\n" |
| 15314 | "Access list name\n") |
| 15315 | { |
| 15316 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15317 | return CMD_SUCCESS; |
| 15318 | } |
| 15319 | |
| 15320 | DEFUN (no_ipv6_bgp_distance_source_access_list, |
| 15321 | no_ipv6_bgp_distance_source_access_list_cmd, |
| 15322 | "no distance <1-255> X:X::X:X/M WORD", |
| 15323 | NO_STR |
| 15324 | "Define an administrative distance\n" |
| 15325 | "Administrative distance\n" |
| 15326 | "IP source prefix\n" |
| 15327 | "Access list name\n") |
| 15328 | { |
| 15329 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15330 | return CMD_SUCCESS; |
| 15331 | } |
| 15332 | #endif |
| 15333 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15334 | DEFUN (bgp_damp_set, |
| 15335 | bgp_damp_set_cmd, |
| 15336 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15337 | "BGP Specific commands\n" |
| 15338 | "Enable route-flap dampening\n" |
| 15339 | "Half-life time for the penalty\n" |
| 15340 | "Value to start reusing a route\n" |
| 15341 | "Value to start suppressing a route\n" |
| 15342 | "Maximum duration to suppress a stable route\n") |
| 15343 | { |
| 15344 | struct bgp *bgp; |
| 15345 | int half = DEFAULT_HALF_LIFE * 60; |
| 15346 | int reuse = DEFAULT_REUSE; |
| 15347 | int suppress = DEFAULT_SUPPRESS; |
| 15348 | int max = 4 * half; |
| 15349 | |
| 15350 | if (argc == 4) |
| 15351 | { |
| 15352 | half = atoi (argv[0]) * 60; |
| 15353 | reuse = atoi (argv[1]); |
| 15354 | suppress = atoi (argv[2]); |
| 15355 | max = atoi (argv[3]) * 60; |
| 15356 | } |
| 15357 | else if (argc == 1) |
| 15358 | { |
| 15359 | half = atoi (argv[0]) * 60; |
| 15360 | max = 4 * half; |
| 15361 | } |
| 15362 | |
| 15363 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 15364 | |
| 15365 | if (suppress < reuse) |
| 15366 | { |
| 15367 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 15368 | VTY_NEWLINE); |
| 15369 | return 0; |
| 15370 | } |
| 15371 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15372 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 15373 | half, reuse, suppress, max); |
| 15374 | } |
| 15375 | |
| 15376 | ALIAS (bgp_damp_set, |
| 15377 | bgp_damp_set2_cmd, |
| 15378 | "bgp dampening <1-45>", |
| 15379 | "BGP Specific commands\n" |
| 15380 | "Enable route-flap dampening\n" |
| 15381 | "Half-life time for the penalty\n") |
| 15382 | |
| 15383 | ALIAS (bgp_damp_set, |
| 15384 | bgp_damp_set3_cmd, |
| 15385 | "bgp dampening", |
| 15386 | "BGP Specific commands\n" |
| 15387 | "Enable route-flap dampening\n") |
| 15388 | |
| 15389 | DEFUN (bgp_damp_unset, |
| 15390 | bgp_damp_unset_cmd, |
| 15391 | "no bgp dampening", |
| 15392 | NO_STR |
| 15393 | "BGP Specific commands\n" |
| 15394 | "Enable route-flap dampening\n") |
| 15395 | { |
| 15396 | struct bgp *bgp; |
| 15397 | |
| 15398 | bgp = vty->index; |
| 15399 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 15400 | } |
| 15401 | |
| 15402 | ALIAS (bgp_damp_unset, |
| 15403 | bgp_damp_unset2_cmd, |
| 15404 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15405 | NO_STR |
| 15406 | "BGP Specific commands\n" |
| 15407 | "Enable route-flap dampening\n" |
| 15408 | "Half-life time for the penalty\n" |
| 15409 | "Value to start reusing a route\n" |
| 15410 | "Value to start suppressing a route\n" |
| 15411 | "Maximum duration to suppress a stable route\n") |
| 15412 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15413 | DEFUN (show_ip_bgp_dampened_paths, |
| 15414 | show_ip_bgp_dampened_paths_cmd, |
| 15415 | "show ip bgp dampened-paths", |
| 15416 | SHOW_STR |
| 15417 | IP_STR |
| 15418 | BGP_STR |
| 15419 | "Display paths suppressed due to dampening\n") |
| 15420 | { |
| 15421 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 15422 | NULL); |
| 15423 | } |
| 15424 | |
| 15425 | ALIAS (show_ip_bgp_dampened_paths, |
| 15426 | show_ip_bgp_damp_dampened_paths_cmd, |
| 15427 | "show ip bgp dampening dampened-paths", |
| 15428 | SHOW_STR |
| 15429 | IP_STR |
| 15430 | BGP_STR |
| 15431 | "Display detailed information about dampening\n" |
| 15432 | "Display paths suppressed due to dampening\n") |
| 15433 | |
| 15434 | DEFUN (show_ip_bgp_flap_statistics, |
| 15435 | show_ip_bgp_flap_statistics_cmd, |
| 15436 | "show ip bgp flap-statistics", |
| 15437 | SHOW_STR |
| 15438 | IP_STR |
| 15439 | BGP_STR |
| 15440 | "Display flap statistics of routes\n") |
| 15441 | { |
| 15442 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 15443 | bgp_show_type_flap_statistics, NULL); |
| 15444 | } |
| 15445 | |
| 15446 | ALIAS (show_ip_bgp_flap_statistics, |
| 15447 | show_ip_bgp_damp_flap_statistics_cmd, |
| 15448 | "show ip bgp dampening flap-statistics", |
| 15449 | SHOW_STR |
| 15450 | IP_STR |
| 15451 | BGP_STR |
| 15452 | "Display detailed information about dampening\n" |
| 15453 | "Display flap statistics of routes\n") |
| 15454 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15455 | DEFUN (show_bgp_ipv4_safi_dampened_paths, |
| 15456 | show_bgp_ipv4_safi_dampened_paths_cmd, |
| 15457 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15458 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15459 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15460 | IP_STR |
| 15461 | "Address Family modifier\n" |
| 15462 | "Address Family modifier\n" |
| 15463 | "Address Family modifier\n" |
| 15464 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15465 | "Display paths suppressed due to dampening\n") |
| 15466 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15467 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15468 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15469 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15470 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15471 | return CMD_WARNING; |
| 15472 | } |
| 15473 | |
| 15474 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL); |
| 15475 | } |
| 15476 | ALIAS (show_bgp_ipv4_safi_dampened_paths, |
| 15477 | show_bgp_ipv4_safi_damp_dampened_paths_cmd, |
| 15478 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15479 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15480 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15481 | IP_STR |
| 15482 | "Address Family modifier\n" |
| 15483 | "Address Family modifier\n" |
| 15484 | "Address Family modifier\n" |
| 15485 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15486 | "Display detailed information about dampening\n" |
| 15487 | "Display paths suppressed due to dampening\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15488 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15489 | DEFUN (show_bgp_ipv6_safi_dampened_paths, |
| 15490 | show_bgp_ipv6_safi_dampened_paths_cmd, |
| 15491 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15492 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15493 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15494 | IPV6_STR |
| 15495 | "Address Family modifier\n" |
| 15496 | "Address Family modifier\n" |
| 15497 | "Address Family modifier\n" |
| 15498 | "Address Family modifier\n" |
| 15499 | "Display paths suppressed due to dampening\n") |
| 15500 | { |
| 15501 | safi_t safi; |
| 15502 | |
| 15503 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15504 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15505 | return CMD_WARNING; |
| 15506 | } |
| 15507 | |
| 15508 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL); |
| 15509 | } |
| 15510 | ALIAS (show_bgp_ipv6_safi_dampened_paths, |
| 15511 | show_bgp_ipv6_safi_damp_dampened_paths_cmd, |
| 15512 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths", |
| 15513 | SHOW_STR |
| 15514 | BGP_STR |
| 15515 | IPV6_STR |
| 15516 | "Address Family modifier\n" |
| 15517 | "Address Family modifier\n" |
| 15518 | "Address Family modifier\n" |
| 15519 | "Address Family modifier\n" |
| 15520 | "Display detailed information about dampening\n" |
| 15521 | "Display paths suppressed due to dampening\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15522 | |
| 15523 | DEFUN (show_bgp_ipv4_safi_flap_statistics, |
| 15524 | show_bgp_ipv4_safi_flap_statistics_cmd, |
| 15525 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics", |
| 15526 | SHOW_STR |
| 15527 | BGP_STR |
| 15528 | "Address Family\n" |
| 15529 | "Address Family modifier\n" |
| 15530 | "Address Family modifier\n" |
| 15531 | "Address Family modifier\n" |
| 15532 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15533 | "Display flap statistics of routes\n") |
| 15534 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15535 | safi_t safi; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15536 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15537 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15538 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15539 | return CMD_WARNING; |
| 15540 | } |
| 15541 | |
| 15542 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL); |
| 15543 | } |
| 15544 | ALIAS (show_bgp_ipv4_safi_flap_statistics, |
| 15545 | show_bgp_ipv4_safi_damp_flap_statistics_cmd, |
| 15546 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15547 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15548 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15549 | "Address Family\n" |
| 15550 | "Address Family modifier\n" |
| 15551 | "Address Family modifier\n" |
| 15552 | "Address Family modifier\n" |
| 15553 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15554 | "Display detailed information about dampening\n" |
| 15555 | "Display flap statistics of routes\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15556 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15557 | DEFUN (show_bgp_ipv6_safi_flap_statistics, |
| 15558 | show_bgp_ipv6_safi_flap_statistics_cmd, |
| 15559 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics", |
| 15560 | SHOW_STR |
| 15561 | BGP_STR |
| 15562 | "Address Family\n" |
| 15563 | "Address Family modifier\n" |
| 15564 | "Address Family modifier\n" |
| 15565 | "Address Family modifier\n" |
| 15566 | "Address Family modifier\n" |
| 15567 | "Display flap statistics of routes\n") |
| 15568 | { |
| 15569 | safi_t safi; |
| 15570 | |
| 15571 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15572 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15573 | return CMD_WARNING; |
| 15574 | } |
| 15575 | |
| 15576 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL); |
| 15577 | } |
| 15578 | ALIAS (show_bgp_ipv6_safi_flap_statistics, |
| 15579 | show_bgp_ipv6_safi_damp_flap_statistics_cmd, |
| 15580 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics", |
| 15581 | SHOW_STR |
| 15582 | BGP_STR |
| 15583 | "Address Family\n" |
| 15584 | "Address Family modifier\n" |
| 15585 | "Address Family modifier\n" |
| 15586 | "Address Family modifier\n" |
| 15587 | "Address Family modifier\n" |
| 15588 | "Display detailed information about dampening\n" |
| 15589 | "Display flap statistics of routes\n") |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15590 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15591 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15592 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15593 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 15594 | const char *ip_str, afi_t afi, safi_t safi, |
| 15595 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15596 | { |
| 15597 | int ret; |
| 15598 | struct prefix match; |
| 15599 | struct bgp_node *rn; |
| 15600 | struct bgp_node *rm; |
| 15601 | struct bgp_info *ri; |
| 15602 | struct bgp_info *ri_temp; |
| 15603 | struct bgp *bgp; |
| 15604 | struct bgp_table *table; |
| 15605 | |
| 15606 | /* BGP structure lookup. */ |
| 15607 | if (view_name) |
| 15608 | { |
| 15609 | bgp = bgp_lookup_by_name (view_name); |
| 15610 | if (bgp == NULL) |
| 15611 | { |
| 15612 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 15613 | return CMD_WARNING; |
| 15614 | } |
| 15615 | } |
| 15616 | else |
| 15617 | { |
| 15618 | bgp = bgp_get_default (); |
| 15619 | if (bgp == NULL) |
| 15620 | { |
| 15621 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 15622 | return CMD_WARNING; |
| 15623 | } |
| 15624 | } |
| 15625 | |
| 15626 | /* Check IP address argument. */ |
| 15627 | ret = str2prefix (ip_str, &match); |
| 15628 | if (! ret) |
| 15629 | { |
| 15630 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 15631 | return CMD_WARNING; |
| 15632 | } |
| 15633 | |
| 15634 | match.family = afi2family (afi); |
| 15635 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15636 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15637 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15638 | 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] | 15639 | { |
| 15640 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 15641 | continue; |
| 15642 | |
| 15643 | if ((table = rn->info) != NULL) |
| 15644 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15645 | { |
| 15646 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 15647 | { |
| 15648 | ri = rm->info; |
| 15649 | while (ri) |
| 15650 | { |
| 15651 | if (ri->extra && ri->extra->damp_info) |
| 15652 | { |
| 15653 | ri_temp = ri->next; |
| 15654 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15655 | ri = ri_temp; |
| 15656 | } |
| 15657 | else |
| 15658 | ri = ri->next; |
| 15659 | } |
| 15660 | } |
| 15661 | |
| 15662 | bgp_unlock_node (rm); |
| 15663 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15664 | } |
| 15665 | } |
| 15666 | else |
| 15667 | { |
| 15668 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15669 | { |
| 15670 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 15671 | { |
| 15672 | ri = rn->info; |
| 15673 | while (ri) |
| 15674 | { |
| 15675 | if (ri->extra && ri->extra->damp_info) |
| 15676 | { |
| 15677 | ri_temp = ri->next; |
| 15678 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15679 | ri = ri_temp; |
| 15680 | } |
| 15681 | else |
| 15682 | ri = ri->next; |
| 15683 | } |
| 15684 | } |
| 15685 | |
| 15686 | bgp_unlock_node (rn); |
| 15687 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15688 | } |
| 15689 | |
| 15690 | return CMD_SUCCESS; |
| 15691 | } |
| 15692 | |
| 15693 | DEFUN (clear_ip_bgp_dampening, |
| 15694 | clear_ip_bgp_dampening_cmd, |
| 15695 | "clear ip bgp dampening", |
| 15696 | CLEAR_STR |
| 15697 | IP_STR |
| 15698 | BGP_STR |
| 15699 | "Clear route flap dampening information\n") |
| 15700 | { |
| 15701 | bgp_damp_info_clean (); |
| 15702 | return CMD_SUCCESS; |
| 15703 | } |
| 15704 | |
| 15705 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 15706 | clear_ip_bgp_dampening_prefix_cmd, |
| 15707 | "clear ip bgp dampening A.B.C.D/M", |
| 15708 | CLEAR_STR |
| 15709 | IP_STR |
| 15710 | BGP_STR |
| 15711 | "Clear route flap dampening information\n" |
| 15712 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 15713 | { |
| 15714 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15715 | SAFI_UNICAST, NULL, 1); |
| 15716 | } |
| 15717 | |
| 15718 | DEFUN (clear_ip_bgp_dampening_address, |
| 15719 | clear_ip_bgp_dampening_address_cmd, |
| 15720 | "clear ip bgp dampening A.B.C.D", |
| 15721 | CLEAR_STR |
| 15722 | IP_STR |
| 15723 | BGP_STR |
| 15724 | "Clear route flap dampening information\n" |
| 15725 | "Network to clear damping information\n") |
| 15726 | { |
| 15727 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15728 | SAFI_UNICAST, NULL, 0); |
| 15729 | } |
| 15730 | |
| 15731 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 15732 | clear_ip_bgp_dampening_address_mask_cmd, |
| 15733 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 15734 | CLEAR_STR |
| 15735 | IP_STR |
| 15736 | BGP_STR |
| 15737 | "Clear route flap dampening information\n" |
| 15738 | "Network to clear damping information\n" |
| 15739 | "Network mask\n") |
| 15740 | { |
| 15741 | int ret; |
| 15742 | char prefix_str[BUFSIZ]; |
| 15743 | |
| 15744 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 15745 | if (! ret) |
| 15746 | { |
| 15747 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 15748 | return CMD_WARNING; |
| 15749 | } |
| 15750 | |
| 15751 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 15752 | SAFI_UNICAST, NULL, 0); |
| 15753 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15754 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15755 | /* also used for encap safi */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15756 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15757 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 15758 | afi_t afi, safi_t safi, int *write) |
| 15759 | { |
| 15760 | struct bgp_node *prn; |
| 15761 | struct bgp_node *rn; |
| 15762 | struct bgp_table *table; |
| 15763 | struct prefix *p; |
| 15764 | struct prefix_rd *prd; |
| 15765 | struct bgp_static *bgp_static; |
| 15766 | u_int32_t label; |
| 15767 | char buf[SU_ADDRSTRLEN]; |
| 15768 | char rdbuf[RD_ADDRSTRLEN]; |
| 15769 | |
| 15770 | /* Network configuration. */ |
| 15771 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 15772 | if ((table = prn->info) != NULL) |
| 15773 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 15774 | if ((bgp_static = rn->info) != NULL) |
| 15775 | { |
| 15776 | p = &rn->p; |
| 15777 | prd = (struct prefix_rd *) &prn->p; |
| 15778 | |
| 15779 | /* "address-family" display. */ |
| 15780 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15781 | |
| 15782 | /* "network" configuration display. */ |
| 15783 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 15784 | label = decode_label (bgp_static->tag); |
| 15785 | |
| 15786 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 15787 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15788 | p->prefixlen, |
| 15789 | rdbuf, label); |
| 15790 | vty_out (vty, "%s", VTY_NEWLINE); |
| 15791 | } |
| 15792 | return 0; |
| 15793 | } |
| 15794 | |
| 15795 | /* Configuration of static route announcement and aggregate |
| 15796 | information. */ |
| 15797 | int |
| 15798 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 15799 | afi_t afi, safi_t safi, int *write) |
| 15800 | { |
| 15801 | struct bgp_node *rn; |
| 15802 | struct prefix *p; |
| 15803 | struct bgp_static *bgp_static; |
| 15804 | struct bgp_aggregate *bgp_aggregate; |
| 15805 | char buf[SU_ADDRSTRLEN]; |
| 15806 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15807 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15808 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 15809 | |
| 15810 | /* Network configuration. */ |
| 15811 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 15812 | if ((bgp_static = rn->info) != NULL) |
| 15813 | { |
| 15814 | p = &rn->p; |
| 15815 | |
| 15816 | /* "address-family" display. */ |
| 15817 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15818 | |
| 15819 | /* "network" configuration display. */ |
| 15820 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 15821 | { |
| 15822 | u_int32_t destination; |
| 15823 | struct in_addr netmask; |
| 15824 | |
| 15825 | destination = ntohl (p->u.prefix4.s_addr); |
| 15826 | masklen2ip (p->prefixlen, &netmask); |
| 15827 | vty_out (vty, " network %s", |
| 15828 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 15829 | |
| 15830 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 15831 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 15832 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 15833 | || p->u.prefix4.s_addr == 0) |
| 15834 | { |
| 15835 | /* Natural mask is not display. */ |
| 15836 | } |
| 15837 | else |
| 15838 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 15839 | } |
| 15840 | else |
| 15841 | { |
| 15842 | vty_out (vty, " network %s/%d", |
| 15843 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15844 | p->prefixlen); |
| 15845 | } |
| 15846 | |
| 15847 | if (bgp_static->rmap.name) |
| 15848 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 15849 | else |
| 15850 | { |
| 15851 | if (bgp_static->backdoor) |
| 15852 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 15853 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15854 | |
| 15855 | vty_out (vty, "%s", VTY_NEWLINE); |
| 15856 | } |
| 15857 | |
| 15858 | /* Aggregate-address configuration. */ |
| 15859 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 15860 | if ((bgp_aggregate = rn->info) != NULL) |
| 15861 | { |
| 15862 | p = &rn->p; |
| 15863 | |
| 15864 | /* "address-family" display. */ |
| 15865 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15866 | |
| 15867 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 15868 | { |
| 15869 | struct in_addr netmask; |
| 15870 | |
| 15871 | masklen2ip (p->prefixlen, &netmask); |
| 15872 | vty_out (vty, " aggregate-address %s %s", |
| 15873 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15874 | inet_ntoa (netmask)); |
| 15875 | } |
| 15876 | else |
| 15877 | { |
| 15878 | vty_out (vty, " aggregate-address %s/%d", |
| 15879 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15880 | p->prefixlen); |
| 15881 | } |
| 15882 | |
| 15883 | if (bgp_aggregate->as_set) |
| 15884 | vty_out (vty, " as-set"); |
| 15885 | |
| 15886 | if (bgp_aggregate->summary_only) |
| 15887 | vty_out (vty, " summary-only"); |
| 15888 | |
| 15889 | vty_out (vty, "%s", VTY_NEWLINE); |
| 15890 | } |
| 15891 | |
| 15892 | return 0; |
| 15893 | } |
| 15894 | |
| 15895 | int |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15896 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp, |
| 15897 | afi_t afi, safi_t safi, int *write) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15898 | { |
| 15899 | struct bgp_node *rn; |
| 15900 | struct bgp_distance *bdistance; |
| 15901 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15902 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 15903 | { |
| 15904 | /* Distance configuration. */ |
| 15905 | if (bgp->distance_ebgp |
| 15906 | && bgp->distance_ibgp |
| 15907 | && bgp->distance_local |
| 15908 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 15909 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 15910 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 15911 | vty_out (vty, " distance bgp %d %d %d%s", |
| 15912 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 15913 | VTY_NEWLINE); |
| 15914 | |
| 15915 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 15916 | if ((bdistance = rn->info) != NULL) |
| 15917 | { |
| 15918 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 15919 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 15920 | bdistance->access_list ? bdistance->access_list : "", |
| 15921 | VTY_NEWLINE); |
| 15922 | } |
| 15923 | } |
| 15924 | |
| 15925 | #ifdef HAVE_IPV6 |
| 15926 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
| 15927 | { |
| 15928 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15929 | if (bgp->ipv6_distance_ebgp |
| 15930 | && bgp->ipv6_distance_ibgp |
| 15931 | && bgp->ipv6_distance_local |
| 15932 | && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 15933 | || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 15934 | || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 15935 | vty_out (vty, " distance bgp %d %d %d%s", |
| 15936 | bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local, |
| 15937 | VTY_NEWLINE); |
| 15938 | |
| 15939 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 15940 | if ((bdistance = rn->info) != NULL) |
| 15941 | { |
| 15942 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 15943 | inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen, |
| 15944 | bdistance->access_list ? bdistance->access_list : "", |
| 15945 | VTY_NEWLINE); |
| 15946 | } |
| 15947 | } |
| 15948 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15949 | |
| 15950 | return 0; |
| 15951 | } |
| 15952 | |
| 15953 | /* Allocate routing table structure and install commands. */ |
| 15954 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 15955 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15956 | { |
| 15957 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 15958 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15959 | |
| 15960 | /* IPv4 BGP commands. */ |
| 15961 | install_element (BGP_NODE, &bgp_network_cmd); |
| 15962 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 15963 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 15964 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 15965 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 15966 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 15967 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 15968 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 15969 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 15970 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 15971 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 15972 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 15973 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 15974 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 15975 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 15976 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 15977 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 15978 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 15979 | |
| 15980 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 15981 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 15982 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 15983 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 15984 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 15985 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 15986 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 15987 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 15988 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 15989 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 15990 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 15991 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 15992 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 15993 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 15994 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 15995 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 15996 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 15997 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 15998 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 15999 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16000 | |
| 16001 | /* IPv4 unicast configuration. */ |
| 16002 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 16003 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 16004 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 16005 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 16006 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 16007 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16008 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16009 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 16010 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 16011 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 16012 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16013 | 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] | 16014 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16015 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 16016 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 16017 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 16018 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16019 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 16020 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 16021 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 16022 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16023 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 16024 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16025 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 16026 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 16027 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 16028 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16029 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16030 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 16031 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16032 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16033 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16034 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16035 | |
| 16036 | /* IPv4 multicast configuration. */ |
| 16037 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 16038 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 16039 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 16040 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 16041 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 16042 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16043 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 16044 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 16045 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 16046 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 16047 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16048 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16049 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 16050 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 16051 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 16052 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16053 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 16054 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 16055 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 16056 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16057 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 16058 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16059 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 16060 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 16061 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 16062 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16063 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16064 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 16065 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16066 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16067 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16068 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16069 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16070 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16071 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16072 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); |
| 16073 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); |
| 16074 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16075 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16076 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd); |
| 16077 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd); |
| 16078 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16079 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16080 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16081 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16082 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16083 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16084 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16085 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16086 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16087 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16088 | install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd); |
| 16089 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16090 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16091 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd); |
| 16092 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd); |
| 16093 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd); |
| 16094 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd); |
| 16095 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd); |
| 16096 | install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd); |
| 16097 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd); |
| 16098 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd); |
| 16099 | install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd); |
| 16100 | install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd); |
| 16101 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd); |
| 16102 | install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd); |
| 16103 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd); |
| 16104 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd); |
| 16105 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd); |
| 16106 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16107 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16108 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16109 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16110 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16111 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16112 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16113 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16114 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16115 | install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16116 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16117 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16118 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16119 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16120 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16121 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16122 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
| 16123 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd); |
| 16124 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd); |
| 16125 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd); |
| 16126 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd); |
| 16127 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd); |
| 16128 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd); |
| 16129 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd); |
| 16130 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd); |
| 16131 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd); |
| 16132 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd); |
| 16133 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16134 | 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] | 16135 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd); |
| 16136 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd); |
| 16137 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd); |
| 16138 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd); |
| 16139 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd); |
| 16140 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd); |
| 16141 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd); |
| 16142 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd); |
| 16143 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd); |
| 16144 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd); |
| 16145 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd); |
| 16146 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd); |
| 16147 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd); |
| 16148 | install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd); |
| 16149 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd); |
| 16150 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd); |
| 16151 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd); |
| 16152 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd); |
| 16153 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd); |
| 16154 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd); |
| 16155 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd); |
| 16156 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd); |
| 16157 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd); |
| 16158 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd); |
| 16159 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd); |
| 16160 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd); |
| 16161 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd); |
| 16162 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd); |
| 16163 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd); |
| 16164 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd); |
| 16165 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd); |
| 16166 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd); |
| 16167 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd); |
| 16168 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd); |
| 16169 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd); |
| 16170 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd); |
| 16171 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd); |
| 16172 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd); |
| 16173 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd); |
| 16174 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd); |
| 16175 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd); |
| 16176 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd); |
| 16177 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd); |
| 16178 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd); |
| 16179 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16180 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16181 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16182 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16183 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16184 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16185 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16186 | |
| 16187 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16188 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16189 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16190 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16191 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16192 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16193 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16194 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16195 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16196 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16197 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16198 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16199 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16200 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16201 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16202 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16203 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd); |
| 16204 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd); |
| 16205 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd); |
| 16206 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd); |
| 16207 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16208 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16209 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16210 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16211 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16212 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16213 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16214 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16215 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16216 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16217 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16218 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16219 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16220 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16221 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16222 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16223 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16224 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16225 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16226 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16227 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16228 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16229 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16230 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16231 | install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd); |
| 16232 | install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd); |
| 16233 | install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16234 | install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16235 | install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd); |
| 16236 | install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd); |
| 16237 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16238 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16239 | install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16240 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16241 | install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16242 | install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16243 | install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16244 | install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16245 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16246 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16247 | install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd); |
| 16248 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16249 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16250 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd); |
| 16251 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd); |
| 16252 | install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd); |
| 16253 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd); |
| 16254 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd); |
| 16255 | install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd); |
| 16256 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd); |
| 16257 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd); |
| 16258 | install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd); |
| 16259 | install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd); |
| 16260 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd); |
| 16261 | install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd); |
| 16262 | install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd); |
| 16263 | install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd); |
| 16264 | install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd); |
| 16265 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16266 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16267 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16268 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16269 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16270 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16271 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16272 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16273 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16274 | install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16275 | install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16276 | install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16277 | install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16278 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16279 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16280 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16281 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
| 16282 | install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd); |
| 16283 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd); |
| 16284 | install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd); |
| 16285 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd); |
| 16286 | install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd); |
| 16287 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd); |
| 16288 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd); |
| 16289 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd); |
| 16290 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd); |
| 16291 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd); |
| 16292 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16293 | 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] | 16294 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd); |
| 16295 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd); |
| 16296 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd); |
| 16297 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd); |
| 16298 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd); |
| 16299 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd); |
| 16300 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd); |
| 16301 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd); |
| 16302 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd); |
| 16303 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd); |
| 16304 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd); |
| 16305 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd); |
| 16306 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd); |
| 16307 | install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd); |
| 16308 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd); |
| 16309 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd); |
| 16310 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd); |
| 16311 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd); |
| 16312 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd); |
| 16313 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd); |
| 16314 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd); |
| 16315 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd); |
| 16316 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd); |
| 16317 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd); |
| 16318 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd); |
| 16319 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd); |
| 16320 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd); |
| 16321 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd); |
| 16322 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd); |
| 16323 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd); |
| 16324 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd); |
| 16325 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd); |
| 16326 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd); |
| 16327 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd); |
| 16328 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd); |
| 16329 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd); |
| 16330 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd); |
| 16331 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd); |
| 16332 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd); |
| 16333 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd); |
| 16334 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd); |
| 16335 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd); |
| 16336 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd); |
| 16337 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd); |
| 16338 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16339 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16340 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16341 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16342 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16343 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16344 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16345 | |
| 16346 | /* BGP dampening clear commands */ |
| 16347 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 16348 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 16349 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 16350 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 16351 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 16352 | /* prefix count */ |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16353 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd); |
| 16354 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 16355 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 16356 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16357 | /* New config IPv6 BGP commands. */ |
| 16358 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 16359 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 16360 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 16361 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 16362 | |
| 16363 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 16364 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 16365 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 16366 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 16367 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 16368 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 16369 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 16370 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16371 | /* Old config IPv6 BGP commands. */ |
| 16372 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 16373 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 16374 | |
| 16375 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 16376 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 16377 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 16378 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 16379 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16380 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16381 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16382 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16383 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16384 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16385 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16386 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16387 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16388 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16389 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16390 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16391 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16392 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16393 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16394 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16395 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16396 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16397 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16398 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16399 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16400 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16401 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16402 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16403 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16404 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16405 | install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 16406 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16407 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16408 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16409 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16410 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16411 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16412 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16413 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16414 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16415 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16416 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16417 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16418 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16419 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16420 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16421 | install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 16422 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16423 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16424 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16425 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16426 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16427 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16428 | |
| 16429 | /* Restricted: |
| 16430 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 16431 | */ |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16432 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16433 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16434 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16435 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16436 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16437 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16438 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16439 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16440 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16441 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16442 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16443 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
| 16444 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16445 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16446 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16447 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16448 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16449 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16450 | 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] | 16451 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16452 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16453 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16454 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16455 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16456 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16457 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16458 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16459 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16460 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16461 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16462 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16463 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16464 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16465 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16466 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16467 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16468 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16469 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16470 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16471 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16472 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16473 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16474 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16475 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16476 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16477 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16478 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16479 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16480 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16481 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16482 | install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 16483 | install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16484 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16485 | install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16486 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16487 | install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16488 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16489 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16490 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16491 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16492 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16493 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16494 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16495 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16496 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16497 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16498 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 16499 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16500 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16501 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16502 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16503 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16504 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 16505 | |
| 16506 | /* Statistics */ |
| 16507 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16508 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16509 | |
| 16510 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 16511 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 16512 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 16513 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 16514 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 16515 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 16516 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16517 | #ifdef HAVE_IPV6 |
| 16518 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd); |
| 16519 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd); |
| 16520 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd); |
| 16521 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd); |
| 16522 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd); |
| 16523 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd); |
| 16524 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd); |
| 16525 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16526 | |
| 16527 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 16528 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 16529 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 16530 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 16531 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 16532 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 16533 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 16534 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 16535 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 16536 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Balaji | 9145f0e | 2016-01-20 22:59:27 +0530 | [diff] [blame] | 16537 | |
| 16538 | /* IPv4 Multicast Mode */ |
| 16539 | install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); |
| 16540 | install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd); |
| 16541 | install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd); |
| 16542 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); |
| 16543 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd); |
| 16544 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16545 | |
| 16546 | /* Deprecated AS-Pathlimit commands */ |
| 16547 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 16548 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 16549 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16550 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16551 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16552 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16553 | |
| 16554 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 16555 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16556 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16557 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16558 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16559 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16560 | |
| 16561 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 16562 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 16563 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16564 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16565 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16566 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16567 | |
| 16568 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 16569 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16570 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16571 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16572 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16573 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16574 | |
| 16575 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 16576 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 16577 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16578 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16579 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16580 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16581 | |
| 16582 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 16583 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16584 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16585 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16586 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16587 | 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] | 16588 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16589 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 16590 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16591 | |
| 16592 | /* old style commands */ |
| 16593 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 16594 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 16595 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 16596 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16597 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 16598 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16599 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 16600 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 16601 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16602 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16603 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 16604 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 16605 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16606 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 16607 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 16608 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 16609 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 16610 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 16611 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 16612 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 16613 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 16614 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 16615 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 16616 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 16617 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 16618 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 16619 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 16620 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 16621 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 16622 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16623 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16624 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16625 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16626 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 16627 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16628 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16629 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16630 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16631 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16632 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16633 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16634 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 16635 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 16636 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 16637 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 16638 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 16639 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 16640 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 16641 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 16642 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 16643 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 16644 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 16645 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 16646 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 16647 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 16648 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16649 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16650 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16651 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); |
| 16652 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16653 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
| 16654 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 16655 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
| 16656 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 16657 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
| 16658 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 16659 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 16660 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
| 16661 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 16662 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 16663 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
| 16664 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 16665 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 16666 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 16667 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
| 16668 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 16669 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
| 16670 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 16671 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 16672 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 16673 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16674 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16675 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 16676 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
| 16677 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 16678 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16679 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
| 16680 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 16681 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16682 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16683 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 16684 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 16685 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16686 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16687 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 16688 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16689 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 16690 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 16691 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 16692 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 16693 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16694 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16695 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16696 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16697 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 16698 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16699 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16700 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16701 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16702 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16703 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16704 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16705 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16706 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16707 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16708 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
| 16709 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 16710 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 16711 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 16712 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16713 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 16714 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16715 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 16716 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 16717 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16718 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16719 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 16720 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 16721 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16722 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 16723 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 16724 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 16725 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 16726 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 16727 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 16728 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 16729 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 16730 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 16731 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 16732 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 16733 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 16734 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 16735 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 16736 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 16737 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 16738 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16739 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16740 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16741 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16742 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 16743 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16744 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16745 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16746 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16747 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16748 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16749 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16750 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 16751 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 16752 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 16753 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 16754 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 16755 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 16756 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 16757 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 16758 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 16759 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 16760 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 16761 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 16762 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 16763 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 16764 | install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); |
| 16765 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16766 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
| 16767 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); |
| 16768 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16769 | install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
| 16770 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 16771 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
| 16772 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 16773 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd); |
| 16774 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 16775 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 16776 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
| 16777 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 16778 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd); |
| 16779 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 16780 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
| 16781 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 16782 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 16783 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 16784 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
| 16785 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 16786 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
| 16787 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 16788 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 16789 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 16790 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16791 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16792 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 16793 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
| 16794 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 16795 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16796 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
| 16797 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 16798 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 16799 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
| 16800 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 16801 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 16802 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 16803 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 16804 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 16805 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 16806 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 16807 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 16808 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 16809 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 16810 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 16811 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 16812 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 16813 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 16814 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 16815 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 16816 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 16817 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 16818 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd); |
| 16819 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 16820 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd); |
| 16821 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 16822 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 16823 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 16824 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 16825 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 16826 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 16827 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 16828 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 16829 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 16830 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 16831 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 16832 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 16833 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 16834 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 16835 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16836 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 16837 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 16838 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 16839 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 16840 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 16841 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 16842 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 16843 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 16844 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 16845 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 16846 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 16847 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 16848 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 16849 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 16850 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 16851 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16852 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 16853 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 16854 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 16855 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 16856 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 16857 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 16858 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 16859 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 16860 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 16861 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 16862 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 16863 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 16864 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 16865 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 16866 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 16867 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 16868 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 16869 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 16870 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd); |
| 16871 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 16872 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 16873 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 16874 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 16875 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 16876 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 16877 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 16878 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 16879 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 16880 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 16881 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 16882 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 16883 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 16884 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 16885 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 16886 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16887 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 16888 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 16889 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 16890 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 16891 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 16892 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 16893 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 16894 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 16895 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 16896 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 16897 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 16898 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 16899 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 16900 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 16901 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 16902 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 16903 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 16904 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 16905 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 16906 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 16907 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 16908 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 16909 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 16910 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 16911 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 16912 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 16913 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 16914 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 16915 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 16916 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 16917 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 16918 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 16919 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 16920 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 16921 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 16922 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 16923 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 16924 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 16925 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 16926 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 16927 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 16928 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 16929 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 16930 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 16931 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 16932 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 16933 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 16934 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 16935 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 16936 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 16937 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 16938 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 16939 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 16940 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 16941 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 16942 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 16943 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 16944 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 16945 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 16946 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 16947 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 16948 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 16949 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 16950 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 16951 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 16952 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 16953 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 16954 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 16955 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 16956 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 16957 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 16958 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 16959 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 16960 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 16961 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 16962 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 16963 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 16964 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 16965 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 16966 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 16967 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 16968 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 16969 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 16970 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 16971 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 16972 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 16973 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 16974 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 16975 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 16976 | /* old with name safi collision */ |
| 16977 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 16978 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 16979 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 16980 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 16981 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16982 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16983 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16984 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16985 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 16986 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 16987 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 16988 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 16989 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16990 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16991 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16992 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16993 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 16994 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 16995 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 16996 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 16997 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16998 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16999 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 17000 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 17001 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 17002 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 17003 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 17004 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 17005 | |
| 17006 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 17007 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
| 17008 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
| 17009 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
| 17010 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 17011 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
| 17012 | |
| 17013 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 17014 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
| 17015 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
| 17016 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
| 17017 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 17018 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 17019 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 17020 | |
| 17021 | void |
| 17022 | bgp_route_finish (void) |
| 17023 | { |
| 17024 | bgp_table_unlock (bgp_distance_table); |
| 17025 | bgp_distance_table = NULL; |
| 17026 | } |