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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 74 | if (safi == SAFI_MPLS_VPN) |
| 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 | |
| 87 | if (safi == SAFI_MPLS_VPN) |
| 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 | |
| 324 | /* Compare two bgp route entity. br is preferable then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 325 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 326 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
| 327 | int *paths_eq) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 328 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 329 | struct attr *newattr, *existattr; |
| 330 | struct attr_extra *newattre, *existattre; |
| 331 | bgp_peer_sort_t new_sort; |
| 332 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 333 | u_int32_t new_pref; |
| 334 | u_int32_t exist_pref; |
| 335 | u_int32_t new_med; |
| 336 | u_int32_t exist_med; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 337 | u_int32_t new_weight; |
| 338 | u_int32_t exist_weight; |
| 339 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 340 | struct in_addr new_id; |
| 341 | struct in_addr exist_id; |
| 342 | int new_cluster; |
| 343 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 344 | int internal_as_route; |
| 345 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 346 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 347 | |
| 348 | *paths_eq = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 349 | |
| 350 | /* 0. Null check. */ |
| 351 | if (new == NULL) |
| 352 | return 0; |
| 353 | if (exist == NULL) |
| 354 | return 1; |
| 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 | 718e374 | 2002-12-13 20:15:29 +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 | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 372 | return 0; |
| 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) |
| 383 | return 1; |
| 384 | if (new_pref < exist_pref) |
| 385 | return 0; |
| 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)) |
| 393 | return 1; |
| 394 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
| 395 | return 0; |
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)) |
hasso | 6811845 | 2005-04-08 15:40:36 +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)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 413 | return 0; |
| 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) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 420 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 421 | if (newhops > exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 422 | return 0; |
| 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 | 718e374 | 2002-12-13 20:15:29 +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 | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 430 | return 0; |
| 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) |
| 451 | return 1; |
| 452 | if (new_med > exist_med) |
| 453 | return 0; |
| 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 | 718e374 | 2002-12-13 20:15:29 +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 | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 465 | return 0; |
| 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) |
| 476 | ret = 1; |
| 477 | if (newm > existm) |
| 478 | ret = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 479 | |
| 480 | /* 9. Maximum path check. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 481 | if (newm == existm) |
| 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 | { |
| 485 | |
| 486 | /* |
| 487 | * For the two paths, all comparison steps till IGP metric |
| 488 | * have succeeded - including AS_PATH hop count. Since 'bgp |
| 489 | * bestpath as-path multipath-relax' knob is on, we don't need |
| 490 | * an exact match of AS_PATH. Thus, mark the paths are equal. |
| 491 | * That will trigger both these paths to get into the multipath |
| 492 | * array. |
| 493 | */ |
| 494 | *paths_eq = 1; |
| 495 | } |
| 496 | else if (new->peer->sort == BGP_PEER_IBGP) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 497 | { |
| 498 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 499 | *paths_eq = 1; |
| 500 | } |
| 501 | else if (new->peer->as == exist->peer->as) |
| 502 | *paths_eq = 1; |
| 503 | } |
| 504 | else |
| 505 | { |
| 506 | /* |
| 507 | * TODO: If unequal cost ibgp multipath is enabled we can |
| 508 | * mark the paths as equal here instead of returning |
| 509 | */ |
| 510 | return ret; |
| 511 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 512 | |
| 513 | /* 10. If both paths are external, prefer the path that was received |
| 514 | first (the oldest one). This step minimizes route-flap, since a |
| 515 | newer path won't displace an older one, even if it was the |
| 516 | preferred route based on the additional decision criteria below. */ |
| 517 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 518 | && new_sort == BGP_PEER_EBGP |
| 519 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 520 | { |
| 521 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 522 | return 1; |
| 523 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 524 | return 0; |
| 525 | } |
| 526 | |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 527 | /* 11. Router-ID comparision. */ |
| 528 | /* If one of the paths is "stale", the corresponding peer router-id will |
| 529 | * be 0 and would always win over the other path. If originator id is |
| 530 | * used for the comparision, it will decide which path is better. |
| 531 | */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 532 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 533 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | else |
| 535 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 536 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 537 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | else |
| 539 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 540 | |
| 541 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 542 | return 1; |
| 543 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 544 | return 0; |
| 545 | |
| 546 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 547 | new_cluster = exist_cluster = 0; |
| 548 | |
| 549 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 550 | new_cluster = newattre->cluster->length; |
| 551 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 552 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 553 | |
| 554 | if (new_cluster < exist_cluster) |
| 555 | return 1; |
| 556 | if (new_cluster > exist_cluster) |
| 557 | return 0; |
| 558 | |
| 559 | /* 13. Neighbor address comparision. */ |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 560 | /* Do this only if neither path is "stale" as stale paths do not have |
| 561 | * valid peer information (as the connection may or may not be up). |
| 562 | */ |
| 563 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) |
| 564 | return 1; |
| 565 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
| 566 | return 0; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 567 | /* locally configured routes to advertise do not have su_remote */ |
| 568 | if (new->peer->su_remote == NULL) |
| 569 | return 0; |
| 570 | if (exist->peer->su_remote == NULL) |
| 571 | return 1; |
| 572 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 574 | |
| 575 | if (ret == 1) |
| 576 | return 0; |
| 577 | if (ret == -1) |
| 578 | return 1; |
| 579 | |
| 580 | return 1; |
| 581 | } |
| 582 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 583 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 584 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 585 | afi_t afi, safi_t safi) |
| 586 | { |
| 587 | struct bgp_filter *filter; |
| 588 | |
| 589 | filter = &peer->filter[afi][safi]; |
| 590 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 591 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 592 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 593 | && !(F ## _IN (filter))) \ |
| 594 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 595 | peer->host, #f, F ## _IN_NAME(filter)); |
| 596 | |
| 597 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 598 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 599 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 600 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 601 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 602 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 603 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 604 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 605 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 606 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 607 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 608 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 609 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 610 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 611 | if (FILTER_LIST_IN_NAME (filter)) { |
| 612 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 613 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 614 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 615 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 616 | } |
| 617 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 618 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 619 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 620 | } |
| 621 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 622 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 624 | afi_t afi, safi_t safi) |
| 625 | { |
| 626 | struct bgp_filter *filter; |
| 627 | |
| 628 | filter = &peer->filter[afi][safi]; |
| 629 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 630 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 631 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 632 | && !(F ## _OUT (filter))) \ |
| 633 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 634 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 635 | |
| 636 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 637 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 640 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 641 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 642 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 643 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 644 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 645 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 646 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 647 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 648 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 649 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 650 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 651 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 652 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 653 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 654 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 655 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 656 | |
| 657 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 658 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 662 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 663 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 664 | { |
| 665 | if (attr->community) |
| 666 | { |
| 667 | /* NO_ADVERTISE check. */ |
| 668 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 669 | return 1; |
| 670 | |
| 671 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 672 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 673 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 674 | return 1; |
| 675 | |
| 676 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 677 | if (peer->sort == BGP_PEER_EBGP |
| 678 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 679 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 680 | return 1; |
| 681 | } |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | /* Route reflection loop check. */ |
| 686 | static int |
| 687 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 688 | { |
| 689 | struct in_addr cluster_id; |
| 690 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 691 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 692 | { |
| 693 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 694 | cluster_id = peer->bgp->cluster_id; |
| 695 | else |
| 696 | cluster_id = peer->bgp->router_id; |
| 697 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 698 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 699 | return 1; |
| 700 | } |
| 701 | return 0; |
| 702 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 703 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 704 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 705 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 706 | afi_t afi, safi_t safi) |
| 707 | { |
| 708 | struct bgp_filter *filter; |
| 709 | struct bgp_info info; |
| 710 | route_map_result_t ret; |
| 711 | |
| 712 | filter = &peer->filter[afi][safi]; |
| 713 | |
| 714 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 715 | if (peer->weight) |
| 716 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 717 | |
| 718 | /* Route map apply. */ |
| 719 | if (ROUTE_MAP_IN_NAME (filter)) |
| 720 | { |
| 721 | /* Duplicate current value to new strucutre for modification. */ |
| 722 | info.peer = peer; |
| 723 | info.attr = attr; |
| 724 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 725 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 726 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 727 | /* Apply BGP route map to the attribute. */ |
| 728 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 729 | |
| 730 | peer->rmap_type = 0; |
| 731 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 732 | if (ret == RMAP_DENYMATCH) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 733 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 734 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 735 | } |
| 736 | return RMAP_PERMIT; |
| 737 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 738 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 739 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 740 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 741 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 742 | { |
| 743 | struct bgp_filter *filter; |
| 744 | struct bgp_info info; |
| 745 | route_map_result_t ret; |
| 746 | |
| 747 | filter = &peer->filter[afi][safi]; |
| 748 | |
| 749 | /* Route map apply. */ |
| 750 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 751 | { |
| 752 | /* Duplicate current value to new strucutre for modification. */ |
| 753 | info.peer = rsclient; |
| 754 | info.attr = attr; |
| 755 | |
| 756 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 757 | |
| 758 | /* Apply BGP route map to the attribute. */ |
| 759 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 760 | |
| 761 | rsclient->rmap_type = 0; |
| 762 | |
| 763 | if (ret == RMAP_DENYMATCH) |
| 764 | { |
| 765 | /* Free newly generated AS path and community by route-map. */ |
| 766 | bgp_attr_flush (attr); |
| 767 | return RMAP_DENY; |
| 768 | } |
| 769 | } |
| 770 | return RMAP_PERMIT; |
| 771 | } |
| 772 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 773 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 774 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 775 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 776 | { |
| 777 | struct bgp_filter *filter; |
| 778 | struct bgp_info info; |
| 779 | route_map_result_t ret; |
| 780 | |
| 781 | filter = &rsclient->filter[afi][safi]; |
| 782 | |
| 783 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 784 | if (peer->weight) |
| 785 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 786 | |
| 787 | /* Route map apply. */ |
| 788 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 789 | { |
| 790 | /* Duplicate current value to new strucutre for modification. */ |
| 791 | info.peer = peer; |
| 792 | info.attr = attr; |
| 793 | |
| 794 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 795 | |
| 796 | /* Apply BGP route map to the attribute. */ |
| 797 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 798 | |
| 799 | peer->rmap_type = 0; |
| 800 | |
| 801 | if (ret == RMAP_DENYMATCH) |
| 802 | { |
| 803 | /* Free newly generated AS path and community by route-map. */ |
| 804 | bgp_attr_flush (attr); |
| 805 | return RMAP_DENY; |
| 806 | } |
| 807 | } |
| 808 | return RMAP_PERMIT; |
| 809 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 810 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 811 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 812 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 813 | struct attr *attr, afi_t afi, safi_t safi) |
| 814 | { |
| 815 | int ret; |
| 816 | char buf[SU_ADDRSTRLEN]; |
| 817 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 818 | struct peer *from; |
| 819 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 820 | int transparent; |
| 821 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 822 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 823 | |
| 824 | from = ri->peer; |
| 825 | filter = &peer->filter[afi][safi]; |
| 826 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 827 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 828 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 829 | if (DISABLE_BGP_ANNOUNCE) |
| 830 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 831 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 832 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 833 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 834 | return 0; |
| 835 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | /* Do not send back route to sender. */ |
| 837 | if (from == peer) |
| 838 | return 0; |
| 839 | |
| 840 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 841 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 842 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 843 | return 0; |
| 844 | |
| 845 | /* Default route check. */ |
| 846 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 847 | { |
| 848 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 849 | return 0; |
| 850 | #ifdef HAVE_IPV6 |
| 851 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 852 | return 0; |
| 853 | #endif /* HAVE_IPV6 */ |
| 854 | } |
| 855 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 856 | /* Transparency check. */ |
| 857 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 858 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 859 | transparent = 1; |
| 860 | else |
| 861 | transparent = 0; |
| 862 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 863 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 864 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 865 | return 0; |
| 866 | |
| 867 | /* If the attribute has originator-id and it is same as remote |
| 868 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 869 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 870 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 871 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 872 | { |
| 873 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 874 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 875 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 876 | peer->host, |
| 877 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 878 | p->prefixlen); |
| 879 | return 0; |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | /* ORF prefix-list filter check */ |
| 884 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 885 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 886 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 887 | if (peer->orf_plist[afi][safi]) |
| 888 | { |
| 889 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 890 | return 0; |
| 891 | } |
| 892 | |
| 893 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 894 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 895 | { |
| 896 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 897 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 898 | "%s [Update:SEND] %s/%d is filtered", |
| 899 | peer->host, |
| 900 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 901 | p->prefixlen); |
| 902 | return 0; |
| 903 | } |
| 904 | |
| 905 | #ifdef BGP_SEND_ASPATH_CHECK |
| 906 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 907 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 908 | { |
| 909 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 910 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 911 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 912 | peer->host, peer->as); |
| 913 | return 0; |
| 914 | } |
| 915 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 916 | |
| 917 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 918 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 919 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 920 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 921 | { |
| 922 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 923 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 924 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 925 | peer->host, |
| 926 | bgp->confed_id); |
| 927 | return 0; |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 932 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 933 | reflect = 1; |
| 934 | else |
| 935 | reflect = 0; |
| 936 | |
| 937 | /* IBGP reflection check. */ |
| 938 | if (reflect) |
| 939 | { |
| 940 | /* A route from a Client peer. */ |
| 941 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 942 | { |
| 943 | /* Reflect to all the Non-Client peers and also to the |
| 944 | Client peers other than the originator. Originator check |
| 945 | is already done. So there is noting to do. */ |
| 946 | /* no bgp client-to-client reflection check. */ |
| 947 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 948 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 949 | return 0; |
| 950 | } |
| 951 | else |
| 952 | { |
| 953 | /* A route from a Non-client peer. Reflect to all other |
| 954 | clients. */ |
| 955 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 956 | return 0; |
| 957 | } |
| 958 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 959 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 960 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 961 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 962 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 963 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 964 | if ((peer->sort == BGP_PEER_IBGP |
| 965 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 966 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 967 | { |
| 968 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 969 | attr->local_pref = bgp->default_local_pref; |
| 970 | } |
| 971 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 972 | /* If originator-id is not set and the route is to be reflected, |
| 973 | set the originator id */ |
| 974 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 975 | from->sort == BGP_PEER_IBGP && |
| 976 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 977 | { |
| 978 | attr->extra = bgp_attr_extra_get(attr); |
| 979 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 980 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 981 | } |
| 982 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 983 | /* 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] | 984 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 985 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 986 | { |
| 987 | if (ri->peer != bgp->peer_self && ! transparent |
| 988 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 989 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 990 | } |
| 991 | |
| 992 | /* next-hop-set */ |
Timo Teräs | 9e7a53c | 2014-04-24 10:22:37 +0300 | [diff] [blame] | 993 | if (transparent |
| 994 | || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 995 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 996 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 997 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 998 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 999 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1000 | #endif /* HAVE_IPV6 */ |
| 1001 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1002 | { |
| 1003 | /* NEXT-HOP Unchanged. */ |
| 1004 | } |
| 1005 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 1006 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1007 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1008 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1009 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1010 | #endif /* HAVE_IPV6 */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1011 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1012 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 1013 | { |
| 1014 | /* Set IPv4 nexthop. */ |
| 1015 | if (p->family == AF_INET) |
| 1016 | { |
| 1017 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1018 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1019 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1020 | else |
| 1021 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1022 | } |
| 1023 | #ifdef HAVE_IPV6 |
| 1024 | /* Set IPv6 nexthop. */ |
| 1025 | if (p->family == AF_INET6) |
| 1026 | { |
| 1027 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1028 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1029 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1030 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1031 | } |
| 1032 | #endif /* HAVE_IPV6 */ |
| 1033 | } |
| 1034 | |
| 1035 | #ifdef HAVE_IPV6 |
| 1036 | if (p->family == AF_INET6) |
| 1037 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1038 | /* Left nexthop_local unchanged if so configured. */ |
| 1039 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1040 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1041 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1042 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1043 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1044 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1045 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1049 | else |
| 1050 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1051 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1052 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1053 | |
| 1054 | /* Set link-local address for shared network peer. */ |
| 1055 | if (peer->shared_network |
| 1056 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1057 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1058 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1059 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1060 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1064 | address.*/ |
| 1065 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1066 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1067 | |
| 1068 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1069 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1070 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1071 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1072 | |
| 1073 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1074 | #endif /* HAVE_IPV6 */ |
| 1075 | |
| 1076 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1077 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1078 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1079 | && aspath_private_as_check (attr->aspath)) |
| 1080 | attr->aspath = aspath_empty_get (); |
| 1081 | |
| 1082 | /* Route map & unsuppress-map apply. */ |
| 1083 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1084 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1085 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1086 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1087 | struct attr dummy_attr; |
| 1088 | struct attr_extra dummy_extra; |
| 1089 | |
| 1090 | dummy_attr.extra = &dummy_extra; |
| 1091 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1092 | info.peer = peer; |
| 1093 | info.attr = attr; |
| 1094 | |
| 1095 | /* The route reflector is not allowed to modify the attributes |
| 1096 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1097 | if (from->sort == BGP_PEER_IBGP |
| 1098 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1099 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1100 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1101 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1102 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1103 | |
| 1104 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1105 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1106 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1107 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1108 | else |
| 1109 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1110 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1111 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1112 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1113 | if (ret == RMAP_DENYMATCH) |
| 1114 | { |
| 1115 | bgp_attr_flush (attr); |
| 1116 | return 0; |
| 1117 | } |
| 1118 | } |
| 1119 | return 1; |
| 1120 | } |
| 1121 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1122 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1123 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1124 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1125 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1126 | int ret; |
| 1127 | char buf[SU_ADDRSTRLEN]; |
| 1128 | struct bgp_filter *filter; |
| 1129 | struct bgp_info info; |
| 1130 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1131 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1132 | |
| 1133 | from = ri->peer; |
| 1134 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1135 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1136 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1137 | if (DISABLE_BGP_ANNOUNCE) |
| 1138 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1139 | |
| 1140 | /* Do not send back route to sender. */ |
| 1141 | if (from == rsclient) |
| 1142 | return 0; |
| 1143 | |
| 1144 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1145 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1146 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1147 | return 0; |
| 1148 | |
| 1149 | /* Default route check. */ |
| 1150 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1151 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1152 | { |
| 1153 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1154 | return 0; |
| 1155 | #ifdef HAVE_IPV6 |
| 1156 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1157 | return 0; |
| 1158 | #endif /* HAVE_IPV6 */ |
| 1159 | } |
| 1160 | |
| 1161 | /* If the attribute has originator-id and it is same as remote |
| 1162 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1163 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1164 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1165 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1166 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1167 | { |
| 1168 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1169 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1170 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1171 | rsclient->host, |
| 1172 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1173 | p->prefixlen); |
| 1174 | return 0; |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | /* ORF prefix-list filter check */ |
| 1179 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1180 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1181 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1182 | if (rsclient->orf_plist[afi][safi]) |
| 1183 | { |
| 1184 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1185 | return 0; |
| 1186 | } |
| 1187 | |
| 1188 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1189 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1190 | { |
| 1191 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1192 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1193 | "%s [Update:SEND] %s/%d is filtered", |
| 1194 | rsclient->host, |
| 1195 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1196 | p->prefixlen); |
| 1197 | return 0; |
| 1198 | } |
| 1199 | |
| 1200 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1201 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1202 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1203 | { |
| 1204 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1205 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1206 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1207 | rsclient->host, rsclient->as); |
| 1208 | return 0; |
| 1209 | } |
| 1210 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1211 | |
| 1212 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1213 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1214 | |
| 1215 | /* next-hop-set */ |
| 1216 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1217 | #ifdef HAVE_IPV6 |
| 1218 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1219 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1220 | #endif /* HAVE_IPV6 */ |
| 1221 | ) |
| 1222 | { |
| 1223 | /* Set IPv4 nexthop. */ |
| 1224 | if (p->family == AF_INET) |
| 1225 | { |
| 1226 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1227 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1228 | IPV4_MAX_BYTELEN); |
| 1229 | else |
| 1230 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1231 | } |
| 1232 | #ifdef HAVE_IPV6 |
| 1233 | /* Set IPv6 nexthop. */ |
| 1234 | if (p->family == AF_INET6) |
| 1235 | { |
| 1236 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1237 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1238 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1239 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1240 | } |
| 1241 | #endif /* HAVE_IPV6 */ |
| 1242 | } |
| 1243 | |
| 1244 | #ifdef HAVE_IPV6 |
| 1245 | if (p->family == AF_INET6) |
| 1246 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1247 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1248 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1249 | /* Left nexthop_local unchanged if so configured. */ |
| 1250 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1251 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1252 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1253 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1254 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1255 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1256 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
| 1259 | /* Default nexthop_local treatment for RS-Clients */ |
| 1260 | else |
| 1261 | { |
| 1262 | /* Announcer and RS-Client are both in the same network */ |
| 1263 | if (rsclient->shared_network && from->shared_network && |
| 1264 | (rsclient->ifindex == from->ifindex)) |
| 1265 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1266 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1267 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1268 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1269 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | /* Set link-local address for shared network peer. */ |
| 1273 | else if (rsclient->shared_network |
| 1274 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1275 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1276 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1277 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1278 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1279 | } |
| 1280 | |
| 1281 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1282 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
| 1285 | } |
| 1286 | #endif /* HAVE_IPV6 */ |
| 1287 | |
| 1288 | |
| 1289 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1290 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1291 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1292 | && aspath_private_as_check (attr->aspath)) |
| 1293 | attr->aspath = aspath_empty_get (); |
| 1294 | |
| 1295 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1296 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1297 | { |
| 1298 | info.peer = rsclient; |
| 1299 | info.attr = attr; |
| 1300 | |
| 1301 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1302 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1303 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1304 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1305 | else |
| 1306 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1307 | |
| 1308 | rsclient->rmap_type = 0; |
| 1309 | |
| 1310 | if (ret == RMAP_DENYMATCH) |
| 1311 | { |
| 1312 | bgp_attr_flush (attr); |
| 1313 | return 0; |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | return 1; |
| 1318 | } |
| 1319 | |
| 1320 | struct bgp_info_pair |
| 1321 | { |
| 1322 | struct bgp_info *old; |
| 1323 | struct bgp_info *new; |
| 1324 | }; |
| 1325 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1326 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1327 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
| 1328 | struct bgp_maxpaths_cfg *mpath_cfg, |
| 1329 | struct bgp_info_pair *result) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1330 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1331 | struct bgp_info *new_select; |
| 1332 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1333 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1334 | struct bgp_info *ri1; |
| 1335 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1336 | struct bgp_info *nextri = NULL; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1337 | int paths_eq, do_mpath; |
| 1338 | struct list mp_list; |
| 1339 | |
| 1340 | bgp_mp_list_init (&mp_list); |
| 1341 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || |
| 1342 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); |
| 1343 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1344 | /* bgp deterministic-med */ |
| 1345 | new_select = NULL; |
| 1346 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1347 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1348 | { |
| 1349 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1350 | continue; |
| 1351 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1352 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1353 | if (ri1->peer && ri1->peer != bgp->peer_self) |
| 1354 | if (ri1->peer->status != Established) |
| 1355 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1356 | |
| 1357 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1358 | if (do_mpath) |
| 1359 | bgp_mp_list_add (&mp_list, ri1); |
| 1360 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | if (ri1->next) |
| 1362 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1363 | { |
| 1364 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1365 | continue; |
| 1366 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1367 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1368 | if (ri2->peer && |
| 1369 | ri2->peer != bgp->peer_self && |
| 1370 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1371 | if (ri2->peer->status != Established) |
| 1372 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1373 | |
| 1374 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1375 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1376 | ri2->attr->aspath)) |
| 1377 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1378 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1379 | old_select = ri2; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1380 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1381 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1382 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1383 | new_select = ri2; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1384 | if (do_mpath && !paths_eq) |
| 1385 | { |
| 1386 | bgp_mp_list_clear (&mp_list); |
| 1387 | bgp_mp_list_add (&mp_list, ri2); |
| 1388 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1389 | } |
| 1390 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1391 | if (do_mpath && paths_eq) |
| 1392 | bgp_mp_list_add (&mp_list, ri2); |
| 1393 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1394 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1395 | } |
| 1396 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1397 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1398 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1399 | |
| 1400 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
| 1401 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | /* Check old selected route and new selected route. */ |
| 1405 | old_select = NULL; |
| 1406 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1407 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1408 | { |
| 1409 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1410 | old_select = ri; |
| 1411 | |
| 1412 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1413 | { |
| 1414 | /* reap REMOVED routes, if needs be |
| 1415 | * selected route must stay for a while longer though |
| 1416 | */ |
| 1417 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1418 | && (ri != old_select)) |
| 1419 | bgp_info_reap (rn, ri); |
| 1420 | |
| 1421 | continue; |
| 1422 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1423 | |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1424 | if (ri->peer && |
| 1425 | ri->peer != bgp->peer_self && |
| 1426 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1427 | if (ri->peer->status != Established) |
| 1428 | continue; |
| 1429 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1430 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1431 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1432 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1433 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1434 | continue; |
| 1435 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1436 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1437 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1438 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1439 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
| 1440 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1441 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1442 | bgp_mp_dmed_deselect (new_select); |
| 1443 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1444 | new_select = ri; |
| 1445 | |
| 1446 | if (do_mpath && !paths_eq) |
| 1447 | { |
| 1448 | bgp_mp_list_clear (&mp_list); |
| 1449 | bgp_mp_list_add (&mp_list, ri); |
| 1450 | } |
| 1451 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1452 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1453 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1454 | |
| 1455 | if (do_mpath && paths_eq) |
| 1456 | bgp_mp_list_add (&mp_list, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1457 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1458 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1459 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1460 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1461 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1462 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1463 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1464 | bgp_mp_list_clear (&mp_list); |
| 1465 | |
| 1466 | result->old = old_select; |
| 1467 | result->new = new_select; |
| 1468 | |
| 1469 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1470 | } |
| 1471 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1472 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1474 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1475 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1476 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1477 | struct attr attr; |
| 1478 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1479 | |
| 1480 | p = &rn->p; |
| 1481 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1482 | /* Announce route to Established peer. */ |
| 1483 | if (peer->status != Established) |
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 | /* Address family configuration check. */ |
| 1487 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1488 | return 0; |
| 1489 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1490 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1491 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1492 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1493 | return 0; |
| 1494 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1495 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1496 | attr.extra = &extra; |
| 1497 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1498 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1499 | { |
| 1500 | case BGP_TABLE_MAIN: |
| 1501 | /* Announcement to peer->conf. If the route is filtered, |
| 1502 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1503 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1504 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1505 | else |
| 1506 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1507 | break; |
| 1508 | case BGP_TABLE_RSCLIENT: |
| 1509 | /* Announcement to peer->conf. If the route is filtered, |
| 1510 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1511 | if (selected && |
| 1512 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1513 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1514 | else |
| 1515 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1516 | break; |
| 1517 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1518 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1519 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1520 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1521 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1522 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1523 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1524 | struct bgp *bgp; |
| 1525 | struct bgp_node *rn; |
| 1526 | afi_t afi; |
| 1527 | safi_t safi; |
| 1528 | }; |
| 1529 | |
| 1530 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1531 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1532 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1533 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1534 | struct bgp *bgp = pq->bgp; |
| 1535 | struct bgp_node *rn = pq->rn; |
| 1536 | afi_t afi = pq->afi; |
| 1537 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1538 | struct bgp_info *new_select; |
| 1539 | struct bgp_info *old_select; |
| 1540 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1541 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1542 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1543 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1544 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1545 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1546 | new_select = old_and_new.new; |
| 1547 | old_select = old_and_new.old; |
| 1548 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1549 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1550 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1551 | if (rsclient->group) |
| 1552 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1553 | { |
| 1554 | /* Nothing to do. */ |
| 1555 | if (old_select && old_select == new_select) |
| 1556 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1557 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1558 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1559 | if (old_select) |
| 1560 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1561 | if (new_select) |
| 1562 | { |
| 1563 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1564 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1565 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1566 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1567 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1568 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1569 | afi, safi); |
| 1570 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1571 | } |
| 1572 | else |
| 1573 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1574 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1575 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1576 | if (new_select) |
| 1577 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1578 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1579 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1580 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1581 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1582 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1583 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1584 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1585 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1586 | bgp_info_reap (rn, old_select); |
| 1587 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1588 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1589 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1590 | } |
| 1591 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1592 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1593 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1594 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1595 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1596 | struct bgp *bgp = pq->bgp; |
| 1597 | struct bgp_node *rn = pq->rn; |
| 1598 | afi_t afi = pq->afi; |
| 1599 | safi_t safi = pq->safi; |
| 1600 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1601 | struct bgp_info *new_select; |
| 1602 | struct bgp_info *old_select; |
| 1603 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1604 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1605 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1606 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1607 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1608 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1609 | old_select = old_and_new.old; |
| 1610 | new_select = old_and_new.new; |
| 1611 | |
| 1612 | /* Nothing to do. */ |
| 1613 | if (old_select && old_select == new_select) |
| 1614 | { |
| 1615 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1616 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1617 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1618 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1619 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1620 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1621 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1622 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1623 | return WQ_SUCCESS; |
| 1624 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1625 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1626 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1627 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1628 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1629 | if (new_select) |
| 1630 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1631 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1632 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1633 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1634 | } |
| 1635 | |
| 1636 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1638 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1639 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1640 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1641 | } |
| 1642 | |
| 1643 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1644 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1645 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1646 | { |
| 1647 | if (new_select |
| 1648 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1649 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1650 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1651 | else |
| 1652 | { |
| 1653 | /* Withdraw the route from the kernel. */ |
| 1654 | if (old_select |
| 1655 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1656 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1657 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1658 | } |
| 1659 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1660 | |
| 1661 | /* Reap old select bgp_info, it it has been removed */ |
| 1662 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1663 | bgp_info_reap (rn, old_select); |
| 1664 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1665 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1666 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1667 | } |
| 1668 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1669 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1670 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1671 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1672 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1673 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1674 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1675 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1676 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1677 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1678 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1679 | } |
| 1680 | |
| 1681 | static void |
| 1682 | bgp_process_queue_init (void) |
| 1683 | { |
| 1684 | bm->process_main_queue |
| 1685 | = work_queue_new (bm->master, "process_main_queue"); |
| 1686 | bm->process_rsclient_queue |
| 1687 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1688 | |
| 1689 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1690 | { |
| 1691 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1692 | exit (1); |
| 1693 | } |
| 1694 | |
| 1695 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1696 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1697 | bm->process_main_queue->spec.max_retries = 0; |
| 1698 | bm->process_main_queue->spec.hold = 50; |
| 1699 | |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1700 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
David Lamparter | d43f8b3 | 2015-03-03 08:54:54 +0100 | [diff] [blame] | 1701 | bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del; |
| 1702 | bm->process_rsclient_queue->spec.max_retries = 0; |
| 1703 | bm->process_rsclient_queue->spec.hold = 50; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1704 | } |
| 1705 | |
| 1706 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1707 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1708 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1709 | struct bgp_process_queue *pqnode; |
| 1710 | |
| 1711 | /* already scheduled for processing? */ |
| 1712 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1713 | return; |
| 1714 | |
| 1715 | if ( (bm->process_main_queue == NULL) || |
| 1716 | (bm->process_rsclient_queue == NULL) ) |
| 1717 | bgp_process_queue_init (); |
| 1718 | |
| 1719 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1720 | sizeof (struct bgp_process_queue)); |
| 1721 | if (!pqnode) |
| 1722 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1723 | |
| 1724 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1725 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1726 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1727 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1728 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1729 | pqnode->afi = afi; |
| 1730 | pqnode->safi = safi; |
| 1731 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1732 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1733 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1734 | case BGP_TABLE_MAIN: |
| 1735 | work_queue_add (bm->process_main_queue, pqnode); |
| 1736 | break; |
| 1737 | case BGP_TABLE_RSCLIENT: |
| 1738 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1739 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1740 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1741 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1742 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1743 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1744 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1745 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1746 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1747 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1748 | { |
| 1749 | struct peer *peer; |
| 1750 | |
| 1751 | peer = THREAD_ARG (thread); |
| 1752 | peer->t_pmax_restart = NULL; |
| 1753 | |
| 1754 | if (BGP_DEBUG (events, EVENTS)) |
| 1755 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1756 | peer->host); |
| 1757 | |
| 1758 | peer_clear (peer); |
| 1759 | |
| 1760 | return 0; |
| 1761 | } |
| 1762 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1763 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1764 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1765 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1766 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1767 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1768 | return 0; |
| 1769 | |
| 1770 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1771 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1772 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1773 | && ! always) |
| 1774 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1775 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1776 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1777 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1778 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1779 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1780 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
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_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1783 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1784 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1785 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1786 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1787 | |
| 1788 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1789 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1790 | |
| 1791 | ndata[0] = (afi >> 8); |
| 1792 | ndata[1] = afi; |
| 1793 | ndata[2] = safi; |
| 1794 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1795 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1796 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1797 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1798 | |
| 1799 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1800 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1801 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1802 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1803 | |
| 1804 | /* restart timer start */ |
| 1805 | if (peer->pmax_restart[afi][safi]) |
| 1806 | { |
| 1807 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1808 | |
| 1809 | if (BGP_DEBUG (events, EVENTS)) |
| 1810 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1811 | peer->host, peer->v_pmax_restart); |
| 1812 | |
| 1813 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1814 | peer->v_pmax_restart); |
| 1815 | } |
| 1816 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1817 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1818 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1819 | else |
| 1820 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1821 | |
| 1822 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1823 | { |
| 1824 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1825 | && ! always) |
| 1826 | return 0; |
| 1827 | |
| 1828 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1829 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1830 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1831 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1832 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1833 | } |
| 1834 | else |
| 1835 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1836 | return 0; |
| 1837 | } |
| 1838 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1839 | /* Unconditionally remove the route from the RIB, without taking |
| 1840 | * damping into consideration (eg, because the session went down) |
| 1841 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1842 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1843 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1844 | afi_t afi, safi_t safi) |
| 1845 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1846 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1847 | |
| 1848 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1849 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1850 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1851 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1852 | } |
| 1853 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1854 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1855 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1856 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1857 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1858 | int status = BGP_DAMP_NONE; |
| 1859 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1860 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1861 | * the bgp_info in the RIB for historical reference. |
| 1862 | */ |
| 1863 | 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] | 1864 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1865 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1866 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1867 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1868 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1869 | return; |
| 1870 | } |
| 1871 | |
| 1872 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1873 | } |
| 1874 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1875 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1876 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1877 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1878 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1879 | { |
| 1880 | struct bgp_node *rn; |
| 1881 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1882 | struct attr new_attr; |
| 1883 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1884 | struct attr *attr_new; |
| 1885 | struct attr *attr_new2; |
| 1886 | struct bgp_info *ri; |
| 1887 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1888 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1889 | char buf[SU_ADDRSTRLEN]; |
| 1890 | |
| 1891 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1892 | if (peer == rsclient) |
| 1893 | return; |
| 1894 | |
| 1895 | bgp = peer->bgp; |
| 1896 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1897 | |
| 1898 | /* Check previously received route. */ |
| 1899 | for (ri = rn->info; ri; ri = ri->next) |
| 1900 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1901 | break; |
| 1902 | |
| 1903 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1904 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1905 | { |
| 1906 | reason = "as-path contains our own AS;"; |
| 1907 | goto filtered; |
| 1908 | } |
| 1909 | |
| 1910 | /* Route reflector originator ID check. */ |
| 1911 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1912 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1913 | { |
| 1914 | reason = "originator is us;"; |
| 1915 | goto filtered; |
| 1916 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1917 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1918 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1919 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1920 | |
| 1921 | /* Apply export policy. */ |
| 1922 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1923 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1924 | { |
| 1925 | reason = "export-policy;"; |
| 1926 | goto filtered; |
| 1927 | } |
| 1928 | |
| 1929 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1930 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1931 | /* Apply import policy. */ |
| 1932 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1933 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1934 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1935 | |
| 1936 | reason = "import-policy;"; |
| 1937 | goto filtered; |
| 1938 | } |
| 1939 | |
| 1940 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1941 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1942 | |
| 1943 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1944 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1945 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1946 | /* 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] | 1947 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1948 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1949 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1950 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1951 | |
| 1952 | reason = "martian next-hop;"; |
| 1953 | goto filtered; |
| 1954 | } |
| 1955 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1956 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1957 | /* If the update is implicit withdraw. */ |
| 1958 | if (ri) |
| 1959 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1960 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1961 | |
| 1962 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1963 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1964 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1965 | { |
| 1966 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1967 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1968 | |
| 1969 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1970 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1971 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1972 | peer->host, |
| 1973 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1974 | p->prefixlen, rsclient->host); |
| 1975 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1976 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1977 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1978 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1979 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1980 | } |
| 1981 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1982 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1983 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1984 | bgp_info_restore (rn, ri); |
| 1985 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1986 | /* Received Logging. */ |
| 1987 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1988 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1989 | peer->host, |
| 1990 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1991 | p->prefixlen, rsclient->host); |
| 1992 | |
| 1993 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1994 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1995 | |
| 1996 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1997 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1998 | ri->attr = attr_new; |
| 1999 | |
| 2000 | /* Update MPLS tag. */ |
| 2001 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2002 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2003 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2004 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2005 | |
| 2006 | /* Process change. */ |
| 2007 | bgp_process (bgp, rn, afi, safi); |
| 2008 | bgp_unlock_node (rn); |
| 2009 | |
| 2010 | return; |
| 2011 | } |
| 2012 | |
| 2013 | /* Received Logging. */ |
| 2014 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2015 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2016 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2017 | peer->host, |
| 2018 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2019 | p->prefixlen, rsclient->host); |
| 2020 | } |
| 2021 | |
| 2022 | /* Make new BGP info. */ |
| 2023 | new = bgp_info_new (); |
| 2024 | new->type = type; |
| 2025 | new->sub_type = sub_type; |
| 2026 | new->peer = peer; |
| 2027 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2028 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2029 | |
| 2030 | /* Update MPLS tag. */ |
| 2031 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2032 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2033 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2034 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2035 | |
| 2036 | /* Register new BGP information. */ |
| 2037 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2038 | |
| 2039 | /* route_node_get lock */ |
| 2040 | bgp_unlock_node (rn); |
| 2041 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2042 | /* Process change. */ |
| 2043 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2044 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2045 | return; |
| 2046 | |
| 2047 | filtered: |
| 2048 | |
| 2049 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2050 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2051 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2052 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2053 | peer->host, |
| 2054 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2055 | p->prefixlen, rsclient->host, reason); |
| 2056 | |
| 2057 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2058 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2059 | |
| 2060 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2061 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2062 | return; |
| 2063 | } |
| 2064 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2065 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2066 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2067 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2068 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2069 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2070 | struct bgp_node *rn; |
| 2071 | struct bgp_info *ri; |
| 2072 | char buf[SU_ADDRSTRLEN]; |
| 2073 | |
| 2074 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2075 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2076 | |
| 2077 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2078 | |
| 2079 | /* Lookup withdrawn route. */ |
| 2080 | for (ri = rn->info; ri; ri = ri->next) |
| 2081 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2082 | break; |
| 2083 | |
| 2084 | /* Withdraw specified route from routing table. */ |
| 2085 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2086 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2087 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2088 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2089 | "%s Can't find the route %s/%d", peer->host, |
| 2090 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2091 | p->prefixlen); |
| 2092 | |
| 2093 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2094 | bgp_unlock_node (rn); |
| 2095 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2096 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2097 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2098 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2099 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2100 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2101 | { |
| 2102 | int ret; |
| 2103 | int aspath_loop_count = 0; |
| 2104 | struct bgp_node *rn; |
| 2105 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2106 | struct attr new_attr; |
| 2107 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2108 | struct attr *attr_new; |
| 2109 | struct bgp_info *ri; |
| 2110 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2111 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2112 | char buf[SU_ADDRSTRLEN]; |
| 2113 | |
| 2114 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2115 | 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] | 2116 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2117 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2118 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2119 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2120 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2121 | bgp_adj_in_set (rn, peer, attr); |
| 2122 | |
| 2123 | /* Check previously received route. */ |
| 2124 | for (ri = rn->info; ri; ri = ri->next) |
| 2125 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2126 | break; |
| 2127 | |
| 2128 | /* AS path local-as loop check. */ |
| 2129 | if (peer->change_local_as) |
| 2130 | { |
| 2131 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2132 | aspath_loop_count = 1; |
| 2133 | |
| 2134 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2135 | { |
| 2136 | reason = "as-path contains our own AS;"; |
| 2137 | goto filtered; |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | /* AS path loop check. */ |
| 2142 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2143 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2144 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2145 | > peer->allowas_in[afi][safi])) |
| 2146 | { |
| 2147 | reason = "as-path contains our own AS;"; |
| 2148 | goto filtered; |
| 2149 | } |
| 2150 | |
| 2151 | /* Route reflector originator ID check. */ |
| 2152 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2153 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2154 | { |
| 2155 | reason = "originator is us;"; |
| 2156 | goto filtered; |
| 2157 | } |
| 2158 | |
| 2159 | /* Route reflector cluster ID check. */ |
| 2160 | if (bgp_cluster_filter (peer, attr)) |
| 2161 | { |
| 2162 | reason = "reflected from the same cluster;"; |
| 2163 | goto filtered; |
| 2164 | } |
| 2165 | |
| 2166 | /* Apply incoming filter. */ |
| 2167 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2168 | { |
| 2169 | reason = "filter;"; |
| 2170 | goto filtered; |
| 2171 | } |
| 2172 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2173 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2174 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2175 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2176 | /* Apply incoming route-map. |
| 2177 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2178 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2179 | * the attr (which takes over the memory references) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2180 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2181 | { |
| 2182 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2183 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2184 | goto filtered; |
| 2185 | } |
| 2186 | |
| 2187 | /* IPv4 unicast next hop check. */ |
| 2188 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2189 | { |
| 2190 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2191 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2192 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2193 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2194 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2195 | { |
| 2196 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2197 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2198 | goto filtered; |
| 2199 | } |
| 2200 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2201 | /* 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] | 2202 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2203 | if (new_attr.nexthop.s_addr == 0 |
| 2204 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2205 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2206 | { |
| 2207 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2208 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2209 | goto filtered; |
| 2210 | } |
| 2211 | } |
| 2212 | |
| 2213 | attr_new = bgp_attr_intern (&new_attr); |
| 2214 | |
| 2215 | /* If the update is implicit withdraw. */ |
| 2216 | if (ri) |
| 2217 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2218 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2219 | |
| 2220 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2221 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2222 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2223 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2224 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2225 | |
| 2226 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2227 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2228 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2229 | { |
| 2230 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2231 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2232 | peer->host, |
| 2233 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2234 | p->prefixlen); |
| 2235 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2236 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2237 | { |
| 2238 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2239 | bgp_process (bgp, rn, afi, safi); |
| 2240 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2241 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2242 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2243 | { |
| 2244 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2245 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2246 | "%s rcvd %s/%d...duplicate ignored", |
| 2247 | peer->host, |
| 2248 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2249 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2250 | |
| 2251 | /* graceful restart STALE flag unset. */ |
| 2252 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2253 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2254 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2255 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2256 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2257 | } |
| 2258 | |
| 2259 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2260 | bgp_attr_unintern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2261 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2262 | return 0; |
| 2263 | } |
| 2264 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2265 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2266 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2267 | { |
| 2268 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2269 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2270 | peer->host, |
| 2271 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2272 | p->prefixlen); |
| 2273 | bgp_info_restore (rn, ri); |
| 2274 | } |
| 2275 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2276 | /* Received Logging. */ |
| 2277 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2278 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2279 | peer->host, |
| 2280 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2281 | p->prefixlen); |
| 2282 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2283 | /* graceful restart STALE flag unset. */ |
| 2284 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2285 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2286 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2287 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2288 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2289 | |
| 2290 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2291 | * only if update is accepted, they'll increment below. |
| 2292 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2293 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2294 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2295 | /* Update bgp route dampening information. */ |
| 2296 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2297 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2298 | { |
| 2299 | /* This is implicit withdraw so we should update dampening |
| 2300 | information. */ |
| 2301 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2302 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2303 | } |
| 2304 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2305 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2306 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2307 | ri->attr = attr_new; |
| 2308 | |
| 2309 | /* Update MPLS tag. */ |
| 2310 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2311 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2312 | |
| 2313 | /* Update bgp route dampening information. */ |
| 2314 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2315 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | { |
| 2317 | /* Now we do normal update dampening. */ |
| 2318 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2319 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2320 | { |
| 2321 | bgp_unlock_node (rn); |
| 2322 | return 0; |
| 2323 | } |
| 2324 | } |
| 2325 | |
| 2326 | /* Nexthop reachability check. */ |
| 2327 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2328 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2329 | && (peer->sort == BGP_PEER_IBGP |
| 2330 | || peer->sort == BGP_PEER_CONFED |
| 2331 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2332 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2333 | { |
| 2334 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2335 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2337 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2338 | } |
| 2339 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2340 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2341 | |
| 2342 | /* Process change. */ |
| 2343 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2344 | |
| 2345 | bgp_process (bgp, rn, afi, safi); |
| 2346 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2347 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2348 | return 0; |
| 2349 | } |
| 2350 | |
| 2351 | /* Received Logging. */ |
| 2352 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2353 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2354 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2355 | peer->host, |
| 2356 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2357 | p->prefixlen); |
| 2358 | } |
| 2359 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2360 | /* Make new BGP info. */ |
| 2361 | new = bgp_info_new (); |
| 2362 | new->type = type; |
| 2363 | new->sub_type = sub_type; |
| 2364 | new->peer = peer; |
| 2365 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2366 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | |
| 2368 | /* Update MPLS tag. */ |
| 2369 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2370 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2371 | |
| 2372 | /* Nexthop reachability check. */ |
| 2373 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2374 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2375 | && (peer->sort == BGP_PEER_IBGP |
| 2376 | || peer->sort == BGP_PEER_CONFED |
| 2377 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2378 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2379 | { |
| 2380 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2381 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2382 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2383 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2384 | } |
| 2385 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2386 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2387 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2388 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2389 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2390 | |
| 2391 | /* Register new BGP information. */ |
| 2392 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2393 | |
| 2394 | /* route_node_get lock */ |
| 2395 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2396 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2397 | /* If maximum prefix count is configured and current prefix |
| 2398 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2399 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2400 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2401 | |
| 2402 | /* Process change. */ |
| 2403 | bgp_process (bgp, rn, afi, safi); |
| 2404 | |
| 2405 | return 0; |
| 2406 | |
| 2407 | /* This BGP update is filtered. Log the reason then update BGP |
| 2408 | entry. */ |
| 2409 | filtered: |
| 2410 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2411 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2412 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2413 | peer->host, |
| 2414 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2415 | p->prefixlen, reason); |
| 2416 | |
| 2417 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2418 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2419 | |
| 2420 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2421 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2422 | return 0; |
| 2423 | } |
| 2424 | |
| 2425 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2426 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2427 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2428 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2429 | { |
| 2430 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2431 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2432 | struct bgp *bgp; |
| 2433 | int ret; |
| 2434 | |
| 2435 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2436 | soft_reconfig); |
| 2437 | |
| 2438 | bgp = peer->bgp; |
| 2439 | |
| 2440 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2441 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2442 | { |
| 2443 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2444 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2445 | sub_type, prd, tag); |
| 2446 | } |
| 2447 | |
| 2448 | return ret; |
| 2449 | } |
| 2450 | |
| 2451 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2452 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2453 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2454 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2455 | { |
| 2456 | struct bgp *bgp; |
| 2457 | char buf[SU_ADDRSTRLEN]; |
| 2458 | struct bgp_node *rn; |
| 2459 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2460 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2461 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2462 | |
| 2463 | bgp = peer->bgp; |
| 2464 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2465 | /* Lookup node. */ |
| 2466 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2467 | |
| 2468 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2469 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2470 | * the iteration over all RS clients. |
| 2471 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2472 | * if there was no entry, we don't need to do anything more. */ |
| 2473 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2474 | && peer != bgp->peer_self) |
| 2475 | if (!bgp_adj_in_unset (rn, peer)) |
| 2476 | { |
| 2477 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2478 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2479 | "not in adj-in", peer->host, |
| 2480 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2481 | p->prefixlen); |
| 2482 | bgp_unlock_node (rn); |
| 2483 | return 0; |
| 2484 | } |
| 2485 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2486 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2487 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2488 | { |
| 2489 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2490 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2491 | } |
| 2492 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2493 | /* Logging. */ |
| 2494 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2495 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2496 | peer->host, |
| 2497 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2498 | p->prefixlen); |
| 2499 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2500 | /* Lookup withdrawn route. */ |
| 2501 | for (ri = rn->info; ri; ri = ri->next) |
| 2502 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2503 | break; |
| 2504 | |
| 2505 | /* Withdraw specified route from routing table. */ |
| 2506 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2507 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2508 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2509 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2510 | "%s Can't find the route %s/%d", peer->host, |
| 2511 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2512 | p->prefixlen); |
| 2513 | |
| 2514 | /* Unlock bgp_node_get() lock. */ |
| 2515 | bgp_unlock_node (rn); |
| 2516 | |
| 2517 | return 0; |
| 2518 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2520 | void |
| 2521 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2522 | { |
| 2523 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2524 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2525 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2526 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2527 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2528 | struct bgp_node *rn; |
| 2529 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2530 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2531 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2532 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2533 | return; |
| 2534 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2535 | bgp = peer->bgp; |
| 2536 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2537 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2538 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2539 | aspath = attr.aspath; |
| 2540 | attr.local_pref = bgp->default_local_pref; |
| 2541 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2542 | |
| 2543 | if (afi == AFI_IP) |
| 2544 | str2prefix ("0.0.0.0/0", &p); |
| 2545 | #ifdef HAVE_IPV6 |
| 2546 | else if (afi == AFI_IP6) |
| 2547 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2548 | struct attr_extra *ae = attr.extra; |
| 2549 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2550 | str2prefix ("::/0", &p); |
| 2551 | |
| 2552 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2553 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2554 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2555 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2556 | |
| 2557 | /* If the peer is on shared nextwork and we have link-local |
| 2558 | nexthop set it. */ |
| 2559 | if (peer->shared_network |
| 2560 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2561 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2562 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2563 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2564 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2565 | } |
| 2566 | } |
| 2567 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2568 | |
| 2569 | if (peer->default_rmap[afi][safi].name) |
| 2570 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2571 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2572 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2573 | { |
| 2574 | for (ri = rn->info; ri; ri = ri->next) |
| 2575 | { |
| 2576 | struct attr dummy_attr; |
| 2577 | struct attr_extra dummy_extra; |
| 2578 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2579 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2580 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2581 | dummy_attr.extra = &dummy_extra; |
| 2582 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2583 | info.peer = ri->peer; |
| 2584 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2585 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2586 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2587 | RMAP_BGP, &info); |
| 2588 | |
| 2589 | /* The route map might have set attributes. If we don't flush them |
| 2590 | * here, they will be leaked. */ |
| 2591 | bgp_attr_flush(&dummy_attr); |
| 2592 | if (ret != RMAP_DENYMATCH) |
| 2593 | break; |
| 2594 | } |
| 2595 | if (ret != RMAP_DENYMATCH) |
| 2596 | break; |
| 2597 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2598 | bgp->peer_self->rmap_type = 0; |
| 2599 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2600 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2601 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2602 | } |
| 2603 | |
| 2604 | if (withdraw) |
| 2605 | { |
| 2606 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2607 | bgp_default_withdraw_send (peer, afi, safi); |
| 2608 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2609 | } |
| 2610 | else |
| 2611 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2612 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2613 | { |
| 2614 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2615 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2616 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2617 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2618 | |
| 2619 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2620 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2621 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2622 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2623 | static void |
| 2624 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2625 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2626 | { |
| 2627 | struct bgp_node *rn; |
| 2628 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2629 | struct attr attr; |
| 2630 | struct attr_extra extra; |
| 2631 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2632 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2633 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2634 | |
| 2635 | if (safi != SAFI_MPLS_VPN |
| 2636 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2637 | bgp_default_originate (peer, afi, safi, 0); |
| 2638 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2639 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2640 | attr.extra = &extra; |
| 2641 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2643 | for (ri = rn->info; ri; ri = ri->next) |
| 2644 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2645 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2646 | if ( (rsclient) ? |
| 2647 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2648 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2649 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2650 | else |
| 2651 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2652 | } |
| 2653 | } |
| 2654 | |
| 2655 | void |
| 2656 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2657 | { |
| 2658 | struct bgp_node *rn; |
| 2659 | struct bgp_table *table; |
| 2660 | |
| 2661 | if (peer->status != Established) |
| 2662 | return; |
| 2663 | |
| 2664 | if (! peer->afc_nego[afi][safi]) |
| 2665 | return; |
| 2666 | |
| 2667 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2668 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2669 | return; |
| 2670 | |
| 2671 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2672 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | else |
| 2674 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2675 | rn = bgp_route_next(rn)) |
| 2676 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2677 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2678 | |
| 2679 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2680 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2681 | } |
| 2682 | |
| 2683 | void |
| 2684 | bgp_announce_route_all (struct peer *peer) |
| 2685 | { |
| 2686 | afi_t afi; |
| 2687 | safi_t safi; |
| 2688 | |
| 2689 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2690 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2691 | bgp_announce_route (peer, afi, safi); |
| 2692 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2693 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2694 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2695 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2696 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2697 | { |
| 2698 | struct bgp_node *rn; |
| 2699 | struct bgp_adj_in *ain; |
| 2700 | |
| 2701 | if (! table) |
| 2702 | table = rsclient->bgp->rib[afi][safi]; |
| 2703 | |
| 2704 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2705 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2706 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2707 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2708 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2709 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2710 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2711 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2712 | } |
| 2713 | } |
| 2714 | |
| 2715 | void |
| 2716 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2717 | { |
| 2718 | struct bgp_table *table; |
| 2719 | struct bgp_node *rn; |
| 2720 | |
| 2721 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2722 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2723 | |
| 2724 | else |
| 2725 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2726 | rn = bgp_route_next (rn)) |
| 2727 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2728 | { |
| 2729 | struct prefix_rd prd; |
| 2730 | prd.family = AF_UNSPEC; |
| 2731 | prd.prefixlen = 64; |
| 2732 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2733 | |
| 2734 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2735 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2736 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2737 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2738 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2739 | 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] | 2740 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2741 | { |
| 2742 | int ret; |
| 2743 | struct bgp_node *rn; |
| 2744 | struct bgp_adj_in *ain; |
| 2745 | |
| 2746 | if (! table) |
| 2747 | table = peer->bgp->rib[afi][safi]; |
| 2748 | |
| 2749 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2750 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2751 | { |
| 2752 | if (ain->peer == peer) |
| 2753 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2754 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2755 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2756 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2757 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2758 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2759 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2760 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2761 | if (ret < 0) |
| 2762 | { |
| 2763 | bgp_unlock_node (rn); |
| 2764 | return; |
| 2765 | } |
| 2766 | continue; |
| 2767 | } |
| 2768 | } |
| 2769 | } |
| 2770 | |
| 2771 | void |
| 2772 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2773 | { |
| 2774 | struct bgp_node *rn; |
| 2775 | struct bgp_table *table; |
| 2776 | |
| 2777 | if (peer->status != Established) |
| 2778 | return; |
| 2779 | |
| 2780 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2781 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2782 | else |
| 2783 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2784 | rn = bgp_route_next (rn)) |
| 2785 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2786 | { |
| 2787 | struct prefix_rd prd; |
| 2788 | prd.family = AF_UNSPEC; |
| 2789 | prd.prefixlen = 64; |
| 2790 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2791 | |
| 2792 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2793 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2794 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2795 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2796 | |
| 2797 | struct bgp_clear_node_queue |
| 2798 | { |
| 2799 | struct bgp_node *rn; |
| 2800 | enum bgp_clear_route_type purpose; |
| 2801 | }; |
| 2802 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2803 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2804 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2805 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2806 | struct bgp_clear_node_queue *cnq = data; |
| 2807 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2808 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2809 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2810 | afi_t afi = bgp_node_table (rn)->afi; |
| 2811 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2812 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2813 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2814 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2815 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2816 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2817 | { |
| 2818 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2819 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2820 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2821 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2822 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2823 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2824 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2825 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2826 | break; |
| 2827 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2828 | return WQ_SUCCESS; |
| 2829 | } |
| 2830 | |
| 2831 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2832 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2833 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2834 | struct bgp_clear_node_queue *cnq = data; |
| 2835 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2836 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2837 | |
| 2838 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2839 | bgp_table_unlock (table); |
| 2840 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2841 | } |
| 2842 | |
| 2843 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2844 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2845 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2846 | struct peer *peer = wq->spec.data; |
| 2847 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2848 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2849 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2850 | |
| 2851 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2852 | } |
| 2853 | |
| 2854 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2855 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2856 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2857 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2858 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2859 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2860 | #undef CLEAR_QUEUE_NAME_LEN |
| 2861 | |
| 2862 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2863 | { |
| 2864 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2865 | exit (1); |
| 2866 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2867 | peer->clear_node_queue->spec.hold = 10; |
| 2868 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2869 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2870 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2871 | peer->clear_node_queue->spec.max_retries = 0; |
| 2872 | |
| 2873 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2874 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2875 | } |
| 2876 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2877 | static void |
| 2878 | 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] | 2879 | struct bgp_table *table, struct peer *rsclient, |
| 2880 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2881 | { |
| 2882 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2883 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2884 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2885 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2886 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2887 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2888 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2889 | if (! table) |
| 2890 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2891 | |
| 2892 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2893 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2894 | struct bgp_info *ri; |
| 2895 | struct bgp_adj_in *ain; |
| 2896 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2897 | |
| 2898 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2899 | * queued for every clearing peer, regardless of whether it is |
| 2900 | * relevant to the peer at hand. |
| 2901 | * |
| 2902 | * Overview: There are 3 different indices which need to be |
| 2903 | * scrubbed, potentially, when a peer is removed: |
| 2904 | * |
| 2905 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2906 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2907 | * 3 other routes visible by the peer's adj-out index |
| 2908 | * |
| 2909 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2910 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2911 | * adj-outs at our leisure. |
| 2912 | * |
| 2913 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2914 | * invisible via RIB index before peer session is allowed to be |
| 2915 | * brought back up. So one needs to know when such a 'search' is |
| 2916 | * complete. |
| 2917 | * |
| 2918 | * Ideally: |
| 2919 | * |
| 2920 | * - there'd be a single global queue or a single RIB walker |
| 2921 | * - rather than tracking which route_nodes still need to be |
| 2922 | * examined on a peer basis, we'd track which peers still |
| 2923 | * aren't cleared |
| 2924 | * |
| 2925 | * Given that our per-peer prefix-counts now should be reliable, |
| 2926 | * this may actually be achievable. It doesn't seem to be a huge |
| 2927 | * problem at this time, |
| 2928 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2929 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2930 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2931 | { |
| 2932 | bgp_adj_in_remove (rn, ain); |
| 2933 | bgp_unlock_node (rn); |
| 2934 | break; |
| 2935 | } |
| 2936 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2937 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2938 | { |
| 2939 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2940 | bgp_unlock_node (rn); |
| 2941 | break; |
| 2942 | } |
| 2943 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2944 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2945 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2946 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2947 | struct bgp_clear_node_queue *cnq; |
| 2948 | |
| 2949 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2950 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2951 | bgp_lock_node (rn); |
| 2952 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2953 | sizeof (struct bgp_clear_node_queue)); |
| 2954 | cnq->rn = rn; |
| 2955 | cnq->purpose = purpose; |
| 2956 | work_queue_add (peer->clear_node_queue, cnq); |
| 2957 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2958 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2959 | } |
| 2960 | return; |
| 2961 | } |
| 2962 | |
| 2963 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2964 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2965 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2966 | { |
| 2967 | struct bgp_node *rn; |
| 2968 | struct bgp_table *table; |
| 2969 | struct peer *rsclient; |
| 2970 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2971 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2972 | if (peer->clear_node_queue == NULL) |
| 2973 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2974 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2975 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2976 | * Idle until it receives a Clearing_Completed event. This protects |
| 2977 | * against peers which flap faster than we can we clear, which could |
| 2978 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2979 | * |
| 2980 | * a) race with routes from the new session being installed before |
| 2981 | * clear_route_node visits the node (to delete the route of that |
| 2982 | * peer) |
| 2983 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2984 | * on the process_main queue. Fast-flapping could cause that queue |
| 2985 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2986 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 2987 | |
| 2988 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 2989 | * the unlock will happen upon work-queue completion; other wise, the |
| 2990 | * unlock happens at the end of this function. |
| 2991 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2992 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 2993 | peer_lock (peer); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2994 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2995 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2996 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2997 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2998 | if (safi != SAFI_MPLS_VPN) |
| 2999 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3000 | else |
| 3001 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3002 | rn = bgp_route_next (rn)) |
| 3003 | if ((table = rn->info) != NULL) |
| 3004 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3005 | |
| 3006 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3007 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3008 | PEER_FLAG_RSERVER_CLIENT)) |
| 3009 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3010 | break; |
| 3011 | |
| 3012 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 3013 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3014 | break; |
| 3015 | |
| 3016 | default: |
| 3017 | assert (0); |
| 3018 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3019 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3020 | |
| 3021 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3022 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3023 | peer_unlock (peer); |
| 3024 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3025 | } |
| 3026 | |
| 3027 | void |
| 3028 | bgp_clear_route_all (struct peer *peer) |
| 3029 | { |
| 3030 | afi_t afi; |
| 3031 | safi_t safi; |
| 3032 | |
| 3033 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3034 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3035 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3036 | } |
| 3037 | |
| 3038 | void |
| 3039 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3040 | { |
| 3041 | struct bgp_table *table; |
| 3042 | struct bgp_node *rn; |
| 3043 | struct bgp_adj_in *ain; |
| 3044 | |
| 3045 | table = peer->bgp->rib[afi][safi]; |
| 3046 | |
| 3047 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3048 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3049 | if (ain->peer == peer) |
| 3050 | { |
| 3051 | bgp_adj_in_remove (rn, ain); |
| 3052 | bgp_unlock_node (rn); |
| 3053 | break; |
| 3054 | } |
| 3055 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3056 | |
| 3057 | void |
| 3058 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3059 | { |
| 3060 | struct bgp_node *rn; |
| 3061 | struct bgp_info *ri; |
| 3062 | struct bgp_table *table; |
| 3063 | |
| 3064 | table = peer->bgp->rib[afi][safi]; |
| 3065 | |
| 3066 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3067 | { |
| 3068 | for (ri = rn->info; ri; ri = ri->next) |
| 3069 | if (ri->peer == peer) |
| 3070 | { |
| 3071 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3072 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3073 | break; |
| 3074 | } |
| 3075 | } |
| 3076 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3077 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3078 | /* Delete all kernel routes. */ |
| 3079 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3080 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3081 | { |
| 3082 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3083 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3084 | struct bgp_node *rn; |
| 3085 | struct bgp_table *table; |
| 3086 | struct bgp_info *ri; |
| 3087 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3088 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3089 | { |
| 3090 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3091 | |
| 3092 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3093 | for (ri = rn->info; ri; ri = ri->next) |
| 3094 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3095 | && ri->type == ZEBRA_ROUTE_BGP |
| 3096 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3097 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3098 | |
| 3099 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3100 | |
| 3101 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3102 | for (ri = rn->info; ri; ri = ri->next) |
| 3103 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3104 | && ri->type == ZEBRA_ROUTE_BGP |
| 3105 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3106 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3107 | } |
| 3108 | } |
| 3109 | |
| 3110 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3111 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3112 | { |
| 3113 | vty_reset (); |
| 3114 | bgp_zclient_reset (); |
| 3115 | access_list_reset (); |
| 3116 | prefix_list_reset (); |
| 3117 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3118 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3119 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3120 | value. */ |
| 3121 | int |
| 3122 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3123 | { |
| 3124 | u_char *pnt; |
| 3125 | u_char *lim; |
| 3126 | struct prefix p; |
| 3127 | int psize; |
| 3128 | int ret; |
| 3129 | |
| 3130 | /* Check peer status. */ |
| 3131 | if (peer->status != Established) |
| 3132 | return 0; |
| 3133 | |
| 3134 | pnt = packet->nlri; |
| 3135 | lim = pnt + packet->length; |
| 3136 | |
| 3137 | for (; pnt < lim; pnt += psize) |
| 3138 | { |
| 3139 | /* Clear prefix structure. */ |
| 3140 | memset (&p, 0, sizeof (struct prefix)); |
| 3141 | |
| 3142 | /* Fetch prefix length. */ |
| 3143 | p.prefixlen = *pnt++; |
| 3144 | p.family = afi2family (packet->afi); |
| 3145 | |
| 3146 | /* Already checked in nlri_sanity_check(). We do double check |
| 3147 | here. */ |
| 3148 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3149 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3150 | return -1; |
| 3151 | |
| 3152 | /* Packet size overflow check. */ |
| 3153 | psize = PSIZE (p.prefixlen); |
| 3154 | |
| 3155 | /* When packet overflow occur return immediately. */ |
| 3156 | if (pnt + psize > lim) |
| 3157 | return -1; |
| 3158 | |
| 3159 | /* Fetch prefix from NLRI packet. */ |
| 3160 | memcpy (&p.u.prefix, pnt, psize); |
| 3161 | |
| 3162 | /* Check address. */ |
| 3163 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3164 | { |
| 3165 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3166 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3167 | /* |
| 3168 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3169 | * If a BGP router receives an UPDATE message with a |
| 3170 | * semantically incorrect NLRI field, in which a prefix is |
| 3171 | * semantically incorrect (eg. an unexpected multicast IP |
| 3172 | * address), it should ignore the prefix. |
| 3173 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3174 | zlog (peer->log, LOG_ERR, |
| 3175 | "IPv4 unicast NLRI is multicast address %s", |
| 3176 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3177 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3178 | return -1; |
| 3179 | } |
| 3180 | } |
| 3181 | |
| 3182 | #ifdef HAVE_IPV6 |
| 3183 | /* Check address. */ |
| 3184 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3185 | { |
| 3186 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3187 | { |
| 3188 | char buf[BUFSIZ]; |
| 3189 | |
| 3190 | zlog (peer->log, LOG_WARNING, |
| 3191 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3192 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3193 | |
| 3194 | continue; |
| 3195 | } |
| 3196 | } |
| 3197 | #endif /* HAVE_IPV6 */ |
| 3198 | |
| 3199 | /* Normal process. */ |
| 3200 | if (attr) |
| 3201 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3202 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3203 | else |
| 3204 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3205 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3206 | |
| 3207 | /* Address family configuration mismatch or maximum-prefix count |
| 3208 | overflow. */ |
| 3209 | if (ret < 0) |
| 3210 | return -1; |
| 3211 | } |
| 3212 | |
| 3213 | /* Packet length consistency check. */ |
| 3214 | if (pnt != lim) |
| 3215 | return -1; |
| 3216 | |
| 3217 | return 0; |
| 3218 | } |
| 3219 | |
| 3220 | /* NLRI encode syntax check routine. */ |
| 3221 | int |
| 3222 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3223 | bgp_size_t length) |
| 3224 | { |
| 3225 | u_char *end; |
| 3226 | u_char prefixlen; |
| 3227 | int psize; |
| 3228 | |
| 3229 | end = pnt + length; |
| 3230 | |
| 3231 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3232 | syntactic validity. If the field is syntactically incorrect, |
| 3233 | then the Error Subcode is set to Invalid Network Field. */ |
| 3234 | |
| 3235 | while (pnt < end) |
| 3236 | { |
| 3237 | prefixlen = *pnt++; |
| 3238 | |
| 3239 | /* Prefix length check. */ |
| 3240 | if ((afi == AFI_IP && prefixlen > 32) |
| 3241 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3242 | { |
| 3243 | plog_err (peer->log, |
| 3244 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3245 | peer->host, prefixlen); |
| 3246 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3247 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3248 | return -1; |
| 3249 | } |
| 3250 | |
| 3251 | /* Packet size overflow check. */ |
| 3252 | psize = PSIZE (prefixlen); |
| 3253 | |
| 3254 | if (pnt + psize > end) |
| 3255 | { |
| 3256 | plog_err (peer->log, |
| 3257 | "%s [Error] Update packet error" |
| 3258 | " (prefix data overflow prefix size is %d)", |
| 3259 | peer->host, psize); |
| 3260 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3261 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3262 | return -1; |
| 3263 | } |
| 3264 | |
| 3265 | pnt += psize; |
| 3266 | } |
| 3267 | |
| 3268 | /* Packet length consistency check. */ |
| 3269 | if (pnt != end) |
| 3270 | { |
| 3271 | plog_err (peer->log, |
| 3272 | "%s [Error] Update packet error" |
| 3273 | " (prefix length mismatch with total length)", |
| 3274 | peer->host); |
| 3275 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3276 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3277 | return -1; |
| 3278 | } |
| 3279 | return 0; |
| 3280 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3281 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3282 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3283 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3284 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3285 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3286 | } |
| 3287 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3288 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3289 | bgp_static_free (struct bgp_static *bgp_static) |
| 3290 | { |
| 3291 | if (bgp_static->rmap.name) |
| 3292 | free (bgp_static->rmap.name); |
| 3293 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3294 | } |
| 3295 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3296 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3297 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3298 | struct prefix *p, afi_t afi, safi_t safi) |
| 3299 | { |
| 3300 | struct bgp_node *rn; |
| 3301 | struct bgp_info *ri; |
| 3302 | |
| 3303 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3304 | |
| 3305 | /* Check selected route and self inserted route. */ |
| 3306 | for (ri = rn->info; ri; ri = ri->next) |
| 3307 | if (ri->peer == bgp->peer_self |
| 3308 | && ri->type == ZEBRA_ROUTE_BGP |
| 3309 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3310 | break; |
| 3311 | |
| 3312 | /* Withdraw static BGP route from routing table. */ |
| 3313 | if (ri) |
| 3314 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3315 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3316 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3317 | } |
| 3318 | |
| 3319 | /* Unlock bgp_node_lookup. */ |
| 3320 | bgp_unlock_node (rn); |
| 3321 | } |
| 3322 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3323 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3324 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3325 | struct bgp_static *bgp_static, |
| 3326 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3327 | { |
| 3328 | struct bgp_node *rn; |
| 3329 | struct bgp_info *ri; |
| 3330 | struct bgp_info *new; |
| 3331 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3332 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3333 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3334 | struct attr new_attr; |
| 3335 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3336 | struct bgp *bgp; |
| 3337 | int ret; |
| 3338 | char buf[SU_ADDRSTRLEN]; |
| 3339 | |
| 3340 | bgp = rsclient->bgp; |
| 3341 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3342 | assert (bgp_static); |
| 3343 | if (!bgp_static) |
| 3344 | return; |
| 3345 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3346 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3347 | |
| 3348 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3349 | |
| 3350 | attr.nexthop = bgp_static->igpnexthop; |
| 3351 | attr.med = bgp_static->igpmetric; |
| 3352 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3353 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3354 | if (bgp_static->atomic) |
| 3355 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3356 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3357 | /* Apply network route-map for export to this rsclient. */ |
| 3358 | if (bgp_static->rmap.name) |
| 3359 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3360 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3361 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3362 | info.attr = &attr_tmp; |
| 3363 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3364 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3365 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3366 | |
| 3367 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3368 | |
| 3369 | rsclient->rmap_type = 0; |
| 3370 | |
| 3371 | if (ret == RMAP_DENYMATCH) |
| 3372 | { |
| 3373 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3374 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3375 | |
| 3376 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3377 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3378 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3379 | bgp_attr_extra_free (&attr); |
| 3380 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3381 | return; |
| 3382 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3383 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3384 | } |
| 3385 | else |
| 3386 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3387 | |
| 3388 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3389 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3390 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3391 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3392 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3393 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3394 | == RMAP_DENY) |
| 3395 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3396 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3397 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3398 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3399 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3400 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3401 | p->prefixlen, rsclient->host); |
| 3402 | |
| 3403 | bgp->peer_self->rmap_type = 0; |
| 3404 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3405 | bgp_attr_unintern (&attr_new); |
| 3406 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3407 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3408 | |
| 3409 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3410 | |
| 3411 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3412 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3413 | |
| 3414 | bgp->peer_self->rmap_type = 0; |
| 3415 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3416 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3417 | attr_new = bgp_attr_intern (&new_attr); |
| 3418 | |
| 3419 | for (ri = rn->info; ri; ri = ri->next) |
| 3420 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3421 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3422 | break; |
| 3423 | |
| 3424 | if (ri) |
| 3425 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3426 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3427 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3428 | { |
| 3429 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3430 | bgp_attr_unintern (&attr_new); |
| 3431 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3432 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3433 | return; |
| 3434 | } |
| 3435 | else |
| 3436 | { |
| 3437 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3438 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3439 | |
| 3440 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3441 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3442 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3443 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3444 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3445 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3446 | |
| 3447 | /* Process change. */ |
| 3448 | bgp_process (bgp, rn, afi, safi); |
| 3449 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3450 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3451 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3452 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3453 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3454 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3455 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3456 | /* Make new BGP info. */ |
| 3457 | new = bgp_info_new (); |
| 3458 | new->type = ZEBRA_ROUTE_BGP; |
| 3459 | new->sub_type = BGP_ROUTE_STATIC; |
| 3460 | new->peer = bgp->peer_self; |
| 3461 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3462 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3463 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3464 | |
| 3465 | /* Register new BGP information. */ |
| 3466 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3467 | |
| 3468 | /* route_node_get lock */ |
| 3469 | bgp_unlock_node (rn); |
| 3470 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3471 | /* Process change. */ |
| 3472 | bgp_process (bgp, rn, afi, safi); |
| 3473 | |
| 3474 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3475 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3476 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3477 | } |
| 3478 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3479 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3480 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3481 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3482 | { |
| 3483 | struct bgp_node *rn; |
| 3484 | struct bgp_info *ri; |
| 3485 | struct bgp_info *new; |
| 3486 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3487 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3488 | struct attr *attr_new; |
| 3489 | int ret; |
| 3490 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3491 | assert (bgp_static); |
| 3492 | if (!bgp_static) |
| 3493 | return; |
| 3494 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3495 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3496 | |
| 3497 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3498 | |
| 3499 | attr.nexthop = bgp_static->igpnexthop; |
| 3500 | attr.med = bgp_static->igpmetric; |
| 3501 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3502 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3503 | if (bgp_static->atomic) |
| 3504 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3505 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3506 | /* Apply route-map. */ |
| 3507 | if (bgp_static->rmap.name) |
| 3508 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3509 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3510 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3511 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3512 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3513 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3514 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3515 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3516 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3517 | bgp->peer_self->rmap_type = 0; |
| 3518 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3519 | if (ret == RMAP_DENYMATCH) |
| 3520 | { |
| 3521 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3522 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3523 | |
| 3524 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3525 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3526 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3527 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3528 | return; |
| 3529 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3530 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3531 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3532 | else |
| 3533 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3534 | |
| 3535 | for (ri = rn->info; ri; ri = ri->next) |
| 3536 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3537 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3538 | break; |
| 3539 | |
| 3540 | if (ri) |
| 3541 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3542 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3543 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3544 | { |
| 3545 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3546 | bgp_attr_unintern (&attr_new); |
| 3547 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3548 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3549 | return; |
| 3550 | } |
| 3551 | else |
| 3552 | { |
| 3553 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3554 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3555 | |
| 3556 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3557 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3558 | bgp_info_restore(rn, ri); |
| 3559 | else |
| 3560 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3561 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3562 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3563 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3564 | |
| 3565 | /* Process change. */ |
| 3566 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3567 | bgp_process (bgp, rn, afi, safi); |
| 3568 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3569 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3570 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3571 | return; |
| 3572 | } |
| 3573 | } |
| 3574 | |
| 3575 | /* Make new BGP info. */ |
| 3576 | new = bgp_info_new (); |
| 3577 | new->type = ZEBRA_ROUTE_BGP; |
| 3578 | new->sub_type = BGP_ROUTE_STATIC; |
| 3579 | new->peer = bgp->peer_self; |
| 3580 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3581 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3582 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3583 | |
| 3584 | /* Aggregate address increment. */ |
| 3585 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3586 | |
| 3587 | /* Register new BGP information. */ |
| 3588 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3589 | |
| 3590 | /* route_node_get lock */ |
| 3591 | bgp_unlock_node (rn); |
| 3592 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3593 | /* Process change. */ |
| 3594 | bgp_process (bgp, rn, afi, safi); |
| 3595 | |
| 3596 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3597 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3598 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3599 | } |
| 3600 | |
| 3601 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3602 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3603 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3604 | { |
| 3605 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3606 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3607 | |
| 3608 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3609 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3610 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3611 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3612 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3613 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3614 | } |
| 3615 | } |
| 3616 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3617 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3618 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3619 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3620 | { |
| 3621 | struct bgp_node *rn; |
| 3622 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3623 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3624 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3625 | |
| 3626 | /* Make new BGP info. */ |
| 3627 | new = bgp_info_new (); |
| 3628 | new->type = ZEBRA_ROUTE_BGP; |
| 3629 | new->sub_type = BGP_ROUTE_STATIC; |
| 3630 | new->peer = bgp->peer_self; |
| 3631 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3632 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3633 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3634 | new->extra = bgp_info_extra_new(); |
| 3635 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3636 | |
| 3637 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3638 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3639 | |
| 3640 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3641 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3642 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3643 | /* route_node_get lock */ |
| 3644 | bgp_unlock_node (rn); |
| 3645 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3646 | /* Process change. */ |
| 3647 | bgp_process (bgp, rn, afi, safi); |
| 3648 | } |
| 3649 | |
| 3650 | void |
| 3651 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3652 | safi_t safi) |
| 3653 | { |
| 3654 | struct bgp_node *rn; |
| 3655 | struct bgp_info *ri; |
| 3656 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3657 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3658 | |
| 3659 | /* Check selected route and self inserted route. */ |
| 3660 | for (ri = rn->info; ri; ri = ri->next) |
| 3661 | if (ri->peer == bgp->peer_self |
| 3662 | && ri->type == ZEBRA_ROUTE_BGP |
| 3663 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3664 | break; |
| 3665 | |
| 3666 | /* Withdraw static BGP route from routing table. */ |
| 3667 | if (ri) |
| 3668 | { |
| 3669 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3670 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3671 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3672 | } |
| 3673 | |
| 3674 | /* Unlock bgp_node_lookup. */ |
| 3675 | bgp_unlock_node (rn); |
| 3676 | } |
| 3677 | |
| 3678 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3679 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3680 | { |
| 3681 | struct bgp_static *bgp_static; |
| 3682 | struct bgp *bgp; |
| 3683 | struct bgp_node *rn; |
| 3684 | struct prefix *p; |
| 3685 | |
| 3686 | bgp = rsclient->bgp; |
| 3687 | |
| 3688 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3689 | if ((bgp_static = rn->info) != NULL) |
| 3690 | { |
| 3691 | p = &rn->p; |
| 3692 | |
| 3693 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3694 | afi, safi); |
| 3695 | } |
| 3696 | } |
| 3697 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3698 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3699 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3700 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3701 | { |
| 3702 | struct bgp_node *rn; |
| 3703 | struct bgp_info *ri; |
| 3704 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3705 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3706 | |
| 3707 | /* Check selected route and self inserted route. */ |
| 3708 | for (ri = rn->info; ri; ri = ri->next) |
| 3709 | if (ri->peer == bgp->peer_self |
| 3710 | && ri->type == ZEBRA_ROUTE_BGP |
| 3711 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3712 | break; |
| 3713 | |
| 3714 | /* Withdraw static BGP route from routing table. */ |
| 3715 | if (ri) |
| 3716 | { |
| 3717 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3718 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3719 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3720 | } |
| 3721 | |
| 3722 | /* Unlock bgp_node_lookup. */ |
| 3723 | bgp_unlock_node (rn); |
| 3724 | } |
| 3725 | |
| 3726 | /* Configure static BGP network. When user don't run zebra, static |
| 3727 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3728 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3729 | 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] | 3730 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3731 | { |
| 3732 | int ret; |
| 3733 | struct prefix p; |
| 3734 | struct bgp_static *bgp_static; |
| 3735 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3736 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3737 | |
| 3738 | /* Convert IP prefix string to struct prefix. */ |
| 3739 | ret = str2prefix (ip_str, &p); |
| 3740 | if (! ret) |
| 3741 | { |
| 3742 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3743 | return CMD_WARNING; |
| 3744 | } |
| 3745 | #ifdef HAVE_IPV6 |
| 3746 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3747 | { |
| 3748 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3749 | VTY_NEWLINE); |
| 3750 | return CMD_WARNING; |
| 3751 | } |
| 3752 | #endif /* HAVE_IPV6 */ |
| 3753 | |
| 3754 | apply_mask (&p); |
| 3755 | |
| 3756 | /* Set BGP static route configuration. */ |
| 3757 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3758 | |
| 3759 | if (rn->info) |
| 3760 | { |
| 3761 | /* Configuration change. */ |
| 3762 | bgp_static = rn->info; |
| 3763 | |
| 3764 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3765 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3766 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3767 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3768 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3769 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3770 | if (rmap) |
| 3771 | { |
| 3772 | if (bgp_static->rmap.name) |
| 3773 | free (bgp_static->rmap.name); |
| 3774 | bgp_static->rmap.name = strdup (rmap); |
| 3775 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3776 | } |
| 3777 | else |
| 3778 | { |
| 3779 | if (bgp_static->rmap.name) |
| 3780 | free (bgp_static->rmap.name); |
| 3781 | bgp_static->rmap.name = NULL; |
| 3782 | bgp_static->rmap.map = NULL; |
| 3783 | bgp_static->valid = 0; |
| 3784 | } |
| 3785 | bgp_unlock_node (rn); |
| 3786 | } |
| 3787 | else |
| 3788 | { |
| 3789 | /* New configuration. */ |
| 3790 | bgp_static = bgp_static_new (); |
| 3791 | bgp_static->backdoor = backdoor; |
| 3792 | bgp_static->valid = 0; |
| 3793 | bgp_static->igpmetric = 0; |
| 3794 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3795 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3796 | if (rmap) |
| 3797 | { |
| 3798 | if (bgp_static->rmap.name) |
| 3799 | free (bgp_static->rmap.name); |
| 3800 | bgp_static->rmap.name = strdup (rmap); |
| 3801 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3802 | } |
| 3803 | rn->info = bgp_static; |
| 3804 | } |
| 3805 | |
| 3806 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3807 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3808 | { |
| 3809 | bgp_static->valid = 1; |
| 3810 | |
| 3811 | if (need_update) |
| 3812 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3813 | |
| 3814 | if (! bgp_static->backdoor) |
| 3815 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3816 | } |
| 3817 | |
| 3818 | return CMD_SUCCESS; |
| 3819 | } |
| 3820 | |
| 3821 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3822 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3823 | 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] | 3824 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3825 | { |
| 3826 | int ret; |
| 3827 | struct prefix p; |
| 3828 | struct bgp_static *bgp_static; |
| 3829 | struct bgp_node *rn; |
| 3830 | |
| 3831 | /* Convert IP prefix string to struct prefix. */ |
| 3832 | ret = str2prefix (ip_str, &p); |
| 3833 | if (! ret) |
| 3834 | { |
| 3835 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3836 | return CMD_WARNING; |
| 3837 | } |
| 3838 | #ifdef HAVE_IPV6 |
| 3839 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3840 | { |
| 3841 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3842 | VTY_NEWLINE); |
| 3843 | return CMD_WARNING; |
| 3844 | } |
| 3845 | #endif /* HAVE_IPV6 */ |
| 3846 | |
| 3847 | apply_mask (&p); |
| 3848 | |
| 3849 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3850 | if (! rn) |
| 3851 | { |
| 3852 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3853 | VTY_NEWLINE); |
| 3854 | return CMD_WARNING; |
| 3855 | } |
| 3856 | |
| 3857 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3858 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3859 | /* Update BGP RIB. */ |
| 3860 | if (! bgp_static->backdoor) |
| 3861 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3862 | |
| 3863 | /* Clear configuration. */ |
| 3864 | bgp_static_free (bgp_static); |
| 3865 | rn->info = NULL; |
| 3866 | bgp_unlock_node (rn); |
| 3867 | bgp_unlock_node (rn); |
| 3868 | |
| 3869 | return CMD_SUCCESS; |
| 3870 | } |
| 3871 | |
| 3872 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3873 | instance. */ |
| 3874 | void |
| 3875 | bgp_static_delete (struct bgp *bgp) |
| 3876 | { |
| 3877 | afi_t afi; |
| 3878 | safi_t safi; |
| 3879 | struct bgp_node *rn; |
| 3880 | struct bgp_node *rm; |
| 3881 | struct bgp_table *table; |
| 3882 | struct bgp_static *bgp_static; |
| 3883 | |
| 3884 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3885 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3886 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3887 | if (rn->info != NULL) |
| 3888 | { |
| 3889 | if (safi == SAFI_MPLS_VPN) |
| 3890 | { |
| 3891 | table = rn->info; |
| 3892 | |
| 3893 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3894 | { |
| 3895 | bgp_static = rn->info; |
| 3896 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3897 | AFI_IP, SAFI_MPLS_VPN, |
| 3898 | (struct prefix_rd *)&rn->p, |
| 3899 | bgp_static->tag); |
| 3900 | bgp_static_free (bgp_static); |
| 3901 | rn->info = NULL; |
| 3902 | bgp_unlock_node (rn); |
| 3903 | } |
| 3904 | } |
| 3905 | else |
| 3906 | { |
| 3907 | bgp_static = rn->info; |
| 3908 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3909 | bgp_static_free (bgp_static); |
| 3910 | rn->info = NULL; |
| 3911 | bgp_unlock_node (rn); |
| 3912 | } |
| 3913 | } |
| 3914 | } |
| 3915 | |
| 3916 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3917 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3918 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3919 | { |
| 3920 | int ret; |
| 3921 | struct prefix p; |
| 3922 | struct prefix_rd prd; |
| 3923 | struct bgp *bgp; |
| 3924 | struct bgp_node *prn; |
| 3925 | struct bgp_node *rn; |
| 3926 | struct bgp_table *table; |
| 3927 | struct bgp_static *bgp_static; |
| 3928 | u_char tag[3]; |
| 3929 | |
| 3930 | bgp = vty->index; |
| 3931 | |
| 3932 | ret = str2prefix (ip_str, &p); |
| 3933 | if (! ret) |
| 3934 | { |
| 3935 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3936 | return CMD_WARNING; |
| 3937 | } |
| 3938 | apply_mask (&p); |
| 3939 | |
| 3940 | ret = str2prefix_rd (rd_str, &prd); |
| 3941 | if (! ret) |
| 3942 | { |
| 3943 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3944 | return CMD_WARNING; |
| 3945 | } |
| 3946 | |
| 3947 | ret = str2tag (tag_str, tag); |
| 3948 | if (! ret) |
| 3949 | { |
| 3950 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3951 | return CMD_WARNING; |
| 3952 | } |
| 3953 | |
| 3954 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3955 | (struct prefix *)&prd); |
| 3956 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3957 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3958 | else |
| 3959 | bgp_unlock_node (prn); |
| 3960 | table = prn->info; |
| 3961 | |
| 3962 | rn = bgp_node_get (table, &p); |
| 3963 | |
| 3964 | if (rn->info) |
| 3965 | { |
| 3966 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3967 | bgp_unlock_node (rn); |
| 3968 | } |
| 3969 | else |
| 3970 | { |
| 3971 | /* New configuration. */ |
| 3972 | bgp_static = bgp_static_new (); |
| 3973 | bgp_static->valid = 1; |
| 3974 | memcpy (bgp_static->tag, tag, 3); |
| 3975 | rn->info = bgp_static; |
| 3976 | |
| 3977 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3978 | } |
| 3979 | |
| 3980 | return CMD_SUCCESS; |
| 3981 | } |
| 3982 | |
| 3983 | /* Configure static BGP network. */ |
| 3984 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3985 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3986 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3987 | { |
| 3988 | int ret; |
| 3989 | struct bgp *bgp; |
| 3990 | struct prefix p; |
| 3991 | struct prefix_rd prd; |
| 3992 | struct bgp_node *prn; |
| 3993 | struct bgp_node *rn; |
| 3994 | struct bgp_table *table; |
| 3995 | struct bgp_static *bgp_static; |
| 3996 | u_char tag[3]; |
| 3997 | |
| 3998 | bgp = vty->index; |
| 3999 | |
| 4000 | /* Convert IP prefix string to struct prefix. */ |
| 4001 | ret = str2prefix (ip_str, &p); |
| 4002 | if (! ret) |
| 4003 | { |
| 4004 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4005 | return CMD_WARNING; |
| 4006 | } |
| 4007 | apply_mask (&p); |
| 4008 | |
| 4009 | ret = str2prefix_rd (rd_str, &prd); |
| 4010 | if (! ret) |
| 4011 | { |
| 4012 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4013 | return CMD_WARNING; |
| 4014 | } |
| 4015 | |
| 4016 | ret = str2tag (tag_str, tag); |
| 4017 | if (! ret) |
| 4018 | { |
| 4019 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4020 | return CMD_WARNING; |
| 4021 | } |
| 4022 | |
| 4023 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 4024 | (struct prefix *)&prd); |
| 4025 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 4026 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4027 | else |
| 4028 | bgp_unlock_node (prn); |
| 4029 | table = prn->info; |
| 4030 | |
| 4031 | rn = bgp_node_lookup (table, &p); |
| 4032 | |
| 4033 | if (rn) |
| 4034 | { |
| 4035 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 4036 | |
| 4037 | bgp_static = rn->info; |
| 4038 | bgp_static_free (bgp_static); |
| 4039 | rn->info = NULL; |
| 4040 | bgp_unlock_node (rn); |
| 4041 | bgp_unlock_node (rn); |
| 4042 | } |
| 4043 | else |
| 4044 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4045 | |
| 4046 | return CMD_SUCCESS; |
| 4047 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4048 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4049 | DEFUN (bgp_network, |
| 4050 | bgp_network_cmd, |
| 4051 | "network A.B.C.D/M", |
| 4052 | "Specify a network to announce via BGP\n" |
| 4053 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4054 | { |
| 4055 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4056 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4057 | } |
| 4058 | |
| 4059 | DEFUN (bgp_network_route_map, |
| 4060 | bgp_network_route_map_cmd, |
| 4061 | "network A.B.C.D/M route-map WORD", |
| 4062 | "Specify a network to announce via BGP\n" |
| 4063 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4064 | "Route-map to modify the attributes\n" |
| 4065 | "Name of the route map\n") |
| 4066 | { |
| 4067 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4068 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4069 | } |
| 4070 | |
| 4071 | DEFUN (bgp_network_backdoor, |
| 4072 | bgp_network_backdoor_cmd, |
| 4073 | "network A.B.C.D/M backdoor", |
| 4074 | "Specify a network to announce via BGP\n" |
| 4075 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4076 | "Specify a BGP backdoor route\n") |
| 4077 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4078 | 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] | 4079 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4080 | } |
| 4081 | |
| 4082 | DEFUN (bgp_network_mask, |
| 4083 | bgp_network_mask_cmd, |
| 4084 | "network A.B.C.D mask A.B.C.D", |
| 4085 | "Specify a network to announce via BGP\n" |
| 4086 | "Network number\n" |
| 4087 | "Network mask\n" |
| 4088 | "Network mask\n") |
| 4089 | { |
| 4090 | int ret; |
| 4091 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4092 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4093 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4094 | if (! ret) |
| 4095 | { |
| 4096 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4097 | return CMD_WARNING; |
| 4098 | } |
| 4099 | |
| 4100 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4101 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4102 | } |
| 4103 | |
| 4104 | DEFUN (bgp_network_mask_route_map, |
| 4105 | bgp_network_mask_route_map_cmd, |
| 4106 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4107 | "Specify a network to announce via BGP\n" |
| 4108 | "Network number\n" |
| 4109 | "Network mask\n" |
| 4110 | "Network mask\n" |
| 4111 | "Route-map to modify the attributes\n" |
| 4112 | "Name of the route map\n") |
| 4113 | { |
| 4114 | int ret; |
| 4115 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4116 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4117 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4118 | if (! ret) |
| 4119 | { |
| 4120 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4121 | return CMD_WARNING; |
| 4122 | } |
| 4123 | |
| 4124 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4125 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4126 | } |
| 4127 | |
| 4128 | DEFUN (bgp_network_mask_backdoor, |
| 4129 | bgp_network_mask_backdoor_cmd, |
| 4130 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4131 | "Specify a network to announce via BGP\n" |
| 4132 | "Network number\n" |
| 4133 | "Network mask\n" |
| 4134 | "Network mask\n" |
| 4135 | "Specify a BGP backdoor route\n") |
| 4136 | { |
| 4137 | int ret; |
| 4138 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4139 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4140 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4141 | if (! ret) |
| 4142 | { |
| 4143 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4144 | return CMD_WARNING; |
| 4145 | } |
| 4146 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4147 | 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] | 4148 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4149 | } |
| 4150 | |
| 4151 | DEFUN (bgp_network_mask_natural, |
| 4152 | bgp_network_mask_natural_cmd, |
| 4153 | "network A.B.C.D", |
| 4154 | "Specify a network to announce via BGP\n" |
| 4155 | "Network number\n") |
| 4156 | { |
| 4157 | int ret; |
| 4158 | char prefix_str[BUFSIZ]; |
| 4159 | |
| 4160 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4161 | if (! ret) |
| 4162 | { |
| 4163 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4164 | return CMD_WARNING; |
| 4165 | } |
| 4166 | |
| 4167 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4168 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4169 | } |
| 4170 | |
| 4171 | DEFUN (bgp_network_mask_natural_route_map, |
| 4172 | bgp_network_mask_natural_route_map_cmd, |
| 4173 | "network A.B.C.D route-map WORD", |
| 4174 | "Specify a network to announce via BGP\n" |
| 4175 | "Network number\n" |
| 4176 | "Route-map to modify the attributes\n" |
| 4177 | "Name of the route map\n") |
| 4178 | { |
| 4179 | int ret; |
| 4180 | char prefix_str[BUFSIZ]; |
| 4181 | |
| 4182 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4183 | if (! ret) |
| 4184 | { |
| 4185 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4186 | return CMD_WARNING; |
| 4187 | } |
| 4188 | |
| 4189 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4190 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4191 | } |
| 4192 | |
| 4193 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4194 | bgp_network_mask_natural_backdoor_cmd, |
| 4195 | "network A.B.C.D backdoor", |
| 4196 | "Specify a network to announce via BGP\n" |
| 4197 | "Network number\n" |
| 4198 | "Specify a BGP backdoor route\n") |
| 4199 | { |
| 4200 | int ret; |
| 4201 | char prefix_str[BUFSIZ]; |
| 4202 | |
| 4203 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4204 | if (! ret) |
| 4205 | { |
| 4206 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4207 | return CMD_WARNING; |
| 4208 | } |
| 4209 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4210 | 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] | 4211 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4212 | } |
| 4213 | |
| 4214 | DEFUN (no_bgp_network, |
| 4215 | no_bgp_network_cmd, |
| 4216 | "no network A.B.C.D/M", |
| 4217 | NO_STR |
| 4218 | "Specify a network to announce via BGP\n" |
| 4219 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4220 | { |
| 4221 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4222 | bgp_node_safi (vty)); |
| 4223 | } |
| 4224 | |
| 4225 | ALIAS (no_bgp_network, |
| 4226 | no_bgp_network_route_map_cmd, |
| 4227 | "no network A.B.C.D/M route-map WORD", |
| 4228 | NO_STR |
| 4229 | "Specify a network to announce via BGP\n" |
| 4230 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4231 | "Route-map to modify the attributes\n" |
| 4232 | "Name of the route map\n") |
| 4233 | |
| 4234 | ALIAS (no_bgp_network, |
| 4235 | no_bgp_network_backdoor_cmd, |
| 4236 | "no network A.B.C.D/M backdoor", |
| 4237 | NO_STR |
| 4238 | "Specify a network to announce via BGP\n" |
| 4239 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4240 | "Specify a BGP backdoor route\n") |
| 4241 | |
| 4242 | DEFUN (no_bgp_network_mask, |
| 4243 | no_bgp_network_mask_cmd, |
| 4244 | "no network A.B.C.D mask A.B.C.D", |
| 4245 | NO_STR |
| 4246 | "Specify a network to announce via BGP\n" |
| 4247 | "Network number\n" |
| 4248 | "Network mask\n" |
| 4249 | "Network mask\n") |
| 4250 | { |
| 4251 | int ret; |
| 4252 | char prefix_str[BUFSIZ]; |
| 4253 | |
| 4254 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4255 | if (! ret) |
| 4256 | { |
| 4257 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4258 | return CMD_WARNING; |
| 4259 | } |
| 4260 | |
| 4261 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4262 | bgp_node_safi (vty)); |
| 4263 | } |
| 4264 | |
| 4265 | ALIAS (no_bgp_network_mask, |
| 4266 | no_bgp_network_mask_route_map_cmd, |
| 4267 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4268 | NO_STR |
| 4269 | "Specify a network to announce via BGP\n" |
| 4270 | "Network number\n" |
| 4271 | "Network mask\n" |
| 4272 | "Network mask\n" |
| 4273 | "Route-map to modify the attributes\n" |
| 4274 | "Name of the route map\n") |
| 4275 | |
| 4276 | ALIAS (no_bgp_network_mask, |
| 4277 | no_bgp_network_mask_backdoor_cmd, |
| 4278 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4279 | NO_STR |
| 4280 | "Specify a network to announce via BGP\n" |
| 4281 | "Network number\n" |
| 4282 | "Network mask\n" |
| 4283 | "Network mask\n" |
| 4284 | "Specify a BGP backdoor route\n") |
| 4285 | |
| 4286 | DEFUN (no_bgp_network_mask_natural, |
| 4287 | no_bgp_network_mask_natural_cmd, |
| 4288 | "no network A.B.C.D", |
| 4289 | NO_STR |
| 4290 | "Specify a network to announce via BGP\n" |
| 4291 | "Network number\n") |
| 4292 | { |
| 4293 | int ret; |
| 4294 | char prefix_str[BUFSIZ]; |
| 4295 | |
| 4296 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4297 | if (! ret) |
| 4298 | { |
| 4299 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4300 | return CMD_WARNING; |
| 4301 | } |
| 4302 | |
| 4303 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4304 | bgp_node_safi (vty)); |
| 4305 | } |
| 4306 | |
| 4307 | ALIAS (no_bgp_network_mask_natural, |
| 4308 | no_bgp_network_mask_natural_route_map_cmd, |
| 4309 | "no network A.B.C.D route-map WORD", |
| 4310 | NO_STR |
| 4311 | "Specify a network to announce via BGP\n" |
| 4312 | "Network number\n" |
| 4313 | "Route-map to modify the attributes\n" |
| 4314 | "Name of the route map\n") |
| 4315 | |
| 4316 | ALIAS (no_bgp_network_mask_natural, |
| 4317 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4318 | "no network A.B.C.D backdoor", |
| 4319 | NO_STR |
| 4320 | "Specify a network to announce via BGP\n" |
| 4321 | "Network number\n" |
| 4322 | "Specify a BGP backdoor route\n") |
| 4323 | |
| 4324 | #ifdef HAVE_IPV6 |
| 4325 | DEFUN (ipv6_bgp_network, |
| 4326 | ipv6_bgp_network_cmd, |
| 4327 | "network X:X::X:X/M", |
| 4328 | "Specify a network to announce via BGP\n" |
| 4329 | "IPv6 prefix <network>/<length>\n") |
| 4330 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4331 | 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] | 4332 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4333 | } |
| 4334 | |
| 4335 | DEFUN (ipv6_bgp_network_route_map, |
| 4336 | ipv6_bgp_network_route_map_cmd, |
| 4337 | "network X:X::X:X/M route-map WORD", |
| 4338 | "Specify a network to announce via BGP\n" |
| 4339 | "IPv6 prefix <network>/<length>\n" |
| 4340 | "Route-map to modify the attributes\n" |
| 4341 | "Name of the route map\n") |
| 4342 | { |
| 4343 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4344 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4345 | } |
| 4346 | |
| 4347 | DEFUN (no_ipv6_bgp_network, |
| 4348 | no_ipv6_bgp_network_cmd, |
| 4349 | "no network X:X::X:X/M", |
| 4350 | NO_STR |
| 4351 | "Specify a network to announce via BGP\n" |
| 4352 | "IPv6 prefix <network>/<length>\n") |
| 4353 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4354 | 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] | 4355 | } |
| 4356 | |
| 4357 | ALIAS (no_ipv6_bgp_network, |
| 4358 | no_ipv6_bgp_network_route_map_cmd, |
| 4359 | "no network X:X::X:X/M route-map WORD", |
| 4360 | NO_STR |
| 4361 | "Specify a network to announce via BGP\n" |
| 4362 | "IPv6 prefix <network>/<length>\n" |
| 4363 | "Route-map to modify the attributes\n" |
| 4364 | "Name of the route map\n") |
| 4365 | |
| 4366 | ALIAS (ipv6_bgp_network, |
| 4367 | old_ipv6_bgp_network_cmd, |
| 4368 | "ipv6 bgp network X:X::X:X/M", |
| 4369 | IPV6_STR |
| 4370 | BGP_STR |
| 4371 | "Specify a network to announce via BGP\n" |
| 4372 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4373 | |
| 4374 | ALIAS (no_ipv6_bgp_network, |
| 4375 | old_no_ipv6_bgp_network_cmd, |
| 4376 | "no ipv6 bgp network X:X::X:X/M", |
| 4377 | NO_STR |
| 4378 | IPV6_STR |
| 4379 | BGP_STR |
| 4380 | "Specify a network to announce via BGP\n" |
| 4381 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4382 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4383 | |
| 4384 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4385 | ALIAS_DEPRECATED (bgp_network, |
| 4386 | bgp_network_ttl_cmd, |
| 4387 | "network A.B.C.D/M pathlimit <0-255>", |
| 4388 | "Specify a network to announce via BGP\n" |
| 4389 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4390 | "AS-Path hopcount limit attribute\n" |
| 4391 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4392 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4393 | bgp_network_backdoor_ttl_cmd, |
| 4394 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4395 | "Specify a network to announce via BGP\n" |
| 4396 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4397 | "Specify a BGP backdoor route\n" |
| 4398 | "AS-Path hopcount limit attribute\n" |
| 4399 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4400 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4401 | bgp_network_mask_ttl_cmd, |
| 4402 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4403 | "Specify a network to announce via BGP\n" |
| 4404 | "Network number\n" |
| 4405 | "Network mask\n" |
| 4406 | "Network mask\n" |
| 4407 | "AS-Path hopcount limit attribute\n" |
| 4408 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4409 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4410 | bgp_network_mask_backdoor_ttl_cmd, |
| 4411 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4412 | "Specify a network to announce via BGP\n" |
| 4413 | "Network number\n" |
| 4414 | "Network mask\n" |
| 4415 | "Network mask\n" |
| 4416 | "Specify a BGP backdoor route\n" |
| 4417 | "AS-Path hopcount limit attribute\n" |
| 4418 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4419 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4420 | bgp_network_mask_natural_ttl_cmd, |
| 4421 | "network A.B.C.D pathlimit <0-255>", |
| 4422 | "Specify a network to announce via BGP\n" |
| 4423 | "Network number\n" |
| 4424 | "AS-Path hopcount limit attribute\n" |
| 4425 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4426 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4427 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4428 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4429 | "Specify a network to announce via BGP\n" |
| 4430 | "Network number\n" |
| 4431 | "Specify a BGP backdoor route\n" |
| 4432 | "AS-Path hopcount limit attribute\n" |
| 4433 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4434 | ALIAS_DEPRECATED (no_bgp_network, |
| 4435 | no_bgp_network_ttl_cmd, |
| 4436 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4437 | NO_STR |
| 4438 | "Specify a network to announce via BGP\n" |
| 4439 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4440 | "AS-Path hopcount limit attribute\n" |
| 4441 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4442 | ALIAS_DEPRECATED (no_bgp_network, |
| 4443 | no_bgp_network_backdoor_ttl_cmd, |
| 4444 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4445 | NO_STR |
| 4446 | "Specify a network to announce via BGP\n" |
| 4447 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4448 | "Specify a BGP backdoor route\n" |
| 4449 | "AS-Path hopcount limit attribute\n" |
| 4450 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4451 | ALIAS_DEPRECATED (no_bgp_network, |
| 4452 | no_bgp_network_mask_ttl_cmd, |
| 4453 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4454 | NO_STR |
| 4455 | "Specify a network to announce via BGP\n" |
| 4456 | "Network number\n" |
| 4457 | "Network mask\n" |
| 4458 | "Network mask\n" |
| 4459 | "AS-Path hopcount limit attribute\n" |
| 4460 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4461 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4462 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4463 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 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 | "Specify a BGP backdoor route\n" |
| 4470 | "AS-Path hopcount limit attribute\n" |
| 4471 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4472 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4473 | no_bgp_network_mask_natural_ttl_cmd, |
| 4474 | "no network A.B.C.D pathlimit <0-255>", |
| 4475 | NO_STR |
| 4476 | "Specify a network to announce via BGP\n" |
| 4477 | "Network number\n" |
| 4478 | "AS-Path hopcount limit attribute\n" |
| 4479 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4480 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4481 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4482 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4483 | NO_STR |
| 4484 | "Specify a network to announce via BGP\n" |
| 4485 | "Network number\n" |
| 4486 | "Specify a BGP backdoor route\n" |
| 4487 | "AS-Path hopcount limit attribute\n" |
| 4488 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4489 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4490 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4491 | ipv6_bgp_network_ttl_cmd, |
| 4492 | "network X:X::X:X/M pathlimit <0-255>", |
| 4493 | "Specify a network to announce via BGP\n" |
| 4494 | "IPv6 prefix <network>/<length>\n" |
| 4495 | "AS-Path hopcount limit attribute\n" |
| 4496 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4497 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4498 | no_ipv6_bgp_network_ttl_cmd, |
| 4499 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4500 | NO_STR |
| 4501 | "Specify a network to announce via BGP\n" |
| 4502 | "IPv6 prefix <network>/<length>\n" |
| 4503 | "AS-Path hopcount limit attribute\n" |
| 4504 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4505 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4506 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4507 | /* Aggreagete address: |
| 4508 | |
| 4509 | advertise-map Set condition to advertise attribute |
| 4510 | as-set Generate AS set path information |
| 4511 | attribute-map Set attributes of aggregate |
| 4512 | route-map Set parameters of aggregate |
| 4513 | summary-only Filter more specific routes from updates |
| 4514 | suppress-map Conditionally filter more specific routes from updates |
| 4515 | <cr> |
| 4516 | */ |
| 4517 | struct bgp_aggregate |
| 4518 | { |
| 4519 | /* Summary-only flag. */ |
| 4520 | u_char summary_only; |
| 4521 | |
| 4522 | /* AS set generation. */ |
| 4523 | u_char as_set; |
| 4524 | |
| 4525 | /* Route-map for aggregated route. */ |
| 4526 | struct route_map *map; |
| 4527 | |
| 4528 | /* Suppress-count. */ |
| 4529 | unsigned long count; |
| 4530 | |
| 4531 | /* SAFI configuration. */ |
| 4532 | safi_t safi; |
| 4533 | }; |
| 4534 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4535 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4536 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4537 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4538 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4539 | } |
| 4540 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4541 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4542 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4543 | { |
| 4544 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4545 | } |
| 4546 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4547 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4548 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4549 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4550 | struct bgp_aggregate *aggregate) |
| 4551 | { |
| 4552 | struct bgp_table *table; |
| 4553 | struct bgp_node *top; |
| 4554 | struct bgp_node *rn; |
| 4555 | u_char origin; |
| 4556 | struct aspath *aspath = NULL; |
| 4557 | struct aspath *asmerge = NULL; |
| 4558 | struct community *community = NULL; |
| 4559 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4560 | struct bgp_info *ri; |
| 4561 | struct bgp_info *new; |
| 4562 | int first = 1; |
| 4563 | unsigned long match = 0; |
| 4564 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4565 | /* ORIGIN attribute: If at least one route among routes that are |
| 4566 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4567 | aggregated route must have the ORIGIN attribute with the value |
| 4568 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4569 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4570 | route must have the origin attribute with the value EGP. In all |
| 4571 | other case the value of the ORIGIN attribute of the aggregated |
| 4572 | route is INTERNAL. */ |
| 4573 | origin = BGP_ORIGIN_IGP; |
| 4574 | |
| 4575 | table = bgp->rib[afi][safi]; |
| 4576 | |
| 4577 | top = bgp_node_get (table, p); |
| 4578 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4579 | if (rn->p.prefixlen > p->prefixlen) |
| 4580 | { |
| 4581 | match = 0; |
| 4582 | |
| 4583 | for (ri = rn->info; ri; ri = ri->next) |
| 4584 | { |
| 4585 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4586 | continue; |
| 4587 | |
| 4588 | if (del && ri == del) |
| 4589 | continue; |
| 4590 | |
| 4591 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4592 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4593 | |
| 4594 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4595 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4596 | || ri->attr->med != med) |
| 4597 | { |
| 4598 | if (aspath) |
| 4599 | aspath_free (aspath); |
| 4600 | if (community) |
| 4601 | community_free (community); |
| 4602 | bgp_unlock_node (rn); |
| 4603 | bgp_unlock_node (top); |
| 4604 | return; |
| 4605 | } |
| 4606 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4607 | |
| 4608 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4609 | { |
| 4610 | if (aggregate->summary_only) |
| 4611 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4612 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4613 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4614 | match++; |
| 4615 | } |
| 4616 | |
| 4617 | aggregate->count++; |
| 4618 | |
| 4619 | if (aggregate->as_set) |
| 4620 | { |
| 4621 | if (origin < ri->attr->origin) |
| 4622 | origin = ri->attr->origin; |
| 4623 | |
| 4624 | if (aspath) |
| 4625 | { |
| 4626 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4627 | aspath_free (aspath); |
| 4628 | aspath = asmerge; |
| 4629 | } |
| 4630 | else |
| 4631 | aspath = aspath_dup (ri->attr->aspath); |
| 4632 | |
| 4633 | if (ri->attr->community) |
| 4634 | { |
| 4635 | if (community) |
| 4636 | { |
| 4637 | commerge = community_merge (community, |
| 4638 | ri->attr->community); |
| 4639 | community = community_uniq_sort (commerge); |
| 4640 | community_free (commerge); |
| 4641 | } |
| 4642 | else |
| 4643 | community = community_dup (ri->attr->community); |
| 4644 | } |
| 4645 | } |
| 4646 | } |
| 4647 | } |
| 4648 | if (match) |
| 4649 | bgp_process (bgp, rn, afi, safi); |
| 4650 | } |
| 4651 | bgp_unlock_node (top); |
| 4652 | |
| 4653 | if (rinew) |
| 4654 | { |
| 4655 | aggregate->count++; |
| 4656 | |
| 4657 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4658 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4659 | |
| 4660 | if (aggregate->as_set) |
| 4661 | { |
| 4662 | if (origin < rinew->attr->origin) |
| 4663 | origin = rinew->attr->origin; |
| 4664 | |
| 4665 | if (aspath) |
| 4666 | { |
| 4667 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4668 | aspath_free (aspath); |
| 4669 | aspath = asmerge; |
| 4670 | } |
| 4671 | else |
| 4672 | aspath = aspath_dup (rinew->attr->aspath); |
| 4673 | |
| 4674 | if (rinew->attr->community) |
| 4675 | { |
| 4676 | if (community) |
| 4677 | { |
| 4678 | commerge = community_merge (community, |
| 4679 | rinew->attr->community); |
| 4680 | community = community_uniq_sort (commerge); |
| 4681 | community_free (commerge); |
| 4682 | } |
| 4683 | else |
| 4684 | community = community_dup (rinew->attr->community); |
| 4685 | } |
| 4686 | } |
| 4687 | } |
| 4688 | |
| 4689 | if (aggregate->count > 0) |
| 4690 | { |
| 4691 | rn = bgp_node_get (table, p); |
| 4692 | new = bgp_info_new (); |
| 4693 | new->type = ZEBRA_ROUTE_BGP; |
| 4694 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4695 | new->peer = bgp->peer_self; |
| 4696 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4697 | 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] | 4698 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4699 | |
| 4700 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4701 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4702 | bgp_process (bgp, rn, afi, safi); |
| 4703 | } |
| 4704 | else |
| 4705 | { |
| 4706 | if (aspath) |
| 4707 | aspath_free (aspath); |
| 4708 | if (community) |
| 4709 | community_free (community); |
| 4710 | } |
| 4711 | } |
| 4712 | |
| 4713 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4714 | struct bgp_aggregate *); |
| 4715 | |
| 4716 | void |
| 4717 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4718 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4719 | { |
| 4720 | struct bgp_node *child; |
| 4721 | struct bgp_node *rn; |
| 4722 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4723 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4724 | |
| 4725 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4726 | if (safi == SAFI_MPLS_VPN) |
| 4727 | return; |
| 4728 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4729 | table = bgp->aggregate[afi][safi]; |
| 4730 | |
| 4731 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4732 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4733 | return; |
| 4734 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4735 | if (p->prefixlen == 0) |
| 4736 | return; |
| 4737 | |
| 4738 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4739 | return; |
| 4740 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4741 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4742 | |
| 4743 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4744 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4745 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4746 | { |
| 4747 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4748 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4749 | } |
| 4750 | bgp_unlock_node (child); |
| 4751 | } |
| 4752 | |
| 4753 | void |
| 4754 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4755 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4756 | { |
| 4757 | struct bgp_node *child; |
| 4758 | struct bgp_node *rn; |
| 4759 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4760 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4761 | |
| 4762 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4763 | if (safi == SAFI_MPLS_VPN) |
| 4764 | return; |
| 4765 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4766 | table = bgp->aggregate[afi][safi]; |
| 4767 | |
| 4768 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4769 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4770 | return; |
| 4771 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4772 | if (p->prefixlen == 0) |
| 4773 | return; |
| 4774 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4775 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4776 | |
| 4777 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4778 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4779 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4780 | { |
| 4781 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4782 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4783 | } |
| 4784 | bgp_unlock_node (child); |
| 4785 | } |
| 4786 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4787 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4788 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4789 | struct bgp_aggregate *aggregate) |
| 4790 | { |
| 4791 | struct bgp_table *table; |
| 4792 | struct bgp_node *top; |
| 4793 | struct bgp_node *rn; |
| 4794 | struct bgp_info *new; |
| 4795 | struct bgp_info *ri; |
| 4796 | unsigned long match; |
| 4797 | u_char origin = BGP_ORIGIN_IGP; |
| 4798 | struct aspath *aspath = NULL; |
| 4799 | struct aspath *asmerge = NULL; |
| 4800 | struct community *community = NULL; |
| 4801 | struct community *commerge = NULL; |
| 4802 | |
| 4803 | table = bgp->rib[afi][safi]; |
| 4804 | |
| 4805 | /* Sanity check. */ |
| 4806 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4807 | return; |
| 4808 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4809 | return; |
| 4810 | |
| 4811 | /* If routes exists below this node, generate aggregate routes. */ |
| 4812 | top = bgp_node_get (table, p); |
| 4813 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4814 | if (rn->p.prefixlen > p->prefixlen) |
| 4815 | { |
| 4816 | match = 0; |
| 4817 | |
| 4818 | for (ri = rn->info; ri; ri = ri->next) |
| 4819 | { |
| 4820 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4821 | continue; |
| 4822 | |
| 4823 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4824 | { |
| 4825 | /* summary-only aggregate route suppress aggregated |
| 4826 | route announcement. */ |
| 4827 | if (aggregate->summary_only) |
| 4828 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4829 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4830 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4831 | match++; |
| 4832 | } |
| 4833 | /* as-set aggregate route generate origin, as path, |
| 4834 | community aggregation. */ |
| 4835 | if (aggregate->as_set) |
| 4836 | { |
| 4837 | if (origin < ri->attr->origin) |
| 4838 | origin = ri->attr->origin; |
| 4839 | |
| 4840 | if (aspath) |
| 4841 | { |
| 4842 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4843 | aspath_free (aspath); |
| 4844 | aspath = asmerge; |
| 4845 | } |
| 4846 | else |
| 4847 | aspath = aspath_dup (ri->attr->aspath); |
| 4848 | |
| 4849 | if (ri->attr->community) |
| 4850 | { |
| 4851 | if (community) |
| 4852 | { |
| 4853 | commerge = community_merge (community, |
| 4854 | ri->attr->community); |
| 4855 | community = community_uniq_sort (commerge); |
| 4856 | community_free (commerge); |
| 4857 | } |
| 4858 | else |
| 4859 | community = community_dup (ri->attr->community); |
| 4860 | } |
| 4861 | } |
| 4862 | aggregate->count++; |
| 4863 | } |
| 4864 | } |
| 4865 | |
| 4866 | /* If this node is suppressed, process the change. */ |
| 4867 | if (match) |
| 4868 | bgp_process (bgp, rn, afi, safi); |
| 4869 | } |
| 4870 | bgp_unlock_node (top); |
| 4871 | |
| 4872 | /* Add aggregate route to BGP table. */ |
| 4873 | if (aggregate->count) |
| 4874 | { |
| 4875 | rn = bgp_node_get (table, p); |
| 4876 | |
| 4877 | new = bgp_info_new (); |
| 4878 | new->type = ZEBRA_ROUTE_BGP; |
| 4879 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4880 | new->peer = bgp->peer_self; |
| 4881 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4882 | 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] | 4883 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4884 | |
| 4885 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4886 | bgp_unlock_node (rn); |
| 4887 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4888 | /* Process change. */ |
| 4889 | bgp_process (bgp, rn, afi, safi); |
| 4890 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 4891 | else |
| 4892 | { |
| 4893 | if (aspath) |
| 4894 | aspath_free (aspath); |
| 4895 | if (community) |
| 4896 | community_free (community); |
| 4897 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4898 | } |
| 4899 | |
| 4900 | void |
| 4901 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4902 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4903 | { |
| 4904 | struct bgp_table *table; |
| 4905 | struct bgp_node *top; |
| 4906 | struct bgp_node *rn; |
| 4907 | struct bgp_info *ri; |
| 4908 | unsigned long match; |
| 4909 | |
| 4910 | table = bgp->rib[afi][safi]; |
| 4911 | |
| 4912 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4913 | return; |
| 4914 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4915 | return; |
| 4916 | |
| 4917 | /* If routes exists below this node, generate aggregate routes. */ |
| 4918 | top = bgp_node_get (table, p); |
| 4919 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4920 | if (rn->p.prefixlen > p->prefixlen) |
| 4921 | { |
| 4922 | match = 0; |
| 4923 | |
| 4924 | for (ri = rn->info; ri; ri = ri->next) |
| 4925 | { |
| 4926 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4927 | continue; |
| 4928 | |
| 4929 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4930 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4931 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4932 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4933 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4934 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4935 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4936 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4937 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4938 | match++; |
| 4939 | } |
| 4940 | } |
| 4941 | aggregate->count--; |
| 4942 | } |
| 4943 | } |
| 4944 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4945 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4946 | if (match) |
| 4947 | bgp_process (bgp, rn, afi, safi); |
| 4948 | } |
| 4949 | bgp_unlock_node (top); |
| 4950 | |
| 4951 | /* Delete aggregate route from BGP table. */ |
| 4952 | rn = bgp_node_get (table, p); |
| 4953 | |
| 4954 | for (ri = rn->info; ri; ri = ri->next) |
| 4955 | if (ri->peer == bgp->peer_self |
| 4956 | && ri->type == ZEBRA_ROUTE_BGP |
| 4957 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4958 | break; |
| 4959 | |
| 4960 | /* Withdraw static BGP route from routing table. */ |
| 4961 | if (ri) |
| 4962 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4963 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4964 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4965 | } |
| 4966 | |
| 4967 | /* Unlock bgp_node_lookup. */ |
| 4968 | bgp_unlock_node (rn); |
| 4969 | } |
| 4970 | |
| 4971 | /* Aggregate route attribute. */ |
| 4972 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4973 | #define AGGREGATE_AS_SET 1 |
| 4974 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4975 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4976 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4977 | afi_t afi, safi_t safi) |
| 4978 | { |
| 4979 | int ret; |
| 4980 | struct prefix p; |
| 4981 | struct bgp_node *rn; |
| 4982 | struct bgp *bgp; |
| 4983 | struct bgp_aggregate *aggregate; |
| 4984 | |
| 4985 | /* Convert string to prefix structure. */ |
| 4986 | ret = str2prefix (prefix_str, &p); |
| 4987 | if (!ret) |
| 4988 | { |
| 4989 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4990 | return CMD_WARNING; |
| 4991 | } |
| 4992 | apply_mask (&p); |
| 4993 | |
| 4994 | /* Get BGP structure. */ |
| 4995 | bgp = vty->index; |
| 4996 | |
| 4997 | /* Old configuration check. */ |
| 4998 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4999 | if (! rn) |
| 5000 | { |
| 5001 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 5002 | VTY_NEWLINE); |
| 5003 | return CMD_WARNING; |
| 5004 | } |
| 5005 | |
| 5006 | aggregate = rn->info; |
| 5007 | if (aggregate->safi & SAFI_UNICAST) |
| 5008 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5009 | if (aggregate->safi & SAFI_MULTICAST) |
| 5010 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5011 | |
| 5012 | /* Unlock aggregate address configuration. */ |
| 5013 | rn->info = NULL; |
| 5014 | bgp_aggregate_free (aggregate); |
| 5015 | bgp_unlock_node (rn); |
| 5016 | bgp_unlock_node (rn); |
| 5017 | |
| 5018 | return CMD_SUCCESS; |
| 5019 | } |
| 5020 | |
| 5021 | static int |
| 5022 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5023 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5024 | u_char summary_only, u_char as_set) |
| 5025 | { |
| 5026 | int ret; |
| 5027 | struct prefix p; |
| 5028 | struct bgp_node *rn; |
| 5029 | struct bgp *bgp; |
| 5030 | struct bgp_aggregate *aggregate; |
| 5031 | |
| 5032 | /* Convert string to prefix structure. */ |
| 5033 | ret = str2prefix (prefix_str, &p); |
| 5034 | if (!ret) |
| 5035 | { |
| 5036 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5037 | return CMD_WARNING; |
| 5038 | } |
| 5039 | apply_mask (&p); |
| 5040 | |
| 5041 | /* Get BGP structure. */ |
| 5042 | bgp = vty->index; |
| 5043 | |
| 5044 | /* Old configuration check. */ |
| 5045 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5046 | |
| 5047 | if (rn->info) |
| 5048 | { |
| 5049 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5050 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5051 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5052 | if (ret) |
| 5053 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5054 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5055 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5056 | return CMD_WARNING; |
| 5057 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5058 | } |
| 5059 | |
| 5060 | /* Make aggregate address structure. */ |
| 5061 | aggregate = bgp_aggregate_new (); |
| 5062 | aggregate->summary_only = summary_only; |
| 5063 | aggregate->as_set = as_set; |
| 5064 | aggregate->safi = safi; |
| 5065 | rn->info = aggregate; |
| 5066 | |
| 5067 | /* Aggregate address insert into BGP routing table. */ |
| 5068 | if (safi & SAFI_UNICAST) |
| 5069 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5070 | if (safi & SAFI_MULTICAST) |
| 5071 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5072 | |
| 5073 | return CMD_SUCCESS; |
| 5074 | } |
| 5075 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5076 | DEFUN (aggregate_address, |
| 5077 | aggregate_address_cmd, |
| 5078 | "aggregate-address A.B.C.D/M", |
| 5079 | "Configure BGP aggregate entries\n" |
| 5080 | "Aggregate prefix\n") |
| 5081 | { |
| 5082 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5083 | } |
| 5084 | |
| 5085 | DEFUN (aggregate_address_mask, |
| 5086 | aggregate_address_mask_cmd, |
| 5087 | "aggregate-address A.B.C.D A.B.C.D", |
| 5088 | "Configure BGP aggregate entries\n" |
| 5089 | "Aggregate address\n" |
| 5090 | "Aggregate mask\n") |
| 5091 | { |
| 5092 | int ret; |
| 5093 | char prefix_str[BUFSIZ]; |
| 5094 | |
| 5095 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5096 | |
| 5097 | if (! ret) |
| 5098 | { |
| 5099 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5100 | return CMD_WARNING; |
| 5101 | } |
| 5102 | |
| 5103 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5104 | 0, 0); |
| 5105 | } |
| 5106 | |
| 5107 | DEFUN (aggregate_address_summary_only, |
| 5108 | aggregate_address_summary_only_cmd, |
| 5109 | "aggregate-address A.B.C.D/M summary-only", |
| 5110 | "Configure BGP aggregate entries\n" |
| 5111 | "Aggregate prefix\n" |
| 5112 | "Filter more specific routes from updates\n") |
| 5113 | { |
| 5114 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5115 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5116 | } |
| 5117 | |
| 5118 | DEFUN (aggregate_address_mask_summary_only, |
| 5119 | aggregate_address_mask_summary_only_cmd, |
| 5120 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5121 | "Configure BGP aggregate entries\n" |
| 5122 | "Aggregate address\n" |
| 5123 | "Aggregate mask\n" |
| 5124 | "Filter more specific routes from updates\n") |
| 5125 | { |
| 5126 | int ret; |
| 5127 | char prefix_str[BUFSIZ]; |
| 5128 | |
| 5129 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5130 | |
| 5131 | if (! ret) |
| 5132 | { |
| 5133 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5134 | return CMD_WARNING; |
| 5135 | } |
| 5136 | |
| 5137 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5138 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5139 | } |
| 5140 | |
| 5141 | DEFUN (aggregate_address_as_set, |
| 5142 | aggregate_address_as_set_cmd, |
| 5143 | "aggregate-address A.B.C.D/M as-set", |
| 5144 | "Configure BGP aggregate entries\n" |
| 5145 | "Aggregate prefix\n" |
| 5146 | "Generate AS set path information\n") |
| 5147 | { |
| 5148 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5149 | 0, AGGREGATE_AS_SET); |
| 5150 | } |
| 5151 | |
| 5152 | DEFUN (aggregate_address_mask_as_set, |
| 5153 | aggregate_address_mask_as_set_cmd, |
| 5154 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5155 | "Configure BGP aggregate entries\n" |
| 5156 | "Aggregate address\n" |
| 5157 | "Aggregate mask\n" |
| 5158 | "Generate AS set path information\n") |
| 5159 | { |
| 5160 | int ret; |
| 5161 | char prefix_str[BUFSIZ]; |
| 5162 | |
| 5163 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5164 | |
| 5165 | if (! ret) |
| 5166 | { |
| 5167 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5168 | return CMD_WARNING; |
| 5169 | } |
| 5170 | |
| 5171 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5172 | 0, AGGREGATE_AS_SET); |
| 5173 | } |
| 5174 | |
| 5175 | |
| 5176 | DEFUN (aggregate_address_as_set_summary, |
| 5177 | aggregate_address_as_set_summary_cmd, |
| 5178 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5179 | "Configure BGP aggregate entries\n" |
| 5180 | "Aggregate prefix\n" |
| 5181 | "Generate AS set path information\n" |
| 5182 | "Filter more specific routes from updates\n") |
| 5183 | { |
| 5184 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5185 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5186 | } |
| 5187 | |
| 5188 | ALIAS (aggregate_address_as_set_summary, |
| 5189 | aggregate_address_summary_as_set_cmd, |
| 5190 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5191 | "Configure BGP aggregate entries\n" |
| 5192 | "Aggregate prefix\n" |
| 5193 | "Filter more specific routes from updates\n" |
| 5194 | "Generate AS set path information\n") |
| 5195 | |
| 5196 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5197 | aggregate_address_mask_as_set_summary_cmd, |
| 5198 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5199 | "Configure BGP aggregate entries\n" |
| 5200 | "Aggregate address\n" |
| 5201 | "Aggregate mask\n" |
| 5202 | "Generate AS set path information\n" |
| 5203 | "Filter more specific routes from updates\n") |
| 5204 | { |
| 5205 | int ret; |
| 5206 | char prefix_str[BUFSIZ]; |
| 5207 | |
| 5208 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5209 | |
| 5210 | if (! ret) |
| 5211 | { |
| 5212 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5213 | return CMD_WARNING; |
| 5214 | } |
| 5215 | |
| 5216 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5217 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5218 | } |
| 5219 | |
| 5220 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5221 | aggregate_address_mask_summary_as_set_cmd, |
| 5222 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5223 | "Configure BGP aggregate entries\n" |
| 5224 | "Aggregate address\n" |
| 5225 | "Aggregate mask\n" |
| 5226 | "Filter more specific routes from updates\n" |
| 5227 | "Generate AS set path information\n") |
| 5228 | |
| 5229 | DEFUN (no_aggregate_address, |
| 5230 | no_aggregate_address_cmd, |
| 5231 | "no aggregate-address A.B.C.D/M", |
| 5232 | NO_STR |
| 5233 | "Configure BGP aggregate entries\n" |
| 5234 | "Aggregate prefix\n") |
| 5235 | { |
| 5236 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5237 | } |
| 5238 | |
| 5239 | ALIAS (no_aggregate_address, |
| 5240 | no_aggregate_address_summary_only_cmd, |
| 5241 | "no aggregate-address A.B.C.D/M summary-only", |
| 5242 | NO_STR |
| 5243 | "Configure BGP aggregate entries\n" |
| 5244 | "Aggregate prefix\n" |
| 5245 | "Filter more specific routes from updates\n") |
| 5246 | |
| 5247 | ALIAS (no_aggregate_address, |
| 5248 | no_aggregate_address_as_set_cmd, |
| 5249 | "no aggregate-address A.B.C.D/M as-set", |
| 5250 | NO_STR |
| 5251 | "Configure BGP aggregate entries\n" |
| 5252 | "Aggregate prefix\n" |
| 5253 | "Generate AS set path information\n") |
| 5254 | |
| 5255 | ALIAS (no_aggregate_address, |
| 5256 | no_aggregate_address_as_set_summary_cmd, |
| 5257 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5258 | NO_STR |
| 5259 | "Configure BGP aggregate entries\n" |
| 5260 | "Aggregate prefix\n" |
| 5261 | "Generate AS set path information\n" |
| 5262 | "Filter more specific routes from updates\n") |
| 5263 | |
| 5264 | ALIAS (no_aggregate_address, |
| 5265 | no_aggregate_address_summary_as_set_cmd, |
| 5266 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5267 | NO_STR |
| 5268 | "Configure BGP aggregate entries\n" |
| 5269 | "Aggregate prefix\n" |
| 5270 | "Filter more specific routes from updates\n" |
| 5271 | "Generate AS set path information\n") |
| 5272 | |
| 5273 | DEFUN (no_aggregate_address_mask, |
| 5274 | no_aggregate_address_mask_cmd, |
| 5275 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5276 | NO_STR |
| 5277 | "Configure BGP aggregate entries\n" |
| 5278 | "Aggregate address\n" |
| 5279 | "Aggregate mask\n") |
| 5280 | { |
| 5281 | int ret; |
| 5282 | char prefix_str[BUFSIZ]; |
| 5283 | |
| 5284 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5285 | |
| 5286 | if (! ret) |
| 5287 | { |
| 5288 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5289 | return CMD_WARNING; |
| 5290 | } |
| 5291 | |
| 5292 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5293 | } |
| 5294 | |
| 5295 | ALIAS (no_aggregate_address_mask, |
| 5296 | no_aggregate_address_mask_summary_only_cmd, |
| 5297 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5298 | NO_STR |
| 5299 | "Configure BGP aggregate entries\n" |
| 5300 | "Aggregate address\n" |
| 5301 | "Aggregate mask\n" |
| 5302 | "Filter more specific routes from updates\n") |
| 5303 | |
| 5304 | ALIAS (no_aggregate_address_mask, |
| 5305 | no_aggregate_address_mask_as_set_cmd, |
| 5306 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5307 | NO_STR |
| 5308 | "Configure BGP aggregate entries\n" |
| 5309 | "Aggregate address\n" |
| 5310 | "Aggregate mask\n" |
| 5311 | "Generate AS set path information\n") |
| 5312 | |
| 5313 | ALIAS (no_aggregate_address_mask, |
| 5314 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5315 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5316 | NO_STR |
| 5317 | "Configure BGP aggregate entries\n" |
| 5318 | "Aggregate address\n" |
| 5319 | "Aggregate mask\n" |
| 5320 | "Generate AS set path information\n" |
| 5321 | "Filter more specific routes from updates\n") |
| 5322 | |
| 5323 | ALIAS (no_aggregate_address_mask, |
| 5324 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5325 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5326 | NO_STR |
| 5327 | "Configure BGP aggregate entries\n" |
| 5328 | "Aggregate address\n" |
| 5329 | "Aggregate mask\n" |
| 5330 | "Filter more specific routes from updates\n" |
| 5331 | "Generate AS set path information\n") |
| 5332 | |
| 5333 | #ifdef HAVE_IPV6 |
| 5334 | DEFUN (ipv6_aggregate_address, |
| 5335 | ipv6_aggregate_address_cmd, |
| 5336 | "aggregate-address X:X::X:X/M", |
| 5337 | "Configure BGP aggregate entries\n" |
| 5338 | "Aggregate prefix\n") |
| 5339 | { |
| 5340 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5341 | } |
| 5342 | |
| 5343 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5344 | ipv6_aggregate_address_summary_only_cmd, |
| 5345 | "aggregate-address X:X::X:X/M summary-only", |
| 5346 | "Configure BGP aggregate entries\n" |
| 5347 | "Aggregate prefix\n" |
| 5348 | "Filter more specific routes from updates\n") |
| 5349 | { |
| 5350 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5351 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5352 | } |
| 5353 | |
| 5354 | DEFUN (no_ipv6_aggregate_address, |
| 5355 | no_ipv6_aggregate_address_cmd, |
| 5356 | "no aggregate-address X:X::X:X/M", |
| 5357 | NO_STR |
| 5358 | "Configure BGP aggregate entries\n" |
| 5359 | "Aggregate prefix\n") |
| 5360 | { |
| 5361 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5362 | } |
| 5363 | |
| 5364 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5365 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5366 | "no aggregate-address X:X::X:X/M summary-only", |
| 5367 | NO_STR |
| 5368 | "Configure BGP aggregate entries\n" |
| 5369 | "Aggregate prefix\n" |
| 5370 | "Filter more specific routes from updates\n") |
| 5371 | { |
| 5372 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5373 | } |
| 5374 | |
| 5375 | ALIAS (ipv6_aggregate_address, |
| 5376 | old_ipv6_aggregate_address_cmd, |
| 5377 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5378 | IPV6_STR |
| 5379 | BGP_STR |
| 5380 | "Configure BGP aggregate entries\n" |
| 5381 | "Aggregate prefix\n") |
| 5382 | |
| 5383 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5384 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5385 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5386 | IPV6_STR |
| 5387 | BGP_STR |
| 5388 | "Configure BGP aggregate entries\n" |
| 5389 | "Aggregate prefix\n" |
| 5390 | "Filter more specific routes from updates\n") |
| 5391 | |
| 5392 | ALIAS (no_ipv6_aggregate_address, |
| 5393 | old_no_ipv6_aggregate_address_cmd, |
| 5394 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5395 | NO_STR |
| 5396 | IPV6_STR |
| 5397 | BGP_STR |
| 5398 | "Configure BGP aggregate entries\n" |
| 5399 | "Aggregate prefix\n") |
| 5400 | |
| 5401 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5402 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5403 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5404 | NO_STR |
| 5405 | IPV6_STR |
| 5406 | BGP_STR |
| 5407 | "Configure BGP aggregate entries\n" |
| 5408 | "Aggregate prefix\n" |
| 5409 | "Filter more specific routes from updates\n") |
| 5410 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5411 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5412 | /* Redistribute route treatment. */ |
| 5413 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5414 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5415 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5416 | u_int32_t metric, u_char type) |
| 5417 | { |
| 5418 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5419 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5420 | struct bgp_info *new; |
| 5421 | struct bgp_info *bi; |
| 5422 | struct bgp_info info; |
| 5423 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5424 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5425 | struct attr *new_attr; |
| 5426 | afi_t afi; |
| 5427 | int ret; |
| 5428 | |
| 5429 | /* Make default attribute. */ |
| 5430 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5431 | if (nexthop) |
| 5432 | attr.nexthop = *nexthop; |
| 5433 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5434 | #ifdef HAVE_IPV6 |
| 5435 | if (nexthop6) |
| 5436 | { |
| 5437 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5438 | extra->mp_nexthop_global = *nexthop6; |
| 5439 | extra->mp_nexthop_len = 16; |
| 5440 | } |
| 5441 | #endif |
| 5442 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5443 | attr.med = metric; |
| 5444 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5445 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5446 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5447 | { |
| 5448 | afi = family2afi (p->family); |
| 5449 | |
| 5450 | if (bgp->redist[afi][type]) |
| 5451 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5452 | struct attr attr_new; |
| 5453 | struct attr_extra extra_new; |
| 5454 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5455 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5456 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5457 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5458 | |
| 5459 | if (bgp->redist_metric_flag[afi][type]) |
| 5460 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5461 | |
| 5462 | /* Apply route-map. */ |
| 5463 | if (bgp->rmap[afi][type].map) |
| 5464 | { |
| 5465 | info.peer = bgp->peer_self; |
| 5466 | info.attr = &attr_new; |
| 5467 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5468 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5469 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5470 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5471 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5472 | |
| 5473 | bgp->peer_self->rmap_type = 0; |
| 5474 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5475 | if (ret == RMAP_DENYMATCH) |
| 5476 | { |
| 5477 | /* Free uninterned attribute. */ |
| 5478 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5479 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5480 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5481 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5482 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5483 | bgp_redistribute_delete (p, type); |
| 5484 | return; |
| 5485 | } |
| 5486 | } |
| 5487 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5488 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5489 | afi, SAFI_UNICAST, p, NULL); |
| 5490 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5491 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5492 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5493 | for (bi = bn->info; bi; bi = bi->next) |
| 5494 | if (bi->peer == bgp->peer_self |
| 5495 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5496 | break; |
| 5497 | |
| 5498 | if (bi) |
| 5499 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5500 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5501 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5502 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5503 | bgp_attr_unintern (&new_attr); |
| 5504 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5505 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5506 | bgp_unlock_node (bn); |
| 5507 | return; |
| 5508 | } |
| 5509 | else |
| 5510 | { |
| 5511 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5512 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5513 | |
| 5514 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5515 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5516 | bgp_info_restore(bn, bi); |
| 5517 | else |
| 5518 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5519 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5520 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5521 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5522 | |
| 5523 | /* Process change. */ |
| 5524 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5525 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5526 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5527 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5528 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5529 | return; |
| 5530 | } |
| 5531 | } |
| 5532 | |
| 5533 | new = bgp_info_new (); |
| 5534 | new->type = type; |
| 5535 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5536 | new->peer = bgp->peer_self; |
| 5537 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5538 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5539 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5540 | |
| 5541 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5542 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5543 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5544 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5545 | } |
| 5546 | } |
| 5547 | |
| 5548 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5549 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5550 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5551 | } |
| 5552 | |
| 5553 | void |
| 5554 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5555 | { |
| 5556 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5557 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5558 | afi_t afi; |
| 5559 | struct bgp_node *rn; |
| 5560 | struct bgp_info *ri; |
| 5561 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5562 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5563 | { |
| 5564 | afi = family2afi (p->family); |
| 5565 | |
| 5566 | if (bgp->redist[afi][type]) |
| 5567 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5568 | 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] | 5569 | |
| 5570 | for (ri = rn->info; ri; ri = ri->next) |
| 5571 | if (ri->peer == bgp->peer_self |
| 5572 | && ri->type == type) |
| 5573 | break; |
| 5574 | |
| 5575 | if (ri) |
| 5576 | { |
| 5577 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5578 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5579 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5580 | } |
| 5581 | bgp_unlock_node (rn); |
| 5582 | } |
| 5583 | } |
| 5584 | } |
| 5585 | |
| 5586 | /* Withdraw specified route type's route. */ |
| 5587 | void |
| 5588 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5589 | { |
| 5590 | struct bgp_node *rn; |
| 5591 | struct bgp_info *ri; |
| 5592 | struct bgp_table *table; |
| 5593 | |
| 5594 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5595 | |
| 5596 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5597 | { |
| 5598 | for (ri = rn->info; ri; ri = ri->next) |
| 5599 | if (ri->peer == bgp->peer_self |
| 5600 | && ri->type == type) |
| 5601 | break; |
| 5602 | |
| 5603 | if (ri) |
| 5604 | { |
| 5605 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5606 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5607 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5608 | } |
| 5609 | } |
| 5610 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5611 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5612 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5613 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5614 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5615 | { |
| 5616 | int len; |
| 5617 | u_int32_t destination; |
| 5618 | char buf[BUFSIZ]; |
| 5619 | |
| 5620 | if (p->family == AF_INET) |
| 5621 | { |
| 5622 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5623 | destination = ntohl (p->u.prefix4.s_addr); |
| 5624 | |
| 5625 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5626 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5627 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5628 | || p->u.prefix4.s_addr == 0) |
| 5629 | { |
| 5630 | /* When mask is natural, mask is not displayed. */ |
| 5631 | } |
| 5632 | else |
| 5633 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5634 | } |
| 5635 | else |
| 5636 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5637 | p->prefixlen); |
| 5638 | |
| 5639 | len = 17 - len; |
| 5640 | if (len < 1) |
| 5641 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5642 | else |
| 5643 | vty_out (vty, "%*s", len, " "); |
| 5644 | } |
| 5645 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5646 | enum bgp_display_type |
| 5647 | { |
| 5648 | normal_list, |
| 5649 | }; |
| 5650 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5651 | /* Print the short form route status for a bgp_info */ |
| 5652 | static void |
| 5653 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5654 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5655 | /* Route status display. */ |
| 5656 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5657 | vty_out (vty, "R"); |
| 5658 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5659 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5660 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5661 | vty_out (vty, "s"); |
| 5662 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5663 | vty_out (vty, "*"); |
| 5664 | else |
| 5665 | vty_out (vty, " "); |
| 5666 | |
| 5667 | /* Selected */ |
| 5668 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5669 | vty_out (vty, "h"); |
| 5670 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5671 | vty_out (vty, "d"); |
| 5672 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5673 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5674 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5675 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5676 | else |
| 5677 | vty_out (vty, " "); |
| 5678 | |
| 5679 | /* Internal route. */ |
| 5680 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5681 | vty_out (vty, "i"); |
| 5682 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5683 | vty_out (vty, " "); |
| 5684 | } |
| 5685 | |
| 5686 | /* called from terminal list command */ |
| 5687 | void |
| 5688 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5689 | struct bgp_info *binfo, int display, safi_t safi) |
| 5690 | { |
| 5691 | struct attr *attr; |
| 5692 | |
| 5693 | /* short status lead text */ |
| 5694 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5695 | |
| 5696 | /* print prefix and mask */ |
| 5697 | if (! display) |
| 5698 | route_vty_out_route (p, vty); |
| 5699 | else |
| 5700 | vty_out (vty, "%*s", 17, " "); |
| 5701 | |
| 5702 | /* Print attribute */ |
| 5703 | attr = binfo->attr; |
| 5704 | if (attr) |
| 5705 | { |
| 5706 | if (p->family == AF_INET) |
| 5707 | { |
| 5708 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5709 | vty_out (vty, "%-16s", |
| 5710 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5711 | else |
| 5712 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5713 | } |
| 5714 | #ifdef HAVE_IPV6 |
| 5715 | else if (p->family == AF_INET6) |
| 5716 | { |
| 5717 | int len; |
| 5718 | char buf[BUFSIZ]; |
| 5719 | |
| 5720 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5721 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5722 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5723 | len = 16 - len; |
| 5724 | if (len < 1) |
| 5725 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5726 | else |
| 5727 | vty_out (vty, "%*s", len, " "); |
| 5728 | } |
| 5729 | #endif /* HAVE_IPV6 */ |
| 5730 | |
| 5731 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5732 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5733 | else |
| 5734 | vty_out (vty, " "); |
| 5735 | |
| 5736 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5737 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5738 | else |
| 5739 | vty_out (vty, " "); |
| 5740 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5741 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5742 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5743 | /* Print aspath */ |
| 5744 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5745 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5746 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5747 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5748 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5749 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5750 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5751 | } |
| 5752 | |
| 5753 | /* called from terminal list command */ |
| 5754 | void |
| 5755 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5756 | struct attr *attr, safi_t safi) |
| 5757 | { |
| 5758 | /* Route status display. */ |
| 5759 | vty_out (vty, "*"); |
| 5760 | vty_out (vty, ">"); |
| 5761 | vty_out (vty, " "); |
| 5762 | |
| 5763 | /* print prefix and mask */ |
| 5764 | route_vty_out_route (p, vty); |
| 5765 | |
| 5766 | /* Print attribute */ |
| 5767 | if (attr) |
| 5768 | { |
| 5769 | if (p->family == AF_INET) |
| 5770 | { |
| 5771 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5772 | vty_out (vty, "%-16s", |
| 5773 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5774 | else |
| 5775 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5776 | } |
| 5777 | #ifdef HAVE_IPV6 |
| 5778 | else if (p->family == AF_INET6) |
| 5779 | { |
| 5780 | int len; |
| 5781 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5782 | |
| 5783 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5784 | |
| 5785 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5786 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5787 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5788 | len = 16 - len; |
| 5789 | if (len < 1) |
| 5790 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5791 | else |
| 5792 | vty_out (vty, "%*s", len, " "); |
| 5793 | } |
| 5794 | #endif /* HAVE_IPV6 */ |
| 5795 | |
| 5796 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5797 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5798 | else |
| 5799 | vty_out (vty, " "); |
| 5800 | |
| 5801 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5802 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5803 | else |
| 5804 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5805 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5806 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5807 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5808 | /* Print aspath */ |
| 5809 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5810 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5811 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5812 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5813 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5814 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5815 | |
| 5816 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5817 | } |
| 5818 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5819 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5820 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5821 | struct bgp_info *binfo, int display, safi_t safi) |
| 5822 | { |
| 5823 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5824 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5825 | |
| 5826 | if (!binfo->extra) |
| 5827 | return; |
| 5828 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5829 | /* short status lead text */ |
| 5830 | route_vty_short_status_out (vty, binfo); |
| 5831 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5832 | /* print prefix and mask */ |
| 5833 | if (! display) |
| 5834 | route_vty_out_route (p, vty); |
| 5835 | else |
| 5836 | vty_out (vty, "%*s", 17, " "); |
| 5837 | |
| 5838 | /* Print attribute */ |
| 5839 | attr = binfo->attr; |
| 5840 | if (attr) |
| 5841 | { |
| 5842 | if (p->family == AF_INET) |
| 5843 | { |
| 5844 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5845 | vty_out (vty, "%-16s", |
| 5846 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5847 | else |
| 5848 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5849 | } |
| 5850 | #ifdef HAVE_IPV6 |
| 5851 | else if (p->family == AF_INET6) |
| 5852 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5853 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5854 | char buf[BUFSIZ]; |
| 5855 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5856 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5857 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5858 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5859 | buf, BUFSIZ)); |
| 5860 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5861 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5862 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5863 | buf, BUFSIZ), |
| 5864 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5865 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5866 | |
| 5867 | } |
| 5868 | #endif /* HAVE_IPV6 */ |
| 5869 | } |
| 5870 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5871 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5872 | |
| 5873 | vty_out (vty, "notag/%d", label); |
| 5874 | |
| 5875 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5876 | } |
| 5877 | |
| 5878 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5879 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5880 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5881 | struct bgp_info *binfo, int display, safi_t safi) |
| 5882 | { |
| 5883 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5884 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5885 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5886 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5887 | /* short status lead text */ |
| 5888 | route_vty_short_status_out (vty, binfo); |
| 5889 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5890 | /* print prefix and mask */ |
| 5891 | if (! display) |
| 5892 | route_vty_out_route (p, vty); |
| 5893 | else |
| 5894 | vty_out (vty, "%*s", 17, " "); |
| 5895 | |
| 5896 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5897 | len = 17 - len; |
| 5898 | if (len < 1) |
| 5899 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5900 | else |
| 5901 | vty_out (vty, "%*s", len, " "); |
| 5902 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5903 | 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] | 5904 | |
| 5905 | /* Print attribute */ |
| 5906 | attr = binfo->attr; |
| 5907 | if (attr) |
| 5908 | { |
| 5909 | /* Print aspath */ |
| 5910 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5911 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5912 | |
| 5913 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5914 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5915 | } |
| 5916 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5917 | } |
| 5918 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5919 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5920 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5921 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5922 | struct bgp_info *binfo, int display, safi_t safi) |
| 5923 | { |
| 5924 | struct attr *attr; |
| 5925 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | char timebuf[BGP_UPTIME_LEN]; |
| 5927 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5928 | |
| 5929 | if (!binfo->extra) |
| 5930 | return; |
| 5931 | |
| 5932 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5933 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5934 | /* short status lead text */ |
| 5935 | route_vty_short_status_out (vty, binfo); |
| 5936 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5937 | /* print prefix and mask */ |
| 5938 | if (! display) |
| 5939 | route_vty_out_route (p, vty); |
| 5940 | else |
| 5941 | vty_out (vty, "%*s", 17, " "); |
| 5942 | |
| 5943 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5944 | len = 16 - len; |
| 5945 | if (len < 1) |
| 5946 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5947 | else |
| 5948 | vty_out (vty, "%*s", len, " "); |
| 5949 | |
| 5950 | len = vty_out (vty, "%d", bdi->flap); |
| 5951 | len = 5 - len; |
| 5952 | if (len < 1) |
| 5953 | vty_out (vty, " "); |
| 5954 | else |
| 5955 | vty_out (vty, "%*s ", len, " "); |
| 5956 | |
| 5957 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5958 | timebuf, BGP_UPTIME_LEN)); |
| 5959 | |
| 5960 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5961 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5962 | 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] | 5963 | else |
| 5964 | vty_out (vty, "%*s ", 8, " "); |
| 5965 | |
| 5966 | /* Print attribute */ |
| 5967 | attr = binfo->attr; |
| 5968 | if (attr) |
| 5969 | { |
| 5970 | /* Print aspath */ |
| 5971 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5972 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5973 | |
| 5974 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5975 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5976 | } |
| 5977 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5978 | } |
| 5979 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5980 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5981 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5982 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5983 | { |
| 5984 | char buf[INET6_ADDRSTRLEN]; |
| 5985 | char buf1[BUFSIZ]; |
| 5986 | struct attr *attr; |
| 5987 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5988 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5989 | time_t tbuf; |
| 5990 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5991 | |
| 5992 | attr = binfo->attr; |
| 5993 | |
| 5994 | if (attr) |
| 5995 | { |
| 5996 | /* Line1 display AS-path, Aggregator */ |
| 5997 | if (attr->aspath) |
| 5998 | { |
| 5999 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6000 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6001 | vty_out (vty, "Local"); |
| 6002 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6003 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6004 | } |
| 6005 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6006 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6007 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6008 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6009 | vty_out (vty, ", (stale)"); |
| 6010 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6011 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6012 | attr->extra->aggregator_as, |
| 6013 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6014 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6015 | vty_out (vty, ", (Received from a RR-client)"); |
| 6016 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6017 | vty_out (vty, ", (Received from a RS-client)"); |
| 6018 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6019 | vty_out (vty, ", (history entry)"); |
| 6020 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6021 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6022 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6023 | |
| 6024 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6025 | if (p->family == AF_INET) |
| 6026 | { |
| 6027 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6028 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6029 | inet_ntoa (attr->nexthop)); |
| 6030 | } |
| 6031 | #ifdef HAVE_IPV6 |
| 6032 | else |
| 6033 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6034 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6035 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6036 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | buf, INET6_ADDRSTRLEN)); |
| 6038 | } |
| 6039 | #endif /* HAVE_IPV6 */ |
| 6040 | |
| 6041 | if (binfo->peer == bgp->peer_self) |
| 6042 | { |
| 6043 | vty_out (vty, " from %s ", |
| 6044 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6045 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6046 | } |
| 6047 | else |
| 6048 | { |
| 6049 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6050 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6051 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6052 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 6053 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6054 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6055 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6056 | else |
| 6057 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6058 | } |
| 6059 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6060 | |
| 6061 | #ifdef HAVE_IPV6 |
| 6062 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6063 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6064 | { |
| 6065 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6066 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6067 | buf, INET6_ADDRSTRLEN), |
| 6068 | VTY_NEWLINE); |
| 6069 | } |
| 6070 | #endif /* HAVE_IPV6 */ |
| 6071 | |
| 6072 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6073 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6074 | |
| 6075 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6076 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6077 | |
| 6078 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6079 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6080 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6081 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6082 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6083 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6084 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6085 | |
| 6086 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6087 | vty_out (vty, ", valid"); |
| 6088 | |
| 6089 | if (binfo->peer != bgp->peer_self) |
| 6090 | { |
| 6091 | if (binfo->peer->as == binfo->peer->local_as) |
| 6092 | vty_out (vty, ", internal"); |
| 6093 | else |
| 6094 | vty_out (vty, ", %s", |
| 6095 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6096 | } |
| 6097 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6098 | vty_out (vty, ", aggregated, local"); |
| 6099 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6100 | vty_out (vty, ", sourced"); |
| 6101 | else |
| 6102 | vty_out (vty, ", sourced, local"); |
| 6103 | |
| 6104 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6105 | vty_out (vty, ", atomic-aggregate"); |
| 6106 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6107 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6108 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6109 | bgp_info_mpath_count (binfo))) |
| 6110 | vty_out (vty, ", multipath"); |
| 6111 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6112 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6113 | vty_out (vty, ", best"); |
| 6114 | |
| 6115 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6116 | |
| 6117 | /* Line 4 display Community */ |
| 6118 | if (attr->community) |
| 6119 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6120 | VTY_NEWLINE); |
| 6121 | |
| 6122 | /* Line 5 display Extended-community */ |
| 6123 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6124 | vty_out (vty, " Extended Community: %s%s", |
| 6125 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6126 | |
| 6127 | /* Line 6 display Originator, Cluster-id */ |
| 6128 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6129 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6130 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6131 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6132 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6133 | vty_out (vty, " Originator: %s", |
| 6134 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6135 | |
| 6136 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6137 | { |
| 6138 | int i; |
| 6139 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6140 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6141 | vty_out (vty, "%s ", |
| 6142 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6143 | } |
| 6144 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6145 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6146 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6147 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6148 | bgp_damp_info_vty (vty, binfo); |
| 6149 | |
| 6150 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6151 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6152 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6153 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6154 | #else |
| 6155 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6156 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6157 | } |
| 6158 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6159 | } |
| 6160 | |
| 6161 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6162 | "h history, * valid, > best, = multipath,%s"\ |
| 6163 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6164 | #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] | 6165 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6166 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6167 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6168 | |
| 6169 | enum bgp_show_type |
| 6170 | { |
| 6171 | bgp_show_type_normal, |
| 6172 | bgp_show_type_regexp, |
| 6173 | bgp_show_type_prefix_list, |
| 6174 | bgp_show_type_filter_list, |
| 6175 | bgp_show_type_route_map, |
| 6176 | bgp_show_type_neighbor, |
| 6177 | bgp_show_type_cidr_only, |
| 6178 | bgp_show_type_prefix_longer, |
| 6179 | bgp_show_type_community_all, |
| 6180 | bgp_show_type_community, |
| 6181 | bgp_show_type_community_exact, |
| 6182 | bgp_show_type_community_list, |
| 6183 | bgp_show_type_community_list_exact, |
| 6184 | bgp_show_type_flap_statistics, |
| 6185 | bgp_show_type_flap_address, |
| 6186 | bgp_show_type_flap_prefix, |
| 6187 | bgp_show_type_flap_cidr_only, |
| 6188 | bgp_show_type_flap_regexp, |
| 6189 | bgp_show_type_flap_filter_list, |
| 6190 | bgp_show_type_flap_prefix_list, |
| 6191 | bgp_show_type_flap_prefix_longer, |
| 6192 | bgp_show_type_flap_route_map, |
| 6193 | bgp_show_type_flap_neighbor, |
| 6194 | bgp_show_type_dampend_paths, |
| 6195 | bgp_show_type_damp_neighbor |
| 6196 | }; |
| 6197 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6198 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6199 | 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] | 6200 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6201 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6202 | struct bgp_info *ri; |
| 6203 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6204 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6205 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6206 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6207 | |
| 6208 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6209 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6210 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6211 | /* Start processing of routes. */ |
| 6212 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6213 | if (rn->info != NULL) |
| 6214 | { |
| 6215 | display = 0; |
| 6216 | |
| 6217 | for (ri = rn->info; ri; ri = ri->next) |
| 6218 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6219 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6220 | || type == bgp_show_type_flap_address |
| 6221 | || type == bgp_show_type_flap_prefix |
| 6222 | || type == bgp_show_type_flap_cidr_only |
| 6223 | || type == bgp_show_type_flap_regexp |
| 6224 | || type == bgp_show_type_flap_filter_list |
| 6225 | || type == bgp_show_type_flap_prefix_list |
| 6226 | || type == bgp_show_type_flap_prefix_longer |
| 6227 | || type == bgp_show_type_flap_route_map |
| 6228 | || type == bgp_show_type_flap_neighbor |
| 6229 | || type == bgp_show_type_dampend_paths |
| 6230 | || type == bgp_show_type_damp_neighbor) |
| 6231 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6232 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6233 | continue; |
| 6234 | } |
| 6235 | if (type == bgp_show_type_regexp |
| 6236 | || type == bgp_show_type_flap_regexp) |
| 6237 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6238 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6239 | |
| 6240 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6241 | continue; |
| 6242 | } |
| 6243 | if (type == bgp_show_type_prefix_list |
| 6244 | || type == bgp_show_type_flap_prefix_list) |
| 6245 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6246 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6247 | |
| 6248 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6249 | continue; |
| 6250 | } |
| 6251 | if (type == bgp_show_type_filter_list |
| 6252 | || type == bgp_show_type_flap_filter_list) |
| 6253 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6254 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6255 | |
| 6256 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6257 | continue; |
| 6258 | } |
| 6259 | if (type == bgp_show_type_route_map |
| 6260 | || type == bgp_show_type_flap_route_map) |
| 6261 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6262 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6263 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6264 | struct attr dummy_attr; |
| 6265 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6266 | int ret; |
| 6267 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6268 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6269 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6270 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6271 | binfo.peer = ri->peer; |
| 6272 | binfo.attr = &dummy_attr; |
| 6273 | |
| 6274 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6275 | if (ret == RMAP_DENYMATCH) |
| 6276 | continue; |
| 6277 | } |
| 6278 | if (type == bgp_show_type_neighbor |
| 6279 | || type == bgp_show_type_flap_neighbor |
| 6280 | || type == bgp_show_type_damp_neighbor) |
| 6281 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6282 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6283 | |
| 6284 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6285 | continue; |
| 6286 | } |
| 6287 | if (type == bgp_show_type_cidr_only |
| 6288 | || type == bgp_show_type_flap_cidr_only) |
| 6289 | { |
| 6290 | u_int32_t destination; |
| 6291 | |
| 6292 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6293 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6294 | continue; |
| 6295 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6296 | continue; |
| 6297 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6298 | continue; |
| 6299 | } |
| 6300 | if (type == bgp_show_type_prefix_longer |
| 6301 | || type == bgp_show_type_flap_prefix_longer) |
| 6302 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6303 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6304 | |
| 6305 | if (! prefix_match (p, &rn->p)) |
| 6306 | continue; |
| 6307 | } |
| 6308 | if (type == bgp_show_type_community_all) |
| 6309 | { |
| 6310 | if (! ri->attr->community) |
| 6311 | continue; |
| 6312 | } |
| 6313 | if (type == bgp_show_type_community) |
| 6314 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6315 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6316 | |
| 6317 | if (! ri->attr->community || |
| 6318 | ! community_match (ri->attr->community, com)) |
| 6319 | continue; |
| 6320 | } |
| 6321 | if (type == bgp_show_type_community_exact) |
| 6322 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6323 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6324 | |
| 6325 | if (! ri->attr->community || |
| 6326 | ! community_cmp (ri->attr->community, com)) |
| 6327 | continue; |
| 6328 | } |
| 6329 | if (type == bgp_show_type_community_list) |
| 6330 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6331 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6332 | |
| 6333 | if (! community_list_match (ri->attr->community, list)) |
| 6334 | continue; |
| 6335 | } |
| 6336 | if (type == bgp_show_type_community_list_exact) |
| 6337 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6338 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6339 | |
| 6340 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6341 | continue; |
| 6342 | } |
| 6343 | if (type == bgp_show_type_flap_address |
| 6344 | || type == bgp_show_type_flap_prefix) |
| 6345 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6346 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6347 | |
| 6348 | if (! prefix_match (&rn->p, p)) |
| 6349 | continue; |
| 6350 | |
| 6351 | if (type == bgp_show_type_flap_prefix) |
| 6352 | if (p->prefixlen != rn->p.prefixlen) |
| 6353 | continue; |
| 6354 | } |
| 6355 | if (type == bgp_show_type_dampend_paths |
| 6356 | || type == bgp_show_type_damp_neighbor) |
| 6357 | { |
| 6358 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6359 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6360 | continue; |
| 6361 | } |
| 6362 | |
| 6363 | if (header) |
| 6364 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6365 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6366 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6367 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6368 | if (type == bgp_show_type_dampend_paths |
| 6369 | || type == bgp_show_type_damp_neighbor) |
| 6370 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6371 | else if (type == bgp_show_type_flap_statistics |
| 6372 | || type == bgp_show_type_flap_address |
| 6373 | || type == bgp_show_type_flap_prefix |
| 6374 | || type == bgp_show_type_flap_cidr_only |
| 6375 | || type == bgp_show_type_flap_regexp |
| 6376 | || type == bgp_show_type_flap_filter_list |
| 6377 | || type == bgp_show_type_flap_prefix_list |
| 6378 | || type == bgp_show_type_flap_prefix_longer |
| 6379 | || type == bgp_show_type_flap_route_map |
| 6380 | || type == bgp_show_type_flap_neighbor) |
| 6381 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6382 | else |
| 6383 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6384 | header = 0; |
| 6385 | } |
| 6386 | |
| 6387 | if (type == bgp_show_type_dampend_paths |
| 6388 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6389 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6390 | else if (type == bgp_show_type_flap_statistics |
| 6391 | || type == bgp_show_type_flap_address |
| 6392 | || type == bgp_show_type_flap_prefix |
| 6393 | || type == bgp_show_type_flap_cidr_only |
| 6394 | || type == bgp_show_type_flap_regexp |
| 6395 | || type == bgp_show_type_flap_filter_list |
| 6396 | || type == bgp_show_type_flap_prefix_list |
| 6397 | || type == bgp_show_type_flap_prefix_longer |
| 6398 | || type == bgp_show_type_flap_route_map |
| 6399 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6400 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6401 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6402 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6403 | display++; |
| 6404 | } |
| 6405 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6406 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6407 | } |
| 6408 | |
| 6409 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6410 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6411 | { |
| 6412 | if (type == bgp_show_type_normal) |
| 6413 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6414 | } |
| 6415 | else |
| 6416 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6417 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6418 | |
| 6419 | return CMD_SUCCESS; |
| 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 (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6424 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6425 | { |
| 6426 | struct bgp_table *table; |
| 6427 | |
| 6428 | if (bgp == NULL) { |
| 6429 | bgp = bgp_get_default (); |
| 6430 | } |
| 6431 | |
| 6432 | if (bgp == NULL) |
| 6433 | { |
| 6434 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6435 | return CMD_WARNING; |
| 6436 | } |
| 6437 | |
| 6438 | |
| 6439 | table = bgp->rib[afi][safi]; |
| 6440 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6441 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6442 | } |
| 6443 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6444 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6445 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6446 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6447 | struct bgp_node *rn, |
| 6448 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6449 | { |
| 6450 | struct bgp_info *ri; |
| 6451 | struct prefix *p; |
| 6452 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6453 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6454 | char buf1[INET6_ADDRSTRLEN]; |
| 6455 | char buf2[INET6_ADDRSTRLEN]; |
| 6456 | int count = 0; |
| 6457 | int best = 0; |
| 6458 | int suppress = 0; |
| 6459 | int no_export = 0; |
| 6460 | int no_advertise = 0; |
| 6461 | int local_as = 0; |
| 6462 | int first = 0; |
| 6463 | |
| 6464 | p = &rn->p; |
| 6465 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6466 | (safi == SAFI_MPLS_VPN ? |
| 6467 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6468 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6469 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6470 | p->prefixlen, VTY_NEWLINE); |
| 6471 | |
| 6472 | for (ri = rn->info; ri; ri = ri->next) |
| 6473 | { |
| 6474 | count++; |
| 6475 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6476 | { |
| 6477 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6478 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6479 | suppress = 1; |
| 6480 | if (ri->attr->community != NULL) |
| 6481 | { |
| 6482 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6483 | no_advertise = 1; |
| 6484 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6485 | no_export = 1; |
| 6486 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6487 | local_as = 1; |
| 6488 | } |
| 6489 | } |
| 6490 | } |
| 6491 | |
| 6492 | vty_out (vty, "Paths: (%d available", count); |
| 6493 | if (best) |
| 6494 | { |
| 6495 | vty_out (vty, ", best #%d", best); |
| 6496 | if (safi == SAFI_UNICAST) |
| 6497 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6498 | } |
| 6499 | else |
| 6500 | vty_out (vty, ", no best path"); |
| 6501 | if (no_advertise) |
| 6502 | vty_out (vty, ", not advertised to any peer"); |
| 6503 | else if (no_export) |
| 6504 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6505 | else if (local_as) |
| 6506 | vty_out (vty, ", not advertised outside local AS"); |
| 6507 | if (suppress) |
| 6508 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6509 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6510 | |
| 6511 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6512 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6513 | { |
| 6514 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6515 | { |
| 6516 | if (! first) |
| 6517 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6518 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6519 | first = 1; |
| 6520 | } |
| 6521 | } |
| 6522 | if (! first) |
| 6523 | vty_out (vty, " Not advertised to any peer"); |
| 6524 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6525 | } |
| 6526 | |
| 6527 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6528 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6529 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6530 | struct bgp_table *rib, const char *ip_str, |
| 6531 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6532 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6533 | { |
| 6534 | int ret; |
| 6535 | int header; |
| 6536 | int display = 0; |
| 6537 | struct prefix match; |
| 6538 | struct bgp_node *rn; |
| 6539 | struct bgp_node *rm; |
| 6540 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6541 | struct bgp_table *table; |
| 6542 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6543 | /* Check IP address argument. */ |
| 6544 | ret = str2prefix (ip_str, &match); |
| 6545 | if (! ret) |
| 6546 | { |
| 6547 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6548 | return CMD_WARNING; |
| 6549 | } |
| 6550 | |
| 6551 | match.family = afi2family (afi); |
| 6552 | |
| 6553 | if (safi == SAFI_MPLS_VPN) |
| 6554 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6555 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6556 | { |
| 6557 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6558 | continue; |
| 6559 | |
| 6560 | if ((table = rn->info) != NULL) |
| 6561 | { |
| 6562 | header = 1; |
| 6563 | |
| 6564 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6565 | { |
| 6566 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6567 | { |
| 6568 | bgp_unlock_node (rm); |
| 6569 | continue; |
| 6570 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6571 | |
| 6572 | for (ri = rm->info; ri; ri = ri->next) |
| 6573 | { |
| 6574 | if (header) |
| 6575 | { |
| 6576 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6577 | AFI_IP, SAFI_MPLS_VPN); |
| 6578 | |
| 6579 | header = 0; |
| 6580 | } |
| 6581 | display++; |
| 6582 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6583 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6584 | |
| 6585 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6586 | } |
| 6587 | } |
| 6588 | } |
| 6589 | } |
| 6590 | else |
| 6591 | { |
| 6592 | header = 1; |
| 6593 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6594 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6595 | { |
| 6596 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6597 | { |
| 6598 | for (ri = rn->info; ri; ri = ri->next) |
| 6599 | { |
| 6600 | if (header) |
| 6601 | { |
| 6602 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6603 | header = 0; |
| 6604 | } |
| 6605 | display++; |
| 6606 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6607 | } |
| 6608 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6609 | |
| 6610 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6611 | } |
| 6612 | } |
| 6613 | |
| 6614 | if (! display) |
| 6615 | { |
| 6616 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6617 | return CMD_WARNING; |
| 6618 | } |
| 6619 | |
| 6620 | return CMD_SUCCESS; |
| 6621 | } |
| 6622 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6623 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6624 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6625 | 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] | 6626 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6627 | int prefix_check) |
| 6628 | { |
| 6629 | struct bgp *bgp; |
| 6630 | |
| 6631 | /* BGP structure lookup. */ |
| 6632 | if (view_name) |
| 6633 | { |
| 6634 | bgp = bgp_lookup_by_name (view_name); |
| 6635 | if (bgp == NULL) |
| 6636 | { |
| 6637 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6638 | return CMD_WARNING; |
| 6639 | } |
| 6640 | } |
| 6641 | else |
| 6642 | { |
| 6643 | bgp = bgp_get_default (); |
| 6644 | if (bgp == NULL) |
| 6645 | { |
| 6646 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6647 | return CMD_WARNING; |
| 6648 | } |
| 6649 | } |
| 6650 | |
| 6651 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6652 | afi, safi, prd, prefix_check); |
| 6653 | } |
| 6654 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6655 | /* BGP route print out function. */ |
| 6656 | DEFUN (show_ip_bgp, |
| 6657 | show_ip_bgp_cmd, |
| 6658 | "show ip bgp", |
| 6659 | SHOW_STR |
| 6660 | IP_STR |
| 6661 | BGP_STR) |
| 6662 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6663 | 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] | 6664 | } |
| 6665 | |
| 6666 | DEFUN (show_ip_bgp_ipv4, |
| 6667 | show_ip_bgp_ipv4_cmd, |
| 6668 | "show ip bgp ipv4 (unicast|multicast)", |
| 6669 | SHOW_STR |
| 6670 | IP_STR |
| 6671 | BGP_STR |
| 6672 | "Address family\n" |
| 6673 | "Address Family modifier\n" |
| 6674 | "Address Family modifier\n") |
| 6675 | { |
| 6676 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6677 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6678 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6679 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6680 | 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] | 6681 | } |
| 6682 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6683 | ALIAS (show_ip_bgp_ipv4, |
| 6684 | show_bgp_ipv4_safi_cmd, |
| 6685 | "show bgp ipv4 (unicast|multicast)", |
| 6686 | SHOW_STR |
| 6687 | BGP_STR |
| 6688 | "Address family\n" |
| 6689 | "Address Family modifier\n" |
| 6690 | "Address Family modifier\n") |
| 6691 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6692 | DEFUN (show_ip_bgp_route, |
| 6693 | show_ip_bgp_route_cmd, |
| 6694 | "show ip bgp A.B.C.D", |
| 6695 | SHOW_STR |
| 6696 | IP_STR |
| 6697 | BGP_STR |
| 6698 | "Network in the BGP routing table to display\n") |
| 6699 | { |
| 6700 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6701 | } |
| 6702 | |
| 6703 | DEFUN (show_ip_bgp_ipv4_route, |
| 6704 | show_ip_bgp_ipv4_route_cmd, |
| 6705 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6706 | SHOW_STR |
| 6707 | IP_STR |
| 6708 | BGP_STR |
| 6709 | "Address family\n" |
| 6710 | "Address Family modifier\n" |
| 6711 | "Address Family modifier\n" |
| 6712 | "Network in the BGP routing table to display\n") |
| 6713 | { |
| 6714 | if (strncmp (argv[0], "m", 1) == 0) |
| 6715 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6716 | |
| 6717 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6718 | } |
| 6719 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6720 | ALIAS (show_ip_bgp_ipv4_route, |
| 6721 | show_bgp_ipv4_safi_route_cmd, |
| 6722 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6723 | SHOW_STR |
| 6724 | BGP_STR |
| 6725 | "Address family\n" |
| 6726 | "Address Family modifier\n" |
| 6727 | "Address Family modifier\n" |
| 6728 | "Network in the BGP routing table to display\n") |
| 6729 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6730 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6731 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6732 | "show ip bgp vpnv4 all A.B.C.D", |
| 6733 | SHOW_STR |
| 6734 | IP_STR |
| 6735 | BGP_STR |
| 6736 | "Display VPNv4 NLRI specific information\n" |
| 6737 | "Display information about all VPNv4 NLRIs\n" |
| 6738 | "Network in the BGP routing table to display\n") |
| 6739 | { |
| 6740 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6741 | } |
| 6742 | |
| 6743 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6744 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6745 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6746 | SHOW_STR |
| 6747 | IP_STR |
| 6748 | BGP_STR |
| 6749 | "Display VPNv4 NLRI specific information\n" |
| 6750 | "Display information for a route distinguisher\n" |
| 6751 | "VPN Route Distinguisher\n" |
| 6752 | "Network in the BGP routing table to display\n") |
| 6753 | { |
| 6754 | int ret; |
| 6755 | struct prefix_rd prd; |
| 6756 | |
| 6757 | ret = str2prefix_rd (argv[0], &prd); |
| 6758 | if (! ret) |
| 6759 | { |
| 6760 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6761 | return CMD_WARNING; |
| 6762 | } |
| 6763 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6764 | } |
| 6765 | |
| 6766 | DEFUN (show_ip_bgp_prefix, |
| 6767 | show_ip_bgp_prefix_cmd, |
| 6768 | "show ip bgp A.B.C.D/M", |
| 6769 | SHOW_STR |
| 6770 | IP_STR |
| 6771 | BGP_STR |
| 6772 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6773 | { |
| 6774 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6775 | } |
| 6776 | |
| 6777 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6778 | show_ip_bgp_ipv4_prefix_cmd, |
| 6779 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6780 | SHOW_STR |
| 6781 | IP_STR |
| 6782 | BGP_STR |
| 6783 | "Address family\n" |
| 6784 | "Address Family modifier\n" |
| 6785 | "Address Family modifier\n" |
| 6786 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6787 | { |
| 6788 | if (strncmp (argv[0], "m", 1) == 0) |
| 6789 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6790 | |
| 6791 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6792 | } |
| 6793 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6794 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6795 | show_bgp_ipv4_safi_prefix_cmd, |
| 6796 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6797 | SHOW_STR |
| 6798 | BGP_STR |
| 6799 | "Address family\n" |
| 6800 | "Address Family modifier\n" |
| 6801 | "Address Family modifier\n" |
| 6802 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6803 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6804 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6805 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6806 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6807 | SHOW_STR |
| 6808 | IP_STR |
| 6809 | BGP_STR |
| 6810 | "Display VPNv4 NLRI specific information\n" |
| 6811 | "Display information about all VPNv4 NLRIs\n" |
| 6812 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6813 | { |
| 6814 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6815 | } |
| 6816 | |
| 6817 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6818 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6819 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6820 | SHOW_STR |
| 6821 | IP_STR |
| 6822 | BGP_STR |
| 6823 | "Display VPNv4 NLRI specific information\n" |
| 6824 | "Display information for a route distinguisher\n" |
| 6825 | "VPN Route Distinguisher\n" |
| 6826 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6827 | { |
| 6828 | int ret; |
| 6829 | struct prefix_rd prd; |
| 6830 | |
| 6831 | ret = str2prefix_rd (argv[0], &prd); |
| 6832 | if (! ret) |
| 6833 | { |
| 6834 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6835 | return CMD_WARNING; |
| 6836 | } |
| 6837 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6838 | } |
| 6839 | |
| 6840 | DEFUN (show_ip_bgp_view, |
| 6841 | show_ip_bgp_view_cmd, |
| 6842 | "show ip bgp view WORD", |
| 6843 | SHOW_STR |
| 6844 | IP_STR |
| 6845 | BGP_STR |
| 6846 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6847 | "View name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6848 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6849 | struct bgp *bgp; |
| 6850 | |
| 6851 | /* BGP structure lookup. */ |
| 6852 | bgp = bgp_lookup_by_name (argv[0]); |
| 6853 | if (bgp == NULL) |
| 6854 | { |
| 6855 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6856 | return CMD_WARNING; |
| 6857 | } |
| 6858 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6859 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6860 | } |
| 6861 | |
| 6862 | DEFUN (show_ip_bgp_view_route, |
| 6863 | show_ip_bgp_view_route_cmd, |
| 6864 | "show ip bgp view WORD A.B.C.D", |
| 6865 | SHOW_STR |
| 6866 | IP_STR |
| 6867 | BGP_STR |
| 6868 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6869 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6870 | "Network in the BGP routing table to display\n") |
| 6871 | { |
| 6872 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6873 | } |
| 6874 | |
| 6875 | DEFUN (show_ip_bgp_view_prefix, |
| 6876 | show_ip_bgp_view_prefix_cmd, |
| 6877 | "show ip bgp view WORD A.B.C.D/M", |
| 6878 | SHOW_STR |
| 6879 | IP_STR |
| 6880 | BGP_STR |
| 6881 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6882 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6883 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6884 | { |
| 6885 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6886 | } |
| 6887 | |
| 6888 | #ifdef HAVE_IPV6 |
| 6889 | DEFUN (show_bgp, |
| 6890 | show_bgp_cmd, |
| 6891 | "show bgp", |
| 6892 | SHOW_STR |
| 6893 | BGP_STR) |
| 6894 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6895 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6896 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6897 | } |
| 6898 | |
| 6899 | ALIAS (show_bgp, |
| 6900 | show_bgp_ipv6_cmd, |
| 6901 | "show bgp ipv6", |
| 6902 | SHOW_STR |
| 6903 | BGP_STR |
| 6904 | "Address family\n") |
| 6905 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6906 | DEFUN (show_bgp_ipv6_safi, |
| 6907 | show_bgp_ipv6_safi_cmd, |
| 6908 | "show bgp ipv6 (unicast|multicast)", |
| 6909 | SHOW_STR |
| 6910 | BGP_STR |
| 6911 | "Address family\n" |
| 6912 | "Address Family modifier\n" |
| 6913 | "Address Family modifier\n") |
| 6914 | { |
| 6915 | if (strncmp (argv[0], "m", 1) == 0) |
| 6916 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6917 | NULL); |
| 6918 | |
| 6919 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6920 | } |
| 6921 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6922 | /* old command */ |
| 6923 | DEFUN (show_ipv6_bgp, |
| 6924 | show_ipv6_bgp_cmd, |
| 6925 | "show ipv6 bgp", |
| 6926 | SHOW_STR |
| 6927 | IP_STR |
| 6928 | BGP_STR) |
| 6929 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6930 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6931 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6932 | } |
| 6933 | |
| 6934 | DEFUN (show_bgp_route, |
| 6935 | show_bgp_route_cmd, |
| 6936 | "show bgp X:X::X:X", |
| 6937 | SHOW_STR |
| 6938 | BGP_STR |
| 6939 | "Network in the BGP routing table to display\n") |
| 6940 | { |
| 6941 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6942 | } |
| 6943 | |
| 6944 | ALIAS (show_bgp_route, |
| 6945 | show_bgp_ipv6_route_cmd, |
| 6946 | "show bgp ipv6 X:X::X:X", |
| 6947 | SHOW_STR |
| 6948 | BGP_STR |
| 6949 | "Address family\n" |
| 6950 | "Network in the BGP routing table to display\n") |
| 6951 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6952 | DEFUN (show_bgp_ipv6_safi_route, |
| 6953 | show_bgp_ipv6_safi_route_cmd, |
| 6954 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6955 | SHOW_STR |
| 6956 | BGP_STR |
| 6957 | "Address family\n" |
| 6958 | "Address Family modifier\n" |
| 6959 | "Address Family modifier\n" |
| 6960 | "Network in the BGP routing table to display\n") |
| 6961 | { |
| 6962 | if (strncmp (argv[0], "m", 1) == 0) |
| 6963 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6964 | |
| 6965 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6966 | } |
| 6967 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6968 | /* old command */ |
| 6969 | DEFUN (show_ipv6_bgp_route, |
| 6970 | show_ipv6_bgp_route_cmd, |
| 6971 | "show ipv6 bgp X:X::X:X", |
| 6972 | SHOW_STR |
| 6973 | IP_STR |
| 6974 | BGP_STR |
| 6975 | "Network in the BGP routing table to display\n") |
| 6976 | { |
| 6977 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6978 | } |
| 6979 | |
| 6980 | DEFUN (show_bgp_prefix, |
| 6981 | show_bgp_prefix_cmd, |
| 6982 | "show bgp X:X::X:X/M", |
| 6983 | SHOW_STR |
| 6984 | BGP_STR |
| 6985 | "IPv6 prefix <network>/<length>\n") |
| 6986 | { |
| 6987 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6988 | } |
| 6989 | |
| 6990 | ALIAS (show_bgp_prefix, |
| 6991 | show_bgp_ipv6_prefix_cmd, |
| 6992 | "show bgp ipv6 X:X::X:X/M", |
| 6993 | SHOW_STR |
| 6994 | BGP_STR |
| 6995 | "Address family\n" |
| 6996 | "IPv6 prefix <network>/<length>\n") |
| 6997 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6998 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6999 | show_bgp_ipv6_safi_prefix_cmd, |
| 7000 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 7001 | SHOW_STR |
| 7002 | BGP_STR |
| 7003 | "Address family\n" |
| 7004 | "Address Family modifier\n" |
| 7005 | "Address Family modifier\n" |
| 7006 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7007 | { |
| 7008 | if (strncmp (argv[0], "m", 1) == 0) |
| 7009 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7010 | |
| 7011 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7012 | } |
| 7013 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7014 | /* old command */ |
| 7015 | DEFUN (show_ipv6_bgp_prefix, |
| 7016 | show_ipv6_bgp_prefix_cmd, |
| 7017 | "show ipv6 bgp X:X::X:X/M", |
| 7018 | SHOW_STR |
| 7019 | IP_STR |
| 7020 | BGP_STR |
| 7021 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7022 | { |
| 7023 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7024 | } |
| 7025 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7026 | DEFUN (show_bgp_view, |
| 7027 | show_bgp_view_cmd, |
| 7028 | "show bgp view WORD", |
| 7029 | SHOW_STR |
| 7030 | BGP_STR |
| 7031 | "BGP view\n" |
| 7032 | "View name\n") |
| 7033 | { |
| 7034 | struct bgp *bgp; |
| 7035 | |
| 7036 | /* BGP structure lookup. */ |
| 7037 | bgp = bgp_lookup_by_name (argv[0]); |
| 7038 | if (bgp == NULL) |
| 7039 | { |
| 7040 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7041 | return CMD_WARNING; |
| 7042 | } |
| 7043 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7044 | 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] | 7045 | } |
| 7046 | |
| 7047 | ALIAS (show_bgp_view, |
| 7048 | show_bgp_view_ipv6_cmd, |
| 7049 | "show bgp view WORD ipv6", |
| 7050 | SHOW_STR |
| 7051 | BGP_STR |
| 7052 | "BGP view\n" |
| 7053 | "View name\n" |
| 7054 | "Address family\n") |
| 7055 | |
| 7056 | DEFUN (show_bgp_view_route, |
| 7057 | show_bgp_view_route_cmd, |
| 7058 | "show bgp view WORD X:X::X:X", |
| 7059 | SHOW_STR |
| 7060 | BGP_STR |
| 7061 | "BGP view\n" |
| 7062 | "View name\n" |
| 7063 | "Network in the BGP routing table to display\n") |
| 7064 | { |
| 7065 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7066 | } |
| 7067 | |
| 7068 | ALIAS (show_bgp_view_route, |
| 7069 | show_bgp_view_ipv6_route_cmd, |
| 7070 | "show bgp view WORD ipv6 X:X::X:X", |
| 7071 | SHOW_STR |
| 7072 | BGP_STR |
| 7073 | "BGP view\n" |
| 7074 | "View name\n" |
| 7075 | "Address family\n" |
| 7076 | "Network in the BGP routing table to display\n") |
| 7077 | |
| 7078 | DEFUN (show_bgp_view_prefix, |
| 7079 | show_bgp_view_prefix_cmd, |
| 7080 | "show bgp view WORD X:X::X:X/M", |
| 7081 | SHOW_STR |
| 7082 | BGP_STR |
| 7083 | "BGP view\n" |
| 7084 | "View name\n" |
| 7085 | "IPv6 prefix <network>/<length>\n") |
| 7086 | { |
| 7087 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7088 | } |
| 7089 | |
| 7090 | ALIAS (show_bgp_view_prefix, |
| 7091 | show_bgp_view_ipv6_prefix_cmd, |
| 7092 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7093 | SHOW_STR |
| 7094 | BGP_STR |
| 7095 | "BGP view\n" |
| 7096 | "View name\n" |
| 7097 | "Address family\n" |
| 7098 | "IPv6 prefix <network>/<length>\n") |
| 7099 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7100 | /* old command */ |
| 7101 | DEFUN (show_ipv6_mbgp, |
| 7102 | show_ipv6_mbgp_cmd, |
| 7103 | "show ipv6 mbgp", |
| 7104 | SHOW_STR |
| 7105 | IP_STR |
| 7106 | MBGP_STR) |
| 7107 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7108 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7109 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7110 | } |
| 7111 | |
| 7112 | /* old command */ |
| 7113 | DEFUN (show_ipv6_mbgp_route, |
| 7114 | show_ipv6_mbgp_route_cmd, |
| 7115 | "show ipv6 mbgp X:X::X:X", |
| 7116 | SHOW_STR |
| 7117 | IP_STR |
| 7118 | MBGP_STR |
| 7119 | "Network in the MBGP routing table to display\n") |
| 7120 | { |
| 7121 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7122 | } |
| 7123 | |
| 7124 | /* old command */ |
| 7125 | DEFUN (show_ipv6_mbgp_prefix, |
| 7126 | show_ipv6_mbgp_prefix_cmd, |
| 7127 | "show ipv6 mbgp X:X::X:X/M", |
| 7128 | SHOW_STR |
| 7129 | IP_STR |
| 7130 | MBGP_STR |
| 7131 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7132 | { |
| 7133 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7134 | } |
| 7135 | #endif |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7136 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7137 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7138 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7139 | 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] | 7140 | safi_t safi, enum bgp_show_type type) |
| 7141 | { |
| 7142 | int i; |
| 7143 | struct buffer *b; |
| 7144 | char *regstr; |
| 7145 | int first; |
| 7146 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7147 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7148 | |
| 7149 | first = 0; |
| 7150 | b = buffer_new (1024); |
| 7151 | for (i = 0; i < argc; i++) |
| 7152 | { |
| 7153 | if (first) |
| 7154 | buffer_putc (b, ' '); |
| 7155 | else |
| 7156 | { |
| 7157 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7158 | continue; |
| 7159 | first = 1; |
| 7160 | } |
| 7161 | |
| 7162 | buffer_putstr (b, argv[i]); |
| 7163 | } |
| 7164 | buffer_putc (b, '\0'); |
| 7165 | |
| 7166 | regstr = buffer_getstr (b); |
| 7167 | buffer_free (b); |
| 7168 | |
| 7169 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7170 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7171 | if (! regex) |
| 7172 | { |
| 7173 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7174 | VTY_NEWLINE); |
| 7175 | return CMD_WARNING; |
| 7176 | } |
| 7177 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7178 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7179 | bgp_regex_free (regex); |
| 7180 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7181 | } |
| 7182 | |
| 7183 | DEFUN (show_ip_bgp_regexp, |
| 7184 | show_ip_bgp_regexp_cmd, |
| 7185 | "show ip bgp regexp .LINE", |
| 7186 | SHOW_STR |
| 7187 | IP_STR |
| 7188 | BGP_STR |
| 7189 | "Display routes matching the AS path regular expression\n" |
| 7190 | "A regular-expression to match the BGP AS paths\n") |
| 7191 | { |
| 7192 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7193 | bgp_show_type_regexp); |
| 7194 | } |
| 7195 | |
| 7196 | DEFUN (show_ip_bgp_flap_regexp, |
| 7197 | show_ip_bgp_flap_regexp_cmd, |
| 7198 | "show ip bgp flap-statistics regexp .LINE", |
| 7199 | SHOW_STR |
| 7200 | IP_STR |
| 7201 | BGP_STR |
| 7202 | "Display flap statistics of routes\n" |
| 7203 | "Display routes matching the AS path regular expression\n" |
| 7204 | "A regular-expression to match the BGP AS paths\n") |
| 7205 | { |
| 7206 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7207 | bgp_show_type_flap_regexp); |
| 7208 | } |
| 7209 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7210 | ALIAS (show_ip_bgp_flap_regexp, |
| 7211 | show_ip_bgp_damp_flap_regexp_cmd, |
| 7212 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 7213 | SHOW_STR |
| 7214 | IP_STR |
| 7215 | BGP_STR |
| 7216 | "Display detailed information about dampening\n" |
| 7217 | "Display flap statistics of routes\n" |
| 7218 | "Display routes matching the AS path regular expression\n" |
| 7219 | "A regular-expression to match the BGP AS paths\n") |
| 7220 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7221 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7222 | show_ip_bgp_ipv4_regexp_cmd, |
| 7223 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7224 | SHOW_STR |
| 7225 | IP_STR |
| 7226 | BGP_STR |
| 7227 | "Address family\n" |
| 7228 | "Address Family modifier\n" |
| 7229 | "Address Family modifier\n" |
| 7230 | "Display routes matching the AS path regular expression\n" |
| 7231 | "A regular-expression to match the BGP AS paths\n") |
| 7232 | { |
| 7233 | if (strncmp (argv[0], "m", 1) == 0) |
| 7234 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7235 | bgp_show_type_regexp); |
| 7236 | |
| 7237 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7238 | bgp_show_type_regexp); |
| 7239 | } |
| 7240 | |
| 7241 | #ifdef HAVE_IPV6 |
| 7242 | DEFUN (show_bgp_regexp, |
| 7243 | show_bgp_regexp_cmd, |
| 7244 | "show bgp regexp .LINE", |
| 7245 | SHOW_STR |
| 7246 | BGP_STR |
| 7247 | "Display routes matching the AS path regular expression\n" |
| 7248 | "A regular-expression to match the BGP AS paths\n") |
| 7249 | { |
| 7250 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7251 | bgp_show_type_regexp); |
| 7252 | } |
| 7253 | |
| 7254 | ALIAS (show_bgp_regexp, |
| 7255 | show_bgp_ipv6_regexp_cmd, |
| 7256 | "show bgp ipv6 regexp .LINE", |
| 7257 | SHOW_STR |
| 7258 | BGP_STR |
| 7259 | "Address family\n" |
| 7260 | "Display routes matching the AS path regular expression\n" |
| 7261 | "A regular-expression to match the BGP AS paths\n") |
| 7262 | |
| 7263 | /* old command */ |
| 7264 | DEFUN (show_ipv6_bgp_regexp, |
| 7265 | show_ipv6_bgp_regexp_cmd, |
| 7266 | "show ipv6 bgp regexp .LINE", |
| 7267 | SHOW_STR |
| 7268 | IP_STR |
| 7269 | BGP_STR |
| 7270 | "Display routes matching the AS path regular expression\n" |
| 7271 | "A regular-expression to match the BGP AS paths\n") |
| 7272 | { |
| 7273 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7274 | bgp_show_type_regexp); |
| 7275 | } |
| 7276 | |
| 7277 | /* old command */ |
| 7278 | DEFUN (show_ipv6_mbgp_regexp, |
| 7279 | show_ipv6_mbgp_regexp_cmd, |
| 7280 | "show ipv6 mbgp regexp .LINE", |
| 7281 | SHOW_STR |
| 7282 | IP_STR |
| 7283 | BGP_STR |
| 7284 | "Display routes matching the AS path regular expression\n" |
| 7285 | "A regular-expression to match the MBGP AS paths\n") |
| 7286 | { |
| 7287 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7288 | bgp_show_type_regexp); |
| 7289 | } |
| 7290 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7291 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7292 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7293 | 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] | 7294 | safi_t safi, enum bgp_show_type type) |
| 7295 | { |
| 7296 | struct prefix_list *plist; |
| 7297 | |
| 7298 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7299 | if (plist == NULL) |
| 7300 | { |
| 7301 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7302 | prefix_list_str, VTY_NEWLINE); |
| 7303 | return CMD_WARNING; |
| 7304 | } |
| 7305 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7306 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7307 | } |
| 7308 | |
| 7309 | DEFUN (show_ip_bgp_prefix_list, |
| 7310 | show_ip_bgp_prefix_list_cmd, |
| 7311 | "show ip bgp prefix-list WORD", |
| 7312 | SHOW_STR |
| 7313 | IP_STR |
| 7314 | BGP_STR |
| 7315 | "Display routes conforming to the prefix-list\n" |
| 7316 | "IP prefix-list name\n") |
| 7317 | { |
| 7318 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7319 | bgp_show_type_prefix_list); |
| 7320 | } |
| 7321 | |
| 7322 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7323 | show_ip_bgp_flap_prefix_list_cmd, |
| 7324 | "show ip bgp flap-statistics prefix-list WORD", |
| 7325 | SHOW_STR |
| 7326 | IP_STR |
| 7327 | BGP_STR |
| 7328 | "Display flap statistics of routes\n" |
| 7329 | "Display routes conforming to the prefix-list\n" |
| 7330 | "IP prefix-list name\n") |
| 7331 | { |
| 7332 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7333 | bgp_show_type_flap_prefix_list); |
| 7334 | } |
| 7335 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7336 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 7337 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 7338 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 7339 | SHOW_STR |
| 7340 | IP_STR |
| 7341 | BGP_STR |
| 7342 | "Display detailed information about dampening\n" |
| 7343 | "Display flap statistics of routes\n" |
| 7344 | "Display routes conforming to the prefix-list\n" |
| 7345 | "IP prefix-list name\n") |
| 7346 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7347 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7348 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7349 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7350 | SHOW_STR |
| 7351 | IP_STR |
| 7352 | BGP_STR |
| 7353 | "Address family\n" |
| 7354 | "Address Family modifier\n" |
| 7355 | "Address Family modifier\n" |
| 7356 | "Display routes conforming to the prefix-list\n" |
| 7357 | "IP prefix-list name\n") |
| 7358 | { |
| 7359 | if (strncmp (argv[0], "m", 1) == 0) |
| 7360 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7361 | bgp_show_type_prefix_list); |
| 7362 | |
| 7363 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7364 | bgp_show_type_prefix_list); |
| 7365 | } |
| 7366 | |
| 7367 | #ifdef HAVE_IPV6 |
| 7368 | DEFUN (show_bgp_prefix_list, |
| 7369 | show_bgp_prefix_list_cmd, |
| 7370 | "show bgp prefix-list WORD", |
| 7371 | SHOW_STR |
| 7372 | BGP_STR |
| 7373 | "Display routes conforming to the prefix-list\n" |
| 7374 | "IPv6 prefix-list name\n") |
| 7375 | { |
| 7376 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7377 | bgp_show_type_prefix_list); |
| 7378 | } |
| 7379 | |
| 7380 | ALIAS (show_bgp_prefix_list, |
| 7381 | show_bgp_ipv6_prefix_list_cmd, |
| 7382 | "show bgp ipv6 prefix-list WORD", |
| 7383 | SHOW_STR |
| 7384 | BGP_STR |
| 7385 | "Address family\n" |
| 7386 | "Display routes conforming to the prefix-list\n" |
| 7387 | "IPv6 prefix-list name\n") |
| 7388 | |
| 7389 | /* old command */ |
| 7390 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7391 | show_ipv6_bgp_prefix_list_cmd, |
| 7392 | "show ipv6 bgp prefix-list WORD", |
| 7393 | SHOW_STR |
| 7394 | IPV6_STR |
| 7395 | BGP_STR |
| 7396 | "Display routes matching the prefix-list\n" |
| 7397 | "IPv6 prefix-list name\n") |
| 7398 | { |
| 7399 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7400 | bgp_show_type_prefix_list); |
| 7401 | } |
| 7402 | |
| 7403 | /* old command */ |
| 7404 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7405 | show_ipv6_mbgp_prefix_list_cmd, |
| 7406 | "show ipv6 mbgp prefix-list WORD", |
| 7407 | SHOW_STR |
| 7408 | IPV6_STR |
| 7409 | MBGP_STR |
| 7410 | "Display routes matching the prefix-list\n" |
| 7411 | "IPv6 prefix-list name\n") |
| 7412 | { |
| 7413 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7414 | bgp_show_type_prefix_list); |
| 7415 | } |
| 7416 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7417 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7418 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7419 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7420 | safi_t safi, enum bgp_show_type type) |
| 7421 | { |
| 7422 | struct as_list *as_list; |
| 7423 | |
| 7424 | as_list = as_list_lookup (filter); |
| 7425 | if (as_list == NULL) |
| 7426 | { |
| 7427 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7428 | return CMD_WARNING; |
| 7429 | } |
| 7430 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7431 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7432 | } |
| 7433 | |
| 7434 | DEFUN (show_ip_bgp_filter_list, |
| 7435 | show_ip_bgp_filter_list_cmd, |
| 7436 | "show ip bgp filter-list WORD", |
| 7437 | SHOW_STR |
| 7438 | IP_STR |
| 7439 | BGP_STR |
| 7440 | "Display routes conforming to the filter-list\n" |
| 7441 | "Regular expression access list name\n") |
| 7442 | { |
| 7443 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7444 | bgp_show_type_filter_list); |
| 7445 | } |
| 7446 | |
| 7447 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7448 | show_ip_bgp_flap_filter_list_cmd, |
| 7449 | "show ip bgp flap-statistics filter-list WORD", |
| 7450 | SHOW_STR |
| 7451 | IP_STR |
| 7452 | BGP_STR |
| 7453 | "Display flap statistics of routes\n" |
| 7454 | "Display routes conforming to the filter-list\n" |
| 7455 | "Regular expression access list name\n") |
| 7456 | { |
| 7457 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7458 | bgp_show_type_flap_filter_list); |
| 7459 | } |
| 7460 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7461 | ALIAS (show_ip_bgp_flap_filter_list, |
| 7462 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 7463 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 7464 | SHOW_STR |
| 7465 | IP_STR |
| 7466 | BGP_STR |
| 7467 | "Display detailed information about dampening\n" |
| 7468 | "Display flap statistics of routes\n" |
| 7469 | "Display routes conforming to the filter-list\n" |
| 7470 | "Regular expression access list name\n") |
| 7471 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7472 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7473 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7474 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7475 | SHOW_STR |
| 7476 | IP_STR |
| 7477 | BGP_STR |
| 7478 | "Address family\n" |
| 7479 | "Address Family modifier\n" |
| 7480 | "Address Family modifier\n" |
| 7481 | "Display routes conforming to the filter-list\n" |
| 7482 | "Regular expression access list name\n") |
| 7483 | { |
| 7484 | if (strncmp (argv[0], "m", 1) == 0) |
| 7485 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7486 | bgp_show_type_filter_list); |
| 7487 | |
| 7488 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7489 | bgp_show_type_filter_list); |
| 7490 | } |
| 7491 | |
| 7492 | #ifdef HAVE_IPV6 |
| 7493 | DEFUN (show_bgp_filter_list, |
| 7494 | show_bgp_filter_list_cmd, |
| 7495 | "show bgp filter-list WORD", |
| 7496 | SHOW_STR |
| 7497 | BGP_STR |
| 7498 | "Display routes conforming to the filter-list\n" |
| 7499 | "Regular expression access list name\n") |
| 7500 | { |
| 7501 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7502 | bgp_show_type_filter_list); |
| 7503 | } |
| 7504 | |
| 7505 | ALIAS (show_bgp_filter_list, |
| 7506 | show_bgp_ipv6_filter_list_cmd, |
| 7507 | "show bgp ipv6 filter-list WORD", |
| 7508 | SHOW_STR |
| 7509 | BGP_STR |
| 7510 | "Address family\n" |
| 7511 | "Display routes conforming to the filter-list\n" |
| 7512 | "Regular expression access list name\n") |
| 7513 | |
| 7514 | /* old command */ |
| 7515 | DEFUN (show_ipv6_bgp_filter_list, |
| 7516 | show_ipv6_bgp_filter_list_cmd, |
| 7517 | "show ipv6 bgp filter-list WORD", |
| 7518 | SHOW_STR |
| 7519 | IPV6_STR |
| 7520 | BGP_STR |
| 7521 | "Display routes conforming to the filter-list\n" |
| 7522 | "Regular expression access list name\n") |
| 7523 | { |
| 7524 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7525 | bgp_show_type_filter_list); |
| 7526 | } |
| 7527 | |
| 7528 | /* old command */ |
| 7529 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7530 | show_ipv6_mbgp_filter_list_cmd, |
| 7531 | "show ipv6 mbgp filter-list WORD", |
| 7532 | SHOW_STR |
| 7533 | IPV6_STR |
| 7534 | MBGP_STR |
| 7535 | "Display routes conforming to the filter-list\n" |
| 7536 | "Regular expression access list name\n") |
| 7537 | { |
| 7538 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7539 | bgp_show_type_filter_list); |
| 7540 | } |
| 7541 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7542 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7543 | DEFUN (show_ip_bgp_dampening_info, |
| 7544 | show_ip_bgp_dampening_params_cmd, |
| 7545 | "show ip bgp dampening parameters", |
| 7546 | SHOW_STR |
| 7547 | IP_STR |
| 7548 | BGP_STR |
| 7549 | "Display detailed information about dampening\n" |
| 7550 | "Display detail of configured dampening parameters\n") |
| 7551 | { |
| 7552 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 7553 | } |
| 7554 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7555 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7556 | 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] | 7557 | safi_t safi, enum bgp_show_type type) |
| 7558 | { |
| 7559 | struct route_map *rmap; |
| 7560 | |
| 7561 | rmap = route_map_lookup_by_name (rmap_str); |
| 7562 | if (! rmap) |
| 7563 | { |
| 7564 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7565 | rmap_str, VTY_NEWLINE); |
| 7566 | return CMD_WARNING; |
| 7567 | } |
| 7568 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7569 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7570 | } |
| 7571 | |
| 7572 | DEFUN (show_ip_bgp_route_map, |
| 7573 | show_ip_bgp_route_map_cmd, |
| 7574 | "show ip bgp route-map WORD", |
| 7575 | SHOW_STR |
| 7576 | IP_STR |
| 7577 | BGP_STR |
| 7578 | "Display routes matching the route-map\n" |
| 7579 | "A route-map to match on\n") |
| 7580 | { |
| 7581 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7582 | bgp_show_type_route_map); |
| 7583 | } |
| 7584 | |
| 7585 | DEFUN (show_ip_bgp_flap_route_map, |
| 7586 | show_ip_bgp_flap_route_map_cmd, |
| 7587 | "show ip bgp flap-statistics route-map WORD", |
| 7588 | SHOW_STR |
| 7589 | IP_STR |
| 7590 | BGP_STR |
| 7591 | "Display flap statistics of routes\n" |
| 7592 | "Display routes matching the route-map\n" |
| 7593 | "A route-map to match on\n") |
| 7594 | { |
| 7595 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7596 | bgp_show_type_flap_route_map); |
| 7597 | } |
| 7598 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7599 | ALIAS (show_ip_bgp_flap_route_map, |
| 7600 | show_ip_bgp_damp_flap_route_map_cmd, |
| 7601 | "show ip bgp dampening flap-statistics route-map WORD", |
| 7602 | SHOW_STR |
| 7603 | IP_STR |
| 7604 | BGP_STR |
| 7605 | "Display detailed information about dampening\n" |
| 7606 | "Display flap statistics of routes\n" |
| 7607 | "Display routes matching the route-map\n" |
| 7608 | "A route-map to match on\n") |
| 7609 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7610 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7611 | show_ip_bgp_ipv4_route_map_cmd, |
| 7612 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7613 | SHOW_STR |
| 7614 | IP_STR |
| 7615 | BGP_STR |
| 7616 | "Address family\n" |
| 7617 | "Address Family modifier\n" |
| 7618 | "Address Family modifier\n" |
| 7619 | "Display routes matching the route-map\n" |
| 7620 | "A route-map to match on\n") |
| 7621 | { |
| 7622 | if (strncmp (argv[0], "m", 1) == 0) |
| 7623 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7624 | bgp_show_type_route_map); |
| 7625 | |
| 7626 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7627 | bgp_show_type_route_map); |
| 7628 | } |
| 7629 | |
| 7630 | DEFUN (show_bgp_route_map, |
| 7631 | show_bgp_route_map_cmd, |
| 7632 | "show bgp route-map WORD", |
| 7633 | SHOW_STR |
| 7634 | BGP_STR |
| 7635 | "Display routes matching the route-map\n" |
| 7636 | "A route-map to match on\n") |
| 7637 | { |
| 7638 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7639 | bgp_show_type_route_map); |
| 7640 | } |
| 7641 | |
| 7642 | ALIAS (show_bgp_route_map, |
| 7643 | show_bgp_ipv6_route_map_cmd, |
| 7644 | "show bgp ipv6 route-map WORD", |
| 7645 | SHOW_STR |
| 7646 | BGP_STR |
| 7647 | "Address family\n" |
| 7648 | "Display routes matching the route-map\n" |
| 7649 | "A route-map to match on\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7650 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7651 | DEFUN (show_ip_bgp_cidr_only, |
| 7652 | show_ip_bgp_cidr_only_cmd, |
| 7653 | "show ip bgp cidr-only", |
| 7654 | SHOW_STR |
| 7655 | IP_STR |
| 7656 | BGP_STR |
| 7657 | "Display only routes with non-natural netmasks\n") |
| 7658 | { |
| 7659 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7660 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7661 | } |
| 7662 | |
| 7663 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7664 | show_ip_bgp_flap_cidr_only_cmd, |
| 7665 | "show ip bgp flap-statistics cidr-only", |
| 7666 | SHOW_STR |
| 7667 | IP_STR |
| 7668 | BGP_STR |
| 7669 | "Display flap statistics of routes\n" |
| 7670 | "Display only routes with non-natural netmasks\n") |
| 7671 | { |
| 7672 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7673 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7674 | } |
| 7675 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7676 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 7677 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 7678 | "show ip bgp dampening flap-statistics cidr-only", |
| 7679 | SHOW_STR |
| 7680 | IP_STR |
| 7681 | BGP_STR |
| 7682 | "Display detailed information about dampening\n" |
| 7683 | "Display flap statistics of routes\n" |
| 7684 | "Display only routes with non-natural netmasks\n") |
| 7685 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7686 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7687 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7688 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7689 | SHOW_STR |
| 7690 | IP_STR |
| 7691 | BGP_STR |
| 7692 | "Address family\n" |
| 7693 | "Address Family modifier\n" |
| 7694 | "Address Family modifier\n" |
| 7695 | "Display only routes with non-natural netmasks\n") |
| 7696 | { |
| 7697 | if (strncmp (argv[0], "m", 1) == 0) |
| 7698 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7699 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7700 | |
| 7701 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7702 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7703 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7704 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7705 | DEFUN (show_ip_bgp_community_all, |
| 7706 | show_ip_bgp_community_all_cmd, |
| 7707 | "show ip bgp community", |
| 7708 | SHOW_STR |
| 7709 | IP_STR |
| 7710 | BGP_STR |
| 7711 | "Display routes matching the communities\n") |
| 7712 | { |
| 7713 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7714 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7715 | } |
| 7716 | |
| 7717 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7718 | show_ip_bgp_ipv4_community_all_cmd, |
| 7719 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7720 | SHOW_STR |
| 7721 | IP_STR |
| 7722 | BGP_STR |
| 7723 | "Address family\n" |
| 7724 | "Address Family modifier\n" |
| 7725 | "Address Family modifier\n" |
| 7726 | "Display routes matching the communities\n") |
| 7727 | { |
| 7728 | if (strncmp (argv[0], "m", 1) == 0) |
| 7729 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7730 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7731 | |
| 7732 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7733 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7734 | } |
| 7735 | |
| 7736 | #ifdef HAVE_IPV6 |
| 7737 | DEFUN (show_bgp_community_all, |
| 7738 | show_bgp_community_all_cmd, |
| 7739 | "show bgp community", |
| 7740 | SHOW_STR |
| 7741 | BGP_STR |
| 7742 | "Display routes matching the communities\n") |
| 7743 | { |
| 7744 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7745 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7746 | } |
| 7747 | |
| 7748 | ALIAS (show_bgp_community_all, |
| 7749 | show_bgp_ipv6_community_all_cmd, |
| 7750 | "show bgp ipv6 community", |
| 7751 | SHOW_STR |
| 7752 | BGP_STR |
| 7753 | "Address family\n" |
| 7754 | "Display routes matching the communities\n") |
| 7755 | |
| 7756 | /* old command */ |
| 7757 | DEFUN (show_ipv6_bgp_community_all, |
| 7758 | show_ipv6_bgp_community_all_cmd, |
| 7759 | "show ipv6 bgp community", |
| 7760 | SHOW_STR |
| 7761 | IPV6_STR |
| 7762 | BGP_STR |
| 7763 | "Display routes matching the communities\n") |
| 7764 | { |
| 7765 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7766 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7767 | } |
| 7768 | |
| 7769 | /* old command */ |
| 7770 | DEFUN (show_ipv6_mbgp_community_all, |
| 7771 | show_ipv6_mbgp_community_all_cmd, |
| 7772 | "show ipv6 mbgp community", |
| 7773 | SHOW_STR |
| 7774 | IPV6_STR |
| 7775 | MBGP_STR |
| 7776 | "Display routes matching the communities\n") |
| 7777 | { |
| 7778 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7779 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7780 | } |
| 7781 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7782 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7783 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7784 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7785 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7786 | { |
| 7787 | struct community *com; |
| 7788 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7789 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7790 | int i; |
| 7791 | char *str; |
| 7792 | int first = 0; |
| 7793 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7794 | /* BGP structure lookup */ |
| 7795 | if (view_name) |
| 7796 | { |
| 7797 | bgp = bgp_lookup_by_name (view_name); |
| 7798 | if (bgp == NULL) |
| 7799 | { |
| 7800 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7801 | return CMD_WARNING; |
| 7802 | } |
| 7803 | } |
| 7804 | else |
| 7805 | { |
| 7806 | bgp = bgp_get_default (); |
| 7807 | if (bgp == NULL) |
| 7808 | { |
| 7809 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7810 | return CMD_WARNING; |
| 7811 | } |
| 7812 | } |
| 7813 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7814 | b = buffer_new (1024); |
| 7815 | for (i = 0; i < argc; i++) |
| 7816 | { |
| 7817 | if (first) |
| 7818 | buffer_putc (b, ' '); |
| 7819 | else |
| 7820 | { |
| 7821 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7822 | continue; |
| 7823 | first = 1; |
| 7824 | } |
| 7825 | |
| 7826 | buffer_putstr (b, argv[i]); |
| 7827 | } |
| 7828 | buffer_putc (b, '\0'); |
| 7829 | |
| 7830 | str = buffer_getstr (b); |
| 7831 | buffer_free (b); |
| 7832 | |
| 7833 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7834 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7835 | if (! com) |
| 7836 | { |
| 7837 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7838 | return CMD_WARNING; |
| 7839 | } |
| 7840 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7841 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7842 | (exact ? bgp_show_type_community_exact : |
| 7843 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7844 | } |
| 7845 | |
| 7846 | DEFUN (show_ip_bgp_community, |
| 7847 | show_ip_bgp_community_cmd, |
| 7848 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7849 | SHOW_STR |
| 7850 | IP_STR |
| 7851 | BGP_STR |
| 7852 | "Display routes matching the communities\n" |
| 7853 | "community number\n" |
| 7854 | "Do not send outside local AS (well-known community)\n" |
| 7855 | "Do not advertise to any peer (well-known community)\n" |
| 7856 | "Do not export to next AS (well-known community)\n") |
| 7857 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7858 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7859 | } |
| 7860 | |
| 7861 | ALIAS (show_ip_bgp_community, |
| 7862 | show_ip_bgp_community2_cmd, |
| 7863 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7864 | SHOW_STR |
| 7865 | IP_STR |
| 7866 | BGP_STR |
| 7867 | "Display routes matching the communities\n" |
| 7868 | "community number\n" |
| 7869 | "Do not send outside local AS (well-known community)\n" |
| 7870 | "Do not advertise to any peer (well-known community)\n" |
| 7871 | "Do not export to next AS (well-known community)\n" |
| 7872 | "community number\n" |
| 7873 | "Do not send outside local AS (well-known community)\n" |
| 7874 | "Do not advertise to any peer (well-known community)\n" |
| 7875 | "Do not export to next AS (well-known community)\n") |
| 7876 | |
| 7877 | ALIAS (show_ip_bgp_community, |
| 7878 | show_ip_bgp_community3_cmd, |
| 7879 | "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)", |
| 7880 | SHOW_STR |
| 7881 | IP_STR |
| 7882 | BGP_STR |
| 7883 | "Display routes matching the communities\n" |
| 7884 | "community number\n" |
| 7885 | "Do not send outside local AS (well-known community)\n" |
| 7886 | "Do not advertise to any peer (well-known community)\n" |
| 7887 | "Do not export to next AS (well-known community)\n" |
| 7888 | "community number\n" |
| 7889 | "Do not send outside local AS (well-known community)\n" |
| 7890 | "Do not advertise to any peer (well-known community)\n" |
| 7891 | "Do not export to next AS (well-known community)\n" |
| 7892 | "community number\n" |
| 7893 | "Do not send outside local AS (well-known community)\n" |
| 7894 | "Do not advertise to any peer (well-known community)\n" |
| 7895 | "Do not export to next AS (well-known community)\n") |
| 7896 | |
| 7897 | ALIAS (show_ip_bgp_community, |
| 7898 | show_ip_bgp_community4_cmd, |
| 7899 | "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)", |
| 7900 | SHOW_STR |
| 7901 | IP_STR |
| 7902 | BGP_STR |
| 7903 | "Display routes matching the communities\n" |
| 7904 | "community number\n" |
| 7905 | "Do not send outside local AS (well-known community)\n" |
| 7906 | "Do not advertise to any peer (well-known community)\n" |
| 7907 | "Do not export to next AS (well-known community)\n" |
| 7908 | "community number\n" |
| 7909 | "Do not send outside local AS (well-known community)\n" |
| 7910 | "Do not advertise to any peer (well-known community)\n" |
| 7911 | "Do not export to next AS (well-known community)\n" |
| 7912 | "community number\n" |
| 7913 | "Do not send outside local AS (well-known community)\n" |
| 7914 | "Do not advertise to any peer (well-known community)\n" |
| 7915 | "Do not export to next AS (well-known community)\n" |
| 7916 | "community number\n" |
| 7917 | "Do not send outside local AS (well-known community)\n" |
| 7918 | "Do not advertise to any peer (well-known community)\n" |
| 7919 | "Do not export to next AS (well-known community)\n") |
| 7920 | |
| 7921 | DEFUN (show_ip_bgp_ipv4_community, |
| 7922 | show_ip_bgp_ipv4_community_cmd, |
| 7923 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7924 | SHOW_STR |
| 7925 | IP_STR |
| 7926 | BGP_STR |
| 7927 | "Address family\n" |
| 7928 | "Address Family modifier\n" |
| 7929 | "Address Family modifier\n" |
| 7930 | "Display routes matching the communities\n" |
| 7931 | "community number\n" |
| 7932 | "Do not send outside local AS (well-known community)\n" |
| 7933 | "Do not advertise to any peer (well-known community)\n" |
| 7934 | "Do not export to next AS (well-known community)\n") |
| 7935 | { |
| 7936 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7937 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7938 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7939 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7940 | } |
| 7941 | |
| 7942 | ALIAS (show_ip_bgp_ipv4_community, |
| 7943 | show_ip_bgp_ipv4_community2_cmd, |
| 7944 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7945 | SHOW_STR |
| 7946 | IP_STR |
| 7947 | BGP_STR |
| 7948 | "Address family\n" |
| 7949 | "Address Family modifier\n" |
| 7950 | "Address Family modifier\n" |
| 7951 | "Display routes matching the communities\n" |
| 7952 | "community number\n" |
| 7953 | "Do not send outside local AS (well-known community)\n" |
| 7954 | "Do not advertise to any peer (well-known community)\n" |
| 7955 | "Do not export to next AS (well-known community)\n" |
| 7956 | "community number\n" |
| 7957 | "Do not send outside local AS (well-known community)\n" |
| 7958 | "Do not advertise to any peer (well-known community)\n" |
| 7959 | "Do not export to next AS (well-known community)\n") |
| 7960 | |
| 7961 | ALIAS (show_ip_bgp_ipv4_community, |
| 7962 | show_ip_bgp_ipv4_community3_cmd, |
| 7963 | "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)", |
| 7964 | SHOW_STR |
| 7965 | IP_STR |
| 7966 | BGP_STR |
| 7967 | "Address family\n" |
| 7968 | "Address Family modifier\n" |
| 7969 | "Address Family modifier\n" |
| 7970 | "Display routes matching the communities\n" |
| 7971 | "community number\n" |
| 7972 | "Do not send outside local AS (well-known community)\n" |
| 7973 | "Do not advertise to any peer (well-known community)\n" |
| 7974 | "Do not export to next AS (well-known community)\n" |
| 7975 | "community number\n" |
| 7976 | "Do not send outside local AS (well-known community)\n" |
| 7977 | "Do not advertise to any peer (well-known community)\n" |
| 7978 | "Do not export to next AS (well-known community)\n" |
| 7979 | "community number\n" |
| 7980 | "Do not send outside local AS (well-known community)\n" |
| 7981 | "Do not advertise to any peer (well-known community)\n" |
| 7982 | "Do not export to next AS (well-known community)\n") |
| 7983 | |
| 7984 | ALIAS (show_ip_bgp_ipv4_community, |
| 7985 | show_ip_bgp_ipv4_community4_cmd, |
| 7986 | "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)", |
| 7987 | SHOW_STR |
| 7988 | IP_STR |
| 7989 | BGP_STR |
| 7990 | "Address family\n" |
| 7991 | "Address Family modifier\n" |
| 7992 | "Address Family modifier\n" |
| 7993 | "Display routes matching the communities\n" |
| 7994 | "community number\n" |
| 7995 | "Do not send outside local AS (well-known community)\n" |
| 7996 | "Do not advertise to any peer (well-known community)\n" |
| 7997 | "Do not export to next AS (well-known community)\n" |
| 7998 | "community number\n" |
| 7999 | "Do not send outside local AS (well-known community)\n" |
| 8000 | "Do not advertise to any peer (well-known community)\n" |
| 8001 | "Do not export to next AS (well-known community)\n" |
| 8002 | "community number\n" |
| 8003 | "Do not send outside local AS (well-known community)\n" |
| 8004 | "Do not advertise to any peer (well-known community)\n" |
| 8005 | "Do not export to next AS (well-known community)\n" |
| 8006 | "community number\n" |
| 8007 | "Do not send outside local AS (well-known community)\n" |
| 8008 | "Do not advertise to any peer (well-known community)\n" |
| 8009 | "Do not export to next AS (well-known community)\n") |
| 8010 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8011 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 8012 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8013 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8014 | SHOW_STR |
| 8015 | BGP_STR |
| 8016 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8017 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8018 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8019 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8020 | "Address Family modifier\n" |
| 8021 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8022 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8023 | { |
| 8024 | int afi; |
| 8025 | int safi; |
| 8026 | struct bgp *bgp; |
| 8027 | |
| 8028 | /* BGP structure lookup. */ |
| 8029 | bgp = bgp_lookup_by_name (argv[0]); |
| 8030 | if (bgp == NULL) |
| 8031 | { |
| 8032 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8033 | return CMD_WARNING; |
| 8034 | } |
| 8035 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8036 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 8037 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8038 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 8039 | } |
| 8040 | |
| 8041 | DEFUN (show_bgp_view_afi_safi_community, |
| 8042 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8043 | "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] | 8044 | SHOW_STR |
| 8045 | BGP_STR |
| 8046 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8047 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8048 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8049 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8050 | "Address family modifier\n" |
| 8051 | "Address family modifier\n" |
| 8052 | "Display routes matching the communities\n" |
| 8053 | "community number\n" |
| 8054 | "Do not send outside local AS (well-known community)\n" |
| 8055 | "Do not advertise to any peer (well-known community)\n" |
| 8056 | "Do not export to next AS (well-known community)\n") |
| 8057 | { |
| 8058 | int afi; |
| 8059 | int safi; |
| 8060 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8061 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 8062 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 8063 | 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] | 8064 | } |
| 8065 | |
| 8066 | ALIAS (show_bgp_view_afi_safi_community, |
| 8067 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8068 | "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] | 8069 | SHOW_STR |
| 8070 | BGP_STR |
| 8071 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8072 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8073 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8074 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8075 | "Address family modifier\n" |
| 8076 | "Address family modifier\n" |
| 8077 | "Display routes matching the communities\n" |
| 8078 | "community number\n" |
| 8079 | "Do not send outside local AS (well-known community)\n" |
| 8080 | "Do not advertise to any peer (well-known community)\n" |
| 8081 | "Do not export to next AS (well-known community)\n" |
| 8082 | "community number\n" |
| 8083 | "Do not send outside local AS (well-known community)\n" |
| 8084 | "Do not advertise to any peer (well-known community)\n" |
| 8085 | "Do not export to next AS (well-known community)\n") |
| 8086 | |
| 8087 | ALIAS (show_bgp_view_afi_safi_community, |
| 8088 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8089 | "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] | 8090 | SHOW_STR |
| 8091 | BGP_STR |
| 8092 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8093 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8094 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8095 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8096 | "Address family modifier\n" |
| 8097 | "Address family modifier\n" |
| 8098 | "Display routes matching the communities\n" |
| 8099 | "community number\n" |
| 8100 | "Do not send outside local AS (well-known community)\n" |
| 8101 | "Do not advertise to any peer (well-known community)\n" |
| 8102 | "Do not export to next AS (well-known community)\n" |
| 8103 | "community number\n" |
| 8104 | "Do not send outside local AS (well-known community)\n" |
| 8105 | "Do not advertise to any peer (well-known community)\n" |
| 8106 | "Do not export to next AS (well-known community)\n" |
| 8107 | "community number\n" |
| 8108 | "Do not send outside local AS (well-known community)\n" |
| 8109 | "Do not advertise to any peer (well-known community)\n" |
| 8110 | "Do not export to next AS (well-known community)\n") |
| 8111 | |
| 8112 | ALIAS (show_bgp_view_afi_safi_community, |
| 8113 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8114 | "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] | 8115 | SHOW_STR |
| 8116 | BGP_STR |
| 8117 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8118 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8119 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8120 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8121 | "Address family modifier\n" |
| 8122 | "Address family modifier\n" |
| 8123 | "Display routes matching the communities\n" |
| 8124 | "community number\n" |
| 8125 | "Do not send outside local AS (well-known community)\n" |
| 8126 | "Do not advertise to any peer (well-known community)\n" |
| 8127 | "Do not export to next AS (well-known community)\n" |
| 8128 | "community number\n" |
| 8129 | "Do not send outside local AS (well-known community)\n" |
| 8130 | "Do not advertise to any peer (well-known community)\n" |
| 8131 | "Do not export to next AS (well-known community)\n" |
| 8132 | "community number\n" |
| 8133 | "Do not send outside local AS (well-known community)\n" |
| 8134 | "Do not advertise to any peer (well-known community)\n" |
| 8135 | "Do not export to next AS (well-known community)\n" |
| 8136 | "community number\n" |
| 8137 | "Do not send outside local AS (well-known community)\n" |
| 8138 | "Do not advertise to any peer (well-known community)\n" |
| 8139 | "Do not export to next AS (well-known community)\n") |
| 8140 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8141 | DEFUN (show_ip_bgp_community_exact, |
| 8142 | show_ip_bgp_community_exact_cmd, |
| 8143 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8144 | SHOW_STR |
| 8145 | IP_STR |
| 8146 | BGP_STR |
| 8147 | "Display routes matching the communities\n" |
| 8148 | "community number\n" |
| 8149 | "Do not send outside local AS (well-known community)\n" |
| 8150 | "Do not advertise to any peer (well-known community)\n" |
| 8151 | "Do not export to next AS (well-known community)\n" |
| 8152 | "Exact match of the communities") |
| 8153 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8154 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8155 | } |
| 8156 | |
| 8157 | ALIAS (show_ip_bgp_community_exact, |
| 8158 | show_ip_bgp_community2_exact_cmd, |
| 8159 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8160 | SHOW_STR |
| 8161 | IP_STR |
| 8162 | BGP_STR |
| 8163 | "Display routes matching the communities\n" |
| 8164 | "community number\n" |
| 8165 | "Do not send outside local AS (well-known community)\n" |
| 8166 | "Do not advertise to any peer (well-known community)\n" |
| 8167 | "Do not export to next AS (well-known community)\n" |
| 8168 | "community number\n" |
| 8169 | "Do not send outside local AS (well-known community)\n" |
| 8170 | "Do not advertise to any peer (well-known community)\n" |
| 8171 | "Do not export to next AS (well-known community)\n" |
| 8172 | "Exact match of the communities") |
| 8173 | |
| 8174 | ALIAS (show_ip_bgp_community_exact, |
| 8175 | show_ip_bgp_community3_exact_cmd, |
| 8176 | "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", |
| 8177 | SHOW_STR |
| 8178 | IP_STR |
| 8179 | BGP_STR |
| 8180 | "Display routes matching the communities\n" |
| 8181 | "community number\n" |
| 8182 | "Do not send outside local AS (well-known community)\n" |
| 8183 | "Do not advertise to any peer (well-known community)\n" |
| 8184 | "Do not export to next AS (well-known community)\n" |
| 8185 | "community number\n" |
| 8186 | "Do not send outside local AS (well-known community)\n" |
| 8187 | "Do not advertise to any peer (well-known community)\n" |
| 8188 | "Do not export to next AS (well-known community)\n" |
| 8189 | "community number\n" |
| 8190 | "Do not send outside local AS (well-known community)\n" |
| 8191 | "Do not advertise to any peer (well-known community)\n" |
| 8192 | "Do not export to next AS (well-known community)\n" |
| 8193 | "Exact match of the communities") |
| 8194 | |
| 8195 | ALIAS (show_ip_bgp_community_exact, |
| 8196 | show_ip_bgp_community4_exact_cmd, |
| 8197 | "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", |
| 8198 | SHOW_STR |
| 8199 | IP_STR |
| 8200 | BGP_STR |
| 8201 | "Display routes matching the communities\n" |
| 8202 | "community number\n" |
| 8203 | "Do not send outside local AS (well-known community)\n" |
| 8204 | "Do not advertise to any peer (well-known community)\n" |
| 8205 | "Do not export to next AS (well-known community)\n" |
| 8206 | "community number\n" |
| 8207 | "Do not send outside local AS (well-known community)\n" |
| 8208 | "Do not advertise to any peer (well-known community)\n" |
| 8209 | "Do not export to next AS (well-known community)\n" |
| 8210 | "community number\n" |
| 8211 | "Do not send outside local AS (well-known community)\n" |
| 8212 | "Do not advertise to any peer (well-known community)\n" |
| 8213 | "Do not export to next AS (well-known community)\n" |
| 8214 | "community number\n" |
| 8215 | "Do not send outside local AS (well-known community)\n" |
| 8216 | "Do not advertise to any peer (well-known community)\n" |
| 8217 | "Do not export to next AS (well-known community)\n" |
| 8218 | "Exact match of the communities") |
| 8219 | |
| 8220 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8221 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8222 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8223 | SHOW_STR |
| 8224 | IP_STR |
| 8225 | BGP_STR |
| 8226 | "Address family\n" |
| 8227 | "Address Family modifier\n" |
| 8228 | "Address Family modifier\n" |
| 8229 | "Display routes matching the communities\n" |
| 8230 | "community number\n" |
| 8231 | "Do not send outside local AS (well-known community)\n" |
| 8232 | "Do not advertise to any peer (well-known community)\n" |
| 8233 | "Do not export to next AS (well-known community)\n" |
| 8234 | "Exact match of the communities") |
| 8235 | { |
| 8236 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8237 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8238 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8239 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8240 | } |
| 8241 | |
| 8242 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8243 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8244 | "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", |
| 8245 | SHOW_STR |
| 8246 | IP_STR |
| 8247 | BGP_STR |
| 8248 | "Address family\n" |
| 8249 | "Address Family modifier\n" |
| 8250 | "Address Family modifier\n" |
| 8251 | "Display routes matching the communities\n" |
| 8252 | "community number\n" |
| 8253 | "Do not send outside local AS (well-known community)\n" |
| 8254 | "Do not advertise to any peer (well-known community)\n" |
| 8255 | "Do not export to next AS (well-known community)\n" |
| 8256 | "community number\n" |
| 8257 | "Do not send outside local AS (well-known community)\n" |
| 8258 | "Do not advertise to any peer (well-known community)\n" |
| 8259 | "Do not export to next AS (well-known community)\n" |
| 8260 | "Exact match of the communities") |
| 8261 | |
| 8262 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8263 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8264 | "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", |
| 8265 | SHOW_STR |
| 8266 | IP_STR |
| 8267 | BGP_STR |
| 8268 | "Address family\n" |
| 8269 | "Address Family modifier\n" |
| 8270 | "Address Family modifier\n" |
| 8271 | "Display routes matching the communities\n" |
| 8272 | "community number\n" |
| 8273 | "Do not send outside local AS (well-known community)\n" |
| 8274 | "Do not advertise to any peer (well-known community)\n" |
| 8275 | "Do not export to next AS (well-known community)\n" |
| 8276 | "community number\n" |
| 8277 | "Do not send outside local AS (well-known community)\n" |
| 8278 | "Do not advertise to any peer (well-known community)\n" |
| 8279 | "Do not export to next AS (well-known community)\n" |
| 8280 | "community number\n" |
| 8281 | "Do not send outside local AS (well-known community)\n" |
| 8282 | "Do not advertise to any peer (well-known community)\n" |
| 8283 | "Do not export to next AS (well-known community)\n" |
| 8284 | "Exact match of the communities") |
| 8285 | |
| 8286 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8287 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8288 | "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", |
| 8289 | SHOW_STR |
| 8290 | IP_STR |
| 8291 | BGP_STR |
| 8292 | "Address family\n" |
| 8293 | "Address Family modifier\n" |
| 8294 | "Address Family modifier\n" |
| 8295 | "Display routes matching the communities\n" |
| 8296 | "community number\n" |
| 8297 | "Do not send outside local AS (well-known community)\n" |
| 8298 | "Do not advertise to any peer (well-known community)\n" |
| 8299 | "Do not export to next AS (well-known community)\n" |
| 8300 | "community number\n" |
| 8301 | "Do not send outside local AS (well-known community)\n" |
| 8302 | "Do not advertise to any peer (well-known community)\n" |
| 8303 | "Do not export to next AS (well-known community)\n" |
| 8304 | "community number\n" |
| 8305 | "Do not send outside local AS (well-known community)\n" |
| 8306 | "Do not advertise to any peer (well-known community)\n" |
| 8307 | "Do not export to next AS (well-known community)\n" |
| 8308 | "community number\n" |
| 8309 | "Do not send outside local AS (well-known community)\n" |
| 8310 | "Do not advertise to any peer (well-known community)\n" |
| 8311 | "Do not export to next AS (well-known community)\n" |
| 8312 | "Exact match of the communities") |
| 8313 | |
| 8314 | #ifdef HAVE_IPV6 |
| 8315 | DEFUN (show_bgp_community, |
| 8316 | show_bgp_community_cmd, |
| 8317 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8318 | SHOW_STR |
| 8319 | BGP_STR |
| 8320 | "Display routes matching the communities\n" |
| 8321 | "community number\n" |
| 8322 | "Do not send outside local AS (well-known community)\n" |
| 8323 | "Do not advertise to any peer (well-known community)\n" |
| 8324 | "Do not export to next AS (well-known community)\n") |
| 8325 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8326 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8327 | } |
| 8328 | |
| 8329 | ALIAS (show_bgp_community, |
| 8330 | show_bgp_ipv6_community_cmd, |
| 8331 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8332 | SHOW_STR |
| 8333 | BGP_STR |
| 8334 | "Address family\n" |
| 8335 | "Display routes matching the communities\n" |
| 8336 | "community number\n" |
| 8337 | "Do not send outside local AS (well-known community)\n" |
| 8338 | "Do not advertise to any peer (well-known community)\n" |
| 8339 | "Do not export to next AS (well-known community)\n") |
| 8340 | |
| 8341 | ALIAS (show_bgp_community, |
| 8342 | show_bgp_community2_cmd, |
| 8343 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8344 | SHOW_STR |
| 8345 | BGP_STR |
| 8346 | "Display routes matching the communities\n" |
| 8347 | "community number\n" |
| 8348 | "Do not send outside local AS (well-known community)\n" |
| 8349 | "Do not advertise to any peer (well-known community)\n" |
| 8350 | "Do not export to next AS (well-known community)\n" |
| 8351 | "community number\n" |
| 8352 | "Do not send outside local AS (well-known community)\n" |
| 8353 | "Do not advertise to any peer (well-known community)\n" |
| 8354 | "Do not export to next AS (well-known community)\n") |
| 8355 | |
| 8356 | ALIAS (show_bgp_community, |
| 8357 | show_bgp_ipv6_community2_cmd, |
| 8358 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8359 | SHOW_STR |
| 8360 | BGP_STR |
| 8361 | "Address family\n" |
| 8362 | "Display routes matching the communities\n" |
| 8363 | "community number\n" |
| 8364 | "Do not send outside local AS (well-known community)\n" |
| 8365 | "Do not advertise to any peer (well-known community)\n" |
| 8366 | "Do not export to next AS (well-known community)\n" |
| 8367 | "community number\n" |
| 8368 | "Do not send outside local AS (well-known community)\n" |
| 8369 | "Do not advertise to any peer (well-known community)\n" |
| 8370 | "Do not export to next AS (well-known community)\n") |
| 8371 | |
| 8372 | ALIAS (show_bgp_community, |
| 8373 | show_bgp_community3_cmd, |
| 8374 | "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)", |
| 8375 | SHOW_STR |
| 8376 | BGP_STR |
| 8377 | "Display routes matching the communities\n" |
| 8378 | "community number\n" |
| 8379 | "Do not send outside local AS (well-known community)\n" |
| 8380 | "Do not advertise to any peer (well-known community)\n" |
| 8381 | "Do not export to next AS (well-known community)\n" |
| 8382 | "community number\n" |
| 8383 | "Do not send outside local AS (well-known community)\n" |
| 8384 | "Do not advertise to any peer (well-known community)\n" |
| 8385 | "Do not export to next AS (well-known community)\n" |
| 8386 | "community number\n" |
| 8387 | "Do not send outside local AS (well-known community)\n" |
| 8388 | "Do not advertise to any peer (well-known community)\n" |
| 8389 | "Do not export to next AS (well-known community)\n") |
| 8390 | |
| 8391 | ALIAS (show_bgp_community, |
| 8392 | show_bgp_ipv6_community3_cmd, |
| 8393 | "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)", |
| 8394 | SHOW_STR |
| 8395 | BGP_STR |
| 8396 | "Address family\n" |
| 8397 | "Display routes matching the communities\n" |
| 8398 | "community number\n" |
| 8399 | "Do not send outside local AS (well-known community)\n" |
| 8400 | "Do not advertise to any peer (well-known community)\n" |
| 8401 | "Do not export to next AS (well-known community)\n" |
| 8402 | "community number\n" |
| 8403 | "Do not send outside local AS (well-known community)\n" |
| 8404 | "Do not advertise to any peer (well-known community)\n" |
| 8405 | "Do not export to next AS (well-known community)\n" |
| 8406 | "community number\n" |
| 8407 | "Do not send outside local AS (well-known community)\n" |
| 8408 | "Do not advertise to any peer (well-known community)\n" |
| 8409 | "Do not export to next AS (well-known community)\n") |
| 8410 | |
| 8411 | ALIAS (show_bgp_community, |
| 8412 | show_bgp_community4_cmd, |
| 8413 | "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)", |
| 8414 | SHOW_STR |
| 8415 | BGP_STR |
| 8416 | "Display routes matching the communities\n" |
| 8417 | "community number\n" |
| 8418 | "Do not send outside local AS (well-known community)\n" |
| 8419 | "Do not advertise to any peer (well-known community)\n" |
| 8420 | "Do not export to next AS (well-known community)\n" |
| 8421 | "community number\n" |
| 8422 | "Do not send outside local AS (well-known community)\n" |
| 8423 | "Do not advertise to any peer (well-known community)\n" |
| 8424 | "Do not export to next AS (well-known community)\n" |
| 8425 | "community number\n" |
| 8426 | "Do not send outside local AS (well-known community)\n" |
| 8427 | "Do not advertise to any peer (well-known community)\n" |
| 8428 | "Do not export to next AS (well-known community)\n" |
| 8429 | "community number\n" |
| 8430 | "Do not send outside local AS (well-known community)\n" |
| 8431 | "Do not advertise to any peer (well-known community)\n" |
| 8432 | "Do not export to next AS (well-known community)\n") |
| 8433 | |
| 8434 | ALIAS (show_bgp_community, |
| 8435 | show_bgp_ipv6_community4_cmd, |
| 8436 | "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)", |
| 8437 | SHOW_STR |
| 8438 | BGP_STR |
| 8439 | "Address family\n" |
| 8440 | "Display routes matching the communities\n" |
| 8441 | "community number\n" |
| 8442 | "Do not send outside local AS (well-known community)\n" |
| 8443 | "Do not advertise to any peer (well-known community)\n" |
| 8444 | "Do not export to next AS (well-known community)\n" |
| 8445 | "community number\n" |
| 8446 | "Do not send outside local AS (well-known community)\n" |
| 8447 | "Do not advertise to any peer (well-known community)\n" |
| 8448 | "Do not export to next AS (well-known community)\n" |
| 8449 | "community number\n" |
| 8450 | "Do not send outside local AS (well-known community)\n" |
| 8451 | "Do not advertise to any peer (well-known community)\n" |
| 8452 | "Do not export to next AS (well-known community)\n" |
| 8453 | "community number\n" |
| 8454 | "Do not send outside local AS (well-known community)\n" |
| 8455 | "Do not advertise to any peer (well-known community)\n" |
| 8456 | "Do not export to next AS (well-known community)\n") |
| 8457 | |
| 8458 | /* old command */ |
| 8459 | DEFUN (show_ipv6_bgp_community, |
| 8460 | show_ipv6_bgp_community_cmd, |
| 8461 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8462 | SHOW_STR |
| 8463 | IPV6_STR |
| 8464 | BGP_STR |
| 8465 | "Display routes matching the communities\n" |
| 8466 | "community number\n" |
| 8467 | "Do not send outside local AS (well-known community)\n" |
| 8468 | "Do not advertise to any peer (well-known community)\n" |
| 8469 | "Do not export to next AS (well-known community)\n") |
| 8470 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8471 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8472 | } |
| 8473 | |
| 8474 | /* old command */ |
| 8475 | ALIAS (show_ipv6_bgp_community, |
| 8476 | show_ipv6_bgp_community2_cmd, |
| 8477 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8478 | SHOW_STR |
| 8479 | IPV6_STR |
| 8480 | BGP_STR |
| 8481 | "Display routes matching the communities\n" |
| 8482 | "community number\n" |
| 8483 | "Do not send outside local AS (well-known community)\n" |
| 8484 | "Do not advertise to any peer (well-known community)\n" |
| 8485 | "Do not export to next AS (well-known community)\n" |
| 8486 | "community number\n" |
| 8487 | "Do not send outside local AS (well-known community)\n" |
| 8488 | "Do not advertise to any peer (well-known community)\n" |
| 8489 | "Do not export to next AS (well-known community)\n") |
| 8490 | |
| 8491 | /* old command */ |
| 8492 | ALIAS (show_ipv6_bgp_community, |
| 8493 | show_ipv6_bgp_community3_cmd, |
| 8494 | "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)", |
| 8495 | SHOW_STR |
| 8496 | IPV6_STR |
| 8497 | BGP_STR |
| 8498 | "Display routes matching the communities\n" |
| 8499 | "community number\n" |
| 8500 | "Do not send outside local AS (well-known community)\n" |
| 8501 | "Do not advertise to any peer (well-known community)\n" |
| 8502 | "Do not export to next AS (well-known community)\n" |
| 8503 | "community number\n" |
| 8504 | "Do not send outside local AS (well-known community)\n" |
| 8505 | "Do not advertise to any peer (well-known community)\n" |
| 8506 | "Do not export to next AS (well-known community)\n" |
| 8507 | "community number\n" |
| 8508 | "Do not send outside local AS (well-known community)\n" |
| 8509 | "Do not advertise to any peer (well-known community)\n" |
| 8510 | "Do not export to next AS (well-known community)\n") |
| 8511 | |
| 8512 | /* old command */ |
| 8513 | ALIAS (show_ipv6_bgp_community, |
| 8514 | show_ipv6_bgp_community4_cmd, |
| 8515 | "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)", |
| 8516 | SHOW_STR |
| 8517 | IPV6_STR |
| 8518 | BGP_STR |
| 8519 | "Display routes matching the communities\n" |
| 8520 | "community number\n" |
| 8521 | "Do not send outside local AS (well-known community)\n" |
| 8522 | "Do not advertise to any peer (well-known community)\n" |
| 8523 | "Do not export to next AS (well-known community)\n" |
| 8524 | "community number\n" |
| 8525 | "Do not send outside local AS (well-known community)\n" |
| 8526 | "Do not advertise to any peer (well-known community)\n" |
| 8527 | "Do not export to next AS (well-known community)\n" |
| 8528 | "community number\n" |
| 8529 | "Do not send outside local AS (well-known community)\n" |
| 8530 | "Do not advertise to any peer (well-known community)\n" |
| 8531 | "Do not export to next AS (well-known community)\n" |
| 8532 | "community number\n" |
| 8533 | "Do not send outside local AS (well-known community)\n" |
| 8534 | "Do not advertise to any peer (well-known community)\n" |
| 8535 | "Do not export to next AS (well-known community)\n") |
| 8536 | |
| 8537 | DEFUN (show_bgp_community_exact, |
| 8538 | show_bgp_community_exact_cmd, |
| 8539 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8540 | SHOW_STR |
| 8541 | BGP_STR |
| 8542 | "Display routes matching the communities\n" |
| 8543 | "community number\n" |
| 8544 | "Do not send outside local AS (well-known community)\n" |
| 8545 | "Do not advertise to any peer (well-known community)\n" |
| 8546 | "Do not export to next AS (well-known community)\n" |
| 8547 | "Exact match of the communities") |
| 8548 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8549 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8550 | } |
| 8551 | |
| 8552 | ALIAS (show_bgp_community_exact, |
| 8553 | show_bgp_ipv6_community_exact_cmd, |
| 8554 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8555 | SHOW_STR |
| 8556 | BGP_STR |
| 8557 | "Address family\n" |
| 8558 | "Display routes matching the communities\n" |
| 8559 | "community number\n" |
| 8560 | "Do not send outside local AS (well-known community)\n" |
| 8561 | "Do not advertise to any peer (well-known community)\n" |
| 8562 | "Do not export to next AS (well-known community)\n" |
| 8563 | "Exact match of the communities") |
| 8564 | |
| 8565 | ALIAS (show_bgp_community_exact, |
| 8566 | show_bgp_community2_exact_cmd, |
| 8567 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8568 | SHOW_STR |
| 8569 | BGP_STR |
| 8570 | "Display routes matching the communities\n" |
| 8571 | "community number\n" |
| 8572 | "Do not send outside local AS (well-known community)\n" |
| 8573 | "Do not advertise to any peer (well-known community)\n" |
| 8574 | "Do not export to next AS (well-known community)\n" |
| 8575 | "community number\n" |
| 8576 | "Do not send outside local AS (well-known community)\n" |
| 8577 | "Do not advertise to any peer (well-known community)\n" |
| 8578 | "Do not export to next AS (well-known community)\n" |
| 8579 | "Exact match of the communities") |
| 8580 | |
| 8581 | ALIAS (show_bgp_community_exact, |
| 8582 | show_bgp_ipv6_community2_exact_cmd, |
| 8583 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8584 | SHOW_STR |
| 8585 | BGP_STR |
| 8586 | "Address family\n" |
| 8587 | "Display routes matching the communities\n" |
| 8588 | "community number\n" |
| 8589 | "Do not send outside local AS (well-known community)\n" |
| 8590 | "Do not advertise to any peer (well-known community)\n" |
| 8591 | "Do not export to next AS (well-known community)\n" |
| 8592 | "community number\n" |
| 8593 | "Do not send outside local AS (well-known community)\n" |
| 8594 | "Do not advertise to any peer (well-known community)\n" |
| 8595 | "Do not export to next AS (well-known community)\n" |
| 8596 | "Exact match of the communities") |
| 8597 | |
| 8598 | ALIAS (show_bgp_community_exact, |
| 8599 | show_bgp_community3_exact_cmd, |
| 8600 | "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", |
| 8601 | SHOW_STR |
| 8602 | BGP_STR |
| 8603 | "Display routes matching the communities\n" |
| 8604 | "community number\n" |
| 8605 | "Do not send outside local AS (well-known community)\n" |
| 8606 | "Do not advertise to any peer (well-known community)\n" |
| 8607 | "Do not export to next AS (well-known community)\n" |
| 8608 | "community number\n" |
| 8609 | "Do not send outside local AS (well-known community)\n" |
| 8610 | "Do not advertise to any peer (well-known community)\n" |
| 8611 | "Do not export to next AS (well-known community)\n" |
| 8612 | "community number\n" |
| 8613 | "Do not send outside local AS (well-known community)\n" |
| 8614 | "Do not advertise to any peer (well-known community)\n" |
| 8615 | "Do not export to next AS (well-known community)\n" |
| 8616 | "Exact match of the communities") |
| 8617 | |
| 8618 | ALIAS (show_bgp_community_exact, |
| 8619 | show_bgp_ipv6_community3_exact_cmd, |
| 8620 | "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", |
| 8621 | SHOW_STR |
| 8622 | BGP_STR |
| 8623 | "Address family\n" |
| 8624 | "Display routes matching the communities\n" |
| 8625 | "community number\n" |
| 8626 | "Do not send outside local AS (well-known community)\n" |
| 8627 | "Do not advertise to any peer (well-known community)\n" |
| 8628 | "Do not export to next AS (well-known community)\n" |
| 8629 | "community number\n" |
| 8630 | "Do not send outside local AS (well-known community)\n" |
| 8631 | "Do not advertise to any peer (well-known community)\n" |
| 8632 | "Do not export to next AS (well-known community)\n" |
| 8633 | "community number\n" |
| 8634 | "Do not send outside local AS (well-known community)\n" |
| 8635 | "Do not advertise to any peer (well-known community)\n" |
| 8636 | "Do not export to next AS (well-known community)\n" |
| 8637 | "Exact match of the communities") |
| 8638 | |
| 8639 | ALIAS (show_bgp_community_exact, |
| 8640 | show_bgp_community4_exact_cmd, |
| 8641 | "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", |
| 8642 | SHOW_STR |
| 8643 | BGP_STR |
| 8644 | "Display routes matching the communities\n" |
| 8645 | "community number\n" |
| 8646 | "Do not send outside local AS (well-known community)\n" |
| 8647 | "Do not advertise to any peer (well-known community)\n" |
| 8648 | "Do not export to next AS (well-known community)\n" |
| 8649 | "community number\n" |
| 8650 | "Do not send outside local AS (well-known community)\n" |
| 8651 | "Do not advertise to any peer (well-known community)\n" |
| 8652 | "Do not export to next AS (well-known community)\n" |
| 8653 | "community number\n" |
| 8654 | "Do not send outside local AS (well-known community)\n" |
| 8655 | "Do not advertise to any peer (well-known community)\n" |
| 8656 | "Do not export to next AS (well-known community)\n" |
| 8657 | "community number\n" |
| 8658 | "Do not send outside local AS (well-known community)\n" |
| 8659 | "Do not advertise to any peer (well-known community)\n" |
| 8660 | "Do not export to next AS (well-known community)\n" |
| 8661 | "Exact match of the communities") |
| 8662 | |
| 8663 | ALIAS (show_bgp_community_exact, |
| 8664 | show_bgp_ipv6_community4_exact_cmd, |
| 8665 | "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", |
| 8666 | SHOW_STR |
| 8667 | BGP_STR |
| 8668 | "Address family\n" |
| 8669 | "Display routes matching the communities\n" |
| 8670 | "community number\n" |
| 8671 | "Do not send outside local AS (well-known community)\n" |
| 8672 | "Do not advertise to any peer (well-known community)\n" |
| 8673 | "Do not export to next AS (well-known community)\n" |
| 8674 | "community number\n" |
| 8675 | "Do not send outside local AS (well-known community)\n" |
| 8676 | "Do not advertise to any peer (well-known community)\n" |
| 8677 | "Do not export to next AS (well-known community)\n" |
| 8678 | "community number\n" |
| 8679 | "Do not send outside local AS (well-known community)\n" |
| 8680 | "Do not advertise to any peer (well-known community)\n" |
| 8681 | "Do not export to next AS (well-known community)\n" |
| 8682 | "community number\n" |
| 8683 | "Do not send outside local AS (well-known community)\n" |
| 8684 | "Do not advertise to any peer (well-known community)\n" |
| 8685 | "Do not export to next AS (well-known community)\n" |
| 8686 | "Exact match of the communities") |
| 8687 | |
| 8688 | /* old command */ |
| 8689 | DEFUN (show_ipv6_bgp_community_exact, |
| 8690 | show_ipv6_bgp_community_exact_cmd, |
| 8691 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8692 | SHOW_STR |
| 8693 | IPV6_STR |
| 8694 | BGP_STR |
| 8695 | "Display routes matching the communities\n" |
| 8696 | "community number\n" |
| 8697 | "Do not send outside local AS (well-known community)\n" |
| 8698 | "Do not advertise to any peer (well-known community)\n" |
| 8699 | "Do not export to next AS (well-known community)\n" |
| 8700 | "Exact match of the communities") |
| 8701 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8702 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8703 | } |
| 8704 | |
| 8705 | /* old command */ |
| 8706 | ALIAS (show_ipv6_bgp_community_exact, |
| 8707 | show_ipv6_bgp_community2_exact_cmd, |
| 8708 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8709 | SHOW_STR |
| 8710 | IPV6_STR |
| 8711 | BGP_STR |
| 8712 | "Display routes matching the communities\n" |
| 8713 | "community number\n" |
| 8714 | "Do not send outside local AS (well-known community)\n" |
| 8715 | "Do not advertise to any peer (well-known community)\n" |
| 8716 | "Do not export to next AS (well-known community)\n" |
| 8717 | "community number\n" |
| 8718 | "Do not send outside local AS (well-known community)\n" |
| 8719 | "Do not advertise to any peer (well-known community)\n" |
| 8720 | "Do not export to next AS (well-known community)\n" |
| 8721 | "Exact match of the communities") |
| 8722 | |
| 8723 | /* old command */ |
| 8724 | ALIAS (show_ipv6_bgp_community_exact, |
| 8725 | show_ipv6_bgp_community3_exact_cmd, |
| 8726 | "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", |
| 8727 | SHOW_STR |
| 8728 | IPV6_STR |
| 8729 | BGP_STR |
| 8730 | "Display routes matching the communities\n" |
| 8731 | "community number\n" |
| 8732 | "Do not send outside local AS (well-known community)\n" |
| 8733 | "Do not advertise to any peer (well-known community)\n" |
| 8734 | "Do not export to next AS (well-known community)\n" |
| 8735 | "community number\n" |
| 8736 | "Do not send outside local AS (well-known community)\n" |
| 8737 | "Do not advertise to any peer (well-known community)\n" |
| 8738 | "Do not export to next AS (well-known community)\n" |
| 8739 | "community number\n" |
| 8740 | "Do not send outside local AS (well-known community)\n" |
| 8741 | "Do not advertise to any peer (well-known community)\n" |
| 8742 | "Do not export to next AS (well-known community)\n" |
| 8743 | "Exact match of the communities") |
| 8744 | |
| 8745 | /* old command */ |
| 8746 | ALIAS (show_ipv6_bgp_community_exact, |
| 8747 | show_ipv6_bgp_community4_exact_cmd, |
| 8748 | "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", |
| 8749 | SHOW_STR |
| 8750 | IPV6_STR |
| 8751 | BGP_STR |
| 8752 | "Display routes matching the communities\n" |
| 8753 | "community number\n" |
| 8754 | "Do not send outside local AS (well-known community)\n" |
| 8755 | "Do not advertise to any peer (well-known community)\n" |
| 8756 | "Do not export to next AS (well-known community)\n" |
| 8757 | "community number\n" |
| 8758 | "Do not send outside local AS (well-known community)\n" |
| 8759 | "Do not advertise to any peer (well-known community)\n" |
| 8760 | "Do not export to next AS (well-known community)\n" |
| 8761 | "community number\n" |
| 8762 | "Do not send outside local AS (well-known community)\n" |
| 8763 | "Do not advertise to any peer (well-known community)\n" |
| 8764 | "Do not export to next AS (well-known community)\n" |
| 8765 | "community number\n" |
| 8766 | "Do not send outside local AS (well-known community)\n" |
| 8767 | "Do not advertise to any peer (well-known community)\n" |
| 8768 | "Do not export to next AS (well-known community)\n" |
| 8769 | "Exact match of the communities") |
| 8770 | |
| 8771 | /* old command */ |
| 8772 | DEFUN (show_ipv6_mbgp_community, |
| 8773 | show_ipv6_mbgp_community_cmd, |
| 8774 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8775 | SHOW_STR |
| 8776 | IPV6_STR |
| 8777 | MBGP_STR |
| 8778 | "Display routes matching the communities\n" |
| 8779 | "community number\n" |
| 8780 | "Do not send outside local AS (well-known community)\n" |
| 8781 | "Do not advertise to any peer (well-known community)\n" |
| 8782 | "Do not export to next AS (well-known community)\n") |
| 8783 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8784 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8785 | } |
| 8786 | |
| 8787 | /* old command */ |
| 8788 | ALIAS (show_ipv6_mbgp_community, |
| 8789 | show_ipv6_mbgp_community2_cmd, |
| 8790 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8791 | SHOW_STR |
| 8792 | IPV6_STR |
| 8793 | MBGP_STR |
| 8794 | "Display routes matching the communities\n" |
| 8795 | "community number\n" |
| 8796 | "Do not send outside local AS (well-known community)\n" |
| 8797 | "Do not advertise to any peer (well-known community)\n" |
| 8798 | "Do not export to next AS (well-known community)\n" |
| 8799 | "community number\n" |
| 8800 | "Do not send outside local AS (well-known community)\n" |
| 8801 | "Do not advertise to any peer (well-known community)\n" |
| 8802 | "Do not export to next AS (well-known community)\n") |
| 8803 | |
| 8804 | /* old command */ |
| 8805 | ALIAS (show_ipv6_mbgp_community, |
| 8806 | show_ipv6_mbgp_community3_cmd, |
| 8807 | "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)", |
| 8808 | SHOW_STR |
| 8809 | IPV6_STR |
| 8810 | MBGP_STR |
| 8811 | "Display routes matching the communities\n" |
| 8812 | "community number\n" |
| 8813 | "Do not send outside local AS (well-known community)\n" |
| 8814 | "Do not advertise to any peer (well-known community)\n" |
| 8815 | "Do not export to next AS (well-known community)\n" |
| 8816 | "community number\n" |
| 8817 | "Do not send outside local AS (well-known community)\n" |
| 8818 | "Do not advertise to any peer (well-known community)\n" |
| 8819 | "Do not export to next AS (well-known community)\n" |
| 8820 | "community number\n" |
| 8821 | "Do not send outside local AS (well-known community)\n" |
| 8822 | "Do not advertise to any peer (well-known community)\n" |
| 8823 | "Do not export to next AS (well-known community)\n") |
| 8824 | |
| 8825 | /* old command */ |
| 8826 | ALIAS (show_ipv6_mbgp_community, |
| 8827 | show_ipv6_mbgp_community4_cmd, |
| 8828 | "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)", |
| 8829 | SHOW_STR |
| 8830 | IPV6_STR |
| 8831 | MBGP_STR |
| 8832 | "Display routes matching the communities\n" |
| 8833 | "community number\n" |
| 8834 | "Do not send outside local AS (well-known community)\n" |
| 8835 | "Do not advertise to any peer (well-known community)\n" |
| 8836 | "Do not export to next AS (well-known community)\n" |
| 8837 | "community number\n" |
| 8838 | "Do not send outside local AS (well-known community)\n" |
| 8839 | "Do not advertise to any peer (well-known community)\n" |
| 8840 | "Do not export to next AS (well-known community)\n" |
| 8841 | "community number\n" |
| 8842 | "Do not send outside local AS (well-known community)\n" |
| 8843 | "Do not advertise to any peer (well-known community)\n" |
| 8844 | "Do not export to next AS (well-known community)\n" |
| 8845 | "community number\n" |
| 8846 | "Do not send outside local AS (well-known community)\n" |
| 8847 | "Do not advertise to any peer (well-known community)\n" |
| 8848 | "Do not export to next AS (well-known community)\n") |
| 8849 | |
| 8850 | /* old command */ |
| 8851 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8852 | show_ipv6_mbgp_community_exact_cmd, |
| 8853 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8854 | SHOW_STR |
| 8855 | IPV6_STR |
| 8856 | MBGP_STR |
| 8857 | "Display routes matching the communities\n" |
| 8858 | "community number\n" |
| 8859 | "Do not send outside local AS (well-known community)\n" |
| 8860 | "Do not advertise to any peer (well-known community)\n" |
| 8861 | "Do not export to next AS (well-known community)\n" |
| 8862 | "Exact match of the communities") |
| 8863 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8864 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8865 | } |
| 8866 | |
| 8867 | /* old command */ |
| 8868 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8869 | show_ipv6_mbgp_community2_exact_cmd, |
| 8870 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8871 | SHOW_STR |
| 8872 | IPV6_STR |
| 8873 | MBGP_STR |
| 8874 | "Display routes matching the communities\n" |
| 8875 | "community number\n" |
| 8876 | "Do not send outside local AS (well-known community)\n" |
| 8877 | "Do not advertise to any peer (well-known community)\n" |
| 8878 | "Do not export to next AS (well-known community)\n" |
| 8879 | "community number\n" |
| 8880 | "Do not send outside local AS (well-known community)\n" |
| 8881 | "Do not advertise to any peer (well-known community)\n" |
| 8882 | "Do not export to next AS (well-known community)\n" |
| 8883 | "Exact match of the communities") |
| 8884 | |
| 8885 | /* old command */ |
| 8886 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8887 | show_ipv6_mbgp_community3_exact_cmd, |
| 8888 | "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", |
| 8889 | SHOW_STR |
| 8890 | IPV6_STR |
| 8891 | MBGP_STR |
| 8892 | "Display routes matching the communities\n" |
| 8893 | "community number\n" |
| 8894 | "Do not send outside local AS (well-known community)\n" |
| 8895 | "Do not advertise to any peer (well-known community)\n" |
| 8896 | "Do not export to next AS (well-known community)\n" |
| 8897 | "community number\n" |
| 8898 | "Do not send outside local AS (well-known community)\n" |
| 8899 | "Do not advertise to any peer (well-known community)\n" |
| 8900 | "Do not export to next AS (well-known community)\n" |
| 8901 | "community number\n" |
| 8902 | "Do not send outside local AS (well-known community)\n" |
| 8903 | "Do not advertise to any peer (well-known community)\n" |
| 8904 | "Do not export to next AS (well-known community)\n" |
| 8905 | "Exact match of the communities") |
| 8906 | |
| 8907 | /* old command */ |
| 8908 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8909 | show_ipv6_mbgp_community4_exact_cmd, |
| 8910 | "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", |
| 8911 | SHOW_STR |
| 8912 | IPV6_STR |
| 8913 | MBGP_STR |
| 8914 | "Display routes matching the communities\n" |
| 8915 | "community number\n" |
| 8916 | "Do not send outside local AS (well-known community)\n" |
| 8917 | "Do not advertise to any peer (well-known community)\n" |
| 8918 | "Do not export to next AS (well-known community)\n" |
| 8919 | "community number\n" |
| 8920 | "Do not send outside local AS (well-known community)\n" |
| 8921 | "Do not advertise to any peer (well-known community)\n" |
| 8922 | "Do not export to next AS (well-known community)\n" |
| 8923 | "community number\n" |
| 8924 | "Do not send outside local AS (well-known community)\n" |
| 8925 | "Do not advertise to any peer (well-known community)\n" |
| 8926 | "Do not export to next AS (well-known community)\n" |
| 8927 | "community number\n" |
| 8928 | "Do not send outside local AS (well-known community)\n" |
| 8929 | "Do not advertise to any peer (well-known community)\n" |
| 8930 | "Do not export to next AS (well-known community)\n" |
| 8931 | "Exact match of the communities") |
| 8932 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 8933 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8934 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8935 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8936 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8937 | { |
| 8938 | struct community_list *list; |
| 8939 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8940 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8941 | if (list == NULL) |
| 8942 | { |
| 8943 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8944 | VTY_NEWLINE); |
| 8945 | return CMD_WARNING; |
| 8946 | } |
| 8947 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8948 | return bgp_show (vty, NULL, afi, safi, |
| 8949 | (exact ? bgp_show_type_community_list_exact : |
| 8950 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8951 | } |
| 8952 | |
| 8953 | DEFUN (show_ip_bgp_community_list, |
| 8954 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8955 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8956 | SHOW_STR |
| 8957 | IP_STR |
| 8958 | BGP_STR |
| 8959 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8960 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8961 | "community-list name\n") |
| 8962 | { |
| 8963 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8964 | } |
| 8965 | |
| 8966 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8967 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8968 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8969 | SHOW_STR |
| 8970 | IP_STR |
| 8971 | BGP_STR |
| 8972 | "Address family\n" |
| 8973 | "Address Family modifier\n" |
| 8974 | "Address Family modifier\n" |
| 8975 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8976 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8977 | "community-list name\n") |
| 8978 | { |
| 8979 | if (strncmp (argv[0], "m", 1) == 0) |
| 8980 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8981 | |
| 8982 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8983 | } |
| 8984 | |
| 8985 | DEFUN (show_ip_bgp_community_list_exact, |
| 8986 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8987 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8988 | SHOW_STR |
| 8989 | IP_STR |
| 8990 | BGP_STR |
| 8991 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8992 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8993 | "community-list name\n" |
| 8994 | "Exact match of the communities\n") |
| 8995 | { |
| 8996 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8997 | } |
| 8998 | |
| 8999 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 9000 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9001 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9002 | SHOW_STR |
| 9003 | IP_STR |
| 9004 | BGP_STR |
| 9005 | "Address family\n" |
| 9006 | "Address Family modifier\n" |
| 9007 | "Address Family modifier\n" |
| 9008 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9009 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9010 | "community-list name\n" |
| 9011 | "Exact match of the communities\n") |
| 9012 | { |
| 9013 | if (strncmp (argv[0], "m", 1) == 0) |
| 9014 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 9015 | |
| 9016 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 9017 | } |
| 9018 | |
| 9019 | #ifdef HAVE_IPV6 |
| 9020 | DEFUN (show_bgp_community_list, |
| 9021 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9022 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9023 | SHOW_STR |
| 9024 | BGP_STR |
| 9025 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9026 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9027 | "community-list name\n") |
| 9028 | { |
| 9029 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9030 | } |
| 9031 | |
| 9032 | ALIAS (show_bgp_community_list, |
| 9033 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9034 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9035 | SHOW_STR |
| 9036 | BGP_STR |
| 9037 | "Address family\n" |
| 9038 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9039 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 9040 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9041 | |
| 9042 | /* old command */ |
| 9043 | DEFUN (show_ipv6_bgp_community_list, |
| 9044 | show_ipv6_bgp_community_list_cmd, |
| 9045 | "show ipv6 bgp community-list WORD", |
| 9046 | SHOW_STR |
| 9047 | IPV6_STR |
| 9048 | BGP_STR |
| 9049 | "Display routes matching the community-list\n" |
| 9050 | "community-list name\n") |
| 9051 | { |
| 9052 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9053 | } |
| 9054 | |
| 9055 | /* old command */ |
| 9056 | DEFUN (show_ipv6_mbgp_community_list, |
| 9057 | show_ipv6_mbgp_community_list_cmd, |
| 9058 | "show ipv6 mbgp community-list WORD", |
| 9059 | SHOW_STR |
| 9060 | IPV6_STR |
| 9061 | MBGP_STR |
| 9062 | "Display routes matching the community-list\n" |
| 9063 | "community-list name\n") |
| 9064 | { |
| 9065 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 9066 | } |
| 9067 | |
| 9068 | DEFUN (show_bgp_community_list_exact, |
| 9069 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9070 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9071 | SHOW_STR |
| 9072 | BGP_STR |
| 9073 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9074 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9075 | "community-list name\n" |
| 9076 | "Exact match of the communities\n") |
| 9077 | { |
| 9078 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9079 | } |
| 9080 | |
| 9081 | ALIAS (show_bgp_community_list_exact, |
| 9082 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9083 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9084 | SHOW_STR |
| 9085 | BGP_STR |
| 9086 | "Address family\n" |
| 9087 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9088 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9089 | "community-list name\n" |
| 9090 | "Exact match of the communities\n") |
| 9091 | |
| 9092 | /* old command */ |
| 9093 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 9094 | show_ipv6_bgp_community_list_exact_cmd, |
| 9095 | "show ipv6 bgp community-list WORD exact-match", |
| 9096 | SHOW_STR |
| 9097 | IPV6_STR |
| 9098 | BGP_STR |
| 9099 | "Display routes matching the community-list\n" |
| 9100 | "community-list name\n" |
| 9101 | "Exact match of the communities\n") |
| 9102 | { |
| 9103 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9104 | } |
| 9105 | |
| 9106 | /* old command */ |
| 9107 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9108 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9109 | "show ipv6 mbgp community-list WORD exact-match", |
| 9110 | SHOW_STR |
| 9111 | IPV6_STR |
| 9112 | MBGP_STR |
| 9113 | "Display routes matching the community-list\n" |
| 9114 | "community-list name\n" |
| 9115 | "Exact match of the communities\n") |
| 9116 | { |
| 9117 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9118 | } |
| 9119 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9120 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9121 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9122 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9123 | safi_t safi, enum bgp_show_type type) |
| 9124 | { |
| 9125 | int ret; |
| 9126 | struct prefix *p; |
| 9127 | |
| 9128 | p = prefix_new(); |
| 9129 | |
| 9130 | ret = str2prefix (prefix, p); |
| 9131 | if (! ret) |
| 9132 | { |
| 9133 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9134 | return CMD_WARNING; |
| 9135 | } |
| 9136 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9137 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9138 | prefix_free(p); |
| 9139 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9140 | } |
| 9141 | |
| 9142 | DEFUN (show_ip_bgp_prefix_longer, |
| 9143 | show_ip_bgp_prefix_longer_cmd, |
| 9144 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9145 | SHOW_STR |
| 9146 | IP_STR |
| 9147 | BGP_STR |
| 9148 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9149 | "Display route and more specific routes\n") |
| 9150 | { |
| 9151 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9152 | bgp_show_type_prefix_longer); |
| 9153 | } |
| 9154 | |
| 9155 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9156 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9157 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9158 | SHOW_STR |
| 9159 | IP_STR |
| 9160 | BGP_STR |
| 9161 | "Display flap statistics of routes\n" |
| 9162 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9163 | "Display route and more specific routes\n") |
| 9164 | { |
| 9165 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9166 | bgp_show_type_flap_prefix_longer); |
| 9167 | } |
| 9168 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9169 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 9170 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 9171 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 9172 | SHOW_STR |
| 9173 | IP_STR |
| 9174 | BGP_STR |
| 9175 | "Display detailed information about dampening\n" |
| 9176 | "Display flap statistics of routes\n" |
| 9177 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9178 | "Display route and more specific routes\n") |
| 9179 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9180 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9181 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9182 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9183 | SHOW_STR |
| 9184 | IP_STR |
| 9185 | BGP_STR |
| 9186 | "Address family\n" |
| 9187 | "Address Family modifier\n" |
| 9188 | "Address Family modifier\n" |
| 9189 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9190 | "Display route and more specific routes\n") |
| 9191 | { |
| 9192 | if (strncmp (argv[0], "m", 1) == 0) |
| 9193 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9194 | bgp_show_type_prefix_longer); |
| 9195 | |
| 9196 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9197 | bgp_show_type_prefix_longer); |
| 9198 | } |
| 9199 | |
| 9200 | DEFUN (show_ip_bgp_flap_address, |
| 9201 | show_ip_bgp_flap_address_cmd, |
| 9202 | "show ip bgp flap-statistics A.B.C.D", |
| 9203 | SHOW_STR |
| 9204 | IP_STR |
| 9205 | BGP_STR |
| 9206 | "Display flap statistics of routes\n" |
| 9207 | "Network in the BGP routing table to display\n") |
| 9208 | { |
| 9209 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9210 | bgp_show_type_flap_address); |
| 9211 | } |
| 9212 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9213 | ALIAS (show_ip_bgp_flap_address, |
| 9214 | show_ip_bgp_damp_flap_address_cmd, |
| 9215 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 9216 | SHOW_STR |
| 9217 | IP_STR |
| 9218 | BGP_STR |
| 9219 | "Display detailed information about dampening\n" |
| 9220 | "Display flap statistics of routes\n" |
| 9221 | "Network in the BGP routing table to display\n") |
| 9222 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9223 | DEFUN (show_ip_bgp_flap_prefix, |
| 9224 | show_ip_bgp_flap_prefix_cmd, |
| 9225 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9226 | SHOW_STR |
| 9227 | IP_STR |
| 9228 | BGP_STR |
| 9229 | "Display flap statistics of routes\n" |
| 9230 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9231 | { |
| 9232 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9233 | bgp_show_type_flap_prefix); |
| 9234 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9235 | |
| 9236 | ALIAS (show_ip_bgp_flap_prefix, |
| 9237 | show_ip_bgp_damp_flap_prefix_cmd, |
| 9238 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 9239 | SHOW_STR |
| 9240 | IP_STR |
| 9241 | BGP_STR |
| 9242 | "Display detailed information about dampening\n" |
| 9243 | "Display flap statistics of routes\n" |
| 9244 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9245 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9246 | #ifdef HAVE_IPV6 |
| 9247 | DEFUN (show_bgp_prefix_longer, |
| 9248 | show_bgp_prefix_longer_cmd, |
| 9249 | "show bgp X:X::X:X/M longer-prefixes", |
| 9250 | SHOW_STR |
| 9251 | BGP_STR |
| 9252 | "IPv6 prefix <network>/<length>\n" |
| 9253 | "Display route and more specific routes\n") |
| 9254 | { |
| 9255 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9256 | bgp_show_type_prefix_longer); |
| 9257 | } |
| 9258 | |
| 9259 | ALIAS (show_bgp_prefix_longer, |
| 9260 | show_bgp_ipv6_prefix_longer_cmd, |
| 9261 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9262 | SHOW_STR |
| 9263 | BGP_STR |
| 9264 | "Address family\n" |
| 9265 | "IPv6 prefix <network>/<length>\n" |
| 9266 | "Display route and more specific routes\n") |
| 9267 | |
| 9268 | /* old command */ |
| 9269 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9270 | show_ipv6_bgp_prefix_longer_cmd, |
| 9271 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9272 | SHOW_STR |
| 9273 | IPV6_STR |
| 9274 | BGP_STR |
| 9275 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9276 | "Display route and more specific routes\n") |
| 9277 | { |
| 9278 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9279 | bgp_show_type_prefix_longer); |
| 9280 | } |
| 9281 | |
| 9282 | /* old command */ |
| 9283 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9284 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9285 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9286 | SHOW_STR |
| 9287 | IPV6_STR |
| 9288 | MBGP_STR |
| 9289 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9290 | "Display route and more specific routes\n") |
| 9291 | { |
| 9292 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9293 | bgp_show_type_prefix_longer); |
| 9294 | } |
| 9295 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9296 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9297 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9298 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9299 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9300 | { |
| 9301 | int ret; |
| 9302 | struct bgp *bgp; |
| 9303 | struct peer *peer; |
| 9304 | union sockunion su; |
| 9305 | |
| 9306 | /* BGP structure lookup. */ |
| 9307 | if (view_name) |
| 9308 | { |
| 9309 | bgp = bgp_lookup_by_name (view_name); |
| 9310 | if (! bgp) |
| 9311 | { |
| 9312 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9313 | return NULL; |
| 9314 | } |
| 9315 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9316 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9317 | { |
| 9318 | bgp = bgp_get_default (); |
| 9319 | if (! bgp) |
| 9320 | { |
| 9321 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9322 | return NULL; |
| 9323 | } |
| 9324 | } |
| 9325 | |
| 9326 | /* Get peer sockunion. */ |
| 9327 | ret = str2sockunion (ip_str, &su); |
| 9328 | if (ret < 0) |
| 9329 | { |
| 9330 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9331 | return NULL; |
| 9332 | } |
| 9333 | |
| 9334 | /* Peer structure lookup. */ |
| 9335 | peer = peer_lookup (bgp, &su); |
| 9336 | if (! peer) |
| 9337 | { |
| 9338 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9339 | return NULL; |
| 9340 | } |
| 9341 | |
| 9342 | return peer; |
| 9343 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9344 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9345 | enum bgp_stats |
| 9346 | { |
| 9347 | BGP_STATS_MAXBITLEN = 0, |
| 9348 | BGP_STATS_RIB, |
| 9349 | BGP_STATS_PREFIXES, |
| 9350 | BGP_STATS_TOTPLEN, |
| 9351 | BGP_STATS_UNAGGREGATEABLE, |
| 9352 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9353 | BGP_STATS_AGGREGATES, |
| 9354 | BGP_STATS_SPACE, |
| 9355 | BGP_STATS_ASPATH_COUNT, |
| 9356 | BGP_STATS_ASPATH_MAXHOPS, |
| 9357 | BGP_STATS_ASPATH_TOTHOPS, |
| 9358 | BGP_STATS_ASPATH_MAXSIZE, |
| 9359 | BGP_STATS_ASPATH_TOTSIZE, |
| 9360 | BGP_STATS_ASN_HIGHEST, |
| 9361 | BGP_STATS_MAX, |
| 9362 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9363 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9364 | static const char *table_stats_strs[] = |
| 9365 | { |
| 9366 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9367 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9368 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9369 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9370 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9371 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9372 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9373 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9374 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9375 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9376 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9377 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9378 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9379 | [BGP_STATS_MAX] = NULL, |
| 9380 | }; |
| 9381 | |
| 9382 | struct bgp_table_stats |
| 9383 | { |
| 9384 | struct bgp_table *table; |
| 9385 | unsigned long long counts[BGP_STATS_MAX]; |
| 9386 | }; |
| 9387 | |
| 9388 | #if 0 |
| 9389 | #define TALLY_SIGFIG 100000 |
| 9390 | static unsigned long |
| 9391 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9392 | { |
| 9393 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9394 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9395 | unsigned long ret = newtot / count; |
| 9396 | |
| 9397 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9398 | return ret + 1; |
| 9399 | else |
| 9400 | return ret; |
| 9401 | } |
| 9402 | #endif |
| 9403 | |
| 9404 | static int |
| 9405 | bgp_table_stats_walker (struct thread *t) |
| 9406 | { |
| 9407 | struct bgp_node *rn; |
| 9408 | struct bgp_node *top; |
| 9409 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9410 | unsigned int space = 0; |
| 9411 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9412 | if (!(top = bgp_table_top (ts->table))) |
| 9413 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9414 | |
| 9415 | switch (top->p.family) |
| 9416 | { |
| 9417 | case AF_INET: |
| 9418 | space = IPV4_MAX_BITLEN; |
| 9419 | break; |
| 9420 | case AF_INET6: |
| 9421 | space = IPV6_MAX_BITLEN; |
| 9422 | break; |
| 9423 | } |
| 9424 | |
| 9425 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9426 | |
| 9427 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9428 | { |
| 9429 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9430 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9431 | unsigned int rinum = 0; |
| 9432 | |
| 9433 | if (rn == top) |
| 9434 | continue; |
| 9435 | |
| 9436 | if (!rn->info) |
| 9437 | continue; |
| 9438 | |
| 9439 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9440 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9441 | |
| 9442 | #if 0 |
| 9443 | ts->counts[BGP_STATS_AVGPLEN] |
| 9444 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9445 | ts->counts[BGP_STATS_AVGPLEN], |
| 9446 | rn->p.prefixlen); |
| 9447 | #endif |
| 9448 | |
| 9449 | /* check if the prefix is included by any other announcements */ |
| 9450 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9451 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9452 | |
| 9453 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9454 | { |
| 9455 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9456 | /* announced address space */ |
| 9457 | if (space) |
| 9458 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9459 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9460 | else if (prn->info) |
| 9461 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9462 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9463 | for (ri = rn->info; ri; ri = ri->next) |
| 9464 | { |
| 9465 | rinum++; |
| 9466 | ts->counts[BGP_STATS_RIB]++; |
| 9467 | |
| 9468 | if (ri->attr && |
| 9469 | (CHECK_FLAG (ri->attr->flag, |
| 9470 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9471 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9472 | |
| 9473 | /* as-path stats */ |
| 9474 | if (ri->attr && ri->attr->aspath) |
| 9475 | { |
| 9476 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9477 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9478 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9479 | |
| 9480 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9481 | |
| 9482 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9483 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9484 | |
| 9485 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9486 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9487 | |
| 9488 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9489 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9490 | #if 0 |
| 9491 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9492 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9493 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9494 | hops); |
| 9495 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9496 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9497 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9498 | size); |
| 9499 | #endif |
| 9500 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9501 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9502 | } |
| 9503 | } |
| 9504 | } |
| 9505 | return 0; |
| 9506 | } |
| 9507 | |
| 9508 | static int |
| 9509 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9510 | { |
| 9511 | struct bgp_table_stats ts; |
| 9512 | unsigned int i; |
| 9513 | |
| 9514 | if (!bgp->rib[afi][safi]) |
| 9515 | { |
| 9516 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9517 | return CMD_WARNING; |
| 9518 | } |
| 9519 | |
| 9520 | memset (&ts, 0, sizeof (ts)); |
| 9521 | ts.table = bgp->rib[afi][safi]; |
| 9522 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9523 | |
| 9524 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9525 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9526 | |
| 9527 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9528 | { |
| 9529 | if (!table_stats_strs[i]) |
| 9530 | continue; |
| 9531 | |
| 9532 | switch (i) |
| 9533 | { |
| 9534 | #if 0 |
| 9535 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9536 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9537 | case BGP_STATS_AVGPLEN: |
| 9538 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9539 | vty_out (vty, "%12.2f", |
| 9540 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9541 | break; |
| 9542 | #endif |
| 9543 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9544 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9545 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9546 | vty_out (vty, "%12.2f", |
| 9547 | ts.counts[i] ? |
| 9548 | (float)ts.counts[i] / |
| 9549 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9550 | : 0); |
| 9551 | break; |
| 9552 | case BGP_STATS_TOTPLEN: |
| 9553 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9554 | vty_out (vty, "%12.2f", |
| 9555 | ts.counts[i] ? |
| 9556 | (float)ts.counts[i] / |
| 9557 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9558 | : 0); |
| 9559 | break; |
| 9560 | case BGP_STATS_SPACE: |
| 9561 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9562 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9563 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9564 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9565 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9566 | vty_out (vty, "%12.2f%s", |
| 9567 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9568 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9569 | VTY_NEWLINE); |
| 9570 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9571 | vty_out (vty, "%12.2f%s", |
| 9572 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9573 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9574 | VTY_NEWLINE); |
| 9575 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9576 | break; |
| 9577 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9578 | vty_out (vty, "%12.2f", |
| 9579 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9580 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9581 | break; |
| 9582 | default: |
| 9583 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9584 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9585 | } |
| 9586 | |
| 9587 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9588 | } |
| 9589 | return CMD_SUCCESS; |
| 9590 | } |
| 9591 | |
| 9592 | static int |
| 9593 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9594 | const char *afi_str, const char *safi_str) |
| 9595 | { |
| 9596 | struct bgp *bgp; |
| 9597 | afi_t afi; |
| 9598 | safi_t safi; |
| 9599 | |
| 9600 | if (name) |
| 9601 | bgp = bgp_lookup_by_name (name); |
| 9602 | else |
| 9603 | bgp = bgp_get_default (); |
| 9604 | |
| 9605 | if (!bgp) |
| 9606 | { |
| 9607 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9608 | return CMD_WARNING; |
| 9609 | } |
| 9610 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9611 | { |
| 9612 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9613 | afi = AFI_IP; |
| 9614 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9615 | afi = AFI_IP6; |
| 9616 | else |
| 9617 | { |
| 9618 | vty_out (vty, "%% Invalid address family %s%s", |
| 9619 | afi_str, VTY_NEWLINE); |
| 9620 | return CMD_WARNING; |
| 9621 | } |
| 9622 | if (strncmp (safi_str, "m", 1) == 0) |
| 9623 | safi = SAFI_MULTICAST; |
| 9624 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9625 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9626 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9627 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9628 | else |
| 9629 | { |
| 9630 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9631 | safi_str, VTY_NEWLINE); |
| 9632 | return CMD_WARNING; |
| 9633 | } |
| 9634 | } |
| 9635 | else |
| 9636 | { |
| 9637 | vty_out (vty, "%% Invalid address family %s%s", |
| 9638 | afi_str, VTY_NEWLINE); |
| 9639 | return CMD_WARNING; |
| 9640 | } |
| 9641 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9642 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9643 | } |
| 9644 | |
| 9645 | DEFUN (show_bgp_statistics, |
| 9646 | show_bgp_statistics_cmd, |
| 9647 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9648 | SHOW_STR |
| 9649 | BGP_STR |
| 9650 | "Address family\n" |
| 9651 | "Address family\n" |
| 9652 | "Address Family modifier\n" |
| 9653 | "Address Family modifier\n" |
| 9654 | "BGP RIB advertisement statistics\n") |
| 9655 | { |
| 9656 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9657 | } |
| 9658 | |
| 9659 | ALIAS (show_bgp_statistics, |
| 9660 | show_bgp_statistics_vpnv4_cmd, |
| 9661 | "show bgp (ipv4) (vpnv4) statistics", |
| 9662 | SHOW_STR |
| 9663 | BGP_STR |
| 9664 | "Address family\n" |
| 9665 | "Address Family modifier\n" |
| 9666 | "BGP RIB advertisement statistics\n") |
| 9667 | |
| 9668 | DEFUN (show_bgp_statistics_view, |
| 9669 | show_bgp_statistics_view_cmd, |
| 9670 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9671 | SHOW_STR |
| 9672 | BGP_STR |
| 9673 | "BGP view\n" |
| 9674 | "Address family\n" |
| 9675 | "Address family\n" |
| 9676 | "Address Family modifier\n" |
| 9677 | "Address Family modifier\n" |
| 9678 | "BGP RIB advertisement statistics\n") |
| 9679 | { |
| 9680 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9681 | } |
| 9682 | |
| 9683 | ALIAS (show_bgp_statistics_view, |
| 9684 | show_bgp_statistics_view_vpnv4_cmd, |
| 9685 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9686 | SHOW_STR |
| 9687 | BGP_STR |
| 9688 | "BGP view\n" |
| 9689 | "Address family\n" |
| 9690 | "Address Family modifier\n" |
| 9691 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9692 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9693 | enum bgp_pcounts |
| 9694 | { |
| 9695 | PCOUNT_ADJ_IN = 0, |
| 9696 | PCOUNT_DAMPED, |
| 9697 | PCOUNT_REMOVED, |
| 9698 | PCOUNT_HISTORY, |
| 9699 | PCOUNT_STALE, |
| 9700 | PCOUNT_VALID, |
| 9701 | PCOUNT_ALL, |
| 9702 | PCOUNT_COUNTED, |
| 9703 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9704 | PCOUNT_MAX, |
| 9705 | }; |
| 9706 | |
| 9707 | static const char *pcount_strs[] = |
| 9708 | { |
| 9709 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9710 | [PCOUNT_DAMPED] = "Damped", |
| 9711 | [PCOUNT_REMOVED] = "Removed", |
| 9712 | [PCOUNT_HISTORY] = "History", |
| 9713 | [PCOUNT_STALE] = "Stale", |
| 9714 | [PCOUNT_VALID] = "Valid", |
| 9715 | [PCOUNT_ALL] = "All RIB", |
| 9716 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9717 | [PCOUNT_PFCNT] = "Useable", |
| 9718 | [PCOUNT_MAX] = NULL, |
| 9719 | }; |
| 9720 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9721 | struct peer_pcounts |
| 9722 | { |
| 9723 | unsigned int count[PCOUNT_MAX]; |
| 9724 | const struct peer *peer; |
| 9725 | const struct bgp_table *table; |
| 9726 | }; |
| 9727 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9728 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9729 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9730 | { |
| 9731 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9732 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9733 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9734 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9735 | 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] | 9736 | { |
| 9737 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9738 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9739 | |
| 9740 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9741 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9742 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9743 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9744 | for (ri = rn->info; ri; ri = ri->next) |
| 9745 | { |
| 9746 | char buf[SU_ADDRSTRLEN]; |
| 9747 | |
| 9748 | if (ri->peer != peer) |
| 9749 | continue; |
| 9750 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9751 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9752 | |
| 9753 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9754 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9755 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9756 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9757 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9758 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9759 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9760 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9761 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9762 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9763 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9764 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9765 | |
| 9766 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9767 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9768 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9769 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9770 | plog_warn (peer->log, |
| 9771 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9772 | peer->host, |
| 9773 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9774 | buf, SU_ADDRSTRLEN), |
| 9775 | rn->p.prefixlen, |
| 9776 | ri->flags); |
| 9777 | } |
| 9778 | else |
| 9779 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9780 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9781 | plog_warn (peer->log, |
| 9782 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9783 | peer->host, |
| 9784 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9785 | buf, SU_ADDRSTRLEN), |
| 9786 | rn->p.prefixlen, |
| 9787 | ri->flags); |
| 9788 | } |
| 9789 | } |
| 9790 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9791 | return 0; |
| 9792 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9793 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9794 | static int |
| 9795 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9796 | { |
| 9797 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9798 | unsigned int i; |
| 9799 | |
| 9800 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9801 | || !peer->bgp->rib[afi][safi]) |
| 9802 | { |
| 9803 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9804 | return CMD_WARNING; |
| 9805 | } |
| 9806 | |
| 9807 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9808 | pcounts.peer = peer; |
| 9809 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9810 | |
| 9811 | /* in-place call via thread subsystem so as to record execution time |
| 9812 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9813 | * on just vty_read()). |
| 9814 | */ |
| 9815 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9816 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9817 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9818 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9819 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9820 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9821 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9822 | |
| 9823 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9824 | vty_out (vty, "%20s: %-10d%s", |
| 9825 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9826 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9827 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9828 | { |
| 9829 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9830 | peer->host, VTY_NEWLINE); |
| 9831 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9832 | VTY_NEWLINE); |
| 9833 | } |
| 9834 | |
| 9835 | return CMD_SUCCESS; |
| 9836 | } |
| 9837 | |
| 9838 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9839 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9840 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9841 | SHOW_STR |
| 9842 | IP_STR |
| 9843 | BGP_STR |
| 9844 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9845 | "Neighbor to display information about\n" |
| 9846 | "Neighbor to display information about\n" |
| 9847 | "Display detailed prefix count information\n") |
| 9848 | { |
| 9849 | struct peer *peer; |
| 9850 | |
| 9851 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9852 | if (! peer) |
| 9853 | return CMD_WARNING; |
| 9854 | |
| 9855 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9856 | } |
| 9857 | |
| 9858 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9859 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9860 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9861 | SHOW_STR |
| 9862 | BGP_STR |
| 9863 | "Address family\n" |
| 9864 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9865 | "Neighbor to display information about\n" |
| 9866 | "Neighbor to display information about\n" |
| 9867 | "Display detailed prefix count information\n") |
| 9868 | { |
| 9869 | struct peer *peer; |
| 9870 | |
| 9871 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9872 | if (! peer) |
| 9873 | return CMD_WARNING; |
| 9874 | |
| 9875 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9876 | } |
| 9877 | |
| 9878 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9879 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9880 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9881 | SHOW_STR |
| 9882 | IP_STR |
| 9883 | BGP_STR |
| 9884 | "Address family\n" |
| 9885 | "Address Family modifier\n" |
| 9886 | "Address Family modifier\n" |
| 9887 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9888 | "Neighbor to display information about\n" |
| 9889 | "Neighbor to display information about\n" |
| 9890 | "Display detailed prefix count information\n") |
| 9891 | { |
| 9892 | struct peer *peer; |
| 9893 | |
| 9894 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9895 | if (! peer) |
| 9896 | return CMD_WARNING; |
| 9897 | |
| 9898 | if (strncmp (argv[0], "m", 1) == 0) |
| 9899 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9900 | |
| 9901 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9902 | } |
| 9903 | |
| 9904 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9905 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9906 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9907 | SHOW_STR |
| 9908 | IP_STR |
| 9909 | BGP_STR |
| 9910 | "Address family\n" |
| 9911 | "Address Family modifier\n" |
| 9912 | "Address Family modifier\n" |
| 9913 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9914 | "Neighbor to display information about\n" |
| 9915 | "Neighbor to display information about\n" |
| 9916 | "Display detailed prefix count information\n") |
| 9917 | { |
| 9918 | struct peer *peer; |
| 9919 | |
| 9920 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9921 | if (! peer) |
| 9922 | return CMD_WARNING; |
| 9923 | |
| 9924 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9925 | } |
| 9926 | |
| 9927 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9928 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9929 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9930 | int in) |
| 9931 | { |
| 9932 | struct bgp_table *table; |
| 9933 | struct bgp_adj_in *ain; |
| 9934 | struct bgp_adj_out *adj; |
| 9935 | unsigned long output_count; |
| 9936 | struct bgp_node *rn; |
| 9937 | int header1 = 1; |
| 9938 | struct bgp *bgp; |
| 9939 | int header2 = 1; |
| 9940 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9941 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9942 | |
| 9943 | if (! bgp) |
| 9944 | return; |
| 9945 | |
| 9946 | table = bgp->rib[afi][safi]; |
| 9947 | |
| 9948 | output_count = 0; |
| 9949 | |
| 9950 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9951 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9952 | { |
| 9953 | 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] | 9954 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9955 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9956 | |
| 9957 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9958 | VTY_NEWLINE, VTY_NEWLINE); |
| 9959 | header1 = 0; |
| 9960 | } |
| 9961 | |
| 9962 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9963 | if (in) |
| 9964 | { |
| 9965 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9966 | if (ain->peer == peer) |
| 9967 | { |
| 9968 | if (header1) |
| 9969 | { |
| 9970 | 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] | 9971 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9972 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9973 | header1 = 0; |
| 9974 | } |
| 9975 | if (header2) |
| 9976 | { |
| 9977 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9978 | header2 = 0; |
| 9979 | } |
| 9980 | if (ain->attr) |
| 9981 | { |
| 9982 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9983 | output_count++; |
| 9984 | } |
| 9985 | } |
| 9986 | } |
| 9987 | else |
| 9988 | { |
| 9989 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9990 | if (adj->peer == peer) |
| 9991 | { |
| 9992 | if (header1) |
| 9993 | { |
| 9994 | 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] | 9995 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9996 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9997 | header1 = 0; |
| 9998 | } |
| 9999 | if (header2) |
| 10000 | { |
| 10001 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 10002 | header2 = 0; |
| 10003 | } |
| 10004 | if (adj->attr) |
| 10005 | { |
| 10006 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 10007 | output_count++; |
| 10008 | } |
| 10009 | } |
| 10010 | } |
| 10011 | |
| 10012 | if (output_count != 0) |
| 10013 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 10014 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 10015 | } |
| 10016 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10017 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10018 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 10019 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10020 | if (! peer || ! peer->afc[afi][safi]) |
| 10021 | { |
| 10022 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 10023 | return CMD_WARNING; |
| 10024 | } |
| 10025 | |
| 10026 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 10027 | { |
| 10028 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 10029 | VTY_NEWLINE); |
| 10030 | return CMD_WARNING; |
| 10031 | } |
| 10032 | |
| 10033 | show_adj_route (vty, peer, afi, safi, in); |
| 10034 | |
| 10035 | return CMD_SUCCESS; |
| 10036 | } |
| 10037 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10038 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 10039 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 10040 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10041 | SHOW_STR |
| 10042 | IP_STR |
| 10043 | BGP_STR |
| 10044 | "BGP view\n" |
| 10045 | "View name\n" |
| 10046 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10047 | "Neighbor to display information about\n" |
| 10048 | "Neighbor to display information about\n" |
| 10049 | "Display the routes advertised to a BGP neighbor\n") |
| 10050 | { |
| 10051 | struct peer *peer; |
| 10052 | |
| 10053 | if (argc == 2) |
| 10054 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10055 | else |
| 10056 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10057 | |
| 10058 | if (! peer) |
| 10059 | return CMD_WARNING; |
| 10060 | |
| 10061 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 10062 | } |
| 10063 | |
| 10064 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10065 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 10066 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10067 | SHOW_STR |
| 10068 | IP_STR |
| 10069 | BGP_STR |
| 10070 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10071 | "Neighbor to display information about\n" |
| 10072 | "Neighbor to display information about\n" |
| 10073 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10074 | |
| 10075 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 10076 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 10077 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10078 | SHOW_STR |
| 10079 | IP_STR |
| 10080 | BGP_STR |
| 10081 | "Address family\n" |
| 10082 | "Address Family modifier\n" |
| 10083 | "Address Family modifier\n" |
| 10084 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10085 | "Neighbor to display information about\n" |
| 10086 | "Neighbor to display information about\n" |
| 10087 | "Display the routes advertised to a BGP neighbor\n") |
| 10088 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10089 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10090 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10091 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10092 | if (! peer) |
| 10093 | return CMD_WARNING; |
| 10094 | |
| 10095 | if (strncmp (argv[0], "m", 1) == 0) |
| 10096 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 10097 | |
| 10098 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10099 | } |
| 10100 | |
| 10101 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10102 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 10103 | show_bgp_view_neighbor_advertised_route_cmd, |
| 10104 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10105 | SHOW_STR |
| 10106 | BGP_STR |
| 10107 | "BGP view\n" |
| 10108 | "View name\n" |
| 10109 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10110 | "Neighbor to display information about\n" |
| 10111 | "Neighbor to display information about\n" |
| 10112 | "Display the routes advertised to a BGP neighbor\n") |
| 10113 | { |
| 10114 | struct peer *peer; |
| 10115 | |
| 10116 | if (argc == 2) |
| 10117 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10118 | else |
| 10119 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10120 | |
| 10121 | if (! peer) |
| 10122 | return CMD_WARNING; |
| 10123 | |
| 10124 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 10125 | } |
| 10126 | |
| 10127 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 10128 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 10129 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10130 | SHOW_STR |
| 10131 | BGP_STR |
| 10132 | "BGP view\n" |
| 10133 | "View name\n" |
| 10134 | "Address family\n" |
| 10135 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10136 | "Neighbor to display information about\n" |
| 10137 | "Neighbor to display information about\n" |
| 10138 | "Display the routes advertised to a BGP neighbor\n") |
| 10139 | |
| 10140 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10141 | show_bgp_view_neighbor_received_routes_cmd, |
| 10142 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10143 | SHOW_STR |
| 10144 | BGP_STR |
| 10145 | "BGP view\n" |
| 10146 | "View name\n" |
| 10147 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10148 | "Neighbor to display information about\n" |
| 10149 | "Neighbor to display information about\n" |
| 10150 | "Display the received routes from neighbor\n") |
| 10151 | { |
| 10152 | struct peer *peer; |
| 10153 | |
| 10154 | if (argc == 2) |
| 10155 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10156 | else |
| 10157 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10158 | |
| 10159 | if (! peer) |
| 10160 | return CMD_WARNING; |
| 10161 | |
| 10162 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10163 | } |
| 10164 | |
| 10165 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10166 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10167 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10168 | SHOW_STR |
| 10169 | BGP_STR |
| 10170 | "BGP view\n" |
| 10171 | "View name\n" |
| 10172 | "Address family\n" |
| 10173 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10174 | "Neighbor to display information about\n" |
| 10175 | "Neighbor to display information about\n" |
| 10176 | "Display the received routes from neighbor\n") |
| 10177 | |
| 10178 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10179 | show_bgp_neighbor_advertised_route_cmd, |
| 10180 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10181 | SHOW_STR |
| 10182 | BGP_STR |
| 10183 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10184 | "Neighbor to display information about\n" |
| 10185 | "Neighbor to display information about\n" |
| 10186 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10187 | |
| 10188 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10189 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10190 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10191 | SHOW_STR |
| 10192 | BGP_STR |
| 10193 | "Address family\n" |
| 10194 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10195 | "Neighbor to display information about\n" |
| 10196 | "Neighbor to display information about\n" |
| 10197 | "Display the routes advertised to a BGP neighbor\n") |
| 10198 | |
| 10199 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10200 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10201 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10202 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10203 | SHOW_STR |
| 10204 | IPV6_STR |
| 10205 | BGP_STR |
| 10206 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10207 | "Neighbor to display information about\n" |
| 10208 | "Neighbor to display information about\n" |
| 10209 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10210 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10211 | /* old command */ |
| 10212 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10213 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10214 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10215 | SHOW_STR |
| 10216 | IPV6_STR |
| 10217 | MBGP_STR |
| 10218 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10219 | "Neighbor to display information about\n" |
| 10220 | "Neighbor to display information about\n" |
| 10221 | "Display the routes advertised to a BGP neighbor\n") |
| 10222 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10223 | struct peer *peer; |
| 10224 | |
| 10225 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10226 | if (! peer) |
| 10227 | return CMD_WARNING; |
| 10228 | |
| 10229 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10230 | } |
| 10231 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10232 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10233 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10234 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10235 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10236 | SHOW_STR |
| 10237 | IP_STR |
| 10238 | BGP_STR |
| 10239 | "BGP view\n" |
| 10240 | "View name\n" |
| 10241 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10242 | "Neighbor to display information about\n" |
| 10243 | "Neighbor to display information about\n" |
| 10244 | "Display the received routes from neighbor\n") |
| 10245 | { |
| 10246 | struct peer *peer; |
| 10247 | |
| 10248 | if (argc == 2) |
| 10249 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10250 | else |
| 10251 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10252 | |
| 10253 | if (! peer) |
| 10254 | return CMD_WARNING; |
| 10255 | |
| 10256 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10257 | } |
| 10258 | |
| 10259 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10260 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10261 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10262 | SHOW_STR |
| 10263 | IP_STR |
| 10264 | BGP_STR |
| 10265 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10266 | "Neighbor to display information about\n" |
| 10267 | "Neighbor to display information about\n" |
| 10268 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10269 | |
| 10270 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10271 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10272 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10273 | SHOW_STR |
| 10274 | IP_STR |
| 10275 | BGP_STR |
| 10276 | "Address family\n" |
| 10277 | "Address Family modifier\n" |
| 10278 | "Address Family modifier\n" |
| 10279 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10280 | "Neighbor to display information about\n" |
| 10281 | "Neighbor to display information about\n" |
| 10282 | "Display the received routes from neighbor\n") |
| 10283 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10284 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10285 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10286 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10287 | if (! peer) |
| 10288 | return CMD_WARNING; |
| 10289 | |
| 10290 | if (strncmp (argv[0], "m", 1) == 0) |
| 10291 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10292 | |
| 10293 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10294 | } |
| 10295 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10296 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10297 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10298 | "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] | 10299 | SHOW_STR |
| 10300 | BGP_STR |
| 10301 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10302 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10303 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10304 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10305 | "Address family modifier\n" |
| 10306 | "Address family modifier\n" |
| 10307 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10308 | "Neighbor to display information about\n" |
| 10309 | "Neighbor to display information about\n" |
| 10310 | "Display the advertised routes to neighbor\n" |
| 10311 | "Display the received routes from neighbor\n") |
| 10312 | { |
| 10313 | int afi; |
| 10314 | int safi; |
| 10315 | int in; |
| 10316 | struct peer *peer; |
| 10317 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 10318 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10319 | |
| 10320 | if (! peer) |
| 10321 | return CMD_WARNING; |
| 10322 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10323 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10324 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10325 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10326 | |
| 10327 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10328 | } |
| 10329 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10330 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10331 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10332 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10333 | SHOW_STR |
| 10334 | IP_STR |
| 10335 | BGP_STR |
| 10336 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10337 | "Neighbor to display information about\n" |
| 10338 | "Neighbor to display information about\n" |
| 10339 | "Display information received from a BGP neighbor\n" |
| 10340 | "Display the prefixlist filter\n") |
| 10341 | { |
| 10342 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10343 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10344 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10345 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10346 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10347 | ret = str2sockunion (argv[0], &su); |
| 10348 | if (ret < 0) |
| 10349 | { |
| 10350 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10351 | return CMD_WARNING; |
| 10352 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10353 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10354 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10355 | if (! peer) |
| 10356 | return CMD_WARNING; |
| 10357 | |
| 10358 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10359 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10360 | if (count) |
| 10361 | { |
| 10362 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10363 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10364 | } |
| 10365 | |
| 10366 | return CMD_SUCCESS; |
| 10367 | } |
| 10368 | |
| 10369 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10370 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10371 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10372 | SHOW_STR |
| 10373 | IP_STR |
| 10374 | BGP_STR |
| 10375 | "Address family\n" |
| 10376 | "Address Family modifier\n" |
| 10377 | "Address Family modifier\n" |
| 10378 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10379 | "Neighbor to display information about\n" |
| 10380 | "Neighbor to display information about\n" |
| 10381 | "Display information received from a BGP neighbor\n" |
| 10382 | "Display the prefixlist filter\n") |
| 10383 | { |
| 10384 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10385 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10386 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10387 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10388 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10389 | ret = str2sockunion (argv[1], &su); |
| 10390 | if (ret < 0) |
| 10391 | { |
| 10392 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10393 | return CMD_WARNING; |
| 10394 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10395 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10396 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10397 | if (! peer) |
| 10398 | return CMD_WARNING; |
| 10399 | |
| 10400 | if (strncmp (argv[0], "m", 1) == 0) |
| 10401 | { |
| 10402 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10403 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10404 | if (count) |
| 10405 | { |
| 10406 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10407 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10408 | } |
| 10409 | } |
| 10410 | else |
| 10411 | { |
| 10412 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10413 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10414 | if (count) |
| 10415 | { |
| 10416 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10417 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10418 | } |
| 10419 | } |
| 10420 | |
| 10421 | return CMD_SUCCESS; |
| 10422 | } |
| 10423 | |
| 10424 | |
| 10425 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10426 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10427 | show_bgp_neighbor_received_routes_cmd, |
| 10428 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10429 | SHOW_STR |
| 10430 | BGP_STR |
| 10431 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10432 | "Neighbor to display information about\n" |
| 10433 | "Neighbor to display information about\n" |
| 10434 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10435 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10436 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10437 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10438 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10439 | SHOW_STR |
| 10440 | BGP_STR |
| 10441 | "Address family\n" |
| 10442 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10443 | "Neighbor to display information about\n" |
| 10444 | "Neighbor to display information about\n" |
| 10445 | "Display the received routes from neighbor\n") |
| 10446 | |
| 10447 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10448 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10449 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10450 | SHOW_STR |
| 10451 | BGP_STR |
| 10452 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10453 | "Neighbor to display information about\n" |
| 10454 | "Neighbor to display information about\n" |
| 10455 | "Display information received from a BGP neighbor\n" |
| 10456 | "Display the prefixlist filter\n") |
| 10457 | { |
| 10458 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10459 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10460 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10461 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10462 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10463 | ret = str2sockunion (argv[0], &su); |
| 10464 | if (ret < 0) |
| 10465 | { |
| 10466 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10467 | return CMD_WARNING; |
| 10468 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10469 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10470 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10471 | if (! peer) |
| 10472 | return CMD_WARNING; |
| 10473 | |
| 10474 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10475 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10476 | if (count) |
| 10477 | { |
| 10478 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10479 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10480 | } |
| 10481 | |
| 10482 | return CMD_SUCCESS; |
| 10483 | } |
| 10484 | |
| 10485 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10486 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10487 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10488 | SHOW_STR |
| 10489 | BGP_STR |
| 10490 | "Address family\n" |
| 10491 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10492 | "Neighbor to display information about\n" |
| 10493 | "Neighbor to display information about\n" |
| 10494 | "Display information received from a BGP neighbor\n" |
| 10495 | "Display the prefixlist filter\n") |
| 10496 | |
| 10497 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10498 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10499 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10500 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10501 | SHOW_STR |
| 10502 | IPV6_STR |
| 10503 | BGP_STR |
| 10504 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10505 | "Neighbor to display information about\n" |
| 10506 | "Neighbor to display information about\n" |
| 10507 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10508 | |
| 10509 | /* old command */ |
| 10510 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10511 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10512 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10513 | SHOW_STR |
| 10514 | IPV6_STR |
| 10515 | MBGP_STR |
| 10516 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10517 | "Neighbor to display information about\n" |
| 10518 | "Neighbor to display information about\n" |
| 10519 | "Display the received routes from neighbor\n") |
| 10520 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10521 | struct peer *peer; |
| 10522 | |
| 10523 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10524 | if (! peer) |
| 10525 | return CMD_WARNING; |
| 10526 | |
| 10527 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10528 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10529 | |
| 10530 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10531 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10532 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10533 | SHOW_STR |
| 10534 | BGP_STR |
| 10535 | "BGP view\n" |
| 10536 | "View name\n" |
| 10537 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10538 | "Neighbor to display information about\n" |
| 10539 | "Neighbor to display information about\n" |
| 10540 | "Display information received from a BGP neighbor\n" |
| 10541 | "Display the prefixlist filter\n") |
| 10542 | { |
| 10543 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10544 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10545 | struct peer *peer; |
| 10546 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10547 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10548 | |
| 10549 | /* BGP structure lookup. */ |
| 10550 | bgp = bgp_lookup_by_name (argv[0]); |
| 10551 | if (bgp == NULL) |
| 10552 | { |
| 10553 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10554 | return CMD_WARNING; |
| 10555 | } |
| 10556 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10557 | ret = str2sockunion (argv[1], &su); |
| 10558 | if (ret < 0) |
| 10559 | { |
| 10560 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10561 | return CMD_WARNING; |
| 10562 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10563 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10564 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10565 | if (! peer) |
| 10566 | return CMD_WARNING; |
| 10567 | |
| 10568 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10569 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10570 | if (count) |
| 10571 | { |
| 10572 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10573 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10574 | } |
| 10575 | |
| 10576 | return CMD_SUCCESS; |
| 10577 | } |
| 10578 | |
| 10579 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10580 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10581 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10582 | SHOW_STR |
| 10583 | BGP_STR |
| 10584 | "BGP view\n" |
| 10585 | "View name\n" |
| 10586 | "Address family\n" |
| 10587 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10588 | "Neighbor to display information about\n" |
| 10589 | "Neighbor to display information about\n" |
| 10590 | "Display information received from a BGP neighbor\n" |
| 10591 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10592 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10593 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10594 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10595 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10596 | safi_t safi, enum bgp_show_type type) |
| 10597 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10598 | if (! peer || ! peer->afc[afi][safi]) |
| 10599 | { |
| 10600 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10601 | return CMD_WARNING; |
| 10602 | } |
| 10603 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10604 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10605 | } |
| 10606 | |
| 10607 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10608 | show_ip_bgp_neighbor_routes_cmd, |
| 10609 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10610 | SHOW_STR |
| 10611 | IP_STR |
| 10612 | BGP_STR |
| 10613 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10614 | "Neighbor to display information about\n" |
| 10615 | "Neighbor to display information about\n" |
| 10616 | "Display routes learned from neighbor\n") |
| 10617 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10618 | struct peer *peer; |
| 10619 | |
| 10620 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10621 | if (! peer) |
| 10622 | return CMD_WARNING; |
| 10623 | |
| 10624 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10625 | bgp_show_type_neighbor); |
| 10626 | } |
| 10627 | |
| 10628 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10629 | show_ip_bgp_neighbor_flap_cmd, |
| 10630 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10631 | SHOW_STR |
| 10632 | IP_STR |
| 10633 | BGP_STR |
| 10634 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10635 | "Neighbor to display information about\n" |
| 10636 | "Neighbor to display information about\n" |
| 10637 | "Display flap statistics of the routes learned from neighbor\n") |
| 10638 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10639 | struct peer *peer; |
| 10640 | |
| 10641 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10642 | if (! peer) |
| 10643 | return CMD_WARNING; |
| 10644 | |
| 10645 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10646 | bgp_show_type_flap_neighbor); |
| 10647 | } |
| 10648 | |
| 10649 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10650 | show_ip_bgp_neighbor_damp_cmd, |
| 10651 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10652 | SHOW_STR |
| 10653 | IP_STR |
| 10654 | BGP_STR |
| 10655 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10656 | "Neighbor to display information about\n" |
| 10657 | "Neighbor to display information about\n" |
| 10658 | "Display the dampened routes received from neighbor\n") |
| 10659 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10660 | struct peer *peer; |
| 10661 | |
| 10662 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10663 | if (! peer) |
| 10664 | return CMD_WARNING; |
| 10665 | |
| 10666 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10667 | bgp_show_type_damp_neighbor); |
| 10668 | } |
| 10669 | |
| 10670 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10671 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10672 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10673 | SHOW_STR |
| 10674 | IP_STR |
| 10675 | BGP_STR |
| 10676 | "Address family\n" |
| 10677 | "Address Family modifier\n" |
| 10678 | "Address Family modifier\n" |
| 10679 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10680 | "Neighbor to display information about\n" |
| 10681 | "Neighbor to display information about\n" |
| 10682 | "Display routes learned from neighbor\n") |
| 10683 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10684 | struct peer *peer; |
| 10685 | |
| 10686 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10687 | if (! peer) |
| 10688 | return CMD_WARNING; |
| 10689 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10690 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10691 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10692 | bgp_show_type_neighbor); |
| 10693 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10694 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10695 | bgp_show_type_neighbor); |
| 10696 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10697 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10698 | DEFUN (show_ip_bgp_view_rsclient, |
| 10699 | show_ip_bgp_view_rsclient_cmd, |
| 10700 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10701 | SHOW_STR |
| 10702 | IP_STR |
| 10703 | BGP_STR |
| 10704 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10705 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10706 | "Information about Route Server Client\n" |
| 10707 | NEIGHBOR_ADDR_STR) |
| 10708 | { |
| 10709 | struct bgp_table *table; |
| 10710 | struct peer *peer; |
| 10711 | |
| 10712 | if (argc == 2) |
| 10713 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10714 | else |
| 10715 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10716 | |
| 10717 | if (! peer) |
| 10718 | return CMD_WARNING; |
| 10719 | |
| 10720 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10721 | { |
| 10722 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10723 | VTY_NEWLINE); |
| 10724 | return CMD_WARNING; |
| 10725 | } |
| 10726 | |
| 10727 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10728 | PEER_FLAG_RSERVER_CLIENT)) |
| 10729 | { |
| 10730 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10731 | VTY_NEWLINE); |
| 10732 | return CMD_WARNING; |
| 10733 | } |
| 10734 | |
| 10735 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10736 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10737 | 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] | 10738 | } |
| 10739 | |
| 10740 | ALIAS (show_ip_bgp_view_rsclient, |
| 10741 | show_ip_bgp_rsclient_cmd, |
| 10742 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10743 | SHOW_STR |
| 10744 | IP_STR |
| 10745 | BGP_STR |
| 10746 | "Information about Route Server Client\n" |
| 10747 | NEIGHBOR_ADDR_STR) |
| 10748 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10749 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10750 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10751 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10752 | SHOW_STR |
| 10753 | BGP_STR |
| 10754 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10755 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10756 | "Address family\n" |
| 10757 | "Address Family modifier\n" |
| 10758 | "Address Family modifier\n" |
| 10759 | "Information about Route Server Client\n" |
| 10760 | NEIGHBOR_ADDR_STR) |
| 10761 | { |
| 10762 | struct bgp_table *table; |
| 10763 | struct peer *peer; |
| 10764 | safi_t safi; |
| 10765 | |
| 10766 | if (argc == 3) { |
| 10767 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10768 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10769 | } else { |
| 10770 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10771 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10772 | } |
| 10773 | |
| 10774 | if (! peer) |
| 10775 | return CMD_WARNING; |
| 10776 | |
| 10777 | if (! peer->afc[AFI_IP][safi]) |
| 10778 | { |
| 10779 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10780 | VTY_NEWLINE); |
| 10781 | return CMD_WARNING; |
| 10782 | } |
| 10783 | |
| 10784 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10785 | PEER_FLAG_RSERVER_CLIENT)) |
| 10786 | { |
| 10787 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10788 | VTY_NEWLINE); |
| 10789 | return CMD_WARNING; |
| 10790 | } |
| 10791 | |
| 10792 | table = peer->rib[AFI_IP][safi]; |
| 10793 | |
| 10794 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10795 | } |
| 10796 | |
| 10797 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10798 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10799 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10800 | SHOW_STR |
| 10801 | BGP_STR |
| 10802 | "Address family\n" |
| 10803 | "Address Family modifier\n" |
| 10804 | "Address Family modifier\n" |
| 10805 | "Information about Route Server Client\n" |
| 10806 | NEIGHBOR_ADDR_STR) |
| 10807 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10808 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10809 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10810 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10811 | SHOW_STR |
| 10812 | IP_STR |
| 10813 | BGP_STR |
| 10814 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10815 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10816 | "Information about Route Server Client\n" |
| 10817 | NEIGHBOR_ADDR_STR |
| 10818 | "Network in the BGP routing table to display\n") |
| 10819 | { |
| 10820 | struct bgp *bgp; |
| 10821 | struct peer *peer; |
| 10822 | |
| 10823 | /* BGP structure lookup. */ |
| 10824 | if (argc == 3) |
| 10825 | { |
| 10826 | bgp = bgp_lookup_by_name (argv[0]); |
| 10827 | if (bgp == NULL) |
| 10828 | { |
| 10829 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10830 | return CMD_WARNING; |
| 10831 | } |
| 10832 | } |
| 10833 | else |
| 10834 | { |
| 10835 | bgp = bgp_get_default (); |
| 10836 | if (bgp == NULL) |
| 10837 | { |
| 10838 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10839 | return CMD_WARNING; |
| 10840 | } |
| 10841 | } |
| 10842 | |
| 10843 | if (argc == 3) |
| 10844 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10845 | else |
| 10846 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10847 | |
| 10848 | if (! peer) |
| 10849 | return CMD_WARNING; |
| 10850 | |
| 10851 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10852 | { |
| 10853 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10854 | VTY_NEWLINE); |
| 10855 | return CMD_WARNING; |
| 10856 | } |
| 10857 | |
| 10858 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10859 | PEER_FLAG_RSERVER_CLIENT)) |
| 10860 | { |
| 10861 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10862 | VTY_NEWLINE); |
| 10863 | return CMD_WARNING; |
| 10864 | } |
| 10865 | |
| 10866 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10867 | (argc == 3) ? argv[2] : argv[1], |
| 10868 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10869 | } |
| 10870 | |
| 10871 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10872 | show_ip_bgp_rsclient_route_cmd, |
| 10873 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10874 | SHOW_STR |
| 10875 | IP_STR |
| 10876 | BGP_STR |
| 10877 | "Information about Route Server Client\n" |
| 10878 | NEIGHBOR_ADDR_STR |
| 10879 | "Network in the BGP routing table to display\n") |
| 10880 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10881 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10882 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10883 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10884 | SHOW_STR |
| 10885 | BGP_STR |
| 10886 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10887 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10888 | "Address family\n" |
| 10889 | "Address Family modifier\n" |
| 10890 | "Address Family modifier\n" |
| 10891 | "Information about Route Server Client\n" |
| 10892 | NEIGHBOR_ADDR_STR |
| 10893 | "Network in the BGP routing table to display\n") |
| 10894 | { |
| 10895 | struct bgp *bgp; |
| 10896 | struct peer *peer; |
| 10897 | safi_t safi; |
| 10898 | |
| 10899 | /* BGP structure lookup. */ |
| 10900 | if (argc == 4) |
| 10901 | { |
| 10902 | bgp = bgp_lookup_by_name (argv[0]); |
| 10903 | if (bgp == NULL) |
| 10904 | { |
| 10905 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10906 | return CMD_WARNING; |
| 10907 | } |
| 10908 | } |
| 10909 | else |
| 10910 | { |
| 10911 | bgp = bgp_get_default (); |
| 10912 | if (bgp == NULL) |
| 10913 | { |
| 10914 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10915 | return CMD_WARNING; |
| 10916 | } |
| 10917 | } |
| 10918 | |
| 10919 | if (argc == 4) { |
| 10920 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10921 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10922 | } else { |
| 10923 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10924 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10925 | } |
| 10926 | |
| 10927 | if (! peer) |
| 10928 | return CMD_WARNING; |
| 10929 | |
| 10930 | if (! peer->afc[AFI_IP][safi]) |
| 10931 | { |
| 10932 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10933 | VTY_NEWLINE); |
| 10934 | return CMD_WARNING; |
| 10935 | } |
| 10936 | |
| 10937 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10938 | PEER_FLAG_RSERVER_CLIENT)) |
| 10939 | { |
| 10940 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10941 | VTY_NEWLINE); |
| 10942 | return CMD_WARNING; |
| 10943 | } |
| 10944 | |
| 10945 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10946 | (argc == 4) ? argv[3] : argv[2], |
| 10947 | AFI_IP, safi, NULL, 0); |
| 10948 | } |
| 10949 | |
| 10950 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10951 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10952 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10953 | SHOW_STR |
| 10954 | BGP_STR |
| 10955 | "Address family\n" |
| 10956 | "Address Family modifier\n" |
| 10957 | "Address Family modifier\n" |
| 10958 | "Information about Route Server Client\n" |
| 10959 | NEIGHBOR_ADDR_STR |
| 10960 | "Network in the BGP routing table to display\n") |
| 10961 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10962 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10963 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10964 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10965 | SHOW_STR |
| 10966 | IP_STR |
| 10967 | BGP_STR |
| 10968 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10969 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10970 | "Information about Route Server Client\n" |
| 10971 | NEIGHBOR_ADDR_STR |
| 10972 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10973 | { |
| 10974 | struct bgp *bgp; |
| 10975 | struct peer *peer; |
| 10976 | |
| 10977 | /* BGP structure lookup. */ |
| 10978 | if (argc == 3) |
| 10979 | { |
| 10980 | bgp = bgp_lookup_by_name (argv[0]); |
| 10981 | if (bgp == NULL) |
| 10982 | { |
| 10983 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10984 | return CMD_WARNING; |
| 10985 | } |
| 10986 | } |
| 10987 | else |
| 10988 | { |
| 10989 | bgp = bgp_get_default (); |
| 10990 | if (bgp == NULL) |
| 10991 | { |
| 10992 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10993 | return CMD_WARNING; |
| 10994 | } |
| 10995 | } |
| 10996 | |
| 10997 | if (argc == 3) |
| 10998 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10999 | else |
| 11000 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11001 | |
| 11002 | if (! peer) |
| 11003 | return CMD_WARNING; |
| 11004 | |
| 11005 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 11006 | { |
| 11007 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11008 | VTY_NEWLINE); |
| 11009 | return CMD_WARNING; |
| 11010 | } |
| 11011 | |
| 11012 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 11013 | PEER_FLAG_RSERVER_CLIENT)) |
| 11014 | { |
| 11015 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11016 | VTY_NEWLINE); |
| 11017 | return CMD_WARNING; |
| 11018 | } |
| 11019 | |
| 11020 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 11021 | (argc == 3) ? argv[2] : argv[1], |
| 11022 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 11023 | } |
| 11024 | |
| 11025 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 11026 | show_ip_bgp_rsclient_prefix_cmd, |
| 11027 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11028 | SHOW_STR |
| 11029 | IP_STR |
| 11030 | BGP_STR |
| 11031 | "Information about Route Server Client\n" |
| 11032 | NEIGHBOR_ADDR_STR |
| 11033 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11034 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11035 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11036 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 11037 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11038 | SHOW_STR |
| 11039 | BGP_STR |
| 11040 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11041 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11042 | "Address family\n" |
| 11043 | "Address Family modifier\n" |
| 11044 | "Address Family modifier\n" |
| 11045 | "Information about Route Server Client\n" |
| 11046 | NEIGHBOR_ADDR_STR |
| 11047 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11048 | { |
| 11049 | struct bgp *bgp; |
| 11050 | struct peer *peer; |
| 11051 | safi_t safi; |
| 11052 | |
| 11053 | /* BGP structure lookup. */ |
| 11054 | if (argc == 4) |
| 11055 | { |
| 11056 | bgp = bgp_lookup_by_name (argv[0]); |
| 11057 | if (bgp == NULL) |
| 11058 | { |
| 11059 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11060 | return CMD_WARNING; |
| 11061 | } |
| 11062 | } |
| 11063 | else |
| 11064 | { |
| 11065 | bgp = bgp_get_default (); |
| 11066 | if (bgp == NULL) |
| 11067 | { |
| 11068 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11069 | return CMD_WARNING; |
| 11070 | } |
| 11071 | } |
| 11072 | |
| 11073 | if (argc == 4) { |
| 11074 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11075 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11076 | } else { |
| 11077 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11078 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11079 | } |
| 11080 | |
| 11081 | if (! peer) |
| 11082 | return CMD_WARNING; |
| 11083 | |
| 11084 | if (! peer->afc[AFI_IP][safi]) |
| 11085 | { |
| 11086 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11087 | VTY_NEWLINE); |
| 11088 | return CMD_WARNING; |
| 11089 | } |
| 11090 | |
| 11091 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 11092 | PEER_FLAG_RSERVER_CLIENT)) |
| 11093 | { |
| 11094 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11095 | VTY_NEWLINE); |
| 11096 | return CMD_WARNING; |
| 11097 | } |
| 11098 | |
| 11099 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 11100 | (argc == 4) ? argv[3] : argv[2], |
| 11101 | AFI_IP, safi, NULL, 1); |
| 11102 | } |
| 11103 | |
| 11104 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11105 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 11106 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11107 | SHOW_STR |
| 11108 | BGP_STR |
| 11109 | "Address family\n" |
| 11110 | "Address Family modifier\n" |
| 11111 | "Address Family modifier\n" |
| 11112 | "Information about Route Server Client\n" |
| 11113 | NEIGHBOR_ADDR_STR |
| 11114 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11115 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11116 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11117 | DEFUN (show_bgp_view_neighbor_routes, |
| 11118 | show_bgp_view_neighbor_routes_cmd, |
| 11119 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11120 | SHOW_STR |
| 11121 | BGP_STR |
| 11122 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11123 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11124 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11125 | "Neighbor to display information about\n" |
| 11126 | "Neighbor to display information about\n" |
| 11127 | "Display routes learned from neighbor\n") |
| 11128 | { |
| 11129 | struct peer *peer; |
| 11130 | |
| 11131 | if (argc == 2) |
| 11132 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11133 | else |
| 11134 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11135 | |
| 11136 | if (! peer) |
| 11137 | return CMD_WARNING; |
| 11138 | |
| 11139 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11140 | bgp_show_type_neighbor); |
| 11141 | } |
| 11142 | |
| 11143 | ALIAS (show_bgp_view_neighbor_routes, |
| 11144 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11145 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11146 | SHOW_STR |
| 11147 | BGP_STR |
| 11148 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11149 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11150 | "Address family\n" |
| 11151 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11152 | "Neighbor to display information about\n" |
| 11153 | "Neighbor to display information about\n" |
| 11154 | "Display routes learned from neighbor\n") |
| 11155 | |
| 11156 | DEFUN (show_bgp_view_neighbor_damp, |
| 11157 | show_bgp_view_neighbor_damp_cmd, |
| 11158 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11159 | SHOW_STR |
| 11160 | BGP_STR |
| 11161 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11162 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11163 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11164 | "Neighbor to display information about\n" |
| 11165 | "Neighbor to display information about\n" |
| 11166 | "Display the dampened routes received from neighbor\n") |
| 11167 | { |
| 11168 | struct peer *peer; |
| 11169 | |
| 11170 | if (argc == 2) |
| 11171 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11172 | else |
| 11173 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11174 | |
| 11175 | if (! peer) |
| 11176 | return CMD_WARNING; |
| 11177 | |
| 11178 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11179 | bgp_show_type_damp_neighbor); |
| 11180 | } |
| 11181 | |
| 11182 | ALIAS (show_bgp_view_neighbor_damp, |
| 11183 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11184 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11185 | SHOW_STR |
| 11186 | BGP_STR |
| 11187 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11188 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11189 | "Address family\n" |
| 11190 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11191 | "Neighbor to display information about\n" |
| 11192 | "Neighbor to display information about\n" |
| 11193 | "Display the dampened routes received from neighbor\n") |
| 11194 | |
| 11195 | DEFUN (show_bgp_view_neighbor_flap, |
| 11196 | show_bgp_view_neighbor_flap_cmd, |
| 11197 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11198 | SHOW_STR |
| 11199 | BGP_STR |
| 11200 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11201 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11202 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11203 | "Neighbor to display information about\n" |
| 11204 | "Neighbor to display information about\n" |
| 11205 | "Display flap statistics of the routes learned from neighbor\n") |
| 11206 | { |
| 11207 | struct peer *peer; |
| 11208 | |
| 11209 | if (argc == 2) |
| 11210 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11211 | else |
| 11212 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11213 | |
| 11214 | if (! peer) |
| 11215 | return CMD_WARNING; |
| 11216 | |
| 11217 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11218 | bgp_show_type_flap_neighbor); |
| 11219 | } |
| 11220 | |
| 11221 | ALIAS (show_bgp_view_neighbor_flap, |
| 11222 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11223 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11224 | SHOW_STR |
| 11225 | BGP_STR |
| 11226 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11227 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11228 | "Address family\n" |
| 11229 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11230 | "Neighbor to display information about\n" |
| 11231 | "Neighbor to display information about\n" |
| 11232 | "Display flap statistics of the routes learned from neighbor\n") |
| 11233 | |
| 11234 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11235 | show_bgp_neighbor_routes_cmd, |
| 11236 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11237 | SHOW_STR |
| 11238 | BGP_STR |
| 11239 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11240 | "Neighbor to display information about\n" |
| 11241 | "Neighbor to display information about\n" |
| 11242 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11243 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11244 | |
| 11245 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11246 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11247 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11248 | SHOW_STR |
| 11249 | BGP_STR |
| 11250 | "Address family\n" |
| 11251 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11252 | "Neighbor to display information about\n" |
| 11253 | "Neighbor to display information about\n" |
| 11254 | "Display routes learned from neighbor\n") |
| 11255 | |
| 11256 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11257 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11258 | ipv6_bgp_neighbor_routes_cmd, |
| 11259 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11260 | SHOW_STR |
| 11261 | IPV6_STR |
| 11262 | BGP_STR |
| 11263 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11264 | "Neighbor to display information about\n" |
| 11265 | "Neighbor to display information about\n" |
| 11266 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11267 | |
| 11268 | /* old command */ |
| 11269 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11270 | ipv6_mbgp_neighbor_routes_cmd, |
| 11271 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11272 | SHOW_STR |
| 11273 | IPV6_STR |
| 11274 | MBGP_STR |
| 11275 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11276 | "Neighbor to display information about\n" |
| 11277 | "Neighbor to display information about\n" |
| 11278 | "Display routes learned from neighbor\n") |
| 11279 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11280 | struct peer *peer; |
| 11281 | |
| 11282 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11283 | if (! peer) |
| 11284 | return CMD_WARNING; |
| 11285 | |
| 11286 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11287 | bgp_show_type_neighbor); |
| 11288 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11289 | |
| 11290 | ALIAS (show_bgp_view_neighbor_flap, |
| 11291 | show_bgp_neighbor_flap_cmd, |
| 11292 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11293 | SHOW_STR |
| 11294 | BGP_STR |
| 11295 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11296 | "Neighbor to display information about\n" |
| 11297 | "Neighbor to display information about\n" |
| 11298 | "Display flap statistics of the routes learned from neighbor\n") |
| 11299 | |
| 11300 | ALIAS (show_bgp_view_neighbor_flap, |
| 11301 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11302 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11303 | SHOW_STR |
| 11304 | BGP_STR |
| 11305 | "Address family\n" |
| 11306 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11307 | "Neighbor to display information about\n" |
| 11308 | "Neighbor to display information about\n" |
| 11309 | "Display flap statistics of the routes learned from neighbor\n") |
| 11310 | |
| 11311 | ALIAS (show_bgp_view_neighbor_damp, |
| 11312 | show_bgp_neighbor_damp_cmd, |
| 11313 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11314 | SHOW_STR |
| 11315 | BGP_STR |
| 11316 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11317 | "Neighbor to display information about\n" |
| 11318 | "Neighbor to display information about\n" |
| 11319 | "Display the dampened routes received from neighbor\n") |
| 11320 | |
| 11321 | ALIAS (show_bgp_view_neighbor_damp, |
| 11322 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11323 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11324 | SHOW_STR |
| 11325 | BGP_STR |
| 11326 | "Address family\n" |
| 11327 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11328 | "Neighbor to display information about\n" |
| 11329 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11330 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11331 | |
| 11332 | DEFUN (show_bgp_view_rsclient, |
| 11333 | show_bgp_view_rsclient_cmd, |
| 11334 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11335 | SHOW_STR |
| 11336 | BGP_STR |
| 11337 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11338 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11339 | "Information about Route Server Client\n" |
| 11340 | NEIGHBOR_ADDR_STR) |
| 11341 | { |
| 11342 | struct bgp_table *table; |
| 11343 | struct peer *peer; |
| 11344 | |
| 11345 | if (argc == 2) |
| 11346 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11347 | else |
| 11348 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11349 | |
| 11350 | if (! peer) |
| 11351 | return CMD_WARNING; |
| 11352 | |
| 11353 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11354 | { |
| 11355 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11356 | VTY_NEWLINE); |
| 11357 | return CMD_WARNING; |
| 11358 | } |
| 11359 | |
| 11360 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11361 | PEER_FLAG_RSERVER_CLIENT)) |
| 11362 | { |
| 11363 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11364 | VTY_NEWLINE); |
| 11365 | return CMD_WARNING; |
| 11366 | } |
| 11367 | |
| 11368 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11369 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11370 | 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] | 11371 | } |
| 11372 | |
| 11373 | ALIAS (show_bgp_view_rsclient, |
| 11374 | show_bgp_rsclient_cmd, |
| 11375 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11376 | SHOW_STR |
| 11377 | BGP_STR |
| 11378 | "Information about Route Server Client\n" |
| 11379 | NEIGHBOR_ADDR_STR) |
| 11380 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11381 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11382 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11383 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11384 | SHOW_STR |
| 11385 | BGP_STR |
| 11386 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11387 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11388 | "Address family\n" |
| 11389 | "Address Family modifier\n" |
| 11390 | "Address Family modifier\n" |
| 11391 | "Information about Route Server Client\n" |
| 11392 | NEIGHBOR_ADDR_STR) |
| 11393 | { |
| 11394 | struct bgp_table *table; |
| 11395 | struct peer *peer; |
| 11396 | safi_t safi; |
| 11397 | |
| 11398 | if (argc == 3) { |
| 11399 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11400 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11401 | } else { |
| 11402 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11403 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11404 | } |
| 11405 | |
| 11406 | if (! peer) |
| 11407 | return CMD_WARNING; |
| 11408 | |
| 11409 | if (! peer->afc[AFI_IP6][safi]) |
| 11410 | { |
| 11411 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11412 | VTY_NEWLINE); |
| 11413 | return CMD_WARNING; |
| 11414 | } |
| 11415 | |
| 11416 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11417 | PEER_FLAG_RSERVER_CLIENT)) |
| 11418 | { |
| 11419 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11420 | VTY_NEWLINE); |
| 11421 | return CMD_WARNING; |
| 11422 | } |
| 11423 | |
| 11424 | table = peer->rib[AFI_IP6][safi]; |
| 11425 | |
| 11426 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11427 | } |
| 11428 | |
| 11429 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11430 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11431 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11432 | SHOW_STR |
| 11433 | BGP_STR |
| 11434 | "Address family\n" |
| 11435 | "Address Family modifier\n" |
| 11436 | "Address Family modifier\n" |
| 11437 | "Information about Route Server Client\n" |
| 11438 | NEIGHBOR_ADDR_STR) |
| 11439 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11440 | DEFUN (show_bgp_view_rsclient_route, |
| 11441 | show_bgp_view_rsclient_route_cmd, |
| 11442 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11443 | SHOW_STR |
| 11444 | BGP_STR |
| 11445 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11446 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11447 | "Information about Route Server Client\n" |
| 11448 | NEIGHBOR_ADDR_STR |
| 11449 | "Network in the BGP routing table to display\n") |
| 11450 | { |
| 11451 | struct bgp *bgp; |
| 11452 | struct peer *peer; |
| 11453 | |
| 11454 | /* BGP structure lookup. */ |
| 11455 | if (argc == 3) |
| 11456 | { |
| 11457 | bgp = bgp_lookup_by_name (argv[0]); |
| 11458 | if (bgp == NULL) |
| 11459 | { |
| 11460 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11461 | return CMD_WARNING; |
| 11462 | } |
| 11463 | } |
| 11464 | else |
| 11465 | { |
| 11466 | bgp = bgp_get_default (); |
| 11467 | if (bgp == NULL) |
| 11468 | { |
| 11469 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11470 | return CMD_WARNING; |
| 11471 | } |
| 11472 | } |
| 11473 | |
| 11474 | if (argc == 3) |
| 11475 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11476 | else |
| 11477 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11478 | |
| 11479 | if (! peer) |
| 11480 | return CMD_WARNING; |
| 11481 | |
| 11482 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11483 | { |
| 11484 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11485 | VTY_NEWLINE); |
| 11486 | return CMD_WARNING; |
| 11487 | } |
| 11488 | |
| 11489 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11490 | PEER_FLAG_RSERVER_CLIENT)) |
| 11491 | { |
| 11492 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11493 | VTY_NEWLINE); |
| 11494 | return CMD_WARNING; |
| 11495 | } |
| 11496 | |
| 11497 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11498 | (argc == 3) ? argv[2] : argv[1], |
| 11499 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11500 | } |
| 11501 | |
| 11502 | ALIAS (show_bgp_view_rsclient_route, |
| 11503 | show_bgp_rsclient_route_cmd, |
| 11504 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11505 | SHOW_STR |
| 11506 | BGP_STR |
| 11507 | "Information about Route Server Client\n" |
| 11508 | NEIGHBOR_ADDR_STR |
| 11509 | "Network in the BGP routing table to display\n") |
| 11510 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11511 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11512 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11513 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11514 | SHOW_STR |
| 11515 | BGP_STR |
| 11516 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11517 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11518 | "Address family\n" |
| 11519 | "Address Family modifier\n" |
| 11520 | "Address Family modifier\n" |
| 11521 | "Information about Route Server Client\n" |
| 11522 | NEIGHBOR_ADDR_STR |
| 11523 | "Network in the BGP routing table to display\n") |
| 11524 | { |
| 11525 | struct bgp *bgp; |
| 11526 | struct peer *peer; |
| 11527 | safi_t safi; |
| 11528 | |
| 11529 | /* BGP structure lookup. */ |
| 11530 | if (argc == 4) |
| 11531 | { |
| 11532 | bgp = bgp_lookup_by_name (argv[0]); |
| 11533 | if (bgp == NULL) |
| 11534 | { |
| 11535 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11536 | return CMD_WARNING; |
| 11537 | } |
| 11538 | } |
| 11539 | else |
| 11540 | { |
| 11541 | bgp = bgp_get_default (); |
| 11542 | if (bgp == NULL) |
| 11543 | { |
| 11544 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11545 | return CMD_WARNING; |
| 11546 | } |
| 11547 | } |
| 11548 | |
| 11549 | if (argc == 4) { |
| 11550 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11551 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11552 | } else { |
| 11553 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11554 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11555 | } |
| 11556 | |
| 11557 | if (! peer) |
| 11558 | return CMD_WARNING; |
| 11559 | |
| 11560 | if (! peer->afc[AFI_IP6][safi]) |
| 11561 | { |
| 11562 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11563 | VTY_NEWLINE); |
| 11564 | return CMD_WARNING; |
| 11565 | } |
| 11566 | |
| 11567 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11568 | PEER_FLAG_RSERVER_CLIENT)) |
| 11569 | { |
| 11570 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11571 | VTY_NEWLINE); |
| 11572 | return CMD_WARNING; |
| 11573 | } |
| 11574 | |
| 11575 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11576 | (argc == 4) ? argv[3] : argv[2], |
| 11577 | AFI_IP6, safi, NULL, 0); |
| 11578 | } |
| 11579 | |
| 11580 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11581 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11582 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11583 | SHOW_STR |
| 11584 | BGP_STR |
| 11585 | "Address family\n" |
| 11586 | "Address Family modifier\n" |
| 11587 | "Address Family modifier\n" |
| 11588 | "Information about Route Server Client\n" |
| 11589 | NEIGHBOR_ADDR_STR |
| 11590 | "Network in the BGP routing table to display\n") |
| 11591 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11592 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11593 | show_bgp_view_rsclient_prefix_cmd, |
| 11594 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11595 | SHOW_STR |
| 11596 | BGP_STR |
| 11597 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11598 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11599 | "Information about Route Server Client\n" |
| 11600 | NEIGHBOR_ADDR_STR |
| 11601 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11602 | { |
| 11603 | struct bgp *bgp; |
| 11604 | struct peer *peer; |
| 11605 | |
| 11606 | /* BGP structure lookup. */ |
| 11607 | if (argc == 3) |
| 11608 | { |
| 11609 | bgp = bgp_lookup_by_name (argv[0]); |
| 11610 | if (bgp == NULL) |
| 11611 | { |
| 11612 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11613 | return CMD_WARNING; |
| 11614 | } |
| 11615 | } |
| 11616 | else |
| 11617 | { |
| 11618 | bgp = bgp_get_default (); |
| 11619 | if (bgp == NULL) |
| 11620 | { |
| 11621 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11622 | return CMD_WARNING; |
| 11623 | } |
| 11624 | } |
| 11625 | |
| 11626 | if (argc == 3) |
| 11627 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11628 | else |
| 11629 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11630 | |
| 11631 | if (! peer) |
| 11632 | return CMD_WARNING; |
| 11633 | |
| 11634 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11635 | { |
| 11636 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11637 | VTY_NEWLINE); |
| 11638 | return CMD_WARNING; |
| 11639 | } |
| 11640 | |
| 11641 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11642 | PEER_FLAG_RSERVER_CLIENT)) |
| 11643 | { |
| 11644 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11645 | VTY_NEWLINE); |
| 11646 | return CMD_WARNING; |
| 11647 | } |
| 11648 | |
| 11649 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11650 | (argc == 3) ? argv[2] : argv[1], |
| 11651 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11652 | } |
| 11653 | |
| 11654 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11655 | show_bgp_rsclient_prefix_cmd, |
| 11656 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11657 | SHOW_STR |
| 11658 | BGP_STR |
| 11659 | "Information about Route Server Client\n" |
| 11660 | NEIGHBOR_ADDR_STR |
| 11661 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11662 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11663 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11664 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11665 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11666 | SHOW_STR |
| 11667 | BGP_STR |
| 11668 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11669 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11670 | "Address family\n" |
| 11671 | "Address Family modifier\n" |
| 11672 | "Address Family modifier\n" |
| 11673 | "Information about Route Server Client\n" |
| 11674 | NEIGHBOR_ADDR_STR |
| 11675 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11676 | { |
| 11677 | struct bgp *bgp; |
| 11678 | struct peer *peer; |
| 11679 | safi_t safi; |
| 11680 | |
| 11681 | /* BGP structure lookup. */ |
| 11682 | if (argc == 4) |
| 11683 | { |
| 11684 | bgp = bgp_lookup_by_name (argv[0]); |
| 11685 | if (bgp == NULL) |
| 11686 | { |
| 11687 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11688 | return CMD_WARNING; |
| 11689 | } |
| 11690 | } |
| 11691 | else |
| 11692 | { |
| 11693 | bgp = bgp_get_default (); |
| 11694 | if (bgp == NULL) |
| 11695 | { |
| 11696 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11697 | return CMD_WARNING; |
| 11698 | } |
| 11699 | } |
| 11700 | |
| 11701 | if (argc == 4) { |
| 11702 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11703 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11704 | } else { |
| 11705 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11706 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11707 | } |
| 11708 | |
| 11709 | if (! peer) |
| 11710 | return CMD_WARNING; |
| 11711 | |
| 11712 | if (! peer->afc[AFI_IP6][safi]) |
| 11713 | { |
| 11714 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11715 | VTY_NEWLINE); |
| 11716 | return CMD_WARNING; |
| 11717 | } |
| 11718 | |
| 11719 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11720 | PEER_FLAG_RSERVER_CLIENT)) |
| 11721 | { |
| 11722 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11723 | VTY_NEWLINE); |
| 11724 | return CMD_WARNING; |
| 11725 | } |
| 11726 | |
| 11727 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11728 | (argc == 4) ? argv[3] : argv[2], |
| 11729 | AFI_IP6, safi, NULL, 1); |
| 11730 | } |
| 11731 | |
| 11732 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11733 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11734 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11735 | SHOW_STR |
| 11736 | BGP_STR |
| 11737 | "Address family\n" |
| 11738 | "Address Family modifier\n" |
| 11739 | "Address Family modifier\n" |
| 11740 | "Information about Route Server Client\n" |
| 11741 | NEIGHBOR_ADDR_STR |
| 11742 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11743 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11744 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11745 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11746 | struct bgp_table *bgp_distance_table; |
| 11747 | |
| 11748 | struct bgp_distance |
| 11749 | { |
| 11750 | /* Distance value for the IP source prefix. */ |
| 11751 | u_char distance; |
| 11752 | |
| 11753 | /* Name of the access-list to be matched. */ |
| 11754 | char *access_list; |
| 11755 | }; |
| 11756 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11757 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11758 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11759 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11760 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11761 | } |
| 11762 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11763 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11764 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11765 | { |
| 11766 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11767 | } |
| 11768 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11769 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11770 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11771 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11772 | { |
| 11773 | int ret; |
| 11774 | struct prefix_ipv4 p; |
| 11775 | u_char distance; |
| 11776 | struct bgp_node *rn; |
| 11777 | struct bgp_distance *bdistance; |
| 11778 | |
| 11779 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11780 | if (ret == 0) |
| 11781 | { |
| 11782 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11783 | return CMD_WARNING; |
| 11784 | } |
| 11785 | |
| 11786 | distance = atoi (distance_str); |
| 11787 | |
| 11788 | /* Get BGP distance node. */ |
| 11789 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11790 | if (rn->info) |
| 11791 | { |
| 11792 | bdistance = rn->info; |
| 11793 | bgp_unlock_node (rn); |
| 11794 | } |
| 11795 | else |
| 11796 | { |
| 11797 | bdistance = bgp_distance_new (); |
| 11798 | rn->info = bdistance; |
| 11799 | } |
| 11800 | |
| 11801 | /* Set distance value. */ |
| 11802 | bdistance->distance = distance; |
| 11803 | |
| 11804 | /* Reset access-list configuration. */ |
| 11805 | if (bdistance->access_list) |
| 11806 | { |
| 11807 | free (bdistance->access_list); |
| 11808 | bdistance->access_list = NULL; |
| 11809 | } |
| 11810 | if (access_list_str) |
| 11811 | bdistance->access_list = strdup (access_list_str); |
| 11812 | |
| 11813 | return CMD_SUCCESS; |
| 11814 | } |
| 11815 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11816 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11817 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11818 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11819 | { |
| 11820 | int ret; |
| 11821 | struct prefix_ipv4 p; |
| 11822 | u_char distance; |
| 11823 | struct bgp_node *rn; |
| 11824 | struct bgp_distance *bdistance; |
| 11825 | |
| 11826 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11827 | if (ret == 0) |
| 11828 | { |
| 11829 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11830 | return CMD_WARNING; |
| 11831 | } |
| 11832 | |
| 11833 | distance = atoi (distance_str); |
| 11834 | |
| 11835 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11836 | if (! rn) |
| 11837 | { |
| 11838 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11839 | return CMD_WARNING; |
| 11840 | } |
| 11841 | |
| 11842 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 11843 | |
| 11844 | if (bdistance->distance != distance) |
| 11845 | { |
| 11846 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 11847 | return CMD_WARNING; |
| 11848 | } |
| 11849 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11850 | if (bdistance->access_list) |
| 11851 | free (bdistance->access_list); |
| 11852 | bgp_distance_free (bdistance); |
| 11853 | |
| 11854 | rn->info = NULL; |
| 11855 | bgp_unlock_node (rn); |
| 11856 | bgp_unlock_node (rn); |
| 11857 | |
| 11858 | return CMD_SUCCESS; |
| 11859 | } |
| 11860 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11861 | /* Apply BGP information to distance method. */ |
| 11862 | u_char |
| 11863 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11864 | { |
| 11865 | struct bgp_node *rn; |
| 11866 | struct prefix_ipv4 q; |
| 11867 | struct peer *peer; |
| 11868 | struct bgp_distance *bdistance; |
| 11869 | struct access_list *alist; |
| 11870 | struct bgp_static *bgp_static; |
| 11871 | |
| 11872 | if (! bgp) |
| 11873 | return 0; |
| 11874 | |
| 11875 | if (p->family != AF_INET) |
| 11876 | return 0; |
| 11877 | |
| 11878 | peer = rinfo->peer; |
| 11879 | |
| 11880 | if (peer->su.sa.sa_family != AF_INET) |
| 11881 | return 0; |
| 11882 | |
| 11883 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11884 | q.family = AF_INET; |
| 11885 | q.prefix = peer->su.sin.sin_addr; |
| 11886 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11887 | |
| 11888 | /* Check source address. */ |
| 11889 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11890 | if (rn) |
| 11891 | { |
| 11892 | bdistance = rn->info; |
| 11893 | bgp_unlock_node (rn); |
| 11894 | |
| 11895 | if (bdistance->access_list) |
| 11896 | { |
| 11897 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11898 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11899 | return bdistance->distance; |
| 11900 | } |
| 11901 | else |
| 11902 | return bdistance->distance; |
| 11903 | } |
| 11904 | |
| 11905 | /* Backdoor check. */ |
| 11906 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11907 | if (rn) |
| 11908 | { |
| 11909 | bgp_static = rn->info; |
| 11910 | bgp_unlock_node (rn); |
| 11911 | |
| 11912 | if (bgp_static->backdoor) |
| 11913 | { |
| 11914 | if (bgp->distance_local) |
| 11915 | return bgp->distance_local; |
| 11916 | else |
| 11917 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11918 | } |
| 11919 | } |
| 11920 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 11921 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11922 | { |
| 11923 | if (bgp->distance_ebgp) |
| 11924 | return bgp->distance_ebgp; |
| 11925 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11926 | } |
| 11927 | else |
| 11928 | { |
| 11929 | if (bgp->distance_ibgp) |
| 11930 | return bgp->distance_ibgp; |
| 11931 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11932 | } |
| 11933 | } |
| 11934 | |
| 11935 | DEFUN (bgp_distance, |
| 11936 | bgp_distance_cmd, |
| 11937 | "distance bgp <1-255> <1-255> <1-255>", |
| 11938 | "Define an administrative distance\n" |
| 11939 | "BGP distance\n" |
| 11940 | "Distance for routes external to the AS\n" |
| 11941 | "Distance for routes internal to the AS\n" |
| 11942 | "Distance for local routes\n") |
| 11943 | { |
| 11944 | struct bgp *bgp; |
| 11945 | |
| 11946 | bgp = vty->index; |
| 11947 | |
| 11948 | bgp->distance_ebgp = atoi (argv[0]); |
| 11949 | bgp->distance_ibgp = atoi (argv[1]); |
| 11950 | bgp->distance_local = atoi (argv[2]); |
| 11951 | return CMD_SUCCESS; |
| 11952 | } |
| 11953 | |
| 11954 | DEFUN (no_bgp_distance, |
| 11955 | no_bgp_distance_cmd, |
| 11956 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11957 | NO_STR |
| 11958 | "Define an administrative distance\n" |
| 11959 | "BGP distance\n" |
| 11960 | "Distance for routes external to the AS\n" |
| 11961 | "Distance for routes internal to the AS\n" |
| 11962 | "Distance for local routes\n") |
| 11963 | { |
| 11964 | struct bgp *bgp; |
| 11965 | |
| 11966 | bgp = vty->index; |
| 11967 | |
| 11968 | bgp->distance_ebgp= 0; |
| 11969 | bgp->distance_ibgp = 0; |
| 11970 | bgp->distance_local = 0; |
| 11971 | return CMD_SUCCESS; |
| 11972 | } |
| 11973 | |
| 11974 | ALIAS (no_bgp_distance, |
| 11975 | no_bgp_distance2_cmd, |
| 11976 | "no distance bgp", |
| 11977 | NO_STR |
| 11978 | "Define an administrative distance\n" |
| 11979 | "BGP distance\n") |
| 11980 | |
| 11981 | DEFUN (bgp_distance_source, |
| 11982 | bgp_distance_source_cmd, |
| 11983 | "distance <1-255> A.B.C.D/M", |
| 11984 | "Define an administrative distance\n" |
| 11985 | "Administrative distance\n" |
| 11986 | "IP source prefix\n") |
| 11987 | { |
| 11988 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11989 | return CMD_SUCCESS; |
| 11990 | } |
| 11991 | |
| 11992 | DEFUN (no_bgp_distance_source, |
| 11993 | no_bgp_distance_source_cmd, |
| 11994 | "no distance <1-255> A.B.C.D/M", |
| 11995 | NO_STR |
| 11996 | "Define an administrative distance\n" |
| 11997 | "Administrative distance\n" |
| 11998 | "IP source prefix\n") |
| 11999 | { |
| 12000 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 12001 | return CMD_SUCCESS; |
| 12002 | } |
| 12003 | |
| 12004 | DEFUN (bgp_distance_source_access_list, |
| 12005 | bgp_distance_source_access_list_cmd, |
| 12006 | "distance <1-255> A.B.C.D/M WORD", |
| 12007 | "Define an administrative distance\n" |
| 12008 | "Administrative distance\n" |
| 12009 | "IP source prefix\n" |
| 12010 | "Access list name\n") |
| 12011 | { |
| 12012 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 12013 | return CMD_SUCCESS; |
| 12014 | } |
| 12015 | |
| 12016 | DEFUN (no_bgp_distance_source_access_list, |
| 12017 | no_bgp_distance_source_access_list_cmd, |
| 12018 | "no distance <1-255> A.B.C.D/M WORD", |
| 12019 | NO_STR |
| 12020 | "Define an administrative distance\n" |
| 12021 | "Administrative distance\n" |
| 12022 | "IP source prefix\n" |
| 12023 | "Access list name\n") |
| 12024 | { |
| 12025 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 12026 | return CMD_SUCCESS; |
| 12027 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12028 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12029 | DEFUN (bgp_damp_set, |
| 12030 | bgp_damp_set_cmd, |
| 12031 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12032 | "BGP Specific commands\n" |
| 12033 | "Enable route-flap dampening\n" |
| 12034 | "Half-life time for the penalty\n" |
| 12035 | "Value to start reusing a route\n" |
| 12036 | "Value to start suppressing a route\n" |
| 12037 | "Maximum duration to suppress a stable route\n") |
| 12038 | { |
| 12039 | struct bgp *bgp; |
| 12040 | int half = DEFAULT_HALF_LIFE * 60; |
| 12041 | int reuse = DEFAULT_REUSE; |
| 12042 | int suppress = DEFAULT_SUPPRESS; |
| 12043 | int max = 4 * half; |
| 12044 | |
| 12045 | if (argc == 4) |
| 12046 | { |
| 12047 | half = atoi (argv[0]) * 60; |
| 12048 | reuse = atoi (argv[1]); |
| 12049 | suppress = atoi (argv[2]); |
| 12050 | max = atoi (argv[3]) * 60; |
| 12051 | } |
| 12052 | else if (argc == 1) |
| 12053 | { |
| 12054 | half = atoi (argv[0]) * 60; |
| 12055 | max = 4 * half; |
| 12056 | } |
| 12057 | |
| 12058 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 12059 | |
| 12060 | if (suppress < reuse) |
| 12061 | { |
| 12062 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 12063 | VTY_NEWLINE); |
| 12064 | return 0; |
| 12065 | } |
| 12066 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12067 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 12068 | half, reuse, suppress, max); |
| 12069 | } |
| 12070 | |
| 12071 | ALIAS (bgp_damp_set, |
| 12072 | bgp_damp_set2_cmd, |
| 12073 | "bgp dampening <1-45>", |
| 12074 | "BGP Specific commands\n" |
| 12075 | "Enable route-flap dampening\n" |
| 12076 | "Half-life time for the penalty\n") |
| 12077 | |
| 12078 | ALIAS (bgp_damp_set, |
| 12079 | bgp_damp_set3_cmd, |
| 12080 | "bgp dampening", |
| 12081 | "BGP Specific commands\n" |
| 12082 | "Enable route-flap dampening\n") |
| 12083 | |
| 12084 | DEFUN (bgp_damp_unset, |
| 12085 | bgp_damp_unset_cmd, |
| 12086 | "no bgp dampening", |
| 12087 | NO_STR |
| 12088 | "BGP Specific commands\n" |
| 12089 | "Enable route-flap dampening\n") |
| 12090 | { |
| 12091 | struct bgp *bgp; |
| 12092 | |
| 12093 | bgp = vty->index; |
| 12094 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 12095 | } |
| 12096 | |
| 12097 | ALIAS (bgp_damp_unset, |
| 12098 | bgp_damp_unset2_cmd, |
| 12099 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12100 | NO_STR |
| 12101 | "BGP Specific commands\n" |
| 12102 | "Enable route-flap dampening\n" |
| 12103 | "Half-life time for the penalty\n" |
| 12104 | "Value to start reusing a route\n" |
| 12105 | "Value to start suppressing a route\n" |
| 12106 | "Maximum duration to suppress a stable route\n") |
| 12107 | |
| 12108 | DEFUN (show_ip_bgp_dampened_paths, |
| 12109 | show_ip_bgp_dampened_paths_cmd, |
| 12110 | "show ip bgp dampened-paths", |
| 12111 | SHOW_STR |
| 12112 | IP_STR |
| 12113 | BGP_STR |
| 12114 | "Display paths suppressed due to dampening\n") |
| 12115 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12116 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 12117 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12118 | } |
| 12119 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12120 | ALIAS (show_ip_bgp_dampened_paths, |
| 12121 | show_ip_bgp_damp_dampened_paths_cmd, |
| 12122 | "show ip bgp dampening dampened-paths", |
| 12123 | SHOW_STR |
| 12124 | IP_STR |
| 12125 | BGP_STR |
| 12126 | "Display detailed information about dampening\n" |
| 12127 | "Display paths suppressed due to dampening\n") |
| 12128 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12129 | DEFUN (show_ip_bgp_flap_statistics, |
| 12130 | show_ip_bgp_flap_statistics_cmd, |
| 12131 | "show ip bgp flap-statistics", |
| 12132 | SHOW_STR |
| 12133 | IP_STR |
| 12134 | BGP_STR |
| 12135 | "Display flap statistics of routes\n") |
| 12136 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12137 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 12138 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12139 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12140 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12141 | ALIAS (show_ip_bgp_flap_statistics, |
| 12142 | show_ip_bgp_damp_flap_statistics_cmd, |
| 12143 | "show ip bgp dampening flap-statistics", |
| 12144 | SHOW_STR |
| 12145 | IP_STR |
| 12146 | BGP_STR |
| 12147 | "Display detailed information about dampening\n" |
| 12148 | "Display flap statistics of routes\n") |
| 12149 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12150 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12151 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12152 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12153 | const char *ip_str, afi_t afi, safi_t safi, |
| 12154 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12155 | { |
| 12156 | int ret; |
| 12157 | struct prefix match; |
| 12158 | struct bgp_node *rn; |
| 12159 | struct bgp_node *rm; |
| 12160 | struct bgp_info *ri; |
| 12161 | struct bgp_info *ri_temp; |
| 12162 | struct bgp *bgp; |
| 12163 | struct bgp_table *table; |
| 12164 | |
| 12165 | /* BGP structure lookup. */ |
| 12166 | if (view_name) |
| 12167 | { |
| 12168 | bgp = bgp_lookup_by_name (view_name); |
| 12169 | if (bgp == NULL) |
| 12170 | { |
| 12171 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12172 | return CMD_WARNING; |
| 12173 | } |
| 12174 | } |
| 12175 | else |
| 12176 | { |
| 12177 | bgp = bgp_get_default (); |
| 12178 | if (bgp == NULL) |
| 12179 | { |
| 12180 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12181 | return CMD_WARNING; |
| 12182 | } |
| 12183 | } |
| 12184 | |
| 12185 | /* Check IP address argument. */ |
| 12186 | ret = str2prefix (ip_str, &match); |
| 12187 | if (! ret) |
| 12188 | { |
| 12189 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12190 | return CMD_WARNING; |
| 12191 | } |
| 12192 | |
| 12193 | match.family = afi2family (afi); |
| 12194 | |
| 12195 | if (safi == SAFI_MPLS_VPN) |
| 12196 | { |
| 12197 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12198 | { |
| 12199 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12200 | continue; |
| 12201 | |
| 12202 | if ((table = rn->info) != NULL) |
| 12203 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12204 | { |
| 12205 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12206 | { |
| 12207 | ri = rm->info; |
| 12208 | while (ri) |
| 12209 | { |
| 12210 | if (ri->extra && ri->extra->damp_info) |
| 12211 | { |
| 12212 | ri_temp = ri->next; |
| 12213 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12214 | ri = ri_temp; |
| 12215 | } |
| 12216 | else |
| 12217 | ri = ri->next; |
| 12218 | } |
| 12219 | } |
| 12220 | |
| 12221 | bgp_unlock_node (rm); |
| 12222 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12223 | } |
| 12224 | } |
| 12225 | else |
| 12226 | { |
| 12227 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12228 | { |
| 12229 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12230 | { |
| 12231 | ri = rn->info; |
| 12232 | while (ri) |
| 12233 | { |
| 12234 | if (ri->extra && ri->extra->damp_info) |
| 12235 | { |
| 12236 | ri_temp = ri->next; |
| 12237 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12238 | ri = ri_temp; |
| 12239 | } |
| 12240 | else |
| 12241 | ri = ri->next; |
| 12242 | } |
| 12243 | } |
| 12244 | |
| 12245 | bgp_unlock_node (rn); |
| 12246 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12247 | } |
| 12248 | |
| 12249 | return CMD_SUCCESS; |
| 12250 | } |
| 12251 | |
| 12252 | DEFUN (clear_ip_bgp_dampening, |
| 12253 | clear_ip_bgp_dampening_cmd, |
| 12254 | "clear ip bgp dampening", |
| 12255 | CLEAR_STR |
| 12256 | IP_STR |
| 12257 | BGP_STR |
| 12258 | "Clear route flap dampening information\n") |
| 12259 | { |
| 12260 | bgp_damp_info_clean (); |
| 12261 | return CMD_SUCCESS; |
| 12262 | } |
| 12263 | |
| 12264 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12265 | clear_ip_bgp_dampening_prefix_cmd, |
| 12266 | "clear ip bgp dampening A.B.C.D/M", |
| 12267 | CLEAR_STR |
| 12268 | IP_STR |
| 12269 | BGP_STR |
| 12270 | "Clear route flap dampening information\n" |
| 12271 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12272 | { |
| 12273 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12274 | SAFI_UNICAST, NULL, 1); |
| 12275 | } |
| 12276 | |
| 12277 | DEFUN (clear_ip_bgp_dampening_address, |
| 12278 | clear_ip_bgp_dampening_address_cmd, |
| 12279 | "clear ip bgp dampening A.B.C.D", |
| 12280 | CLEAR_STR |
| 12281 | IP_STR |
| 12282 | BGP_STR |
| 12283 | "Clear route flap dampening information\n" |
| 12284 | "Network to clear damping information\n") |
| 12285 | { |
| 12286 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12287 | SAFI_UNICAST, NULL, 0); |
| 12288 | } |
| 12289 | |
| 12290 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12291 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12292 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12293 | CLEAR_STR |
| 12294 | IP_STR |
| 12295 | BGP_STR |
| 12296 | "Clear route flap dampening information\n" |
| 12297 | "Network to clear damping information\n" |
| 12298 | "Network mask\n") |
| 12299 | { |
| 12300 | int ret; |
| 12301 | char prefix_str[BUFSIZ]; |
| 12302 | |
| 12303 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12304 | if (! ret) |
| 12305 | { |
| 12306 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12307 | return CMD_WARNING; |
| 12308 | } |
| 12309 | |
| 12310 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12311 | SAFI_UNICAST, NULL, 0); |
| 12312 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12313 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12314 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12315 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12316 | afi_t afi, safi_t safi, int *write) |
| 12317 | { |
| 12318 | struct bgp_node *prn; |
| 12319 | struct bgp_node *rn; |
| 12320 | struct bgp_table *table; |
| 12321 | struct prefix *p; |
| 12322 | struct prefix_rd *prd; |
| 12323 | struct bgp_static *bgp_static; |
| 12324 | u_int32_t label; |
| 12325 | char buf[SU_ADDRSTRLEN]; |
| 12326 | char rdbuf[RD_ADDRSTRLEN]; |
| 12327 | |
| 12328 | /* Network configuration. */ |
| 12329 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12330 | if ((table = prn->info) != NULL) |
| 12331 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12332 | if ((bgp_static = rn->info) != NULL) |
| 12333 | { |
| 12334 | p = &rn->p; |
| 12335 | prd = (struct prefix_rd *) &prn->p; |
| 12336 | |
| 12337 | /* "address-family" display. */ |
| 12338 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12339 | |
| 12340 | /* "network" configuration display. */ |
| 12341 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12342 | label = decode_label (bgp_static->tag); |
| 12343 | |
| 12344 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12345 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12346 | p->prefixlen, |
| 12347 | rdbuf, label); |
| 12348 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12349 | } |
| 12350 | return 0; |
| 12351 | } |
| 12352 | |
| 12353 | /* Configuration of static route announcement and aggregate |
| 12354 | information. */ |
| 12355 | int |
| 12356 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12357 | afi_t afi, safi_t safi, int *write) |
| 12358 | { |
| 12359 | struct bgp_node *rn; |
| 12360 | struct prefix *p; |
| 12361 | struct bgp_static *bgp_static; |
| 12362 | struct bgp_aggregate *bgp_aggregate; |
| 12363 | char buf[SU_ADDRSTRLEN]; |
| 12364 | |
| 12365 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12366 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12367 | |
| 12368 | /* Network configuration. */ |
| 12369 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12370 | if ((bgp_static = rn->info) != NULL) |
| 12371 | { |
| 12372 | p = &rn->p; |
| 12373 | |
| 12374 | /* "address-family" display. */ |
| 12375 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12376 | |
| 12377 | /* "network" configuration display. */ |
| 12378 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12379 | { |
| 12380 | u_int32_t destination; |
| 12381 | struct in_addr netmask; |
| 12382 | |
| 12383 | destination = ntohl (p->u.prefix4.s_addr); |
| 12384 | masklen2ip (p->prefixlen, &netmask); |
| 12385 | vty_out (vty, " network %s", |
| 12386 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12387 | |
| 12388 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12389 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12390 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12391 | || p->u.prefix4.s_addr == 0) |
| 12392 | { |
| 12393 | /* Natural mask is not display. */ |
| 12394 | } |
| 12395 | else |
| 12396 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12397 | } |
| 12398 | else |
| 12399 | { |
| 12400 | vty_out (vty, " network %s/%d", |
| 12401 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12402 | p->prefixlen); |
| 12403 | } |
| 12404 | |
| 12405 | if (bgp_static->rmap.name) |
| 12406 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12407 | else |
| 12408 | { |
| 12409 | if (bgp_static->backdoor) |
| 12410 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12411 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12412 | |
| 12413 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12414 | } |
| 12415 | |
| 12416 | /* Aggregate-address configuration. */ |
| 12417 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12418 | if ((bgp_aggregate = rn->info) != NULL) |
| 12419 | { |
| 12420 | p = &rn->p; |
| 12421 | |
| 12422 | /* "address-family" display. */ |
| 12423 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12424 | |
| 12425 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12426 | { |
| 12427 | struct in_addr netmask; |
| 12428 | |
| 12429 | masklen2ip (p->prefixlen, &netmask); |
| 12430 | vty_out (vty, " aggregate-address %s %s", |
| 12431 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12432 | inet_ntoa (netmask)); |
| 12433 | } |
| 12434 | else |
| 12435 | { |
| 12436 | vty_out (vty, " aggregate-address %s/%d", |
| 12437 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12438 | p->prefixlen); |
| 12439 | } |
| 12440 | |
| 12441 | if (bgp_aggregate->as_set) |
| 12442 | vty_out (vty, " as-set"); |
| 12443 | |
| 12444 | if (bgp_aggregate->summary_only) |
| 12445 | vty_out (vty, " summary-only"); |
| 12446 | |
| 12447 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12448 | } |
| 12449 | |
| 12450 | return 0; |
| 12451 | } |
| 12452 | |
| 12453 | int |
| 12454 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12455 | { |
| 12456 | struct bgp_node *rn; |
| 12457 | struct bgp_distance *bdistance; |
| 12458 | |
| 12459 | /* Distance configuration. */ |
| 12460 | if (bgp->distance_ebgp |
| 12461 | && bgp->distance_ibgp |
| 12462 | && bgp->distance_local |
| 12463 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12464 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12465 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12466 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12467 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12468 | VTY_NEWLINE); |
| 12469 | |
| 12470 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12471 | if ((bdistance = rn->info) != NULL) |
| 12472 | { |
| 12473 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12474 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12475 | bdistance->access_list ? bdistance->access_list : "", |
| 12476 | VTY_NEWLINE); |
| 12477 | } |
| 12478 | |
| 12479 | return 0; |
| 12480 | } |
| 12481 | |
| 12482 | /* Allocate routing table structure and install commands. */ |
| 12483 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12484 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12485 | { |
| 12486 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12487 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12488 | |
| 12489 | /* IPv4 BGP commands. */ |
| 12490 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12491 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12492 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12493 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12494 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12495 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12496 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12497 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12498 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12499 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12500 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12501 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12502 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12503 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12504 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12505 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12506 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12507 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12508 | |
| 12509 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12510 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12511 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12512 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12513 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12514 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12515 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12516 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12517 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12518 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12519 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12520 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12521 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12522 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12523 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12524 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12525 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12526 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12527 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12528 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12529 | |
| 12530 | /* IPv4 unicast configuration. */ |
| 12531 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12532 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12533 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12534 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12535 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12536 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12537 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12538 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12539 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12540 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12541 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12542 | 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] | 12543 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12544 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12545 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12546 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12547 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12548 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12549 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12550 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12551 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12552 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12553 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12554 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12555 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12556 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12557 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12558 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12559 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12560 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12561 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12562 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12563 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12564 | |
| 12565 | /* IPv4 multicast configuration. */ |
| 12566 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12567 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12568 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12569 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12570 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12571 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12572 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12573 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12574 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12575 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12576 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12577 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12578 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12579 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12580 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12581 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12582 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12583 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12584 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12585 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12586 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12587 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12588 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12589 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12590 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12591 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12592 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12593 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12594 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12595 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12596 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12597 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12598 | |
| 12599 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12600 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12601 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12602 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12603 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12604 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12605 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12606 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12607 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12608 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12609 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12610 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12611 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12612 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12613 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12614 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12615 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12616 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12617 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12618 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12619 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12620 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12621 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12622 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12623 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12624 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12625 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12626 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12627 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12628 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12629 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12630 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12631 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12632 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12633 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12634 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12635 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12636 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12637 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12638 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12639 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12640 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12641 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12642 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12643 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12644 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12645 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12646 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12647 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12648 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12649 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12650 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12651 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12652 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12653 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12654 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12655 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12656 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12657 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12658 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12659 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12660 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12661 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12662 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12663 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12664 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12665 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12666 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12667 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12668 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12669 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12670 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12671 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12672 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12673 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12674 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12675 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12676 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12677 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12678 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12679 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12680 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12681 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12682 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12683 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12684 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12685 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12686 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12687 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12688 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12689 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12690 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12691 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12692 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12693 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12694 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12695 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12696 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12697 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12698 | |
| 12699 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12700 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12701 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12702 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12703 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12704 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12705 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12706 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12707 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12708 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12709 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12710 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12711 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12712 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12713 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12714 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12715 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12716 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12717 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12718 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12719 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12720 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12721 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12722 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12723 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12724 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12725 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12726 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12727 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12728 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12729 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12730 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12731 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12732 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12733 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12734 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12735 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12736 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12737 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12738 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12739 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12740 | |
| 12741 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12742 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12743 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12744 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12745 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12746 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12747 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12748 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12749 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12750 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12751 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12752 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12753 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12754 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12755 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12756 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12757 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12758 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12759 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12760 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12761 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12762 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12763 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12764 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12765 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12766 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12767 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12768 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12769 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12770 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12771 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12772 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12773 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12774 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12775 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12776 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12777 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12778 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12779 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12780 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12781 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12782 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12783 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12784 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12785 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12786 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12787 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12788 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12789 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12790 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12791 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12792 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12793 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12794 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12795 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12796 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12797 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12798 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12799 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12800 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12801 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12802 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12803 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12804 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12805 | install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12806 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12807 | install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12808 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12809 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12810 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12811 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12812 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12813 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12814 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12815 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12816 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12817 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12818 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12819 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12820 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 12821 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12822 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12823 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12824 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12825 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12826 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12827 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12828 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12829 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12830 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12831 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12832 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12833 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12834 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12835 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12836 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12837 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12838 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12839 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12840 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12841 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12842 | |
| 12843 | /* BGP dampening clear commands */ |
| 12844 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12845 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12846 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12847 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12848 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12849 | /* prefix count */ |
| 12850 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12851 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12852 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12853 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12854 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12855 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12856 | /* New config IPv6 BGP commands. */ |
| 12857 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12858 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12859 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12860 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12861 | |
| 12862 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12863 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12864 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12865 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12866 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12867 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12868 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12869 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12870 | /* Old config IPv6 BGP commands. */ |
| 12871 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12872 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12873 | |
| 12874 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12875 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12876 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12877 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12878 | |
| 12879 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12880 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12881 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12882 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12883 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12884 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12885 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12886 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12887 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12888 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12889 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12890 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12891 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12892 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12893 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12894 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12895 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12896 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12897 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12898 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12899 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12900 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12901 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12902 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12903 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12904 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12905 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12906 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12907 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12908 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12909 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12910 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12911 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12912 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12913 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12914 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12915 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12916 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12917 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12918 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12919 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12920 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12921 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12922 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12923 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12924 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12925 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12926 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12927 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12928 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12929 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12930 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12931 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12932 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12933 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12934 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12935 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12936 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12937 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12938 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12939 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12940 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12941 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12942 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12943 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12944 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12945 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12946 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12947 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12948 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12949 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12950 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12951 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12952 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12953 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12954 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12955 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12956 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12957 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12958 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12959 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12960 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12961 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12962 | |
| 12963 | /* Restricted: |
| 12964 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12965 | */ |
| 12966 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12967 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12968 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12969 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12970 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12971 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12972 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12973 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12974 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12975 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12976 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12977 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12978 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12979 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12980 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12981 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12982 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12983 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12984 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12985 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12986 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12987 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12988 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12989 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12990 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12991 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12992 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12993 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12994 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12995 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12996 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12997 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12998 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12999 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13000 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13001 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13002 | |
| 13003 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 13004 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13005 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13006 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 13007 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13008 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13009 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 13010 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13011 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13012 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 13013 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 13014 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 13015 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 13016 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 13017 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 13018 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 13019 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 13020 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 13021 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 13022 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 13023 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 13024 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 13025 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 13026 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 13027 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 13028 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 13029 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 13030 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 13031 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 13032 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 13033 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 13034 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 13035 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 13036 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 13037 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 13038 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 13039 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 13040 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 13041 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 13042 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 13043 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 13044 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 13045 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 13046 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 13047 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 13048 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 13049 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 13050 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 13051 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13052 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 13053 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 13054 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 13055 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13056 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13057 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13058 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13059 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13060 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13061 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13062 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 13063 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 13064 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 13065 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 13066 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 13067 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 13068 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 13069 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 13070 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 13071 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 13072 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 13073 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 13074 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 13075 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 13076 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 13077 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 13078 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 13079 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13080 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13081 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13082 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13083 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13084 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13085 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13086 | |
| 13087 | /* Statistics */ |
| 13088 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 13089 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 13090 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 13091 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 13092 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13093 | /* old command */ |
| 13094 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 13095 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 13096 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13097 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13098 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13099 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13100 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13101 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 13102 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 13103 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 13104 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 13105 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13106 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13107 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13108 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13109 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13110 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13111 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13112 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 13113 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 13114 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13115 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13116 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13117 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13118 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13119 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 13120 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13121 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13122 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13123 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13124 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13125 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13126 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13127 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13128 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13129 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13130 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13131 | /* old command */ |
| 13132 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 13133 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 13134 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13135 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13136 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13137 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13138 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13139 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 13140 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 13141 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 13142 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 13143 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13144 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13145 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13146 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13147 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13148 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13149 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13150 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 13151 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 13152 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13153 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13154 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13155 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13156 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13157 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 13158 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13159 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13160 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13161 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13162 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13163 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13164 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13165 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13166 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13167 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 13168 | |
| 13169 | /* old command */ |
| 13170 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13171 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13172 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13173 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13174 | |
| 13175 | /* old command */ |
| 13176 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13177 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13178 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13179 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13180 | |
| 13181 | /* old command */ |
| 13182 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13183 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13184 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13185 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13186 | #endif /* HAVE_IPV6 */ |
| 13187 | |
| 13188 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13189 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13190 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13191 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13192 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13193 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13194 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13195 | |
| 13196 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13197 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13198 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13199 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13200 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13201 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13202 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13203 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13204 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13205 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13206 | |
| 13207 | /* Deprecated AS-Pathlimit commands */ |
| 13208 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13209 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13210 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13211 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13212 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13213 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13214 | |
| 13215 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13216 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13217 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13218 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13219 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13220 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13221 | |
| 13222 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13223 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13224 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13225 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13226 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13227 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13228 | |
| 13229 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13230 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13231 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13232 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13233 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13234 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13235 | |
| 13236 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13237 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13238 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13239 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13240 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13241 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13242 | |
| 13243 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13244 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13245 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13246 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13247 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13248 | 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] | 13249 | |
| 13250 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13251 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13252 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13253 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13254 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13255 | |
| 13256 | void |
| 13257 | bgp_route_finish (void) |
| 13258 | { |
| 13259 | bgp_table_unlock (bgp_distance_table); |
| 13260 | bgp_distance_table = NULL; |
| 13261 | } |