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[]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [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 | } |
| 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 | { |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 243 | assert (rn && rn->table); |
| 244 | assert (ri && ri->peer && ri->peer->bgp); |
| 245 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 246 | /* Ignore 'pcount' for RS-client tables */ |
| 247 | if (rn->table->type != BGP_TABLE_MAIN |
| 248 | || ri->peer == ri->peer->bgp->peer_self) |
| 249 | return; |
| 250 | |
| 251 | if (BGP_INFO_HOLDDOWN (ri) |
| 252 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 253 | { |
| 254 | |
| 255 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 256 | |
| 257 | /* slight hack, but more robust against errors. */ |
| 258 | if (ri->peer->pcount[rn->table->afi][rn->table->safi]) |
| 259 | ri->peer->pcount[rn->table->afi][rn->table->safi]--; |
| 260 | else |
| 261 | { |
| 262 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 263 | __func__, ri->peer->host); |
| 264 | zlog_backtrace (LOG_WARNING); |
| 265 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 266 | } |
| 267 | } |
| 268 | else if (!BGP_INFO_HOLDDOWN (ri) |
| 269 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 270 | { |
| 271 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 272 | ri->peer->pcount[rn->table->afi][rn->table->safi]++; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | |
| 277 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 278 | * This is here primarily to keep prefix-count in check. |
| 279 | */ |
| 280 | void |
| 281 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 282 | { |
| 283 | SET_FLAG (ri->flags, flag); |
| 284 | |
| 285 | /* early bath if we know it's not a flag that changes useability state */ |
| 286 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 287 | return; |
| 288 | |
| 289 | bgp_pcount_adjust (rn, ri); |
| 290 | } |
| 291 | |
| 292 | void |
| 293 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 294 | { |
| 295 | UNSET_FLAG (ri->flags, flag); |
| 296 | |
| 297 | /* early bath if we know it's not a flag that changes useability state */ |
| 298 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 299 | return; |
| 300 | |
| 301 | bgp_pcount_adjust (rn, ri); |
| 302 | } |
| 303 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 304 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 305 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 306 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 307 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 308 | { |
| 309 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 310 | return attr->med; |
| 311 | else |
| 312 | { |
| 313 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 314 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 315 | else |
| 316 | return 0; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | /* Compare two bgp route entity. br is preferable then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 321 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 322 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
| 323 | int *paths_eq) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 324 | { |
| 325 | u_int32_t new_pref; |
| 326 | u_int32_t exist_pref; |
| 327 | u_int32_t new_med; |
| 328 | u_int32_t exist_med; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 329 | u_int32_t new_weight = 0; |
| 330 | u_int32_t exist_weight = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 331 | struct in_addr new_id; |
| 332 | struct in_addr exist_id; |
| 333 | int new_cluster; |
| 334 | int exist_cluster; |
| 335 | int internal_as_route = 0; |
| 336 | int confed_as_route = 0; |
| 337 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 338 | uint32_t newm, existm; |
| 339 | |
| 340 | *paths_eq = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 341 | |
| 342 | /* 0. Null check. */ |
| 343 | if (new == NULL) |
| 344 | return 0; |
| 345 | if (exist == NULL) |
| 346 | return 1; |
| 347 | |
| 348 | /* 1. Weight check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 349 | if (new->attr->extra) |
| 350 | new_weight = new->attr->extra->weight; |
| 351 | if (exist->attr->extra) |
| 352 | exist_weight = exist->attr->extra->weight; |
| 353 | if (new_weight > exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 354 | return 1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 355 | if (new_weight < exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 356 | return 0; |
| 357 | |
| 358 | /* 2. Local preference check. */ |
| 359 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 360 | new_pref = new->attr->local_pref; |
| 361 | else |
| 362 | new_pref = bgp->default_local_pref; |
| 363 | |
| 364 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 365 | exist_pref = exist->attr->local_pref; |
| 366 | else |
| 367 | exist_pref = bgp->default_local_pref; |
| 368 | |
| 369 | if (new_pref > exist_pref) |
| 370 | return 1; |
| 371 | if (new_pref < exist_pref) |
| 372 | return 0; |
| 373 | |
| 374 | /* 3. Local route check. */ |
| 375 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 376 | return 1; |
| 377 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 378 | return 0; |
| 379 | |
| 380 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 381 | return 1; |
| 382 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 383 | return 0; |
| 384 | |
| 385 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 386 | return 1; |
| 387 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 388 | return 0; |
| 389 | |
| 390 | /* 4. AS path length check. */ |
| 391 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 392 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 393 | int exist_hops = aspath_count_hops (exist->attr->aspath); |
| 394 | int exist_confeds = aspath_count_confeds (exist->attr->aspath); |
| 395 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 396 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 397 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 398 | int aspath_hops; |
| 399 | |
| 400 | aspath_hops = aspath_count_hops (new->attr->aspath); |
| 401 | aspath_hops += aspath_count_confeds (new->attr->aspath); |
| 402 | |
| 403 | if ( aspath_hops < (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 404 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 405 | if ( aspath_hops > (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 406 | return 0; |
| 407 | } |
| 408 | else |
| 409 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 410 | int newhops = aspath_count_hops (new->attr->aspath); |
| 411 | |
| 412 | if (newhops < exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 413 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 414 | if (newhops > exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 415 | return 0; |
| 416 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | /* 5. Origin check. */ |
| 420 | if (new->attr->origin < exist->attr->origin) |
| 421 | return 1; |
| 422 | if (new->attr->origin > exist->attr->origin) |
| 423 | return 0; |
| 424 | |
| 425 | /* 6. MED check. */ |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 426 | internal_as_route = (aspath_count_hops (new->attr->aspath) == 0 |
| 427 | && aspath_count_hops (exist->attr->aspath) == 0); |
| 428 | confed_as_route = (aspath_count_confeds (new->attr->aspath) > 0 |
| 429 | && aspath_count_confeds (exist->attr->aspath) > 0 |
| 430 | && aspath_count_hops (new->attr->aspath) == 0 |
| 431 | && aspath_count_hops (exist->attr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 432 | |
| 433 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 434 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 435 | && confed_as_route) |
| 436 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 437 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 438 | || internal_as_route) |
| 439 | { |
| 440 | new_med = bgp_med_value (new->attr, bgp); |
| 441 | exist_med = bgp_med_value (exist->attr, bgp); |
| 442 | |
| 443 | if (new_med < exist_med) |
| 444 | return 1; |
| 445 | if (new_med > exist_med) |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | /* 7. Peer type check. */ |
| 450 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 451 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 452 | return 1; |
| 453 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 454 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 455 | return 1; |
| 456 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 457 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 458 | return 0; |
| 459 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 460 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 461 | return 0; |
| 462 | |
| 463 | /* 8. IGP metric check. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 464 | newm = (new->extra ? new->extra->igpmetric : 0); |
| 465 | existm = (exist->extra ? exist->extra->igpmetric : 0); |
| 466 | if (newm < existm) |
| 467 | ret = 1; |
| 468 | if (newm > existm) |
| 469 | ret = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 470 | |
| 471 | /* 9. Maximum path check. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 472 | if (newm == existm) |
| 473 | { |
| 474 | if ((peer_sort (new->peer) == BGP_PEER_IBGP)) |
| 475 | { |
| 476 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 477 | *paths_eq = 1; |
| 478 | } |
| 479 | else if (new->peer->as == exist->peer->as) |
| 480 | *paths_eq = 1; |
| 481 | } |
| 482 | else |
| 483 | { |
| 484 | /* |
| 485 | * TODO: If unequal cost ibgp multipath is enabled we can |
| 486 | * mark the paths as equal here instead of returning |
| 487 | */ |
| 488 | return ret; |
| 489 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 490 | |
| 491 | /* 10. If both paths are external, prefer the path that was received |
| 492 | first (the oldest one). This step minimizes route-flap, since a |
| 493 | newer path won't displace an older one, even if it was the |
| 494 | preferred route based on the additional decision criteria below. */ |
| 495 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 496 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 497 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 498 | { |
| 499 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 500 | return 1; |
| 501 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 502 | return 0; |
| 503 | } |
| 504 | |
| 505 | /* 11. Rourter-ID comparision. */ |
| 506 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 507 | new_id.s_addr = new->attr->extra->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | else |
| 509 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 510 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 511 | exist_id.s_addr = exist->attr->extra->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 512 | else |
| 513 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 514 | |
| 515 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 516 | return 1; |
| 517 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 518 | return 0; |
| 519 | |
| 520 | /* 12. Cluster length comparision. */ |
| 521 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 522 | new_cluster = new->attr->extra->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 523 | else |
| 524 | new_cluster = 0; |
| 525 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 526 | exist_cluster = exist->attr->extra->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 527 | else |
| 528 | exist_cluster = 0; |
| 529 | |
| 530 | if (new_cluster < exist_cluster) |
| 531 | return 1; |
| 532 | if (new_cluster > exist_cluster) |
| 533 | return 0; |
| 534 | |
| 535 | /* 13. Neighbor address comparision. */ |
| 536 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 537 | |
| 538 | if (ret == 1) |
| 539 | return 0; |
| 540 | if (ret == -1) |
| 541 | return 1; |
| 542 | |
| 543 | return 1; |
| 544 | } |
| 545 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 546 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 547 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 548 | afi_t afi, safi_t safi) |
| 549 | { |
| 550 | struct bgp_filter *filter; |
| 551 | |
| 552 | filter = &peer->filter[afi][safi]; |
| 553 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 554 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 555 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 556 | && !(F ## _IN (filter))) \ |
| 557 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 558 | peer->host, #f, F ## _IN_NAME(filter)); |
| 559 | |
| 560 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 561 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 562 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 563 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 564 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 565 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 566 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 567 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 568 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 569 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 571 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 572 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 574 | if (FILTER_LIST_IN_NAME (filter)) { |
| 575 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 576 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 577 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 578 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 579 | } |
| 580 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 581 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 582 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 583 | } |
| 584 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 585 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 587 | afi_t afi, safi_t safi) |
| 588 | { |
| 589 | struct bgp_filter *filter; |
| 590 | |
| 591 | filter = &peer->filter[afi][safi]; |
| 592 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 593 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 594 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 595 | && !(F ## _OUT (filter))) \ |
| 596 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 597 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 598 | |
| 599 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 600 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 601 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 602 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 603 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 604 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 606 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 607 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 608 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 609 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 610 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 611 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 612 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 613 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 614 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 615 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 616 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 617 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 618 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 619 | |
| 620 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 621 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 625 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 626 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 627 | { |
| 628 | if (attr->community) |
| 629 | { |
| 630 | /* NO_ADVERTISE check. */ |
| 631 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 632 | return 1; |
| 633 | |
| 634 | /* NO_EXPORT check. */ |
| 635 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 636 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 637 | return 1; |
| 638 | |
| 639 | /* NO_EXPORT_SUBCONFED check. */ |
| 640 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 641 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 642 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 643 | return 1; |
| 644 | } |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | /* Route reflection loop check. */ |
| 649 | static int |
| 650 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 651 | { |
| 652 | struct in_addr cluster_id; |
| 653 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 654 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 655 | { |
| 656 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 657 | cluster_id = peer->bgp->cluster_id; |
| 658 | else |
| 659 | cluster_id = peer->bgp->router_id; |
| 660 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 661 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 662 | return 1; |
| 663 | } |
| 664 | return 0; |
| 665 | } |
| 666 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 667 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 668 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 669 | afi_t afi, safi_t safi) |
| 670 | { |
| 671 | struct bgp_filter *filter; |
| 672 | struct bgp_info info; |
| 673 | route_map_result_t ret; |
| 674 | |
| 675 | filter = &peer->filter[afi][safi]; |
| 676 | |
| 677 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 678 | if (peer->weight) |
| 679 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 680 | |
| 681 | /* Route map apply. */ |
| 682 | if (ROUTE_MAP_IN_NAME (filter)) |
| 683 | { |
| 684 | /* Duplicate current value to new strucutre for modification. */ |
| 685 | info.peer = peer; |
| 686 | info.attr = attr; |
| 687 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 688 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 689 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | /* Apply BGP route map to the attribute. */ |
| 691 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 692 | |
| 693 | peer->rmap_type = 0; |
| 694 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 695 | if (ret == RMAP_DENYMATCH) |
| 696 | { |
| 697 | /* Free newly generated AS path and community by route-map. */ |
| 698 | bgp_attr_flush (attr); |
| 699 | return RMAP_DENY; |
| 700 | } |
| 701 | } |
| 702 | return RMAP_PERMIT; |
| 703 | } |
| 704 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 705 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 706 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 707 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 708 | { |
| 709 | struct bgp_filter *filter; |
| 710 | struct bgp_info info; |
| 711 | route_map_result_t ret; |
| 712 | |
| 713 | filter = &peer->filter[afi][safi]; |
| 714 | |
| 715 | /* Route map apply. */ |
| 716 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 717 | { |
| 718 | /* Duplicate current value to new strucutre for modification. */ |
| 719 | info.peer = rsclient; |
| 720 | info.attr = attr; |
| 721 | |
| 722 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 723 | |
| 724 | /* Apply BGP route map to the attribute. */ |
| 725 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 726 | |
| 727 | rsclient->rmap_type = 0; |
| 728 | |
| 729 | if (ret == RMAP_DENYMATCH) |
| 730 | { |
| 731 | /* Free newly generated AS path and community by route-map. */ |
| 732 | bgp_attr_flush (attr); |
| 733 | return RMAP_DENY; |
| 734 | } |
| 735 | } |
| 736 | return RMAP_PERMIT; |
| 737 | } |
| 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_import_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 = &rsclient->filter[afi][safi]; |
| 748 | |
| 749 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 750 | if (peer->weight) |
| 751 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 752 | |
| 753 | /* Route map apply. */ |
| 754 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 755 | { |
| 756 | /* Duplicate current value to new strucutre for modification. */ |
| 757 | info.peer = peer; |
| 758 | info.attr = attr; |
| 759 | |
| 760 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 761 | |
| 762 | /* Apply BGP route map to the attribute. */ |
| 763 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 764 | |
| 765 | peer->rmap_type = 0; |
| 766 | |
| 767 | if (ret == RMAP_DENYMATCH) |
| 768 | { |
| 769 | /* Free newly generated AS path and community by route-map. */ |
| 770 | bgp_attr_flush (attr); |
| 771 | return RMAP_DENY; |
| 772 | } |
| 773 | } |
| 774 | return RMAP_PERMIT; |
| 775 | } |
| 776 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 777 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 778 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 779 | struct attr *attr, afi_t afi, safi_t safi) |
| 780 | { |
| 781 | int ret; |
| 782 | char buf[SU_ADDRSTRLEN]; |
| 783 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 784 | struct peer *from; |
| 785 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 786 | int transparent; |
| 787 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 788 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 789 | |
| 790 | from = ri->peer; |
| 791 | filter = &peer->filter[afi][safi]; |
| 792 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 793 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 794 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 795 | if (DISABLE_BGP_ANNOUNCE) |
| 796 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 797 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 798 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 799 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 800 | return 0; |
| 801 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 802 | /* Do not send back route to sender. */ |
| 803 | if (from == peer) |
| 804 | return 0; |
| 805 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 806 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 807 | if (p->family == AF_INET |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 808 | && IPV4_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 809 | return 0; |
| 810 | #ifdef HAVE_IPV6 |
| 811 | if (p->family == AF_INET6 |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 812 | && IPV6_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 813 | return 0; |
| 814 | #endif |
| 815 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 816 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 817 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 818 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 819 | return 0; |
| 820 | |
| 821 | /* Default route check. */ |
| 822 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 823 | { |
| 824 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 825 | return 0; |
| 826 | #ifdef HAVE_IPV6 |
| 827 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 828 | return 0; |
| 829 | #endif /* HAVE_IPV6 */ |
| 830 | } |
| 831 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 832 | /* Transparency check. */ |
| 833 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 834 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 835 | transparent = 1; |
| 836 | else |
| 837 | transparent = 0; |
| 838 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 839 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 840 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 841 | return 0; |
| 842 | |
| 843 | /* If the attribute has originator-id and it is same as remote |
| 844 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 845 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 846 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 847 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | { |
| 849 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 850 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 852 | peer->host, |
| 853 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 854 | p->prefixlen); |
| 855 | return 0; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | /* ORF prefix-list filter check */ |
| 860 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 861 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 862 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 863 | if (peer->orf_plist[afi][safi]) |
| 864 | { |
| 865 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 866 | return 0; |
| 867 | } |
| 868 | |
| 869 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 870 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 871 | { |
| 872 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 873 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 874 | "%s [Update:SEND] %s/%d is filtered", |
| 875 | peer->host, |
| 876 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 877 | p->prefixlen); |
| 878 | return 0; |
| 879 | } |
| 880 | |
| 881 | #ifdef BGP_SEND_ASPATH_CHECK |
| 882 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 883 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 884 | { |
| 885 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 886 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 887 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 888 | peer->host, peer->as); |
| 889 | return 0; |
| 890 | } |
| 891 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 892 | |
| 893 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 894 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 895 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 896 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 897 | { |
| 898 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 899 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 900 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 901 | peer->host, |
| 902 | bgp->confed_id); |
| 903 | return 0; |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | /* Route-Reflect check. */ |
| 908 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 909 | reflect = 1; |
| 910 | else |
| 911 | reflect = 0; |
| 912 | |
| 913 | /* IBGP reflection check. */ |
| 914 | if (reflect) |
| 915 | { |
| 916 | /* A route from a Client peer. */ |
| 917 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 918 | { |
| 919 | /* Reflect to all the Non-Client peers and also to the |
| 920 | Client peers other than the originator. Originator check |
| 921 | is already done. So there is noting to do. */ |
| 922 | /* no bgp client-to-client reflection check. */ |
| 923 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 924 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 925 | return 0; |
| 926 | } |
| 927 | else |
| 928 | { |
| 929 | /* A route from a Non-client peer. Reflect to all other |
| 930 | clients. */ |
| 931 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 932 | return 0; |
| 933 | } |
| 934 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 935 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 936 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 937 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 938 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 939 | /* If local-preference is not set. */ |
| 940 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 941 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 942 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 943 | { |
| 944 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 945 | attr->local_pref = bgp->default_local_pref; |
| 946 | } |
| 947 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 948 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 949 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 950 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 951 | { |
| 952 | if (ri->peer != bgp->peer_self && ! transparent |
| 953 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 954 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 955 | } |
| 956 | |
| 957 | /* next-hop-set */ |
| 958 | if (transparent || reflect |
| 959 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 960 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 961 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 962 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 963 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 964 | #endif /* HAVE_IPV6 */ |
| 965 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 966 | { |
| 967 | /* NEXT-HOP Unchanged. */ |
| 968 | } |
| 969 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 970 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 971 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 972 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 973 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 974 | #endif /* HAVE_IPV6 */ |
| 975 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 976 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 977 | { |
| 978 | /* Set IPv4 nexthop. */ |
| 979 | if (p->family == AF_INET) |
| 980 | { |
| 981 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 982 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 983 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 984 | else |
| 985 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 986 | } |
| 987 | #ifdef HAVE_IPV6 |
| 988 | /* Set IPv6 nexthop. */ |
| 989 | if (p->family == AF_INET6) |
| 990 | { |
| 991 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 992 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 993 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 994 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 995 | } |
| 996 | #endif /* HAVE_IPV6 */ |
| 997 | } |
| 998 | |
| 999 | #ifdef HAVE_IPV6 |
| 1000 | if (p->family == AF_INET6) |
| 1001 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1002 | /* Left nexthop_local unchanged if so configured. */ |
| 1003 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1004 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1005 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1006 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1007 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1008 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1009 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
| 1012 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1013 | else |
| 1014 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1015 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1016 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1017 | |
| 1018 | /* Set link-local address for shared network peer. */ |
| 1019 | if (peer->shared_network |
| 1020 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1021 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1022 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1023 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1024 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1028 | address.*/ |
| 1029 | if (reflect) |
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 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1033 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1034 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1035 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1036 | |
| 1037 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1038 | #endif /* HAVE_IPV6 */ |
| 1039 | |
| 1040 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1041 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 1042 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1043 | && aspath_private_as_check (attr->aspath)) |
| 1044 | attr->aspath = aspath_empty_get (); |
| 1045 | |
| 1046 | /* Route map & unsuppress-map apply. */ |
| 1047 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1048 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1049 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1050 | struct bgp_info info; |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1051 | struct attr dummy_attr = { 0 }; |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1052 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1053 | info.peer = peer; |
| 1054 | info.attr = attr; |
| 1055 | |
| 1056 | /* The route reflector is not allowed to modify the attributes |
| 1057 | of the reflected IBGP routes. */ |
| 1058 | if (peer_sort (from) == BGP_PEER_IBGP |
| 1059 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 1060 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1061 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1062 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1063 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1064 | |
| 1065 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1066 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1067 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1068 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1069 | else |
| 1070 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1071 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1072 | peer->rmap_type = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1073 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1074 | if (dummy_attr.extra) |
| 1075 | bgp_attr_extra_free (&dummy_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1076 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1077 | if (ret == RMAP_DENYMATCH) |
| 1078 | { |
| 1079 | bgp_attr_flush (attr); |
| 1080 | return 0; |
| 1081 | } |
| 1082 | } |
| 1083 | return 1; |
| 1084 | } |
| 1085 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1086 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1087 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1088 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1089 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1090 | int ret; |
| 1091 | char buf[SU_ADDRSTRLEN]; |
| 1092 | struct bgp_filter *filter; |
| 1093 | struct bgp_info info; |
| 1094 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1095 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1096 | |
| 1097 | from = ri->peer; |
| 1098 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1099 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1100 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1101 | if (DISABLE_BGP_ANNOUNCE) |
| 1102 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1103 | |
| 1104 | /* Do not send back route to sender. */ |
| 1105 | if (from == rsclient) |
| 1106 | return 0; |
| 1107 | |
| 1108 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1109 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1110 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1111 | return 0; |
| 1112 | |
| 1113 | /* Default route check. */ |
| 1114 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1115 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1116 | { |
| 1117 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1118 | return 0; |
| 1119 | #ifdef HAVE_IPV6 |
| 1120 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1121 | return 0; |
| 1122 | #endif /* HAVE_IPV6 */ |
| 1123 | } |
| 1124 | |
| 1125 | /* If the attribute has originator-id and it is same as remote |
| 1126 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1127 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1128 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1129 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1130 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1131 | { |
| 1132 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1133 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1134 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1135 | rsclient->host, |
| 1136 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1137 | p->prefixlen); |
| 1138 | return 0; |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | /* ORF prefix-list filter check */ |
| 1143 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1144 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1145 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1146 | if (rsclient->orf_plist[afi][safi]) |
| 1147 | { |
| 1148 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1149 | return 0; |
| 1150 | } |
| 1151 | |
| 1152 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1153 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1154 | { |
| 1155 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1156 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1157 | "%s [Update:SEND] %s/%d is filtered", |
| 1158 | rsclient->host, |
| 1159 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1160 | p->prefixlen); |
| 1161 | return 0; |
| 1162 | } |
| 1163 | |
| 1164 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1165 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1166 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
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, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1170 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1171 | rsclient->host, rsclient->as); |
| 1172 | return 0; |
| 1173 | } |
| 1174 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1175 | |
| 1176 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1177 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1178 | |
| 1179 | /* next-hop-set */ |
| 1180 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1181 | #ifdef HAVE_IPV6 |
| 1182 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1183 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1184 | #endif /* HAVE_IPV6 */ |
| 1185 | ) |
| 1186 | { |
| 1187 | /* Set IPv4 nexthop. */ |
| 1188 | if (p->family == AF_INET) |
| 1189 | { |
| 1190 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1191 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1192 | IPV4_MAX_BYTELEN); |
| 1193 | else |
| 1194 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1195 | } |
| 1196 | #ifdef HAVE_IPV6 |
| 1197 | /* Set IPv6 nexthop. */ |
| 1198 | if (p->family == AF_INET6) |
| 1199 | { |
| 1200 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1201 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1202 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1203 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1204 | } |
| 1205 | #endif /* HAVE_IPV6 */ |
| 1206 | } |
| 1207 | |
| 1208 | #ifdef HAVE_IPV6 |
| 1209 | if (p->family == AF_INET6) |
| 1210 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1211 | struct attr_extra *attre = attr->extra; |
| 1212 | |
| 1213 | assert (attr->extra); |
| 1214 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1215 | /* Left nexthop_local unchanged if so configured. */ |
| 1216 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1217 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1218 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1219 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1220 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1221 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1222 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | /* Default nexthop_local treatment for RS-Clients */ |
| 1226 | else |
| 1227 | { |
| 1228 | /* Announcer and RS-Client are both in the same network */ |
| 1229 | if (rsclient->shared_network && from->shared_network && |
| 1230 | (rsclient->ifindex == from->ifindex)) |
| 1231 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1232 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1233 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1234 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1235 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1236 | } |
| 1237 | |
| 1238 | /* Set link-local address for shared network peer. */ |
| 1239 | else if (rsclient->shared_network |
| 1240 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1241 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1242 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1243 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1244 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1245 | } |
| 1246 | |
| 1247 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1248 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | } |
| 1252 | #endif /* HAVE_IPV6 */ |
| 1253 | |
| 1254 | |
| 1255 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1256 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 1257 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1258 | && aspath_private_as_check (attr->aspath)) |
| 1259 | attr->aspath = aspath_empty_get (); |
| 1260 | |
| 1261 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1262 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1263 | { |
| 1264 | info.peer = rsclient; |
| 1265 | info.attr = attr; |
| 1266 | |
| 1267 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1268 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1269 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1270 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1271 | else |
| 1272 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1273 | |
| 1274 | rsclient->rmap_type = 0; |
| 1275 | |
| 1276 | if (ret == RMAP_DENYMATCH) |
| 1277 | { |
| 1278 | bgp_attr_flush (attr); |
| 1279 | return 0; |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | return 1; |
| 1284 | } |
| 1285 | |
| 1286 | struct bgp_info_pair |
| 1287 | { |
| 1288 | struct bgp_info *old; |
| 1289 | struct bgp_info *new; |
| 1290 | }; |
| 1291 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1292 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1293 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
| 1294 | struct bgp_maxpaths_cfg *mpath_cfg, |
| 1295 | struct bgp_info_pair *result) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1296 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1297 | struct bgp_info *new_select; |
| 1298 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1299 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1300 | struct bgp_info *ri1; |
| 1301 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1302 | struct bgp_info *nextri = NULL; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1303 | int paths_eq, do_mpath; |
| 1304 | struct list mp_list; |
| 1305 | |
| 1306 | bgp_mp_list_init (&mp_list); |
| 1307 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || |
| 1308 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); |
| 1309 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1310 | /* bgp deterministic-med */ |
| 1311 | new_select = NULL; |
| 1312 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1313 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1314 | { |
| 1315 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1316 | continue; |
| 1317 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1318 | continue; |
| 1319 | |
| 1320 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1321 | if (do_mpath) |
| 1322 | bgp_mp_list_add (&mp_list, ri1); |
| 1323 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1324 | if (ri1->next) |
| 1325 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1326 | { |
| 1327 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1328 | continue; |
| 1329 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1330 | continue; |
| 1331 | |
| 1332 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1333 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1334 | ri2->attr->aspath)) |
| 1335 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1336 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1337 | old_select = ri2; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1338 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1339 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1340 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1341 | new_select = ri2; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1342 | if (do_mpath && !paths_eq) |
| 1343 | { |
| 1344 | bgp_mp_list_clear (&mp_list); |
| 1345 | bgp_mp_list_add (&mp_list, ri2); |
| 1346 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1347 | } |
| 1348 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1349 | if (do_mpath && paths_eq) |
| 1350 | bgp_mp_list_add (&mp_list, ri2); |
| 1351 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1352 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1353 | } |
| 1354 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1355 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1356 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1357 | |
| 1358 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
| 1359 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1360 | } |
| 1361 | |
| 1362 | /* Check old selected route and new selected route. */ |
| 1363 | old_select = NULL; |
| 1364 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1365 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1366 | { |
| 1367 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1368 | old_select = ri; |
| 1369 | |
| 1370 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1371 | { |
| 1372 | /* reap REMOVED routes, if needs be |
| 1373 | * selected route must stay for a while longer though |
| 1374 | */ |
| 1375 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1376 | && (ri != old_select)) |
| 1377 | bgp_info_reap (rn, ri); |
| 1378 | |
| 1379 | continue; |
| 1380 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1381 | |
| 1382 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1383 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1384 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1385 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1386 | continue; |
| 1387 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1388 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1389 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1390 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1391 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
| 1392 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1393 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1394 | bgp_mp_dmed_deselect (new_select); |
| 1395 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1396 | new_select = ri; |
| 1397 | |
| 1398 | if (do_mpath && !paths_eq) |
| 1399 | { |
| 1400 | bgp_mp_list_clear (&mp_list); |
| 1401 | bgp_mp_list_add (&mp_list, ri); |
| 1402 | } |
| 1403 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1404 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1405 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1406 | |
| 1407 | if (do_mpath && paths_eq) |
| 1408 | bgp_mp_list_add (&mp_list, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1409 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1410 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1411 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1412 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1413 | 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] | 1414 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1415 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1416 | bgp_mp_list_clear (&mp_list); |
| 1417 | |
| 1418 | result->old = old_select; |
| 1419 | result->new = new_select; |
| 1420 | |
| 1421 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1422 | } |
| 1423 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1424 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1425 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1426 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1427 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1428 | struct prefix *p; |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1429 | struct attr attr = { 0 }; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1430 | |
| 1431 | p = &rn->p; |
| 1432 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1433 | /* Announce route to Established peer. */ |
| 1434 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1435 | return 0; |
| 1436 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1437 | /* Address family configuration check. */ |
| 1438 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1439 | return 0; |
| 1440 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1441 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1442 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1443 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1444 | return 0; |
| 1445 | |
| 1446 | switch (rn->table->type) |
| 1447 | { |
| 1448 | case BGP_TABLE_MAIN: |
| 1449 | /* Announcement to peer->conf. If the route is filtered, |
| 1450 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1451 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1452 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1453 | else |
| 1454 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1455 | break; |
| 1456 | case BGP_TABLE_RSCLIENT: |
| 1457 | /* Announcement to peer->conf. If the route is filtered, |
| 1458 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1459 | if (selected && |
| 1460 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1461 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1462 | else |
| 1463 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1464 | break; |
| 1465 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1466 | |
| 1467 | bgp_attr_extra_free (&attr); |
| 1468 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1469 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1470 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1471 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1472 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1474 | struct bgp *bgp; |
| 1475 | struct bgp_node *rn; |
| 1476 | afi_t afi; |
| 1477 | safi_t safi; |
| 1478 | }; |
| 1479 | |
| 1480 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1481 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1482 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1483 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1484 | struct bgp *bgp = pq->bgp; |
| 1485 | struct bgp_node *rn = pq->rn; |
| 1486 | afi_t afi = pq->afi; |
| 1487 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1488 | struct bgp_info *new_select; |
| 1489 | struct bgp_info *old_select; |
| 1490 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1491 | struct listnode *node, *nnode; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1492 | struct peer *rsclient = rn->table->owner; |
| 1493 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1494 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1495 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1496 | new_select = old_and_new.new; |
| 1497 | old_select = old_and_new.old; |
| 1498 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1499 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1500 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1501 | if (rsclient->group) |
| 1502 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1503 | { |
| 1504 | /* Nothing to do. */ |
| 1505 | if (old_select && old_select == new_select) |
| 1506 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1507 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1508 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1509 | if (old_select) |
| 1510 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1511 | if (new_select) |
| 1512 | { |
| 1513 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1514 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1515 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1516 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1517 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1518 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1519 | afi, safi); |
| 1520 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1521 | } |
| 1522 | else |
| 1523 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1524 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1525 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1526 | if (new_select) |
| 1527 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1528 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1529 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1530 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1531 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1532 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1533 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1534 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1535 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1536 | bgp_info_reap (rn, old_select); |
| 1537 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1538 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1539 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1540 | } |
| 1541 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1542 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1543 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1544 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1545 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1546 | struct bgp *bgp = pq->bgp; |
| 1547 | struct bgp_node *rn = pq->rn; |
| 1548 | afi_t afi = pq->afi; |
| 1549 | safi_t safi = pq->safi; |
| 1550 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1551 | struct bgp_info *new_select; |
| 1552 | struct bgp_info *old_select; |
| 1553 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1554 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1555 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1556 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1557 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1558 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1559 | old_select = old_and_new.old; |
| 1560 | new_select = old_and_new.new; |
| 1561 | |
| 1562 | /* Nothing to do. */ |
| 1563 | if (old_select && old_select == new_select) |
| 1564 | { |
| 1565 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1566 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1567 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1568 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1569 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1570 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1571 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1572 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1573 | return WQ_SUCCESS; |
| 1574 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1575 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1576 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1577 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1578 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1579 | if (new_select) |
| 1580 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1581 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1582 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1583 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1584 | } |
| 1585 | |
| 1586 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1587 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1588 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1589 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1590 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1591 | } |
| 1592 | |
| 1593 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1594 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1595 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1596 | { |
| 1597 | if (new_select |
| 1598 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1599 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1600 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1601 | else |
| 1602 | { |
| 1603 | /* Withdraw the route from the kernel. */ |
| 1604 | if (old_select |
| 1605 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1606 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1607 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1608 | } |
| 1609 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1610 | |
| 1611 | /* Reap old select bgp_info, it it has been removed */ |
| 1612 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1613 | bgp_info_reap (rn, old_select); |
| 1614 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1615 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1616 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1617 | } |
| 1618 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1619 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1620 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1621 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1622 | struct bgp_process_queue *pq = data; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1623 | struct bgp_table *table = pq->rn->table; |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1624 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1625 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1626 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1627 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1628 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1629 | } |
| 1630 | |
| 1631 | static void |
| 1632 | bgp_process_queue_init (void) |
| 1633 | { |
| 1634 | bm->process_main_queue |
| 1635 | = work_queue_new (bm->master, "process_main_queue"); |
| 1636 | bm->process_rsclient_queue |
| 1637 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1638 | |
| 1639 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1640 | { |
| 1641 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1642 | exit (1); |
| 1643 | } |
| 1644 | |
| 1645 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1646 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1647 | bm->process_main_queue->spec.max_retries = 0; |
| 1648 | bm->process_main_queue->spec.hold = 50; |
| 1649 | |
| 1650 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, |
| 1651 | sizeof (struct work_queue *)); |
| 1652 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1653 | } |
| 1654 | |
| 1655 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1656 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1657 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1658 | struct bgp_process_queue *pqnode; |
| 1659 | |
| 1660 | /* already scheduled for processing? */ |
| 1661 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1662 | return; |
| 1663 | |
| 1664 | if ( (bm->process_main_queue == NULL) || |
| 1665 | (bm->process_rsclient_queue == NULL) ) |
| 1666 | bgp_process_queue_init (); |
| 1667 | |
| 1668 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1669 | sizeof (struct bgp_process_queue)); |
| 1670 | if (!pqnode) |
| 1671 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1672 | |
| 1673 | /* all unlocked in bgp_processq_del */ |
| 1674 | bgp_table_lock (rn->table); |
| 1675 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1676 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1677 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1678 | pqnode->afi = afi; |
| 1679 | pqnode->safi = safi; |
| 1680 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1681 | switch (rn->table->type) |
| 1682 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1683 | case BGP_TABLE_MAIN: |
| 1684 | work_queue_add (bm->process_main_queue, pqnode); |
| 1685 | break; |
| 1686 | case BGP_TABLE_RSCLIENT: |
| 1687 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1688 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1689 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1690 | |
| 1691 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1692 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1693 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1694 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1695 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1696 | { |
| 1697 | struct peer *peer; |
| 1698 | |
| 1699 | peer = THREAD_ARG (thread); |
| 1700 | peer->t_pmax_restart = NULL; |
| 1701 | |
| 1702 | if (BGP_DEBUG (events, EVENTS)) |
| 1703 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1704 | peer->host); |
| 1705 | |
| 1706 | peer_clear (peer); |
| 1707 | |
| 1708 | return 0; |
| 1709 | } |
| 1710 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1711 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1712 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1713 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1714 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1715 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1716 | return 0; |
| 1717 | |
| 1718 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1719 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1720 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1721 | && ! always) |
| 1722 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1723 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1724 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1725 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1726 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1727 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1728 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1729 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1730 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1731 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1732 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1733 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1734 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1735 | |
| 1736 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1737 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1738 | |
| 1739 | ndata[0] = (afi >> 8); |
| 1740 | ndata[1] = afi; |
| 1741 | ndata[2] = safi; |
| 1742 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1743 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1744 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1745 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1746 | |
| 1747 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1748 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1749 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1750 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1751 | |
| 1752 | /* restart timer start */ |
| 1753 | if (peer->pmax_restart[afi][safi]) |
| 1754 | { |
| 1755 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1756 | |
| 1757 | if (BGP_DEBUG (events, EVENTS)) |
| 1758 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1759 | peer->host, peer->v_pmax_restart); |
| 1760 | |
| 1761 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1762 | peer->v_pmax_restart); |
| 1763 | } |
| 1764 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1765 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1766 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1767 | else |
| 1768 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1769 | |
| 1770 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1771 | { |
| 1772 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1773 | && ! always) |
| 1774 | return 0; |
| 1775 | |
| 1776 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1777 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1778 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1779 | 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_THRESHOLD); |
| 1781 | } |
| 1782 | else |
| 1783 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1784 | return 0; |
| 1785 | } |
| 1786 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1787 | /* Unconditionally remove the route from the RIB, without taking |
| 1788 | * damping into consideration (eg, because the session went down) |
| 1789 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1790 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1791 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1792 | afi_t afi, safi_t safi) |
| 1793 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1794 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1795 | |
| 1796 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1797 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1798 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1799 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1800 | } |
| 1801 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1802 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1803 | 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] | 1804 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1805 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1806 | int status = BGP_DAMP_NONE; |
| 1807 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1808 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1809 | * the bgp_info in the RIB for historical reference. |
| 1810 | */ |
| 1811 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1812 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1813 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1814 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1815 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1816 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1817 | return; |
| 1818 | } |
| 1819 | |
| 1820 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1821 | } |
| 1822 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1823 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1824 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1825 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1826 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1827 | { |
| 1828 | struct bgp_node *rn; |
| 1829 | struct bgp *bgp; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1830 | struct attr new_attr = { 0 }; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1831 | struct attr *attr_new; |
| 1832 | struct attr *attr_new2; |
| 1833 | struct bgp_info *ri; |
| 1834 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1835 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1836 | char buf[SU_ADDRSTRLEN]; |
| 1837 | |
| 1838 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1839 | if (peer == rsclient) |
| 1840 | return; |
| 1841 | |
| 1842 | bgp = peer->bgp; |
| 1843 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1844 | |
| 1845 | /* Check previously received route. */ |
| 1846 | for (ri = rn->info; ri; ri = ri->next) |
| 1847 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1848 | break; |
| 1849 | |
| 1850 | /* AS path loop check. */ |
| 1851 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1852 | { |
| 1853 | reason = "as-path contains our own AS;"; |
| 1854 | goto filtered; |
| 1855 | } |
| 1856 | |
| 1857 | /* Route reflector originator ID check. */ |
| 1858 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1859 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1860 | { |
| 1861 | reason = "originator is us;"; |
| 1862 | goto filtered; |
| 1863 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1864 | |
| 1865 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1866 | |
| 1867 | /* Apply export policy. */ |
| 1868 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1869 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1870 | { |
| 1871 | reason = "export-policy;"; |
| 1872 | goto filtered; |
| 1873 | } |
| 1874 | |
| 1875 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1876 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1877 | /* Apply import policy. */ |
| 1878 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1879 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1880 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1881 | |
| 1882 | reason = "import-policy;"; |
| 1883 | goto filtered; |
| 1884 | } |
| 1885 | |
| 1886 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1887 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1888 | |
| 1889 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1890 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1891 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1892 | /* 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] | 1893 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1894 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1895 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1896 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1897 | |
| 1898 | reason = "martian next-hop;"; |
| 1899 | goto filtered; |
| 1900 | } |
| 1901 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1902 | |
| 1903 | /* new_attr isn't passed to any functions after here */ |
| 1904 | bgp_attr_extra_free (&new_attr); |
| 1905 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1906 | /* If the update is implicit withdraw. */ |
| 1907 | if (ri) |
| 1908 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1909 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1910 | |
| 1911 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1912 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1913 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1914 | { |
| 1915 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1916 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1917 | |
| 1918 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1919 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1920 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1921 | peer->host, |
| 1922 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1923 | p->prefixlen, rsclient->host); |
| 1924 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1925 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1926 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1927 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1928 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1929 | } |
| 1930 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1931 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1932 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1933 | bgp_info_restore (rn, ri); |
| 1934 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1935 | /* Received Logging. */ |
| 1936 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1937 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1938 | peer->host, |
| 1939 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1940 | p->prefixlen, rsclient->host); |
| 1941 | |
| 1942 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1943 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1944 | |
| 1945 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1946 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1947 | ri->attr = attr_new; |
| 1948 | |
| 1949 | /* Update MPLS tag. */ |
| 1950 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1951 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1952 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1953 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1954 | |
| 1955 | /* Process change. */ |
| 1956 | bgp_process (bgp, rn, afi, safi); |
| 1957 | bgp_unlock_node (rn); |
| 1958 | |
| 1959 | return; |
| 1960 | } |
| 1961 | |
| 1962 | /* Received Logging. */ |
| 1963 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1964 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1965 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1966 | peer->host, |
| 1967 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1968 | p->prefixlen, rsclient->host); |
| 1969 | } |
| 1970 | |
| 1971 | /* Make new BGP info. */ |
| 1972 | new = bgp_info_new (); |
| 1973 | new->type = type; |
| 1974 | new->sub_type = sub_type; |
| 1975 | new->peer = peer; |
| 1976 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1977 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1978 | |
| 1979 | /* Update MPLS tag. */ |
| 1980 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1981 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1982 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1983 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1984 | |
| 1985 | /* Register new BGP information. */ |
| 1986 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1987 | |
| 1988 | /* route_node_get lock */ |
| 1989 | bgp_unlock_node (rn); |
| 1990 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1991 | /* Process change. */ |
| 1992 | bgp_process (bgp, rn, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1993 | |
| 1994 | bgp_attr_extra_free (&new_attr); |
| 1995 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1996 | return; |
| 1997 | |
| 1998 | filtered: |
| 1999 | |
| 2000 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2001 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2002 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2003 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2004 | peer->host, |
| 2005 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2006 | p->prefixlen, rsclient->host, reason); |
| 2007 | |
| 2008 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2009 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2010 | |
| 2011 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2012 | |
| 2013 | if (new_attr.extra) |
| 2014 | bgp_attr_extra_free (&new_attr); |
| 2015 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2016 | return; |
| 2017 | } |
| 2018 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2019 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2020 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2021 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2022 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2023 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2024 | struct bgp_node *rn; |
| 2025 | struct bgp_info *ri; |
| 2026 | char buf[SU_ADDRSTRLEN]; |
| 2027 | |
| 2028 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2029 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2030 | |
| 2031 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2032 | |
| 2033 | /* Lookup withdrawn route. */ |
| 2034 | for (ri = rn->info; ri; ri = ri->next) |
| 2035 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2036 | break; |
| 2037 | |
| 2038 | /* Withdraw specified route from routing table. */ |
| 2039 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2040 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2041 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2042 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2043 | "%s Can't find the route %s/%d", peer->host, |
| 2044 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2045 | p->prefixlen); |
| 2046 | |
| 2047 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2048 | bgp_unlock_node (rn); |
| 2049 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2050 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2051 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2052 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2053 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2054 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2055 | { |
| 2056 | int ret; |
| 2057 | int aspath_loop_count = 0; |
| 2058 | struct bgp_node *rn; |
| 2059 | struct bgp *bgp; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2060 | struct attr new_attr = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2061 | struct attr *attr_new; |
| 2062 | struct bgp_info *ri; |
| 2063 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2064 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2065 | char buf[SU_ADDRSTRLEN]; |
| 2066 | |
| 2067 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2068 | 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] | 2069 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2070 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2071 | Adj-RIBs-In. */ |
| 2072 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2073 | && peer != bgp->peer_self && ! soft_reconfig) |
| 2074 | bgp_adj_in_set (rn, peer, attr); |
| 2075 | |
| 2076 | /* Check previously received route. */ |
| 2077 | for (ri = rn->info; ri; ri = ri->next) |
| 2078 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2079 | break; |
| 2080 | |
| 2081 | /* AS path local-as loop check. */ |
| 2082 | if (peer->change_local_as) |
| 2083 | { |
| 2084 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2085 | aspath_loop_count = 1; |
| 2086 | |
| 2087 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2088 | { |
| 2089 | reason = "as-path contains our own AS;"; |
| 2090 | goto filtered; |
| 2091 | } |
| 2092 | } |
| 2093 | |
| 2094 | /* AS path loop check. */ |
| 2095 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2096 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2097 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2098 | > peer->allowas_in[afi][safi])) |
| 2099 | { |
| 2100 | reason = "as-path contains our own AS;"; |
| 2101 | goto filtered; |
| 2102 | } |
| 2103 | |
| 2104 | /* Route reflector originator ID check. */ |
| 2105 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2106 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2107 | { |
| 2108 | reason = "originator is us;"; |
| 2109 | goto filtered; |
| 2110 | } |
| 2111 | |
| 2112 | /* Route reflector cluster ID check. */ |
| 2113 | if (bgp_cluster_filter (peer, attr)) |
| 2114 | { |
| 2115 | reason = "reflected from the same cluster;"; |
| 2116 | goto filtered; |
| 2117 | } |
| 2118 | |
| 2119 | /* Apply incoming filter. */ |
| 2120 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2121 | { |
| 2122 | reason = "filter;"; |
| 2123 | goto filtered; |
| 2124 | } |
| 2125 | |
| 2126 | /* Apply incoming route-map. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2127 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | |
| 2129 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2130 | { |
| 2131 | reason = "route-map;"; |
| 2132 | goto filtered; |
| 2133 | } |
| 2134 | |
| 2135 | /* IPv4 unicast next hop check. */ |
| 2136 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2137 | { |
| 2138 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2139 | discard it. */ |
| 2140 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2141 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2142 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2143 | { |
| 2144 | reason = "non-connected next-hop;"; |
| 2145 | goto filtered; |
| 2146 | } |
| 2147 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2148 | /* 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] | 2149 | must not be my own address. */ |
| 2150 | if (bgp_nexthop_self (afi, &new_attr) |
| 2151 | || new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2152 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2153 | { |
| 2154 | reason = "martian next-hop;"; |
| 2155 | goto filtered; |
| 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | attr_new = bgp_attr_intern (&new_attr); |
| 2160 | |
| 2161 | /* If the update is implicit withdraw. */ |
| 2162 | if (ri) |
| 2163 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2164 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2165 | |
| 2166 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2167 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2168 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2169 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2170 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2171 | |
| 2172 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2173 | && peer_sort (peer) == BGP_PEER_EBGP |
| 2174 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2175 | { |
| 2176 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2177 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2178 | peer->host, |
| 2179 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2180 | p->prefixlen); |
| 2181 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2182 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2183 | { |
| 2184 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2185 | bgp_process (bgp, rn, afi, safi); |
| 2186 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2187 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2188 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2189 | { |
| 2190 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2191 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2192 | "%s rcvd %s/%d...duplicate ignored", |
| 2193 | peer->host, |
| 2194 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2195 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2196 | |
| 2197 | /* graceful restart STALE flag unset. */ |
| 2198 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2199 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2200 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2201 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2202 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2203 | } |
| 2204 | |
| 2205 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2206 | bgp_attr_unintern (&attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2207 | bgp_attr_extra_free (&new_attr); |
| 2208 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2209 | return 0; |
| 2210 | } |
| 2211 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2212 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2213 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2214 | { |
| 2215 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2216 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2217 | peer->host, |
| 2218 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2219 | p->prefixlen); |
| 2220 | bgp_info_restore (rn, ri); |
| 2221 | } |
| 2222 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2223 | /* Received Logging. */ |
| 2224 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2225 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2226 | peer->host, |
| 2227 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2228 | p->prefixlen); |
| 2229 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2230 | /* graceful restart STALE flag unset. */ |
| 2231 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2232 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2233 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2234 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2235 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2236 | |
| 2237 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2238 | * only if update is accepted, they'll increment below. |
| 2239 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2240 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2241 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2242 | /* Update bgp route dampening information. */ |
| 2243 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2244 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2245 | { |
| 2246 | /* This is implicit withdraw so we should update dampening |
| 2247 | information. */ |
| 2248 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2249 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2250 | } |
| 2251 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2253 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | ri->attr = attr_new; |
| 2255 | |
| 2256 | /* Update MPLS tag. */ |
| 2257 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2258 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2259 | |
| 2260 | /* Update bgp route dampening information. */ |
| 2261 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2262 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2263 | { |
| 2264 | /* Now we do normal update dampening. */ |
| 2265 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2266 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2267 | { |
| 2268 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2269 | bgp_attr_extra_free (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2270 | return 0; |
| 2271 | } |
| 2272 | } |
| 2273 | |
| 2274 | /* Nexthop reachability check. */ |
| 2275 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2276 | && safi == SAFI_UNICAST |
| 2277 | && (peer_sort (peer) == BGP_PEER_IBGP |
Vasilis Tsiligiannis | 638b70b | 2009-07-20 01:25:16 +0300 | [diff] [blame] | 2278 | || peer_sort (peer) == BGP_PEER_CONFED |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2279 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2280 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2281 | { |
| 2282 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2283 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2284 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2285 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2286 | } |
| 2287 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2288 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2289 | |
| 2290 | /* Process change. */ |
| 2291 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2292 | |
| 2293 | bgp_process (bgp, rn, afi, safi); |
| 2294 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2295 | bgp_attr_extra_free (&new_attr); |
| 2296 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2297 | return 0; |
| 2298 | } |
| 2299 | |
| 2300 | /* Received Logging. */ |
| 2301 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2302 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2303 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2304 | peer->host, |
| 2305 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2306 | p->prefixlen); |
| 2307 | } |
| 2308 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2309 | /* Make new BGP info. */ |
| 2310 | new = bgp_info_new (); |
| 2311 | new->type = type; |
| 2312 | new->sub_type = sub_type; |
| 2313 | new->peer = peer; |
| 2314 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2315 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | |
| 2317 | /* Update MPLS tag. */ |
| 2318 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2319 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2320 | |
| 2321 | /* Nexthop reachability check. */ |
| 2322 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2323 | && safi == SAFI_UNICAST |
| 2324 | && (peer_sort (peer) == BGP_PEER_IBGP |
Vasilis Tsiligiannis | 638b70b | 2009-07-20 01:25:16 +0300 | [diff] [blame] | 2325 | || peer_sort (peer) == BGP_PEER_CONFED |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2326 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2327 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | { |
| 2329 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2330 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2331 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2332 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2333 | } |
| 2334 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2335 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2337 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2338 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2339 | |
| 2340 | /* Register new BGP information. */ |
| 2341 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2342 | |
| 2343 | /* route_node_get lock */ |
| 2344 | bgp_unlock_node (rn); |
| 2345 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2346 | bgp_attr_extra_free (&new_attr); |
| 2347 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2348 | /* If maximum prefix count is configured and current prefix |
| 2349 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2350 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2351 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2352 | |
| 2353 | /* Process change. */ |
| 2354 | bgp_process (bgp, rn, afi, safi); |
| 2355 | |
| 2356 | return 0; |
| 2357 | |
| 2358 | /* This BGP update is filtered. Log the reason then update BGP |
| 2359 | entry. */ |
| 2360 | filtered: |
| 2361 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2362 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2363 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2364 | peer->host, |
| 2365 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2366 | p->prefixlen, reason); |
| 2367 | |
| 2368 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2369 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2370 | |
| 2371 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2372 | |
| 2373 | bgp_attr_extra_free (&new_attr); |
| 2374 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2375 | return 0; |
| 2376 | } |
| 2377 | |
| 2378 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2379 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2380 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2381 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2382 | { |
| 2383 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2384 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2385 | struct bgp *bgp; |
| 2386 | int ret; |
| 2387 | |
| 2388 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2389 | soft_reconfig); |
| 2390 | |
| 2391 | bgp = peer->bgp; |
| 2392 | |
| 2393 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2394 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2395 | { |
| 2396 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2397 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2398 | sub_type, prd, tag); |
| 2399 | } |
| 2400 | |
| 2401 | return ret; |
| 2402 | } |
| 2403 | |
| 2404 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2405 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2406 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2407 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2408 | { |
| 2409 | struct bgp *bgp; |
| 2410 | char buf[SU_ADDRSTRLEN]; |
| 2411 | struct bgp_node *rn; |
| 2412 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2413 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2414 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2415 | |
| 2416 | bgp = peer->bgp; |
| 2417 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2418 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2419 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2420 | { |
| 2421 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2422 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2423 | } |
| 2424 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2425 | /* Logging. */ |
| 2426 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2427 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2428 | peer->host, |
| 2429 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2430 | p->prefixlen); |
| 2431 | |
| 2432 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2433 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2434 | |
| 2435 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2436 | further calculation. */ |
| 2437 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2438 | && peer != bgp->peer_self) |
| 2439 | bgp_adj_in_unset (rn, peer); |
| 2440 | |
| 2441 | /* Lookup withdrawn route. */ |
| 2442 | for (ri = rn->info; ri; ri = ri->next) |
| 2443 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2444 | break; |
| 2445 | |
| 2446 | /* Withdraw specified route from routing table. */ |
| 2447 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2448 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2449 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2450 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2451 | "%s Can't find the route %s/%d", peer->host, |
| 2452 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2453 | p->prefixlen); |
| 2454 | |
| 2455 | /* Unlock bgp_node_get() lock. */ |
| 2456 | bgp_unlock_node (rn); |
| 2457 | |
| 2458 | return 0; |
| 2459 | } |
| 2460 | |
| 2461 | void |
| 2462 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2463 | { |
| 2464 | struct bgp *bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2465 | struct attr attr = { 0 }; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2466 | struct aspath *aspath = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2467 | struct prefix p; |
| 2468 | struct bgp_info binfo; |
| 2469 | struct peer *from; |
| 2470 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2471 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2472 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2473 | return; |
| 2474 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2475 | bgp = peer->bgp; |
| 2476 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2477 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2479 | aspath = attr.aspath; |
| 2480 | attr.local_pref = bgp->default_local_pref; |
| 2481 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2482 | |
| 2483 | if (afi == AFI_IP) |
| 2484 | str2prefix ("0.0.0.0/0", &p); |
| 2485 | #ifdef HAVE_IPV6 |
| 2486 | else if (afi == AFI_IP6) |
| 2487 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2488 | struct attr_extra *ae; |
| 2489 | attr.extra = NULL; |
| 2490 | |
| 2491 | ae = bgp_attr_extra_get (&attr); |
| 2492 | attr.extra = ae; |
| 2493 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2494 | str2prefix ("::/0", &p); |
| 2495 | |
| 2496 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2497 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2498 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2499 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2500 | |
| 2501 | /* If the peer is on shared nextwork and we have link-local |
| 2502 | nexthop set it. */ |
| 2503 | if (peer->shared_network |
| 2504 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2505 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2506 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2507 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2508 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2509 | } |
| 2510 | } |
| 2511 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2512 | |
| 2513 | if (peer->default_rmap[afi][safi].name) |
| 2514 | { |
| 2515 | binfo.peer = bgp->peer_self; |
| 2516 | binfo.attr = &attr; |
| 2517 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2518 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2520 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2521 | RMAP_BGP, &binfo); |
| 2522 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2523 | bgp->peer_self->rmap_type = 0; |
| 2524 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2525 | if (ret == RMAP_DENYMATCH) |
| 2526 | { |
| 2527 | bgp_attr_flush (&attr); |
| 2528 | withdraw = 1; |
| 2529 | } |
| 2530 | } |
| 2531 | |
| 2532 | if (withdraw) |
| 2533 | { |
| 2534 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2535 | bgp_default_withdraw_send (peer, afi, safi); |
| 2536 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2537 | } |
| 2538 | else |
| 2539 | { |
| 2540 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2541 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2542 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2543 | |
| 2544 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2545 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2546 | } |
| 2547 | |
| 2548 | static void |
| 2549 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2550 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2551 | { |
| 2552 | struct bgp_node *rn; |
| 2553 | struct bgp_info *ri; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2554 | struct attr attr = { 0 }; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2555 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2556 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2557 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2558 | |
| 2559 | if (safi != SAFI_MPLS_VPN |
| 2560 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2561 | bgp_default_originate (peer, afi, safi, 0); |
| 2562 | |
| 2563 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2564 | for (ri = rn->info; ri; ri = ri->next) |
| 2565 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2566 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2567 | if ( (rsclient) ? |
| 2568 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2569 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2570 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2571 | else |
| 2572 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2573 | |
| 2574 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2575 | } |
| 2576 | } |
| 2577 | |
| 2578 | void |
| 2579 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2580 | { |
| 2581 | struct bgp_node *rn; |
| 2582 | struct bgp_table *table; |
| 2583 | |
| 2584 | if (peer->status != Established) |
| 2585 | return; |
| 2586 | |
| 2587 | if (! peer->afc_nego[afi][safi]) |
| 2588 | return; |
| 2589 | |
| 2590 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2591 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2592 | return; |
| 2593 | |
| 2594 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2595 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2596 | else |
| 2597 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2598 | rn = bgp_route_next(rn)) |
| 2599 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2600 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2601 | |
| 2602 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2603 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2604 | } |
| 2605 | |
| 2606 | void |
| 2607 | bgp_announce_route_all (struct peer *peer) |
| 2608 | { |
| 2609 | afi_t afi; |
| 2610 | safi_t safi; |
| 2611 | |
| 2612 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2613 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2614 | bgp_announce_route (peer, afi, safi); |
| 2615 | } |
| 2616 | |
| 2617 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2618 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2619 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2620 | { |
| 2621 | struct bgp_node *rn; |
| 2622 | struct bgp_adj_in *ain; |
| 2623 | |
| 2624 | if (! table) |
| 2625 | table = rsclient->bgp->rib[afi][safi]; |
| 2626 | |
| 2627 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2628 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2629 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2630 | struct bgp_info *ri = rn->info; |
| 2631 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2632 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2633 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, |
| 2634 | (bgp_info_extra_get (ri))->tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2635 | } |
| 2636 | } |
| 2637 | |
| 2638 | void |
| 2639 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2640 | { |
| 2641 | struct bgp_table *table; |
| 2642 | struct bgp_node *rn; |
| 2643 | |
| 2644 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2645 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2646 | |
| 2647 | else |
| 2648 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2649 | rn = bgp_route_next (rn)) |
| 2650 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2651 | { |
| 2652 | struct prefix_rd prd; |
| 2653 | prd.family = AF_UNSPEC; |
| 2654 | prd.prefixlen = 64; |
| 2655 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2656 | |
| 2657 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2658 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2659 | } |
| 2660 | |
| 2661 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2662 | 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^] | 2663 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2664 | { |
| 2665 | int ret; |
| 2666 | struct bgp_node *rn; |
| 2667 | struct bgp_adj_in *ain; |
| 2668 | |
| 2669 | if (! table) |
| 2670 | table = peer->bgp->rib[afi][safi]; |
| 2671 | |
| 2672 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2673 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2674 | { |
| 2675 | if (ain->peer == peer) |
| 2676 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2677 | struct bgp_info *ri = rn->info; |
| 2678 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2679 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2680 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2681 | prd, (bgp_info_extra_get (ri))->tag, 1); |
| 2682 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2683 | if (ret < 0) |
| 2684 | { |
| 2685 | bgp_unlock_node (rn); |
| 2686 | return; |
| 2687 | } |
| 2688 | continue; |
| 2689 | } |
| 2690 | } |
| 2691 | } |
| 2692 | |
| 2693 | void |
| 2694 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2695 | { |
| 2696 | struct bgp_node *rn; |
| 2697 | struct bgp_table *table; |
| 2698 | |
| 2699 | if (peer->status != Established) |
| 2700 | return; |
| 2701 | |
| 2702 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2703 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2704 | else |
| 2705 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2706 | rn = bgp_route_next (rn)) |
| 2707 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame^] | 2708 | { |
| 2709 | struct prefix_rd prd; |
| 2710 | prd.family = AF_UNSPEC; |
| 2711 | prd.prefixlen = 64; |
| 2712 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2713 | |
| 2714 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2715 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2716 | } |
| 2717 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2718 | |
| 2719 | struct bgp_clear_node_queue |
| 2720 | { |
| 2721 | struct bgp_node *rn; |
| 2722 | enum bgp_clear_route_type purpose; |
| 2723 | }; |
| 2724 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2725 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2726 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2727 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2728 | struct bgp_clear_node_queue *cnq = data; |
| 2729 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2730 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2731 | struct bgp_info *ri; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2732 | afi_t afi = rn->table->afi; |
| 2733 | safi_t safi = rn->table->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2734 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2735 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2736 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2737 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2738 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2739 | { |
| 2740 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2741 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2742 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2743 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2744 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2745 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2746 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2747 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2748 | break; |
| 2749 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2750 | return WQ_SUCCESS; |
| 2751 | } |
| 2752 | |
| 2753 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2754 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2755 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2756 | struct bgp_clear_node_queue *cnq = data; |
| 2757 | struct bgp_node *rn = cnq->rn; |
| 2758 | struct bgp_table *table = rn->table; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2759 | |
| 2760 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2761 | bgp_table_unlock (table); |
| 2762 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2763 | } |
| 2764 | |
| 2765 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2766 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2767 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2768 | struct peer *peer = wq->spec.data; |
| 2769 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2770 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2771 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2772 | |
| 2773 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2774 | } |
| 2775 | |
| 2776 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2777 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2778 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2779 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2780 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2781 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2782 | #undef CLEAR_QUEUE_NAME_LEN |
| 2783 | |
| 2784 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2785 | { |
| 2786 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2787 | exit (1); |
| 2788 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2789 | peer->clear_node_queue->spec.hold = 10; |
| 2790 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2791 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2792 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2793 | peer->clear_node_queue->spec.max_retries = 0; |
| 2794 | |
| 2795 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2796 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2797 | } |
| 2798 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2799 | static void |
| 2800 | 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] | 2801 | struct bgp_table *table, struct peer *rsclient, |
| 2802 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2803 | { |
| 2804 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2805 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2806 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2807 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2808 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2809 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2810 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2811 | if (! table) |
| 2812 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2813 | |
| 2814 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2815 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2816 | struct bgp_info *ri; |
| 2817 | struct bgp_adj_in *ain; |
| 2818 | struct bgp_adj_out *aout; |
| 2819 | |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2820 | if (rn->info == NULL) |
| 2821 | continue; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2822 | |
| 2823 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2824 | * queued for every clearing peer, regardless of whether it is |
| 2825 | * relevant to the peer at hand. |
| 2826 | * |
| 2827 | * Overview: There are 3 different indices which need to be |
| 2828 | * scrubbed, potentially, when a peer is removed: |
| 2829 | * |
| 2830 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2831 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2832 | * 3 other routes visible by the peer's adj-out index |
| 2833 | * |
| 2834 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2835 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2836 | * adj-outs at our leisure. |
| 2837 | * |
| 2838 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2839 | * invisible via RIB index before peer session is allowed to be |
| 2840 | * brought back up. So one needs to know when such a 'search' is |
| 2841 | * complete. |
| 2842 | * |
| 2843 | * Ideally: |
| 2844 | * |
| 2845 | * - there'd be a single global queue or a single RIB walker |
| 2846 | * - rather than tracking which route_nodes still need to be |
| 2847 | * examined on a peer basis, we'd track which peers still |
| 2848 | * aren't cleared |
| 2849 | * |
| 2850 | * Given that our per-peer prefix-counts now should be reliable, |
| 2851 | * this may actually be achievable. It doesn't seem to be a huge |
| 2852 | * problem at this time, |
| 2853 | */ |
| 2854 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2855 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2856 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2857 | struct bgp_clear_node_queue *cnq; |
| 2858 | |
| 2859 | /* both unlocked in bgp_clear_node_queue_del */ |
| 2860 | bgp_table_lock (rn->table); |
| 2861 | bgp_lock_node (rn); |
| 2862 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2863 | sizeof (struct bgp_clear_node_queue)); |
| 2864 | cnq->rn = rn; |
| 2865 | cnq->purpose = purpose; |
| 2866 | work_queue_add (peer->clear_node_queue, cnq); |
| 2867 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2868 | } |
| 2869 | |
| 2870 | for (ain = rn->adj_in; ain; ain = ain->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2871 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2872 | { |
| 2873 | bgp_adj_in_remove (rn, ain); |
| 2874 | bgp_unlock_node (rn); |
| 2875 | break; |
| 2876 | } |
| 2877 | for (aout = rn->adj_out; aout; aout = aout->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2878 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2879 | { |
| 2880 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2881 | bgp_unlock_node (rn); |
| 2882 | break; |
| 2883 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2884 | } |
| 2885 | return; |
| 2886 | } |
| 2887 | |
| 2888 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2889 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2890 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2891 | { |
| 2892 | struct bgp_node *rn; |
| 2893 | struct bgp_table *table; |
| 2894 | struct peer *rsclient; |
| 2895 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2896 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2897 | if (peer->clear_node_queue == NULL) |
| 2898 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2899 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2900 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2901 | * Idle until it receives a Clearing_Completed event. This protects |
| 2902 | * against peers which flap faster than we can we clear, which could |
| 2903 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2904 | * |
| 2905 | * a) race with routes from the new session being installed before |
| 2906 | * clear_route_node visits the node (to delete the route of that |
| 2907 | * peer) |
| 2908 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2909 | * on the process_main queue. Fast-flapping could cause that queue |
| 2910 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2911 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2912 | if (!peer->clear_node_queue->thread) |
| 2913 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2914 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2915 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2916 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2917 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2918 | if (safi != SAFI_MPLS_VPN) |
| 2919 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 2920 | else |
| 2921 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2922 | rn = bgp_route_next (rn)) |
| 2923 | if ((table = rn->info) != NULL) |
| 2924 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 2925 | |
| 2926 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 2927 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 2928 | PEER_FLAG_RSERVER_CLIENT)) |
| 2929 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 2930 | break; |
| 2931 | |
| 2932 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 2933 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 2934 | break; |
| 2935 | |
| 2936 | default: |
| 2937 | assert (0); |
| 2938 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2939 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2940 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2941 | /* If no routes were cleared, nothing was added to workqueue, the |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2942 | * completion function won't be run by workqueue code - call it here. |
| 2943 | * XXX: Actually, this assumption doesn't hold, see |
| 2944 | * bgp_clear_route_table(), we queue all non-empty nodes. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2945 | * |
| 2946 | * Additionally, there is a presumption in FSM that clearing is only |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2947 | * really needed if peer state is Established - peers in |
| 2948 | * pre-Established states shouldn't have any route-update state |
| 2949 | * associated with them (in or out). |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2950 | * |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2951 | * We still can get here in pre-Established though, through |
| 2952 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity |
| 2953 | * check to ensure the assumption above holds. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2954 | * |
| 2955 | * At some future point, this check could be move to the top of the |
| 2956 | * function, and do a quick early-return when state is |
| 2957 | * pre-Established, avoiding above list and table scans. Once we're |
| 2958 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2959 | */ |
| 2960 | if (!peer->clear_node_queue->thread) |
| 2961 | bgp_clear_node_complete (peer->clear_node_queue); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2962 | } |
| 2963 | |
| 2964 | void |
| 2965 | bgp_clear_route_all (struct peer *peer) |
| 2966 | { |
| 2967 | afi_t afi; |
| 2968 | safi_t safi; |
| 2969 | |
| 2970 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2971 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2972 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2973 | } |
| 2974 | |
| 2975 | void |
| 2976 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2977 | { |
| 2978 | struct bgp_table *table; |
| 2979 | struct bgp_node *rn; |
| 2980 | struct bgp_adj_in *ain; |
| 2981 | |
| 2982 | table = peer->bgp->rib[afi][safi]; |
| 2983 | |
| 2984 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2985 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2986 | if (ain->peer == peer) |
| 2987 | { |
| 2988 | bgp_adj_in_remove (rn, ain); |
| 2989 | bgp_unlock_node (rn); |
| 2990 | break; |
| 2991 | } |
| 2992 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2993 | |
| 2994 | void |
| 2995 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2996 | { |
| 2997 | struct bgp_node *rn; |
| 2998 | struct bgp_info *ri; |
| 2999 | struct bgp_table *table; |
| 3000 | |
| 3001 | table = peer->bgp->rib[afi][safi]; |
| 3002 | |
| 3003 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3004 | { |
| 3005 | for (ri = rn->info; ri; ri = ri->next) |
| 3006 | if (ri->peer == peer) |
| 3007 | { |
| 3008 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3009 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3010 | break; |
| 3011 | } |
| 3012 | } |
| 3013 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3014 | |
| 3015 | /* Delete all kernel routes. */ |
| 3016 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3017 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3018 | { |
| 3019 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3020 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3021 | struct bgp_node *rn; |
| 3022 | struct bgp_table *table; |
| 3023 | struct bgp_info *ri; |
| 3024 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3025 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3026 | { |
| 3027 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3028 | |
| 3029 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3030 | for (ri = rn->info; ri; ri = ri->next) |
| 3031 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3032 | && ri->type == ZEBRA_ROUTE_BGP |
| 3033 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3034 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3035 | |
| 3036 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3037 | |
| 3038 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3039 | for (ri = rn->info; ri; ri = ri->next) |
| 3040 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3041 | && ri->type == ZEBRA_ROUTE_BGP |
| 3042 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3043 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3044 | } |
| 3045 | } |
| 3046 | |
| 3047 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3048 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3049 | { |
| 3050 | vty_reset (); |
| 3051 | bgp_zclient_reset (); |
| 3052 | access_list_reset (); |
| 3053 | prefix_list_reset (); |
| 3054 | } |
| 3055 | |
| 3056 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3057 | value. */ |
| 3058 | int |
| 3059 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3060 | { |
| 3061 | u_char *pnt; |
| 3062 | u_char *lim; |
| 3063 | struct prefix p; |
| 3064 | int psize; |
| 3065 | int ret; |
| 3066 | |
| 3067 | /* Check peer status. */ |
| 3068 | if (peer->status != Established) |
| 3069 | return 0; |
| 3070 | |
| 3071 | pnt = packet->nlri; |
| 3072 | lim = pnt + packet->length; |
| 3073 | |
| 3074 | for (; pnt < lim; pnt += psize) |
| 3075 | { |
| 3076 | /* Clear prefix structure. */ |
| 3077 | memset (&p, 0, sizeof (struct prefix)); |
| 3078 | |
| 3079 | /* Fetch prefix length. */ |
| 3080 | p.prefixlen = *pnt++; |
| 3081 | p.family = afi2family (packet->afi); |
| 3082 | |
| 3083 | /* Already checked in nlri_sanity_check(). We do double check |
| 3084 | here. */ |
| 3085 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3086 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3087 | return -1; |
| 3088 | |
| 3089 | /* Packet size overflow check. */ |
| 3090 | psize = PSIZE (p.prefixlen); |
| 3091 | |
| 3092 | /* When packet overflow occur return immediately. */ |
| 3093 | if (pnt + psize > lim) |
| 3094 | return -1; |
| 3095 | |
| 3096 | /* Fetch prefix from NLRI packet. */ |
| 3097 | memcpy (&p.u.prefix, pnt, psize); |
| 3098 | |
| 3099 | /* Check address. */ |
| 3100 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3101 | { |
| 3102 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3103 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3104 | /* |
| 3105 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3106 | * If a BGP router receives an UPDATE message with a |
| 3107 | * semantically incorrect NLRI field, in which a prefix is |
| 3108 | * semantically incorrect (eg. an unexpected multicast IP |
| 3109 | * address), it should ignore the prefix. |
| 3110 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3111 | zlog (peer->log, LOG_ERR, |
| 3112 | "IPv4 unicast NLRI is multicast address %s", |
| 3113 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3114 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3115 | return -1; |
| 3116 | } |
| 3117 | } |
| 3118 | |
| 3119 | #ifdef HAVE_IPV6 |
| 3120 | /* Check address. */ |
| 3121 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3122 | { |
| 3123 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3124 | { |
| 3125 | char buf[BUFSIZ]; |
| 3126 | |
| 3127 | zlog (peer->log, LOG_WARNING, |
| 3128 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3129 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3130 | |
| 3131 | continue; |
| 3132 | } |
| 3133 | } |
| 3134 | #endif /* HAVE_IPV6 */ |
| 3135 | |
| 3136 | /* Normal process. */ |
| 3137 | if (attr) |
| 3138 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3139 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3140 | else |
| 3141 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3142 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3143 | |
| 3144 | /* Address family configuration mismatch or maximum-prefix count |
| 3145 | overflow. */ |
| 3146 | if (ret < 0) |
| 3147 | return -1; |
| 3148 | } |
| 3149 | |
| 3150 | /* Packet length consistency check. */ |
| 3151 | if (pnt != lim) |
| 3152 | return -1; |
| 3153 | |
| 3154 | return 0; |
| 3155 | } |
| 3156 | |
| 3157 | /* NLRI encode syntax check routine. */ |
| 3158 | int |
| 3159 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3160 | bgp_size_t length) |
| 3161 | { |
| 3162 | u_char *end; |
| 3163 | u_char prefixlen; |
| 3164 | int psize; |
| 3165 | |
| 3166 | end = pnt + length; |
| 3167 | |
| 3168 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3169 | syntactic validity. If the field is syntactically incorrect, |
| 3170 | then the Error Subcode is set to Invalid Network Field. */ |
| 3171 | |
| 3172 | while (pnt < end) |
| 3173 | { |
| 3174 | prefixlen = *pnt++; |
| 3175 | |
| 3176 | /* Prefix length check. */ |
| 3177 | if ((afi == AFI_IP && prefixlen > 32) |
| 3178 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3179 | { |
| 3180 | plog_err (peer->log, |
| 3181 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3182 | peer->host, prefixlen); |
| 3183 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3184 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3185 | return -1; |
| 3186 | } |
| 3187 | |
| 3188 | /* Packet size overflow check. */ |
| 3189 | psize = PSIZE (prefixlen); |
| 3190 | |
| 3191 | if (pnt + psize > end) |
| 3192 | { |
| 3193 | plog_err (peer->log, |
| 3194 | "%s [Error] Update packet error" |
| 3195 | " (prefix data overflow prefix size is %d)", |
| 3196 | peer->host, psize); |
| 3197 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3198 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3199 | return -1; |
| 3200 | } |
| 3201 | |
| 3202 | pnt += psize; |
| 3203 | } |
| 3204 | |
| 3205 | /* Packet length consistency check. */ |
| 3206 | if (pnt != end) |
| 3207 | { |
| 3208 | plog_err (peer->log, |
| 3209 | "%s [Error] Update packet error" |
| 3210 | " (prefix length mismatch with total length)", |
| 3211 | peer->host); |
| 3212 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3213 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3214 | return -1; |
| 3215 | } |
| 3216 | return 0; |
| 3217 | } |
| 3218 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3219 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3220 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3221 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3222 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3223 | } |
| 3224 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3225 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3226 | bgp_static_free (struct bgp_static *bgp_static) |
| 3227 | { |
| 3228 | if (bgp_static->rmap.name) |
| 3229 | free (bgp_static->rmap.name); |
| 3230 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3231 | } |
| 3232 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3233 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3234 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3235 | struct prefix *p, afi_t afi, safi_t safi) |
| 3236 | { |
| 3237 | struct bgp_node *rn; |
| 3238 | struct bgp_info *ri; |
| 3239 | |
| 3240 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3241 | |
| 3242 | /* Check selected route and self inserted route. */ |
| 3243 | for (ri = rn->info; ri; ri = ri->next) |
| 3244 | if (ri->peer == bgp->peer_self |
| 3245 | && ri->type == ZEBRA_ROUTE_BGP |
| 3246 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3247 | break; |
| 3248 | |
| 3249 | /* Withdraw static BGP route from routing table. */ |
| 3250 | if (ri) |
| 3251 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3252 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3253 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3254 | } |
| 3255 | |
| 3256 | /* Unlock bgp_node_lookup. */ |
| 3257 | bgp_unlock_node (rn); |
| 3258 | } |
| 3259 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3260 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3261 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3262 | struct bgp_static *bgp_static, |
| 3263 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3264 | { |
| 3265 | struct bgp_node *rn; |
| 3266 | struct bgp_info *ri; |
| 3267 | struct bgp_info *new; |
| 3268 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3269 | struct attr *attr_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3270 | struct attr attr = {0 }; |
| 3271 | struct attr new_attr = { .extra = 0 }; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3272 | struct bgp *bgp; |
| 3273 | int ret; |
| 3274 | char buf[SU_ADDRSTRLEN]; |
| 3275 | |
| 3276 | bgp = rsclient->bgp; |
| 3277 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3278 | assert (bgp_static); |
| 3279 | if (!bgp_static) |
| 3280 | return; |
| 3281 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3282 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3283 | |
| 3284 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3285 | |
| 3286 | attr.nexthop = bgp_static->igpnexthop; |
| 3287 | attr.med = bgp_static->igpmetric; |
| 3288 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3289 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3290 | if (bgp_static->atomic) |
| 3291 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3292 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3293 | /* Apply network route-map for export to this rsclient. */ |
| 3294 | if (bgp_static->rmap.name) |
| 3295 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3296 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3297 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3298 | info.attr = &attr_tmp; |
| 3299 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3300 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3301 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3302 | |
| 3303 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3304 | |
| 3305 | rsclient->rmap_type = 0; |
| 3306 | |
| 3307 | if (ret == RMAP_DENYMATCH) |
| 3308 | { |
| 3309 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3310 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3311 | |
| 3312 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3313 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3314 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3315 | bgp_attr_extra_free (&attr); |
| 3316 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3317 | return; |
| 3318 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3319 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3320 | } |
| 3321 | else |
| 3322 | attr_new = bgp_attr_intern (&attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3323 | |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3324 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3325 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3326 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3327 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3328 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3329 | == RMAP_DENY) |
| 3330 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3331 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3332 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3333 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3334 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3335 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3336 | p->prefixlen, rsclient->host); |
| 3337 | |
| 3338 | bgp->peer_self->rmap_type = 0; |
| 3339 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3340 | bgp_attr_unintern (&attr_new); |
| 3341 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3342 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3343 | |
| 3344 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3345 | |
| 3346 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3347 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3348 | |
| 3349 | bgp->peer_self->rmap_type = 0; |
| 3350 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3351 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3352 | attr_new = bgp_attr_intern (&new_attr); |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3353 | bgp_attr_extra_free (&new_attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3354 | |
| 3355 | for (ri = rn->info; ri; ri = ri->next) |
| 3356 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3357 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3358 | break; |
| 3359 | |
| 3360 | if (ri) |
| 3361 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3362 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3363 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3364 | { |
| 3365 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3366 | bgp_attr_unintern (&attr_new); |
| 3367 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3368 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3369 | return; |
| 3370 | } |
| 3371 | else |
| 3372 | { |
| 3373 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3374 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3375 | |
| 3376 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3377 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3378 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3379 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3380 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3381 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3382 | |
| 3383 | /* Process change. */ |
| 3384 | bgp_process (bgp, rn, afi, safi); |
| 3385 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3386 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3387 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3388 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3389 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3390 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3391 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3392 | /* Make new BGP info. */ |
| 3393 | new = bgp_info_new (); |
| 3394 | new->type = ZEBRA_ROUTE_BGP; |
| 3395 | new->sub_type = BGP_ROUTE_STATIC; |
| 3396 | new->peer = bgp->peer_self; |
| 3397 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3398 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3399 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3400 | |
| 3401 | /* Register new BGP information. */ |
| 3402 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3403 | |
| 3404 | /* route_node_get lock */ |
| 3405 | bgp_unlock_node (rn); |
| 3406 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3407 | /* Process change. */ |
| 3408 | bgp_process (bgp, rn, afi, safi); |
| 3409 | |
| 3410 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3411 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3412 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3413 | } |
| 3414 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3415 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3416 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3417 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3418 | { |
| 3419 | struct bgp_node *rn; |
| 3420 | struct bgp_info *ri; |
| 3421 | struct bgp_info *new; |
| 3422 | struct bgp_info info; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3423 | struct attr attr = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3424 | struct attr *attr_new; |
| 3425 | int ret; |
| 3426 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3427 | assert (bgp_static); |
| 3428 | if (!bgp_static) |
| 3429 | return; |
| 3430 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3431 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3432 | |
| 3433 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3434 | |
| 3435 | attr.nexthop = bgp_static->igpnexthop; |
| 3436 | attr.med = bgp_static->igpmetric; |
| 3437 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3438 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3439 | if (bgp_static->atomic) |
| 3440 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3441 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3442 | /* Apply route-map. */ |
| 3443 | if (bgp_static->rmap.name) |
| 3444 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3445 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3446 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3447 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3448 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3449 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3450 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3451 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3452 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3453 | bgp->peer_self->rmap_type = 0; |
| 3454 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3455 | if (ret == RMAP_DENYMATCH) |
| 3456 | { |
| 3457 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3458 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3459 | |
| 3460 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3461 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3462 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3463 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3464 | return; |
| 3465 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3466 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3467 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3468 | else |
| 3469 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3470 | |
| 3471 | for (ri = rn->info; ri; ri = ri->next) |
| 3472 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3473 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3474 | break; |
| 3475 | |
| 3476 | if (ri) |
| 3477 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3478 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3479 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3480 | { |
| 3481 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3482 | bgp_attr_unintern (&attr_new); |
| 3483 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3484 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3485 | return; |
| 3486 | } |
| 3487 | else |
| 3488 | { |
| 3489 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3490 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3491 | |
| 3492 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3493 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3494 | bgp_info_restore(rn, ri); |
| 3495 | else |
| 3496 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3497 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3498 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3499 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3500 | |
| 3501 | /* Process change. */ |
| 3502 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3503 | bgp_process (bgp, rn, afi, safi); |
| 3504 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3505 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3506 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3507 | return; |
| 3508 | } |
| 3509 | } |
| 3510 | |
| 3511 | /* Make new BGP info. */ |
| 3512 | new = bgp_info_new (); |
| 3513 | new->type = ZEBRA_ROUTE_BGP; |
| 3514 | new->sub_type = BGP_ROUTE_STATIC; |
| 3515 | new->peer = bgp->peer_self; |
| 3516 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3517 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3518 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3519 | |
| 3520 | /* Aggregate address increment. */ |
| 3521 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3522 | |
| 3523 | /* Register new BGP information. */ |
| 3524 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3525 | |
| 3526 | /* route_node_get lock */ |
| 3527 | bgp_unlock_node (rn); |
| 3528 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3529 | /* Process change. */ |
| 3530 | bgp_process (bgp, rn, afi, safi); |
| 3531 | |
| 3532 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3533 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3534 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3535 | } |
| 3536 | |
| 3537 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3538 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3539 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3540 | { |
| 3541 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3542 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3543 | |
| 3544 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3545 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3546 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3547 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3548 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3549 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3550 | } |
| 3551 | } |
| 3552 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3553 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3554 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3555 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3556 | { |
| 3557 | struct bgp_node *rn; |
| 3558 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3559 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3560 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3561 | |
| 3562 | /* Make new BGP info. */ |
| 3563 | new = bgp_info_new (); |
| 3564 | new->type = ZEBRA_ROUTE_BGP; |
| 3565 | new->sub_type = BGP_ROUTE_STATIC; |
| 3566 | new->peer = bgp->peer_self; |
| 3567 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3568 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3569 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3570 | new->extra = bgp_info_extra_new(); |
| 3571 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3572 | |
| 3573 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3574 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3575 | |
| 3576 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3577 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3578 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3579 | /* route_node_get lock */ |
| 3580 | bgp_unlock_node (rn); |
| 3581 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3582 | /* Process change. */ |
| 3583 | bgp_process (bgp, rn, afi, safi); |
| 3584 | } |
| 3585 | |
| 3586 | void |
| 3587 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3588 | safi_t safi) |
| 3589 | { |
| 3590 | struct bgp_node *rn; |
| 3591 | struct bgp_info *ri; |
| 3592 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3593 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3594 | |
| 3595 | /* Check selected route and self inserted route. */ |
| 3596 | for (ri = rn->info; ri; ri = ri->next) |
| 3597 | if (ri->peer == bgp->peer_self |
| 3598 | && ri->type == ZEBRA_ROUTE_BGP |
| 3599 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3600 | break; |
| 3601 | |
| 3602 | /* Withdraw static BGP route from routing table. */ |
| 3603 | if (ri) |
| 3604 | { |
| 3605 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3606 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3607 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3608 | } |
| 3609 | |
| 3610 | /* Unlock bgp_node_lookup. */ |
| 3611 | bgp_unlock_node (rn); |
| 3612 | } |
| 3613 | |
| 3614 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3615 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3616 | { |
| 3617 | struct bgp_static *bgp_static; |
| 3618 | struct bgp *bgp; |
| 3619 | struct bgp_node *rn; |
| 3620 | struct prefix *p; |
| 3621 | |
| 3622 | bgp = rsclient->bgp; |
| 3623 | |
| 3624 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3625 | if ((bgp_static = rn->info) != NULL) |
| 3626 | { |
| 3627 | p = &rn->p; |
| 3628 | |
| 3629 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3630 | afi, safi); |
| 3631 | } |
| 3632 | } |
| 3633 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3634 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3635 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3636 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3637 | { |
| 3638 | struct bgp_node *rn; |
| 3639 | struct bgp_info *ri; |
| 3640 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3641 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3642 | |
| 3643 | /* Check selected route and self inserted route. */ |
| 3644 | for (ri = rn->info; ri; ri = ri->next) |
| 3645 | if (ri->peer == bgp->peer_self |
| 3646 | && ri->type == ZEBRA_ROUTE_BGP |
| 3647 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3648 | break; |
| 3649 | |
| 3650 | /* Withdraw static BGP route from routing table. */ |
| 3651 | if (ri) |
| 3652 | { |
| 3653 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3654 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3655 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3656 | } |
| 3657 | |
| 3658 | /* Unlock bgp_node_lookup. */ |
| 3659 | bgp_unlock_node (rn); |
| 3660 | } |
| 3661 | |
| 3662 | /* Configure static BGP network. When user don't run zebra, static |
| 3663 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3664 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3665 | 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] | 3666 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3667 | { |
| 3668 | int ret; |
| 3669 | struct prefix p; |
| 3670 | struct bgp_static *bgp_static; |
| 3671 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3672 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3673 | |
| 3674 | /* Convert IP prefix string to struct prefix. */ |
| 3675 | ret = str2prefix (ip_str, &p); |
| 3676 | if (! ret) |
| 3677 | { |
| 3678 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3679 | return CMD_WARNING; |
| 3680 | } |
| 3681 | #ifdef HAVE_IPV6 |
| 3682 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3683 | { |
| 3684 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3685 | VTY_NEWLINE); |
| 3686 | return CMD_WARNING; |
| 3687 | } |
| 3688 | #endif /* HAVE_IPV6 */ |
| 3689 | |
| 3690 | apply_mask (&p); |
| 3691 | |
| 3692 | /* Set BGP static route configuration. */ |
| 3693 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3694 | |
| 3695 | if (rn->info) |
| 3696 | { |
| 3697 | /* Configuration change. */ |
| 3698 | bgp_static = rn->info; |
| 3699 | |
| 3700 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3701 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3702 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3703 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3704 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3705 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3706 | if (rmap) |
| 3707 | { |
| 3708 | if (bgp_static->rmap.name) |
| 3709 | free (bgp_static->rmap.name); |
| 3710 | bgp_static->rmap.name = strdup (rmap); |
| 3711 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3712 | } |
| 3713 | else |
| 3714 | { |
| 3715 | if (bgp_static->rmap.name) |
| 3716 | free (bgp_static->rmap.name); |
| 3717 | bgp_static->rmap.name = NULL; |
| 3718 | bgp_static->rmap.map = NULL; |
| 3719 | bgp_static->valid = 0; |
| 3720 | } |
| 3721 | bgp_unlock_node (rn); |
| 3722 | } |
| 3723 | else |
| 3724 | { |
| 3725 | /* New configuration. */ |
| 3726 | bgp_static = bgp_static_new (); |
| 3727 | bgp_static->backdoor = backdoor; |
| 3728 | bgp_static->valid = 0; |
| 3729 | bgp_static->igpmetric = 0; |
| 3730 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3731 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3732 | if (rmap) |
| 3733 | { |
| 3734 | if (bgp_static->rmap.name) |
| 3735 | free (bgp_static->rmap.name); |
| 3736 | bgp_static->rmap.name = strdup (rmap); |
| 3737 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3738 | } |
| 3739 | rn->info = bgp_static; |
| 3740 | } |
| 3741 | |
| 3742 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3743 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3744 | { |
| 3745 | bgp_static->valid = 1; |
| 3746 | |
| 3747 | if (need_update) |
| 3748 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3749 | |
| 3750 | if (! bgp_static->backdoor) |
| 3751 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3752 | } |
| 3753 | |
| 3754 | return CMD_SUCCESS; |
| 3755 | } |
| 3756 | |
| 3757 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3758 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3759 | 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] | 3760 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3761 | { |
| 3762 | int ret; |
| 3763 | struct prefix p; |
| 3764 | struct bgp_static *bgp_static; |
| 3765 | struct bgp_node *rn; |
| 3766 | |
| 3767 | /* Convert IP prefix string to struct prefix. */ |
| 3768 | ret = str2prefix (ip_str, &p); |
| 3769 | if (! ret) |
| 3770 | { |
| 3771 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3772 | return CMD_WARNING; |
| 3773 | } |
| 3774 | #ifdef HAVE_IPV6 |
| 3775 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3776 | { |
| 3777 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3778 | VTY_NEWLINE); |
| 3779 | return CMD_WARNING; |
| 3780 | } |
| 3781 | #endif /* HAVE_IPV6 */ |
| 3782 | |
| 3783 | apply_mask (&p); |
| 3784 | |
| 3785 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3786 | if (! rn) |
| 3787 | { |
| 3788 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3789 | VTY_NEWLINE); |
| 3790 | return CMD_WARNING; |
| 3791 | } |
| 3792 | |
| 3793 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3794 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3795 | /* Update BGP RIB. */ |
| 3796 | if (! bgp_static->backdoor) |
| 3797 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3798 | |
| 3799 | /* Clear configuration. */ |
| 3800 | bgp_static_free (bgp_static); |
| 3801 | rn->info = NULL; |
| 3802 | bgp_unlock_node (rn); |
| 3803 | bgp_unlock_node (rn); |
| 3804 | |
| 3805 | return CMD_SUCCESS; |
| 3806 | } |
| 3807 | |
| 3808 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3809 | instance. */ |
| 3810 | void |
| 3811 | bgp_static_delete (struct bgp *bgp) |
| 3812 | { |
| 3813 | afi_t afi; |
| 3814 | safi_t safi; |
| 3815 | struct bgp_node *rn; |
| 3816 | struct bgp_node *rm; |
| 3817 | struct bgp_table *table; |
| 3818 | struct bgp_static *bgp_static; |
| 3819 | |
| 3820 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3821 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3822 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3823 | if (rn->info != NULL) |
| 3824 | { |
| 3825 | if (safi == SAFI_MPLS_VPN) |
| 3826 | { |
| 3827 | table = rn->info; |
| 3828 | |
| 3829 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3830 | { |
| 3831 | bgp_static = rn->info; |
| 3832 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3833 | AFI_IP, SAFI_MPLS_VPN, |
| 3834 | (struct prefix_rd *)&rn->p, |
| 3835 | bgp_static->tag); |
| 3836 | bgp_static_free (bgp_static); |
| 3837 | rn->info = NULL; |
| 3838 | bgp_unlock_node (rn); |
| 3839 | } |
| 3840 | } |
| 3841 | else |
| 3842 | { |
| 3843 | bgp_static = rn->info; |
| 3844 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3845 | bgp_static_free (bgp_static); |
| 3846 | rn->info = NULL; |
| 3847 | bgp_unlock_node (rn); |
| 3848 | } |
| 3849 | } |
| 3850 | } |
| 3851 | |
| 3852 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3853 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3854 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3855 | { |
| 3856 | int ret; |
| 3857 | struct prefix p; |
| 3858 | struct prefix_rd prd; |
| 3859 | struct bgp *bgp; |
| 3860 | struct bgp_node *prn; |
| 3861 | struct bgp_node *rn; |
| 3862 | struct bgp_table *table; |
| 3863 | struct bgp_static *bgp_static; |
| 3864 | u_char tag[3]; |
| 3865 | |
| 3866 | bgp = vty->index; |
| 3867 | |
| 3868 | ret = str2prefix (ip_str, &p); |
| 3869 | if (! ret) |
| 3870 | { |
| 3871 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3872 | return CMD_WARNING; |
| 3873 | } |
| 3874 | apply_mask (&p); |
| 3875 | |
| 3876 | ret = str2prefix_rd (rd_str, &prd); |
| 3877 | if (! ret) |
| 3878 | { |
| 3879 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3880 | return CMD_WARNING; |
| 3881 | } |
| 3882 | |
| 3883 | ret = str2tag (tag_str, tag); |
| 3884 | if (! ret) |
| 3885 | { |
| 3886 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3887 | return CMD_WARNING; |
| 3888 | } |
| 3889 | |
| 3890 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3891 | (struct prefix *)&prd); |
| 3892 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3893 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3894 | else |
| 3895 | bgp_unlock_node (prn); |
| 3896 | table = prn->info; |
| 3897 | |
| 3898 | rn = bgp_node_get (table, &p); |
| 3899 | |
| 3900 | if (rn->info) |
| 3901 | { |
| 3902 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3903 | bgp_unlock_node (rn); |
| 3904 | } |
| 3905 | else |
| 3906 | { |
| 3907 | /* New configuration. */ |
| 3908 | bgp_static = bgp_static_new (); |
| 3909 | bgp_static->valid = 1; |
| 3910 | memcpy (bgp_static->tag, tag, 3); |
| 3911 | rn->info = bgp_static; |
| 3912 | |
| 3913 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3914 | } |
| 3915 | |
| 3916 | return CMD_SUCCESS; |
| 3917 | } |
| 3918 | |
| 3919 | /* Configure static BGP network. */ |
| 3920 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3921 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3922 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3923 | { |
| 3924 | int ret; |
| 3925 | struct bgp *bgp; |
| 3926 | struct prefix p; |
| 3927 | struct prefix_rd prd; |
| 3928 | struct bgp_node *prn; |
| 3929 | struct bgp_node *rn; |
| 3930 | struct bgp_table *table; |
| 3931 | struct bgp_static *bgp_static; |
| 3932 | u_char tag[3]; |
| 3933 | |
| 3934 | bgp = vty->index; |
| 3935 | |
| 3936 | /* Convert IP prefix string to struct prefix. */ |
| 3937 | ret = str2prefix (ip_str, &p); |
| 3938 | if (! ret) |
| 3939 | { |
| 3940 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3941 | return CMD_WARNING; |
| 3942 | } |
| 3943 | apply_mask (&p); |
| 3944 | |
| 3945 | ret = str2prefix_rd (rd_str, &prd); |
| 3946 | if (! ret) |
| 3947 | { |
| 3948 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3949 | return CMD_WARNING; |
| 3950 | } |
| 3951 | |
| 3952 | ret = str2tag (tag_str, tag); |
| 3953 | if (! ret) |
| 3954 | { |
| 3955 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3956 | return CMD_WARNING; |
| 3957 | } |
| 3958 | |
| 3959 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3960 | (struct prefix *)&prd); |
| 3961 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3962 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3963 | else |
| 3964 | bgp_unlock_node (prn); |
| 3965 | table = prn->info; |
| 3966 | |
| 3967 | rn = bgp_node_lookup (table, &p); |
| 3968 | |
| 3969 | if (rn) |
| 3970 | { |
| 3971 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3972 | |
| 3973 | bgp_static = rn->info; |
| 3974 | bgp_static_free (bgp_static); |
| 3975 | rn->info = NULL; |
| 3976 | bgp_unlock_node (rn); |
| 3977 | bgp_unlock_node (rn); |
| 3978 | } |
| 3979 | else |
| 3980 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3981 | |
| 3982 | return CMD_SUCCESS; |
| 3983 | } |
| 3984 | |
| 3985 | DEFUN (bgp_network, |
| 3986 | bgp_network_cmd, |
| 3987 | "network A.B.C.D/M", |
| 3988 | "Specify a network to announce via BGP\n" |
| 3989 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3990 | { |
| 3991 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3992 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3993 | } |
| 3994 | |
| 3995 | DEFUN (bgp_network_route_map, |
| 3996 | bgp_network_route_map_cmd, |
| 3997 | "network A.B.C.D/M route-map WORD", |
| 3998 | "Specify a network to announce via BGP\n" |
| 3999 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4000 | "Route-map to modify the attributes\n" |
| 4001 | "Name of the route map\n") |
| 4002 | { |
| 4003 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4004 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4005 | } |
| 4006 | |
| 4007 | DEFUN (bgp_network_backdoor, |
| 4008 | bgp_network_backdoor_cmd, |
| 4009 | "network A.B.C.D/M backdoor", |
| 4010 | "Specify a network to announce via BGP\n" |
| 4011 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4012 | "Specify a BGP backdoor route\n") |
| 4013 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4014 | 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] | 4015 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4016 | } |
| 4017 | |
| 4018 | DEFUN (bgp_network_mask, |
| 4019 | bgp_network_mask_cmd, |
| 4020 | "network A.B.C.D mask A.B.C.D", |
| 4021 | "Specify a network to announce via BGP\n" |
| 4022 | "Network number\n" |
| 4023 | "Network mask\n" |
| 4024 | "Network mask\n") |
| 4025 | { |
| 4026 | int ret; |
| 4027 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4028 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4029 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4030 | if (! ret) |
| 4031 | { |
| 4032 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4033 | return CMD_WARNING; |
| 4034 | } |
| 4035 | |
| 4036 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4037 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4038 | } |
| 4039 | |
| 4040 | DEFUN (bgp_network_mask_route_map, |
| 4041 | bgp_network_mask_route_map_cmd, |
| 4042 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4043 | "Specify a network to announce via BGP\n" |
| 4044 | "Network number\n" |
| 4045 | "Network mask\n" |
| 4046 | "Network mask\n" |
| 4047 | "Route-map to modify the attributes\n" |
| 4048 | "Name of the route map\n") |
| 4049 | { |
| 4050 | int ret; |
| 4051 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4052 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4053 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4054 | if (! ret) |
| 4055 | { |
| 4056 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4057 | return CMD_WARNING; |
| 4058 | } |
| 4059 | |
| 4060 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4061 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4062 | } |
| 4063 | |
| 4064 | DEFUN (bgp_network_mask_backdoor, |
| 4065 | bgp_network_mask_backdoor_cmd, |
| 4066 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4067 | "Specify a network to announce via BGP\n" |
| 4068 | "Network number\n" |
| 4069 | "Network mask\n" |
| 4070 | "Network mask\n" |
| 4071 | "Specify a BGP backdoor route\n") |
| 4072 | { |
| 4073 | int ret; |
| 4074 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4075 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4076 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4077 | if (! ret) |
| 4078 | { |
| 4079 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4080 | return CMD_WARNING; |
| 4081 | } |
| 4082 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4083 | 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] | 4084 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | DEFUN (bgp_network_mask_natural, |
| 4088 | bgp_network_mask_natural_cmd, |
| 4089 | "network A.B.C.D", |
| 4090 | "Specify a network to announce via BGP\n" |
| 4091 | "Network number\n") |
| 4092 | { |
| 4093 | int ret; |
| 4094 | char prefix_str[BUFSIZ]; |
| 4095 | |
| 4096 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4097 | if (! ret) |
| 4098 | { |
| 4099 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4100 | return CMD_WARNING; |
| 4101 | } |
| 4102 | |
| 4103 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4104 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4105 | } |
| 4106 | |
| 4107 | DEFUN (bgp_network_mask_natural_route_map, |
| 4108 | bgp_network_mask_natural_route_map_cmd, |
| 4109 | "network A.B.C.D route-map WORD", |
| 4110 | "Specify a network to announce via BGP\n" |
| 4111 | "Network number\n" |
| 4112 | "Route-map to modify the attributes\n" |
| 4113 | "Name of the route map\n") |
| 4114 | { |
| 4115 | int ret; |
| 4116 | char prefix_str[BUFSIZ]; |
| 4117 | |
| 4118 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4119 | if (! ret) |
| 4120 | { |
| 4121 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4122 | return CMD_WARNING; |
| 4123 | } |
| 4124 | |
| 4125 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4126 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4127 | } |
| 4128 | |
| 4129 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4130 | bgp_network_mask_natural_backdoor_cmd, |
| 4131 | "network A.B.C.D backdoor", |
| 4132 | "Specify a network to announce via BGP\n" |
| 4133 | "Network number\n" |
| 4134 | "Specify a BGP backdoor route\n") |
| 4135 | { |
| 4136 | int ret; |
| 4137 | char prefix_str[BUFSIZ]; |
| 4138 | |
| 4139 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4140 | if (! ret) |
| 4141 | { |
| 4142 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4143 | return CMD_WARNING; |
| 4144 | } |
| 4145 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4146 | 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] | 4147 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4148 | } |
| 4149 | |
| 4150 | DEFUN (no_bgp_network, |
| 4151 | no_bgp_network_cmd, |
| 4152 | "no network A.B.C.D/M", |
| 4153 | NO_STR |
| 4154 | "Specify a network to announce via BGP\n" |
| 4155 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4156 | { |
| 4157 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4158 | bgp_node_safi (vty)); |
| 4159 | } |
| 4160 | |
| 4161 | ALIAS (no_bgp_network, |
| 4162 | no_bgp_network_route_map_cmd, |
| 4163 | "no network A.B.C.D/M route-map WORD", |
| 4164 | NO_STR |
| 4165 | "Specify a network to announce via BGP\n" |
| 4166 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4167 | "Route-map to modify the attributes\n" |
| 4168 | "Name of the route map\n") |
| 4169 | |
| 4170 | ALIAS (no_bgp_network, |
| 4171 | no_bgp_network_backdoor_cmd, |
| 4172 | "no network A.B.C.D/M backdoor", |
| 4173 | NO_STR |
| 4174 | "Specify a network to announce via BGP\n" |
| 4175 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4176 | "Specify a BGP backdoor route\n") |
| 4177 | |
| 4178 | DEFUN (no_bgp_network_mask, |
| 4179 | no_bgp_network_mask_cmd, |
| 4180 | "no network A.B.C.D mask A.B.C.D", |
| 4181 | NO_STR |
| 4182 | "Specify a network to announce via BGP\n" |
| 4183 | "Network number\n" |
| 4184 | "Network mask\n" |
| 4185 | "Network mask\n") |
| 4186 | { |
| 4187 | int ret; |
| 4188 | char prefix_str[BUFSIZ]; |
| 4189 | |
| 4190 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4191 | if (! ret) |
| 4192 | { |
| 4193 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4194 | return CMD_WARNING; |
| 4195 | } |
| 4196 | |
| 4197 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4198 | bgp_node_safi (vty)); |
| 4199 | } |
| 4200 | |
| 4201 | ALIAS (no_bgp_network_mask, |
| 4202 | no_bgp_network_mask_route_map_cmd, |
| 4203 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4204 | NO_STR |
| 4205 | "Specify a network to announce via BGP\n" |
| 4206 | "Network number\n" |
| 4207 | "Network mask\n" |
| 4208 | "Network mask\n" |
| 4209 | "Route-map to modify the attributes\n" |
| 4210 | "Name of the route map\n") |
| 4211 | |
| 4212 | ALIAS (no_bgp_network_mask, |
| 4213 | no_bgp_network_mask_backdoor_cmd, |
| 4214 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4215 | NO_STR |
| 4216 | "Specify a network to announce via BGP\n" |
| 4217 | "Network number\n" |
| 4218 | "Network mask\n" |
| 4219 | "Network mask\n" |
| 4220 | "Specify a BGP backdoor route\n") |
| 4221 | |
| 4222 | DEFUN (no_bgp_network_mask_natural, |
| 4223 | no_bgp_network_mask_natural_cmd, |
| 4224 | "no network A.B.C.D", |
| 4225 | NO_STR |
| 4226 | "Specify a network to announce via BGP\n" |
| 4227 | "Network number\n") |
| 4228 | { |
| 4229 | int ret; |
| 4230 | char prefix_str[BUFSIZ]; |
| 4231 | |
| 4232 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4233 | if (! ret) |
| 4234 | { |
| 4235 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4236 | return CMD_WARNING; |
| 4237 | } |
| 4238 | |
| 4239 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4240 | bgp_node_safi (vty)); |
| 4241 | } |
| 4242 | |
| 4243 | ALIAS (no_bgp_network_mask_natural, |
| 4244 | no_bgp_network_mask_natural_route_map_cmd, |
| 4245 | "no network A.B.C.D route-map WORD", |
| 4246 | NO_STR |
| 4247 | "Specify a network to announce via BGP\n" |
| 4248 | "Network number\n" |
| 4249 | "Route-map to modify the attributes\n" |
| 4250 | "Name of the route map\n") |
| 4251 | |
| 4252 | ALIAS (no_bgp_network_mask_natural, |
| 4253 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4254 | "no network A.B.C.D backdoor", |
| 4255 | NO_STR |
| 4256 | "Specify a network to announce via BGP\n" |
| 4257 | "Network number\n" |
| 4258 | "Specify a BGP backdoor route\n") |
| 4259 | |
| 4260 | #ifdef HAVE_IPV6 |
| 4261 | DEFUN (ipv6_bgp_network, |
| 4262 | ipv6_bgp_network_cmd, |
| 4263 | "network X:X::X:X/M", |
| 4264 | "Specify a network to announce via BGP\n" |
| 4265 | "IPv6 prefix <network>/<length>\n") |
| 4266 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4267 | 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] | 4268 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4269 | } |
| 4270 | |
| 4271 | DEFUN (ipv6_bgp_network_route_map, |
| 4272 | ipv6_bgp_network_route_map_cmd, |
| 4273 | "network X:X::X:X/M route-map WORD", |
| 4274 | "Specify a network to announce via BGP\n" |
| 4275 | "IPv6 prefix <network>/<length>\n" |
| 4276 | "Route-map to modify the attributes\n" |
| 4277 | "Name of the route map\n") |
| 4278 | { |
| 4279 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4280 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4281 | } |
| 4282 | |
| 4283 | DEFUN (no_ipv6_bgp_network, |
| 4284 | no_ipv6_bgp_network_cmd, |
| 4285 | "no network X:X::X:X/M", |
| 4286 | NO_STR |
| 4287 | "Specify a network to announce via BGP\n" |
| 4288 | "IPv6 prefix <network>/<length>\n") |
| 4289 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4290 | 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] | 4291 | } |
| 4292 | |
| 4293 | ALIAS (no_ipv6_bgp_network, |
| 4294 | no_ipv6_bgp_network_route_map_cmd, |
| 4295 | "no network X:X::X:X/M route-map WORD", |
| 4296 | NO_STR |
| 4297 | "Specify a network to announce via BGP\n" |
| 4298 | "IPv6 prefix <network>/<length>\n" |
| 4299 | "Route-map to modify the attributes\n" |
| 4300 | "Name of the route map\n") |
| 4301 | |
| 4302 | ALIAS (ipv6_bgp_network, |
| 4303 | old_ipv6_bgp_network_cmd, |
| 4304 | "ipv6 bgp network X:X::X:X/M", |
| 4305 | IPV6_STR |
| 4306 | BGP_STR |
| 4307 | "Specify a network to announce via BGP\n" |
| 4308 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4309 | |
| 4310 | ALIAS (no_ipv6_bgp_network, |
| 4311 | old_no_ipv6_bgp_network_cmd, |
| 4312 | "no ipv6 bgp network X:X::X:X/M", |
| 4313 | NO_STR |
| 4314 | IPV6_STR |
| 4315 | BGP_STR |
| 4316 | "Specify a network to announce via BGP\n" |
| 4317 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4318 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4319 | |
| 4320 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4321 | ALIAS_DEPRECATED (bgp_network, |
| 4322 | bgp_network_ttl_cmd, |
| 4323 | "network A.B.C.D/M pathlimit <0-255>", |
| 4324 | "Specify a network to announce via BGP\n" |
| 4325 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4326 | "AS-Path hopcount limit attribute\n" |
| 4327 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4328 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4329 | bgp_network_backdoor_ttl_cmd, |
| 4330 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4331 | "Specify a network to announce via BGP\n" |
| 4332 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4333 | "Specify a BGP backdoor route\n" |
| 4334 | "AS-Path hopcount limit attribute\n" |
| 4335 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4336 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4337 | bgp_network_mask_ttl_cmd, |
| 4338 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4339 | "Specify a network to announce via BGP\n" |
| 4340 | "Network number\n" |
| 4341 | "Network mask\n" |
| 4342 | "Network mask\n" |
| 4343 | "AS-Path hopcount limit attribute\n" |
| 4344 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4345 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4346 | bgp_network_mask_backdoor_ttl_cmd, |
| 4347 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4348 | "Specify a network to announce via BGP\n" |
| 4349 | "Network number\n" |
| 4350 | "Network mask\n" |
| 4351 | "Network mask\n" |
| 4352 | "Specify a BGP backdoor route\n" |
| 4353 | "AS-Path hopcount limit attribute\n" |
| 4354 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4355 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4356 | bgp_network_mask_natural_ttl_cmd, |
| 4357 | "network A.B.C.D pathlimit <0-255>", |
| 4358 | "Specify a network to announce via BGP\n" |
| 4359 | "Network number\n" |
| 4360 | "AS-Path hopcount limit attribute\n" |
| 4361 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4362 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4363 | bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4364 | "network A.B.C.D backdoor pathlimit (1-255>", |
| 4365 | "Specify a network to announce via BGP\n" |
| 4366 | "Network number\n" |
| 4367 | "Specify a BGP backdoor route\n" |
| 4368 | "AS-Path hopcount limit attribute\n" |
| 4369 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4370 | ALIAS_DEPRECATED (no_bgp_network, |
| 4371 | no_bgp_network_ttl_cmd, |
| 4372 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4373 | NO_STR |
| 4374 | "Specify a network to announce via BGP\n" |
| 4375 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4376 | "AS-Path hopcount limit attribute\n" |
| 4377 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4378 | ALIAS_DEPRECATED (no_bgp_network, |
| 4379 | no_bgp_network_backdoor_ttl_cmd, |
| 4380 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4381 | NO_STR |
| 4382 | "Specify a network to announce via BGP\n" |
| 4383 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4384 | "Specify a BGP backdoor route\n" |
| 4385 | "AS-Path hopcount limit attribute\n" |
| 4386 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4387 | ALIAS_DEPRECATED (no_bgp_network, |
| 4388 | no_bgp_network_mask_ttl_cmd, |
| 4389 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4390 | NO_STR |
| 4391 | "Specify a network to announce via BGP\n" |
| 4392 | "Network number\n" |
| 4393 | "Network mask\n" |
| 4394 | "Network mask\n" |
| 4395 | "AS-Path hopcount limit attribute\n" |
| 4396 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4397 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4398 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4399 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4400 | NO_STR |
| 4401 | "Specify a network to announce via BGP\n" |
| 4402 | "Network number\n" |
| 4403 | "Network mask\n" |
| 4404 | "Network mask\n" |
| 4405 | "Specify a BGP backdoor route\n" |
| 4406 | "AS-Path hopcount limit attribute\n" |
| 4407 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4408 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4409 | no_bgp_network_mask_natural_ttl_cmd, |
| 4410 | "no network A.B.C.D pathlimit <0-255>", |
| 4411 | NO_STR |
| 4412 | "Specify a network to announce via BGP\n" |
| 4413 | "Network number\n" |
| 4414 | "AS-Path hopcount limit attribute\n" |
| 4415 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4416 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4417 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4418 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4419 | NO_STR |
| 4420 | "Specify a network to announce via BGP\n" |
| 4421 | "Network number\n" |
| 4422 | "Specify a BGP backdoor route\n" |
| 4423 | "AS-Path hopcount limit attribute\n" |
| 4424 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4425 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4426 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4427 | ipv6_bgp_network_ttl_cmd, |
| 4428 | "network X:X::X:X/M pathlimit <0-255>", |
| 4429 | "Specify a network to announce via BGP\n" |
| 4430 | "IPv6 prefix <network>/<length>\n" |
| 4431 | "AS-Path hopcount limit attribute\n" |
| 4432 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4433 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4434 | no_ipv6_bgp_network_ttl_cmd, |
| 4435 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4436 | NO_STR |
| 4437 | "Specify a network to announce via BGP\n" |
| 4438 | "IPv6 prefix <network>/<length>\n" |
| 4439 | "AS-Path hopcount limit attribute\n" |
| 4440 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4441 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4442 | |
| 4443 | /* Aggreagete address: |
| 4444 | |
| 4445 | advertise-map Set condition to advertise attribute |
| 4446 | as-set Generate AS set path information |
| 4447 | attribute-map Set attributes of aggregate |
| 4448 | route-map Set parameters of aggregate |
| 4449 | summary-only Filter more specific routes from updates |
| 4450 | suppress-map Conditionally filter more specific routes from updates |
| 4451 | <cr> |
| 4452 | */ |
| 4453 | struct bgp_aggregate |
| 4454 | { |
| 4455 | /* Summary-only flag. */ |
| 4456 | u_char summary_only; |
| 4457 | |
| 4458 | /* AS set generation. */ |
| 4459 | u_char as_set; |
| 4460 | |
| 4461 | /* Route-map for aggregated route. */ |
| 4462 | struct route_map *map; |
| 4463 | |
| 4464 | /* Suppress-count. */ |
| 4465 | unsigned long count; |
| 4466 | |
| 4467 | /* SAFI configuration. */ |
| 4468 | safi_t safi; |
| 4469 | }; |
| 4470 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4471 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4472 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4473 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4474 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4475 | } |
| 4476 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4477 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4478 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4479 | { |
| 4480 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4481 | } |
| 4482 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4483 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4484 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4485 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4486 | struct bgp_aggregate *aggregate) |
| 4487 | { |
| 4488 | struct bgp_table *table; |
| 4489 | struct bgp_node *top; |
| 4490 | struct bgp_node *rn; |
| 4491 | u_char origin; |
| 4492 | struct aspath *aspath = NULL; |
| 4493 | struct aspath *asmerge = NULL; |
| 4494 | struct community *community = NULL; |
| 4495 | struct community *commerge = NULL; |
| 4496 | struct in_addr nexthop; |
| 4497 | u_int32_t med = 0; |
| 4498 | struct bgp_info *ri; |
| 4499 | struct bgp_info *new; |
| 4500 | int first = 1; |
| 4501 | unsigned long match = 0; |
| 4502 | |
| 4503 | /* Record adding route's nexthop and med. */ |
| 4504 | if (rinew) |
| 4505 | { |
| 4506 | nexthop = rinew->attr->nexthop; |
| 4507 | med = rinew->attr->med; |
| 4508 | } |
| 4509 | |
| 4510 | /* ORIGIN attribute: If at least one route among routes that are |
| 4511 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4512 | aggregated route must have the ORIGIN attribute with the value |
| 4513 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4514 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4515 | route must have the origin attribute with the value EGP. In all |
| 4516 | other case the value of the ORIGIN attribute of the aggregated |
| 4517 | route is INTERNAL. */ |
| 4518 | origin = BGP_ORIGIN_IGP; |
| 4519 | |
| 4520 | table = bgp->rib[afi][safi]; |
| 4521 | |
| 4522 | top = bgp_node_get (table, p); |
| 4523 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4524 | if (rn->p.prefixlen > p->prefixlen) |
| 4525 | { |
| 4526 | match = 0; |
| 4527 | |
| 4528 | for (ri = rn->info; ri; ri = ri->next) |
| 4529 | { |
| 4530 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4531 | continue; |
| 4532 | |
| 4533 | if (del && ri == del) |
| 4534 | continue; |
| 4535 | |
| 4536 | if (! rinew && first) |
| 4537 | { |
| 4538 | nexthop = ri->attr->nexthop; |
| 4539 | med = ri->attr->med; |
| 4540 | first = 0; |
| 4541 | } |
| 4542 | |
| 4543 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4544 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4545 | || ri->attr->med != med) |
| 4546 | { |
| 4547 | if (aspath) |
| 4548 | aspath_free (aspath); |
| 4549 | if (community) |
| 4550 | community_free (community); |
| 4551 | bgp_unlock_node (rn); |
| 4552 | bgp_unlock_node (top); |
| 4553 | return; |
| 4554 | } |
| 4555 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4556 | |
| 4557 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4558 | { |
| 4559 | if (aggregate->summary_only) |
| 4560 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4561 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4562 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4563 | match++; |
| 4564 | } |
| 4565 | |
| 4566 | aggregate->count++; |
| 4567 | |
| 4568 | if (aggregate->as_set) |
| 4569 | { |
| 4570 | if (origin < ri->attr->origin) |
| 4571 | origin = ri->attr->origin; |
| 4572 | |
| 4573 | if (aspath) |
| 4574 | { |
| 4575 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4576 | aspath_free (aspath); |
| 4577 | aspath = asmerge; |
| 4578 | } |
| 4579 | else |
| 4580 | aspath = aspath_dup (ri->attr->aspath); |
| 4581 | |
| 4582 | if (ri->attr->community) |
| 4583 | { |
| 4584 | if (community) |
| 4585 | { |
| 4586 | commerge = community_merge (community, |
| 4587 | ri->attr->community); |
| 4588 | community = community_uniq_sort (commerge); |
| 4589 | community_free (commerge); |
| 4590 | } |
| 4591 | else |
| 4592 | community = community_dup (ri->attr->community); |
| 4593 | } |
| 4594 | } |
| 4595 | } |
| 4596 | } |
| 4597 | if (match) |
| 4598 | bgp_process (bgp, rn, afi, safi); |
| 4599 | } |
| 4600 | bgp_unlock_node (top); |
| 4601 | |
| 4602 | if (rinew) |
| 4603 | { |
| 4604 | aggregate->count++; |
| 4605 | |
| 4606 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4607 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4608 | |
| 4609 | if (aggregate->as_set) |
| 4610 | { |
| 4611 | if (origin < rinew->attr->origin) |
| 4612 | origin = rinew->attr->origin; |
| 4613 | |
| 4614 | if (aspath) |
| 4615 | { |
| 4616 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4617 | aspath_free (aspath); |
| 4618 | aspath = asmerge; |
| 4619 | } |
| 4620 | else |
| 4621 | aspath = aspath_dup (rinew->attr->aspath); |
| 4622 | |
| 4623 | if (rinew->attr->community) |
| 4624 | { |
| 4625 | if (community) |
| 4626 | { |
| 4627 | commerge = community_merge (community, |
| 4628 | rinew->attr->community); |
| 4629 | community = community_uniq_sort (commerge); |
| 4630 | community_free (commerge); |
| 4631 | } |
| 4632 | else |
| 4633 | community = community_dup (rinew->attr->community); |
| 4634 | } |
| 4635 | } |
| 4636 | } |
| 4637 | |
| 4638 | if (aggregate->count > 0) |
| 4639 | { |
| 4640 | rn = bgp_node_get (table, p); |
| 4641 | new = bgp_info_new (); |
| 4642 | new->type = ZEBRA_ROUTE_BGP; |
| 4643 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4644 | new->peer = bgp->peer_self; |
| 4645 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4646 | 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] | 4647 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4648 | |
| 4649 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4650 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4651 | bgp_process (bgp, rn, afi, safi); |
| 4652 | } |
| 4653 | else |
| 4654 | { |
| 4655 | if (aspath) |
| 4656 | aspath_free (aspath); |
| 4657 | if (community) |
| 4658 | community_free (community); |
| 4659 | } |
| 4660 | } |
| 4661 | |
| 4662 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4663 | struct bgp_aggregate *); |
| 4664 | |
| 4665 | void |
| 4666 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4667 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4668 | { |
| 4669 | struct bgp_node *child; |
| 4670 | struct bgp_node *rn; |
| 4671 | struct bgp_aggregate *aggregate; |
| 4672 | |
| 4673 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4674 | if (safi == SAFI_MPLS_VPN) |
| 4675 | return; |
| 4676 | |
| 4677 | if (p->prefixlen == 0) |
| 4678 | return; |
| 4679 | |
| 4680 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4681 | return; |
| 4682 | |
| 4683 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4684 | |
| 4685 | /* Aggregate address configuration check. */ |
| 4686 | for (rn = child; rn; rn = rn->parent) |
| 4687 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4688 | { |
| 4689 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4690 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4691 | } |
| 4692 | bgp_unlock_node (child); |
| 4693 | } |
| 4694 | |
| 4695 | void |
| 4696 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4697 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4698 | { |
| 4699 | struct bgp_node *child; |
| 4700 | struct bgp_node *rn; |
| 4701 | struct bgp_aggregate *aggregate; |
| 4702 | |
| 4703 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4704 | if (safi == SAFI_MPLS_VPN) |
| 4705 | return; |
| 4706 | |
| 4707 | if (p->prefixlen == 0) |
| 4708 | return; |
| 4709 | |
| 4710 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4711 | |
| 4712 | /* Aggregate address configuration check. */ |
| 4713 | for (rn = child; rn; rn = rn->parent) |
| 4714 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4715 | { |
| 4716 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4717 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4718 | } |
| 4719 | bgp_unlock_node (child); |
| 4720 | } |
| 4721 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4722 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4723 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4724 | struct bgp_aggregate *aggregate) |
| 4725 | { |
| 4726 | struct bgp_table *table; |
| 4727 | struct bgp_node *top; |
| 4728 | struct bgp_node *rn; |
| 4729 | struct bgp_info *new; |
| 4730 | struct bgp_info *ri; |
| 4731 | unsigned long match; |
| 4732 | u_char origin = BGP_ORIGIN_IGP; |
| 4733 | struct aspath *aspath = NULL; |
| 4734 | struct aspath *asmerge = NULL; |
| 4735 | struct community *community = NULL; |
| 4736 | struct community *commerge = NULL; |
| 4737 | |
| 4738 | table = bgp->rib[afi][safi]; |
| 4739 | |
| 4740 | /* Sanity check. */ |
| 4741 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4742 | return; |
| 4743 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4744 | return; |
| 4745 | |
| 4746 | /* If routes exists below this node, generate aggregate routes. */ |
| 4747 | top = bgp_node_get (table, p); |
| 4748 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4749 | if (rn->p.prefixlen > p->prefixlen) |
| 4750 | { |
| 4751 | match = 0; |
| 4752 | |
| 4753 | for (ri = rn->info; ri; ri = ri->next) |
| 4754 | { |
| 4755 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4756 | continue; |
| 4757 | |
| 4758 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4759 | { |
| 4760 | /* summary-only aggregate route suppress aggregated |
| 4761 | route announcement. */ |
| 4762 | if (aggregate->summary_only) |
| 4763 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4764 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4765 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4766 | match++; |
| 4767 | } |
| 4768 | /* as-set aggregate route generate origin, as path, |
| 4769 | community aggregation. */ |
| 4770 | if (aggregate->as_set) |
| 4771 | { |
| 4772 | if (origin < ri->attr->origin) |
| 4773 | origin = ri->attr->origin; |
| 4774 | |
| 4775 | if (aspath) |
| 4776 | { |
| 4777 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4778 | aspath_free (aspath); |
| 4779 | aspath = asmerge; |
| 4780 | } |
| 4781 | else |
| 4782 | aspath = aspath_dup (ri->attr->aspath); |
| 4783 | |
| 4784 | if (ri->attr->community) |
| 4785 | { |
| 4786 | if (community) |
| 4787 | { |
| 4788 | commerge = community_merge (community, |
| 4789 | ri->attr->community); |
| 4790 | community = community_uniq_sort (commerge); |
| 4791 | community_free (commerge); |
| 4792 | } |
| 4793 | else |
| 4794 | community = community_dup (ri->attr->community); |
| 4795 | } |
| 4796 | } |
| 4797 | aggregate->count++; |
| 4798 | } |
| 4799 | } |
| 4800 | |
| 4801 | /* If this node is suppressed, process the change. */ |
| 4802 | if (match) |
| 4803 | bgp_process (bgp, rn, afi, safi); |
| 4804 | } |
| 4805 | bgp_unlock_node (top); |
| 4806 | |
| 4807 | /* Add aggregate route to BGP table. */ |
| 4808 | if (aggregate->count) |
| 4809 | { |
| 4810 | rn = bgp_node_get (table, p); |
| 4811 | |
| 4812 | new = bgp_info_new (); |
| 4813 | new->type = ZEBRA_ROUTE_BGP; |
| 4814 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4815 | new->peer = bgp->peer_self; |
| 4816 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4817 | 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] | 4818 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4819 | |
| 4820 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4821 | bgp_unlock_node (rn); |
| 4822 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4823 | /* Process change. */ |
| 4824 | bgp_process (bgp, rn, afi, safi); |
| 4825 | } |
| 4826 | } |
| 4827 | |
| 4828 | void |
| 4829 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4830 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4831 | { |
| 4832 | struct bgp_table *table; |
| 4833 | struct bgp_node *top; |
| 4834 | struct bgp_node *rn; |
| 4835 | struct bgp_info *ri; |
| 4836 | unsigned long match; |
| 4837 | |
| 4838 | table = bgp->rib[afi][safi]; |
| 4839 | |
| 4840 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4841 | return; |
| 4842 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4843 | return; |
| 4844 | |
| 4845 | /* If routes exists below this node, generate aggregate routes. */ |
| 4846 | top = bgp_node_get (table, p); |
| 4847 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4848 | if (rn->p.prefixlen > p->prefixlen) |
| 4849 | { |
| 4850 | match = 0; |
| 4851 | |
| 4852 | for (ri = rn->info; ri; ri = ri->next) |
| 4853 | { |
| 4854 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4855 | continue; |
| 4856 | |
| 4857 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4858 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4859 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4860 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4861 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4862 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4863 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4864 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4865 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4866 | match++; |
| 4867 | } |
| 4868 | } |
| 4869 | aggregate->count--; |
| 4870 | } |
| 4871 | } |
| 4872 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4873 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4874 | if (match) |
| 4875 | bgp_process (bgp, rn, afi, safi); |
| 4876 | } |
| 4877 | bgp_unlock_node (top); |
| 4878 | |
| 4879 | /* Delete aggregate route from BGP table. */ |
| 4880 | rn = bgp_node_get (table, p); |
| 4881 | |
| 4882 | for (ri = rn->info; ri; ri = ri->next) |
| 4883 | if (ri->peer == bgp->peer_self |
| 4884 | && ri->type == ZEBRA_ROUTE_BGP |
| 4885 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4886 | break; |
| 4887 | |
| 4888 | /* Withdraw static BGP route from routing table. */ |
| 4889 | if (ri) |
| 4890 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4891 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4892 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4893 | } |
| 4894 | |
| 4895 | /* Unlock bgp_node_lookup. */ |
| 4896 | bgp_unlock_node (rn); |
| 4897 | } |
| 4898 | |
| 4899 | /* Aggregate route attribute. */ |
| 4900 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4901 | #define AGGREGATE_AS_SET 1 |
| 4902 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4903 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4904 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4905 | afi_t afi, safi_t safi) |
| 4906 | { |
| 4907 | int ret; |
| 4908 | struct prefix p; |
| 4909 | struct bgp_node *rn; |
| 4910 | struct bgp *bgp; |
| 4911 | struct bgp_aggregate *aggregate; |
| 4912 | |
| 4913 | /* Convert string to prefix structure. */ |
| 4914 | ret = str2prefix (prefix_str, &p); |
| 4915 | if (!ret) |
| 4916 | { |
| 4917 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4918 | return CMD_WARNING; |
| 4919 | } |
| 4920 | apply_mask (&p); |
| 4921 | |
| 4922 | /* Get BGP structure. */ |
| 4923 | bgp = vty->index; |
| 4924 | |
| 4925 | /* Old configuration check. */ |
| 4926 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4927 | if (! rn) |
| 4928 | { |
| 4929 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4930 | VTY_NEWLINE); |
| 4931 | return CMD_WARNING; |
| 4932 | } |
| 4933 | |
| 4934 | aggregate = rn->info; |
| 4935 | if (aggregate->safi & SAFI_UNICAST) |
| 4936 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4937 | if (aggregate->safi & SAFI_MULTICAST) |
| 4938 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4939 | |
| 4940 | /* Unlock aggregate address configuration. */ |
| 4941 | rn->info = NULL; |
| 4942 | bgp_aggregate_free (aggregate); |
| 4943 | bgp_unlock_node (rn); |
| 4944 | bgp_unlock_node (rn); |
| 4945 | |
| 4946 | return CMD_SUCCESS; |
| 4947 | } |
| 4948 | |
| 4949 | static int |
| 4950 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4951 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4952 | u_char summary_only, u_char as_set) |
| 4953 | { |
| 4954 | int ret; |
| 4955 | struct prefix p; |
| 4956 | struct bgp_node *rn; |
| 4957 | struct bgp *bgp; |
| 4958 | struct bgp_aggregate *aggregate; |
| 4959 | |
| 4960 | /* Convert string to prefix structure. */ |
| 4961 | ret = str2prefix (prefix_str, &p); |
| 4962 | if (!ret) |
| 4963 | { |
| 4964 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4965 | return CMD_WARNING; |
| 4966 | } |
| 4967 | apply_mask (&p); |
| 4968 | |
| 4969 | /* Get BGP structure. */ |
| 4970 | bgp = vty->index; |
| 4971 | |
| 4972 | /* Old configuration check. */ |
| 4973 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4974 | |
| 4975 | if (rn->info) |
| 4976 | { |
| 4977 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4978 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4979 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 4980 | if (ret) |
| 4981 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4982 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 4983 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4984 | return CMD_WARNING; |
| 4985 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4986 | } |
| 4987 | |
| 4988 | /* Make aggregate address structure. */ |
| 4989 | aggregate = bgp_aggregate_new (); |
| 4990 | aggregate->summary_only = summary_only; |
| 4991 | aggregate->as_set = as_set; |
| 4992 | aggregate->safi = safi; |
| 4993 | rn->info = aggregate; |
| 4994 | |
| 4995 | /* Aggregate address insert into BGP routing table. */ |
| 4996 | if (safi & SAFI_UNICAST) |
| 4997 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4998 | if (safi & SAFI_MULTICAST) |
| 4999 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5000 | |
| 5001 | return CMD_SUCCESS; |
| 5002 | } |
| 5003 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5004 | DEFUN (aggregate_address, |
| 5005 | aggregate_address_cmd, |
| 5006 | "aggregate-address A.B.C.D/M", |
| 5007 | "Configure BGP aggregate entries\n" |
| 5008 | "Aggregate prefix\n") |
| 5009 | { |
| 5010 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5011 | } |
| 5012 | |
| 5013 | DEFUN (aggregate_address_mask, |
| 5014 | aggregate_address_mask_cmd, |
| 5015 | "aggregate-address A.B.C.D A.B.C.D", |
| 5016 | "Configure BGP aggregate entries\n" |
| 5017 | "Aggregate address\n" |
| 5018 | "Aggregate mask\n") |
| 5019 | { |
| 5020 | int ret; |
| 5021 | char prefix_str[BUFSIZ]; |
| 5022 | |
| 5023 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5024 | |
| 5025 | if (! ret) |
| 5026 | { |
| 5027 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5028 | return CMD_WARNING; |
| 5029 | } |
| 5030 | |
| 5031 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5032 | 0, 0); |
| 5033 | } |
| 5034 | |
| 5035 | DEFUN (aggregate_address_summary_only, |
| 5036 | aggregate_address_summary_only_cmd, |
| 5037 | "aggregate-address A.B.C.D/M summary-only", |
| 5038 | "Configure BGP aggregate entries\n" |
| 5039 | "Aggregate prefix\n" |
| 5040 | "Filter more specific routes from updates\n") |
| 5041 | { |
| 5042 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5043 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5044 | } |
| 5045 | |
| 5046 | DEFUN (aggregate_address_mask_summary_only, |
| 5047 | aggregate_address_mask_summary_only_cmd, |
| 5048 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5049 | "Configure BGP aggregate entries\n" |
| 5050 | "Aggregate address\n" |
| 5051 | "Aggregate mask\n" |
| 5052 | "Filter more specific routes from updates\n") |
| 5053 | { |
| 5054 | int ret; |
| 5055 | char prefix_str[BUFSIZ]; |
| 5056 | |
| 5057 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5058 | |
| 5059 | if (! ret) |
| 5060 | { |
| 5061 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5062 | return CMD_WARNING; |
| 5063 | } |
| 5064 | |
| 5065 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5066 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5067 | } |
| 5068 | |
| 5069 | DEFUN (aggregate_address_as_set, |
| 5070 | aggregate_address_as_set_cmd, |
| 5071 | "aggregate-address A.B.C.D/M as-set", |
| 5072 | "Configure BGP aggregate entries\n" |
| 5073 | "Aggregate prefix\n" |
| 5074 | "Generate AS set path information\n") |
| 5075 | { |
| 5076 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5077 | 0, AGGREGATE_AS_SET); |
| 5078 | } |
| 5079 | |
| 5080 | DEFUN (aggregate_address_mask_as_set, |
| 5081 | aggregate_address_mask_as_set_cmd, |
| 5082 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5083 | "Configure BGP aggregate entries\n" |
| 5084 | "Aggregate address\n" |
| 5085 | "Aggregate mask\n" |
| 5086 | "Generate AS set path information\n") |
| 5087 | { |
| 5088 | int ret; |
| 5089 | char prefix_str[BUFSIZ]; |
| 5090 | |
| 5091 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5092 | |
| 5093 | if (! ret) |
| 5094 | { |
| 5095 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5096 | return CMD_WARNING; |
| 5097 | } |
| 5098 | |
| 5099 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5100 | 0, AGGREGATE_AS_SET); |
| 5101 | } |
| 5102 | |
| 5103 | |
| 5104 | DEFUN (aggregate_address_as_set_summary, |
| 5105 | aggregate_address_as_set_summary_cmd, |
| 5106 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5107 | "Configure BGP aggregate entries\n" |
| 5108 | "Aggregate prefix\n" |
| 5109 | "Generate AS set path information\n" |
| 5110 | "Filter more specific routes from updates\n") |
| 5111 | { |
| 5112 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5113 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5114 | } |
| 5115 | |
| 5116 | ALIAS (aggregate_address_as_set_summary, |
| 5117 | aggregate_address_summary_as_set_cmd, |
| 5118 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5119 | "Configure BGP aggregate entries\n" |
| 5120 | "Aggregate prefix\n" |
| 5121 | "Filter more specific routes from updates\n" |
| 5122 | "Generate AS set path information\n") |
| 5123 | |
| 5124 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5125 | aggregate_address_mask_as_set_summary_cmd, |
| 5126 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5127 | "Configure BGP aggregate entries\n" |
| 5128 | "Aggregate address\n" |
| 5129 | "Aggregate mask\n" |
| 5130 | "Generate AS set path information\n" |
| 5131 | "Filter more specific routes from updates\n") |
| 5132 | { |
| 5133 | int ret; |
| 5134 | char prefix_str[BUFSIZ]; |
| 5135 | |
| 5136 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5137 | |
| 5138 | if (! ret) |
| 5139 | { |
| 5140 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5141 | return CMD_WARNING; |
| 5142 | } |
| 5143 | |
| 5144 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5145 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5146 | } |
| 5147 | |
| 5148 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5149 | aggregate_address_mask_summary_as_set_cmd, |
| 5150 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5151 | "Configure BGP aggregate entries\n" |
| 5152 | "Aggregate address\n" |
| 5153 | "Aggregate mask\n" |
| 5154 | "Filter more specific routes from updates\n" |
| 5155 | "Generate AS set path information\n") |
| 5156 | |
| 5157 | DEFUN (no_aggregate_address, |
| 5158 | no_aggregate_address_cmd, |
| 5159 | "no aggregate-address A.B.C.D/M", |
| 5160 | NO_STR |
| 5161 | "Configure BGP aggregate entries\n" |
| 5162 | "Aggregate prefix\n") |
| 5163 | { |
| 5164 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5165 | } |
| 5166 | |
| 5167 | ALIAS (no_aggregate_address, |
| 5168 | no_aggregate_address_summary_only_cmd, |
| 5169 | "no aggregate-address A.B.C.D/M summary-only", |
| 5170 | NO_STR |
| 5171 | "Configure BGP aggregate entries\n" |
| 5172 | "Aggregate prefix\n" |
| 5173 | "Filter more specific routes from updates\n") |
| 5174 | |
| 5175 | ALIAS (no_aggregate_address, |
| 5176 | no_aggregate_address_as_set_cmd, |
| 5177 | "no aggregate-address A.B.C.D/M as-set", |
| 5178 | NO_STR |
| 5179 | "Configure BGP aggregate entries\n" |
| 5180 | "Aggregate prefix\n" |
| 5181 | "Generate AS set path information\n") |
| 5182 | |
| 5183 | ALIAS (no_aggregate_address, |
| 5184 | no_aggregate_address_as_set_summary_cmd, |
| 5185 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5186 | NO_STR |
| 5187 | "Configure BGP aggregate entries\n" |
| 5188 | "Aggregate prefix\n" |
| 5189 | "Generate AS set path information\n" |
| 5190 | "Filter more specific routes from updates\n") |
| 5191 | |
| 5192 | ALIAS (no_aggregate_address, |
| 5193 | no_aggregate_address_summary_as_set_cmd, |
| 5194 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5195 | NO_STR |
| 5196 | "Configure BGP aggregate entries\n" |
| 5197 | "Aggregate prefix\n" |
| 5198 | "Filter more specific routes from updates\n" |
| 5199 | "Generate AS set path information\n") |
| 5200 | |
| 5201 | DEFUN (no_aggregate_address_mask, |
| 5202 | no_aggregate_address_mask_cmd, |
| 5203 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5204 | NO_STR |
| 5205 | "Configure BGP aggregate entries\n" |
| 5206 | "Aggregate address\n" |
| 5207 | "Aggregate mask\n") |
| 5208 | { |
| 5209 | int ret; |
| 5210 | char prefix_str[BUFSIZ]; |
| 5211 | |
| 5212 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5213 | |
| 5214 | if (! ret) |
| 5215 | { |
| 5216 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5217 | return CMD_WARNING; |
| 5218 | } |
| 5219 | |
| 5220 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5221 | } |
| 5222 | |
| 5223 | ALIAS (no_aggregate_address_mask, |
| 5224 | no_aggregate_address_mask_summary_only_cmd, |
| 5225 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5226 | NO_STR |
| 5227 | "Configure BGP aggregate entries\n" |
| 5228 | "Aggregate address\n" |
| 5229 | "Aggregate mask\n" |
| 5230 | "Filter more specific routes from updates\n") |
| 5231 | |
| 5232 | ALIAS (no_aggregate_address_mask, |
| 5233 | no_aggregate_address_mask_as_set_cmd, |
| 5234 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5235 | NO_STR |
| 5236 | "Configure BGP aggregate entries\n" |
| 5237 | "Aggregate address\n" |
| 5238 | "Aggregate mask\n" |
| 5239 | "Generate AS set path information\n") |
| 5240 | |
| 5241 | ALIAS (no_aggregate_address_mask, |
| 5242 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5243 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5244 | NO_STR |
| 5245 | "Configure BGP aggregate entries\n" |
| 5246 | "Aggregate address\n" |
| 5247 | "Aggregate mask\n" |
| 5248 | "Generate AS set path information\n" |
| 5249 | "Filter more specific routes from updates\n") |
| 5250 | |
| 5251 | ALIAS (no_aggregate_address_mask, |
| 5252 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5253 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5254 | NO_STR |
| 5255 | "Configure BGP aggregate entries\n" |
| 5256 | "Aggregate address\n" |
| 5257 | "Aggregate mask\n" |
| 5258 | "Filter more specific routes from updates\n" |
| 5259 | "Generate AS set path information\n") |
| 5260 | |
| 5261 | #ifdef HAVE_IPV6 |
| 5262 | DEFUN (ipv6_aggregate_address, |
| 5263 | ipv6_aggregate_address_cmd, |
| 5264 | "aggregate-address X:X::X:X/M", |
| 5265 | "Configure BGP aggregate entries\n" |
| 5266 | "Aggregate prefix\n") |
| 5267 | { |
| 5268 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5269 | } |
| 5270 | |
| 5271 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5272 | ipv6_aggregate_address_summary_only_cmd, |
| 5273 | "aggregate-address X:X::X:X/M summary-only", |
| 5274 | "Configure BGP aggregate entries\n" |
| 5275 | "Aggregate prefix\n" |
| 5276 | "Filter more specific routes from updates\n") |
| 5277 | { |
| 5278 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5279 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5280 | } |
| 5281 | |
| 5282 | DEFUN (no_ipv6_aggregate_address, |
| 5283 | no_ipv6_aggregate_address_cmd, |
| 5284 | "no aggregate-address X:X::X:X/M", |
| 5285 | NO_STR |
| 5286 | "Configure BGP aggregate entries\n" |
| 5287 | "Aggregate prefix\n") |
| 5288 | { |
| 5289 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5290 | } |
| 5291 | |
| 5292 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5293 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5294 | "no aggregate-address X:X::X:X/M summary-only", |
| 5295 | NO_STR |
| 5296 | "Configure BGP aggregate entries\n" |
| 5297 | "Aggregate prefix\n" |
| 5298 | "Filter more specific routes from updates\n") |
| 5299 | { |
| 5300 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5301 | } |
| 5302 | |
| 5303 | ALIAS (ipv6_aggregate_address, |
| 5304 | old_ipv6_aggregate_address_cmd, |
| 5305 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5306 | IPV6_STR |
| 5307 | BGP_STR |
| 5308 | "Configure BGP aggregate entries\n" |
| 5309 | "Aggregate prefix\n") |
| 5310 | |
| 5311 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5312 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5313 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5314 | IPV6_STR |
| 5315 | BGP_STR |
| 5316 | "Configure BGP aggregate entries\n" |
| 5317 | "Aggregate prefix\n" |
| 5318 | "Filter more specific routes from updates\n") |
| 5319 | |
| 5320 | ALIAS (no_ipv6_aggregate_address, |
| 5321 | old_no_ipv6_aggregate_address_cmd, |
| 5322 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5323 | NO_STR |
| 5324 | IPV6_STR |
| 5325 | BGP_STR |
| 5326 | "Configure BGP aggregate entries\n" |
| 5327 | "Aggregate prefix\n") |
| 5328 | |
| 5329 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5330 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5331 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5332 | NO_STR |
| 5333 | IPV6_STR |
| 5334 | BGP_STR |
| 5335 | "Configure BGP aggregate entries\n" |
| 5336 | "Aggregate prefix\n" |
| 5337 | "Filter more specific routes from updates\n") |
| 5338 | #endif /* HAVE_IPV6 */ |
| 5339 | |
| 5340 | /* Redistribute route treatment. */ |
| 5341 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5342 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5343 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5344 | u_int32_t metric, u_char type) |
| 5345 | { |
| 5346 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5347 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5348 | struct bgp_info *new; |
| 5349 | struct bgp_info *bi; |
| 5350 | struct bgp_info info; |
| 5351 | struct bgp_node *bn; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5352 | struct attr attr = { 0 }; |
| 5353 | struct attr attr_new = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5354 | struct attr *new_attr; |
| 5355 | afi_t afi; |
| 5356 | int ret; |
| 5357 | |
| 5358 | /* Make default attribute. */ |
| 5359 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5360 | if (nexthop) |
| 5361 | attr.nexthop = *nexthop; |
| 5362 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5363 | #ifdef HAVE_IPV6 |
| 5364 | if (nexthop6) |
| 5365 | { |
| 5366 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5367 | extra->mp_nexthop_global = *nexthop6; |
| 5368 | extra->mp_nexthop_len = 16; |
| 5369 | } |
| 5370 | #endif |
| 5371 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5372 | attr.med = metric; |
| 5373 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5374 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5375 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5376 | { |
| 5377 | afi = family2afi (p->family); |
| 5378 | |
| 5379 | if (bgp->redist[afi][type]) |
| 5380 | { |
| 5381 | /* Copy attribute for modification. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5382 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5383 | |
| 5384 | if (bgp->redist_metric_flag[afi][type]) |
| 5385 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5386 | |
| 5387 | /* Apply route-map. */ |
| 5388 | if (bgp->rmap[afi][type].map) |
| 5389 | { |
| 5390 | info.peer = bgp->peer_self; |
| 5391 | info.attr = &attr_new; |
| 5392 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5393 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5394 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5395 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5396 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5397 | |
| 5398 | bgp->peer_self->rmap_type = 0; |
| 5399 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5400 | if (ret == RMAP_DENYMATCH) |
| 5401 | { |
| 5402 | /* Free uninterned attribute. */ |
| 5403 | bgp_attr_flush (&attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5404 | bgp_attr_extra_free (&attr_new); |
| 5405 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5406 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5407 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5408 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5409 | bgp_redistribute_delete (p, type); |
| 5410 | return; |
| 5411 | } |
| 5412 | } |
| 5413 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5414 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5415 | afi, SAFI_UNICAST, p, NULL); |
| 5416 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5417 | new_attr = bgp_attr_intern (&attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5418 | bgp_attr_extra_free (&attr_new); |
| 5419 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5420 | for (bi = bn->info; bi; bi = bi->next) |
| 5421 | if (bi->peer == bgp->peer_self |
| 5422 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5423 | break; |
| 5424 | |
| 5425 | if (bi) |
| 5426 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5427 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5428 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5429 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5430 | bgp_attr_unintern (&new_attr); |
| 5431 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5432 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5433 | bgp_unlock_node (bn); |
| 5434 | return; |
| 5435 | } |
| 5436 | else |
| 5437 | { |
| 5438 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5439 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5440 | |
| 5441 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5442 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5443 | bgp_info_restore(bn, bi); |
| 5444 | else |
| 5445 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5446 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5447 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5448 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5449 | |
| 5450 | /* Process change. */ |
| 5451 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5452 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5453 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5454 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5455 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5456 | return; |
| 5457 | } |
| 5458 | } |
| 5459 | |
| 5460 | new = bgp_info_new (); |
| 5461 | new->type = type; |
| 5462 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5463 | new->peer = bgp->peer_self; |
| 5464 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5465 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5466 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5467 | |
| 5468 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5469 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5470 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5471 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5472 | } |
| 5473 | } |
| 5474 | |
| 5475 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5476 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5477 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5478 | } |
| 5479 | |
| 5480 | void |
| 5481 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5482 | { |
| 5483 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5484 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5485 | afi_t afi; |
| 5486 | struct bgp_node *rn; |
| 5487 | struct bgp_info *ri; |
| 5488 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5489 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5490 | { |
| 5491 | afi = family2afi (p->family); |
| 5492 | |
| 5493 | if (bgp->redist[afi][type]) |
| 5494 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5495 | 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] | 5496 | |
| 5497 | for (ri = rn->info; ri; ri = ri->next) |
| 5498 | if (ri->peer == bgp->peer_self |
| 5499 | && ri->type == type) |
| 5500 | break; |
| 5501 | |
| 5502 | if (ri) |
| 5503 | { |
| 5504 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5505 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5506 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5507 | } |
| 5508 | bgp_unlock_node (rn); |
| 5509 | } |
| 5510 | } |
| 5511 | } |
| 5512 | |
| 5513 | /* Withdraw specified route type's route. */ |
| 5514 | void |
| 5515 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5516 | { |
| 5517 | struct bgp_node *rn; |
| 5518 | struct bgp_info *ri; |
| 5519 | struct bgp_table *table; |
| 5520 | |
| 5521 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5522 | |
| 5523 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5524 | { |
| 5525 | for (ri = rn->info; ri; ri = ri->next) |
| 5526 | if (ri->peer == bgp->peer_self |
| 5527 | && ri->type == type) |
| 5528 | break; |
| 5529 | |
| 5530 | if (ri) |
| 5531 | { |
| 5532 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5533 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5534 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5535 | } |
| 5536 | } |
| 5537 | } |
| 5538 | |
| 5539 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5540 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5541 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5542 | { |
| 5543 | int len; |
| 5544 | u_int32_t destination; |
| 5545 | char buf[BUFSIZ]; |
| 5546 | |
| 5547 | if (p->family == AF_INET) |
| 5548 | { |
| 5549 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5550 | destination = ntohl (p->u.prefix4.s_addr); |
| 5551 | |
| 5552 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5553 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5554 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5555 | || p->u.prefix4.s_addr == 0) |
| 5556 | { |
| 5557 | /* When mask is natural, mask is not displayed. */ |
| 5558 | } |
| 5559 | else |
| 5560 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5561 | } |
| 5562 | else |
| 5563 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5564 | p->prefixlen); |
| 5565 | |
| 5566 | len = 17 - len; |
| 5567 | if (len < 1) |
| 5568 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5569 | else |
| 5570 | vty_out (vty, "%*s", len, " "); |
| 5571 | } |
| 5572 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5573 | enum bgp_display_type |
| 5574 | { |
| 5575 | normal_list, |
| 5576 | }; |
| 5577 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5578 | /* Print the short form route status for a bgp_info */ |
| 5579 | static void |
| 5580 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5581 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5582 | /* Route status display. */ |
| 5583 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5584 | vty_out (vty, "R"); |
| 5585 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5586 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5587 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5588 | vty_out (vty, "s"); |
| 5589 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5590 | vty_out (vty, "*"); |
| 5591 | else |
| 5592 | vty_out (vty, " "); |
| 5593 | |
| 5594 | /* Selected */ |
| 5595 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5596 | vty_out (vty, "h"); |
| 5597 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5598 | vty_out (vty, "d"); |
| 5599 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5600 | vty_out (vty, ">"); |
| 5601 | else |
| 5602 | vty_out (vty, " "); |
| 5603 | |
| 5604 | /* Internal route. */ |
| 5605 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5606 | vty_out (vty, "i"); |
| 5607 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5608 | vty_out (vty, " "); |
| 5609 | } |
| 5610 | |
| 5611 | /* called from terminal list command */ |
| 5612 | void |
| 5613 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5614 | struct bgp_info *binfo, int display, safi_t safi) |
| 5615 | { |
| 5616 | struct attr *attr; |
| 5617 | |
| 5618 | /* short status lead text */ |
| 5619 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5620 | |
| 5621 | /* print prefix and mask */ |
| 5622 | if (! display) |
| 5623 | route_vty_out_route (p, vty); |
| 5624 | else |
| 5625 | vty_out (vty, "%*s", 17, " "); |
| 5626 | |
| 5627 | /* Print attribute */ |
| 5628 | attr = binfo->attr; |
| 5629 | if (attr) |
| 5630 | { |
| 5631 | if (p->family == AF_INET) |
| 5632 | { |
| 5633 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5634 | vty_out (vty, "%-16s", |
| 5635 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5636 | else |
| 5637 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5638 | } |
| 5639 | #ifdef HAVE_IPV6 |
| 5640 | else if (p->family == AF_INET6) |
| 5641 | { |
| 5642 | int len; |
| 5643 | char buf[BUFSIZ]; |
| 5644 | |
| 5645 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5646 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5647 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5648 | len = 16 - len; |
| 5649 | if (len < 1) |
| 5650 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5651 | else |
| 5652 | vty_out (vty, "%*s", len, " "); |
| 5653 | } |
| 5654 | #endif /* HAVE_IPV6 */ |
| 5655 | |
| 5656 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5657 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5658 | else |
| 5659 | vty_out (vty, " "); |
| 5660 | |
| 5661 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5662 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5663 | else |
| 5664 | vty_out (vty, " "); |
| 5665 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5666 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5667 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5668 | /* Print aspath */ |
| 5669 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5670 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5671 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5672 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5673 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5674 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5675 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5676 | } |
| 5677 | |
| 5678 | /* called from terminal list command */ |
| 5679 | void |
| 5680 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5681 | struct attr *attr, safi_t safi) |
| 5682 | { |
| 5683 | /* Route status display. */ |
| 5684 | vty_out (vty, "*"); |
| 5685 | vty_out (vty, ">"); |
| 5686 | vty_out (vty, " "); |
| 5687 | |
| 5688 | /* print prefix and mask */ |
| 5689 | route_vty_out_route (p, vty); |
| 5690 | |
| 5691 | /* Print attribute */ |
| 5692 | if (attr) |
| 5693 | { |
| 5694 | if (p->family == AF_INET) |
| 5695 | { |
| 5696 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5697 | vty_out (vty, "%-16s", |
| 5698 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5699 | else |
| 5700 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5701 | } |
| 5702 | #ifdef HAVE_IPV6 |
| 5703 | else if (p->family == AF_INET6) |
| 5704 | { |
| 5705 | int len; |
| 5706 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5707 | |
| 5708 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5709 | |
| 5710 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5711 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5712 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5713 | len = 16 - len; |
| 5714 | if (len < 1) |
| 5715 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5716 | else |
| 5717 | vty_out (vty, "%*s", len, " "); |
| 5718 | } |
| 5719 | #endif /* HAVE_IPV6 */ |
| 5720 | |
| 5721 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5722 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5723 | else |
| 5724 | vty_out (vty, " "); |
| 5725 | |
| 5726 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5727 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5728 | else |
| 5729 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5730 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5731 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5732 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5733 | /* Print aspath */ |
| 5734 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5735 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5736 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5737 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5738 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5739 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5740 | |
| 5741 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5742 | } |
| 5743 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5744 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5745 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5746 | struct bgp_info *binfo, int display, safi_t safi) |
| 5747 | { |
| 5748 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5749 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5750 | |
| 5751 | if (!binfo->extra) |
| 5752 | return; |
| 5753 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5754 | /* short status lead text */ |
| 5755 | route_vty_short_status_out (vty, binfo); |
| 5756 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5757 | /* print prefix and mask */ |
| 5758 | if (! display) |
| 5759 | route_vty_out_route (p, vty); |
| 5760 | else |
| 5761 | vty_out (vty, "%*s", 17, " "); |
| 5762 | |
| 5763 | /* Print attribute */ |
| 5764 | attr = binfo->attr; |
| 5765 | if (attr) |
| 5766 | { |
| 5767 | if (p->family == AF_INET) |
| 5768 | { |
| 5769 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5770 | vty_out (vty, "%-16s", |
| 5771 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5772 | else |
| 5773 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5774 | } |
| 5775 | #ifdef HAVE_IPV6 |
| 5776 | else if (p->family == AF_INET6) |
| 5777 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5778 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5779 | char buf[BUFSIZ]; |
| 5780 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5781 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5782 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5783 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5784 | buf, BUFSIZ)); |
| 5785 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5786 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5787 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5788 | buf, BUFSIZ), |
| 5789 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5790 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5791 | |
| 5792 | } |
| 5793 | #endif /* HAVE_IPV6 */ |
| 5794 | } |
| 5795 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5796 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5797 | |
| 5798 | vty_out (vty, "notag/%d", label); |
| 5799 | |
| 5800 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5801 | } |
| 5802 | |
| 5803 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5804 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5805 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5806 | struct bgp_info *binfo, int display, safi_t safi) |
| 5807 | { |
| 5808 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5809 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5810 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5811 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5812 | /* short status lead text */ |
| 5813 | route_vty_short_status_out (vty, binfo); |
| 5814 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5815 | /* print prefix and mask */ |
| 5816 | if (! display) |
| 5817 | route_vty_out_route (p, vty); |
| 5818 | else |
| 5819 | vty_out (vty, "%*s", 17, " "); |
| 5820 | |
| 5821 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5822 | len = 17 - len; |
| 5823 | if (len < 1) |
| 5824 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5825 | else |
| 5826 | vty_out (vty, "%*s", len, " "); |
| 5827 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5828 | 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] | 5829 | |
| 5830 | /* Print attribute */ |
| 5831 | attr = binfo->attr; |
| 5832 | if (attr) |
| 5833 | { |
| 5834 | /* Print aspath */ |
| 5835 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5836 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5837 | |
| 5838 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5839 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5840 | } |
| 5841 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5842 | } |
| 5843 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5844 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5845 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5846 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5847 | struct bgp_info *binfo, int display, safi_t safi) |
| 5848 | { |
| 5849 | struct attr *attr; |
| 5850 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5851 | char timebuf[BGP_UPTIME_LEN]; |
| 5852 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5853 | |
| 5854 | if (!binfo->extra) |
| 5855 | return; |
| 5856 | |
| 5857 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5858 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5859 | /* short status lead text */ |
| 5860 | route_vty_short_status_out (vty, binfo); |
| 5861 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5862 | /* print prefix and mask */ |
| 5863 | if (! display) |
| 5864 | route_vty_out_route (p, vty); |
| 5865 | else |
| 5866 | vty_out (vty, "%*s", 17, " "); |
| 5867 | |
| 5868 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5869 | len = 16 - len; |
| 5870 | if (len < 1) |
| 5871 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5872 | else |
| 5873 | vty_out (vty, "%*s", len, " "); |
| 5874 | |
| 5875 | len = vty_out (vty, "%d", bdi->flap); |
| 5876 | len = 5 - len; |
| 5877 | if (len < 1) |
| 5878 | vty_out (vty, " "); |
| 5879 | else |
| 5880 | vty_out (vty, "%*s ", len, " "); |
| 5881 | |
| 5882 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5883 | timebuf, BGP_UPTIME_LEN)); |
| 5884 | |
| 5885 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5886 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5887 | 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] | 5888 | else |
| 5889 | vty_out (vty, "%*s ", 8, " "); |
| 5890 | |
| 5891 | /* Print attribute */ |
| 5892 | attr = binfo->attr; |
| 5893 | if (attr) |
| 5894 | { |
| 5895 | /* Print aspath */ |
| 5896 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5897 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5898 | |
| 5899 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5900 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5901 | } |
| 5902 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5903 | } |
| 5904 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5905 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5906 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5907 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5908 | { |
| 5909 | char buf[INET6_ADDRSTRLEN]; |
| 5910 | char buf1[BUFSIZ]; |
| 5911 | struct attr *attr; |
| 5912 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5913 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5914 | time_t tbuf; |
| 5915 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5916 | |
| 5917 | attr = binfo->attr; |
| 5918 | |
| 5919 | if (attr) |
| 5920 | { |
| 5921 | /* Line1 display AS-path, Aggregator */ |
| 5922 | if (attr->aspath) |
| 5923 | { |
| 5924 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5925 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | vty_out (vty, "Local"); |
| 5927 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5928 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5929 | } |
| 5930 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5931 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5932 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5933 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5934 | vty_out (vty, ", (stale)"); |
| 5935 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 5936 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5937 | attr->extra->aggregator_as, |
| 5938 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5939 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5940 | vty_out (vty, ", (Received from a RR-client)"); |
| 5941 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5942 | vty_out (vty, ", (Received from a RS-client)"); |
| 5943 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5944 | vty_out (vty, ", (history entry)"); |
| 5945 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5946 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5947 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5948 | |
| 5949 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5950 | if (p->family == AF_INET) |
| 5951 | { |
| 5952 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5953 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5954 | inet_ntoa (attr->nexthop)); |
| 5955 | } |
| 5956 | #ifdef HAVE_IPV6 |
| 5957 | else |
| 5958 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5959 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5960 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5961 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5962 | buf, INET6_ADDRSTRLEN)); |
| 5963 | } |
| 5964 | #endif /* HAVE_IPV6 */ |
| 5965 | |
| 5966 | if (binfo->peer == bgp->peer_self) |
| 5967 | { |
| 5968 | vty_out (vty, " from %s ", |
| 5969 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5970 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5971 | } |
| 5972 | else |
| 5973 | { |
| 5974 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5975 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5976 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 5977 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5978 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5979 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5980 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5981 | else |
| 5982 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5983 | } |
| 5984 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5985 | |
| 5986 | #ifdef HAVE_IPV6 |
| 5987 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5988 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5989 | { |
| 5990 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5991 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5992 | buf, INET6_ADDRSTRLEN), |
| 5993 | VTY_NEWLINE); |
| 5994 | } |
| 5995 | #endif /* HAVE_IPV6 */ |
| 5996 | |
| 5997 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5998 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5999 | |
| 6000 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6001 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6002 | |
| 6003 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6004 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6005 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6006 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6007 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6008 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6009 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6010 | |
| 6011 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6012 | vty_out (vty, ", valid"); |
| 6013 | |
| 6014 | if (binfo->peer != bgp->peer_self) |
| 6015 | { |
| 6016 | if (binfo->peer->as == binfo->peer->local_as) |
| 6017 | vty_out (vty, ", internal"); |
| 6018 | else |
| 6019 | vty_out (vty, ", %s", |
| 6020 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6021 | } |
| 6022 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6023 | vty_out (vty, ", aggregated, local"); |
| 6024 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6025 | vty_out (vty, ", sourced"); |
| 6026 | else |
| 6027 | vty_out (vty, ", sourced, local"); |
| 6028 | |
| 6029 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6030 | vty_out (vty, ", atomic-aggregate"); |
| 6031 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6032 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6033 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6034 | bgp_info_mpath_count (binfo))) |
| 6035 | vty_out (vty, ", multipath"); |
| 6036 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6038 | vty_out (vty, ", best"); |
| 6039 | |
| 6040 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6041 | |
| 6042 | /* Line 4 display Community */ |
| 6043 | if (attr->community) |
| 6044 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6045 | VTY_NEWLINE); |
| 6046 | |
| 6047 | /* Line 5 display Extended-community */ |
| 6048 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6049 | vty_out (vty, " Extended Community: %s%s", |
| 6050 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6051 | |
| 6052 | /* Line 6 display Originator, Cluster-id */ |
| 6053 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6054 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6055 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6056 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6057 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6058 | vty_out (vty, " Originator: %s", |
| 6059 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6060 | |
| 6061 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6062 | { |
| 6063 | int i; |
| 6064 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6065 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6066 | vty_out (vty, "%s ", |
| 6067 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6068 | } |
| 6069 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6070 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6071 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6072 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6073 | bgp_damp_info_vty (vty, binfo); |
| 6074 | |
| 6075 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6076 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6077 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6078 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6079 | #else |
| 6080 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6081 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6082 | } |
| 6083 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6084 | } |
| 6085 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6086 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6087 | #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] | 6088 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6089 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6090 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6091 | |
| 6092 | enum bgp_show_type |
| 6093 | { |
| 6094 | bgp_show_type_normal, |
| 6095 | bgp_show_type_regexp, |
| 6096 | bgp_show_type_prefix_list, |
| 6097 | bgp_show_type_filter_list, |
| 6098 | bgp_show_type_route_map, |
| 6099 | bgp_show_type_neighbor, |
| 6100 | bgp_show_type_cidr_only, |
| 6101 | bgp_show_type_prefix_longer, |
| 6102 | bgp_show_type_community_all, |
| 6103 | bgp_show_type_community, |
| 6104 | bgp_show_type_community_exact, |
| 6105 | bgp_show_type_community_list, |
| 6106 | bgp_show_type_community_list_exact, |
| 6107 | bgp_show_type_flap_statistics, |
| 6108 | bgp_show_type_flap_address, |
| 6109 | bgp_show_type_flap_prefix, |
| 6110 | bgp_show_type_flap_cidr_only, |
| 6111 | bgp_show_type_flap_regexp, |
| 6112 | bgp_show_type_flap_filter_list, |
| 6113 | bgp_show_type_flap_prefix_list, |
| 6114 | bgp_show_type_flap_prefix_longer, |
| 6115 | bgp_show_type_flap_route_map, |
| 6116 | bgp_show_type_flap_neighbor, |
| 6117 | bgp_show_type_dampend_paths, |
| 6118 | bgp_show_type_damp_neighbor |
| 6119 | }; |
| 6120 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6121 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6122 | 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] | 6123 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6124 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6125 | struct bgp_info *ri; |
| 6126 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6127 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6128 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6129 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6130 | |
| 6131 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6132 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6133 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6134 | /* Start processing of routes. */ |
| 6135 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6136 | if (rn->info != NULL) |
| 6137 | { |
| 6138 | display = 0; |
| 6139 | |
| 6140 | for (ri = rn->info; ri; ri = ri->next) |
| 6141 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6142 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6143 | || type == bgp_show_type_flap_address |
| 6144 | || type == bgp_show_type_flap_prefix |
| 6145 | || type == bgp_show_type_flap_cidr_only |
| 6146 | || type == bgp_show_type_flap_regexp |
| 6147 | || type == bgp_show_type_flap_filter_list |
| 6148 | || type == bgp_show_type_flap_prefix_list |
| 6149 | || type == bgp_show_type_flap_prefix_longer |
| 6150 | || type == bgp_show_type_flap_route_map |
| 6151 | || type == bgp_show_type_flap_neighbor |
| 6152 | || type == bgp_show_type_dampend_paths |
| 6153 | || type == bgp_show_type_damp_neighbor) |
| 6154 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6155 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6156 | continue; |
| 6157 | } |
| 6158 | if (type == bgp_show_type_regexp |
| 6159 | || type == bgp_show_type_flap_regexp) |
| 6160 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6161 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6162 | |
| 6163 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6164 | continue; |
| 6165 | } |
| 6166 | if (type == bgp_show_type_prefix_list |
| 6167 | || type == bgp_show_type_flap_prefix_list) |
| 6168 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6169 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6170 | |
| 6171 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6172 | continue; |
| 6173 | } |
| 6174 | if (type == bgp_show_type_filter_list |
| 6175 | || type == bgp_show_type_flap_filter_list) |
| 6176 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6177 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6178 | |
| 6179 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6180 | continue; |
| 6181 | } |
| 6182 | if (type == bgp_show_type_route_map |
| 6183 | || type == bgp_show_type_flap_route_map) |
| 6184 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6185 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6186 | struct bgp_info binfo; |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 6187 | struct attr dummy_attr = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6188 | int ret; |
| 6189 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6190 | bgp_attr_dup (&dummy_attr, ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6191 | binfo.peer = ri->peer; |
| 6192 | binfo.attr = &dummy_attr; |
| 6193 | |
| 6194 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6195 | |
| 6196 | bgp_attr_extra_free (&dummy_attr); |
| 6197 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6198 | if (ret == RMAP_DENYMATCH) |
| 6199 | continue; |
| 6200 | } |
| 6201 | if (type == bgp_show_type_neighbor |
| 6202 | || type == bgp_show_type_flap_neighbor |
| 6203 | || type == bgp_show_type_damp_neighbor) |
| 6204 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6205 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6206 | |
| 6207 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6208 | continue; |
| 6209 | } |
| 6210 | if (type == bgp_show_type_cidr_only |
| 6211 | || type == bgp_show_type_flap_cidr_only) |
| 6212 | { |
| 6213 | u_int32_t destination; |
| 6214 | |
| 6215 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6216 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6217 | continue; |
| 6218 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6219 | continue; |
| 6220 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6221 | continue; |
| 6222 | } |
| 6223 | if (type == bgp_show_type_prefix_longer |
| 6224 | || type == bgp_show_type_flap_prefix_longer) |
| 6225 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6226 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6227 | |
| 6228 | if (! prefix_match (p, &rn->p)) |
| 6229 | continue; |
| 6230 | } |
| 6231 | if (type == bgp_show_type_community_all) |
| 6232 | { |
| 6233 | if (! ri->attr->community) |
| 6234 | continue; |
| 6235 | } |
| 6236 | if (type == bgp_show_type_community) |
| 6237 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6238 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6239 | |
| 6240 | if (! ri->attr->community || |
| 6241 | ! community_match (ri->attr->community, com)) |
| 6242 | continue; |
| 6243 | } |
| 6244 | if (type == bgp_show_type_community_exact) |
| 6245 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6246 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6247 | |
| 6248 | if (! ri->attr->community || |
| 6249 | ! community_cmp (ri->attr->community, com)) |
| 6250 | continue; |
| 6251 | } |
| 6252 | if (type == bgp_show_type_community_list) |
| 6253 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6254 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6255 | |
| 6256 | if (! community_list_match (ri->attr->community, list)) |
| 6257 | continue; |
| 6258 | } |
| 6259 | if (type == bgp_show_type_community_list_exact) |
| 6260 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6261 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6262 | |
| 6263 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6264 | continue; |
| 6265 | } |
| 6266 | if (type == bgp_show_type_flap_address |
| 6267 | || type == bgp_show_type_flap_prefix) |
| 6268 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6269 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6270 | |
| 6271 | if (! prefix_match (&rn->p, p)) |
| 6272 | continue; |
| 6273 | |
| 6274 | if (type == bgp_show_type_flap_prefix) |
| 6275 | if (p->prefixlen != rn->p.prefixlen) |
| 6276 | continue; |
| 6277 | } |
| 6278 | if (type == bgp_show_type_dampend_paths |
| 6279 | || type == bgp_show_type_damp_neighbor) |
| 6280 | { |
| 6281 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6282 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6283 | continue; |
| 6284 | } |
| 6285 | |
| 6286 | if (header) |
| 6287 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6288 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6289 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6290 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6291 | if (type == bgp_show_type_dampend_paths |
| 6292 | || type == bgp_show_type_damp_neighbor) |
| 6293 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6294 | else if (type == bgp_show_type_flap_statistics |
| 6295 | || type == bgp_show_type_flap_address |
| 6296 | || type == bgp_show_type_flap_prefix |
| 6297 | || type == bgp_show_type_flap_cidr_only |
| 6298 | || type == bgp_show_type_flap_regexp |
| 6299 | || type == bgp_show_type_flap_filter_list |
| 6300 | || type == bgp_show_type_flap_prefix_list |
| 6301 | || type == bgp_show_type_flap_prefix_longer |
| 6302 | || type == bgp_show_type_flap_route_map |
| 6303 | || type == bgp_show_type_flap_neighbor) |
| 6304 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6305 | else |
| 6306 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6307 | header = 0; |
| 6308 | } |
| 6309 | |
| 6310 | if (type == bgp_show_type_dampend_paths |
| 6311 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6312 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6313 | else if (type == bgp_show_type_flap_statistics |
| 6314 | || type == bgp_show_type_flap_address |
| 6315 | || type == bgp_show_type_flap_prefix |
| 6316 | || type == bgp_show_type_flap_cidr_only |
| 6317 | || type == bgp_show_type_flap_regexp |
| 6318 | || type == bgp_show_type_flap_filter_list |
| 6319 | || type == bgp_show_type_flap_prefix_list |
| 6320 | || type == bgp_show_type_flap_prefix_longer |
| 6321 | || type == bgp_show_type_flap_route_map |
| 6322 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6323 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6324 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6325 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6326 | display++; |
| 6327 | } |
| 6328 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6329 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6330 | } |
| 6331 | |
| 6332 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6333 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6334 | { |
| 6335 | if (type == bgp_show_type_normal) |
| 6336 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6337 | } |
| 6338 | else |
| 6339 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6340 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6341 | |
| 6342 | return CMD_SUCCESS; |
| 6343 | } |
| 6344 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6345 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6346 | 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] | 6347 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6348 | { |
| 6349 | struct bgp_table *table; |
| 6350 | |
| 6351 | if (bgp == NULL) { |
| 6352 | bgp = bgp_get_default (); |
| 6353 | } |
| 6354 | |
| 6355 | if (bgp == NULL) |
| 6356 | { |
| 6357 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6358 | return CMD_WARNING; |
| 6359 | } |
| 6360 | |
| 6361 | |
| 6362 | table = bgp->rib[afi][safi]; |
| 6363 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6364 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6365 | } |
| 6366 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6367 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6368 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6369 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6370 | struct bgp_node *rn, |
| 6371 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6372 | { |
| 6373 | struct bgp_info *ri; |
| 6374 | struct prefix *p; |
| 6375 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6376 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6377 | char buf1[INET6_ADDRSTRLEN]; |
| 6378 | char buf2[INET6_ADDRSTRLEN]; |
| 6379 | int count = 0; |
| 6380 | int best = 0; |
| 6381 | int suppress = 0; |
| 6382 | int no_export = 0; |
| 6383 | int no_advertise = 0; |
| 6384 | int local_as = 0; |
| 6385 | int first = 0; |
| 6386 | |
| 6387 | p = &rn->p; |
| 6388 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6389 | (safi == SAFI_MPLS_VPN ? |
| 6390 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6391 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6392 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6393 | p->prefixlen, VTY_NEWLINE); |
| 6394 | |
| 6395 | for (ri = rn->info; ri; ri = ri->next) |
| 6396 | { |
| 6397 | count++; |
| 6398 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6399 | { |
| 6400 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6401 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6402 | suppress = 1; |
| 6403 | if (ri->attr->community != NULL) |
| 6404 | { |
| 6405 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6406 | no_advertise = 1; |
| 6407 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6408 | no_export = 1; |
| 6409 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6410 | local_as = 1; |
| 6411 | } |
| 6412 | } |
| 6413 | } |
| 6414 | |
| 6415 | vty_out (vty, "Paths: (%d available", count); |
| 6416 | if (best) |
| 6417 | { |
| 6418 | vty_out (vty, ", best #%d", best); |
| 6419 | if (safi == SAFI_UNICAST) |
| 6420 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6421 | } |
| 6422 | else |
| 6423 | vty_out (vty, ", no best path"); |
| 6424 | if (no_advertise) |
| 6425 | vty_out (vty, ", not advertised to any peer"); |
| 6426 | else if (no_export) |
| 6427 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6428 | else if (local_as) |
| 6429 | vty_out (vty, ", not advertised outside local AS"); |
| 6430 | if (suppress) |
| 6431 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6432 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6433 | |
| 6434 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6435 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6436 | { |
| 6437 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6438 | { |
| 6439 | if (! first) |
| 6440 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6441 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6442 | first = 1; |
| 6443 | } |
| 6444 | } |
| 6445 | if (! first) |
| 6446 | vty_out (vty, " Not advertised to any peer"); |
| 6447 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6448 | } |
| 6449 | |
| 6450 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6451 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6452 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6453 | struct bgp_table *rib, const char *ip_str, |
| 6454 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6455 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6456 | { |
| 6457 | int ret; |
| 6458 | int header; |
| 6459 | int display = 0; |
| 6460 | struct prefix match; |
| 6461 | struct bgp_node *rn; |
| 6462 | struct bgp_node *rm; |
| 6463 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6464 | struct bgp_table *table; |
| 6465 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6466 | /* Check IP address argument. */ |
| 6467 | ret = str2prefix (ip_str, &match); |
| 6468 | if (! ret) |
| 6469 | { |
| 6470 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6471 | return CMD_WARNING; |
| 6472 | } |
| 6473 | |
| 6474 | match.family = afi2family (afi); |
| 6475 | |
| 6476 | if (safi == SAFI_MPLS_VPN) |
| 6477 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6478 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6479 | { |
| 6480 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6481 | continue; |
| 6482 | |
| 6483 | if ((table = rn->info) != NULL) |
| 6484 | { |
| 6485 | header = 1; |
| 6486 | |
| 6487 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6488 | { |
| 6489 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6490 | { |
| 6491 | bgp_unlock_node (rm); |
| 6492 | continue; |
| 6493 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6494 | |
| 6495 | for (ri = rm->info; ri; ri = ri->next) |
| 6496 | { |
| 6497 | if (header) |
| 6498 | { |
| 6499 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6500 | AFI_IP, SAFI_MPLS_VPN); |
| 6501 | |
| 6502 | header = 0; |
| 6503 | } |
| 6504 | display++; |
| 6505 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6506 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6507 | |
| 6508 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6509 | } |
| 6510 | } |
| 6511 | } |
| 6512 | } |
| 6513 | else |
| 6514 | { |
| 6515 | header = 1; |
| 6516 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6517 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6518 | { |
| 6519 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6520 | { |
| 6521 | for (ri = rn->info; ri; ri = ri->next) |
| 6522 | { |
| 6523 | if (header) |
| 6524 | { |
| 6525 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6526 | header = 0; |
| 6527 | } |
| 6528 | display++; |
| 6529 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6530 | } |
| 6531 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6532 | |
| 6533 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6534 | } |
| 6535 | } |
| 6536 | |
| 6537 | if (! display) |
| 6538 | { |
| 6539 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6540 | return CMD_WARNING; |
| 6541 | } |
| 6542 | |
| 6543 | return CMD_SUCCESS; |
| 6544 | } |
| 6545 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6546 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6547 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6548 | 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] | 6549 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6550 | int prefix_check) |
| 6551 | { |
| 6552 | struct bgp *bgp; |
| 6553 | |
| 6554 | /* BGP structure lookup. */ |
| 6555 | if (view_name) |
| 6556 | { |
| 6557 | bgp = bgp_lookup_by_name (view_name); |
| 6558 | if (bgp == NULL) |
| 6559 | { |
| 6560 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6561 | return CMD_WARNING; |
| 6562 | } |
| 6563 | } |
| 6564 | else |
| 6565 | { |
| 6566 | bgp = bgp_get_default (); |
| 6567 | if (bgp == NULL) |
| 6568 | { |
| 6569 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6570 | return CMD_WARNING; |
| 6571 | } |
| 6572 | } |
| 6573 | |
| 6574 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6575 | afi, safi, prd, prefix_check); |
| 6576 | } |
| 6577 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6578 | /* BGP route print out function. */ |
| 6579 | DEFUN (show_ip_bgp, |
| 6580 | show_ip_bgp_cmd, |
| 6581 | "show ip bgp", |
| 6582 | SHOW_STR |
| 6583 | IP_STR |
| 6584 | BGP_STR) |
| 6585 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6586 | 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] | 6587 | } |
| 6588 | |
| 6589 | DEFUN (show_ip_bgp_ipv4, |
| 6590 | show_ip_bgp_ipv4_cmd, |
| 6591 | "show ip bgp ipv4 (unicast|multicast)", |
| 6592 | SHOW_STR |
| 6593 | IP_STR |
| 6594 | BGP_STR |
| 6595 | "Address family\n" |
| 6596 | "Address Family modifier\n" |
| 6597 | "Address Family modifier\n") |
| 6598 | { |
| 6599 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6600 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6601 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6602 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6603 | 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] | 6604 | } |
| 6605 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6606 | ALIAS (show_ip_bgp_ipv4, |
| 6607 | show_bgp_ipv4_safi_cmd, |
| 6608 | "show bgp ipv4 (unicast|multicast)", |
| 6609 | SHOW_STR |
| 6610 | BGP_STR |
| 6611 | "Address family\n" |
| 6612 | "Address Family modifier\n" |
| 6613 | "Address Family modifier\n") |
| 6614 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6615 | DEFUN (show_ip_bgp_route, |
| 6616 | show_ip_bgp_route_cmd, |
| 6617 | "show ip bgp A.B.C.D", |
| 6618 | SHOW_STR |
| 6619 | IP_STR |
| 6620 | BGP_STR |
| 6621 | "Network in the BGP routing table to display\n") |
| 6622 | { |
| 6623 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6624 | } |
| 6625 | |
| 6626 | DEFUN (show_ip_bgp_ipv4_route, |
| 6627 | show_ip_bgp_ipv4_route_cmd, |
| 6628 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6629 | SHOW_STR |
| 6630 | IP_STR |
| 6631 | BGP_STR |
| 6632 | "Address family\n" |
| 6633 | "Address Family modifier\n" |
| 6634 | "Address Family modifier\n" |
| 6635 | "Network in the BGP routing table to display\n") |
| 6636 | { |
| 6637 | if (strncmp (argv[0], "m", 1) == 0) |
| 6638 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6639 | |
| 6640 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6641 | } |
| 6642 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6643 | ALIAS (show_ip_bgp_ipv4_route, |
| 6644 | show_bgp_ipv4_safi_route_cmd, |
| 6645 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6646 | SHOW_STR |
| 6647 | BGP_STR |
| 6648 | "Address family\n" |
| 6649 | "Address Family modifier\n" |
| 6650 | "Address Family modifier\n" |
| 6651 | "Network in the BGP routing table to display\n") |
| 6652 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6653 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6654 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6655 | "show ip bgp vpnv4 all A.B.C.D", |
| 6656 | SHOW_STR |
| 6657 | IP_STR |
| 6658 | BGP_STR |
| 6659 | "Display VPNv4 NLRI specific information\n" |
| 6660 | "Display information about all VPNv4 NLRIs\n" |
| 6661 | "Network in the BGP routing table to display\n") |
| 6662 | { |
| 6663 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6664 | } |
| 6665 | |
| 6666 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6667 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6668 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6669 | SHOW_STR |
| 6670 | IP_STR |
| 6671 | BGP_STR |
| 6672 | "Display VPNv4 NLRI specific information\n" |
| 6673 | "Display information for a route distinguisher\n" |
| 6674 | "VPN Route Distinguisher\n" |
| 6675 | "Network in the BGP routing table to display\n") |
| 6676 | { |
| 6677 | int ret; |
| 6678 | struct prefix_rd prd; |
| 6679 | |
| 6680 | ret = str2prefix_rd (argv[0], &prd); |
| 6681 | if (! ret) |
| 6682 | { |
| 6683 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6684 | return CMD_WARNING; |
| 6685 | } |
| 6686 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6687 | } |
| 6688 | |
| 6689 | DEFUN (show_ip_bgp_prefix, |
| 6690 | show_ip_bgp_prefix_cmd, |
| 6691 | "show ip bgp A.B.C.D/M", |
| 6692 | SHOW_STR |
| 6693 | IP_STR |
| 6694 | BGP_STR |
| 6695 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6696 | { |
| 6697 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6698 | } |
| 6699 | |
| 6700 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6701 | show_ip_bgp_ipv4_prefix_cmd, |
| 6702 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6703 | SHOW_STR |
| 6704 | IP_STR |
| 6705 | BGP_STR |
| 6706 | "Address family\n" |
| 6707 | "Address Family modifier\n" |
| 6708 | "Address Family modifier\n" |
| 6709 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6710 | { |
| 6711 | if (strncmp (argv[0], "m", 1) == 0) |
| 6712 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6713 | |
| 6714 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6715 | } |
| 6716 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6717 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6718 | show_bgp_ipv4_safi_prefix_cmd, |
| 6719 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6720 | SHOW_STR |
| 6721 | BGP_STR |
| 6722 | "Address family\n" |
| 6723 | "Address Family modifier\n" |
| 6724 | "Address Family modifier\n" |
| 6725 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6726 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6727 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6728 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6729 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6730 | SHOW_STR |
| 6731 | IP_STR |
| 6732 | BGP_STR |
| 6733 | "Display VPNv4 NLRI specific information\n" |
| 6734 | "Display information about all VPNv4 NLRIs\n" |
| 6735 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6736 | { |
| 6737 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6738 | } |
| 6739 | |
| 6740 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6741 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6742 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6743 | SHOW_STR |
| 6744 | IP_STR |
| 6745 | BGP_STR |
| 6746 | "Display VPNv4 NLRI specific information\n" |
| 6747 | "Display information for a route distinguisher\n" |
| 6748 | "VPN Route Distinguisher\n" |
| 6749 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6750 | { |
| 6751 | int ret; |
| 6752 | struct prefix_rd prd; |
| 6753 | |
| 6754 | ret = str2prefix_rd (argv[0], &prd); |
| 6755 | if (! ret) |
| 6756 | { |
| 6757 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6758 | return CMD_WARNING; |
| 6759 | } |
| 6760 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6761 | } |
| 6762 | |
| 6763 | DEFUN (show_ip_bgp_view, |
| 6764 | show_ip_bgp_view_cmd, |
| 6765 | "show ip bgp view WORD", |
| 6766 | SHOW_STR |
| 6767 | IP_STR |
| 6768 | BGP_STR |
| 6769 | "BGP view\n" |
| 6770 | "BGP view name\n") |
| 6771 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6772 | struct bgp *bgp; |
| 6773 | |
| 6774 | /* BGP structure lookup. */ |
| 6775 | bgp = bgp_lookup_by_name (argv[0]); |
| 6776 | if (bgp == NULL) |
| 6777 | { |
| 6778 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6779 | return CMD_WARNING; |
| 6780 | } |
| 6781 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6782 | 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] | 6783 | } |
| 6784 | |
| 6785 | DEFUN (show_ip_bgp_view_route, |
| 6786 | show_ip_bgp_view_route_cmd, |
| 6787 | "show ip bgp view WORD A.B.C.D", |
| 6788 | SHOW_STR |
| 6789 | IP_STR |
| 6790 | BGP_STR |
| 6791 | "BGP view\n" |
| 6792 | "BGP view name\n" |
| 6793 | "Network in the BGP routing table to display\n") |
| 6794 | { |
| 6795 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6796 | } |
| 6797 | |
| 6798 | DEFUN (show_ip_bgp_view_prefix, |
| 6799 | show_ip_bgp_view_prefix_cmd, |
| 6800 | "show ip bgp view WORD A.B.C.D/M", |
| 6801 | SHOW_STR |
| 6802 | IP_STR |
| 6803 | BGP_STR |
| 6804 | "BGP view\n" |
| 6805 | "BGP view name\n" |
| 6806 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6807 | { |
| 6808 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6809 | } |
| 6810 | |
| 6811 | #ifdef HAVE_IPV6 |
| 6812 | DEFUN (show_bgp, |
| 6813 | show_bgp_cmd, |
| 6814 | "show bgp", |
| 6815 | SHOW_STR |
| 6816 | BGP_STR) |
| 6817 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6818 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6819 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6820 | } |
| 6821 | |
| 6822 | ALIAS (show_bgp, |
| 6823 | show_bgp_ipv6_cmd, |
| 6824 | "show bgp ipv6", |
| 6825 | SHOW_STR |
| 6826 | BGP_STR |
| 6827 | "Address family\n") |
| 6828 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6829 | DEFUN (show_bgp_ipv6_safi, |
| 6830 | show_bgp_ipv6_safi_cmd, |
| 6831 | "show bgp ipv6 (unicast|multicast)", |
| 6832 | SHOW_STR |
| 6833 | BGP_STR |
| 6834 | "Address family\n" |
| 6835 | "Address Family modifier\n" |
| 6836 | "Address Family modifier\n") |
| 6837 | { |
| 6838 | if (strncmp (argv[0], "m", 1) == 0) |
| 6839 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6840 | NULL); |
| 6841 | |
| 6842 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6843 | } |
| 6844 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6845 | /* old command */ |
| 6846 | DEFUN (show_ipv6_bgp, |
| 6847 | show_ipv6_bgp_cmd, |
| 6848 | "show ipv6 bgp", |
| 6849 | SHOW_STR |
| 6850 | IP_STR |
| 6851 | BGP_STR) |
| 6852 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6853 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6854 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6855 | } |
| 6856 | |
| 6857 | DEFUN (show_bgp_route, |
| 6858 | show_bgp_route_cmd, |
| 6859 | "show bgp X:X::X:X", |
| 6860 | SHOW_STR |
| 6861 | BGP_STR |
| 6862 | "Network in the BGP routing table to display\n") |
| 6863 | { |
| 6864 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6865 | } |
| 6866 | |
| 6867 | ALIAS (show_bgp_route, |
| 6868 | show_bgp_ipv6_route_cmd, |
| 6869 | "show bgp ipv6 X:X::X:X", |
| 6870 | SHOW_STR |
| 6871 | BGP_STR |
| 6872 | "Address family\n" |
| 6873 | "Network in the BGP routing table to display\n") |
| 6874 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6875 | DEFUN (show_bgp_ipv6_safi_route, |
| 6876 | show_bgp_ipv6_safi_route_cmd, |
| 6877 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6878 | SHOW_STR |
| 6879 | BGP_STR |
| 6880 | "Address family\n" |
| 6881 | "Address Family modifier\n" |
| 6882 | "Address Family modifier\n" |
| 6883 | "Network in the BGP routing table to display\n") |
| 6884 | { |
| 6885 | if (strncmp (argv[0], "m", 1) == 0) |
| 6886 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6887 | |
| 6888 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6889 | } |
| 6890 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6891 | /* old command */ |
| 6892 | DEFUN (show_ipv6_bgp_route, |
| 6893 | show_ipv6_bgp_route_cmd, |
| 6894 | "show ipv6 bgp X:X::X:X", |
| 6895 | SHOW_STR |
| 6896 | IP_STR |
| 6897 | BGP_STR |
| 6898 | "Network in the BGP routing table to display\n") |
| 6899 | { |
| 6900 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6901 | } |
| 6902 | |
| 6903 | DEFUN (show_bgp_prefix, |
| 6904 | show_bgp_prefix_cmd, |
| 6905 | "show bgp X:X::X:X/M", |
| 6906 | SHOW_STR |
| 6907 | BGP_STR |
| 6908 | "IPv6 prefix <network>/<length>\n") |
| 6909 | { |
| 6910 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6911 | } |
| 6912 | |
| 6913 | ALIAS (show_bgp_prefix, |
| 6914 | show_bgp_ipv6_prefix_cmd, |
| 6915 | "show bgp ipv6 X:X::X:X/M", |
| 6916 | SHOW_STR |
| 6917 | BGP_STR |
| 6918 | "Address family\n" |
| 6919 | "IPv6 prefix <network>/<length>\n") |
| 6920 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6921 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6922 | show_bgp_ipv6_safi_prefix_cmd, |
| 6923 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 6924 | SHOW_STR |
| 6925 | BGP_STR |
| 6926 | "Address family\n" |
| 6927 | "Address Family modifier\n" |
| 6928 | "Address Family modifier\n" |
| 6929 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6930 | { |
| 6931 | if (strncmp (argv[0], "m", 1) == 0) |
| 6932 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6933 | |
| 6934 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6935 | } |
| 6936 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6937 | /* old command */ |
| 6938 | DEFUN (show_ipv6_bgp_prefix, |
| 6939 | show_ipv6_bgp_prefix_cmd, |
| 6940 | "show ipv6 bgp X:X::X:X/M", |
| 6941 | SHOW_STR |
| 6942 | IP_STR |
| 6943 | BGP_STR |
| 6944 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6945 | { |
| 6946 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6947 | } |
| 6948 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6949 | DEFUN (show_bgp_view, |
| 6950 | show_bgp_view_cmd, |
| 6951 | "show bgp view WORD", |
| 6952 | SHOW_STR |
| 6953 | BGP_STR |
| 6954 | "BGP view\n" |
| 6955 | "View name\n") |
| 6956 | { |
| 6957 | struct bgp *bgp; |
| 6958 | |
| 6959 | /* BGP structure lookup. */ |
| 6960 | bgp = bgp_lookup_by_name (argv[0]); |
| 6961 | if (bgp == NULL) |
| 6962 | { |
| 6963 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6964 | return CMD_WARNING; |
| 6965 | } |
| 6966 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6967 | 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] | 6968 | } |
| 6969 | |
| 6970 | ALIAS (show_bgp_view, |
| 6971 | show_bgp_view_ipv6_cmd, |
| 6972 | "show bgp view WORD ipv6", |
| 6973 | SHOW_STR |
| 6974 | BGP_STR |
| 6975 | "BGP view\n" |
| 6976 | "View name\n" |
| 6977 | "Address family\n") |
| 6978 | |
| 6979 | DEFUN (show_bgp_view_route, |
| 6980 | show_bgp_view_route_cmd, |
| 6981 | "show bgp view WORD X:X::X:X", |
| 6982 | SHOW_STR |
| 6983 | BGP_STR |
| 6984 | "BGP view\n" |
| 6985 | "View name\n" |
| 6986 | "Network in the BGP routing table to display\n") |
| 6987 | { |
| 6988 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6989 | } |
| 6990 | |
| 6991 | ALIAS (show_bgp_view_route, |
| 6992 | show_bgp_view_ipv6_route_cmd, |
| 6993 | "show bgp view WORD ipv6 X:X::X:X", |
| 6994 | SHOW_STR |
| 6995 | BGP_STR |
| 6996 | "BGP view\n" |
| 6997 | "View name\n" |
| 6998 | "Address family\n" |
| 6999 | "Network in the BGP routing table to display\n") |
| 7000 | |
| 7001 | DEFUN (show_bgp_view_prefix, |
| 7002 | show_bgp_view_prefix_cmd, |
| 7003 | "show bgp view WORD X:X::X:X/M", |
| 7004 | SHOW_STR |
| 7005 | BGP_STR |
| 7006 | "BGP view\n" |
| 7007 | "View name\n" |
| 7008 | "IPv6 prefix <network>/<length>\n") |
| 7009 | { |
| 7010 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7011 | } |
| 7012 | |
| 7013 | ALIAS (show_bgp_view_prefix, |
| 7014 | show_bgp_view_ipv6_prefix_cmd, |
| 7015 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7016 | SHOW_STR |
| 7017 | BGP_STR |
| 7018 | "BGP view\n" |
| 7019 | "View name\n" |
| 7020 | "Address family\n" |
| 7021 | "IPv6 prefix <network>/<length>\n") |
| 7022 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7023 | /* old command */ |
| 7024 | DEFUN (show_ipv6_mbgp, |
| 7025 | show_ipv6_mbgp_cmd, |
| 7026 | "show ipv6 mbgp", |
| 7027 | SHOW_STR |
| 7028 | IP_STR |
| 7029 | MBGP_STR) |
| 7030 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7031 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7032 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7033 | } |
| 7034 | |
| 7035 | /* old command */ |
| 7036 | DEFUN (show_ipv6_mbgp_route, |
| 7037 | show_ipv6_mbgp_route_cmd, |
| 7038 | "show ipv6 mbgp X:X::X:X", |
| 7039 | SHOW_STR |
| 7040 | IP_STR |
| 7041 | MBGP_STR |
| 7042 | "Network in the MBGP routing table to display\n") |
| 7043 | { |
| 7044 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7045 | } |
| 7046 | |
| 7047 | /* old command */ |
| 7048 | DEFUN (show_ipv6_mbgp_prefix, |
| 7049 | show_ipv6_mbgp_prefix_cmd, |
| 7050 | "show ipv6 mbgp X:X::X:X/M", |
| 7051 | SHOW_STR |
| 7052 | IP_STR |
| 7053 | MBGP_STR |
| 7054 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7055 | { |
| 7056 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7057 | } |
| 7058 | #endif |
| 7059 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7060 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7061 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7062 | 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] | 7063 | safi_t safi, enum bgp_show_type type) |
| 7064 | { |
| 7065 | int i; |
| 7066 | struct buffer *b; |
| 7067 | char *regstr; |
| 7068 | int first; |
| 7069 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7070 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7071 | |
| 7072 | first = 0; |
| 7073 | b = buffer_new (1024); |
| 7074 | for (i = 0; i < argc; i++) |
| 7075 | { |
| 7076 | if (first) |
| 7077 | buffer_putc (b, ' '); |
| 7078 | else |
| 7079 | { |
| 7080 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7081 | continue; |
| 7082 | first = 1; |
| 7083 | } |
| 7084 | |
| 7085 | buffer_putstr (b, argv[i]); |
| 7086 | } |
| 7087 | buffer_putc (b, '\0'); |
| 7088 | |
| 7089 | regstr = buffer_getstr (b); |
| 7090 | buffer_free (b); |
| 7091 | |
| 7092 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7093 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7094 | if (! regex) |
| 7095 | { |
| 7096 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7097 | VTY_NEWLINE); |
| 7098 | return CMD_WARNING; |
| 7099 | } |
| 7100 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7101 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7102 | bgp_regex_free (regex); |
| 7103 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7104 | } |
| 7105 | |
| 7106 | DEFUN (show_ip_bgp_regexp, |
| 7107 | show_ip_bgp_regexp_cmd, |
| 7108 | "show ip bgp regexp .LINE", |
| 7109 | SHOW_STR |
| 7110 | IP_STR |
| 7111 | BGP_STR |
| 7112 | "Display routes matching the AS path regular expression\n" |
| 7113 | "A regular-expression to match the BGP AS paths\n") |
| 7114 | { |
| 7115 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7116 | bgp_show_type_regexp); |
| 7117 | } |
| 7118 | |
| 7119 | DEFUN (show_ip_bgp_flap_regexp, |
| 7120 | show_ip_bgp_flap_regexp_cmd, |
| 7121 | "show ip bgp flap-statistics regexp .LINE", |
| 7122 | SHOW_STR |
| 7123 | IP_STR |
| 7124 | BGP_STR |
| 7125 | "Display flap statistics of routes\n" |
| 7126 | "Display routes matching the AS path regular expression\n" |
| 7127 | "A regular-expression to match the BGP AS paths\n") |
| 7128 | { |
| 7129 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7130 | bgp_show_type_flap_regexp); |
| 7131 | } |
| 7132 | |
| 7133 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7134 | show_ip_bgp_ipv4_regexp_cmd, |
| 7135 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7136 | SHOW_STR |
| 7137 | IP_STR |
| 7138 | BGP_STR |
| 7139 | "Address family\n" |
| 7140 | "Address Family modifier\n" |
| 7141 | "Address Family modifier\n" |
| 7142 | "Display routes matching the AS path regular expression\n" |
| 7143 | "A regular-expression to match the BGP AS paths\n") |
| 7144 | { |
| 7145 | if (strncmp (argv[0], "m", 1) == 0) |
| 7146 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7147 | bgp_show_type_regexp); |
| 7148 | |
| 7149 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7150 | bgp_show_type_regexp); |
| 7151 | } |
| 7152 | |
| 7153 | #ifdef HAVE_IPV6 |
| 7154 | DEFUN (show_bgp_regexp, |
| 7155 | show_bgp_regexp_cmd, |
| 7156 | "show bgp regexp .LINE", |
| 7157 | SHOW_STR |
| 7158 | BGP_STR |
| 7159 | "Display routes matching the AS path regular expression\n" |
| 7160 | "A regular-expression to match the BGP AS paths\n") |
| 7161 | { |
| 7162 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7163 | bgp_show_type_regexp); |
| 7164 | } |
| 7165 | |
| 7166 | ALIAS (show_bgp_regexp, |
| 7167 | show_bgp_ipv6_regexp_cmd, |
| 7168 | "show bgp ipv6 regexp .LINE", |
| 7169 | SHOW_STR |
| 7170 | BGP_STR |
| 7171 | "Address family\n" |
| 7172 | "Display routes matching the AS path regular expression\n" |
| 7173 | "A regular-expression to match the BGP AS paths\n") |
| 7174 | |
| 7175 | /* old command */ |
| 7176 | DEFUN (show_ipv6_bgp_regexp, |
| 7177 | show_ipv6_bgp_regexp_cmd, |
| 7178 | "show ipv6 bgp regexp .LINE", |
| 7179 | SHOW_STR |
| 7180 | IP_STR |
| 7181 | BGP_STR |
| 7182 | "Display routes matching the AS path regular expression\n" |
| 7183 | "A regular-expression to match the BGP AS paths\n") |
| 7184 | { |
| 7185 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7186 | bgp_show_type_regexp); |
| 7187 | } |
| 7188 | |
| 7189 | /* old command */ |
| 7190 | DEFUN (show_ipv6_mbgp_regexp, |
| 7191 | show_ipv6_mbgp_regexp_cmd, |
| 7192 | "show ipv6 mbgp regexp .LINE", |
| 7193 | SHOW_STR |
| 7194 | IP_STR |
| 7195 | BGP_STR |
| 7196 | "Display routes matching the AS path regular expression\n" |
| 7197 | "A regular-expression to match the MBGP AS paths\n") |
| 7198 | { |
| 7199 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7200 | bgp_show_type_regexp); |
| 7201 | } |
| 7202 | #endif /* HAVE_IPV6 */ |
| 7203 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7204 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7205 | 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] | 7206 | safi_t safi, enum bgp_show_type type) |
| 7207 | { |
| 7208 | struct prefix_list *plist; |
| 7209 | |
| 7210 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7211 | if (plist == NULL) |
| 7212 | { |
| 7213 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7214 | prefix_list_str, VTY_NEWLINE); |
| 7215 | return CMD_WARNING; |
| 7216 | } |
| 7217 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7218 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7219 | } |
| 7220 | |
| 7221 | DEFUN (show_ip_bgp_prefix_list, |
| 7222 | show_ip_bgp_prefix_list_cmd, |
| 7223 | "show ip bgp prefix-list WORD", |
| 7224 | SHOW_STR |
| 7225 | IP_STR |
| 7226 | BGP_STR |
| 7227 | "Display routes conforming to the prefix-list\n" |
| 7228 | "IP prefix-list name\n") |
| 7229 | { |
| 7230 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7231 | bgp_show_type_prefix_list); |
| 7232 | } |
| 7233 | |
| 7234 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7235 | show_ip_bgp_flap_prefix_list_cmd, |
| 7236 | "show ip bgp flap-statistics prefix-list WORD", |
| 7237 | SHOW_STR |
| 7238 | IP_STR |
| 7239 | BGP_STR |
| 7240 | "Display flap statistics of routes\n" |
| 7241 | "Display routes conforming to the prefix-list\n" |
| 7242 | "IP prefix-list name\n") |
| 7243 | { |
| 7244 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7245 | bgp_show_type_flap_prefix_list); |
| 7246 | } |
| 7247 | |
| 7248 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7249 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7250 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7251 | SHOW_STR |
| 7252 | IP_STR |
| 7253 | BGP_STR |
| 7254 | "Address family\n" |
| 7255 | "Address Family modifier\n" |
| 7256 | "Address Family modifier\n" |
| 7257 | "Display routes conforming to the prefix-list\n" |
| 7258 | "IP prefix-list name\n") |
| 7259 | { |
| 7260 | if (strncmp (argv[0], "m", 1) == 0) |
| 7261 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7262 | bgp_show_type_prefix_list); |
| 7263 | |
| 7264 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7265 | bgp_show_type_prefix_list); |
| 7266 | } |
| 7267 | |
| 7268 | #ifdef HAVE_IPV6 |
| 7269 | DEFUN (show_bgp_prefix_list, |
| 7270 | show_bgp_prefix_list_cmd, |
| 7271 | "show bgp prefix-list WORD", |
| 7272 | SHOW_STR |
| 7273 | BGP_STR |
| 7274 | "Display routes conforming to the prefix-list\n" |
| 7275 | "IPv6 prefix-list name\n") |
| 7276 | { |
| 7277 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7278 | bgp_show_type_prefix_list); |
| 7279 | } |
| 7280 | |
| 7281 | ALIAS (show_bgp_prefix_list, |
| 7282 | show_bgp_ipv6_prefix_list_cmd, |
| 7283 | "show bgp ipv6 prefix-list WORD", |
| 7284 | SHOW_STR |
| 7285 | BGP_STR |
| 7286 | "Address family\n" |
| 7287 | "Display routes conforming to the prefix-list\n" |
| 7288 | "IPv6 prefix-list name\n") |
| 7289 | |
| 7290 | /* old command */ |
| 7291 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7292 | show_ipv6_bgp_prefix_list_cmd, |
| 7293 | "show ipv6 bgp prefix-list WORD", |
| 7294 | SHOW_STR |
| 7295 | IPV6_STR |
| 7296 | BGP_STR |
| 7297 | "Display routes matching the prefix-list\n" |
| 7298 | "IPv6 prefix-list name\n") |
| 7299 | { |
| 7300 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7301 | bgp_show_type_prefix_list); |
| 7302 | } |
| 7303 | |
| 7304 | /* old command */ |
| 7305 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7306 | show_ipv6_mbgp_prefix_list_cmd, |
| 7307 | "show ipv6 mbgp prefix-list WORD", |
| 7308 | SHOW_STR |
| 7309 | IPV6_STR |
| 7310 | MBGP_STR |
| 7311 | "Display routes matching the prefix-list\n" |
| 7312 | "IPv6 prefix-list name\n") |
| 7313 | { |
| 7314 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7315 | bgp_show_type_prefix_list); |
| 7316 | } |
| 7317 | #endif /* HAVE_IPV6 */ |
| 7318 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7319 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7320 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7321 | safi_t safi, enum bgp_show_type type) |
| 7322 | { |
| 7323 | struct as_list *as_list; |
| 7324 | |
| 7325 | as_list = as_list_lookup (filter); |
| 7326 | if (as_list == NULL) |
| 7327 | { |
| 7328 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7329 | return CMD_WARNING; |
| 7330 | } |
| 7331 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7332 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7333 | } |
| 7334 | |
| 7335 | DEFUN (show_ip_bgp_filter_list, |
| 7336 | show_ip_bgp_filter_list_cmd, |
| 7337 | "show ip bgp filter-list WORD", |
| 7338 | SHOW_STR |
| 7339 | IP_STR |
| 7340 | BGP_STR |
| 7341 | "Display routes conforming to the filter-list\n" |
| 7342 | "Regular expression access list name\n") |
| 7343 | { |
| 7344 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7345 | bgp_show_type_filter_list); |
| 7346 | } |
| 7347 | |
| 7348 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7349 | show_ip_bgp_flap_filter_list_cmd, |
| 7350 | "show ip bgp flap-statistics filter-list WORD", |
| 7351 | SHOW_STR |
| 7352 | IP_STR |
| 7353 | BGP_STR |
| 7354 | "Display flap statistics of routes\n" |
| 7355 | "Display routes conforming to the filter-list\n" |
| 7356 | "Regular expression access list name\n") |
| 7357 | { |
| 7358 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7359 | bgp_show_type_flap_filter_list); |
| 7360 | } |
| 7361 | |
| 7362 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7363 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7364 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7365 | SHOW_STR |
| 7366 | IP_STR |
| 7367 | BGP_STR |
| 7368 | "Address family\n" |
| 7369 | "Address Family modifier\n" |
| 7370 | "Address Family modifier\n" |
| 7371 | "Display routes conforming to the filter-list\n" |
| 7372 | "Regular expression access list name\n") |
| 7373 | { |
| 7374 | if (strncmp (argv[0], "m", 1) == 0) |
| 7375 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7376 | bgp_show_type_filter_list); |
| 7377 | |
| 7378 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7379 | bgp_show_type_filter_list); |
| 7380 | } |
| 7381 | |
| 7382 | #ifdef HAVE_IPV6 |
| 7383 | DEFUN (show_bgp_filter_list, |
| 7384 | show_bgp_filter_list_cmd, |
| 7385 | "show bgp filter-list WORD", |
| 7386 | SHOW_STR |
| 7387 | BGP_STR |
| 7388 | "Display routes conforming to the filter-list\n" |
| 7389 | "Regular expression access list name\n") |
| 7390 | { |
| 7391 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7392 | bgp_show_type_filter_list); |
| 7393 | } |
| 7394 | |
| 7395 | ALIAS (show_bgp_filter_list, |
| 7396 | show_bgp_ipv6_filter_list_cmd, |
| 7397 | "show bgp ipv6 filter-list WORD", |
| 7398 | SHOW_STR |
| 7399 | BGP_STR |
| 7400 | "Address family\n" |
| 7401 | "Display routes conforming to the filter-list\n" |
| 7402 | "Regular expression access list name\n") |
| 7403 | |
| 7404 | /* old command */ |
| 7405 | DEFUN (show_ipv6_bgp_filter_list, |
| 7406 | show_ipv6_bgp_filter_list_cmd, |
| 7407 | "show ipv6 bgp filter-list WORD", |
| 7408 | SHOW_STR |
| 7409 | IPV6_STR |
| 7410 | BGP_STR |
| 7411 | "Display routes conforming to the filter-list\n" |
| 7412 | "Regular expression access list name\n") |
| 7413 | { |
| 7414 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7415 | bgp_show_type_filter_list); |
| 7416 | } |
| 7417 | |
| 7418 | /* old command */ |
| 7419 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7420 | show_ipv6_mbgp_filter_list_cmd, |
| 7421 | "show ipv6 mbgp filter-list WORD", |
| 7422 | SHOW_STR |
| 7423 | IPV6_STR |
| 7424 | MBGP_STR |
| 7425 | "Display routes conforming to the filter-list\n" |
| 7426 | "Regular expression access list name\n") |
| 7427 | { |
| 7428 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7429 | bgp_show_type_filter_list); |
| 7430 | } |
| 7431 | #endif /* HAVE_IPV6 */ |
| 7432 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7433 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7434 | 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] | 7435 | safi_t safi, enum bgp_show_type type) |
| 7436 | { |
| 7437 | struct route_map *rmap; |
| 7438 | |
| 7439 | rmap = route_map_lookup_by_name (rmap_str); |
| 7440 | if (! rmap) |
| 7441 | { |
| 7442 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7443 | rmap_str, VTY_NEWLINE); |
| 7444 | return CMD_WARNING; |
| 7445 | } |
| 7446 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7447 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7448 | } |
| 7449 | |
| 7450 | DEFUN (show_ip_bgp_route_map, |
| 7451 | show_ip_bgp_route_map_cmd, |
| 7452 | "show ip bgp route-map WORD", |
| 7453 | SHOW_STR |
| 7454 | IP_STR |
| 7455 | BGP_STR |
| 7456 | "Display routes matching the route-map\n" |
| 7457 | "A route-map to match on\n") |
| 7458 | { |
| 7459 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7460 | bgp_show_type_route_map); |
| 7461 | } |
| 7462 | |
| 7463 | DEFUN (show_ip_bgp_flap_route_map, |
| 7464 | show_ip_bgp_flap_route_map_cmd, |
| 7465 | "show ip bgp flap-statistics route-map WORD", |
| 7466 | SHOW_STR |
| 7467 | IP_STR |
| 7468 | BGP_STR |
| 7469 | "Display flap statistics of routes\n" |
| 7470 | "Display routes matching the route-map\n" |
| 7471 | "A route-map to match on\n") |
| 7472 | { |
| 7473 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7474 | bgp_show_type_flap_route_map); |
| 7475 | } |
| 7476 | |
| 7477 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7478 | show_ip_bgp_ipv4_route_map_cmd, |
| 7479 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7480 | SHOW_STR |
| 7481 | IP_STR |
| 7482 | BGP_STR |
| 7483 | "Address family\n" |
| 7484 | "Address Family modifier\n" |
| 7485 | "Address Family modifier\n" |
| 7486 | "Display routes matching the route-map\n" |
| 7487 | "A route-map to match on\n") |
| 7488 | { |
| 7489 | if (strncmp (argv[0], "m", 1) == 0) |
| 7490 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7491 | bgp_show_type_route_map); |
| 7492 | |
| 7493 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7494 | bgp_show_type_route_map); |
| 7495 | } |
| 7496 | |
| 7497 | DEFUN (show_bgp_route_map, |
| 7498 | show_bgp_route_map_cmd, |
| 7499 | "show bgp route-map WORD", |
| 7500 | SHOW_STR |
| 7501 | BGP_STR |
| 7502 | "Display routes matching the route-map\n" |
| 7503 | "A route-map to match on\n") |
| 7504 | { |
| 7505 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7506 | bgp_show_type_route_map); |
| 7507 | } |
| 7508 | |
| 7509 | ALIAS (show_bgp_route_map, |
| 7510 | show_bgp_ipv6_route_map_cmd, |
| 7511 | "show bgp ipv6 route-map WORD", |
| 7512 | SHOW_STR |
| 7513 | BGP_STR |
| 7514 | "Address family\n" |
| 7515 | "Display routes matching the route-map\n" |
| 7516 | "A route-map to match on\n") |
| 7517 | |
| 7518 | DEFUN (show_ip_bgp_cidr_only, |
| 7519 | show_ip_bgp_cidr_only_cmd, |
| 7520 | "show ip bgp cidr-only", |
| 7521 | SHOW_STR |
| 7522 | IP_STR |
| 7523 | BGP_STR |
| 7524 | "Display only routes with non-natural netmasks\n") |
| 7525 | { |
| 7526 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7527 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7528 | } |
| 7529 | |
| 7530 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7531 | show_ip_bgp_flap_cidr_only_cmd, |
| 7532 | "show ip bgp flap-statistics cidr-only", |
| 7533 | SHOW_STR |
| 7534 | IP_STR |
| 7535 | BGP_STR |
| 7536 | "Display flap statistics of routes\n" |
| 7537 | "Display only routes with non-natural netmasks\n") |
| 7538 | { |
| 7539 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7540 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7541 | } |
| 7542 | |
| 7543 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7544 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7545 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7546 | SHOW_STR |
| 7547 | IP_STR |
| 7548 | BGP_STR |
| 7549 | "Address family\n" |
| 7550 | "Address Family modifier\n" |
| 7551 | "Address Family modifier\n" |
| 7552 | "Display only routes with non-natural netmasks\n") |
| 7553 | { |
| 7554 | if (strncmp (argv[0], "m", 1) == 0) |
| 7555 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7556 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7557 | |
| 7558 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7559 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7560 | } |
| 7561 | |
| 7562 | DEFUN (show_ip_bgp_community_all, |
| 7563 | show_ip_bgp_community_all_cmd, |
| 7564 | "show ip bgp community", |
| 7565 | SHOW_STR |
| 7566 | IP_STR |
| 7567 | BGP_STR |
| 7568 | "Display routes matching the communities\n") |
| 7569 | { |
| 7570 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7571 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7572 | } |
| 7573 | |
| 7574 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7575 | show_ip_bgp_ipv4_community_all_cmd, |
| 7576 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7577 | SHOW_STR |
| 7578 | IP_STR |
| 7579 | BGP_STR |
| 7580 | "Address family\n" |
| 7581 | "Address Family modifier\n" |
| 7582 | "Address Family modifier\n" |
| 7583 | "Display routes matching the communities\n") |
| 7584 | { |
| 7585 | if (strncmp (argv[0], "m", 1) == 0) |
| 7586 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7587 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7588 | |
| 7589 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7590 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7591 | } |
| 7592 | |
| 7593 | #ifdef HAVE_IPV6 |
| 7594 | DEFUN (show_bgp_community_all, |
| 7595 | show_bgp_community_all_cmd, |
| 7596 | "show bgp community", |
| 7597 | SHOW_STR |
| 7598 | BGP_STR |
| 7599 | "Display routes matching the communities\n") |
| 7600 | { |
| 7601 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7602 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7603 | } |
| 7604 | |
| 7605 | ALIAS (show_bgp_community_all, |
| 7606 | show_bgp_ipv6_community_all_cmd, |
| 7607 | "show bgp ipv6 community", |
| 7608 | SHOW_STR |
| 7609 | BGP_STR |
| 7610 | "Address family\n" |
| 7611 | "Display routes matching the communities\n") |
| 7612 | |
| 7613 | /* old command */ |
| 7614 | DEFUN (show_ipv6_bgp_community_all, |
| 7615 | show_ipv6_bgp_community_all_cmd, |
| 7616 | "show ipv6 bgp community", |
| 7617 | SHOW_STR |
| 7618 | IPV6_STR |
| 7619 | BGP_STR |
| 7620 | "Display routes matching the communities\n") |
| 7621 | { |
| 7622 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7623 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7624 | } |
| 7625 | |
| 7626 | /* old command */ |
| 7627 | DEFUN (show_ipv6_mbgp_community_all, |
| 7628 | show_ipv6_mbgp_community_all_cmd, |
| 7629 | "show ipv6 mbgp community", |
| 7630 | SHOW_STR |
| 7631 | IPV6_STR |
| 7632 | MBGP_STR |
| 7633 | "Display routes matching the communities\n") |
| 7634 | { |
| 7635 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7636 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7637 | } |
| 7638 | #endif /* HAVE_IPV6 */ |
| 7639 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7640 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7641 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7642 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7643 | { |
| 7644 | struct community *com; |
| 7645 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7646 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7647 | int i; |
| 7648 | char *str; |
| 7649 | int first = 0; |
| 7650 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7651 | /* BGP structure lookup */ |
| 7652 | if (view_name) |
| 7653 | { |
| 7654 | bgp = bgp_lookup_by_name (view_name); |
| 7655 | if (bgp == NULL) |
| 7656 | { |
| 7657 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7658 | return CMD_WARNING; |
| 7659 | } |
| 7660 | } |
| 7661 | else |
| 7662 | { |
| 7663 | bgp = bgp_get_default (); |
| 7664 | if (bgp == NULL) |
| 7665 | { |
| 7666 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7667 | return CMD_WARNING; |
| 7668 | } |
| 7669 | } |
| 7670 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7671 | b = buffer_new (1024); |
| 7672 | for (i = 0; i < argc; i++) |
| 7673 | { |
| 7674 | if (first) |
| 7675 | buffer_putc (b, ' '); |
| 7676 | else |
| 7677 | { |
| 7678 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7679 | continue; |
| 7680 | first = 1; |
| 7681 | } |
| 7682 | |
| 7683 | buffer_putstr (b, argv[i]); |
| 7684 | } |
| 7685 | buffer_putc (b, '\0'); |
| 7686 | |
| 7687 | str = buffer_getstr (b); |
| 7688 | buffer_free (b); |
| 7689 | |
| 7690 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7691 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7692 | if (! com) |
| 7693 | { |
| 7694 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7695 | return CMD_WARNING; |
| 7696 | } |
| 7697 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7698 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7699 | (exact ? bgp_show_type_community_exact : |
| 7700 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7701 | } |
| 7702 | |
| 7703 | DEFUN (show_ip_bgp_community, |
| 7704 | show_ip_bgp_community_cmd, |
| 7705 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7706 | SHOW_STR |
| 7707 | IP_STR |
| 7708 | BGP_STR |
| 7709 | "Display routes matching the communities\n" |
| 7710 | "community number\n" |
| 7711 | "Do not send outside local AS (well-known community)\n" |
| 7712 | "Do not advertise to any peer (well-known community)\n" |
| 7713 | "Do not export to next AS (well-known community)\n") |
| 7714 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7715 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7716 | } |
| 7717 | |
| 7718 | ALIAS (show_ip_bgp_community, |
| 7719 | show_ip_bgp_community2_cmd, |
| 7720 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7721 | SHOW_STR |
| 7722 | IP_STR |
| 7723 | BGP_STR |
| 7724 | "Display routes matching the communities\n" |
| 7725 | "community number\n" |
| 7726 | "Do not send outside local AS (well-known community)\n" |
| 7727 | "Do not advertise to any peer (well-known community)\n" |
| 7728 | "Do not export to next AS (well-known community)\n" |
| 7729 | "community number\n" |
| 7730 | "Do not send outside local AS (well-known community)\n" |
| 7731 | "Do not advertise to any peer (well-known community)\n" |
| 7732 | "Do not export to next AS (well-known community)\n") |
| 7733 | |
| 7734 | ALIAS (show_ip_bgp_community, |
| 7735 | show_ip_bgp_community3_cmd, |
| 7736 | "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)", |
| 7737 | SHOW_STR |
| 7738 | IP_STR |
| 7739 | BGP_STR |
| 7740 | "Display routes matching the communities\n" |
| 7741 | "community number\n" |
| 7742 | "Do not send outside local AS (well-known community)\n" |
| 7743 | "Do not advertise to any peer (well-known community)\n" |
| 7744 | "Do not export to next AS (well-known community)\n" |
| 7745 | "community number\n" |
| 7746 | "Do not send outside local AS (well-known community)\n" |
| 7747 | "Do not advertise to any peer (well-known community)\n" |
| 7748 | "Do not export to next AS (well-known community)\n" |
| 7749 | "community number\n" |
| 7750 | "Do not send outside local AS (well-known community)\n" |
| 7751 | "Do not advertise to any peer (well-known community)\n" |
| 7752 | "Do not export to next AS (well-known community)\n") |
| 7753 | |
| 7754 | ALIAS (show_ip_bgp_community, |
| 7755 | show_ip_bgp_community4_cmd, |
| 7756 | "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)", |
| 7757 | SHOW_STR |
| 7758 | IP_STR |
| 7759 | BGP_STR |
| 7760 | "Display routes matching the communities\n" |
| 7761 | "community number\n" |
| 7762 | "Do not send outside local AS (well-known community)\n" |
| 7763 | "Do not advertise to any peer (well-known community)\n" |
| 7764 | "Do not export to next AS (well-known community)\n" |
| 7765 | "community number\n" |
| 7766 | "Do not send outside local AS (well-known community)\n" |
| 7767 | "Do not advertise to any peer (well-known community)\n" |
| 7768 | "Do not export to next AS (well-known community)\n" |
| 7769 | "community number\n" |
| 7770 | "Do not send outside local AS (well-known community)\n" |
| 7771 | "Do not advertise to any peer (well-known community)\n" |
| 7772 | "Do not export to next AS (well-known community)\n" |
| 7773 | "community number\n" |
| 7774 | "Do not send outside local AS (well-known community)\n" |
| 7775 | "Do not advertise to any peer (well-known community)\n" |
| 7776 | "Do not export to next AS (well-known community)\n") |
| 7777 | |
| 7778 | DEFUN (show_ip_bgp_ipv4_community, |
| 7779 | show_ip_bgp_ipv4_community_cmd, |
| 7780 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7781 | SHOW_STR |
| 7782 | IP_STR |
| 7783 | BGP_STR |
| 7784 | "Address family\n" |
| 7785 | "Address Family modifier\n" |
| 7786 | "Address Family modifier\n" |
| 7787 | "Display routes matching the communities\n" |
| 7788 | "community number\n" |
| 7789 | "Do not send outside local AS (well-known community)\n" |
| 7790 | "Do not advertise to any peer (well-known community)\n" |
| 7791 | "Do not export to next AS (well-known community)\n") |
| 7792 | { |
| 7793 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7794 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7795 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7796 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7797 | } |
| 7798 | |
| 7799 | ALIAS (show_ip_bgp_ipv4_community, |
| 7800 | show_ip_bgp_ipv4_community2_cmd, |
| 7801 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7802 | SHOW_STR |
| 7803 | IP_STR |
| 7804 | BGP_STR |
| 7805 | "Address family\n" |
| 7806 | "Address Family modifier\n" |
| 7807 | "Address Family modifier\n" |
| 7808 | "Display routes matching the communities\n" |
| 7809 | "community number\n" |
| 7810 | "Do not send outside local AS (well-known community)\n" |
| 7811 | "Do not advertise to any peer (well-known community)\n" |
| 7812 | "Do not export to next AS (well-known community)\n" |
| 7813 | "community number\n" |
| 7814 | "Do not send outside local AS (well-known community)\n" |
| 7815 | "Do not advertise to any peer (well-known community)\n" |
| 7816 | "Do not export to next AS (well-known community)\n") |
| 7817 | |
| 7818 | ALIAS (show_ip_bgp_ipv4_community, |
| 7819 | show_ip_bgp_ipv4_community3_cmd, |
| 7820 | "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)", |
| 7821 | SHOW_STR |
| 7822 | IP_STR |
| 7823 | BGP_STR |
| 7824 | "Address family\n" |
| 7825 | "Address Family modifier\n" |
| 7826 | "Address Family modifier\n" |
| 7827 | "Display routes matching the communities\n" |
| 7828 | "community number\n" |
| 7829 | "Do not send outside local AS (well-known community)\n" |
| 7830 | "Do not advertise to any peer (well-known community)\n" |
| 7831 | "Do not export to next AS (well-known community)\n" |
| 7832 | "community number\n" |
| 7833 | "Do not send outside local AS (well-known community)\n" |
| 7834 | "Do not advertise to any peer (well-known community)\n" |
| 7835 | "Do not export to next AS (well-known community)\n" |
| 7836 | "community number\n" |
| 7837 | "Do not send outside local AS (well-known community)\n" |
| 7838 | "Do not advertise to any peer (well-known community)\n" |
| 7839 | "Do not export to next AS (well-known community)\n") |
| 7840 | |
| 7841 | ALIAS (show_ip_bgp_ipv4_community, |
| 7842 | show_ip_bgp_ipv4_community4_cmd, |
| 7843 | "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)", |
| 7844 | SHOW_STR |
| 7845 | IP_STR |
| 7846 | BGP_STR |
| 7847 | "Address family\n" |
| 7848 | "Address Family modifier\n" |
| 7849 | "Address Family modifier\n" |
| 7850 | "Display routes matching the communities\n" |
| 7851 | "community number\n" |
| 7852 | "Do not send outside local AS (well-known community)\n" |
| 7853 | "Do not advertise to any peer (well-known community)\n" |
| 7854 | "Do not export to next AS (well-known community)\n" |
| 7855 | "community number\n" |
| 7856 | "Do not send outside local AS (well-known community)\n" |
| 7857 | "Do not advertise to any peer (well-known community)\n" |
| 7858 | "Do not export to next AS (well-known community)\n" |
| 7859 | "community number\n" |
| 7860 | "Do not send outside local AS (well-known community)\n" |
| 7861 | "Do not advertise to any peer (well-known community)\n" |
| 7862 | "Do not export to next AS (well-known community)\n" |
| 7863 | "community number\n" |
| 7864 | "Do not send outside local AS (well-known community)\n" |
| 7865 | "Do not advertise to any peer (well-known community)\n" |
| 7866 | "Do not export to next AS (well-known community)\n") |
| 7867 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7868 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 7869 | show_bgp_view_afi_safi_community_all_cmd, |
| 7870 | #ifdef HAVE_IPV6 |
| 7871 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
| 7872 | #else |
| 7873 | "show bgp view WORD ipv4 (unicast|multicast) community", |
| 7874 | #endif |
| 7875 | SHOW_STR |
| 7876 | BGP_STR |
| 7877 | "BGP view\n" |
| 7878 | "BGP view name\n" |
| 7879 | "Address family\n" |
| 7880 | #ifdef HAVE_IPV6 |
| 7881 | "Address family\n" |
| 7882 | #endif |
| 7883 | "Address Family modifier\n" |
| 7884 | "Address Family modifier\n" |
| 7885 | "Display routes containing communities\n") |
| 7886 | { |
| 7887 | int afi; |
| 7888 | int safi; |
| 7889 | struct bgp *bgp; |
| 7890 | |
| 7891 | /* BGP structure lookup. */ |
| 7892 | bgp = bgp_lookup_by_name (argv[0]); |
| 7893 | if (bgp == NULL) |
| 7894 | { |
| 7895 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7896 | return CMD_WARNING; |
| 7897 | } |
| 7898 | |
| 7899 | #ifdef HAVE_IPV6 |
| 7900 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7901 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7902 | #else |
| 7903 | afi = AFI_IP; |
| 7904 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7905 | #endif |
| 7906 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 7907 | } |
| 7908 | |
| 7909 | DEFUN (show_bgp_view_afi_safi_community, |
| 7910 | show_bgp_view_afi_safi_community_cmd, |
| 7911 | #ifdef HAVE_IPV6 |
| 7912 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7913 | #else |
| 7914 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7915 | #endif |
| 7916 | SHOW_STR |
| 7917 | BGP_STR |
| 7918 | "BGP view\n" |
| 7919 | "BGP view name\n" |
| 7920 | "Address family\n" |
| 7921 | #ifdef HAVE_IPV6 |
| 7922 | "Address family\n" |
| 7923 | #endif |
| 7924 | "Address family modifier\n" |
| 7925 | "Address family modifier\n" |
| 7926 | "Display routes matching the communities\n" |
| 7927 | "community number\n" |
| 7928 | "Do not send outside local AS (well-known community)\n" |
| 7929 | "Do not advertise to any peer (well-known community)\n" |
| 7930 | "Do not export to next AS (well-known community)\n") |
| 7931 | { |
| 7932 | int afi; |
| 7933 | int safi; |
| 7934 | |
| 7935 | #ifdef HAVE_IPV6 |
| 7936 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7937 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7938 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
| 7939 | #else |
| 7940 | afi = AFI_IP; |
| 7941 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7942 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); |
| 7943 | #endif |
| 7944 | } |
| 7945 | |
| 7946 | ALIAS (show_bgp_view_afi_safi_community, |
| 7947 | show_bgp_view_afi_safi_community2_cmd, |
| 7948 | #ifdef HAVE_IPV6 |
| 7949 | "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)", |
| 7950 | #else |
| 7951 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7952 | #endif |
| 7953 | SHOW_STR |
| 7954 | BGP_STR |
| 7955 | "BGP view\n" |
| 7956 | "BGP view name\n" |
| 7957 | "Address family\n" |
| 7958 | #ifdef HAVE_IPV6 |
| 7959 | "Address family\n" |
| 7960 | #endif |
| 7961 | "Address family modifier\n" |
| 7962 | "Address family modifier\n" |
| 7963 | "Display routes matching the communities\n" |
| 7964 | "community number\n" |
| 7965 | "Do not send outside local AS (well-known community)\n" |
| 7966 | "Do not advertise to any peer (well-known community)\n" |
| 7967 | "Do not export to next AS (well-known community)\n" |
| 7968 | "community number\n" |
| 7969 | "Do not send outside local AS (well-known community)\n" |
| 7970 | "Do not advertise to any peer (well-known community)\n" |
| 7971 | "Do not export to next AS (well-known community)\n") |
| 7972 | |
| 7973 | ALIAS (show_bgp_view_afi_safi_community, |
| 7974 | show_bgp_view_afi_safi_community3_cmd, |
| 7975 | #ifdef HAVE_IPV6 |
| 7976 | "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)", |
| 7977 | #else |
| 7978 | "show bgp view WORD 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)", |
| 7979 | #endif |
| 7980 | SHOW_STR |
| 7981 | BGP_STR |
| 7982 | "BGP view\n" |
| 7983 | "BGP view name\n" |
| 7984 | "Address family\n" |
| 7985 | #ifdef HAVE_IPV6 |
| 7986 | "Address family\n" |
| 7987 | #endif |
| 7988 | "Address family modifier\n" |
| 7989 | "Address family modifier\n" |
| 7990 | "Display routes matching the communities\n" |
| 7991 | "community number\n" |
| 7992 | "Do not send outside local AS (well-known community)\n" |
| 7993 | "Do not advertise to any peer (well-known community)\n" |
| 7994 | "Do not export to next AS (well-known community)\n" |
| 7995 | "community number\n" |
| 7996 | "Do not send outside local AS (well-known community)\n" |
| 7997 | "Do not advertise to any peer (well-known community)\n" |
| 7998 | "Do not export to next AS (well-known community)\n" |
| 7999 | "community number\n" |
| 8000 | "Do not send outside local AS (well-known community)\n" |
| 8001 | "Do not advertise to any peer (well-known community)\n" |
| 8002 | "Do not export to next AS (well-known community)\n") |
| 8003 | |
| 8004 | ALIAS (show_bgp_view_afi_safi_community, |
| 8005 | show_bgp_view_afi_safi_community4_cmd, |
| 8006 | #ifdef HAVE_IPV6 |
| 8007 | "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)", |
| 8008 | #else |
| 8009 | "show bgp view WORD 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)", |
| 8010 | #endif |
| 8011 | SHOW_STR |
| 8012 | BGP_STR |
| 8013 | "BGP view\n" |
| 8014 | "BGP view name\n" |
| 8015 | "Address family\n" |
| 8016 | #ifdef HAVE_IPV6 |
| 8017 | "Address family\n" |
| 8018 | #endif |
| 8019 | "Address family modifier\n" |
| 8020 | "Address family modifier\n" |
| 8021 | "Display routes matching the communities\n" |
| 8022 | "community number\n" |
| 8023 | "Do not send outside local AS (well-known community)\n" |
| 8024 | "Do not advertise to any peer (well-known community)\n" |
| 8025 | "Do not export to next AS (well-known community)\n" |
| 8026 | "community number\n" |
| 8027 | "Do not send outside local AS (well-known community)\n" |
| 8028 | "Do not advertise to any peer (well-known community)\n" |
| 8029 | "Do not export to next AS (well-known community)\n" |
| 8030 | "community number\n" |
| 8031 | "Do not send outside local AS (well-known community)\n" |
| 8032 | "Do not advertise to any peer (well-known community)\n" |
| 8033 | "Do not export to next AS (well-known community)\n" |
| 8034 | "community number\n" |
| 8035 | "Do not send outside local AS (well-known community)\n" |
| 8036 | "Do not advertise to any peer (well-known community)\n" |
| 8037 | "Do not export to next AS (well-known community)\n") |
| 8038 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8039 | DEFUN (show_ip_bgp_community_exact, |
| 8040 | show_ip_bgp_community_exact_cmd, |
| 8041 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8042 | SHOW_STR |
| 8043 | IP_STR |
| 8044 | BGP_STR |
| 8045 | "Display routes matching the communities\n" |
| 8046 | "community number\n" |
| 8047 | "Do not send outside local AS (well-known community)\n" |
| 8048 | "Do not advertise to any peer (well-known community)\n" |
| 8049 | "Do not export to next AS (well-known community)\n" |
| 8050 | "Exact match of the communities") |
| 8051 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8052 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8053 | } |
| 8054 | |
| 8055 | ALIAS (show_ip_bgp_community_exact, |
| 8056 | show_ip_bgp_community2_exact_cmd, |
| 8057 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8058 | SHOW_STR |
| 8059 | IP_STR |
| 8060 | BGP_STR |
| 8061 | "Display routes matching the communities\n" |
| 8062 | "community number\n" |
| 8063 | "Do not send outside local AS (well-known community)\n" |
| 8064 | "Do not advertise to any peer (well-known community)\n" |
| 8065 | "Do not export to next AS (well-known community)\n" |
| 8066 | "community number\n" |
| 8067 | "Do not send outside local AS (well-known community)\n" |
| 8068 | "Do not advertise to any peer (well-known community)\n" |
| 8069 | "Do not export to next AS (well-known community)\n" |
| 8070 | "Exact match of the communities") |
| 8071 | |
| 8072 | ALIAS (show_ip_bgp_community_exact, |
| 8073 | show_ip_bgp_community3_exact_cmd, |
| 8074 | "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", |
| 8075 | SHOW_STR |
| 8076 | IP_STR |
| 8077 | BGP_STR |
| 8078 | "Display routes matching the communities\n" |
| 8079 | "community number\n" |
| 8080 | "Do not send outside local AS (well-known community)\n" |
| 8081 | "Do not advertise to any peer (well-known community)\n" |
| 8082 | "Do not export to next AS (well-known community)\n" |
| 8083 | "community number\n" |
| 8084 | "Do not send outside local AS (well-known community)\n" |
| 8085 | "Do not advertise to any peer (well-known community)\n" |
| 8086 | "Do not export to next AS (well-known community)\n" |
| 8087 | "community number\n" |
| 8088 | "Do not send outside local AS (well-known community)\n" |
| 8089 | "Do not advertise to any peer (well-known community)\n" |
| 8090 | "Do not export to next AS (well-known community)\n" |
| 8091 | "Exact match of the communities") |
| 8092 | |
| 8093 | ALIAS (show_ip_bgp_community_exact, |
| 8094 | show_ip_bgp_community4_exact_cmd, |
| 8095 | "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", |
| 8096 | SHOW_STR |
| 8097 | IP_STR |
| 8098 | BGP_STR |
| 8099 | "Display routes matching the communities\n" |
| 8100 | "community number\n" |
| 8101 | "Do not send outside local AS (well-known community)\n" |
| 8102 | "Do not advertise to any peer (well-known community)\n" |
| 8103 | "Do not export to next AS (well-known community)\n" |
| 8104 | "community number\n" |
| 8105 | "Do not send outside local AS (well-known community)\n" |
| 8106 | "Do not advertise to any peer (well-known community)\n" |
| 8107 | "Do not export to next AS (well-known community)\n" |
| 8108 | "community number\n" |
| 8109 | "Do not send outside local AS (well-known community)\n" |
| 8110 | "Do not advertise to any peer (well-known community)\n" |
| 8111 | "Do not export to next AS (well-known community)\n" |
| 8112 | "community number\n" |
| 8113 | "Do not send outside local AS (well-known community)\n" |
| 8114 | "Do not advertise to any peer (well-known community)\n" |
| 8115 | "Do not export to next AS (well-known community)\n" |
| 8116 | "Exact match of the communities") |
| 8117 | |
| 8118 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8119 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8120 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8121 | SHOW_STR |
| 8122 | IP_STR |
| 8123 | BGP_STR |
| 8124 | "Address family\n" |
| 8125 | "Address Family modifier\n" |
| 8126 | "Address Family modifier\n" |
| 8127 | "Display routes matching the communities\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 | "Exact match of the communities") |
| 8133 | { |
| 8134 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8135 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8136 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8137 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8138 | } |
| 8139 | |
| 8140 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8141 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8142 | "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", |
| 8143 | SHOW_STR |
| 8144 | IP_STR |
| 8145 | BGP_STR |
| 8146 | "Address family\n" |
| 8147 | "Address Family modifier\n" |
| 8148 | "Address Family modifier\n" |
| 8149 | "Display routes matching the communities\n" |
| 8150 | "community number\n" |
| 8151 | "Do not send outside local AS (well-known community)\n" |
| 8152 | "Do not advertise to any peer (well-known community)\n" |
| 8153 | "Do not export to next AS (well-known community)\n" |
| 8154 | "community number\n" |
| 8155 | "Do not send outside local AS (well-known community)\n" |
| 8156 | "Do not advertise to any peer (well-known community)\n" |
| 8157 | "Do not export to next AS (well-known community)\n" |
| 8158 | "Exact match of the communities") |
| 8159 | |
| 8160 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8161 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8162 | "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", |
| 8163 | SHOW_STR |
| 8164 | IP_STR |
| 8165 | BGP_STR |
| 8166 | "Address family\n" |
| 8167 | "Address Family modifier\n" |
| 8168 | "Address Family modifier\n" |
| 8169 | "Display routes matching the communities\n" |
| 8170 | "community number\n" |
| 8171 | "Do not send outside local AS (well-known community)\n" |
| 8172 | "Do not advertise to any peer (well-known community)\n" |
| 8173 | "Do not export to next AS (well-known community)\n" |
| 8174 | "community number\n" |
| 8175 | "Do not send outside local AS (well-known community)\n" |
| 8176 | "Do not advertise to any peer (well-known community)\n" |
| 8177 | "Do not export to next AS (well-known community)\n" |
| 8178 | "community number\n" |
| 8179 | "Do not send outside local AS (well-known community)\n" |
| 8180 | "Do not advertise to any peer (well-known community)\n" |
| 8181 | "Do not export to next AS (well-known community)\n" |
| 8182 | "Exact match of the communities") |
| 8183 | |
| 8184 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8185 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8186 | "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", |
| 8187 | SHOW_STR |
| 8188 | IP_STR |
| 8189 | BGP_STR |
| 8190 | "Address family\n" |
| 8191 | "Address Family modifier\n" |
| 8192 | "Address Family modifier\n" |
| 8193 | "Display routes matching the communities\n" |
| 8194 | "community number\n" |
| 8195 | "Do not send outside local AS (well-known community)\n" |
| 8196 | "Do not advertise to any peer (well-known community)\n" |
| 8197 | "Do not export to next AS (well-known community)\n" |
| 8198 | "community number\n" |
| 8199 | "Do not send outside local AS (well-known community)\n" |
| 8200 | "Do not advertise to any peer (well-known community)\n" |
| 8201 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 8211 | |
| 8212 | #ifdef HAVE_IPV6 |
| 8213 | DEFUN (show_bgp_community, |
| 8214 | show_bgp_community_cmd, |
| 8215 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8216 | SHOW_STR |
| 8217 | BGP_STR |
| 8218 | "Display routes matching the communities\n" |
| 8219 | "community number\n" |
| 8220 | "Do not send outside local AS (well-known community)\n" |
| 8221 | "Do not advertise to any peer (well-known community)\n" |
| 8222 | "Do not export to next AS (well-known community)\n") |
| 8223 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8224 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8225 | } |
| 8226 | |
| 8227 | ALIAS (show_bgp_community, |
| 8228 | show_bgp_ipv6_community_cmd, |
| 8229 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8230 | SHOW_STR |
| 8231 | BGP_STR |
| 8232 | "Address family\n" |
| 8233 | "Display routes matching the communities\n" |
| 8234 | "community number\n" |
| 8235 | "Do not send outside local AS (well-known community)\n" |
| 8236 | "Do not advertise to any peer (well-known community)\n" |
| 8237 | "Do not export to next AS (well-known community)\n") |
| 8238 | |
| 8239 | ALIAS (show_bgp_community, |
| 8240 | show_bgp_community2_cmd, |
| 8241 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8242 | SHOW_STR |
| 8243 | BGP_STR |
| 8244 | "Display routes matching the communities\n" |
| 8245 | "community number\n" |
| 8246 | "Do not send outside local AS (well-known community)\n" |
| 8247 | "Do not advertise to any peer (well-known community)\n" |
| 8248 | "Do not export to next AS (well-known community)\n" |
| 8249 | "community number\n" |
| 8250 | "Do not send outside local AS (well-known community)\n" |
| 8251 | "Do not advertise to any peer (well-known community)\n" |
| 8252 | "Do not export to next AS (well-known community)\n") |
| 8253 | |
| 8254 | ALIAS (show_bgp_community, |
| 8255 | show_bgp_ipv6_community2_cmd, |
| 8256 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8257 | SHOW_STR |
| 8258 | BGP_STR |
| 8259 | "Address family\n" |
| 8260 | "Display routes matching the communities\n" |
| 8261 | "community number\n" |
| 8262 | "Do not send outside local AS (well-known community)\n" |
| 8263 | "Do not advertise to any peer (well-known community)\n" |
| 8264 | "Do not export to next AS (well-known community)\n" |
| 8265 | "community number\n" |
| 8266 | "Do not send outside local AS (well-known community)\n" |
| 8267 | "Do not advertise to any peer (well-known community)\n" |
| 8268 | "Do not export to next AS (well-known community)\n") |
| 8269 | |
| 8270 | ALIAS (show_bgp_community, |
| 8271 | show_bgp_community3_cmd, |
| 8272 | "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)", |
| 8273 | SHOW_STR |
| 8274 | BGP_STR |
| 8275 | "Display routes matching the communities\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 | "community number\n" |
| 8285 | "Do not send outside local AS (well-known community)\n" |
| 8286 | "Do not advertise to any peer (well-known community)\n" |
| 8287 | "Do not export to next AS (well-known community)\n") |
| 8288 | |
| 8289 | ALIAS (show_bgp_community, |
| 8290 | show_bgp_ipv6_community3_cmd, |
| 8291 | "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)", |
| 8292 | SHOW_STR |
| 8293 | BGP_STR |
| 8294 | "Address family\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 | |
| 8309 | ALIAS (show_bgp_community, |
| 8310 | show_bgp_community4_cmd, |
| 8311 | "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)", |
| 8312 | SHOW_STR |
| 8313 | BGP_STR |
| 8314 | "Display routes matching the communities\n" |
| 8315 | "community number\n" |
| 8316 | "Do not send outside local AS (well-known community)\n" |
| 8317 | "Do not advertise to any peer (well-known community)\n" |
| 8318 | "Do not export to next AS (well-known community)\n" |
| 8319 | "community number\n" |
| 8320 | "Do not send outside local AS (well-known community)\n" |
| 8321 | "Do not advertise to any peer (well-known community)\n" |
| 8322 | "Do not export to next AS (well-known community)\n" |
| 8323 | "community number\n" |
| 8324 | "Do not send outside local AS (well-known community)\n" |
| 8325 | "Do not advertise to any peer (well-known community)\n" |
| 8326 | "Do not export to next AS (well-known community)\n" |
| 8327 | "community number\n" |
| 8328 | "Do not send outside local AS (well-known community)\n" |
| 8329 | "Do not advertise to any peer (well-known community)\n" |
| 8330 | "Do not export to next AS (well-known community)\n") |
| 8331 | |
| 8332 | ALIAS (show_bgp_community, |
| 8333 | show_bgp_ipv6_community4_cmd, |
| 8334 | "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)", |
| 8335 | SHOW_STR |
| 8336 | BGP_STR |
| 8337 | "Address family\n" |
| 8338 | "Display routes matching the communities\n" |
| 8339 | "community number\n" |
| 8340 | "Do not send outside local AS (well-known community)\n" |
| 8341 | "Do not advertise to any peer (well-known community)\n" |
| 8342 | "Do not export to next AS (well-known community)\n" |
| 8343 | "community number\n" |
| 8344 | "Do not send outside local AS (well-known community)\n" |
| 8345 | "Do not advertise to any peer (well-known community)\n" |
| 8346 | "Do not export to next AS (well-known community)\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 | /* old command */ |
| 8357 | DEFUN (show_ipv6_bgp_community, |
| 8358 | show_ipv6_bgp_community_cmd, |
| 8359 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8360 | SHOW_STR |
| 8361 | IPV6_STR |
| 8362 | BGP_STR |
| 8363 | "Display routes matching the communities\n" |
| 8364 | "community number\n" |
| 8365 | "Do not send outside local AS (well-known community)\n" |
| 8366 | "Do not advertise to any peer (well-known community)\n" |
| 8367 | "Do not export to next AS (well-known community)\n") |
| 8368 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8369 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8370 | } |
| 8371 | |
| 8372 | /* old command */ |
| 8373 | ALIAS (show_ipv6_bgp_community, |
| 8374 | show_ipv6_bgp_community2_cmd, |
| 8375 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8376 | SHOW_STR |
| 8377 | IPV6_STR |
| 8378 | BGP_STR |
| 8379 | "Display routes matching the communities\n" |
| 8380 | "community number\n" |
| 8381 | "Do not send outside local AS (well-known community)\n" |
| 8382 | "Do not advertise to any peer (well-known community)\n" |
| 8383 | "Do not export to next AS (well-known community)\n" |
| 8384 | "community number\n" |
| 8385 | "Do not send outside local AS (well-known community)\n" |
| 8386 | "Do not advertise to any peer (well-known community)\n" |
| 8387 | "Do not export to next AS (well-known community)\n") |
| 8388 | |
| 8389 | /* old command */ |
| 8390 | ALIAS (show_ipv6_bgp_community, |
| 8391 | show_ipv6_bgp_community3_cmd, |
| 8392 | "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)", |
| 8393 | SHOW_STR |
| 8394 | IPV6_STR |
| 8395 | BGP_STR |
| 8396 | "Display routes matching the communities\n" |
| 8397 | "community number\n" |
| 8398 | "Do not send outside local AS (well-known community)\n" |
| 8399 | "Do not advertise to any peer (well-known community)\n" |
| 8400 | "Do not export to next AS (well-known community)\n" |
| 8401 | "community number\n" |
| 8402 | "Do not send outside local AS (well-known community)\n" |
| 8403 | "Do not advertise to any peer (well-known community)\n" |
| 8404 | "Do not export to next AS (well-known community)\n" |
| 8405 | "community number\n" |
| 8406 | "Do not send outside local AS (well-known community)\n" |
| 8407 | "Do not advertise to any peer (well-known community)\n" |
| 8408 | "Do not export to next AS (well-known community)\n") |
| 8409 | |
| 8410 | /* old command */ |
| 8411 | ALIAS (show_ipv6_bgp_community, |
| 8412 | show_ipv6_bgp_community4_cmd, |
| 8413 | "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)", |
| 8414 | SHOW_STR |
| 8415 | IPV6_STR |
| 8416 | BGP_STR |
| 8417 | "Display routes matching the communities\n" |
| 8418 | "community number\n" |
| 8419 | "Do not send outside local AS (well-known community)\n" |
| 8420 | "Do not advertise to any peer (well-known community)\n" |
| 8421 | "Do not export to next AS (well-known community)\n" |
| 8422 | "community number\n" |
| 8423 | "Do not send outside local AS (well-known community)\n" |
| 8424 | "Do not advertise to any peer (well-known community)\n" |
| 8425 | "Do not export to next AS (well-known community)\n" |
| 8426 | "community number\n" |
| 8427 | "Do not send outside local AS (well-known community)\n" |
| 8428 | "Do not advertise to any peer (well-known community)\n" |
| 8429 | "Do not export to next AS (well-known community)\n" |
| 8430 | "community number\n" |
| 8431 | "Do not send outside local AS (well-known community)\n" |
| 8432 | "Do not advertise to any peer (well-known community)\n" |
| 8433 | "Do not export to next AS (well-known community)\n") |
| 8434 | |
| 8435 | DEFUN (show_bgp_community_exact, |
| 8436 | show_bgp_community_exact_cmd, |
| 8437 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8438 | SHOW_STR |
| 8439 | BGP_STR |
| 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 | "Exact match of the communities") |
| 8446 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8447 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8448 | } |
| 8449 | |
| 8450 | ALIAS (show_bgp_community_exact, |
| 8451 | show_bgp_ipv6_community_exact_cmd, |
| 8452 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8453 | SHOW_STR |
| 8454 | BGP_STR |
| 8455 | "Address family\n" |
| 8456 | "Display routes matching the communities\n" |
| 8457 | "community number\n" |
| 8458 | "Do not send outside local AS (well-known community)\n" |
| 8459 | "Do not advertise to any peer (well-known community)\n" |
| 8460 | "Do not export to next AS (well-known community)\n" |
| 8461 | "Exact match of the communities") |
| 8462 | |
| 8463 | ALIAS (show_bgp_community_exact, |
| 8464 | show_bgp_community2_exact_cmd, |
| 8465 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8466 | SHOW_STR |
| 8467 | BGP_STR |
| 8468 | "Display routes matching the communities\n" |
| 8469 | "community number\n" |
| 8470 | "Do not send outside local AS (well-known community)\n" |
| 8471 | "Do not advertise to any peer (well-known community)\n" |
| 8472 | "Do not export to next AS (well-known community)\n" |
| 8473 | "community number\n" |
| 8474 | "Do not send outside local AS (well-known community)\n" |
| 8475 | "Do not advertise to any peer (well-known community)\n" |
| 8476 | "Do not export to next AS (well-known community)\n" |
| 8477 | "Exact match of the communities") |
| 8478 | |
| 8479 | ALIAS (show_bgp_community_exact, |
| 8480 | show_bgp_ipv6_community2_exact_cmd, |
| 8481 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8482 | SHOW_STR |
| 8483 | BGP_STR |
| 8484 | "Address family\n" |
| 8485 | "Display routes matching the communities\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 | "community number\n" |
| 8491 | "Do not send outside local AS (well-known community)\n" |
| 8492 | "Do not advertise to any peer (well-known community)\n" |
| 8493 | "Do not export to next AS (well-known community)\n" |
| 8494 | "Exact match of the communities") |
| 8495 | |
| 8496 | ALIAS (show_bgp_community_exact, |
| 8497 | show_bgp_community3_exact_cmd, |
| 8498 | "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", |
| 8499 | SHOW_STR |
| 8500 | BGP_STR |
| 8501 | "Display routes matching the communities\n" |
| 8502 | "community number\n" |
| 8503 | "Do not send outside local AS (well-known community)\n" |
| 8504 | "Do not advertise to any peer (well-known community)\n" |
| 8505 | "Do not export to next AS (well-known community)\n" |
| 8506 | "community number\n" |
| 8507 | "Do not send outside local AS (well-known community)\n" |
| 8508 | "Do not advertise to any peer (well-known community)\n" |
| 8509 | "Do not export to next AS (well-known community)\n" |
| 8510 | "community number\n" |
| 8511 | "Do not send outside local AS (well-known community)\n" |
| 8512 | "Do not advertise to any peer (well-known community)\n" |
| 8513 | "Do not export to next AS (well-known community)\n" |
| 8514 | "Exact match of the communities") |
| 8515 | |
| 8516 | ALIAS (show_bgp_community_exact, |
| 8517 | show_bgp_ipv6_community3_exact_cmd, |
| 8518 | "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", |
| 8519 | SHOW_STR |
| 8520 | BGP_STR |
| 8521 | "Address family\n" |
| 8522 | "Display routes matching the communities\n" |
| 8523 | "community number\n" |
| 8524 | "Do not send outside local AS (well-known community)\n" |
| 8525 | "Do not advertise to any peer (well-known community)\n" |
| 8526 | "Do not export to next AS (well-known community)\n" |
| 8527 | "community number\n" |
| 8528 | "Do not send outside local AS (well-known community)\n" |
| 8529 | "Do not advertise to any peer (well-known community)\n" |
| 8530 | "Do not export to next AS (well-known community)\n" |
| 8531 | "community number\n" |
| 8532 | "Do not send outside local AS (well-known community)\n" |
| 8533 | "Do not advertise to any peer (well-known community)\n" |
| 8534 | "Do not export to next AS (well-known community)\n" |
| 8535 | "Exact match of the communities") |
| 8536 | |
| 8537 | ALIAS (show_bgp_community_exact, |
| 8538 | show_bgp_community4_exact_cmd, |
| 8539 | "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", |
| 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 | "community number\n" |
| 8548 | "Do not send outside local AS (well-known community)\n" |
| 8549 | "Do not advertise to any peer (well-known community)\n" |
| 8550 | "Do not export to next AS (well-known community)\n" |
| 8551 | "community number\n" |
| 8552 | "Do not send outside local AS (well-known community)\n" |
| 8553 | "Do not advertise to any peer (well-known community)\n" |
| 8554 | "Do not export to next AS (well-known community)\n" |
| 8555 | "community number\n" |
| 8556 | "Do not send outside local AS (well-known community)\n" |
| 8557 | "Do not advertise to any peer (well-known community)\n" |
| 8558 | "Do not export to next AS (well-known community)\n" |
| 8559 | "Exact match of the communities") |
| 8560 | |
| 8561 | ALIAS (show_bgp_community_exact, |
| 8562 | show_bgp_ipv6_community4_exact_cmd, |
| 8563 | "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", |
| 8564 | SHOW_STR |
| 8565 | BGP_STR |
| 8566 | "Address family\n" |
| 8567 | "Display routes matching the communities\n" |
| 8568 | "community number\n" |
| 8569 | "Do not send outside local AS (well-known community)\n" |
| 8570 | "Do not advertise to any peer (well-known community)\n" |
| 8571 | "Do not export to next AS (well-known community)\n" |
| 8572 | "community number\n" |
| 8573 | "Do not send outside local AS (well-known community)\n" |
| 8574 | "Do not advertise to any peer (well-known community)\n" |
| 8575 | "Do not export to next AS (well-known community)\n" |
| 8576 | "community number\n" |
| 8577 | "Do not send outside local AS (well-known community)\n" |
| 8578 | "Do not advertise to any peer (well-known community)\n" |
| 8579 | "Do not export to next AS (well-known community)\n" |
| 8580 | "community number\n" |
| 8581 | "Do not send outside local AS (well-known community)\n" |
| 8582 | "Do not advertise to any peer (well-known community)\n" |
| 8583 | "Do not export to next AS (well-known community)\n" |
| 8584 | "Exact match of the communities") |
| 8585 | |
| 8586 | /* old command */ |
| 8587 | DEFUN (show_ipv6_bgp_community_exact, |
| 8588 | show_ipv6_bgp_community_exact_cmd, |
| 8589 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8590 | SHOW_STR |
| 8591 | IPV6_STR |
| 8592 | BGP_STR |
| 8593 | "Display routes matching the communities\n" |
| 8594 | "community number\n" |
| 8595 | "Do not send outside local AS (well-known community)\n" |
| 8596 | "Do not advertise to any peer (well-known community)\n" |
| 8597 | "Do not export to next AS (well-known community)\n" |
| 8598 | "Exact match of the communities") |
| 8599 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8600 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8601 | } |
| 8602 | |
| 8603 | /* old command */ |
| 8604 | ALIAS (show_ipv6_bgp_community_exact, |
| 8605 | show_ipv6_bgp_community2_exact_cmd, |
| 8606 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8607 | SHOW_STR |
| 8608 | IPV6_STR |
| 8609 | BGP_STR |
| 8610 | "Display routes matching the communities\n" |
| 8611 | "community number\n" |
| 8612 | "Do not send outside local AS (well-known community)\n" |
| 8613 | "Do not advertise to any peer (well-known community)\n" |
| 8614 | "Do not export to next AS (well-known community)\n" |
| 8615 | "community number\n" |
| 8616 | "Do not send outside local AS (well-known community)\n" |
| 8617 | "Do not advertise to any peer (well-known community)\n" |
| 8618 | "Do not export to next AS (well-known community)\n" |
| 8619 | "Exact match of the communities") |
| 8620 | |
| 8621 | /* old command */ |
| 8622 | ALIAS (show_ipv6_bgp_community_exact, |
| 8623 | show_ipv6_bgp_community3_exact_cmd, |
| 8624 | "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", |
| 8625 | SHOW_STR |
| 8626 | IPV6_STR |
| 8627 | BGP_STR |
| 8628 | "Display routes matching the communities\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 | "community number\n" |
| 8638 | "Do not send outside local AS (well-known community)\n" |
| 8639 | "Do not advertise to any peer (well-known community)\n" |
| 8640 | "Do not export to next AS (well-known community)\n" |
| 8641 | "Exact match of the communities") |
| 8642 | |
| 8643 | /* old command */ |
| 8644 | ALIAS (show_ipv6_bgp_community_exact, |
| 8645 | show_ipv6_bgp_community4_exact_cmd, |
| 8646 | "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", |
| 8647 | SHOW_STR |
| 8648 | IPV6_STR |
| 8649 | BGP_STR |
| 8650 | "Display routes matching the communities\n" |
| 8651 | "community number\n" |
| 8652 | "Do not send outside local AS (well-known community)\n" |
| 8653 | "Do not advertise to any peer (well-known community)\n" |
| 8654 | "Do not export to next AS (well-known community)\n" |
| 8655 | "community number\n" |
| 8656 | "Do not send outside local AS (well-known community)\n" |
| 8657 | "Do not advertise to any peer (well-known community)\n" |
| 8658 | "Do not export to next AS (well-known community)\n" |
| 8659 | "community number\n" |
| 8660 | "Do not send outside local AS (well-known community)\n" |
| 8661 | "Do not advertise to any peer (well-known community)\n" |
| 8662 | "Do not export to next AS (well-known community)\n" |
| 8663 | "community number\n" |
| 8664 | "Do not send outside local AS (well-known community)\n" |
| 8665 | "Do not advertise to any peer (well-known community)\n" |
| 8666 | "Do not export to next AS (well-known community)\n" |
| 8667 | "Exact match of the communities") |
| 8668 | |
| 8669 | /* old command */ |
| 8670 | DEFUN (show_ipv6_mbgp_community, |
| 8671 | show_ipv6_mbgp_community_cmd, |
| 8672 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8673 | SHOW_STR |
| 8674 | IPV6_STR |
| 8675 | MBGP_STR |
| 8676 | "Display routes matching the communities\n" |
| 8677 | "community number\n" |
| 8678 | "Do not send outside local AS (well-known community)\n" |
| 8679 | "Do not advertise to any peer (well-known community)\n" |
| 8680 | "Do not export to next AS (well-known community)\n") |
| 8681 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8682 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8683 | } |
| 8684 | |
| 8685 | /* old command */ |
| 8686 | ALIAS (show_ipv6_mbgp_community, |
| 8687 | show_ipv6_mbgp_community2_cmd, |
| 8688 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8689 | SHOW_STR |
| 8690 | IPV6_STR |
| 8691 | MBGP_STR |
| 8692 | "Display routes matching the communities\n" |
| 8693 | "community number\n" |
| 8694 | "Do not send outside local AS (well-known community)\n" |
| 8695 | "Do not advertise to any peer (well-known community)\n" |
| 8696 | "Do not export to next AS (well-known community)\n" |
| 8697 | "community number\n" |
| 8698 | "Do not send outside local AS (well-known community)\n" |
| 8699 | "Do not advertise to any peer (well-known community)\n" |
| 8700 | "Do not export to next AS (well-known community)\n") |
| 8701 | |
| 8702 | /* old command */ |
| 8703 | ALIAS (show_ipv6_mbgp_community, |
| 8704 | show_ipv6_mbgp_community3_cmd, |
| 8705 | "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)", |
| 8706 | SHOW_STR |
| 8707 | IPV6_STR |
| 8708 | MBGP_STR |
| 8709 | "Display routes matching the communities\n" |
| 8710 | "community number\n" |
| 8711 | "Do not send outside local AS (well-known community)\n" |
| 8712 | "Do not advertise to any peer (well-known community)\n" |
| 8713 | "Do not export to next AS (well-known community)\n" |
| 8714 | "community number\n" |
| 8715 | "Do not send outside local AS (well-known community)\n" |
| 8716 | "Do not advertise to any peer (well-known community)\n" |
| 8717 | "Do not export to next AS (well-known community)\n" |
| 8718 | "community number\n" |
| 8719 | "Do not send outside local AS (well-known community)\n" |
| 8720 | "Do not advertise to any peer (well-known community)\n" |
| 8721 | "Do not export to next AS (well-known community)\n") |
| 8722 | |
| 8723 | /* old command */ |
| 8724 | ALIAS (show_ipv6_mbgp_community, |
| 8725 | show_ipv6_mbgp_community4_cmd, |
| 8726 | "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)", |
| 8727 | SHOW_STR |
| 8728 | IPV6_STR |
| 8729 | MBGP_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 | "community number\n" |
| 8744 | "Do not send outside local AS (well-known community)\n" |
| 8745 | "Do not advertise to any peer (well-known community)\n" |
| 8746 | "Do not export to next AS (well-known community)\n") |
| 8747 | |
| 8748 | /* old command */ |
| 8749 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8750 | show_ipv6_mbgp_community_exact_cmd, |
| 8751 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8752 | SHOW_STR |
| 8753 | IPV6_STR |
| 8754 | MBGP_STR |
| 8755 | "Display routes matching the communities\n" |
| 8756 | "community number\n" |
| 8757 | "Do not send outside local AS (well-known community)\n" |
| 8758 | "Do not advertise to any peer (well-known community)\n" |
| 8759 | "Do not export to next AS (well-known community)\n" |
| 8760 | "Exact match of the communities") |
| 8761 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8762 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8763 | } |
| 8764 | |
| 8765 | /* old command */ |
| 8766 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8767 | show_ipv6_mbgp_community2_exact_cmd, |
| 8768 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8769 | SHOW_STR |
| 8770 | IPV6_STR |
| 8771 | MBGP_STR |
| 8772 | "Display routes matching the communities\n" |
| 8773 | "community number\n" |
| 8774 | "Do not send outside local AS (well-known community)\n" |
| 8775 | "Do not advertise to any peer (well-known community)\n" |
| 8776 | "Do not export to next AS (well-known community)\n" |
| 8777 | "community number\n" |
| 8778 | "Do not send outside local AS (well-known community)\n" |
| 8779 | "Do not advertise to any peer (well-known community)\n" |
| 8780 | "Do not export to next AS (well-known community)\n" |
| 8781 | "Exact match of the communities") |
| 8782 | |
| 8783 | /* old command */ |
| 8784 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8785 | show_ipv6_mbgp_community3_exact_cmd, |
| 8786 | "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", |
| 8787 | SHOW_STR |
| 8788 | IPV6_STR |
| 8789 | MBGP_STR |
| 8790 | "Display routes matching the communities\n" |
| 8791 | "community number\n" |
| 8792 | "Do not send outside local AS (well-known community)\n" |
| 8793 | "Do not advertise to any peer (well-known community)\n" |
| 8794 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 8804 | |
| 8805 | /* old command */ |
| 8806 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8807 | show_ipv6_mbgp_community4_exact_cmd, |
| 8808 | "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", |
| 8809 | SHOW_STR |
| 8810 | IPV6_STR |
| 8811 | MBGP_STR |
| 8812 | "Display routes matching the communities\n" |
| 8813 | "community number\n" |
| 8814 | "Do not send outside local AS (well-known community)\n" |
| 8815 | "Do not advertise to any peer (well-known community)\n" |
| 8816 | "Do not export to next AS (well-known community)\n" |
| 8817 | "community number\n" |
| 8818 | "Do not send outside local AS (well-known community)\n" |
| 8819 | "Do not advertise to any peer (well-known community)\n" |
| 8820 | "Do not export to next AS (well-known community)\n" |
| 8821 | "community number\n" |
| 8822 | "Do not send outside local AS (well-known community)\n" |
| 8823 | "Do not advertise to any peer (well-known community)\n" |
| 8824 | "Do not export to next AS (well-known community)\n" |
| 8825 | "community number\n" |
| 8826 | "Do not send outside local AS (well-known community)\n" |
| 8827 | "Do not advertise to any peer (well-known community)\n" |
| 8828 | "Do not export to next AS (well-known community)\n" |
| 8829 | "Exact match of the communities") |
| 8830 | #endif /* HAVE_IPV6 */ |
| 8831 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8832 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8833 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8834 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8835 | { |
| 8836 | struct community_list *list; |
| 8837 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8838 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8839 | if (list == NULL) |
| 8840 | { |
| 8841 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8842 | VTY_NEWLINE); |
| 8843 | return CMD_WARNING; |
| 8844 | } |
| 8845 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8846 | return bgp_show (vty, NULL, afi, safi, |
| 8847 | (exact ? bgp_show_type_community_list_exact : |
| 8848 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8849 | } |
| 8850 | |
| 8851 | DEFUN (show_ip_bgp_community_list, |
| 8852 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8853 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8854 | SHOW_STR |
| 8855 | IP_STR |
| 8856 | BGP_STR |
| 8857 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8858 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8859 | "community-list name\n") |
| 8860 | { |
| 8861 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8862 | } |
| 8863 | |
| 8864 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8865 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8866 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8867 | SHOW_STR |
| 8868 | IP_STR |
| 8869 | BGP_STR |
| 8870 | "Address family\n" |
| 8871 | "Address Family modifier\n" |
| 8872 | "Address Family modifier\n" |
| 8873 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8874 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8875 | "community-list name\n") |
| 8876 | { |
| 8877 | if (strncmp (argv[0], "m", 1) == 0) |
| 8878 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8879 | |
| 8880 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8881 | } |
| 8882 | |
| 8883 | DEFUN (show_ip_bgp_community_list_exact, |
| 8884 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8885 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8886 | SHOW_STR |
| 8887 | IP_STR |
| 8888 | BGP_STR |
| 8889 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8890 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8891 | "community-list name\n" |
| 8892 | "Exact match of the communities\n") |
| 8893 | { |
| 8894 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8895 | } |
| 8896 | |
| 8897 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8898 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8899 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8900 | SHOW_STR |
| 8901 | IP_STR |
| 8902 | BGP_STR |
| 8903 | "Address family\n" |
| 8904 | "Address Family modifier\n" |
| 8905 | "Address Family modifier\n" |
| 8906 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8907 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8908 | "community-list name\n" |
| 8909 | "Exact match of the communities\n") |
| 8910 | { |
| 8911 | if (strncmp (argv[0], "m", 1) == 0) |
| 8912 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8913 | |
| 8914 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8915 | } |
| 8916 | |
| 8917 | #ifdef HAVE_IPV6 |
| 8918 | DEFUN (show_bgp_community_list, |
| 8919 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8920 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8921 | SHOW_STR |
| 8922 | BGP_STR |
| 8923 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8924 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8925 | "community-list name\n") |
| 8926 | { |
| 8927 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8928 | } |
| 8929 | |
| 8930 | ALIAS (show_bgp_community_list, |
| 8931 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8932 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8933 | SHOW_STR |
| 8934 | BGP_STR |
| 8935 | "Address family\n" |
| 8936 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8937 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8938 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8939 | |
| 8940 | /* old command */ |
| 8941 | DEFUN (show_ipv6_bgp_community_list, |
| 8942 | show_ipv6_bgp_community_list_cmd, |
| 8943 | "show ipv6 bgp community-list WORD", |
| 8944 | SHOW_STR |
| 8945 | IPV6_STR |
| 8946 | BGP_STR |
| 8947 | "Display routes matching the community-list\n" |
| 8948 | "community-list name\n") |
| 8949 | { |
| 8950 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8951 | } |
| 8952 | |
| 8953 | /* old command */ |
| 8954 | DEFUN (show_ipv6_mbgp_community_list, |
| 8955 | show_ipv6_mbgp_community_list_cmd, |
| 8956 | "show ipv6 mbgp community-list WORD", |
| 8957 | SHOW_STR |
| 8958 | IPV6_STR |
| 8959 | MBGP_STR |
| 8960 | "Display routes matching the community-list\n" |
| 8961 | "community-list name\n") |
| 8962 | { |
| 8963 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8964 | } |
| 8965 | |
| 8966 | DEFUN (show_bgp_community_list_exact, |
| 8967 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8968 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8969 | SHOW_STR |
| 8970 | BGP_STR |
| 8971 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8972 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8973 | "community-list name\n" |
| 8974 | "Exact match of the communities\n") |
| 8975 | { |
| 8976 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8977 | } |
| 8978 | |
| 8979 | ALIAS (show_bgp_community_list_exact, |
| 8980 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8981 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8982 | SHOW_STR |
| 8983 | BGP_STR |
| 8984 | "Address family\n" |
| 8985 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8986 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8987 | "community-list name\n" |
| 8988 | "Exact match of the communities\n") |
| 8989 | |
| 8990 | /* old command */ |
| 8991 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 8992 | show_ipv6_bgp_community_list_exact_cmd, |
| 8993 | "show ipv6 bgp community-list WORD exact-match", |
| 8994 | SHOW_STR |
| 8995 | IPV6_STR |
| 8996 | BGP_STR |
| 8997 | "Display routes matching the community-list\n" |
| 8998 | "community-list name\n" |
| 8999 | "Exact match of the communities\n") |
| 9000 | { |
| 9001 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9002 | } |
| 9003 | |
| 9004 | /* old command */ |
| 9005 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9006 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9007 | "show ipv6 mbgp community-list WORD exact-match", |
| 9008 | SHOW_STR |
| 9009 | IPV6_STR |
| 9010 | MBGP_STR |
| 9011 | "Display routes matching the community-list\n" |
| 9012 | "community-list name\n" |
| 9013 | "Exact match of the communities\n") |
| 9014 | { |
| 9015 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9016 | } |
| 9017 | #endif /* HAVE_IPV6 */ |
| 9018 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9019 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9020 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9021 | safi_t safi, enum bgp_show_type type) |
| 9022 | { |
| 9023 | int ret; |
| 9024 | struct prefix *p; |
| 9025 | |
| 9026 | p = prefix_new(); |
| 9027 | |
| 9028 | ret = str2prefix (prefix, p); |
| 9029 | if (! ret) |
| 9030 | { |
| 9031 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9032 | return CMD_WARNING; |
| 9033 | } |
| 9034 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9035 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9036 | prefix_free(p); |
| 9037 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9038 | } |
| 9039 | |
| 9040 | DEFUN (show_ip_bgp_prefix_longer, |
| 9041 | show_ip_bgp_prefix_longer_cmd, |
| 9042 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9043 | SHOW_STR |
| 9044 | IP_STR |
| 9045 | BGP_STR |
| 9046 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9047 | "Display route and more specific routes\n") |
| 9048 | { |
| 9049 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9050 | bgp_show_type_prefix_longer); |
| 9051 | } |
| 9052 | |
| 9053 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9054 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9055 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9056 | SHOW_STR |
| 9057 | IP_STR |
| 9058 | BGP_STR |
| 9059 | "Display flap statistics of routes\n" |
| 9060 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9061 | "Display route and more specific routes\n") |
| 9062 | { |
| 9063 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9064 | bgp_show_type_flap_prefix_longer); |
| 9065 | } |
| 9066 | |
| 9067 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9068 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9069 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9070 | SHOW_STR |
| 9071 | IP_STR |
| 9072 | BGP_STR |
| 9073 | "Address family\n" |
| 9074 | "Address Family modifier\n" |
| 9075 | "Address Family modifier\n" |
| 9076 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9077 | "Display route and more specific routes\n") |
| 9078 | { |
| 9079 | if (strncmp (argv[0], "m", 1) == 0) |
| 9080 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9081 | bgp_show_type_prefix_longer); |
| 9082 | |
| 9083 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9084 | bgp_show_type_prefix_longer); |
| 9085 | } |
| 9086 | |
| 9087 | DEFUN (show_ip_bgp_flap_address, |
| 9088 | show_ip_bgp_flap_address_cmd, |
| 9089 | "show ip bgp flap-statistics A.B.C.D", |
| 9090 | SHOW_STR |
| 9091 | IP_STR |
| 9092 | BGP_STR |
| 9093 | "Display flap statistics of routes\n" |
| 9094 | "Network in the BGP routing table to display\n") |
| 9095 | { |
| 9096 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9097 | bgp_show_type_flap_address); |
| 9098 | } |
| 9099 | |
| 9100 | DEFUN (show_ip_bgp_flap_prefix, |
| 9101 | show_ip_bgp_flap_prefix_cmd, |
| 9102 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9103 | SHOW_STR |
| 9104 | IP_STR |
| 9105 | BGP_STR |
| 9106 | "Display flap statistics of routes\n" |
| 9107 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9108 | { |
| 9109 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9110 | bgp_show_type_flap_prefix); |
| 9111 | } |
| 9112 | #ifdef HAVE_IPV6 |
| 9113 | DEFUN (show_bgp_prefix_longer, |
| 9114 | show_bgp_prefix_longer_cmd, |
| 9115 | "show bgp X:X::X:X/M longer-prefixes", |
| 9116 | SHOW_STR |
| 9117 | BGP_STR |
| 9118 | "IPv6 prefix <network>/<length>\n" |
| 9119 | "Display route and more specific routes\n") |
| 9120 | { |
| 9121 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9122 | bgp_show_type_prefix_longer); |
| 9123 | } |
| 9124 | |
| 9125 | ALIAS (show_bgp_prefix_longer, |
| 9126 | show_bgp_ipv6_prefix_longer_cmd, |
| 9127 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9128 | SHOW_STR |
| 9129 | BGP_STR |
| 9130 | "Address family\n" |
| 9131 | "IPv6 prefix <network>/<length>\n" |
| 9132 | "Display route and more specific routes\n") |
| 9133 | |
| 9134 | /* old command */ |
| 9135 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9136 | show_ipv6_bgp_prefix_longer_cmd, |
| 9137 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9138 | SHOW_STR |
| 9139 | IPV6_STR |
| 9140 | BGP_STR |
| 9141 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9142 | "Display route and more specific routes\n") |
| 9143 | { |
| 9144 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9145 | bgp_show_type_prefix_longer); |
| 9146 | } |
| 9147 | |
| 9148 | /* old command */ |
| 9149 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9150 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9151 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9152 | SHOW_STR |
| 9153 | IPV6_STR |
| 9154 | MBGP_STR |
| 9155 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9156 | "Display route and more specific routes\n") |
| 9157 | { |
| 9158 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9159 | bgp_show_type_prefix_longer); |
| 9160 | } |
| 9161 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9162 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9163 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9164 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9165 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9166 | { |
| 9167 | int ret; |
| 9168 | struct bgp *bgp; |
| 9169 | struct peer *peer; |
| 9170 | union sockunion su; |
| 9171 | |
| 9172 | /* BGP structure lookup. */ |
| 9173 | if (view_name) |
| 9174 | { |
| 9175 | bgp = bgp_lookup_by_name (view_name); |
| 9176 | if (! bgp) |
| 9177 | { |
| 9178 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9179 | return NULL; |
| 9180 | } |
| 9181 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9182 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9183 | { |
| 9184 | bgp = bgp_get_default (); |
| 9185 | if (! bgp) |
| 9186 | { |
| 9187 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9188 | return NULL; |
| 9189 | } |
| 9190 | } |
| 9191 | |
| 9192 | /* Get peer sockunion. */ |
| 9193 | ret = str2sockunion (ip_str, &su); |
| 9194 | if (ret < 0) |
| 9195 | { |
| 9196 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9197 | return NULL; |
| 9198 | } |
| 9199 | |
| 9200 | /* Peer structure lookup. */ |
| 9201 | peer = peer_lookup (bgp, &su); |
| 9202 | if (! peer) |
| 9203 | { |
| 9204 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9205 | return NULL; |
| 9206 | } |
| 9207 | |
| 9208 | return peer; |
| 9209 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9210 | |
| 9211 | enum bgp_stats |
| 9212 | { |
| 9213 | BGP_STATS_MAXBITLEN = 0, |
| 9214 | BGP_STATS_RIB, |
| 9215 | BGP_STATS_PREFIXES, |
| 9216 | BGP_STATS_TOTPLEN, |
| 9217 | BGP_STATS_UNAGGREGATEABLE, |
| 9218 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9219 | BGP_STATS_AGGREGATES, |
| 9220 | BGP_STATS_SPACE, |
| 9221 | BGP_STATS_ASPATH_COUNT, |
| 9222 | BGP_STATS_ASPATH_MAXHOPS, |
| 9223 | BGP_STATS_ASPATH_TOTHOPS, |
| 9224 | BGP_STATS_ASPATH_MAXSIZE, |
| 9225 | BGP_STATS_ASPATH_TOTSIZE, |
| 9226 | BGP_STATS_ASN_HIGHEST, |
| 9227 | BGP_STATS_MAX, |
| 9228 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9229 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9230 | static const char *table_stats_strs[] = |
| 9231 | { |
| 9232 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9233 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9234 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9235 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9236 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9237 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9238 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9239 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9240 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9241 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9242 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9243 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9244 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9245 | [BGP_STATS_MAX] = NULL, |
| 9246 | }; |
| 9247 | |
| 9248 | struct bgp_table_stats |
| 9249 | { |
| 9250 | struct bgp_table *table; |
| 9251 | unsigned long long counts[BGP_STATS_MAX]; |
| 9252 | }; |
| 9253 | |
| 9254 | #if 0 |
| 9255 | #define TALLY_SIGFIG 100000 |
| 9256 | static unsigned long |
| 9257 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9258 | { |
| 9259 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9260 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9261 | unsigned long ret = newtot / count; |
| 9262 | |
| 9263 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9264 | return ret + 1; |
| 9265 | else |
| 9266 | return ret; |
| 9267 | } |
| 9268 | #endif |
| 9269 | |
| 9270 | static int |
| 9271 | bgp_table_stats_walker (struct thread *t) |
| 9272 | { |
| 9273 | struct bgp_node *rn; |
| 9274 | struct bgp_node *top; |
| 9275 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9276 | unsigned int space = 0; |
| 9277 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9278 | if (!(top = bgp_table_top (ts->table))) |
| 9279 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9280 | |
| 9281 | switch (top->p.family) |
| 9282 | { |
| 9283 | case AF_INET: |
| 9284 | space = IPV4_MAX_BITLEN; |
| 9285 | break; |
| 9286 | case AF_INET6: |
| 9287 | space = IPV6_MAX_BITLEN; |
| 9288 | break; |
| 9289 | } |
| 9290 | |
| 9291 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9292 | |
| 9293 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9294 | { |
| 9295 | struct bgp_info *ri; |
| 9296 | struct bgp_node *prn = rn->parent; |
| 9297 | unsigned int rinum = 0; |
| 9298 | |
| 9299 | if (rn == top) |
| 9300 | continue; |
| 9301 | |
| 9302 | if (!rn->info) |
| 9303 | continue; |
| 9304 | |
| 9305 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9306 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9307 | |
| 9308 | #if 0 |
| 9309 | ts->counts[BGP_STATS_AVGPLEN] |
| 9310 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9311 | ts->counts[BGP_STATS_AVGPLEN], |
| 9312 | rn->p.prefixlen); |
| 9313 | #endif |
| 9314 | |
| 9315 | /* check if the prefix is included by any other announcements */ |
| 9316 | while (prn && !prn->info) |
| 9317 | prn = prn->parent; |
| 9318 | |
| 9319 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9320 | { |
| 9321 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9322 | /* announced address space */ |
| 9323 | if (space) |
| 9324 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9325 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9326 | else if (prn->info) |
| 9327 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9328 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9329 | for (ri = rn->info; ri; ri = ri->next) |
| 9330 | { |
| 9331 | rinum++; |
| 9332 | ts->counts[BGP_STATS_RIB]++; |
| 9333 | |
| 9334 | if (ri->attr && |
| 9335 | (CHECK_FLAG (ri->attr->flag, |
| 9336 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9337 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9338 | |
| 9339 | /* as-path stats */ |
| 9340 | if (ri->attr && ri->attr->aspath) |
| 9341 | { |
| 9342 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9343 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9344 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9345 | |
| 9346 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9347 | |
| 9348 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9349 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9350 | |
| 9351 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9352 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9353 | |
| 9354 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9355 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9356 | #if 0 |
| 9357 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9358 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9359 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9360 | hops); |
| 9361 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9362 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9363 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9364 | size); |
| 9365 | #endif |
| 9366 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9367 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9368 | } |
| 9369 | } |
| 9370 | } |
| 9371 | return 0; |
| 9372 | } |
| 9373 | |
| 9374 | static int |
| 9375 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9376 | { |
| 9377 | struct bgp_table_stats ts; |
| 9378 | unsigned int i; |
| 9379 | |
| 9380 | if (!bgp->rib[afi][safi]) |
| 9381 | { |
| 9382 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9383 | return CMD_WARNING; |
| 9384 | } |
| 9385 | |
| 9386 | memset (&ts, 0, sizeof (ts)); |
| 9387 | ts.table = bgp->rib[afi][safi]; |
| 9388 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9389 | |
| 9390 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9391 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9392 | |
| 9393 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9394 | { |
| 9395 | if (!table_stats_strs[i]) |
| 9396 | continue; |
| 9397 | |
| 9398 | switch (i) |
| 9399 | { |
| 9400 | #if 0 |
| 9401 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9402 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9403 | case BGP_STATS_AVGPLEN: |
| 9404 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9405 | vty_out (vty, "%12.2f", |
| 9406 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9407 | break; |
| 9408 | #endif |
| 9409 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9410 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9411 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9412 | vty_out (vty, "%12.2f", |
| 9413 | ts.counts[i] ? |
| 9414 | (float)ts.counts[i] / |
| 9415 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9416 | : 0); |
| 9417 | break; |
| 9418 | case BGP_STATS_TOTPLEN: |
| 9419 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9420 | vty_out (vty, "%12.2f", |
| 9421 | ts.counts[i] ? |
| 9422 | (float)ts.counts[i] / |
| 9423 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9424 | : 0); |
| 9425 | break; |
| 9426 | case BGP_STATS_SPACE: |
| 9427 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9428 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9429 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9430 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9431 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9432 | vty_out (vty, "%12.2f%s", |
| 9433 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9434 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9435 | VTY_NEWLINE); |
| 9436 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9437 | vty_out (vty, "%12.2f%s", |
| 9438 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9439 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9440 | VTY_NEWLINE); |
| 9441 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9442 | break; |
| 9443 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9444 | vty_out (vty, "%12.2f", |
| 9445 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9446 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9447 | break; |
| 9448 | default: |
| 9449 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9450 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9451 | } |
| 9452 | |
| 9453 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9454 | } |
| 9455 | return CMD_SUCCESS; |
| 9456 | } |
| 9457 | |
| 9458 | static int |
| 9459 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9460 | const char *afi_str, const char *safi_str) |
| 9461 | { |
| 9462 | struct bgp *bgp; |
| 9463 | afi_t afi; |
| 9464 | safi_t safi; |
| 9465 | |
| 9466 | if (name) |
| 9467 | bgp = bgp_lookup_by_name (name); |
| 9468 | else |
| 9469 | bgp = bgp_get_default (); |
| 9470 | |
| 9471 | if (!bgp) |
| 9472 | { |
| 9473 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9474 | return CMD_WARNING; |
| 9475 | } |
| 9476 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9477 | { |
| 9478 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9479 | afi = AFI_IP; |
| 9480 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9481 | afi = AFI_IP6; |
| 9482 | else |
| 9483 | { |
| 9484 | vty_out (vty, "%% Invalid address family %s%s", |
| 9485 | afi_str, VTY_NEWLINE); |
| 9486 | return CMD_WARNING; |
| 9487 | } |
| 9488 | if (strncmp (safi_str, "m", 1) == 0) |
| 9489 | safi = SAFI_MULTICAST; |
| 9490 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9491 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9492 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9493 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9494 | else |
| 9495 | { |
| 9496 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9497 | safi_str, VTY_NEWLINE); |
| 9498 | return CMD_WARNING; |
| 9499 | } |
| 9500 | } |
| 9501 | else |
| 9502 | { |
| 9503 | vty_out (vty, "%% Invalid address family %s%s", |
| 9504 | afi_str, VTY_NEWLINE); |
| 9505 | return CMD_WARNING; |
| 9506 | } |
| 9507 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9508 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9509 | } |
| 9510 | |
| 9511 | DEFUN (show_bgp_statistics, |
| 9512 | show_bgp_statistics_cmd, |
| 9513 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9514 | SHOW_STR |
| 9515 | BGP_STR |
| 9516 | "Address family\n" |
| 9517 | "Address family\n" |
| 9518 | "Address Family modifier\n" |
| 9519 | "Address Family modifier\n" |
| 9520 | "BGP RIB advertisement statistics\n") |
| 9521 | { |
| 9522 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9523 | } |
| 9524 | |
| 9525 | ALIAS (show_bgp_statistics, |
| 9526 | show_bgp_statistics_vpnv4_cmd, |
| 9527 | "show bgp (ipv4) (vpnv4) statistics", |
| 9528 | SHOW_STR |
| 9529 | BGP_STR |
| 9530 | "Address family\n" |
| 9531 | "Address Family modifier\n" |
| 9532 | "BGP RIB advertisement statistics\n") |
| 9533 | |
| 9534 | DEFUN (show_bgp_statistics_view, |
| 9535 | show_bgp_statistics_view_cmd, |
| 9536 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9537 | SHOW_STR |
| 9538 | BGP_STR |
| 9539 | "BGP view\n" |
| 9540 | "Address family\n" |
| 9541 | "Address family\n" |
| 9542 | "Address Family modifier\n" |
| 9543 | "Address Family modifier\n" |
| 9544 | "BGP RIB advertisement statistics\n") |
| 9545 | { |
| 9546 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9547 | } |
| 9548 | |
| 9549 | ALIAS (show_bgp_statistics_view, |
| 9550 | show_bgp_statistics_view_vpnv4_cmd, |
| 9551 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9552 | SHOW_STR |
| 9553 | BGP_STR |
| 9554 | "BGP view\n" |
| 9555 | "Address family\n" |
| 9556 | "Address Family modifier\n" |
| 9557 | "BGP RIB advertisement statistics\n") |
| 9558 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9559 | enum bgp_pcounts |
| 9560 | { |
| 9561 | PCOUNT_ADJ_IN = 0, |
| 9562 | PCOUNT_DAMPED, |
| 9563 | PCOUNT_REMOVED, |
| 9564 | PCOUNT_HISTORY, |
| 9565 | PCOUNT_STALE, |
| 9566 | PCOUNT_VALID, |
| 9567 | PCOUNT_ALL, |
| 9568 | PCOUNT_COUNTED, |
| 9569 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9570 | PCOUNT_MAX, |
| 9571 | }; |
| 9572 | |
| 9573 | static const char *pcount_strs[] = |
| 9574 | { |
| 9575 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9576 | [PCOUNT_DAMPED] = "Damped", |
| 9577 | [PCOUNT_REMOVED] = "Removed", |
| 9578 | [PCOUNT_HISTORY] = "History", |
| 9579 | [PCOUNT_STALE] = "Stale", |
| 9580 | [PCOUNT_VALID] = "Valid", |
| 9581 | [PCOUNT_ALL] = "All RIB", |
| 9582 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9583 | [PCOUNT_PFCNT] = "Useable", |
| 9584 | [PCOUNT_MAX] = NULL, |
| 9585 | }; |
| 9586 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9587 | struct peer_pcounts |
| 9588 | { |
| 9589 | unsigned int count[PCOUNT_MAX]; |
| 9590 | const struct peer *peer; |
| 9591 | const struct bgp_table *table; |
| 9592 | }; |
| 9593 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9594 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9595 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9596 | { |
| 9597 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9598 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9599 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9600 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9601 | 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] | 9602 | { |
| 9603 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9604 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9605 | |
| 9606 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9607 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9608 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9609 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9610 | for (ri = rn->info; ri; ri = ri->next) |
| 9611 | { |
| 9612 | char buf[SU_ADDRSTRLEN]; |
| 9613 | |
| 9614 | if (ri->peer != peer) |
| 9615 | continue; |
| 9616 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9617 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9618 | |
| 9619 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9620 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9621 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9622 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9623 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9624 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9625 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9626 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9627 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9628 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9629 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9630 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9631 | |
| 9632 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9633 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9634 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9635 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9636 | plog_warn (peer->log, |
| 9637 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9638 | peer->host, |
| 9639 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9640 | buf, SU_ADDRSTRLEN), |
| 9641 | rn->p.prefixlen, |
| 9642 | ri->flags); |
| 9643 | } |
| 9644 | else |
| 9645 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9646 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9647 | plog_warn (peer->log, |
| 9648 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9649 | peer->host, |
| 9650 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9651 | buf, SU_ADDRSTRLEN), |
| 9652 | rn->p.prefixlen, |
| 9653 | ri->flags); |
| 9654 | } |
| 9655 | } |
| 9656 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9657 | return 0; |
| 9658 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9659 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9660 | static int |
| 9661 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9662 | { |
| 9663 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9664 | unsigned int i; |
| 9665 | |
| 9666 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9667 | || !peer->bgp->rib[afi][safi]) |
| 9668 | { |
| 9669 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9670 | return CMD_WARNING; |
| 9671 | } |
| 9672 | |
| 9673 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9674 | pcounts.peer = peer; |
| 9675 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9676 | |
| 9677 | /* in-place call via thread subsystem so as to record execution time |
| 9678 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9679 | * on just vty_read()). |
| 9680 | */ |
| 9681 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9682 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9683 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9684 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9685 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9686 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9687 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9688 | |
| 9689 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9690 | vty_out (vty, "%20s: %-10d%s", |
| 9691 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9692 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9693 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9694 | { |
| 9695 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9696 | peer->host, VTY_NEWLINE); |
| 9697 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9698 | VTY_NEWLINE); |
| 9699 | } |
| 9700 | |
| 9701 | return CMD_SUCCESS; |
| 9702 | } |
| 9703 | |
| 9704 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9705 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9706 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9707 | SHOW_STR |
| 9708 | IP_STR |
| 9709 | BGP_STR |
| 9710 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9711 | "Neighbor to display information about\n" |
| 9712 | "Neighbor to display information about\n" |
| 9713 | "Display detailed prefix count information\n") |
| 9714 | { |
| 9715 | struct peer *peer; |
| 9716 | |
| 9717 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9718 | if (! peer) |
| 9719 | return CMD_WARNING; |
| 9720 | |
| 9721 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9722 | } |
| 9723 | |
| 9724 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9725 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9726 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9727 | SHOW_STR |
| 9728 | BGP_STR |
| 9729 | "Address family\n" |
| 9730 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9731 | "Neighbor to display information about\n" |
| 9732 | "Neighbor to display information about\n" |
| 9733 | "Display detailed prefix count information\n") |
| 9734 | { |
| 9735 | struct peer *peer; |
| 9736 | |
| 9737 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9738 | if (! peer) |
| 9739 | return CMD_WARNING; |
| 9740 | |
| 9741 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9742 | } |
| 9743 | |
| 9744 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9745 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9746 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9747 | SHOW_STR |
| 9748 | IP_STR |
| 9749 | BGP_STR |
| 9750 | "Address family\n" |
| 9751 | "Address Family modifier\n" |
| 9752 | "Address Family modifier\n" |
| 9753 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9754 | "Neighbor to display information about\n" |
| 9755 | "Neighbor to display information about\n" |
| 9756 | "Display detailed prefix count information\n") |
| 9757 | { |
| 9758 | struct peer *peer; |
| 9759 | |
| 9760 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9761 | if (! peer) |
| 9762 | return CMD_WARNING; |
| 9763 | |
| 9764 | if (strncmp (argv[0], "m", 1) == 0) |
| 9765 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9766 | |
| 9767 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9768 | } |
| 9769 | |
| 9770 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9771 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9772 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9773 | SHOW_STR |
| 9774 | IP_STR |
| 9775 | BGP_STR |
| 9776 | "Address family\n" |
| 9777 | "Address Family modifier\n" |
| 9778 | "Address Family modifier\n" |
| 9779 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9780 | "Neighbor to display information about\n" |
| 9781 | "Neighbor to display information about\n" |
| 9782 | "Display detailed prefix count information\n") |
| 9783 | { |
| 9784 | struct peer *peer; |
| 9785 | |
| 9786 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9787 | if (! peer) |
| 9788 | return CMD_WARNING; |
| 9789 | |
| 9790 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9791 | } |
| 9792 | |
| 9793 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9794 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9795 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9796 | int in) |
| 9797 | { |
| 9798 | struct bgp_table *table; |
| 9799 | struct bgp_adj_in *ain; |
| 9800 | struct bgp_adj_out *adj; |
| 9801 | unsigned long output_count; |
| 9802 | struct bgp_node *rn; |
| 9803 | int header1 = 1; |
| 9804 | struct bgp *bgp; |
| 9805 | int header2 = 1; |
| 9806 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9807 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9808 | |
| 9809 | if (! bgp) |
| 9810 | return; |
| 9811 | |
| 9812 | table = bgp->rib[afi][safi]; |
| 9813 | |
| 9814 | output_count = 0; |
| 9815 | |
| 9816 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9817 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9818 | { |
| 9819 | 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] | 9820 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9821 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9822 | |
| 9823 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9824 | VTY_NEWLINE, VTY_NEWLINE); |
| 9825 | header1 = 0; |
| 9826 | } |
| 9827 | |
| 9828 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9829 | if (in) |
| 9830 | { |
| 9831 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9832 | if (ain->peer == peer) |
| 9833 | { |
| 9834 | if (header1) |
| 9835 | { |
| 9836 | 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] | 9837 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9838 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9839 | header1 = 0; |
| 9840 | } |
| 9841 | if (header2) |
| 9842 | { |
| 9843 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9844 | header2 = 0; |
| 9845 | } |
| 9846 | if (ain->attr) |
| 9847 | { |
| 9848 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9849 | output_count++; |
| 9850 | } |
| 9851 | } |
| 9852 | } |
| 9853 | else |
| 9854 | { |
| 9855 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9856 | if (adj->peer == peer) |
| 9857 | { |
| 9858 | if (header1) |
| 9859 | { |
| 9860 | 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] | 9861 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9862 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9863 | header1 = 0; |
| 9864 | } |
| 9865 | if (header2) |
| 9866 | { |
| 9867 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9868 | header2 = 0; |
| 9869 | } |
| 9870 | if (adj->attr) |
| 9871 | { |
| 9872 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9873 | output_count++; |
| 9874 | } |
| 9875 | } |
| 9876 | } |
| 9877 | |
| 9878 | if (output_count != 0) |
| 9879 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9880 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9881 | } |
| 9882 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9883 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9884 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9885 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9886 | if (! peer || ! peer->afc[afi][safi]) |
| 9887 | { |
| 9888 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9889 | return CMD_WARNING; |
| 9890 | } |
| 9891 | |
| 9892 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9893 | { |
| 9894 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9895 | VTY_NEWLINE); |
| 9896 | return CMD_WARNING; |
| 9897 | } |
| 9898 | |
| 9899 | show_adj_route (vty, peer, afi, safi, in); |
| 9900 | |
| 9901 | return CMD_SUCCESS; |
| 9902 | } |
| 9903 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 9904 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 9905 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 9906 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9907 | SHOW_STR |
| 9908 | IP_STR |
| 9909 | BGP_STR |
| 9910 | "BGP view\n" |
| 9911 | "View name\n" |
| 9912 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9913 | "Neighbor to display information about\n" |
| 9914 | "Neighbor to display information about\n" |
| 9915 | "Display the routes advertised to a BGP neighbor\n") |
| 9916 | { |
| 9917 | struct peer *peer; |
| 9918 | |
| 9919 | if (argc == 2) |
| 9920 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9921 | else |
| 9922 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9923 | |
| 9924 | if (! peer) |
| 9925 | return CMD_WARNING; |
| 9926 | |
| 9927 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 9928 | } |
| 9929 | |
| 9930 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9931 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9932 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9933 | SHOW_STR |
| 9934 | IP_STR |
| 9935 | BGP_STR |
| 9936 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9937 | "Neighbor to display information about\n" |
| 9938 | "Neighbor to display information about\n" |
| 9939 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9940 | |
| 9941 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9942 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9943 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9944 | SHOW_STR |
| 9945 | IP_STR |
| 9946 | BGP_STR |
| 9947 | "Address family\n" |
| 9948 | "Address Family modifier\n" |
| 9949 | "Address Family modifier\n" |
| 9950 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9951 | "Neighbor to display information about\n" |
| 9952 | "Neighbor to display information about\n" |
| 9953 | "Display the routes advertised to a BGP neighbor\n") |
| 9954 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9955 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9956 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9957 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9958 | if (! peer) |
| 9959 | return CMD_WARNING; |
| 9960 | |
| 9961 | if (strncmp (argv[0], "m", 1) == 0) |
| 9962 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 9963 | |
| 9964 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9965 | } |
| 9966 | |
| 9967 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9968 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 9969 | show_bgp_view_neighbor_advertised_route_cmd, |
| 9970 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9971 | SHOW_STR |
| 9972 | BGP_STR |
| 9973 | "BGP view\n" |
| 9974 | "View name\n" |
| 9975 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9976 | "Neighbor to display information about\n" |
| 9977 | "Neighbor to display information about\n" |
| 9978 | "Display the routes advertised to a BGP neighbor\n") |
| 9979 | { |
| 9980 | struct peer *peer; |
| 9981 | |
| 9982 | if (argc == 2) |
| 9983 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9984 | else |
| 9985 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9986 | |
| 9987 | if (! peer) |
| 9988 | return CMD_WARNING; |
| 9989 | |
| 9990 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 9991 | } |
| 9992 | |
| 9993 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 9994 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 9995 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9996 | SHOW_STR |
| 9997 | BGP_STR |
| 9998 | "BGP view\n" |
| 9999 | "View name\n" |
| 10000 | "Address family\n" |
| 10001 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10002 | "Neighbor to display information about\n" |
| 10003 | "Neighbor to display information about\n" |
| 10004 | "Display the routes advertised to a BGP neighbor\n") |
| 10005 | |
| 10006 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10007 | show_bgp_view_neighbor_received_routes_cmd, |
| 10008 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10009 | SHOW_STR |
| 10010 | BGP_STR |
| 10011 | "BGP view\n" |
| 10012 | "View name\n" |
| 10013 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10014 | "Neighbor to display information about\n" |
| 10015 | "Neighbor to display information about\n" |
| 10016 | "Display the received routes from neighbor\n") |
| 10017 | { |
| 10018 | struct peer *peer; |
| 10019 | |
| 10020 | if (argc == 2) |
| 10021 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10022 | else |
| 10023 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10024 | |
| 10025 | if (! peer) |
| 10026 | return CMD_WARNING; |
| 10027 | |
| 10028 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10029 | } |
| 10030 | |
| 10031 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10032 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10033 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10034 | SHOW_STR |
| 10035 | BGP_STR |
| 10036 | "BGP view\n" |
| 10037 | "View name\n" |
| 10038 | "Address family\n" |
| 10039 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10040 | "Neighbor to display information about\n" |
| 10041 | "Neighbor to display information about\n" |
| 10042 | "Display the received routes from neighbor\n") |
| 10043 | |
| 10044 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10045 | show_bgp_neighbor_advertised_route_cmd, |
| 10046 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10047 | SHOW_STR |
| 10048 | BGP_STR |
| 10049 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10050 | "Neighbor to display information about\n" |
| 10051 | "Neighbor to display information about\n" |
| 10052 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10053 | |
| 10054 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10055 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10056 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10057 | SHOW_STR |
| 10058 | BGP_STR |
| 10059 | "Address family\n" |
| 10060 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10061 | "Neighbor to display information about\n" |
| 10062 | "Neighbor to display information about\n" |
| 10063 | "Display the routes advertised to a BGP neighbor\n") |
| 10064 | |
| 10065 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10066 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10067 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10068 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10069 | SHOW_STR |
| 10070 | IPV6_STR |
| 10071 | BGP_STR |
| 10072 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10073 | "Neighbor to display information about\n" |
| 10074 | "Neighbor to display information about\n" |
| 10075 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10076 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10077 | /* old command */ |
| 10078 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10079 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10080 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10081 | SHOW_STR |
| 10082 | IPV6_STR |
| 10083 | MBGP_STR |
| 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; |
| 10090 | |
| 10091 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10092 | if (! peer) |
| 10093 | return CMD_WARNING; |
| 10094 | |
| 10095 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10096 | } |
| 10097 | #endif /* HAVE_IPV6 */ |
| 10098 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10099 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10100 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10101 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10102 | SHOW_STR |
| 10103 | IP_STR |
| 10104 | BGP_STR |
| 10105 | "BGP view\n" |
| 10106 | "View name\n" |
| 10107 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10108 | "Neighbor to display information about\n" |
| 10109 | "Neighbor to display information about\n" |
| 10110 | "Display the received routes from neighbor\n") |
| 10111 | { |
| 10112 | struct peer *peer; |
| 10113 | |
| 10114 | if (argc == 2) |
| 10115 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10116 | else |
| 10117 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10118 | |
| 10119 | if (! peer) |
| 10120 | return CMD_WARNING; |
| 10121 | |
| 10122 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10123 | } |
| 10124 | |
| 10125 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10126 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10127 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10128 | SHOW_STR |
| 10129 | IP_STR |
| 10130 | BGP_STR |
| 10131 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10132 | "Neighbor to display information about\n" |
| 10133 | "Neighbor to display information about\n" |
| 10134 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10135 | |
| 10136 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10137 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10138 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10139 | SHOW_STR |
| 10140 | IP_STR |
| 10141 | BGP_STR |
| 10142 | "Address family\n" |
| 10143 | "Address Family modifier\n" |
| 10144 | "Address Family modifier\n" |
| 10145 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10146 | "Neighbor to display information about\n" |
| 10147 | "Neighbor to display information about\n" |
| 10148 | "Display the received routes from neighbor\n") |
| 10149 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10150 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10151 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10152 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10153 | if (! peer) |
| 10154 | return CMD_WARNING; |
| 10155 | |
| 10156 | if (strncmp (argv[0], "m", 1) == 0) |
| 10157 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10158 | |
| 10159 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10160 | } |
| 10161 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10162 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10163 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
| 10164 | #ifdef HAVE_IPV6 |
| 10165 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10166 | #else |
| 10167 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10168 | #endif |
| 10169 | SHOW_STR |
| 10170 | BGP_STR |
| 10171 | "BGP view\n" |
| 10172 | "BGP view name\n" |
| 10173 | "Address family\n" |
| 10174 | #ifdef HAVE_IPV6 |
| 10175 | "Address family\n" |
| 10176 | #endif |
| 10177 | "Address family modifier\n" |
| 10178 | "Address family modifier\n" |
| 10179 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10180 | "Neighbor to display information about\n" |
| 10181 | "Neighbor to display information about\n" |
| 10182 | "Display the advertised routes to neighbor\n" |
| 10183 | "Display the received routes from neighbor\n") |
| 10184 | { |
| 10185 | int afi; |
| 10186 | int safi; |
| 10187 | int in; |
| 10188 | struct peer *peer; |
| 10189 | |
| 10190 | #ifdef HAVE_IPV6 |
| 10191 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
| 10192 | #else |
| 10193 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10194 | #endif |
| 10195 | |
| 10196 | if (! peer) |
| 10197 | return CMD_WARNING; |
| 10198 | |
| 10199 | #ifdef HAVE_IPV6 |
| 10200 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10201 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10202 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
| 10203 | #else |
| 10204 | afi = AFI_IP; |
| 10205 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10206 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; |
| 10207 | #endif |
| 10208 | |
| 10209 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10210 | } |
| 10211 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10212 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10213 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10214 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10215 | SHOW_STR |
| 10216 | IP_STR |
| 10217 | BGP_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 information received from a BGP neighbor\n" |
| 10222 | "Display the prefixlist filter\n") |
| 10223 | { |
| 10224 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10225 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10226 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10227 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10228 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10229 | ret = str2sockunion (argv[0], &su); |
| 10230 | if (ret < 0) |
| 10231 | { |
| 10232 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10233 | return CMD_WARNING; |
| 10234 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10235 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10236 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10237 | if (! peer) |
| 10238 | return CMD_WARNING; |
| 10239 | |
| 10240 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10241 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10242 | if (count) |
| 10243 | { |
| 10244 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10245 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10246 | } |
| 10247 | |
| 10248 | return CMD_SUCCESS; |
| 10249 | } |
| 10250 | |
| 10251 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10252 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10253 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10254 | SHOW_STR |
| 10255 | IP_STR |
| 10256 | BGP_STR |
| 10257 | "Address family\n" |
| 10258 | "Address Family modifier\n" |
| 10259 | "Address Family modifier\n" |
| 10260 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10261 | "Neighbor to display information about\n" |
| 10262 | "Neighbor to display information about\n" |
| 10263 | "Display information received from a BGP neighbor\n" |
| 10264 | "Display the prefixlist filter\n") |
| 10265 | { |
| 10266 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10267 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10268 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10269 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10270 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10271 | ret = str2sockunion (argv[1], &su); |
| 10272 | if (ret < 0) |
| 10273 | { |
| 10274 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10275 | return CMD_WARNING; |
| 10276 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10277 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10278 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10279 | if (! peer) |
| 10280 | return CMD_WARNING; |
| 10281 | |
| 10282 | if (strncmp (argv[0], "m", 1) == 0) |
| 10283 | { |
| 10284 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10285 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10286 | if (count) |
| 10287 | { |
| 10288 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10289 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10290 | } |
| 10291 | } |
| 10292 | else |
| 10293 | { |
| 10294 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10295 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10296 | if (count) |
| 10297 | { |
| 10298 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10299 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10300 | } |
| 10301 | } |
| 10302 | |
| 10303 | return CMD_SUCCESS; |
| 10304 | } |
| 10305 | |
| 10306 | |
| 10307 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10308 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10309 | show_bgp_neighbor_received_routes_cmd, |
| 10310 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10311 | SHOW_STR |
| 10312 | BGP_STR |
| 10313 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10314 | "Neighbor to display information about\n" |
| 10315 | "Neighbor to display information about\n" |
| 10316 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10317 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10318 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10319 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10320 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10321 | SHOW_STR |
| 10322 | BGP_STR |
| 10323 | "Address family\n" |
| 10324 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10325 | "Neighbor to display information about\n" |
| 10326 | "Neighbor to display information about\n" |
| 10327 | "Display the received routes from neighbor\n") |
| 10328 | |
| 10329 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10330 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10331 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10332 | SHOW_STR |
| 10333 | BGP_STR |
| 10334 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10335 | "Neighbor to display information about\n" |
| 10336 | "Neighbor to display information about\n" |
| 10337 | "Display information received from a BGP neighbor\n" |
| 10338 | "Display the prefixlist filter\n") |
| 10339 | { |
| 10340 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10341 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10342 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10343 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10344 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10345 | ret = str2sockunion (argv[0], &su); |
| 10346 | if (ret < 0) |
| 10347 | { |
| 10348 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10349 | return CMD_WARNING; |
| 10350 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10351 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10352 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10353 | if (! peer) |
| 10354 | return CMD_WARNING; |
| 10355 | |
| 10356 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10357 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10358 | if (count) |
| 10359 | { |
| 10360 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10361 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10362 | } |
| 10363 | |
| 10364 | return CMD_SUCCESS; |
| 10365 | } |
| 10366 | |
| 10367 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10368 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10369 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10370 | SHOW_STR |
| 10371 | BGP_STR |
| 10372 | "Address family\n" |
| 10373 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10374 | "Neighbor to display information about\n" |
| 10375 | "Neighbor to display information about\n" |
| 10376 | "Display information received from a BGP neighbor\n" |
| 10377 | "Display the prefixlist filter\n") |
| 10378 | |
| 10379 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10380 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10381 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10382 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10383 | SHOW_STR |
| 10384 | IPV6_STR |
| 10385 | BGP_STR |
| 10386 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10387 | "Neighbor to display information about\n" |
| 10388 | "Neighbor to display information about\n" |
| 10389 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10390 | |
| 10391 | /* old command */ |
| 10392 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10393 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10394 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10395 | SHOW_STR |
| 10396 | IPV6_STR |
| 10397 | MBGP_STR |
| 10398 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10399 | "Neighbor to display information about\n" |
| 10400 | "Neighbor to display information about\n" |
| 10401 | "Display the received routes from neighbor\n") |
| 10402 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10403 | struct peer *peer; |
| 10404 | |
| 10405 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10406 | if (! peer) |
| 10407 | return CMD_WARNING; |
| 10408 | |
| 10409 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10410 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10411 | |
| 10412 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10413 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10414 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10415 | SHOW_STR |
| 10416 | BGP_STR |
| 10417 | "BGP view\n" |
| 10418 | "View name\n" |
| 10419 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10420 | "Neighbor to display information about\n" |
| 10421 | "Neighbor to display information about\n" |
| 10422 | "Display information received from a BGP neighbor\n" |
| 10423 | "Display the prefixlist filter\n") |
| 10424 | { |
| 10425 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10426 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10427 | struct peer *peer; |
| 10428 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10429 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10430 | |
| 10431 | /* BGP structure lookup. */ |
| 10432 | bgp = bgp_lookup_by_name (argv[0]); |
| 10433 | if (bgp == NULL) |
| 10434 | { |
| 10435 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10436 | return CMD_WARNING; |
| 10437 | } |
| 10438 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10439 | ret = str2sockunion (argv[1], &su); |
| 10440 | if (ret < 0) |
| 10441 | { |
| 10442 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10443 | return CMD_WARNING; |
| 10444 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10445 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10446 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10447 | if (! peer) |
| 10448 | return CMD_WARNING; |
| 10449 | |
| 10450 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10451 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10452 | if (count) |
| 10453 | { |
| 10454 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10455 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10456 | } |
| 10457 | |
| 10458 | return CMD_SUCCESS; |
| 10459 | } |
| 10460 | |
| 10461 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10462 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10463 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10464 | SHOW_STR |
| 10465 | BGP_STR |
| 10466 | "BGP view\n" |
| 10467 | "View name\n" |
| 10468 | "Address family\n" |
| 10469 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10470 | "Neighbor to display information about\n" |
| 10471 | "Neighbor to display information about\n" |
| 10472 | "Display information received from a BGP neighbor\n" |
| 10473 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10474 | #endif /* HAVE_IPV6 */ |
| 10475 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10476 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10477 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10478 | safi_t safi, enum bgp_show_type type) |
| 10479 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10480 | if (! peer || ! peer->afc[afi][safi]) |
| 10481 | { |
| 10482 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10483 | return CMD_WARNING; |
| 10484 | } |
| 10485 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10486 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10487 | } |
| 10488 | |
| 10489 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10490 | show_ip_bgp_neighbor_routes_cmd, |
| 10491 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10492 | SHOW_STR |
| 10493 | IP_STR |
| 10494 | BGP_STR |
| 10495 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10496 | "Neighbor to display information about\n" |
| 10497 | "Neighbor to display information about\n" |
| 10498 | "Display routes learned from neighbor\n") |
| 10499 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10500 | struct peer *peer; |
| 10501 | |
| 10502 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10503 | if (! peer) |
| 10504 | return CMD_WARNING; |
| 10505 | |
| 10506 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10507 | bgp_show_type_neighbor); |
| 10508 | } |
| 10509 | |
| 10510 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10511 | show_ip_bgp_neighbor_flap_cmd, |
| 10512 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10513 | SHOW_STR |
| 10514 | IP_STR |
| 10515 | BGP_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 flap statistics of the routes learned 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 bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10528 | bgp_show_type_flap_neighbor); |
| 10529 | } |
| 10530 | |
| 10531 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10532 | show_ip_bgp_neighbor_damp_cmd, |
| 10533 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10534 | SHOW_STR |
| 10535 | IP_STR |
| 10536 | BGP_STR |
| 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 the dampened routes received from neighbor\n") |
| 10541 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10542 | struct peer *peer; |
| 10543 | |
| 10544 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10545 | if (! peer) |
| 10546 | return CMD_WARNING; |
| 10547 | |
| 10548 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10549 | bgp_show_type_damp_neighbor); |
| 10550 | } |
| 10551 | |
| 10552 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10553 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10554 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10555 | SHOW_STR |
| 10556 | IP_STR |
| 10557 | BGP_STR |
| 10558 | "Address family\n" |
| 10559 | "Address Family modifier\n" |
| 10560 | "Address Family modifier\n" |
| 10561 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10562 | "Neighbor to display information about\n" |
| 10563 | "Neighbor to display information about\n" |
| 10564 | "Display routes learned from neighbor\n") |
| 10565 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10566 | struct peer *peer; |
| 10567 | |
| 10568 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10569 | if (! peer) |
| 10570 | return CMD_WARNING; |
| 10571 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10572 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10573 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10574 | bgp_show_type_neighbor); |
| 10575 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10576 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10577 | bgp_show_type_neighbor); |
| 10578 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10579 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10580 | DEFUN (show_ip_bgp_view_rsclient, |
| 10581 | show_ip_bgp_view_rsclient_cmd, |
| 10582 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10583 | SHOW_STR |
| 10584 | IP_STR |
| 10585 | BGP_STR |
| 10586 | "BGP view\n" |
| 10587 | "BGP view name\n" |
| 10588 | "Information about Route Server Client\n" |
| 10589 | NEIGHBOR_ADDR_STR) |
| 10590 | { |
| 10591 | struct bgp_table *table; |
| 10592 | struct peer *peer; |
| 10593 | |
| 10594 | if (argc == 2) |
| 10595 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10596 | else |
| 10597 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10598 | |
| 10599 | if (! peer) |
| 10600 | return CMD_WARNING; |
| 10601 | |
| 10602 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10603 | { |
| 10604 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10605 | VTY_NEWLINE); |
| 10606 | return CMD_WARNING; |
| 10607 | } |
| 10608 | |
| 10609 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10610 | PEER_FLAG_RSERVER_CLIENT)) |
| 10611 | { |
| 10612 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10613 | VTY_NEWLINE); |
| 10614 | return CMD_WARNING; |
| 10615 | } |
| 10616 | |
| 10617 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10618 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10619 | 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] | 10620 | } |
| 10621 | |
| 10622 | ALIAS (show_ip_bgp_view_rsclient, |
| 10623 | show_ip_bgp_rsclient_cmd, |
| 10624 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10625 | SHOW_STR |
| 10626 | IP_STR |
| 10627 | BGP_STR |
| 10628 | "Information about Route Server Client\n" |
| 10629 | NEIGHBOR_ADDR_STR) |
| 10630 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10631 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10632 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10633 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10634 | SHOW_STR |
| 10635 | BGP_STR |
| 10636 | "BGP view\n" |
| 10637 | "BGP view name\n" |
| 10638 | "Address family\n" |
| 10639 | "Address Family modifier\n" |
| 10640 | "Address Family modifier\n" |
| 10641 | "Information about Route Server Client\n" |
| 10642 | NEIGHBOR_ADDR_STR) |
| 10643 | { |
| 10644 | struct bgp_table *table; |
| 10645 | struct peer *peer; |
| 10646 | safi_t safi; |
| 10647 | |
| 10648 | if (argc == 3) { |
| 10649 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10650 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10651 | } else { |
| 10652 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10653 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10654 | } |
| 10655 | |
| 10656 | if (! peer) |
| 10657 | return CMD_WARNING; |
| 10658 | |
| 10659 | if (! peer->afc[AFI_IP][safi]) |
| 10660 | { |
| 10661 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10662 | VTY_NEWLINE); |
| 10663 | return CMD_WARNING; |
| 10664 | } |
| 10665 | |
| 10666 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10667 | PEER_FLAG_RSERVER_CLIENT)) |
| 10668 | { |
| 10669 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10670 | VTY_NEWLINE); |
| 10671 | return CMD_WARNING; |
| 10672 | } |
| 10673 | |
| 10674 | table = peer->rib[AFI_IP][safi]; |
| 10675 | |
| 10676 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10677 | } |
| 10678 | |
| 10679 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10680 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10681 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10682 | SHOW_STR |
| 10683 | BGP_STR |
| 10684 | "Address family\n" |
| 10685 | "Address Family modifier\n" |
| 10686 | "Address Family modifier\n" |
| 10687 | "Information about Route Server Client\n" |
| 10688 | NEIGHBOR_ADDR_STR) |
| 10689 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10690 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10691 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10692 | "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] | 10693 | SHOW_STR |
| 10694 | IP_STR |
| 10695 | BGP_STR |
| 10696 | "BGP view\n" |
| 10697 | "BGP view name\n" |
| 10698 | "Information about Route Server Client\n" |
| 10699 | NEIGHBOR_ADDR_STR |
| 10700 | "Network in the BGP routing table to display\n") |
| 10701 | { |
| 10702 | struct bgp *bgp; |
| 10703 | struct peer *peer; |
| 10704 | |
| 10705 | /* BGP structure lookup. */ |
| 10706 | if (argc == 3) |
| 10707 | { |
| 10708 | bgp = bgp_lookup_by_name (argv[0]); |
| 10709 | if (bgp == NULL) |
| 10710 | { |
| 10711 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10712 | return CMD_WARNING; |
| 10713 | } |
| 10714 | } |
| 10715 | else |
| 10716 | { |
| 10717 | bgp = bgp_get_default (); |
| 10718 | if (bgp == NULL) |
| 10719 | { |
| 10720 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10721 | return CMD_WARNING; |
| 10722 | } |
| 10723 | } |
| 10724 | |
| 10725 | if (argc == 3) |
| 10726 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10727 | else |
| 10728 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10729 | |
| 10730 | if (! peer) |
| 10731 | return CMD_WARNING; |
| 10732 | |
| 10733 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10734 | { |
| 10735 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10736 | VTY_NEWLINE); |
| 10737 | return CMD_WARNING; |
| 10738 | } |
| 10739 | |
| 10740 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10741 | PEER_FLAG_RSERVER_CLIENT)) |
| 10742 | { |
| 10743 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10744 | VTY_NEWLINE); |
| 10745 | return CMD_WARNING; |
| 10746 | } |
| 10747 | |
| 10748 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10749 | (argc == 3) ? argv[2] : argv[1], |
| 10750 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10751 | } |
| 10752 | |
| 10753 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10754 | show_ip_bgp_rsclient_route_cmd, |
| 10755 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10756 | SHOW_STR |
| 10757 | IP_STR |
| 10758 | BGP_STR |
| 10759 | "Information about Route Server Client\n" |
| 10760 | NEIGHBOR_ADDR_STR |
| 10761 | "Network in the BGP routing table to display\n") |
| 10762 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10763 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10764 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10765 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10766 | SHOW_STR |
| 10767 | BGP_STR |
| 10768 | "BGP view\n" |
| 10769 | "BGP view name\n" |
| 10770 | "Address family\n" |
| 10771 | "Address Family modifier\n" |
| 10772 | "Address Family modifier\n" |
| 10773 | "Information about Route Server Client\n" |
| 10774 | NEIGHBOR_ADDR_STR |
| 10775 | "Network in the BGP routing table to display\n") |
| 10776 | { |
| 10777 | struct bgp *bgp; |
| 10778 | struct peer *peer; |
| 10779 | safi_t safi; |
| 10780 | |
| 10781 | /* BGP structure lookup. */ |
| 10782 | if (argc == 4) |
| 10783 | { |
| 10784 | bgp = bgp_lookup_by_name (argv[0]); |
| 10785 | if (bgp == NULL) |
| 10786 | { |
| 10787 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10788 | return CMD_WARNING; |
| 10789 | } |
| 10790 | } |
| 10791 | else |
| 10792 | { |
| 10793 | bgp = bgp_get_default (); |
| 10794 | if (bgp == NULL) |
| 10795 | { |
| 10796 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10797 | return CMD_WARNING; |
| 10798 | } |
| 10799 | } |
| 10800 | |
| 10801 | if (argc == 4) { |
| 10802 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10803 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10804 | } else { |
| 10805 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10806 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10807 | } |
| 10808 | |
| 10809 | if (! peer) |
| 10810 | return CMD_WARNING; |
| 10811 | |
| 10812 | if (! peer->afc[AFI_IP][safi]) |
| 10813 | { |
| 10814 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10815 | VTY_NEWLINE); |
| 10816 | return CMD_WARNING; |
| 10817 | } |
| 10818 | |
| 10819 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10820 | PEER_FLAG_RSERVER_CLIENT)) |
| 10821 | { |
| 10822 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10823 | VTY_NEWLINE); |
| 10824 | return CMD_WARNING; |
| 10825 | } |
| 10826 | |
| 10827 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10828 | (argc == 4) ? argv[3] : argv[2], |
| 10829 | AFI_IP, safi, NULL, 0); |
| 10830 | } |
| 10831 | |
| 10832 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10833 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10834 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10835 | SHOW_STR |
| 10836 | BGP_STR |
| 10837 | "Address family\n" |
| 10838 | "Address Family modifier\n" |
| 10839 | "Address Family modifier\n" |
| 10840 | "Information about Route Server Client\n" |
| 10841 | NEIGHBOR_ADDR_STR |
| 10842 | "Network in the BGP routing table to display\n") |
| 10843 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10844 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10845 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10846 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10847 | SHOW_STR |
| 10848 | IP_STR |
| 10849 | BGP_STR |
| 10850 | "BGP view\n" |
| 10851 | "BGP view name\n" |
| 10852 | "Information about Route Server Client\n" |
| 10853 | NEIGHBOR_ADDR_STR |
| 10854 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10855 | { |
| 10856 | struct bgp *bgp; |
| 10857 | struct peer *peer; |
| 10858 | |
| 10859 | /* BGP structure lookup. */ |
| 10860 | if (argc == 3) |
| 10861 | { |
| 10862 | bgp = bgp_lookup_by_name (argv[0]); |
| 10863 | if (bgp == NULL) |
| 10864 | { |
| 10865 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10866 | return CMD_WARNING; |
| 10867 | } |
| 10868 | } |
| 10869 | else |
| 10870 | { |
| 10871 | bgp = bgp_get_default (); |
| 10872 | if (bgp == NULL) |
| 10873 | { |
| 10874 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10875 | return CMD_WARNING; |
| 10876 | } |
| 10877 | } |
| 10878 | |
| 10879 | if (argc == 3) |
| 10880 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10881 | else |
| 10882 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10883 | |
| 10884 | if (! peer) |
| 10885 | return CMD_WARNING; |
| 10886 | |
| 10887 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10888 | { |
| 10889 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10890 | VTY_NEWLINE); |
| 10891 | return CMD_WARNING; |
| 10892 | } |
| 10893 | |
| 10894 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10895 | PEER_FLAG_RSERVER_CLIENT)) |
| 10896 | { |
| 10897 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10898 | VTY_NEWLINE); |
| 10899 | return CMD_WARNING; |
| 10900 | } |
| 10901 | |
| 10902 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10903 | (argc == 3) ? argv[2] : argv[1], |
| 10904 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 10905 | } |
| 10906 | |
| 10907 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 10908 | show_ip_bgp_rsclient_prefix_cmd, |
| 10909 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10910 | SHOW_STR |
| 10911 | IP_STR |
| 10912 | BGP_STR |
| 10913 | "Information about Route Server Client\n" |
| 10914 | NEIGHBOR_ADDR_STR |
| 10915 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10916 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10917 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10918 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 10919 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10920 | SHOW_STR |
| 10921 | BGP_STR |
| 10922 | "BGP view\n" |
| 10923 | "BGP view name\n" |
| 10924 | "Address family\n" |
| 10925 | "Address Family modifier\n" |
| 10926 | "Address Family modifier\n" |
| 10927 | "Information about Route Server Client\n" |
| 10928 | NEIGHBOR_ADDR_STR |
| 10929 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10930 | { |
| 10931 | struct bgp *bgp; |
| 10932 | struct peer *peer; |
| 10933 | safi_t safi; |
| 10934 | |
| 10935 | /* BGP structure lookup. */ |
| 10936 | if (argc == 4) |
| 10937 | { |
| 10938 | bgp = bgp_lookup_by_name (argv[0]); |
| 10939 | if (bgp == NULL) |
| 10940 | { |
| 10941 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10942 | return CMD_WARNING; |
| 10943 | } |
| 10944 | } |
| 10945 | else |
| 10946 | { |
| 10947 | bgp = bgp_get_default (); |
| 10948 | if (bgp == NULL) |
| 10949 | { |
| 10950 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10951 | return CMD_WARNING; |
| 10952 | } |
| 10953 | } |
| 10954 | |
| 10955 | if (argc == 4) { |
| 10956 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10957 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10958 | } else { |
| 10959 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10960 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10961 | } |
| 10962 | |
| 10963 | if (! peer) |
| 10964 | return CMD_WARNING; |
| 10965 | |
| 10966 | if (! peer->afc[AFI_IP][safi]) |
| 10967 | { |
| 10968 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10969 | VTY_NEWLINE); |
| 10970 | return CMD_WARNING; |
| 10971 | } |
| 10972 | |
| 10973 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10974 | PEER_FLAG_RSERVER_CLIENT)) |
| 10975 | { |
| 10976 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10977 | VTY_NEWLINE); |
| 10978 | return CMD_WARNING; |
| 10979 | } |
| 10980 | |
| 10981 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10982 | (argc == 4) ? argv[3] : argv[2], |
| 10983 | AFI_IP, safi, NULL, 1); |
| 10984 | } |
| 10985 | |
| 10986 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10987 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 10988 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10989 | SHOW_STR |
| 10990 | BGP_STR |
| 10991 | "Address family\n" |
| 10992 | "Address Family modifier\n" |
| 10993 | "Address Family modifier\n" |
| 10994 | "Information about Route Server Client\n" |
| 10995 | NEIGHBOR_ADDR_STR |
| 10996 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10997 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10998 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10999 | DEFUN (show_bgp_view_neighbor_routes, |
| 11000 | show_bgp_view_neighbor_routes_cmd, |
| 11001 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11002 | SHOW_STR |
| 11003 | BGP_STR |
| 11004 | "BGP view\n" |
| 11005 | "BGP view name\n" |
| 11006 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11007 | "Neighbor to display information about\n" |
| 11008 | "Neighbor to display information about\n" |
| 11009 | "Display routes learned from neighbor\n") |
| 11010 | { |
| 11011 | struct peer *peer; |
| 11012 | |
| 11013 | if (argc == 2) |
| 11014 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11015 | else |
| 11016 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11017 | |
| 11018 | if (! peer) |
| 11019 | return CMD_WARNING; |
| 11020 | |
| 11021 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11022 | bgp_show_type_neighbor); |
| 11023 | } |
| 11024 | |
| 11025 | ALIAS (show_bgp_view_neighbor_routes, |
| 11026 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11027 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11028 | SHOW_STR |
| 11029 | BGP_STR |
| 11030 | "BGP view\n" |
| 11031 | "BGP view name\n" |
| 11032 | "Address family\n" |
| 11033 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11034 | "Neighbor to display information about\n" |
| 11035 | "Neighbor to display information about\n" |
| 11036 | "Display routes learned from neighbor\n") |
| 11037 | |
| 11038 | DEFUN (show_bgp_view_neighbor_damp, |
| 11039 | show_bgp_view_neighbor_damp_cmd, |
| 11040 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11041 | SHOW_STR |
| 11042 | BGP_STR |
| 11043 | "BGP view\n" |
| 11044 | "BGP view name\n" |
| 11045 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11046 | "Neighbor to display information about\n" |
| 11047 | "Neighbor to display information about\n" |
| 11048 | "Display the dampened routes received from neighbor\n") |
| 11049 | { |
| 11050 | struct peer *peer; |
| 11051 | |
| 11052 | if (argc == 2) |
| 11053 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11054 | else |
| 11055 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11056 | |
| 11057 | if (! peer) |
| 11058 | return CMD_WARNING; |
| 11059 | |
| 11060 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11061 | bgp_show_type_damp_neighbor); |
| 11062 | } |
| 11063 | |
| 11064 | ALIAS (show_bgp_view_neighbor_damp, |
| 11065 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11066 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11067 | SHOW_STR |
| 11068 | BGP_STR |
| 11069 | "BGP view\n" |
| 11070 | "BGP view name\n" |
| 11071 | "Address family\n" |
| 11072 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11073 | "Neighbor to display information about\n" |
| 11074 | "Neighbor to display information about\n" |
| 11075 | "Display the dampened routes received from neighbor\n") |
| 11076 | |
| 11077 | DEFUN (show_bgp_view_neighbor_flap, |
| 11078 | show_bgp_view_neighbor_flap_cmd, |
| 11079 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11080 | SHOW_STR |
| 11081 | BGP_STR |
| 11082 | "BGP view\n" |
| 11083 | "BGP view name\n" |
| 11084 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11085 | "Neighbor to display information about\n" |
| 11086 | "Neighbor to display information about\n" |
| 11087 | "Display flap statistics of the routes learned from neighbor\n") |
| 11088 | { |
| 11089 | struct peer *peer; |
| 11090 | |
| 11091 | if (argc == 2) |
| 11092 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11093 | else |
| 11094 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11095 | |
| 11096 | if (! peer) |
| 11097 | return CMD_WARNING; |
| 11098 | |
| 11099 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11100 | bgp_show_type_flap_neighbor); |
| 11101 | } |
| 11102 | |
| 11103 | ALIAS (show_bgp_view_neighbor_flap, |
| 11104 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11105 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11106 | SHOW_STR |
| 11107 | BGP_STR |
| 11108 | "BGP view\n" |
| 11109 | "BGP view name\n" |
| 11110 | "Address family\n" |
| 11111 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11112 | "Neighbor to display information about\n" |
| 11113 | "Neighbor to display information about\n" |
| 11114 | "Display flap statistics of the routes learned from neighbor\n") |
| 11115 | |
| 11116 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11117 | show_bgp_neighbor_routes_cmd, |
| 11118 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11119 | SHOW_STR |
| 11120 | BGP_STR |
| 11121 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11122 | "Neighbor to display information about\n" |
| 11123 | "Neighbor to display information about\n" |
| 11124 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11125 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11126 | |
| 11127 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11128 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11129 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11130 | SHOW_STR |
| 11131 | BGP_STR |
| 11132 | "Address family\n" |
| 11133 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11134 | "Neighbor to display information about\n" |
| 11135 | "Neighbor to display information about\n" |
| 11136 | "Display routes learned from neighbor\n") |
| 11137 | |
| 11138 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11139 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11140 | ipv6_bgp_neighbor_routes_cmd, |
| 11141 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11142 | SHOW_STR |
| 11143 | IPV6_STR |
| 11144 | BGP_STR |
| 11145 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11146 | "Neighbor to display information about\n" |
| 11147 | "Neighbor to display information about\n" |
| 11148 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11149 | |
| 11150 | /* old command */ |
| 11151 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11152 | ipv6_mbgp_neighbor_routes_cmd, |
| 11153 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11154 | SHOW_STR |
| 11155 | IPV6_STR |
| 11156 | MBGP_STR |
| 11157 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11158 | "Neighbor to display information about\n" |
| 11159 | "Neighbor to display information about\n" |
| 11160 | "Display routes learned from neighbor\n") |
| 11161 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11162 | struct peer *peer; |
| 11163 | |
| 11164 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11165 | if (! peer) |
| 11166 | return CMD_WARNING; |
| 11167 | |
| 11168 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11169 | bgp_show_type_neighbor); |
| 11170 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11171 | |
| 11172 | ALIAS (show_bgp_view_neighbor_flap, |
| 11173 | show_bgp_neighbor_flap_cmd, |
| 11174 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11175 | SHOW_STR |
| 11176 | BGP_STR |
| 11177 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11178 | "Neighbor to display information about\n" |
| 11179 | "Neighbor to display information about\n" |
| 11180 | "Display flap statistics of the routes learned from neighbor\n") |
| 11181 | |
| 11182 | ALIAS (show_bgp_view_neighbor_flap, |
| 11183 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11184 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11185 | SHOW_STR |
| 11186 | BGP_STR |
| 11187 | "Address family\n" |
| 11188 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11189 | "Neighbor to display information about\n" |
| 11190 | "Neighbor to display information about\n" |
| 11191 | "Display flap statistics of the routes learned from neighbor\n") |
| 11192 | |
| 11193 | ALIAS (show_bgp_view_neighbor_damp, |
| 11194 | show_bgp_neighbor_damp_cmd, |
| 11195 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11196 | SHOW_STR |
| 11197 | BGP_STR |
| 11198 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11199 | "Neighbor to display information about\n" |
| 11200 | "Neighbor to display information about\n" |
| 11201 | "Display the dampened routes received from neighbor\n") |
| 11202 | |
| 11203 | ALIAS (show_bgp_view_neighbor_damp, |
| 11204 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11205 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11206 | SHOW_STR |
| 11207 | BGP_STR |
| 11208 | "Address family\n" |
| 11209 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11210 | "Neighbor to display information about\n" |
| 11211 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11212 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11213 | |
| 11214 | DEFUN (show_bgp_view_rsclient, |
| 11215 | show_bgp_view_rsclient_cmd, |
| 11216 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11217 | SHOW_STR |
| 11218 | BGP_STR |
| 11219 | "BGP view\n" |
| 11220 | "BGP view name\n" |
| 11221 | "Information about Route Server Client\n" |
| 11222 | NEIGHBOR_ADDR_STR) |
| 11223 | { |
| 11224 | struct bgp_table *table; |
| 11225 | struct peer *peer; |
| 11226 | |
| 11227 | if (argc == 2) |
| 11228 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11229 | else |
| 11230 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11231 | |
| 11232 | if (! peer) |
| 11233 | return CMD_WARNING; |
| 11234 | |
| 11235 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11236 | { |
| 11237 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11238 | VTY_NEWLINE); |
| 11239 | return CMD_WARNING; |
| 11240 | } |
| 11241 | |
| 11242 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11243 | PEER_FLAG_RSERVER_CLIENT)) |
| 11244 | { |
| 11245 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11246 | VTY_NEWLINE); |
| 11247 | return CMD_WARNING; |
| 11248 | } |
| 11249 | |
| 11250 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11251 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11252 | 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] | 11253 | } |
| 11254 | |
| 11255 | ALIAS (show_bgp_view_rsclient, |
| 11256 | show_bgp_rsclient_cmd, |
| 11257 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11258 | SHOW_STR |
| 11259 | BGP_STR |
| 11260 | "Information about Route Server Client\n" |
| 11261 | NEIGHBOR_ADDR_STR) |
| 11262 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11263 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11264 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11265 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11266 | SHOW_STR |
| 11267 | BGP_STR |
| 11268 | "BGP view\n" |
| 11269 | "BGP view name\n" |
| 11270 | "Address family\n" |
| 11271 | "Address Family modifier\n" |
| 11272 | "Address Family modifier\n" |
| 11273 | "Information about Route Server Client\n" |
| 11274 | NEIGHBOR_ADDR_STR) |
| 11275 | { |
| 11276 | struct bgp_table *table; |
| 11277 | struct peer *peer; |
| 11278 | safi_t safi; |
| 11279 | |
| 11280 | if (argc == 3) { |
| 11281 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11282 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11283 | } else { |
| 11284 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11285 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11286 | } |
| 11287 | |
| 11288 | if (! peer) |
| 11289 | return CMD_WARNING; |
| 11290 | |
| 11291 | if (! peer->afc[AFI_IP6][safi]) |
| 11292 | { |
| 11293 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11294 | VTY_NEWLINE); |
| 11295 | return CMD_WARNING; |
| 11296 | } |
| 11297 | |
| 11298 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11299 | PEER_FLAG_RSERVER_CLIENT)) |
| 11300 | { |
| 11301 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11302 | VTY_NEWLINE); |
| 11303 | return CMD_WARNING; |
| 11304 | } |
| 11305 | |
| 11306 | table = peer->rib[AFI_IP6][safi]; |
| 11307 | |
| 11308 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11309 | } |
| 11310 | |
| 11311 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11312 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11313 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11314 | SHOW_STR |
| 11315 | BGP_STR |
| 11316 | "Address family\n" |
| 11317 | "Address Family modifier\n" |
| 11318 | "Address Family modifier\n" |
| 11319 | "Information about Route Server Client\n" |
| 11320 | NEIGHBOR_ADDR_STR) |
| 11321 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11322 | DEFUN (show_bgp_view_rsclient_route, |
| 11323 | show_bgp_view_rsclient_route_cmd, |
| 11324 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11325 | SHOW_STR |
| 11326 | BGP_STR |
| 11327 | "BGP view\n" |
| 11328 | "BGP view name\n" |
| 11329 | "Information about Route Server Client\n" |
| 11330 | NEIGHBOR_ADDR_STR |
| 11331 | "Network in the BGP routing table to display\n") |
| 11332 | { |
| 11333 | struct bgp *bgp; |
| 11334 | struct peer *peer; |
| 11335 | |
| 11336 | /* BGP structure lookup. */ |
| 11337 | if (argc == 3) |
| 11338 | { |
| 11339 | bgp = bgp_lookup_by_name (argv[0]); |
| 11340 | if (bgp == NULL) |
| 11341 | { |
| 11342 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11343 | return CMD_WARNING; |
| 11344 | } |
| 11345 | } |
| 11346 | else |
| 11347 | { |
| 11348 | bgp = bgp_get_default (); |
| 11349 | if (bgp == NULL) |
| 11350 | { |
| 11351 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11352 | return CMD_WARNING; |
| 11353 | } |
| 11354 | } |
| 11355 | |
| 11356 | if (argc == 3) |
| 11357 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11358 | else |
| 11359 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11360 | |
| 11361 | if (! peer) |
| 11362 | return CMD_WARNING; |
| 11363 | |
| 11364 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11365 | { |
| 11366 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11367 | VTY_NEWLINE); |
| 11368 | return CMD_WARNING; |
| 11369 | } |
| 11370 | |
| 11371 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11372 | PEER_FLAG_RSERVER_CLIENT)) |
| 11373 | { |
| 11374 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11375 | VTY_NEWLINE); |
| 11376 | return CMD_WARNING; |
| 11377 | } |
| 11378 | |
| 11379 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11380 | (argc == 3) ? argv[2] : argv[1], |
| 11381 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11382 | } |
| 11383 | |
| 11384 | ALIAS (show_bgp_view_rsclient_route, |
| 11385 | show_bgp_rsclient_route_cmd, |
| 11386 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11387 | SHOW_STR |
| 11388 | BGP_STR |
| 11389 | "Information about Route Server Client\n" |
| 11390 | NEIGHBOR_ADDR_STR |
| 11391 | "Network in the BGP routing table to display\n") |
| 11392 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11393 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11394 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11395 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11396 | SHOW_STR |
| 11397 | BGP_STR |
| 11398 | "BGP view\n" |
| 11399 | "BGP view name\n" |
| 11400 | "Address family\n" |
| 11401 | "Address Family modifier\n" |
| 11402 | "Address Family modifier\n" |
| 11403 | "Information about Route Server Client\n" |
| 11404 | NEIGHBOR_ADDR_STR |
| 11405 | "Network in the BGP routing table to display\n") |
| 11406 | { |
| 11407 | struct bgp *bgp; |
| 11408 | struct peer *peer; |
| 11409 | safi_t safi; |
| 11410 | |
| 11411 | /* BGP structure lookup. */ |
| 11412 | if (argc == 4) |
| 11413 | { |
| 11414 | bgp = bgp_lookup_by_name (argv[0]); |
| 11415 | if (bgp == NULL) |
| 11416 | { |
| 11417 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11418 | return CMD_WARNING; |
| 11419 | } |
| 11420 | } |
| 11421 | else |
| 11422 | { |
| 11423 | bgp = bgp_get_default (); |
| 11424 | if (bgp == NULL) |
| 11425 | { |
| 11426 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11427 | return CMD_WARNING; |
| 11428 | } |
| 11429 | } |
| 11430 | |
| 11431 | if (argc == 4) { |
| 11432 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11433 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11434 | } else { |
| 11435 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11436 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11437 | } |
| 11438 | |
| 11439 | if (! peer) |
| 11440 | return CMD_WARNING; |
| 11441 | |
| 11442 | if (! peer->afc[AFI_IP6][safi]) |
| 11443 | { |
| 11444 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11445 | VTY_NEWLINE); |
| 11446 | return CMD_WARNING; |
| 11447 | } |
| 11448 | |
| 11449 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11450 | PEER_FLAG_RSERVER_CLIENT)) |
| 11451 | { |
| 11452 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11453 | VTY_NEWLINE); |
| 11454 | return CMD_WARNING; |
| 11455 | } |
| 11456 | |
| 11457 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11458 | (argc == 4) ? argv[3] : argv[2], |
| 11459 | AFI_IP6, safi, NULL, 0); |
| 11460 | } |
| 11461 | |
| 11462 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11463 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11464 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11465 | SHOW_STR |
| 11466 | BGP_STR |
| 11467 | "Address family\n" |
| 11468 | "Address Family modifier\n" |
| 11469 | "Address Family modifier\n" |
| 11470 | "Information about Route Server Client\n" |
| 11471 | NEIGHBOR_ADDR_STR |
| 11472 | "Network in the BGP routing table to display\n") |
| 11473 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11474 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11475 | show_bgp_view_rsclient_prefix_cmd, |
| 11476 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11477 | SHOW_STR |
| 11478 | BGP_STR |
| 11479 | "BGP view\n" |
| 11480 | "BGP view name\n" |
| 11481 | "Information about Route Server Client\n" |
| 11482 | NEIGHBOR_ADDR_STR |
| 11483 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11484 | { |
| 11485 | struct bgp *bgp; |
| 11486 | struct peer *peer; |
| 11487 | |
| 11488 | /* BGP structure lookup. */ |
| 11489 | if (argc == 3) |
| 11490 | { |
| 11491 | bgp = bgp_lookup_by_name (argv[0]); |
| 11492 | if (bgp == NULL) |
| 11493 | { |
| 11494 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11495 | return CMD_WARNING; |
| 11496 | } |
| 11497 | } |
| 11498 | else |
| 11499 | { |
| 11500 | bgp = bgp_get_default (); |
| 11501 | if (bgp == NULL) |
| 11502 | { |
| 11503 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11504 | return CMD_WARNING; |
| 11505 | } |
| 11506 | } |
| 11507 | |
| 11508 | if (argc == 3) |
| 11509 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11510 | else |
| 11511 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11512 | |
| 11513 | if (! peer) |
| 11514 | return CMD_WARNING; |
| 11515 | |
| 11516 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11517 | { |
| 11518 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11519 | VTY_NEWLINE); |
| 11520 | return CMD_WARNING; |
| 11521 | } |
| 11522 | |
| 11523 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11524 | PEER_FLAG_RSERVER_CLIENT)) |
| 11525 | { |
| 11526 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11527 | VTY_NEWLINE); |
| 11528 | return CMD_WARNING; |
| 11529 | } |
| 11530 | |
| 11531 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11532 | (argc == 3) ? argv[2] : argv[1], |
| 11533 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11534 | } |
| 11535 | |
| 11536 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11537 | show_bgp_rsclient_prefix_cmd, |
| 11538 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11539 | SHOW_STR |
| 11540 | BGP_STR |
| 11541 | "Information about Route Server Client\n" |
| 11542 | NEIGHBOR_ADDR_STR |
| 11543 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11544 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11545 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11546 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11547 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11548 | SHOW_STR |
| 11549 | BGP_STR |
| 11550 | "BGP view\n" |
| 11551 | "BGP view name\n" |
| 11552 | "Address family\n" |
| 11553 | "Address Family modifier\n" |
| 11554 | "Address Family modifier\n" |
| 11555 | "Information about Route Server Client\n" |
| 11556 | NEIGHBOR_ADDR_STR |
| 11557 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11558 | { |
| 11559 | struct bgp *bgp; |
| 11560 | struct peer *peer; |
| 11561 | safi_t safi; |
| 11562 | |
| 11563 | /* BGP structure lookup. */ |
| 11564 | if (argc == 4) |
| 11565 | { |
| 11566 | bgp = bgp_lookup_by_name (argv[0]); |
| 11567 | if (bgp == NULL) |
| 11568 | { |
| 11569 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11570 | return CMD_WARNING; |
| 11571 | } |
| 11572 | } |
| 11573 | else |
| 11574 | { |
| 11575 | bgp = bgp_get_default (); |
| 11576 | if (bgp == NULL) |
| 11577 | { |
| 11578 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11579 | return CMD_WARNING; |
| 11580 | } |
| 11581 | } |
| 11582 | |
| 11583 | if (argc == 4) { |
| 11584 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11585 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11586 | } else { |
| 11587 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11588 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11589 | } |
| 11590 | |
| 11591 | if (! peer) |
| 11592 | return CMD_WARNING; |
| 11593 | |
| 11594 | if (! peer->afc[AFI_IP6][safi]) |
| 11595 | { |
| 11596 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11597 | VTY_NEWLINE); |
| 11598 | return CMD_WARNING; |
| 11599 | } |
| 11600 | |
| 11601 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11602 | PEER_FLAG_RSERVER_CLIENT)) |
| 11603 | { |
| 11604 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11605 | VTY_NEWLINE); |
| 11606 | return CMD_WARNING; |
| 11607 | } |
| 11608 | |
| 11609 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11610 | (argc == 4) ? argv[3] : argv[2], |
| 11611 | AFI_IP6, safi, NULL, 1); |
| 11612 | } |
| 11613 | |
| 11614 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11615 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11616 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11617 | SHOW_STR |
| 11618 | BGP_STR |
| 11619 | "Address family\n" |
| 11620 | "Address Family modifier\n" |
| 11621 | "Address Family modifier\n" |
| 11622 | "Information about Route Server Client\n" |
| 11623 | NEIGHBOR_ADDR_STR |
| 11624 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11625 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11626 | #endif /* HAVE_IPV6 */ |
| 11627 | |
| 11628 | struct bgp_table *bgp_distance_table; |
| 11629 | |
| 11630 | struct bgp_distance |
| 11631 | { |
| 11632 | /* Distance value for the IP source prefix. */ |
| 11633 | u_char distance; |
| 11634 | |
| 11635 | /* Name of the access-list to be matched. */ |
| 11636 | char *access_list; |
| 11637 | }; |
| 11638 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11639 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11640 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11641 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11642 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11643 | } |
| 11644 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11645 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11646 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11647 | { |
| 11648 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11649 | } |
| 11650 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11651 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11652 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11653 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11654 | { |
| 11655 | int ret; |
| 11656 | struct prefix_ipv4 p; |
| 11657 | u_char distance; |
| 11658 | struct bgp_node *rn; |
| 11659 | struct bgp_distance *bdistance; |
| 11660 | |
| 11661 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11662 | if (ret == 0) |
| 11663 | { |
| 11664 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11665 | return CMD_WARNING; |
| 11666 | } |
| 11667 | |
| 11668 | distance = atoi (distance_str); |
| 11669 | |
| 11670 | /* Get BGP distance node. */ |
| 11671 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11672 | if (rn->info) |
| 11673 | { |
| 11674 | bdistance = rn->info; |
| 11675 | bgp_unlock_node (rn); |
| 11676 | } |
| 11677 | else |
| 11678 | { |
| 11679 | bdistance = bgp_distance_new (); |
| 11680 | rn->info = bdistance; |
| 11681 | } |
| 11682 | |
| 11683 | /* Set distance value. */ |
| 11684 | bdistance->distance = distance; |
| 11685 | |
| 11686 | /* Reset access-list configuration. */ |
| 11687 | if (bdistance->access_list) |
| 11688 | { |
| 11689 | free (bdistance->access_list); |
| 11690 | bdistance->access_list = NULL; |
| 11691 | } |
| 11692 | if (access_list_str) |
| 11693 | bdistance->access_list = strdup (access_list_str); |
| 11694 | |
| 11695 | return CMD_SUCCESS; |
| 11696 | } |
| 11697 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11698 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11699 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11700 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11701 | { |
| 11702 | int ret; |
| 11703 | struct prefix_ipv4 p; |
| 11704 | u_char distance; |
| 11705 | struct bgp_node *rn; |
| 11706 | struct bgp_distance *bdistance; |
| 11707 | |
| 11708 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11709 | if (ret == 0) |
| 11710 | { |
| 11711 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11712 | return CMD_WARNING; |
| 11713 | } |
| 11714 | |
| 11715 | distance = atoi (distance_str); |
| 11716 | |
| 11717 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11718 | if (! rn) |
| 11719 | { |
| 11720 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11721 | return CMD_WARNING; |
| 11722 | } |
| 11723 | |
| 11724 | bdistance = rn->info; |
| 11725 | |
| 11726 | if (bdistance->access_list) |
| 11727 | free (bdistance->access_list); |
| 11728 | bgp_distance_free (bdistance); |
| 11729 | |
| 11730 | rn->info = NULL; |
| 11731 | bgp_unlock_node (rn); |
| 11732 | bgp_unlock_node (rn); |
| 11733 | |
| 11734 | return CMD_SUCCESS; |
| 11735 | } |
| 11736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11737 | /* Apply BGP information to distance method. */ |
| 11738 | u_char |
| 11739 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11740 | { |
| 11741 | struct bgp_node *rn; |
| 11742 | struct prefix_ipv4 q; |
| 11743 | struct peer *peer; |
| 11744 | struct bgp_distance *bdistance; |
| 11745 | struct access_list *alist; |
| 11746 | struct bgp_static *bgp_static; |
| 11747 | |
| 11748 | if (! bgp) |
| 11749 | return 0; |
| 11750 | |
| 11751 | if (p->family != AF_INET) |
| 11752 | return 0; |
| 11753 | |
| 11754 | peer = rinfo->peer; |
| 11755 | |
| 11756 | if (peer->su.sa.sa_family != AF_INET) |
| 11757 | return 0; |
| 11758 | |
| 11759 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11760 | q.family = AF_INET; |
| 11761 | q.prefix = peer->su.sin.sin_addr; |
| 11762 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11763 | |
| 11764 | /* Check source address. */ |
| 11765 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11766 | if (rn) |
| 11767 | { |
| 11768 | bdistance = rn->info; |
| 11769 | bgp_unlock_node (rn); |
| 11770 | |
| 11771 | if (bdistance->access_list) |
| 11772 | { |
| 11773 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11774 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11775 | return bdistance->distance; |
| 11776 | } |
| 11777 | else |
| 11778 | return bdistance->distance; |
| 11779 | } |
| 11780 | |
| 11781 | /* Backdoor check. */ |
| 11782 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11783 | if (rn) |
| 11784 | { |
| 11785 | bgp_static = rn->info; |
| 11786 | bgp_unlock_node (rn); |
| 11787 | |
| 11788 | if (bgp_static->backdoor) |
| 11789 | { |
| 11790 | if (bgp->distance_local) |
| 11791 | return bgp->distance_local; |
| 11792 | else |
| 11793 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11794 | } |
| 11795 | } |
| 11796 | |
| 11797 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 11798 | { |
| 11799 | if (bgp->distance_ebgp) |
| 11800 | return bgp->distance_ebgp; |
| 11801 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11802 | } |
| 11803 | else |
| 11804 | { |
| 11805 | if (bgp->distance_ibgp) |
| 11806 | return bgp->distance_ibgp; |
| 11807 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11808 | } |
| 11809 | } |
| 11810 | |
| 11811 | DEFUN (bgp_distance, |
| 11812 | bgp_distance_cmd, |
| 11813 | "distance bgp <1-255> <1-255> <1-255>", |
| 11814 | "Define an administrative distance\n" |
| 11815 | "BGP distance\n" |
| 11816 | "Distance for routes external to the AS\n" |
| 11817 | "Distance for routes internal to the AS\n" |
| 11818 | "Distance for local routes\n") |
| 11819 | { |
| 11820 | struct bgp *bgp; |
| 11821 | |
| 11822 | bgp = vty->index; |
| 11823 | |
| 11824 | bgp->distance_ebgp = atoi (argv[0]); |
| 11825 | bgp->distance_ibgp = atoi (argv[1]); |
| 11826 | bgp->distance_local = atoi (argv[2]); |
| 11827 | return CMD_SUCCESS; |
| 11828 | } |
| 11829 | |
| 11830 | DEFUN (no_bgp_distance, |
| 11831 | no_bgp_distance_cmd, |
| 11832 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11833 | NO_STR |
| 11834 | "Define an administrative distance\n" |
| 11835 | "BGP distance\n" |
| 11836 | "Distance for routes external to the AS\n" |
| 11837 | "Distance for routes internal to the AS\n" |
| 11838 | "Distance for local routes\n") |
| 11839 | { |
| 11840 | struct bgp *bgp; |
| 11841 | |
| 11842 | bgp = vty->index; |
| 11843 | |
| 11844 | bgp->distance_ebgp= 0; |
| 11845 | bgp->distance_ibgp = 0; |
| 11846 | bgp->distance_local = 0; |
| 11847 | return CMD_SUCCESS; |
| 11848 | } |
| 11849 | |
| 11850 | ALIAS (no_bgp_distance, |
| 11851 | no_bgp_distance2_cmd, |
| 11852 | "no distance bgp", |
| 11853 | NO_STR |
| 11854 | "Define an administrative distance\n" |
| 11855 | "BGP distance\n") |
| 11856 | |
| 11857 | DEFUN (bgp_distance_source, |
| 11858 | bgp_distance_source_cmd, |
| 11859 | "distance <1-255> A.B.C.D/M", |
| 11860 | "Define an administrative distance\n" |
| 11861 | "Administrative distance\n" |
| 11862 | "IP source prefix\n") |
| 11863 | { |
| 11864 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11865 | return CMD_SUCCESS; |
| 11866 | } |
| 11867 | |
| 11868 | DEFUN (no_bgp_distance_source, |
| 11869 | no_bgp_distance_source_cmd, |
| 11870 | "no distance <1-255> A.B.C.D/M", |
| 11871 | NO_STR |
| 11872 | "Define an administrative distance\n" |
| 11873 | "Administrative distance\n" |
| 11874 | "IP source prefix\n") |
| 11875 | { |
| 11876 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 11877 | return CMD_SUCCESS; |
| 11878 | } |
| 11879 | |
| 11880 | DEFUN (bgp_distance_source_access_list, |
| 11881 | bgp_distance_source_access_list_cmd, |
| 11882 | "distance <1-255> A.B.C.D/M WORD", |
| 11883 | "Define an administrative distance\n" |
| 11884 | "Administrative distance\n" |
| 11885 | "IP source prefix\n" |
| 11886 | "Access list name\n") |
| 11887 | { |
| 11888 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 11889 | return CMD_SUCCESS; |
| 11890 | } |
| 11891 | |
| 11892 | DEFUN (no_bgp_distance_source_access_list, |
| 11893 | no_bgp_distance_source_access_list_cmd, |
| 11894 | "no distance <1-255> A.B.C.D/M WORD", |
| 11895 | NO_STR |
| 11896 | "Define an administrative distance\n" |
| 11897 | "Administrative distance\n" |
| 11898 | "IP source prefix\n" |
| 11899 | "Access list name\n") |
| 11900 | { |
| 11901 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 11902 | return CMD_SUCCESS; |
| 11903 | } |
| 11904 | |
| 11905 | DEFUN (bgp_damp_set, |
| 11906 | bgp_damp_set_cmd, |
| 11907 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11908 | "BGP Specific commands\n" |
| 11909 | "Enable route-flap dampening\n" |
| 11910 | "Half-life time for the penalty\n" |
| 11911 | "Value to start reusing a route\n" |
| 11912 | "Value to start suppressing a route\n" |
| 11913 | "Maximum duration to suppress a stable route\n") |
| 11914 | { |
| 11915 | struct bgp *bgp; |
| 11916 | int half = DEFAULT_HALF_LIFE * 60; |
| 11917 | int reuse = DEFAULT_REUSE; |
| 11918 | int suppress = DEFAULT_SUPPRESS; |
| 11919 | int max = 4 * half; |
| 11920 | |
| 11921 | if (argc == 4) |
| 11922 | { |
| 11923 | half = atoi (argv[0]) * 60; |
| 11924 | reuse = atoi (argv[1]); |
| 11925 | suppress = atoi (argv[2]); |
| 11926 | max = atoi (argv[3]) * 60; |
| 11927 | } |
| 11928 | else if (argc == 1) |
| 11929 | { |
| 11930 | half = atoi (argv[0]) * 60; |
| 11931 | max = 4 * half; |
| 11932 | } |
| 11933 | |
| 11934 | bgp = vty->index; |
| 11935 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 11936 | half, reuse, suppress, max); |
| 11937 | } |
| 11938 | |
| 11939 | ALIAS (bgp_damp_set, |
| 11940 | bgp_damp_set2_cmd, |
| 11941 | "bgp dampening <1-45>", |
| 11942 | "BGP Specific commands\n" |
| 11943 | "Enable route-flap dampening\n" |
| 11944 | "Half-life time for the penalty\n") |
| 11945 | |
| 11946 | ALIAS (bgp_damp_set, |
| 11947 | bgp_damp_set3_cmd, |
| 11948 | "bgp dampening", |
| 11949 | "BGP Specific commands\n" |
| 11950 | "Enable route-flap dampening\n") |
| 11951 | |
| 11952 | DEFUN (bgp_damp_unset, |
| 11953 | bgp_damp_unset_cmd, |
| 11954 | "no bgp dampening", |
| 11955 | NO_STR |
| 11956 | "BGP Specific commands\n" |
| 11957 | "Enable route-flap dampening\n") |
| 11958 | { |
| 11959 | struct bgp *bgp; |
| 11960 | |
| 11961 | bgp = vty->index; |
| 11962 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 11963 | } |
| 11964 | |
| 11965 | ALIAS (bgp_damp_unset, |
| 11966 | bgp_damp_unset2_cmd, |
| 11967 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11968 | NO_STR |
| 11969 | "BGP Specific commands\n" |
| 11970 | "Enable route-flap dampening\n" |
| 11971 | "Half-life time for the penalty\n" |
| 11972 | "Value to start reusing a route\n" |
| 11973 | "Value to start suppressing a route\n" |
| 11974 | "Maximum duration to suppress a stable route\n") |
| 11975 | |
| 11976 | DEFUN (show_ip_bgp_dampened_paths, |
| 11977 | show_ip_bgp_dampened_paths_cmd, |
| 11978 | "show ip bgp dampened-paths", |
| 11979 | SHOW_STR |
| 11980 | IP_STR |
| 11981 | BGP_STR |
| 11982 | "Display paths suppressed due to dampening\n") |
| 11983 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11984 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 11985 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11986 | } |
| 11987 | |
| 11988 | DEFUN (show_ip_bgp_flap_statistics, |
| 11989 | show_ip_bgp_flap_statistics_cmd, |
| 11990 | "show ip bgp flap-statistics", |
| 11991 | SHOW_STR |
| 11992 | IP_STR |
| 11993 | BGP_STR |
| 11994 | "Display flap statistics of routes\n") |
| 11995 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11996 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 11997 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11998 | } |
| 11999 | |
| 12000 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12001 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12002 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12003 | const char *ip_str, afi_t afi, safi_t safi, |
| 12004 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12005 | { |
| 12006 | int ret; |
| 12007 | struct prefix match; |
| 12008 | struct bgp_node *rn; |
| 12009 | struct bgp_node *rm; |
| 12010 | struct bgp_info *ri; |
| 12011 | struct bgp_info *ri_temp; |
| 12012 | struct bgp *bgp; |
| 12013 | struct bgp_table *table; |
| 12014 | |
| 12015 | /* BGP structure lookup. */ |
| 12016 | if (view_name) |
| 12017 | { |
| 12018 | bgp = bgp_lookup_by_name (view_name); |
| 12019 | if (bgp == NULL) |
| 12020 | { |
| 12021 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12022 | return CMD_WARNING; |
| 12023 | } |
| 12024 | } |
| 12025 | else |
| 12026 | { |
| 12027 | bgp = bgp_get_default (); |
| 12028 | if (bgp == NULL) |
| 12029 | { |
| 12030 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12031 | return CMD_WARNING; |
| 12032 | } |
| 12033 | } |
| 12034 | |
| 12035 | /* Check IP address argument. */ |
| 12036 | ret = str2prefix (ip_str, &match); |
| 12037 | if (! ret) |
| 12038 | { |
| 12039 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12040 | return CMD_WARNING; |
| 12041 | } |
| 12042 | |
| 12043 | match.family = afi2family (afi); |
| 12044 | |
| 12045 | if (safi == SAFI_MPLS_VPN) |
| 12046 | { |
| 12047 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12048 | { |
| 12049 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12050 | continue; |
| 12051 | |
| 12052 | if ((table = rn->info) != NULL) |
| 12053 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12054 | { |
| 12055 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12056 | { |
| 12057 | ri = rm->info; |
| 12058 | while (ri) |
| 12059 | { |
| 12060 | if (ri->extra && ri->extra->damp_info) |
| 12061 | { |
| 12062 | ri_temp = ri->next; |
| 12063 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12064 | ri = ri_temp; |
| 12065 | } |
| 12066 | else |
| 12067 | ri = ri->next; |
| 12068 | } |
| 12069 | } |
| 12070 | |
| 12071 | bgp_unlock_node (rm); |
| 12072 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12073 | } |
| 12074 | } |
| 12075 | else |
| 12076 | { |
| 12077 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12078 | { |
| 12079 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12080 | { |
| 12081 | ri = rn->info; |
| 12082 | while (ri) |
| 12083 | { |
| 12084 | if (ri->extra && ri->extra->damp_info) |
| 12085 | { |
| 12086 | ri_temp = ri->next; |
| 12087 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12088 | ri = ri_temp; |
| 12089 | } |
| 12090 | else |
| 12091 | ri = ri->next; |
| 12092 | } |
| 12093 | } |
| 12094 | |
| 12095 | bgp_unlock_node (rn); |
| 12096 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12097 | } |
| 12098 | |
| 12099 | return CMD_SUCCESS; |
| 12100 | } |
| 12101 | |
| 12102 | DEFUN (clear_ip_bgp_dampening, |
| 12103 | clear_ip_bgp_dampening_cmd, |
| 12104 | "clear ip bgp dampening", |
| 12105 | CLEAR_STR |
| 12106 | IP_STR |
| 12107 | BGP_STR |
| 12108 | "Clear route flap dampening information\n") |
| 12109 | { |
| 12110 | bgp_damp_info_clean (); |
| 12111 | return CMD_SUCCESS; |
| 12112 | } |
| 12113 | |
| 12114 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12115 | clear_ip_bgp_dampening_prefix_cmd, |
| 12116 | "clear ip bgp dampening A.B.C.D/M", |
| 12117 | CLEAR_STR |
| 12118 | IP_STR |
| 12119 | BGP_STR |
| 12120 | "Clear route flap dampening information\n" |
| 12121 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12122 | { |
| 12123 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12124 | SAFI_UNICAST, NULL, 1); |
| 12125 | } |
| 12126 | |
| 12127 | DEFUN (clear_ip_bgp_dampening_address, |
| 12128 | clear_ip_bgp_dampening_address_cmd, |
| 12129 | "clear ip bgp dampening A.B.C.D", |
| 12130 | CLEAR_STR |
| 12131 | IP_STR |
| 12132 | BGP_STR |
| 12133 | "Clear route flap dampening information\n" |
| 12134 | "Network to clear damping information\n") |
| 12135 | { |
| 12136 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12137 | SAFI_UNICAST, NULL, 0); |
| 12138 | } |
| 12139 | |
| 12140 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12141 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12142 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12143 | CLEAR_STR |
| 12144 | IP_STR |
| 12145 | BGP_STR |
| 12146 | "Clear route flap dampening information\n" |
| 12147 | "Network to clear damping information\n" |
| 12148 | "Network mask\n") |
| 12149 | { |
| 12150 | int ret; |
| 12151 | char prefix_str[BUFSIZ]; |
| 12152 | |
| 12153 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12154 | if (! ret) |
| 12155 | { |
| 12156 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12157 | return CMD_WARNING; |
| 12158 | } |
| 12159 | |
| 12160 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12161 | SAFI_UNICAST, NULL, 0); |
| 12162 | } |
| 12163 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12164 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12165 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12166 | afi_t afi, safi_t safi, int *write) |
| 12167 | { |
| 12168 | struct bgp_node *prn; |
| 12169 | struct bgp_node *rn; |
| 12170 | struct bgp_table *table; |
| 12171 | struct prefix *p; |
| 12172 | struct prefix_rd *prd; |
| 12173 | struct bgp_static *bgp_static; |
| 12174 | u_int32_t label; |
| 12175 | char buf[SU_ADDRSTRLEN]; |
| 12176 | char rdbuf[RD_ADDRSTRLEN]; |
| 12177 | |
| 12178 | /* Network configuration. */ |
| 12179 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12180 | if ((table = prn->info) != NULL) |
| 12181 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12182 | if ((bgp_static = rn->info) != NULL) |
| 12183 | { |
| 12184 | p = &rn->p; |
| 12185 | prd = (struct prefix_rd *) &prn->p; |
| 12186 | |
| 12187 | /* "address-family" display. */ |
| 12188 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12189 | |
| 12190 | /* "network" configuration display. */ |
| 12191 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12192 | label = decode_label (bgp_static->tag); |
| 12193 | |
| 12194 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12195 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12196 | p->prefixlen, |
| 12197 | rdbuf, label); |
| 12198 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12199 | } |
| 12200 | return 0; |
| 12201 | } |
| 12202 | |
| 12203 | /* Configuration of static route announcement and aggregate |
| 12204 | information. */ |
| 12205 | int |
| 12206 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12207 | afi_t afi, safi_t safi, int *write) |
| 12208 | { |
| 12209 | struct bgp_node *rn; |
| 12210 | struct prefix *p; |
| 12211 | struct bgp_static *bgp_static; |
| 12212 | struct bgp_aggregate *bgp_aggregate; |
| 12213 | char buf[SU_ADDRSTRLEN]; |
| 12214 | |
| 12215 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12216 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12217 | |
| 12218 | /* Network configuration. */ |
| 12219 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12220 | if ((bgp_static = rn->info) != NULL) |
| 12221 | { |
| 12222 | p = &rn->p; |
| 12223 | |
| 12224 | /* "address-family" display. */ |
| 12225 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12226 | |
| 12227 | /* "network" configuration display. */ |
| 12228 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12229 | { |
| 12230 | u_int32_t destination; |
| 12231 | struct in_addr netmask; |
| 12232 | |
| 12233 | destination = ntohl (p->u.prefix4.s_addr); |
| 12234 | masklen2ip (p->prefixlen, &netmask); |
| 12235 | vty_out (vty, " network %s", |
| 12236 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12237 | |
| 12238 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12239 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12240 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12241 | || p->u.prefix4.s_addr == 0) |
| 12242 | { |
| 12243 | /* Natural mask is not display. */ |
| 12244 | } |
| 12245 | else |
| 12246 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12247 | } |
| 12248 | else |
| 12249 | { |
| 12250 | vty_out (vty, " network %s/%d", |
| 12251 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12252 | p->prefixlen); |
| 12253 | } |
| 12254 | |
| 12255 | if (bgp_static->rmap.name) |
| 12256 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12257 | else |
| 12258 | { |
| 12259 | if (bgp_static->backdoor) |
| 12260 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12261 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12262 | |
| 12263 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12264 | } |
| 12265 | |
| 12266 | /* Aggregate-address configuration. */ |
| 12267 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12268 | if ((bgp_aggregate = rn->info) != NULL) |
| 12269 | { |
| 12270 | p = &rn->p; |
| 12271 | |
| 12272 | /* "address-family" display. */ |
| 12273 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12274 | |
| 12275 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12276 | { |
| 12277 | struct in_addr netmask; |
| 12278 | |
| 12279 | masklen2ip (p->prefixlen, &netmask); |
| 12280 | vty_out (vty, " aggregate-address %s %s", |
| 12281 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12282 | inet_ntoa (netmask)); |
| 12283 | } |
| 12284 | else |
| 12285 | { |
| 12286 | vty_out (vty, " aggregate-address %s/%d", |
| 12287 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12288 | p->prefixlen); |
| 12289 | } |
| 12290 | |
| 12291 | if (bgp_aggregate->as_set) |
| 12292 | vty_out (vty, " as-set"); |
| 12293 | |
| 12294 | if (bgp_aggregate->summary_only) |
| 12295 | vty_out (vty, " summary-only"); |
| 12296 | |
| 12297 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12298 | } |
| 12299 | |
| 12300 | return 0; |
| 12301 | } |
| 12302 | |
| 12303 | int |
| 12304 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12305 | { |
| 12306 | struct bgp_node *rn; |
| 12307 | struct bgp_distance *bdistance; |
| 12308 | |
| 12309 | /* Distance configuration. */ |
| 12310 | if (bgp->distance_ebgp |
| 12311 | && bgp->distance_ibgp |
| 12312 | && bgp->distance_local |
| 12313 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12314 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12315 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12316 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12317 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12318 | VTY_NEWLINE); |
| 12319 | |
| 12320 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12321 | if ((bdistance = rn->info) != NULL) |
| 12322 | { |
| 12323 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12324 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12325 | bdistance->access_list ? bdistance->access_list : "", |
| 12326 | VTY_NEWLINE); |
| 12327 | } |
| 12328 | |
| 12329 | return 0; |
| 12330 | } |
| 12331 | |
| 12332 | /* Allocate routing table structure and install commands. */ |
| 12333 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12334 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12335 | { |
| 12336 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12337 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12338 | |
| 12339 | /* IPv4 BGP commands. */ |
| 12340 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12341 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12342 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12343 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12344 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12345 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12346 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12347 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12348 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12349 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12350 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12351 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12352 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12353 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12354 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12355 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12356 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12357 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12358 | |
| 12359 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12360 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12361 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12362 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12363 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12364 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12365 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12366 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12367 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12368 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12369 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12370 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12371 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12372 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12373 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12374 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12375 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12376 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12377 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12378 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12379 | |
| 12380 | /* IPv4 unicast configuration. */ |
| 12381 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12382 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12383 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12384 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12385 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12386 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12387 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12388 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12389 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12390 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12391 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12392 | 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] | 12393 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12394 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12395 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12396 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12397 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12398 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12399 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12400 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12401 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12402 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12403 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12404 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12405 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12406 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12407 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12408 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12409 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12410 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12411 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12412 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12413 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12414 | |
| 12415 | /* IPv4 multicast configuration. */ |
| 12416 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12417 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12418 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12419 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12420 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12421 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12422 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12423 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12424 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12425 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12426 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12427 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12428 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12429 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12430 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12431 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12432 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12433 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12434 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12435 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12436 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12437 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12438 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12439 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12440 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12441 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12442 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12443 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12444 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12445 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12446 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12447 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12448 | |
| 12449 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12450 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12451 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12452 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12453 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12454 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12455 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12456 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12457 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12458 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12459 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12460 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12461 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12462 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12463 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12464 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12465 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12466 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12467 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12468 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12469 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12470 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12471 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12472 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12473 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12474 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12475 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12476 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12477 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12478 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12479 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12480 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12481 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12482 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12483 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12484 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12485 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12486 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12487 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12488 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12489 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12490 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12491 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12492 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12493 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12494 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12495 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12496 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12497 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12498 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12499 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12500 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12501 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12502 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12503 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12504 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12505 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12506 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12507 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12508 | 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] | 12509 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12510 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12511 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12512 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12513 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12514 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12515 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 12516 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12517 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12518 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12519 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12520 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12521 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12522 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12523 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12524 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12525 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12526 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12527 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12528 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12529 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12530 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12531 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12532 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12533 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12534 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12535 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12536 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12537 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12538 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12539 | |
| 12540 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12541 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12542 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12543 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12544 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12545 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12546 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12547 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12548 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12549 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12550 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12551 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12552 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12553 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12554 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12555 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12556 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12557 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12558 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12559 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12560 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12561 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12562 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12563 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12564 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12565 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12566 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12567 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12568 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12569 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12570 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12571 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12572 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12573 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12574 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12575 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12576 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12577 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12578 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12579 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12580 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12581 | |
| 12582 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12583 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12584 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12585 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12586 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12587 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12588 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12589 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12590 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12591 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12592 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12593 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12594 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12595 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12596 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12597 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12598 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12599 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12600 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12601 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12602 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12603 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12604 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12605 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12606 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12607 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12608 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12609 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12610 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12611 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12612 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12613 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12614 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12615 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12616 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12617 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12618 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12619 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12620 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12621 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12622 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12623 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12624 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12625 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12626 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12627 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12628 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12629 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12630 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12631 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12632 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12633 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12634 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12635 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12636 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12637 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12638 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12639 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12640 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12641 | 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] | 12642 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12643 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12644 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12645 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12646 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12647 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12648 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 12649 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12650 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12651 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12652 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12653 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12654 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12655 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12656 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12657 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12658 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12659 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12660 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12661 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12662 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12663 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12664 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12665 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12666 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12667 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12668 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12669 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12670 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12671 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12672 | |
| 12673 | /* BGP dampening clear commands */ |
| 12674 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12675 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12676 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12677 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12678 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12679 | /* prefix count */ |
| 12680 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12681 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12682 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12683 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12684 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12685 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12686 | /* New config IPv6 BGP commands. */ |
| 12687 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12688 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12689 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12690 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12691 | |
| 12692 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12693 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12694 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12695 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12696 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12697 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12698 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12699 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12700 | /* Old config IPv6 BGP commands. */ |
| 12701 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12702 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12703 | |
| 12704 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12705 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12706 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12707 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12708 | |
| 12709 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12710 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12711 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12712 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12713 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12714 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12715 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12716 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12717 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12718 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12719 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12720 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12721 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12722 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12723 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12724 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12725 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12726 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12727 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12728 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12729 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12730 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12731 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12732 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12733 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12734 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12735 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12736 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12737 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12738 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12739 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12740 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12741 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12742 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12743 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12744 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12745 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12746 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12747 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12748 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12749 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12750 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12751 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12752 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12753 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12754 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12755 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12756 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12757 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12758 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12759 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12760 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12761 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12762 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12763 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12764 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12765 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12766 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12767 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12768 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12769 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12770 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12771 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12772 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12773 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12774 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12775 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12776 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12777 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12778 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12779 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12780 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12781 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12782 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12783 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12784 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12785 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12786 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12787 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12788 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12789 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12790 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12791 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12792 | |
| 12793 | /* Restricted: |
| 12794 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12795 | */ |
| 12796 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12797 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12798 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12799 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12800 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12801 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12802 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12803 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12804 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12805 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12806 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12807 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12808 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12809 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12810 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12811 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12812 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12813 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12814 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12815 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12816 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12817 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12818 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12819 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12820 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12821 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12822 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12823 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12824 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12825 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12826 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12827 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12828 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12829 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12830 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12831 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12832 | |
| 12833 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 12834 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12835 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12836 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 12837 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12838 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12839 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 12840 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12841 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12842 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 12843 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12844 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 12845 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12846 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 12847 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12848 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 12849 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12850 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 12851 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12852 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 12853 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 12854 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 12855 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 12856 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 12857 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 12858 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 12859 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 12860 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 12861 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12862 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 12863 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12864 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 12865 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12866 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 12867 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12868 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 12869 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12870 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 12871 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12872 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 12873 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12874 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12875 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12876 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12877 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12878 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 12879 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12880 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12881 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12882 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 12883 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12884 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 12885 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12886 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12887 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12888 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12889 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12890 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12891 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12892 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 12893 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 12894 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 12895 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12896 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 12897 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12898 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12899 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12900 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12901 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12902 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12903 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12904 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12905 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12906 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12907 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12908 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12909 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12910 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12911 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12912 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12913 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12914 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12915 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12916 | |
| 12917 | /* Statistics */ |
| 12918 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 12919 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 12920 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 12921 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 12922 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12923 | /* old command */ |
| 12924 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 12925 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 12926 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12927 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12928 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12929 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12930 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12931 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 12932 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 12933 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 12934 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 12935 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12936 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12937 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12938 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12939 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12940 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12941 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12942 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 12943 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 12944 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12945 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12946 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12947 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12948 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12949 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 12950 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12951 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12952 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12953 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12954 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 12955 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 12956 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 12957 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 12958 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 12959 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12960 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12961 | /* old command */ |
| 12962 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 12963 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 12964 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12965 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12966 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12967 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12968 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12969 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 12970 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 12971 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 12972 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 12973 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12974 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12975 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12976 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12977 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12978 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12979 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12980 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 12981 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 12982 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12983 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12984 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12985 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12986 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12987 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 12988 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12989 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12990 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12991 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12992 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 12993 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 12994 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 12995 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 12996 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 12997 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 12998 | |
| 12999 | /* old command */ |
| 13000 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13001 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13002 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13003 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13004 | |
| 13005 | /* old command */ |
| 13006 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13007 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13008 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13009 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13010 | |
| 13011 | /* old command */ |
| 13012 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13013 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13014 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13015 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13016 | #endif /* HAVE_IPV6 */ |
| 13017 | |
| 13018 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13019 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13020 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13021 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13022 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13023 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13024 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13025 | |
| 13026 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13027 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13028 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13029 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13030 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13031 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13032 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13033 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13034 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13035 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13036 | |
| 13037 | /* Deprecated AS-Pathlimit commands */ |
| 13038 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13039 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13040 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13041 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13042 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13043 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13044 | |
| 13045 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13046 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13047 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13048 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13049 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13050 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13051 | |
| 13052 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13053 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13054 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13055 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13056 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13057 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13058 | |
| 13059 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13060 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13061 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13062 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13063 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13064 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13065 | |
| 13066 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13067 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13068 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13069 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13070 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13071 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13072 | |
| 13073 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13074 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13075 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13076 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13077 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13078 | 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] | 13079 | |
| 13080 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13081 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13082 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13083 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13084 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13085 | |
| 13086 | void |
| 13087 | bgp_route_finish (void) |
| 13088 | { |
| 13089 | bgp_table_unlock (bgp_distance_table); |
| 13090 | bgp_distance_table = NULL; |
| 13091 | } |