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" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 57 | |
| 58 | /* Extern from bgp_dump.c */ |
| 59 | extern char *bgp_origin_str[]; |
| 60 | extern char *bgp_origin_long_str[]; |
| 61 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 62 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 63 | 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] | 64 | struct prefix_rd *prd) |
| 65 | { |
| 66 | struct bgp_node *rn; |
| 67 | struct bgp_node *prn = NULL; |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 68 | |
| 69 | assert (table); |
| 70 | if (!table) |
| 71 | return NULL; |
| 72 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 73 | if (safi == SAFI_MPLS_VPN) |
| 74 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 75 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | |
| 77 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 78 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 79 | else |
| 80 | bgp_unlock_node (prn); |
| 81 | table = prn->info; |
| 82 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 83 | |
| 84 | rn = bgp_node_get (table, p); |
| 85 | |
| 86 | if (safi == SAFI_MPLS_VPN) |
| 87 | rn->prn = prn; |
| 88 | |
| 89 | return rn; |
| 90 | } |
| 91 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 92 | /* Allocate bgp_info_extra */ |
| 93 | static struct bgp_info_extra * |
| 94 | bgp_info_extra_new (void) |
| 95 | { |
| 96 | struct bgp_info_extra *new; |
| 97 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); |
| 98 | return new; |
| 99 | } |
| 100 | |
| 101 | static void |
| 102 | bgp_info_extra_free (struct bgp_info_extra **extra) |
| 103 | { |
| 104 | if (extra && *extra) |
| 105 | { |
| 106 | if ((*extra)->damp_info) |
| 107 | bgp_damp_info_free ((*extra)->damp_info, 0); |
| 108 | |
| 109 | (*extra)->damp_info = NULL; |
| 110 | |
| 111 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); |
| 112 | |
| 113 | *extra = NULL; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /* Get bgp_info extra information for the given bgp_info, lazy allocated |
| 118 | * if required. |
| 119 | */ |
| 120 | struct bgp_info_extra * |
| 121 | bgp_info_extra_get (struct bgp_info *ri) |
| 122 | { |
| 123 | if (!ri->extra) |
| 124 | ri->extra = bgp_info_extra_new(); |
| 125 | return ri->extra; |
| 126 | } |
| 127 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 128 | /* Allocate new bgp info structure. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 129 | static struct bgp_info * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 130 | bgp_info_new () |
| 131 | { |
| 132 | struct bgp_info *new; |
| 133 | |
| 134 | new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 135 | memset (new, 0, sizeof (struct bgp_info)); |
| 136 | |
| 137 | return new; |
| 138 | } |
| 139 | |
| 140 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 141 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 142 | bgp_info_free (struct bgp_info *binfo) |
| 143 | { |
| 144 | if (binfo->attr) |
| 145 | bgp_attr_unintern (binfo->attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 146 | |
| 147 | bgp_info_extra_free (&binfo->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 149 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 150 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 151 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 152 | } |
| 153 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 154 | struct bgp_info * |
| 155 | bgp_info_lock (struct bgp_info *binfo) |
| 156 | { |
| 157 | binfo->lock++; |
| 158 | return binfo; |
| 159 | } |
| 160 | |
| 161 | struct bgp_info * |
| 162 | bgp_info_unlock (struct bgp_info *binfo) |
| 163 | { |
| 164 | assert (binfo && binfo->lock > 0); |
| 165 | binfo->lock--; |
| 166 | |
| 167 | if (binfo->lock == 0) |
| 168 | { |
| 169 | #if 0 |
| 170 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 171 | zlog_backtrace (LOG_DEBUG); |
| 172 | #endif |
| 173 | bgp_info_free (binfo); |
| 174 | return NULL; |
| 175 | } |
| 176 | |
| 177 | #if 0 |
| 178 | if (binfo->lock == 1) |
| 179 | { |
| 180 | zlog_debug ("%s: unlocked to 1", __func__); |
| 181 | zlog_backtrace (LOG_DEBUG); |
| 182 | } |
| 183 | #endif |
| 184 | |
| 185 | return binfo; |
| 186 | } |
| 187 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 188 | void |
| 189 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 190 | { |
| 191 | struct bgp_info *top; |
| 192 | |
| 193 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 194 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | ri->next = rn->info; |
| 196 | ri->prev = NULL; |
| 197 | if (top) |
| 198 | top->prev = ri; |
| 199 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 200 | |
| 201 | bgp_info_lock (ri); |
| 202 | bgp_lock_node (rn); |
| 203 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 204 | } |
| 205 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 206 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 207 | completion callback *only* */ |
| 208 | static void |
| 209 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 210 | { |
| 211 | if (ri->next) |
| 212 | ri->next->prev = ri->prev; |
| 213 | if (ri->prev) |
| 214 | ri->prev->next = ri->next; |
| 215 | else |
| 216 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 217 | |
| 218 | bgp_info_unlock (ri); |
| 219 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 220 | } |
| 221 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 222 | void |
| 223 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 224 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 225 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
| 226 | /* set of previous already took care of pcount */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 227 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 228 | } |
| 229 | |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 230 | /* undo the effects of a previous call to bgp_info_delete; typically |
| 231 | called when a route is deleted and then quickly re-added before the |
| 232 | deletion has been processed */ |
| 233 | static void |
| 234 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) |
| 235 | { |
| 236 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); |
| 237 | /* unset of previous already took care of pcount */ |
| 238 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 239 | } |
| 240 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 241 | /* Adjust pcount as required */ |
| 242 | static void |
| 243 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) |
| 244 | { |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 245 | assert (rn && rn->table); |
| 246 | assert (ri && ri->peer && ri->peer->bgp); |
| 247 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 248 | /* Ignore 'pcount' for RS-client tables */ |
| 249 | if (rn->table->type != BGP_TABLE_MAIN |
| 250 | || ri->peer == ri->peer->bgp->peer_self) |
| 251 | return; |
| 252 | |
| 253 | if (BGP_INFO_HOLDDOWN (ri) |
| 254 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 255 | { |
| 256 | |
| 257 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 258 | |
| 259 | /* slight hack, but more robust against errors. */ |
| 260 | if (ri->peer->pcount[rn->table->afi][rn->table->safi]) |
| 261 | ri->peer->pcount[rn->table->afi][rn->table->safi]--; |
| 262 | else |
| 263 | { |
| 264 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 265 | __func__, ri->peer->host); |
| 266 | zlog_backtrace (LOG_WARNING); |
| 267 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 268 | } |
| 269 | } |
| 270 | else if (!BGP_INFO_HOLDDOWN (ri) |
| 271 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 272 | { |
| 273 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 274 | ri->peer->pcount[rn->table->afi][rn->table->safi]++; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | |
| 279 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 280 | * This is here primarily to keep prefix-count in check. |
| 281 | */ |
| 282 | void |
| 283 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 284 | { |
| 285 | SET_FLAG (ri->flags, flag); |
| 286 | |
| 287 | /* early bath if we know it's not a flag that changes useability state */ |
| 288 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 289 | return; |
| 290 | |
| 291 | bgp_pcount_adjust (rn, ri); |
| 292 | } |
| 293 | |
| 294 | void |
| 295 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 296 | { |
| 297 | UNSET_FLAG (ri->flags, flag); |
| 298 | |
| 299 | /* early bath if we know it's not a flag that changes useability state */ |
| 300 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 301 | return; |
| 302 | |
| 303 | bgp_pcount_adjust (rn, ri); |
| 304 | } |
| 305 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 306 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 307 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 308 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 309 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 310 | { |
| 311 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 312 | return attr->med; |
| 313 | else |
| 314 | { |
| 315 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 316 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 317 | else |
| 318 | return 0; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | /* Compare two bgp route entity. br is preferable then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 323 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 324 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) |
| 325 | { |
| 326 | u_int32_t new_pref; |
| 327 | u_int32_t exist_pref; |
| 328 | u_int32_t new_med; |
| 329 | u_int32_t exist_med; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 330 | u_int32_t new_weight = 0; |
| 331 | u_int32_t exist_weight = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 332 | struct in_addr new_id; |
| 333 | struct in_addr exist_id; |
| 334 | int new_cluster; |
| 335 | int exist_cluster; |
| 336 | int internal_as_route = 0; |
| 337 | int confed_as_route = 0; |
| 338 | int ret; |
| 339 | |
| 340 | /* 0. Null check. */ |
| 341 | if (new == NULL) |
| 342 | return 0; |
| 343 | if (exist == NULL) |
| 344 | return 1; |
| 345 | |
| 346 | /* 1. Weight check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 347 | if (new->attr->extra) |
| 348 | new_weight = new->attr->extra->weight; |
| 349 | if (exist->attr->extra) |
| 350 | exist_weight = exist->attr->extra->weight; |
| 351 | if (new_weight > exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 352 | return 1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 353 | if (new_weight < exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 354 | return 0; |
| 355 | |
| 356 | /* 2. Local preference check. */ |
| 357 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 358 | new_pref = new->attr->local_pref; |
| 359 | else |
| 360 | new_pref = bgp->default_local_pref; |
| 361 | |
| 362 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 363 | exist_pref = exist->attr->local_pref; |
| 364 | else |
| 365 | exist_pref = bgp->default_local_pref; |
| 366 | |
| 367 | if (new_pref > exist_pref) |
| 368 | return 1; |
| 369 | if (new_pref < exist_pref) |
| 370 | return 0; |
| 371 | |
| 372 | /* 3. Local route check. */ |
| 373 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 374 | return 1; |
| 375 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 376 | return 0; |
| 377 | |
| 378 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 379 | return 1; |
| 380 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 381 | return 0; |
| 382 | |
| 383 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 384 | return 1; |
| 385 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 386 | return 0; |
| 387 | |
| 388 | /* 4. AS path length check. */ |
| 389 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 390 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 391 | int exist_hops = aspath_count_hops (exist->attr->aspath); |
| 392 | int exist_confeds = aspath_count_confeds (exist->attr->aspath); |
| 393 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 394 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 395 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 396 | int aspath_hops; |
| 397 | |
| 398 | aspath_hops = aspath_count_hops (new->attr->aspath); |
| 399 | aspath_hops += aspath_count_confeds (new->attr->aspath); |
| 400 | |
| 401 | if ( aspath_hops < (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 402 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 403 | if ( aspath_hops > (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 404 | return 0; |
| 405 | } |
| 406 | else |
| 407 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 408 | int newhops = aspath_count_hops (new->attr->aspath); |
| 409 | |
| 410 | if (newhops < exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 411 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 412 | if (newhops > exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 413 | return 0; |
| 414 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | /* 5. Origin check. */ |
| 418 | if (new->attr->origin < exist->attr->origin) |
| 419 | return 1; |
| 420 | if (new->attr->origin > exist->attr->origin) |
| 421 | return 0; |
| 422 | |
| 423 | /* 6. MED check. */ |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 424 | internal_as_route = (aspath_count_hops (new->attr->aspath) == 0 |
| 425 | && aspath_count_hops (exist->attr->aspath) == 0); |
| 426 | confed_as_route = (aspath_count_confeds (new->attr->aspath) > 0 |
| 427 | && aspath_count_confeds (exist->attr->aspath) > 0 |
| 428 | && aspath_count_hops (new->attr->aspath) == 0 |
| 429 | && aspath_count_hops (exist->attr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 430 | |
| 431 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 432 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 433 | && confed_as_route) |
| 434 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 435 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 436 | || internal_as_route) |
| 437 | { |
| 438 | new_med = bgp_med_value (new->attr, bgp); |
| 439 | exist_med = bgp_med_value (exist->attr, bgp); |
| 440 | |
| 441 | if (new_med < exist_med) |
| 442 | return 1; |
| 443 | if (new_med > exist_med) |
| 444 | return 0; |
| 445 | } |
| 446 | |
| 447 | /* 7. Peer type check. */ |
| 448 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 449 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 450 | return 1; |
| 451 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 452 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 453 | return 1; |
| 454 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 455 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 456 | return 0; |
| 457 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 458 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 459 | return 0; |
| 460 | |
| 461 | /* 8. IGP metric check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 462 | if (new->extra || exist->extra) |
| 463 | { |
| 464 | uint32_t newm = (new->extra ? new->extra->igpmetric : 0); |
| 465 | uint32_t existm = (exist->extra ? exist->extra->igpmetric : 0); |
| 466 | |
| 467 | if (newm < existm) |
| 468 | return 1; |
| 469 | if (newm > existm) |
| 470 | return 0; |
| 471 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 472 | |
| 473 | /* 9. Maximum path check. */ |
| 474 | |
| 475 | /* 10. If both paths are external, prefer the path that was received |
| 476 | first (the oldest one). This step minimizes route-flap, since a |
| 477 | newer path won't displace an older one, even if it was the |
| 478 | preferred route based on the additional decision criteria below. */ |
| 479 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 480 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 481 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 482 | { |
| 483 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 484 | return 1; |
| 485 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | /* 11. Rourter-ID comparision. */ |
| 490 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 491 | new_id.s_addr = new->attr->extra->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 492 | else |
| 493 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 494 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 495 | exist_id.s_addr = exist->attr->extra->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 496 | else |
| 497 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 498 | |
| 499 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 500 | return 1; |
| 501 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 502 | return 0; |
| 503 | |
| 504 | /* 12. Cluster length comparision. */ |
| 505 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 506 | new_cluster = new->attr->extra->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 507 | else |
| 508 | new_cluster = 0; |
| 509 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 510 | exist_cluster = exist->attr->extra->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | else |
| 512 | exist_cluster = 0; |
| 513 | |
| 514 | if (new_cluster < exist_cluster) |
| 515 | return 1; |
| 516 | if (new_cluster > exist_cluster) |
| 517 | return 0; |
| 518 | |
| 519 | /* 13. Neighbor address comparision. */ |
| 520 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 521 | |
| 522 | if (ret == 1) |
| 523 | return 0; |
| 524 | if (ret == -1) |
| 525 | return 1; |
| 526 | |
| 527 | return 1; |
| 528 | } |
| 529 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 530 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 531 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 532 | afi_t afi, safi_t safi) |
| 533 | { |
| 534 | struct bgp_filter *filter; |
| 535 | |
| 536 | filter = &peer->filter[afi][safi]; |
| 537 | |
| 538 | if (DISTRIBUTE_IN_NAME (filter)) |
| 539 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 540 | return FILTER_DENY; |
| 541 | |
| 542 | if (PREFIX_LIST_IN_NAME (filter)) |
| 543 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 544 | return FILTER_DENY; |
| 545 | |
| 546 | if (FILTER_LIST_IN_NAME (filter)) |
| 547 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 548 | return FILTER_DENY; |
| 549 | |
| 550 | return FILTER_PERMIT; |
| 551 | } |
| 552 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 553 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 554 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 555 | afi_t afi, safi_t safi) |
| 556 | { |
| 557 | struct bgp_filter *filter; |
| 558 | |
| 559 | filter = &peer->filter[afi][safi]; |
| 560 | |
| 561 | if (DISTRIBUTE_OUT_NAME (filter)) |
| 562 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 563 | return FILTER_DENY; |
| 564 | |
| 565 | if (PREFIX_LIST_OUT_NAME (filter)) |
| 566 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 567 | return FILTER_DENY; |
| 568 | |
| 569 | if (FILTER_LIST_OUT_NAME (filter)) |
| 570 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 571 | return FILTER_DENY; |
| 572 | |
| 573 | return FILTER_PERMIT; |
| 574 | } |
| 575 | |
| 576 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 577 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 578 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 579 | { |
| 580 | if (attr->community) |
| 581 | { |
| 582 | /* NO_ADVERTISE check. */ |
| 583 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 584 | return 1; |
| 585 | |
| 586 | /* NO_EXPORT check. */ |
| 587 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 588 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 589 | return 1; |
| 590 | |
| 591 | /* NO_EXPORT_SUBCONFED check. */ |
| 592 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 593 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 594 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 595 | return 1; |
| 596 | } |
| 597 | return 0; |
| 598 | } |
| 599 | |
| 600 | /* Route reflection loop check. */ |
| 601 | static int |
| 602 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 603 | { |
| 604 | struct in_addr cluster_id; |
| 605 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 606 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 607 | { |
| 608 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 609 | cluster_id = peer->bgp->cluster_id; |
| 610 | else |
| 611 | cluster_id = peer->bgp->router_id; |
| 612 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 613 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 614 | return 1; |
| 615 | } |
| 616 | return 0; |
| 617 | } |
| 618 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 619 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 620 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 621 | afi_t afi, safi_t safi) |
| 622 | { |
| 623 | struct bgp_filter *filter; |
| 624 | struct bgp_info info; |
| 625 | route_map_result_t ret; |
| 626 | |
| 627 | filter = &peer->filter[afi][safi]; |
| 628 | |
| 629 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 630 | if (peer->weight) |
| 631 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 632 | |
| 633 | /* Route map apply. */ |
| 634 | if (ROUTE_MAP_IN_NAME (filter)) |
| 635 | { |
| 636 | /* Duplicate current value to new strucutre for modification. */ |
| 637 | info.peer = peer; |
| 638 | info.attr = attr; |
| 639 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 640 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 641 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 642 | /* Apply BGP route map to the attribute. */ |
| 643 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 644 | |
| 645 | peer->rmap_type = 0; |
| 646 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 647 | if (ret == RMAP_DENYMATCH) |
| 648 | { |
| 649 | /* Free newly generated AS path and community by route-map. */ |
| 650 | bgp_attr_flush (attr); |
| 651 | return RMAP_DENY; |
| 652 | } |
| 653 | } |
| 654 | return RMAP_PERMIT; |
| 655 | } |
| 656 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 657 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 658 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 659 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 660 | { |
| 661 | struct bgp_filter *filter; |
| 662 | struct bgp_info info; |
| 663 | route_map_result_t ret; |
| 664 | |
| 665 | filter = &peer->filter[afi][safi]; |
| 666 | |
| 667 | /* Route map apply. */ |
| 668 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 669 | { |
| 670 | /* Duplicate current value to new strucutre for modification. */ |
| 671 | info.peer = rsclient; |
| 672 | info.attr = attr; |
| 673 | |
| 674 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 675 | |
| 676 | /* Apply BGP route map to the attribute. */ |
| 677 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 678 | |
| 679 | rsclient->rmap_type = 0; |
| 680 | |
| 681 | if (ret == RMAP_DENYMATCH) |
| 682 | { |
| 683 | /* Free newly generated AS path and community by route-map. */ |
| 684 | bgp_attr_flush (attr); |
| 685 | return RMAP_DENY; |
| 686 | } |
| 687 | } |
| 688 | return RMAP_PERMIT; |
| 689 | } |
| 690 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 691 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 692 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 693 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 694 | { |
| 695 | struct bgp_filter *filter; |
| 696 | struct bgp_info info; |
| 697 | route_map_result_t ret; |
| 698 | |
| 699 | filter = &rsclient->filter[afi][safi]; |
| 700 | |
| 701 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 702 | if (peer->weight) |
| 703 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 704 | |
| 705 | /* Route map apply. */ |
| 706 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 707 | { |
| 708 | /* Duplicate current value to new strucutre for modification. */ |
| 709 | info.peer = peer; |
| 710 | info.attr = attr; |
| 711 | |
| 712 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 713 | |
| 714 | /* Apply BGP route map to the attribute. */ |
| 715 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 716 | |
| 717 | peer->rmap_type = 0; |
| 718 | |
| 719 | if (ret == RMAP_DENYMATCH) |
| 720 | { |
| 721 | /* Free newly generated AS path and community by route-map. */ |
| 722 | bgp_attr_flush (attr); |
| 723 | return RMAP_DENY; |
| 724 | } |
| 725 | } |
| 726 | return RMAP_PERMIT; |
| 727 | } |
| 728 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 729 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 730 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 731 | struct attr *attr, afi_t afi, safi_t safi) |
| 732 | { |
| 733 | int ret; |
| 734 | char buf[SU_ADDRSTRLEN]; |
| 735 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 736 | struct peer *from; |
| 737 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 738 | int transparent; |
| 739 | int reflect; |
| 740 | |
| 741 | from = ri->peer; |
| 742 | filter = &peer->filter[afi][safi]; |
| 743 | bgp = peer->bgp; |
| 744 | |
| 745 | #ifdef DISABLE_BGP_ANNOUNCE |
| 746 | return 0; |
| 747 | #endif |
| 748 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 749 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 750 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 751 | return 0; |
| 752 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 753 | /* Do not send back route to sender. */ |
| 754 | if (from == peer) |
| 755 | return 0; |
| 756 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 757 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 758 | if (p->family == AF_INET |
| 759 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 760 | return 0; |
| 761 | #ifdef HAVE_IPV6 |
| 762 | if (p->family == AF_INET6 |
| 763 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 764 | return 0; |
| 765 | #endif |
| 766 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 767 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 768 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 769 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 770 | return 0; |
| 771 | |
| 772 | /* Default route check. */ |
| 773 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 774 | { |
| 775 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 776 | return 0; |
| 777 | #ifdef HAVE_IPV6 |
| 778 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 779 | return 0; |
| 780 | #endif /* HAVE_IPV6 */ |
| 781 | } |
| 782 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 783 | /* Transparency check. */ |
| 784 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 785 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 786 | transparent = 1; |
| 787 | else |
| 788 | transparent = 0; |
| 789 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 790 | /* If community is not disabled check the no-export and local. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 791 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 792 | return 0; |
| 793 | |
| 794 | /* If the attribute has originator-id and it is same as remote |
| 795 | peer's id. */ |
| 796 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 797 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 798 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 799 | { |
| 800 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 801 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 802 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 803 | peer->host, |
| 804 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 805 | p->prefixlen); |
| 806 | return 0; |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | /* ORF prefix-list filter check */ |
| 811 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 812 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 813 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 814 | if (peer->orf_plist[afi][safi]) |
| 815 | { |
| 816 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 817 | return 0; |
| 818 | } |
| 819 | |
| 820 | /* Output filter check. */ |
| 821 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) |
| 822 | { |
| 823 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 824 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 825 | "%s [Update:SEND] %s/%d is filtered", |
| 826 | peer->host, |
| 827 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 828 | p->prefixlen); |
| 829 | return 0; |
| 830 | } |
| 831 | |
| 832 | #ifdef BGP_SEND_ASPATH_CHECK |
| 833 | /* AS path loop check. */ |
| 834 | if (aspath_loop_check (ri->attr->aspath, peer->as)) |
| 835 | { |
| 836 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 837 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 838 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 839 | peer->host, peer->as); |
| 840 | return 0; |
| 841 | } |
| 842 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 843 | |
| 844 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 845 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 846 | { |
| 847 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) |
| 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] suppress announcement to peer AS %d is AS path.", |
| 852 | peer->host, |
| 853 | bgp->confed_id); |
| 854 | return 0; |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | /* Route-Reflect check. */ |
| 859 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 860 | reflect = 1; |
| 861 | else |
| 862 | reflect = 0; |
| 863 | |
| 864 | /* IBGP reflection check. */ |
| 865 | if (reflect) |
| 866 | { |
| 867 | /* A route from a Client peer. */ |
| 868 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 869 | { |
| 870 | /* Reflect to all the Non-Client peers and also to the |
| 871 | Client peers other than the originator. Originator check |
| 872 | is already done. So there is noting to do. */ |
| 873 | /* no bgp client-to-client reflection check. */ |
| 874 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 875 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 876 | return 0; |
| 877 | } |
| 878 | else |
| 879 | { |
| 880 | /* A route from a Non-client peer. Reflect to all other |
| 881 | clients. */ |
| 882 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 883 | return 0; |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | /* For modify attribute, copy it to temporary structure. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 888 | bgp_attr_dup (attr, ri->attr); |
| 889 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 890 | /* If local-preference is not set. */ |
| 891 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 892 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 893 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 894 | { |
| 895 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 896 | attr->local_pref = bgp->default_local_pref; |
| 897 | } |
| 898 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 899 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 900 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 901 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 902 | { |
| 903 | if (ri->peer != bgp->peer_self && ! transparent |
| 904 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 905 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 906 | } |
| 907 | |
| 908 | /* next-hop-set */ |
| 909 | if (transparent || reflect |
| 910 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 911 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 912 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 913 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 914 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 915 | #endif /* HAVE_IPV6 */ |
| 916 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 917 | { |
| 918 | /* NEXT-HOP Unchanged. */ |
| 919 | } |
| 920 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 921 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 922 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 923 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 924 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 925 | #endif /* HAVE_IPV6 */ |
| 926 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 927 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 928 | { |
| 929 | /* Set IPv4 nexthop. */ |
| 930 | if (p->family == AF_INET) |
| 931 | { |
| 932 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 933 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 934 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 935 | else |
| 936 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 937 | } |
| 938 | #ifdef HAVE_IPV6 |
| 939 | /* Set IPv6 nexthop. */ |
| 940 | if (p->family == AF_INET6) |
| 941 | { |
| 942 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 943 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 944 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 945 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 946 | } |
| 947 | #endif /* HAVE_IPV6 */ |
| 948 | } |
| 949 | |
| 950 | #ifdef HAVE_IPV6 |
| 951 | if (p->family == AF_INET6) |
| 952 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 953 | /* Left nexthop_local unchanged if so configured. */ |
| 954 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 955 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 956 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 957 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 958 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 959 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 960 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 964 | else |
| 965 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 966 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 967 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 968 | |
| 969 | /* Set link-local address for shared network peer. */ |
| 970 | if (peer->shared_network |
| 971 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 972 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 973 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 974 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 975 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 979 | address.*/ |
| 980 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 981 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 982 | |
| 983 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 984 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 985 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 986 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 987 | |
| 988 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 989 | #endif /* HAVE_IPV6 */ |
| 990 | |
| 991 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 992 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 993 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 994 | && aspath_private_as_check (attr->aspath)) |
| 995 | attr->aspath = aspath_empty_get (); |
| 996 | |
| 997 | /* Route map & unsuppress-map apply. */ |
| 998 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 999 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1000 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1001 | struct bgp_info info; |
| 1002 | struct attr dummy_attr; |
| 1003 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1004 | info.peer = peer; |
| 1005 | info.attr = attr; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1006 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1007 | |
| 1008 | /* The route reflector is not allowed to modify the attributes |
| 1009 | of the reflected IBGP routes. */ |
| 1010 | if (peer_sort (from) == BGP_PEER_IBGP |
| 1011 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 1012 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1013 | dummy_attr.extra = NULL; |
| 1014 | bgp_attr_dup (&dummy_attr, attr); |
| 1015 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1016 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1017 | |
| 1018 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1019 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1020 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1021 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1022 | else |
| 1023 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1024 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1025 | peer->rmap_type = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1026 | |
| 1027 | bgp_attr_extra_free (&dummy_attr); |
| 1028 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1029 | if (ret == RMAP_DENYMATCH) |
| 1030 | { |
| 1031 | bgp_attr_flush (attr); |
| 1032 | return 0; |
| 1033 | } |
| 1034 | } |
| 1035 | return 1; |
| 1036 | } |
| 1037 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1038 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1039 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1040 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1041 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1042 | int ret; |
| 1043 | char buf[SU_ADDRSTRLEN]; |
| 1044 | struct bgp_filter *filter; |
| 1045 | struct bgp_info info; |
| 1046 | struct peer *from; |
| 1047 | struct bgp *bgp; |
| 1048 | |
| 1049 | from = ri->peer; |
| 1050 | filter = &rsclient->filter[afi][safi]; |
| 1051 | bgp = rsclient->bgp; |
| 1052 | |
| 1053 | #ifdef DISABLE_BGP_ANNOUNCE |
| 1054 | return 0; |
| 1055 | #endif |
| 1056 | |
| 1057 | /* Do not send back route to sender. */ |
| 1058 | if (from == rsclient) |
| 1059 | return 0; |
| 1060 | |
| 1061 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1062 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1063 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1064 | return 0; |
| 1065 | |
| 1066 | /* Default route check. */ |
| 1067 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1068 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1069 | { |
| 1070 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1071 | return 0; |
| 1072 | #ifdef HAVE_IPV6 |
| 1073 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1074 | return 0; |
| 1075 | #endif /* HAVE_IPV6 */ |
| 1076 | } |
| 1077 | |
| 1078 | /* If the attribute has originator-id and it is same as remote |
| 1079 | peer's id. */ |
| 1080 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 1081 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1082 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
| 1083 | &ri->attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1084 | { |
| 1085 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1086 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1087 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1088 | rsclient->host, |
| 1089 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1090 | p->prefixlen); |
| 1091 | return 0; |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | /* ORF prefix-list filter check */ |
| 1096 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1097 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1098 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1099 | if (rsclient->orf_plist[afi][safi]) |
| 1100 | { |
| 1101 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
| 1105 | /* Output filter check. */ |
| 1106 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) |
| 1107 | { |
| 1108 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1109 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1110 | "%s [Update:SEND] %s/%d is filtered", |
| 1111 | rsclient->host, |
| 1112 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1113 | p->prefixlen); |
| 1114 | return 0; |
| 1115 | } |
| 1116 | |
| 1117 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1118 | /* AS path loop check. */ |
| 1119 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) |
| 1120 | { |
| 1121 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1122 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1123 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 1124 | rsclient->host, rsclient->as); |
| 1125 | return 0; |
| 1126 | } |
| 1127 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1128 | |
| 1129 | /* For modify attribute, copy it to temporary structure. */ |
| 1130 | *attr = *ri->attr; |
| 1131 | |
| 1132 | /* next-hop-set */ |
| 1133 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1134 | #ifdef HAVE_IPV6 |
| 1135 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1136 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1137 | #endif /* HAVE_IPV6 */ |
| 1138 | ) |
| 1139 | { |
| 1140 | /* Set IPv4 nexthop. */ |
| 1141 | if (p->family == AF_INET) |
| 1142 | { |
| 1143 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1144 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1145 | IPV4_MAX_BYTELEN); |
| 1146 | else |
| 1147 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1148 | } |
| 1149 | #ifdef HAVE_IPV6 |
| 1150 | /* Set IPv6 nexthop. */ |
| 1151 | if (p->family == AF_INET6) |
| 1152 | { |
| 1153 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1154 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1155 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1156 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1157 | } |
| 1158 | #endif /* HAVE_IPV6 */ |
| 1159 | } |
| 1160 | |
| 1161 | #ifdef HAVE_IPV6 |
| 1162 | if (p->family == AF_INET6) |
| 1163 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1164 | struct attr_extra *attre = attr->extra; |
| 1165 | |
| 1166 | assert (attr->extra); |
| 1167 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1168 | /* Left nexthop_local unchanged if so configured. */ |
| 1169 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1170 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1171 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1172 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1173 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1174 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1175 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | /* Default nexthop_local treatment for RS-Clients */ |
| 1179 | else |
| 1180 | { |
| 1181 | /* Announcer and RS-Client are both in the same network */ |
| 1182 | if (rsclient->shared_network && from->shared_network && |
| 1183 | (rsclient->ifindex == from->ifindex)) |
| 1184 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1185 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1186 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1187 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1188 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1189 | } |
| 1190 | |
| 1191 | /* Set link-local address for shared network peer. */ |
| 1192 | else if (rsclient->shared_network |
| 1193 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1194 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1195 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1196 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1197 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
| 1200 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1201 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | } |
| 1205 | #endif /* HAVE_IPV6 */ |
| 1206 | |
| 1207 | |
| 1208 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1209 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 1210 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1211 | && aspath_private_as_check (attr->aspath)) |
| 1212 | attr->aspath = aspath_empty_get (); |
| 1213 | |
| 1214 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1215 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1216 | { |
| 1217 | info.peer = rsclient; |
| 1218 | info.attr = attr; |
| 1219 | |
| 1220 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1221 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1222 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1224 | else |
| 1225 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1226 | |
| 1227 | rsclient->rmap_type = 0; |
| 1228 | |
| 1229 | if (ret == RMAP_DENYMATCH) |
| 1230 | { |
| 1231 | bgp_attr_flush (attr); |
| 1232 | return 0; |
| 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | return 1; |
| 1237 | } |
| 1238 | |
| 1239 | struct bgp_info_pair |
| 1240 | { |
| 1241 | struct bgp_info *old; |
| 1242 | struct bgp_info *new; |
| 1243 | }; |
| 1244 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1245 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1246 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
| 1247 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1248 | struct bgp_info *new_select; |
| 1249 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1250 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1251 | struct bgp_info *ri1; |
| 1252 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1253 | struct bgp_info *nextri = NULL; |
| 1254 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1255 | /* bgp deterministic-med */ |
| 1256 | new_select = NULL; |
| 1257 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1258 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1259 | { |
| 1260 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1261 | continue; |
| 1262 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1263 | continue; |
| 1264 | |
| 1265 | new_select = ri1; |
| 1266 | if (ri1->next) |
| 1267 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1268 | { |
| 1269 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1270 | continue; |
| 1271 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1272 | continue; |
| 1273 | |
| 1274 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1275 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1276 | ri2->attr->aspath)) |
| 1277 | { |
| 1278 | if (bgp_info_cmp (bgp, ri2, new_select)) |
| 1279 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1280 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1281 | new_select = ri2; |
| 1282 | } |
| 1283 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1284 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1285 | } |
| 1286 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1287 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1288 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1289 | } |
| 1290 | |
| 1291 | /* Check old selected route and new selected route. */ |
| 1292 | old_select = NULL; |
| 1293 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1294 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1295 | { |
| 1296 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1297 | old_select = ri; |
| 1298 | |
| 1299 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1300 | { |
| 1301 | /* reap REMOVED routes, if needs be |
| 1302 | * selected route must stay for a while longer though |
| 1303 | */ |
| 1304 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1305 | && (ri != old_select)) |
| 1306 | bgp_info_reap (rn, ri); |
| 1307 | |
| 1308 | continue; |
| 1309 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1310 | |
| 1311 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1312 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1313 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1314 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1315 | continue; |
| 1316 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1317 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1318 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1319 | |
| 1320 | if (bgp_info_cmp (bgp, ri, new_select)) |
| 1321 | new_select = ri; |
| 1322 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1323 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1324 | result->old = old_select; |
| 1325 | result->new = new_select; |
| 1326 | |
| 1327 | return; |
| 1328 | } |
| 1329 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1330 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1331 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
| 1332 | struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi) |
| 1333 | { |
| 1334 | struct prefix *p; |
| 1335 | |
| 1336 | p = &rn->p; |
| 1337 | |
| 1338 | /* Announce route to Established peer. */ |
| 1339 | if (peer->status != Established) |
| 1340 | return 0; |
| 1341 | |
| 1342 | /* Address family configuration check. */ |
| 1343 | if (! peer->afc_nego[afi][safi]) |
| 1344 | return 0; |
| 1345 | |
| 1346 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 1347 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1348 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1349 | return 0; |
| 1350 | |
| 1351 | switch (rn->table->type) |
| 1352 | { |
| 1353 | case BGP_TABLE_MAIN: |
| 1354 | /* Announcement to peer->conf. If the route is filtered, |
| 1355 | withdraw it. */ |
| 1356 | if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi)) |
| 1357 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1358 | else |
| 1359 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1360 | break; |
| 1361 | case BGP_TABLE_RSCLIENT: |
| 1362 | /* Announcement to peer->conf. If the route is filtered, |
| 1363 | withdraw it. */ |
| 1364 | if (selected && bgp_announce_check_rsclient |
| 1365 | (selected, peer, p, attr, afi, safi)) |
| 1366 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1367 | else |
| 1368 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1369 | break; |
| 1370 | } |
| 1371 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1372 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1373 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1374 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1375 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1376 | struct bgp *bgp; |
| 1377 | struct bgp_node *rn; |
| 1378 | afi_t afi; |
| 1379 | safi_t safi; |
| 1380 | }; |
| 1381 | |
| 1382 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1383 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1384 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1385 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1386 | struct bgp *bgp = pq->bgp; |
| 1387 | struct bgp_node *rn = pq->rn; |
| 1388 | afi_t afi = pq->afi; |
| 1389 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1390 | struct bgp_info *new_select; |
| 1391 | struct bgp_info *old_select; |
| 1392 | struct bgp_info_pair old_and_new; |
| 1393 | struct attr attr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1394 | struct listnode *node, *nnode; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1395 | struct peer *rsclient = rn->table->owner; |
| 1396 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1397 | memset (&attr, 0, sizeof (struct attr)); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1398 | /* Best path selection. */ |
| 1399 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1400 | new_select = old_and_new.new; |
| 1401 | old_select = old_and_new.old; |
| 1402 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1403 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1404 | { |
| 1405 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1406 | { |
| 1407 | /* Nothing to do. */ |
| 1408 | if (old_select && old_select == new_select) |
| 1409 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1410 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1411 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1412 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1413 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1414 | if (new_select) |
| 1415 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1416 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1417 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1418 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1419 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1420 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, |
| 1421 | afi, safi); |
| 1422 | } |
| 1423 | } |
| 1424 | else |
| 1425 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1426 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1427 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1428 | if (new_select) |
| 1429 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1430 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1431 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1432 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1433 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1434 | &attr, afi, safi); |
| 1435 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1436 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1437 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1438 | bgp_info_reap (rn, old_select); |
| 1439 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1440 | bgp_attr_extra_free (&attr); |
| 1441 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1442 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1443 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1444 | } |
| 1445 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1446 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1447 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1448 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1449 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1450 | struct bgp *bgp = pq->bgp; |
| 1451 | struct bgp_node *rn = pq->rn; |
| 1452 | afi_t afi = pq->afi; |
| 1453 | safi_t safi = pq->safi; |
| 1454 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1455 | struct bgp_info *new_select; |
| 1456 | struct bgp_info *old_select; |
| 1457 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1458 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1459 | struct peer *peer; |
| 1460 | struct attr attr; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1461 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1462 | memset (&attr, 0, sizeof (struct attr)); |
| 1463 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1464 | /* Best path selection. */ |
| 1465 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1466 | old_select = old_and_new.old; |
| 1467 | new_select = old_and_new.new; |
| 1468 | |
| 1469 | /* Nothing to do. */ |
| 1470 | if (old_select && old_select == new_select) |
| 1471 | { |
| 1472 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1473 | { |
| 1474 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) |
| 1475 | bgp_zebra_announce (p, old_select, bgp); |
| 1476 | |
| 1477 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1478 | return WQ_SUCCESS; |
| 1479 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1480 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1481 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1482 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1483 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1484 | if (new_select) |
| 1485 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1486 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1487 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1488 | } |
| 1489 | |
| 1490 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1491 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1492 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1493 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1494 | bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1495 | } |
| 1496 | |
| 1497 | /* FIB update. */ |
| 1498 | if (safi == SAFI_UNICAST && ! bgp->name && |
| 1499 | ! bgp_option_check (BGP_OPT_NO_FIB)) |
| 1500 | { |
| 1501 | if (new_select |
| 1502 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1503 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
| 1504 | bgp_zebra_announce (p, new_select, bgp); |
| 1505 | else |
| 1506 | { |
| 1507 | /* Withdraw the route from the kernel. */ |
| 1508 | if (old_select |
| 1509 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1510 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
| 1511 | bgp_zebra_withdraw (p, old_select); |
| 1512 | } |
| 1513 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1514 | |
| 1515 | /* Reap old select bgp_info, it it has been removed */ |
| 1516 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1517 | bgp_info_reap (rn, old_select); |
| 1518 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1519 | bgp_attr_extra_free (&attr); |
| 1520 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1521 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1522 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1523 | } |
| 1524 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1525 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1526 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1527 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1528 | struct bgp_process_queue *pq = data; |
| 1529 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1530 | bgp_unlock_node (pq->rn); |
| 1531 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1532 | } |
| 1533 | |
| 1534 | static void |
| 1535 | bgp_process_queue_init (void) |
| 1536 | { |
| 1537 | bm->process_main_queue |
| 1538 | = work_queue_new (bm->master, "process_main_queue"); |
| 1539 | bm->process_rsclient_queue |
| 1540 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1541 | |
| 1542 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1543 | { |
| 1544 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1545 | exit (1); |
| 1546 | } |
| 1547 | |
| 1548 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
| 1549 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
| 1550 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
| 1551 | bm->process_rsclient_queue->spec.del_item_data |
| 1552 | = bm->process_main_queue->spec.del_item_data; |
| 1553 | bm->process_main_queue->spec.max_retries |
| 1554 | = bm->process_main_queue->spec.max_retries = 0; |
| 1555 | bm->process_rsclient_queue->spec.hold |
Paul Jakma | 09dd561 | 2006-09-14 03:38:16 +0000 | [diff] [blame] | 1556 | = bm->process_main_queue->spec.hold = 50; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1557 | } |
| 1558 | |
| 1559 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1560 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1561 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1562 | struct bgp_process_queue *pqnode; |
| 1563 | |
| 1564 | /* already scheduled for processing? */ |
| 1565 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1566 | return; |
| 1567 | |
| 1568 | if ( (bm->process_main_queue == NULL) || |
| 1569 | (bm->process_rsclient_queue == NULL) ) |
| 1570 | bgp_process_queue_init (); |
| 1571 | |
| 1572 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1573 | sizeof (struct bgp_process_queue)); |
| 1574 | if (!pqnode) |
| 1575 | return; |
| 1576 | |
| 1577 | pqnode->rn = bgp_lock_node (rn); /* unlocked by bgp_processq_del */ |
| 1578 | pqnode->bgp = bgp; |
| 1579 | pqnode->afi = afi; |
| 1580 | pqnode->safi = safi; |
| 1581 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1582 | switch (rn->table->type) |
| 1583 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1584 | case BGP_TABLE_MAIN: |
| 1585 | work_queue_add (bm->process_main_queue, pqnode); |
| 1586 | break; |
| 1587 | case BGP_TABLE_RSCLIENT: |
| 1588 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1589 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1590 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1591 | |
| 1592 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1593 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1594 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1595 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1596 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1597 | { |
| 1598 | struct peer *peer; |
| 1599 | |
| 1600 | peer = THREAD_ARG (thread); |
| 1601 | peer->t_pmax_restart = NULL; |
| 1602 | |
| 1603 | if (BGP_DEBUG (events, EVENTS)) |
| 1604 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1605 | peer->host); |
| 1606 | |
| 1607 | peer_clear (peer); |
| 1608 | |
| 1609 | return 0; |
| 1610 | } |
| 1611 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1612 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1613 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1614 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1615 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1616 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1617 | return 0; |
| 1618 | |
| 1619 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1620 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1621 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1622 | && ! always) |
| 1623 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1624 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1625 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1626 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1627 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1628 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1629 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1630 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1631 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1632 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1633 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1634 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1635 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1636 | |
| 1637 | if (safi == SAFI_MPLS_VPN) |
| 1638 | safi = BGP_SAFI_VPNV4; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1639 | |
| 1640 | ndata[0] = (afi >> 8); |
| 1641 | ndata[1] = afi; |
| 1642 | ndata[2] = safi; |
| 1643 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1644 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1645 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1646 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1647 | |
| 1648 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1649 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1650 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1651 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1652 | |
| 1653 | /* restart timer start */ |
| 1654 | if (peer->pmax_restart[afi][safi]) |
| 1655 | { |
| 1656 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1657 | |
| 1658 | if (BGP_DEBUG (events, EVENTS)) |
| 1659 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1660 | peer->host, peer->v_pmax_restart); |
| 1661 | |
| 1662 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1663 | peer->v_pmax_restart); |
| 1664 | } |
| 1665 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1666 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1667 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1668 | else |
| 1669 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1670 | |
| 1671 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1672 | { |
| 1673 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1674 | && ! always) |
| 1675 | return 0; |
| 1676 | |
| 1677 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1678 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1679 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1680 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1681 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1682 | } |
| 1683 | else |
| 1684 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1685 | return 0; |
| 1686 | } |
| 1687 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1688 | /* Unconditionally remove the route from the RIB, without taking |
| 1689 | * damping into consideration (eg, because the session went down) |
| 1690 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1691 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1692 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1693 | afi_t afi, safi_t safi) |
| 1694 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1695 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1696 | |
| 1697 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1698 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1699 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1700 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1701 | } |
| 1702 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1703 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1704 | 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] | 1705 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1706 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1707 | int status = BGP_DAMP_NONE; |
| 1708 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1709 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1710 | * the bgp_info in the RIB for historical reference. |
| 1711 | */ |
| 1712 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1713 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1714 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1715 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1716 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1717 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1718 | return; |
| 1719 | } |
| 1720 | |
| 1721 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1722 | } |
| 1723 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1724 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1725 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1726 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1727 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1728 | { |
| 1729 | struct bgp_node *rn; |
| 1730 | struct bgp *bgp; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1731 | struct attr new_attr = { 0 }; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1732 | struct attr *attr_new; |
| 1733 | struct attr *attr_new2; |
| 1734 | struct bgp_info *ri; |
| 1735 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1736 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1737 | char buf[SU_ADDRSTRLEN]; |
| 1738 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1739 | //memset (new_attr, 0, sizeof (struct attr)); |
| 1740 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1741 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1742 | if (peer == rsclient) |
| 1743 | return; |
| 1744 | |
| 1745 | bgp = peer->bgp; |
| 1746 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1747 | |
| 1748 | /* Check previously received route. */ |
| 1749 | for (ri = rn->info; ri; ri = ri->next) |
| 1750 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1751 | break; |
| 1752 | |
| 1753 | /* AS path loop check. */ |
| 1754 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1755 | { |
| 1756 | reason = "as-path contains our own AS;"; |
| 1757 | goto filtered; |
| 1758 | } |
| 1759 | |
| 1760 | /* Route reflector originator ID check. */ |
| 1761 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1762 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1763 | { |
| 1764 | reason = "originator is us;"; |
| 1765 | goto filtered; |
| 1766 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1767 | |
| 1768 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1769 | |
| 1770 | /* Apply export policy. */ |
| 1771 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1772 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1773 | { |
| 1774 | reason = "export-policy;"; |
| 1775 | goto filtered; |
| 1776 | } |
| 1777 | |
| 1778 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1779 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1780 | /* Apply import policy. */ |
| 1781 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1782 | { |
| 1783 | bgp_attr_unintern (attr_new2); |
| 1784 | |
| 1785 | reason = "import-policy;"; |
| 1786 | goto filtered; |
| 1787 | } |
| 1788 | |
| 1789 | attr_new = bgp_attr_intern (&new_attr); |
| 1790 | bgp_attr_unintern (attr_new2); |
| 1791 | |
| 1792 | /* IPv4 unicast next hop check. */ |
| 1793 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1794 | { |
| 1795 | /* Next hop must not be 0.0.0.0 nor Class E address. */ |
| 1796 | if (new_attr.nexthop.s_addr == 0 |
| 1797 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1798 | { |
| 1799 | bgp_attr_unintern (attr_new); |
| 1800 | |
| 1801 | reason = "martian next-hop;"; |
| 1802 | goto filtered; |
| 1803 | } |
| 1804 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1805 | |
| 1806 | /* new_attr isn't passed to any functions after here */ |
| 1807 | bgp_attr_extra_free (&new_attr); |
| 1808 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1809 | /* If the update is implicit withdraw. */ |
| 1810 | if (ri) |
| 1811 | { |
| 1812 | ri->uptime = time (NULL); |
| 1813 | |
| 1814 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1815 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1816 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1817 | { |
| 1818 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1819 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1820 | |
| 1821 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1822 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1823 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1824 | peer->host, |
| 1825 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1826 | p->prefixlen, rsclient->host); |
| 1827 | |
| 1828 | bgp_unlock_node (rn); |
| 1829 | bgp_attr_unintern (attr_new); |
| 1830 | |
| 1831 | return; |
| 1832 | } |
| 1833 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1834 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1835 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1836 | bgp_info_restore (rn, ri); |
| 1837 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1838 | /* Received Logging. */ |
| 1839 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1840 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1841 | peer->host, |
| 1842 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1843 | p->prefixlen, rsclient->host); |
| 1844 | |
| 1845 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1846 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1847 | |
| 1848 | /* Update to new attribute. */ |
| 1849 | bgp_attr_unintern (ri->attr); |
| 1850 | ri->attr = attr_new; |
| 1851 | |
| 1852 | /* Update MPLS tag. */ |
| 1853 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1854 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1855 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1856 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1857 | |
| 1858 | /* Process change. */ |
| 1859 | bgp_process (bgp, rn, afi, safi); |
| 1860 | bgp_unlock_node (rn); |
| 1861 | |
| 1862 | return; |
| 1863 | } |
| 1864 | |
| 1865 | /* Received Logging. */ |
| 1866 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1867 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1868 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1869 | peer->host, |
| 1870 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1871 | p->prefixlen, rsclient->host); |
| 1872 | } |
| 1873 | |
| 1874 | /* Make new BGP info. */ |
| 1875 | new = bgp_info_new (); |
| 1876 | new->type = type; |
| 1877 | new->sub_type = sub_type; |
| 1878 | new->peer = peer; |
| 1879 | new->attr = attr_new; |
| 1880 | new->uptime = time (NULL); |
| 1881 | |
| 1882 | /* Update MPLS tag. */ |
| 1883 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1884 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1885 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1886 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1887 | |
| 1888 | /* Register new BGP information. */ |
| 1889 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1890 | |
| 1891 | /* route_node_get lock */ |
| 1892 | bgp_unlock_node (rn); |
| 1893 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1894 | /* Process change. */ |
| 1895 | bgp_process (bgp, rn, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1896 | |
| 1897 | bgp_attr_extra_free (&new_attr); |
| 1898 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1899 | return; |
| 1900 | |
| 1901 | filtered: |
| 1902 | |
| 1903 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 1904 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1905 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1906 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 1907 | peer->host, |
| 1908 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1909 | p->prefixlen, rsclient->host, reason); |
| 1910 | |
| 1911 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1912 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1913 | |
| 1914 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1915 | |
| 1916 | if (new_attr.extra) |
| 1917 | bgp_attr_extra_free (&new_attr); |
| 1918 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1919 | return; |
| 1920 | } |
| 1921 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1922 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1923 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1924 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 1925 | struct prefix_rd *prd, u_char *tag) |
| 1926 | { |
| 1927 | struct bgp_node *rn; |
| 1928 | struct bgp_info *ri; |
| 1929 | char buf[SU_ADDRSTRLEN]; |
| 1930 | |
| 1931 | if (rsclient == peer) |
| 1932 | return; |
| 1933 | |
| 1934 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1935 | |
| 1936 | /* Lookup withdrawn route. */ |
| 1937 | for (ri = rn->info; ri; ri = ri->next) |
| 1938 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1939 | break; |
| 1940 | |
| 1941 | /* Withdraw specified route from routing table. */ |
| 1942 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1943 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1944 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1945 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1946 | "%s Can't find the route %s/%d", peer->host, |
| 1947 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1948 | p->prefixlen); |
| 1949 | |
| 1950 | /* Unlock bgp_node_get() lock. */ |
| 1951 | bgp_unlock_node (rn); |
| 1952 | } |
| 1953 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1954 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1955 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1956 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1957 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1958 | { |
| 1959 | int ret; |
| 1960 | int aspath_loop_count = 0; |
| 1961 | struct bgp_node *rn; |
| 1962 | struct bgp *bgp; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1963 | struct attr new_attr = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1964 | struct attr *attr_new; |
| 1965 | struct bgp_info *ri; |
| 1966 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1967 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1968 | char buf[SU_ADDRSTRLEN]; |
| 1969 | |
| 1970 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1971 | 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] | 1972 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1973 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 1974 | Adj-RIBs-In. */ |
| 1975 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1976 | && peer != bgp->peer_self && ! soft_reconfig) |
| 1977 | bgp_adj_in_set (rn, peer, attr); |
| 1978 | |
| 1979 | /* Check previously received route. */ |
| 1980 | for (ri = rn->info; ri; ri = ri->next) |
| 1981 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1982 | break; |
| 1983 | |
| 1984 | /* AS path local-as loop check. */ |
| 1985 | if (peer->change_local_as) |
| 1986 | { |
| 1987 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 1988 | aspath_loop_count = 1; |
| 1989 | |
| 1990 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 1991 | { |
| 1992 | reason = "as-path contains our own AS;"; |
| 1993 | goto filtered; |
| 1994 | } |
| 1995 | } |
| 1996 | |
| 1997 | /* AS path loop check. */ |
| 1998 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 1999 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2000 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2001 | > peer->allowas_in[afi][safi])) |
| 2002 | { |
| 2003 | reason = "as-path contains our own AS;"; |
| 2004 | goto filtered; |
| 2005 | } |
| 2006 | |
| 2007 | /* Route reflector originator ID check. */ |
| 2008 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2009 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2010 | { |
| 2011 | reason = "originator is us;"; |
| 2012 | goto filtered; |
| 2013 | } |
| 2014 | |
| 2015 | /* Route reflector cluster ID check. */ |
| 2016 | if (bgp_cluster_filter (peer, attr)) |
| 2017 | { |
| 2018 | reason = "reflected from the same cluster;"; |
| 2019 | goto filtered; |
| 2020 | } |
| 2021 | |
| 2022 | /* Apply incoming filter. */ |
| 2023 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2024 | { |
| 2025 | reason = "filter;"; |
| 2026 | goto filtered; |
| 2027 | } |
| 2028 | |
| 2029 | /* Apply incoming route-map. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2030 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2031 | |
| 2032 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2033 | { |
| 2034 | reason = "route-map;"; |
| 2035 | goto filtered; |
| 2036 | } |
| 2037 | |
| 2038 | /* IPv4 unicast next hop check. */ |
| 2039 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2040 | { |
| 2041 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2042 | discard it. */ |
| 2043 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
| 2044 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2045 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2046 | { |
| 2047 | reason = "non-connected next-hop;"; |
| 2048 | goto filtered; |
| 2049 | } |
| 2050 | |
| 2051 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop |
| 2052 | must not be my own address. */ |
| 2053 | if (bgp_nexthop_self (afi, &new_attr) |
| 2054 | || new_attr.nexthop.s_addr == 0 |
| 2055 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 2056 | { |
| 2057 | reason = "martian next-hop;"; |
| 2058 | goto filtered; |
| 2059 | } |
| 2060 | } |
| 2061 | |
| 2062 | attr_new = bgp_attr_intern (&new_attr); |
| 2063 | |
| 2064 | /* If the update is implicit withdraw. */ |
| 2065 | if (ri) |
| 2066 | { |
| 2067 | ri->uptime = time (NULL); |
| 2068 | |
| 2069 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2070 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2071 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2072 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2073 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2074 | |
| 2075 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2076 | && peer_sort (peer) == BGP_PEER_EBGP |
| 2077 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2078 | { |
| 2079 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2080 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2081 | peer->host, |
| 2082 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2083 | p->prefixlen); |
| 2084 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2085 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2086 | { |
| 2087 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2088 | bgp_process (bgp, rn, afi, safi); |
| 2089 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2090 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2091 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2092 | { |
| 2093 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2094 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2095 | "%s rcvd %s/%d...duplicate ignored", |
| 2096 | peer->host, |
| 2097 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2098 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2099 | |
| 2100 | /* graceful restart STALE flag unset. */ |
| 2101 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2102 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2103 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2104 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2105 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2106 | } |
| 2107 | |
| 2108 | bgp_unlock_node (rn); |
| 2109 | bgp_attr_unintern (attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2110 | bgp_attr_extra_free (&new_attr); |
| 2111 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2112 | return 0; |
| 2113 | } |
| 2114 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2115 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2116 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2117 | { |
| 2118 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2119 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2120 | peer->host, |
| 2121 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2122 | p->prefixlen); |
| 2123 | bgp_info_restore (rn, ri); |
| 2124 | } |
| 2125 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2126 | /* Received Logging. */ |
| 2127 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2128 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2129 | peer->host, |
| 2130 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2131 | p->prefixlen); |
| 2132 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2133 | /* graceful restart STALE flag unset. */ |
| 2134 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2135 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2136 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2137 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2138 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2139 | |
| 2140 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2141 | * only if update is accepted, they'll increment below. |
| 2142 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2143 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2144 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2145 | /* Update bgp route dampening information. */ |
| 2146 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2147 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2148 | { |
| 2149 | /* This is implicit withdraw so we should update dampening |
| 2150 | information. */ |
| 2151 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2152 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2153 | } |
| 2154 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2155 | /* Update to new attribute. */ |
| 2156 | bgp_attr_unintern (ri->attr); |
| 2157 | ri->attr = attr_new; |
| 2158 | |
| 2159 | /* Update MPLS tag. */ |
| 2160 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2161 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2162 | |
| 2163 | /* Update bgp route dampening information. */ |
| 2164 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2165 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2166 | { |
| 2167 | /* Now we do normal update dampening. */ |
| 2168 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2169 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2170 | { |
| 2171 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2172 | bgp_attr_extra_free (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2173 | return 0; |
| 2174 | } |
| 2175 | } |
| 2176 | |
| 2177 | /* Nexthop reachability check. */ |
| 2178 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2179 | && safi == SAFI_UNICAST |
| 2180 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 2181 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2182 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2183 | { |
| 2184 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2185 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2186 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2187 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2188 | } |
| 2189 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2190 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2191 | |
| 2192 | /* Process change. */ |
| 2193 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2194 | |
| 2195 | bgp_process (bgp, rn, afi, safi); |
| 2196 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2197 | bgp_attr_extra_free (&new_attr); |
| 2198 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2199 | return 0; |
| 2200 | } |
| 2201 | |
| 2202 | /* Received Logging. */ |
| 2203 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2204 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2205 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2206 | peer->host, |
| 2207 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2208 | p->prefixlen); |
| 2209 | } |
| 2210 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2211 | /* Make new BGP info. */ |
| 2212 | new = bgp_info_new (); |
| 2213 | new->type = type; |
| 2214 | new->sub_type = sub_type; |
| 2215 | new->peer = peer; |
| 2216 | new->attr = attr_new; |
| 2217 | new->uptime = time (NULL); |
| 2218 | |
| 2219 | /* Update MPLS tag. */ |
| 2220 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2221 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2222 | |
| 2223 | /* Nexthop reachability check. */ |
| 2224 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2225 | && safi == SAFI_UNICAST |
| 2226 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 2227 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2228 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2229 | { |
| 2230 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2231 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2232 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2233 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2234 | } |
| 2235 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2236 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2237 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2238 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2239 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2240 | |
| 2241 | /* Register new BGP information. */ |
| 2242 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2243 | |
| 2244 | /* route_node_get lock */ |
| 2245 | bgp_unlock_node (rn); |
| 2246 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2247 | bgp_attr_extra_free (&new_attr); |
| 2248 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2249 | /* If maximum prefix count is configured and current prefix |
| 2250 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2251 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2252 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2253 | |
| 2254 | /* Process change. */ |
| 2255 | bgp_process (bgp, rn, afi, safi); |
| 2256 | |
| 2257 | return 0; |
| 2258 | |
| 2259 | /* This BGP update is filtered. Log the reason then update BGP |
| 2260 | entry. */ |
| 2261 | filtered: |
| 2262 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2263 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2264 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2265 | peer->host, |
| 2266 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2267 | p->prefixlen, reason); |
| 2268 | |
| 2269 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2270 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2271 | |
| 2272 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2273 | |
| 2274 | bgp_attr_extra_free (&new_attr); |
| 2275 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2276 | return 0; |
| 2277 | } |
| 2278 | |
| 2279 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2280 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2281 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2282 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2283 | { |
| 2284 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2285 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2286 | struct bgp *bgp; |
| 2287 | int ret; |
| 2288 | |
| 2289 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2290 | soft_reconfig); |
| 2291 | |
| 2292 | bgp = peer->bgp; |
| 2293 | |
| 2294 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2295 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2296 | { |
| 2297 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2298 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2299 | sub_type, prd, tag); |
| 2300 | } |
| 2301 | |
| 2302 | return ret; |
| 2303 | } |
| 2304 | |
| 2305 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2306 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2307 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2308 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2309 | { |
| 2310 | struct bgp *bgp; |
| 2311 | char buf[SU_ADDRSTRLEN]; |
| 2312 | struct bgp_node *rn; |
| 2313 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2314 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2315 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | |
| 2317 | bgp = peer->bgp; |
| 2318 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2319 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2320 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2321 | { |
| 2322 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2323 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2324 | } |
| 2325 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2326 | /* Logging. */ |
| 2327 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2328 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2329 | peer->host, |
| 2330 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2331 | p->prefixlen); |
| 2332 | |
| 2333 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2334 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2335 | |
| 2336 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2337 | further calculation. */ |
| 2338 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2339 | && peer != bgp->peer_self) |
| 2340 | bgp_adj_in_unset (rn, peer); |
| 2341 | |
| 2342 | /* Lookup withdrawn route. */ |
| 2343 | for (ri = rn->info; ri; ri = ri->next) |
| 2344 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2345 | break; |
| 2346 | |
| 2347 | /* Withdraw specified route from routing table. */ |
| 2348 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2349 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2350 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2351 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2352 | "%s Can't find the route %s/%d", peer->host, |
| 2353 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2354 | p->prefixlen); |
| 2355 | |
| 2356 | /* Unlock bgp_node_get() lock. */ |
| 2357 | bgp_unlock_node (rn); |
| 2358 | |
| 2359 | return 0; |
| 2360 | } |
| 2361 | |
| 2362 | void |
| 2363 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2364 | { |
| 2365 | struct bgp *bgp; |
| 2366 | struct attr attr; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2367 | struct aspath *aspath = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2368 | struct prefix p; |
| 2369 | struct bgp_info binfo; |
| 2370 | struct peer *from; |
| 2371 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2372 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame^] | 2373 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2374 | return; |
| 2375 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2376 | bgp = peer->bgp; |
| 2377 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2378 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2379 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2380 | aspath = attr.aspath; |
| 2381 | attr.local_pref = bgp->default_local_pref; |
| 2382 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2383 | |
| 2384 | if (afi == AFI_IP) |
| 2385 | str2prefix ("0.0.0.0/0", &p); |
| 2386 | #ifdef HAVE_IPV6 |
| 2387 | else if (afi == AFI_IP6) |
| 2388 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2389 | struct attr_extra *ae; |
| 2390 | attr.extra = NULL; |
| 2391 | |
| 2392 | ae = bgp_attr_extra_get (&attr); |
| 2393 | attr.extra = ae; |
| 2394 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2395 | str2prefix ("::/0", &p); |
| 2396 | |
| 2397 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2398 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2399 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2400 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2401 | |
| 2402 | /* If the peer is on shared nextwork and we have link-local |
| 2403 | nexthop set it. */ |
| 2404 | if (peer->shared_network |
| 2405 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2406 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2407 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2408 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2409 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2410 | } |
| 2411 | } |
| 2412 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2413 | |
| 2414 | if (peer->default_rmap[afi][safi].name) |
| 2415 | { |
| 2416 | binfo.peer = bgp->peer_self; |
| 2417 | binfo.attr = &attr; |
| 2418 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2419 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2420 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2421 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2422 | RMAP_BGP, &binfo); |
| 2423 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2424 | bgp->peer_self->rmap_type = 0; |
| 2425 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2426 | if (ret == RMAP_DENYMATCH) |
| 2427 | { |
| 2428 | bgp_attr_flush (&attr); |
| 2429 | withdraw = 1; |
| 2430 | } |
| 2431 | } |
| 2432 | |
| 2433 | if (withdraw) |
| 2434 | { |
| 2435 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2436 | bgp_default_withdraw_send (peer, afi, safi); |
| 2437 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2438 | } |
| 2439 | else |
| 2440 | { |
| 2441 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2442 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2443 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2444 | |
| 2445 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2446 | aspath_unintern (aspath); |
| 2447 | } |
| 2448 | |
| 2449 | static void |
| 2450 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2451 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2452 | { |
| 2453 | struct bgp_node *rn; |
| 2454 | struct bgp_info *ri; |
| 2455 | struct attr attr; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2456 | |
| 2457 | memset (&attr, 0, sizeof (struct attr)); |
| 2458 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2459 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2460 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2461 | |
| 2462 | if (safi != SAFI_MPLS_VPN |
| 2463 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2464 | bgp_default_originate (peer, afi, safi, 0); |
| 2465 | |
| 2466 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2467 | for (ri = rn->info; ri; ri = ri->next) |
| 2468 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2469 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2470 | if ( (rsclient) ? |
| 2471 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2472 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2473 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2474 | else |
| 2475 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2476 | |
| 2477 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | } |
| 2479 | } |
| 2480 | |
| 2481 | void |
| 2482 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2483 | { |
| 2484 | struct bgp_node *rn; |
| 2485 | struct bgp_table *table; |
| 2486 | |
| 2487 | if (peer->status != Established) |
| 2488 | return; |
| 2489 | |
| 2490 | if (! peer->afc_nego[afi][safi]) |
| 2491 | return; |
| 2492 | |
| 2493 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2494 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2495 | return; |
| 2496 | |
| 2497 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2498 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2499 | else |
| 2500 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2501 | rn = bgp_route_next(rn)) |
| 2502 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2503 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2504 | |
| 2505 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2506 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2507 | } |
| 2508 | |
| 2509 | void |
| 2510 | bgp_announce_route_all (struct peer *peer) |
| 2511 | { |
| 2512 | afi_t afi; |
| 2513 | safi_t safi; |
| 2514 | |
| 2515 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2516 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2517 | bgp_announce_route (peer, afi, safi); |
| 2518 | } |
| 2519 | |
| 2520 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2521 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
| 2522 | safi_t safi, struct bgp_table *table) |
| 2523 | { |
| 2524 | struct bgp_node *rn; |
| 2525 | struct bgp_adj_in *ain; |
| 2526 | |
| 2527 | if (! table) |
| 2528 | table = rsclient->bgp->rib[afi][safi]; |
| 2529 | |
| 2530 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2531 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2532 | { |
| 2533 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
| 2534 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2535 | } |
| 2536 | } |
| 2537 | |
| 2538 | void |
| 2539 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2540 | { |
| 2541 | struct bgp_table *table; |
| 2542 | struct bgp_node *rn; |
| 2543 | |
| 2544 | if (safi != SAFI_MPLS_VPN) |
| 2545 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); |
| 2546 | |
| 2547 | else |
| 2548 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2549 | rn = bgp_route_next (rn)) |
| 2550 | if ((table = rn->info) != NULL) |
| 2551 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); |
| 2552 | } |
| 2553 | |
| 2554 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2555 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 2556 | struct bgp_table *table) |
| 2557 | { |
| 2558 | int ret; |
| 2559 | struct bgp_node *rn; |
| 2560 | struct bgp_adj_in *ain; |
| 2561 | |
| 2562 | if (! table) |
| 2563 | table = peer->bgp->rib[afi][safi]; |
| 2564 | |
| 2565 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2566 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2567 | { |
| 2568 | if (ain->peer == peer) |
| 2569 | { |
| 2570 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2571 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 2572 | NULL, NULL, 1); |
| 2573 | if (ret < 0) |
| 2574 | { |
| 2575 | bgp_unlock_node (rn); |
| 2576 | return; |
| 2577 | } |
| 2578 | continue; |
| 2579 | } |
| 2580 | } |
| 2581 | } |
| 2582 | |
| 2583 | void |
| 2584 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2585 | { |
| 2586 | struct bgp_node *rn; |
| 2587 | struct bgp_table *table; |
| 2588 | |
| 2589 | if (peer->status != Established) |
| 2590 | return; |
| 2591 | |
| 2592 | if (safi != SAFI_MPLS_VPN) |
| 2593 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 2594 | else |
| 2595 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2596 | rn = bgp_route_next (rn)) |
| 2597 | if ((table = rn->info) != NULL) |
| 2598 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 2599 | } |
| 2600 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2601 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2602 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2603 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2604 | struct bgp_node *rn = data; |
| 2605 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2606 | struct bgp_info *ri; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2607 | afi_t afi = rn->table->afi; |
| 2608 | safi_t safi = rn->table->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2609 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2610 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2611 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2612 | for (ri = rn->info; ri; ri = ri->next) |
| 2613 | if (ri->peer == peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2614 | { |
| 2615 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2616 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2617 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2618 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2619 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2620 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2621 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2622 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2623 | break; |
| 2624 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2625 | return WQ_SUCCESS; |
| 2626 | } |
| 2627 | |
| 2628 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2629 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2630 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2631 | struct bgp_node *rn = data; |
| 2632 | |
| 2633 | bgp_unlock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2634 | } |
| 2635 | |
| 2636 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2637 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2638 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2639 | struct peer *peer = wq->spec.data; |
| 2640 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2641 | peer_unlock (peer); /* bgp_clear_node_complete */ |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2642 | |
| 2643 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2644 | BGP_EVENT_ADD (peer, Clearing_Completed); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2645 | } |
| 2646 | |
| 2647 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2648 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2649 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2650 | #define CLEAR_QUEUE_NAME_LEN 26 /* "clear 2001:123:123:123::1" */ |
| 2651 | char wname[CLEAR_QUEUE_NAME_LEN]; |
| 2652 | |
| 2653 | snprintf (wname, CLEAR_QUEUE_NAME_LEN, "clear %s", peer->host); |
| 2654 | #undef CLEAR_QUEUE_NAME_LEN |
| 2655 | |
| 2656 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2657 | { |
| 2658 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2659 | exit (1); |
| 2660 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2661 | peer->clear_node_queue->spec.hold = 10; |
| 2662 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2663 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2664 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2665 | peer->clear_node_queue->spec.max_retries = 0; |
| 2666 | |
| 2667 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2668 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2669 | } |
| 2670 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2671 | static void |
| 2672 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2673 | struct bgp_table *table, struct peer *rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2674 | { |
| 2675 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2676 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2677 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2678 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2679 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2680 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2681 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2682 | if (! table) |
| 2683 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2684 | |
| 2685 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2686 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2687 | struct bgp_info *ri; |
| 2688 | struct bgp_adj_in *ain; |
| 2689 | struct bgp_adj_out *aout; |
| 2690 | |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2691 | if (rn->info == NULL) |
| 2692 | continue; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2693 | |
| 2694 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2695 | * queued for every clearing peer, regardless of whether it is |
| 2696 | * relevant to the peer at hand. |
| 2697 | * |
| 2698 | * Overview: There are 3 different indices which need to be |
| 2699 | * scrubbed, potentially, when a peer is removed: |
| 2700 | * |
| 2701 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2702 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2703 | * 3 other routes visible by the peer's adj-out index |
| 2704 | * |
| 2705 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2706 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2707 | * adj-outs at our leisure. |
| 2708 | * |
| 2709 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2710 | * invisible via RIB index before peer session is allowed to be |
| 2711 | * brought back up. So one needs to know when such a 'search' is |
| 2712 | * complete. |
| 2713 | * |
| 2714 | * Ideally: |
| 2715 | * |
| 2716 | * - there'd be a single global queue or a single RIB walker |
| 2717 | * - rather than tracking which route_nodes still need to be |
| 2718 | * examined on a peer basis, we'd track which peers still |
| 2719 | * aren't cleared |
| 2720 | * |
| 2721 | * Given that our per-peer prefix-counts now should be reliable, |
| 2722 | * this may actually be achievable. It doesn't seem to be a huge |
| 2723 | * problem at this time, |
| 2724 | */ |
| 2725 | for (ri = rn->info; ri; ri = ri->next) |
| 2726 | if (ri->peer == peer) |
| 2727 | { |
| 2728 | bgp_lock_node (rn); /* unlocked: bgp_clear_node_queue_del */ |
| 2729 | work_queue_add (peer->clear_node_queue, rn); |
| 2730 | } |
| 2731 | |
| 2732 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2733 | if (ain->peer == peer) |
| 2734 | { |
| 2735 | bgp_adj_in_remove (rn, ain); |
| 2736 | bgp_unlock_node (rn); |
| 2737 | break; |
| 2738 | } |
| 2739 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2740 | if (aout->peer == peer) |
| 2741 | { |
| 2742 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2743 | bgp_unlock_node (rn); |
| 2744 | break; |
| 2745 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2746 | } |
| 2747 | return; |
| 2748 | } |
| 2749 | |
| 2750 | void |
| 2751 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2752 | { |
| 2753 | struct bgp_node *rn; |
| 2754 | struct bgp_table *table; |
| 2755 | struct peer *rsclient; |
| 2756 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2757 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2758 | if (peer->clear_node_queue == NULL) |
| 2759 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2760 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2761 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2762 | * Idle until it receives a Clearing_Completed event. This protects |
| 2763 | * against peers which flap faster than we can we clear, which could |
| 2764 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2765 | * |
| 2766 | * a) race with routes from the new session being installed before |
| 2767 | * clear_route_node visits the node (to delete the route of that |
| 2768 | * peer) |
| 2769 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2770 | * on the process_main queue. Fast-flapping could cause that queue |
| 2771 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2772 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2773 | if (!peer->clear_node_queue->thread) |
| 2774 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2775 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2776 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2777 | bgp_clear_route_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2778 | else |
| 2779 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2780 | rn = bgp_route_next (rn)) |
| 2781 | if ((table = rn->info) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2782 | bgp_clear_route_table (peer, afi, safi, table, NULL); |
| 2783 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2784 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2785 | { |
| 2786 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2787 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient); |
| 2788 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2789 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2790 | /* If no routes were cleared, nothing was added to workqueue, the |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2791 | * completion function won't be run by workqueue code - call it here. |
| 2792 | * XXX: Actually, this assumption doesn't hold, see |
| 2793 | * bgp_clear_route_table(), we queue all non-empty nodes. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2794 | * |
| 2795 | * Additionally, there is a presumption in FSM that clearing is only |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2796 | * really needed if peer state is Established - peers in |
| 2797 | * pre-Established states shouldn't have any route-update state |
| 2798 | * associated with them (in or out). |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2799 | * |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2800 | * We still can get here in pre-Established though, through |
| 2801 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity |
| 2802 | * check to ensure the assumption above holds. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2803 | * |
| 2804 | * At some future point, this check could be move to the top of the |
| 2805 | * function, and do a quick early-return when state is |
| 2806 | * pre-Established, avoiding above list and table scans. Once we're |
| 2807 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2808 | */ |
| 2809 | if (!peer->clear_node_queue->thread) |
| 2810 | bgp_clear_node_complete (peer->clear_node_queue); |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2811 | else |
| 2812 | { |
| 2813 | /* clearing queue scheduled. Normal if in Established state |
| 2814 | * (and about to transition out of it), but otherwise... |
| 2815 | */ |
| 2816 | if (peer->status != Established) |
| 2817 | { |
| 2818 | plog_err (peer->log, "%s [Error] State %s is not Established," |
| 2819 | " but routes were cleared - bug!", |
| 2820 | peer->host, LOOKUP (bgp_status_msg, peer->status)); |
| 2821 | assert (peer->status == Established); |
| 2822 | } |
| 2823 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2824 | } |
| 2825 | |
| 2826 | void |
| 2827 | bgp_clear_route_all (struct peer *peer) |
| 2828 | { |
| 2829 | afi_t afi; |
| 2830 | safi_t safi; |
| 2831 | |
| 2832 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2833 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2834 | bgp_clear_route (peer, afi, safi); |
| 2835 | } |
| 2836 | |
| 2837 | void |
| 2838 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2839 | { |
| 2840 | struct bgp_table *table; |
| 2841 | struct bgp_node *rn; |
| 2842 | struct bgp_adj_in *ain; |
| 2843 | |
| 2844 | table = peer->bgp->rib[afi][safi]; |
| 2845 | |
| 2846 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2847 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2848 | if (ain->peer == peer) |
| 2849 | { |
| 2850 | bgp_adj_in_remove (rn, ain); |
| 2851 | bgp_unlock_node (rn); |
| 2852 | break; |
| 2853 | } |
| 2854 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2855 | |
| 2856 | void |
| 2857 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2858 | { |
| 2859 | struct bgp_node *rn; |
| 2860 | struct bgp_info *ri; |
| 2861 | struct bgp_table *table; |
| 2862 | |
| 2863 | table = peer->bgp->rib[afi][safi]; |
| 2864 | |
| 2865 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2866 | { |
| 2867 | for (ri = rn->info; ri; ri = ri->next) |
| 2868 | if (ri->peer == peer) |
| 2869 | { |
| 2870 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2871 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 2872 | break; |
| 2873 | } |
| 2874 | } |
| 2875 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2876 | |
| 2877 | /* Delete all kernel routes. */ |
| 2878 | void |
paul | 545acaf | 2004-04-20 15:13:15 +0000 | [diff] [blame] | 2879 | bgp_cleanup_routes () |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2880 | { |
| 2881 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2882 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2883 | struct bgp_node *rn; |
| 2884 | struct bgp_table *table; |
| 2885 | struct bgp_info *ri; |
| 2886 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2887 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2888 | { |
| 2889 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 2890 | |
| 2891 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2892 | for (ri = rn->info; ri; ri = ri->next) |
| 2893 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2894 | && ri->type == ZEBRA_ROUTE_BGP |
| 2895 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2896 | bgp_zebra_withdraw (&rn->p, ri); |
| 2897 | |
| 2898 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 2899 | |
| 2900 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2901 | for (ri = rn->info; ri; ri = ri->next) |
| 2902 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2903 | && ri->type == ZEBRA_ROUTE_BGP |
| 2904 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2905 | bgp_zebra_withdraw (&rn->p, ri); |
| 2906 | } |
| 2907 | } |
| 2908 | |
| 2909 | void |
| 2910 | bgp_reset () |
| 2911 | { |
| 2912 | vty_reset (); |
| 2913 | bgp_zclient_reset (); |
| 2914 | access_list_reset (); |
| 2915 | prefix_list_reset (); |
| 2916 | } |
| 2917 | |
| 2918 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 2919 | value. */ |
| 2920 | int |
| 2921 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 2922 | { |
| 2923 | u_char *pnt; |
| 2924 | u_char *lim; |
| 2925 | struct prefix p; |
| 2926 | int psize; |
| 2927 | int ret; |
| 2928 | |
| 2929 | /* Check peer status. */ |
| 2930 | if (peer->status != Established) |
| 2931 | return 0; |
| 2932 | |
| 2933 | pnt = packet->nlri; |
| 2934 | lim = pnt + packet->length; |
| 2935 | |
| 2936 | for (; pnt < lim; pnt += psize) |
| 2937 | { |
| 2938 | /* Clear prefix structure. */ |
| 2939 | memset (&p, 0, sizeof (struct prefix)); |
| 2940 | |
| 2941 | /* Fetch prefix length. */ |
| 2942 | p.prefixlen = *pnt++; |
| 2943 | p.family = afi2family (packet->afi); |
| 2944 | |
| 2945 | /* Already checked in nlri_sanity_check(). We do double check |
| 2946 | here. */ |
| 2947 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 2948 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 2949 | return -1; |
| 2950 | |
| 2951 | /* Packet size overflow check. */ |
| 2952 | psize = PSIZE (p.prefixlen); |
| 2953 | |
| 2954 | /* When packet overflow occur return immediately. */ |
| 2955 | if (pnt + psize > lim) |
| 2956 | return -1; |
| 2957 | |
| 2958 | /* Fetch prefix from NLRI packet. */ |
| 2959 | memcpy (&p.u.prefix, pnt, psize); |
| 2960 | |
| 2961 | /* Check address. */ |
| 2962 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 2963 | { |
| 2964 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 2965 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2966 | /* |
| 2967 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 2968 | * If a BGP router receives an UPDATE message with a |
| 2969 | * semantically incorrect NLRI field, in which a prefix is |
| 2970 | * semantically incorrect (eg. an unexpected multicast IP |
| 2971 | * address), it should ignore the prefix. |
| 2972 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2973 | zlog (peer->log, LOG_ERR, |
| 2974 | "IPv4 unicast NLRI is multicast address %s", |
| 2975 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2976 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2977 | return -1; |
| 2978 | } |
| 2979 | } |
| 2980 | |
| 2981 | #ifdef HAVE_IPV6 |
| 2982 | /* Check address. */ |
| 2983 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 2984 | { |
| 2985 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2986 | { |
| 2987 | char buf[BUFSIZ]; |
| 2988 | |
| 2989 | zlog (peer->log, LOG_WARNING, |
| 2990 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 2991 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 2992 | |
| 2993 | continue; |
| 2994 | } |
| 2995 | } |
| 2996 | #endif /* HAVE_IPV6 */ |
| 2997 | |
| 2998 | /* Normal process. */ |
| 2999 | if (attr) |
| 3000 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3001 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3002 | else |
| 3003 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3004 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3005 | |
| 3006 | /* Address family configuration mismatch or maximum-prefix count |
| 3007 | overflow. */ |
| 3008 | if (ret < 0) |
| 3009 | return -1; |
| 3010 | } |
| 3011 | |
| 3012 | /* Packet length consistency check. */ |
| 3013 | if (pnt != lim) |
| 3014 | return -1; |
| 3015 | |
| 3016 | return 0; |
| 3017 | } |
| 3018 | |
| 3019 | /* NLRI encode syntax check routine. */ |
| 3020 | int |
| 3021 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3022 | bgp_size_t length) |
| 3023 | { |
| 3024 | u_char *end; |
| 3025 | u_char prefixlen; |
| 3026 | int psize; |
| 3027 | |
| 3028 | end = pnt + length; |
| 3029 | |
| 3030 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3031 | syntactic validity. If the field is syntactically incorrect, |
| 3032 | then the Error Subcode is set to Invalid Network Field. */ |
| 3033 | |
| 3034 | while (pnt < end) |
| 3035 | { |
| 3036 | prefixlen = *pnt++; |
| 3037 | |
| 3038 | /* Prefix length check. */ |
| 3039 | if ((afi == AFI_IP && prefixlen > 32) |
| 3040 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3041 | { |
| 3042 | plog_err (peer->log, |
| 3043 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3044 | peer->host, prefixlen); |
| 3045 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3046 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3047 | return -1; |
| 3048 | } |
| 3049 | |
| 3050 | /* Packet size overflow check. */ |
| 3051 | psize = PSIZE (prefixlen); |
| 3052 | |
| 3053 | if (pnt + psize > end) |
| 3054 | { |
| 3055 | plog_err (peer->log, |
| 3056 | "%s [Error] Update packet error" |
| 3057 | " (prefix data overflow prefix size is %d)", |
| 3058 | peer->host, psize); |
| 3059 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3060 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3061 | return -1; |
| 3062 | } |
| 3063 | |
| 3064 | pnt += psize; |
| 3065 | } |
| 3066 | |
| 3067 | /* Packet length consistency check. */ |
| 3068 | if (pnt != end) |
| 3069 | { |
| 3070 | plog_err (peer->log, |
| 3071 | "%s [Error] Update packet error" |
| 3072 | " (prefix length mismatch with total length)", |
| 3073 | peer->host); |
| 3074 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3075 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3076 | return -1; |
| 3077 | } |
| 3078 | return 0; |
| 3079 | } |
| 3080 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3081 | static struct bgp_static * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3082 | bgp_static_new () |
| 3083 | { |
| 3084 | struct bgp_static *new; |
| 3085 | new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
| 3086 | memset (new, 0, sizeof (struct bgp_static)); |
| 3087 | return new; |
| 3088 | } |
| 3089 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3090 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3091 | bgp_static_free (struct bgp_static *bgp_static) |
| 3092 | { |
| 3093 | if (bgp_static->rmap.name) |
| 3094 | free (bgp_static->rmap.name); |
| 3095 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3096 | } |
| 3097 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3098 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3099 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3100 | struct prefix *p, afi_t afi, safi_t safi) |
| 3101 | { |
| 3102 | struct bgp_node *rn; |
| 3103 | struct bgp_info *ri; |
| 3104 | |
| 3105 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3106 | |
| 3107 | /* Check selected route and self inserted route. */ |
| 3108 | for (ri = rn->info; ri; ri = ri->next) |
| 3109 | if (ri->peer == bgp->peer_self |
| 3110 | && ri->type == ZEBRA_ROUTE_BGP |
| 3111 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3112 | break; |
| 3113 | |
| 3114 | /* Withdraw static BGP route from routing table. */ |
| 3115 | if (ri) |
| 3116 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3117 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3118 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3119 | } |
| 3120 | |
| 3121 | /* Unlock bgp_node_lookup. */ |
| 3122 | bgp_unlock_node (rn); |
| 3123 | } |
| 3124 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3125 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3126 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3127 | struct bgp_static *bgp_static, |
| 3128 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3129 | { |
| 3130 | struct bgp_node *rn; |
| 3131 | struct bgp_info *ri; |
| 3132 | struct bgp_info *new; |
| 3133 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3134 | struct attr *attr_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3135 | struct attr attr = {0 }; |
| 3136 | struct attr new_attr = { .extra = 0 }; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3137 | struct bgp *bgp; |
| 3138 | int ret; |
| 3139 | char buf[SU_ADDRSTRLEN]; |
| 3140 | |
| 3141 | bgp = rsclient->bgp; |
| 3142 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3143 | assert (bgp_static); |
| 3144 | if (!bgp_static) |
| 3145 | return; |
| 3146 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3147 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3148 | |
| 3149 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3150 | |
| 3151 | attr.nexthop = bgp_static->igpnexthop; |
| 3152 | attr.med = bgp_static->igpmetric; |
| 3153 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3154 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3155 | /* Apply network route-map for export to this rsclient. */ |
| 3156 | if (bgp_static->rmap.name) |
| 3157 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3158 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3159 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3160 | info.attr = &attr_tmp; |
| 3161 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3162 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3163 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3164 | |
| 3165 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3166 | |
| 3167 | rsclient->rmap_type = 0; |
| 3168 | |
| 3169 | if (ret == RMAP_DENYMATCH) |
| 3170 | { |
| 3171 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3172 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3173 | |
| 3174 | /* Unintern original. */ |
| 3175 | aspath_unintern (attr.aspath); |
| 3176 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3177 | bgp_attr_extra_free (&attr); |
| 3178 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3179 | return; |
| 3180 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3181 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3182 | } |
| 3183 | else |
| 3184 | attr_new = bgp_attr_intern (&attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3185 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3186 | new_attr = *attr_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3187 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3188 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3189 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3190 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3191 | == RMAP_DENY) |
| 3192 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3193 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3194 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3195 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3196 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3197 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3198 | p->prefixlen, rsclient->host); |
| 3199 | |
| 3200 | bgp->peer_self->rmap_type = 0; |
| 3201 | |
| 3202 | bgp_attr_unintern (attr_new); |
| 3203 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3204 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3205 | |
| 3206 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3207 | |
| 3208 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3209 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3210 | |
| 3211 | bgp->peer_self->rmap_type = 0; |
| 3212 | |
| 3213 | bgp_attr_unintern (attr_new); |
| 3214 | attr_new = bgp_attr_intern (&new_attr); |
| 3215 | |
| 3216 | for (ri = rn->info; ri; ri = ri->next) |
| 3217 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3218 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3219 | break; |
| 3220 | |
| 3221 | if (ri) |
| 3222 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3223 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3224 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3225 | { |
| 3226 | bgp_unlock_node (rn); |
| 3227 | bgp_attr_unintern (attr_new); |
| 3228 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3229 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3230 | return; |
| 3231 | } |
| 3232 | else |
| 3233 | { |
| 3234 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3235 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3236 | |
| 3237 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3238 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3239 | bgp_info_restore(rn, ri); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3240 | bgp_attr_unintern (ri->attr); |
| 3241 | ri->attr = attr_new; |
| 3242 | ri->uptime = time (NULL); |
| 3243 | |
| 3244 | /* Process change. */ |
| 3245 | bgp_process (bgp, rn, afi, safi); |
| 3246 | bgp_unlock_node (rn); |
| 3247 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3248 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3249 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3250 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3251 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3252 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3253 | /* Make new BGP info. */ |
| 3254 | new = bgp_info_new (); |
| 3255 | new->type = ZEBRA_ROUTE_BGP; |
| 3256 | new->sub_type = BGP_ROUTE_STATIC; |
| 3257 | new->peer = bgp->peer_self; |
| 3258 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3259 | new->attr = attr_new; |
| 3260 | new->uptime = time (NULL); |
| 3261 | |
| 3262 | /* Register new BGP information. */ |
| 3263 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3264 | |
| 3265 | /* route_node_get lock */ |
| 3266 | bgp_unlock_node (rn); |
| 3267 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3268 | /* Process change. */ |
| 3269 | bgp_process (bgp, rn, afi, safi); |
| 3270 | |
| 3271 | /* Unintern original. */ |
| 3272 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3273 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3274 | } |
| 3275 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3276 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3277 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3278 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3279 | { |
| 3280 | struct bgp_node *rn; |
| 3281 | struct bgp_info *ri; |
| 3282 | struct bgp_info *new; |
| 3283 | struct bgp_info info; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3284 | struct attr attr = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3285 | struct attr *attr_new; |
| 3286 | int ret; |
| 3287 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3288 | assert (bgp_static); |
| 3289 | if (!bgp_static) |
| 3290 | return; |
| 3291 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3292 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3293 | |
| 3294 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3295 | |
| 3296 | attr.nexthop = bgp_static->igpnexthop; |
| 3297 | attr.med = bgp_static->igpmetric; |
| 3298 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3299 | |
| 3300 | /* Apply route-map. */ |
| 3301 | if (bgp_static->rmap.name) |
| 3302 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3303 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3304 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3305 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3306 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3307 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3308 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3309 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3310 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3311 | bgp->peer_self->rmap_type = 0; |
| 3312 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3313 | if (ret == RMAP_DENYMATCH) |
| 3314 | { |
| 3315 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3316 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3317 | |
| 3318 | /* Unintern original. */ |
| 3319 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3320 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3321 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3322 | return; |
| 3323 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3324 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3325 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3326 | else |
| 3327 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3328 | |
| 3329 | for (ri = rn->info; ri; ri = ri->next) |
| 3330 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3331 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3332 | break; |
| 3333 | |
| 3334 | if (ri) |
| 3335 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3336 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3337 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3338 | { |
| 3339 | bgp_unlock_node (rn); |
| 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 | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3343 | return; |
| 3344 | } |
| 3345 | else |
| 3346 | { |
| 3347 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3348 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3349 | |
| 3350 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3351 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3352 | bgp_info_restore(rn, ri); |
| 3353 | else |
| 3354 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3355 | bgp_attr_unintern (ri->attr); |
| 3356 | ri->attr = attr_new; |
| 3357 | ri->uptime = time (NULL); |
| 3358 | |
| 3359 | /* Process change. */ |
| 3360 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3361 | bgp_process (bgp, rn, afi, safi); |
| 3362 | bgp_unlock_node (rn); |
| 3363 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3364 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3365 | return; |
| 3366 | } |
| 3367 | } |
| 3368 | |
| 3369 | /* Make new BGP info. */ |
| 3370 | new = bgp_info_new (); |
| 3371 | new->type = ZEBRA_ROUTE_BGP; |
| 3372 | new->sub_type = BGP_ROUTE_STATIC; |
| 3373 | new->peer = bgp->peer_self; |
| 3374 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3375 | new->attr = attr_new; |
| 3376 | new->uptime = time (NULL); |
| 3377 | |
| 3378 | /* Aggregate address increment. */ |
| 3379 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3380 | |
| 3381 | /* Register new BGP information. */ |
| 3382 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3383 | |
| 3384 | /* route_node_get lock */ |
| 3385 | bgp_unlock_node (rn); |
| 3386 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3387 | /* Process change. */ |
| 3388 | bgp_process (bgp, rn, afi, safi); |
| 3389 | |
| 3390 | /* Unintern original. */ |
| 3391 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3392 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3393 | } |
| 3394 | |
| 3395 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3396 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3397 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3398 | { |
| 3399 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3400 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3401 | |
| 3402 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3403 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3404 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3405 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3406 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3407 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3408 | } |
| 3409 | } |
| 3410 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3411 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3412 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 3413 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 3414 | { |
| 3415 | struct bgp_node *rn; |
| 3416 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3417 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3418 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3419 | |
| 3420 | /* Make new BGP info. */ |
| 3421 | new = bgp_info_new (); |
| 3422 | new->type = ZEBRA_ROUTE_BGP; |
| 3423 | new->sub_type = BGP_ROUTE_STATIC; |
| 3424 | new->peer = bgp->peer_self; |
| 3425 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3426 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3427 | new->uptime = time (NULL); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3428 | new->extra = bgp_info_extra_new(); |
| 3429 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3430 | |
| 3431 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3432 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3433 | |
| 3434 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3435 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3436 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3437 | /* route_node_get lock */ |
| 3438 | bgp_unlock_node (rn); |
| 3439 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3440 | /* Process change. */ |
| 3441 | bgp_process (bgp, rn, afi, safi); |
| 3442 | } |
| 3443 | |
| 3444 | void |
| 3445 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3446 | safi_t safi) |
| 3447 | { |
| 3448 | struct bgp_node *rn; |
| 3449 | struct bgp_info *ri; |
| 3450 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3451 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3452 | |
| 3453 | /* Check selected route and self inserted route. */ |
| 3454 | for (ri = rn->info; ri; ri = ri->next) |
| 3455 | if (ri->peer == bgp->peer_self |
| 3456 | && ri->type == ZEBRA_ROUTE_BGP |
| 3457 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3458 | break; |
| 3459 | |
| 3460 | /* Withdraw static BGP route from routing table. */ |
| 3461 | if (ri) |
| 3462 | { |
| 3463 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3464 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3465 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3466 | } |
| 3467 | |
| 3468 | /* Unlock bgp_node_lookup. */ |
| 3469 | bgp_unlock_node (rn); |
| 3470 | } |
| 3471 | |
| 3472 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3473 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3474 | { |
| 3475 | struct bgp_static *bgp_static; |
| 3476 | struct bgp *bgp; |
| 3477 | struct bgp_node *rn; |
| 3478 | struct prefix *p; |
| 3479 | |
| 3480 | bgp = rsclient->bgp; |
| 3481 | |
| 3482 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3483 | if ((bgp_static = rn->info) != NULL) |
| 3484 | { |
| 3485 | p = &rn->p; |
| 3486 | |
| 3487 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3488 | afi, safi); |
| 3489 | } |
| 3490 | } |
| 3491 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3492 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3493 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 3494 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 3495 | { |
| 3496 | struct bgp_node *rn; |
| 3497 | struct bgp_info *ri; |
| 3498 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3499 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3500 | |
| 3501 | /* Check selected route and self inserted route. */ |
| 3502 | for (ri = rn->info; ri; ri = ri->next) |
| 3503 | if (ri->peer == bgp->peer_self |
| 3504 | && ri->type == ZEBRA_ROUTE_BGP |
| 3505 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3506 | break; |
| 3507 | |
| 3508 | /* Withdraw static BGP route from routing table. */ |
| 3509 | if (ri) |
| 3510 | { |
| 3511 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3512 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3513 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3514 | } |
| 3515 | |
| 3516 | /* Unlock bgp_node_lookup. */ |
| 3517 | bgp_unlock_node (rn); |
| 3518 | } |
| 3519 | |
| 3520 | /* Configure static BGP network. When user don't run zebra, static |
| 3521 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3522 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3523 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
| 3524 | u_int16_t afi, u_char safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3525 | { |
| 3526 | int ret; |
| 3527 | struct prefix p; |
| 3528 | struct bgp_static *bgp_static; |
| 3529 | struct bgp_node *rn; |
| 3530 | int need_update = 0; |
| 3531 | |
| 3532 | /* Convert IP prefix string to struct prefix. */ |
| 3533 | ret = str2prefix (ip_str, &p); |
| 3534 | if (! ret) |
| 3535 | { |
| 3536 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3537 | return CMD_WARNING; |
| 3538 | } |
| 3539 | #ifdef HAVE_IPV6 |
| 3540 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3541 | { |
| 3542 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3543 | VTY_NEWLINE); |
| 3544 | return CMD_WARNING; |
| 3545 | } |
| 3546 | #endif /* HAVE_IPV6 */ |
| 3547 | |
| 3548 | apply_mask (&p); |
| 3549 | |
| 3550 | /* Set BGP static route configuration. */ |
| 3551 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3552 | |
| 3553 | if (rn->info) |
| 3554 | { |
| 3555 | /* Configuration change. */ |
| 3556 | bgp_static = rn->info; |
| 3557 | |
| 3558 | /* Check previous routes are installed into BGP. */ |
| 3559 | if (! bgp_static->backdoor && bgp_static->valid) |
| 3560 | need_update = 1; |
| 3561 | |
| 3562 | bgp_static->backdoor = backdoor; |
| 3563 | if (rmap) |
| 3564 | { |
| 3565 | if (bgp_static->rmap.name) |
| 3566 | free (bgp_static->rmap.name); |
| 3567 | bgp_static->rmap.name = strdup (rmap); |
| 3568 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3569 | } |
| 3570 | else |
| 3571 | { |
| 3572 | if (bgp_static->rmap.name) |
| 3573 | free (bgp_static->rmap.name); |
| 3574 | bgp_static->rmap.name = NULL; |
| 3575 | bgp_static->rmap.map = NULL; |
| 3576 | bgp_static->valid = 0; |
| 3577 | } |
| 3578 | bgp_unlock_node (rn); |
| 3579 | } |
| 3580 | else |
| 3581 | { |
| 3582 | /* New configuration. */ |
| 3583 | bgp_static = bgp_static_new (); |
| 3584 | bgp_static->backdoor = backdoor; |
| 3585 | bgp_static->valid = 0; |
| 3586 | bgp_static->igpmetric = 0; |
| 3587 | bgp_static->igpnexthop.s_addr = 0; |
| 3588 | if (rmap) |
| 3589 | { |
| 3590 | if (bgp_static->rmap.name) |
| 3591 | free (bgp_static->rmap.name); |
| 3592 | bgp_static->rmap.name = strdup (rmap); |
| 3593 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3594 | } |
| 3595 | rn->info = bgp_static; |
| 3596 | } |
| 3597 | |
| 3598 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3599 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3600 | { |
| 3601 | bgp_static->valid = 1; |
| 3602 | |
| 3603 | if (need_update) |
| 3604 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3605 | |
| 3606 | if (! bgp_static->backdoor) |
| 3607 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3608 | } |
| 3609 | |
| 3610 | return CMD_SUCCESS; |
| 3611 | } |
| 3612 | |
| 3613 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3614 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3615 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3616 | u_int16_t afi, u_char safi) |
| 3617 | { |
| 3618 | int ret; |
| 3619 | struct prefix p; |
| 3620 | struct bgp_static *bgp_static; |
| 3621 | struct bgp_node *rn; |
| 3622 | |
| 3623 | /* Convert IP prefix string to struct prefix. */ |
| 3624 | ret = str2prefix (ip_str, &p); |
| 3625 | if (! ret) |
| 3626 | { |
| 3627 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3628 | return CMD_WARNING; |
| 3629 | } |
| 3630 | #ifdef HAVE_IPV6 |
| 3631 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3632 | { |
| 3633 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3634 | VTY_NEWLINE); |
| 3635 | return CMD_WARNING; |
| 3636 | } |
| 3637 | #endif /* HAVE_IPV6 */ |
| 3638 | |
| 3639 | apply_mask (&p); |
| 3640 | |
| 3641 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3642 | if (! rn) |
| 3643 | { |
| 3644 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3645 | VTY_NEWLINE); |
| 3646 | return CMD_WARNING; |
| 3647 | } |
| 3648 | |
| 3649 | bgp_static = rn->info; |
| 3650 | |
| 3651 | /* Update BGP RIB. */ |
| 3652 | if (! bgp_static->backdoor) |
| 3653 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3654 | |
| 3655 | /* Clear configuration. */ |
| 3656 | bgp_static_free (bgp_static); |
| 3657 | rn->info = NULL; |
| 3658 | bgp_unlock_node (rn); |
| 3659 | bgp_unlock_node (rn); |
| 3660 | |
| 3661 | return CMD_SUCCESS; |
| 3662 | } |
| 3663 | |
| 3664 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3665 | instance. */ |
| 3666 | void |
| 3667 | bgp_static_delete (struct bgp *bgp) |
| 3668 | { |
| 3669 | afi_t afi; |
| 3670 | safi_t safi; |
| 3671 | struct bgp_node *rn; |
| 3672 | struct bgp_node *rm; |
| 3673 | struct bgp_table *table; |
| 3674 | struct bgp_static *bgp_static; |
| 3675 | |
| 3676 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3677 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3678 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3679 | if (rn->info != NULL) |
| 3680 | { |
| 3681 | if (safi == SAFI_MPLS_VPN) |
| 3682 | { |
| 3683 | table = rn->info; |
| 3684 | |
| 3685 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3686 | { |
| 3687 | bgp_static = rn->info; |
| 3688 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3689 | AFI_IP, SAFI_MPLS_VPN, |
| 3690 | (struct prefix_rd *)&rn->p, |
| 3691 | bgp_static->tag); |
| 3692 | bgp_static_free (bgp_static); |
| 3693 | rn->info = NULL; |
| 3694 | bgp_unlock_node (rn); |
| 3695 | } |
| 3696 | } |
| 3697 | else |
| 3698 | { |
| 3699 | bgp_static = rn->info; |
| 3700 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3701 | bgp_static_free (bgp_static); |
| 3702 | rn->info = NULL; |
| 3703 | bgp_unlock_node (rn); |
| 3704 | } |
| 3705 | } |
| 3706 | } |
| 3707 | |
| 3708 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3709 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3710 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3711 | { |
| 3712 | int ret; |
| 3713 | struct prefix p; |
| 3714 | struct prefix_rd prd; |
| 3715 | struct bgp *bgp; |
| 3716 | struct bgp_node *prn; |
| 3717 | struct bgp_node *rn; |
| 3718 | struct bgp_table *table; |
| 3719 | struct bgp_static *bgp_static; |
| 3720 | u_char tag[3]; |
| 3721 | |
| 3722 | bgp = vty->index; |
| 3723 | |
| 3724 | ret = str2prefix (ip_str, &p); |
| 3725 | if (! ret) |
| 3726 | { |
| 3727 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3728 | return CMD_WARNING; |
| 3729 | } |
| 3730 | apply_mask (&p); |
| 3731 | |
| 3732 | ret = str2prefix_rd (rd_str, &prd); |
| 3733 | if (! ret) |
| 3734 | { |
| 3735 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3736 | return CMD_WARNING; |
| 3737 | } |
| 3738 | |
| 3739 | ret = str2tag (tag_str, tag); |
| 3740 | if (! ret) |
| 3741 | { |
| 3742 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3743 | return CMD_WARNING; |
| 3744 | } |
| 3745 | |
| 3746 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3747 | (struct prefix *)&prd); |
| 3748 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3749 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3750 | else |
| 3751 | bgp_unlock_node (prn); |
| 3752 | table = prn->info; |
| 3753 | |
| 3754 | rn = bgp_node_get (table, &p); |
| 3755 | |
| 3756 | if (rn->info) |
| 3757 | { |
| 3758 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3759 | bgp_unlock_node (rn); |
| 3760 | } |
| 3761 | else |
| 3762 | { |
| 3763 | /* New configuration. */ |
| 3764 | bgp_static = bgp_static_new (); |
| 3765 | bgp_static->valid = 1; |
| 3766 | memcpy (bgp_static->tag, tag, 3); |
| 3767 | rn->info = bgp_static; |
| 3768 | |
| 3769 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3770 | } |
| 3771 | |
| 3772 | return CMD_SUCCESS; |
| 3773 | } |
| 3774 | |
| 3775 | /* Configure static BGP network. */ |
| 3776 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3777 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3778 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3779 | { |
| 3780 | int ret; |
| 3781 | struct bgp *bgp; |
| 3782 | struct prefix p; |
| 3783 | struct prefix_rd prd; |
| 3784 | struct bgp_node *prn; |
| 3785 | struct bgp_node *rn; |
| 3786 | struct bgp_table *table; |
| 3787 | struct bgp_static *bgp_static; |
| 3788 | u_char tag[3]; |
| 3789 | |
| 3790 | bgp = vty->index; |
| 3791 | |
| 3792 | /* Convert IP prefix string to struct prefix. */ |
| 3793 | ret = str2prefix (ip_str, &p); |
| 3794 | if (! ret) |
| 3795 | { |
| 3796 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3797 | return CMD_WARNING; |
| 3798 | } |
| 3799 | apply_mask (&p); |
| 3800 | |
| 3801 | ret = str2prefix_rd (rd_str, &prd); |
| 3802 | if (! ret) |
| 3803 | { |
| 3804 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3805 | return CMD_WARNING; |
| 3806 | } |
| 3807 | |
| 3808 | ret = str2tag (tag_str, tag); |
| 3809 | if (! ret) |
| 3810 | { |
| 3811 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3812 | return CMD_WARNING; |
| 3813 | } |
| 3814 | |
| 3815 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3816 | (struct prefix *)&prd); |
| 3817 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3818 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3819 | else |
| 3820 | bgp_unlock_node (prn); |
| 3821 | table = prn->info; |
| 3822 | |
| 3823 | rn = bgp_node_lookup (table, &p); |
| 3824 | |
| 3825 | if (rn) |
| 3826 | { |
| 3827 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3828 | |
| 3829 | bgp_static = rn->info; |
| 3830 | bgp_static_free (bgp_static); |
| 3831 | rn->info = NULL; |
| 3832 | bgp_unlock_node (rn); |
| 3833 | bgp_unlock_node (rn); |
| 3834 | } |
| 3835 | else |
| 3836 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3837 | |
| 3838 | return CMD_SUCCESS; |
| 3839 | } |
| 3840 | |
| 3841 | DEFUN (bgp_network, |
| 3842 | bgp_network_cmd, |
| 3843 | "network A.B.C.D/M", |
| 3844 | "Specify a network to announce via BGP\n" |
| 3845 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3846 | { |
| 3847 | return bgp_static_set (vty, vty->index, argv[0], |
| 3848 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3849 | } |
| 3850 | |
| 3851 | DEFUN (bgp_network_route_map, |
| 3852 | bgp_network_route_map_cmd, |
| 3853 | "network A.B.C.D/M route-map WORD", |
| 3854 | "Specify a network to announce via BGP\n" |
| 3855 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3856 | "Route-map to modify the attributes\n" |
| 3857 | "Name of the route map\n") |
| 3858 | { |
| 3859 | return bgp_static_set (vty, vty->index, argv[0], |
| 3860 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3861 | } |
| 3862 | |
| 3863 | DEFUN (bgp_network_backdoor, |
| 3864 | bgp_network_backdoor_cmd, |
| 3865 | "network A.B.C.D/M backdoor", |
| 3866 | "Specify a network to announce via BGP\n" |
| 3867 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3868 | "Specify a BGP backdoor route\n") |
| 3869 | { |
| 3870 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3871 | } |
| 3872 | |
| 3873 | DEFUN (bgp_network_mask, |
| 3874 | bgp_network_mask_cmd, |
| 3875 | "network A.B.C.D mask A.B.C.D", |
| 3876 | "Specify a network to announce via BGP\n" |
| 3877 | "Network number\n" |
| 3878 | "Network mask\n" |
| 3879 | "Network mask\n") |
| 3880 | { |
| 3881 | int ret; |
| 3882 | char prefix_str[BUFSIZ]; |
| 3883 | |
| 3884 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3885 | if (! ret) |
| 3886 | { |
| 3887 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3888 | return CMD_WARNING; |
| 3889 | } |
| 3890 | |
| 3891 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3892 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3893 | } |
| 3894 | |
| 3895 | DEFUN (bgp_network_mask_route_map, |
| 3896 | bgp_network_mask_route_map_cmd, |
| 3897 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 3898 | "Specify a network to announce via BGP\n" |
| 3899 | "Network number\n" |
| 3900 | "Network mask\n" |
| 3901 | "Network mask\n" |
| 3902 | "Route-map to modify the attributes\n" |
| 3903 | "Name of the route map\n") |
| 3904 | { |
| 3905 | int ret; |
| 3906 | char prefix_str[BUFSIZ]; |
| 3907 | |
| 3908 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3909 | if (! ret) |
| 3910 | { |
| 3911 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3912 | return CMD_WARNING; |
| 3913 | } |
| 3914 | |
| 3915 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3916 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
| 3917 | } |
| 3918 | |
| 3919 | DEFUN (bgp_network_mask_backdoor, |
| 3920 | bgp_network_mask_backdoor_cmd, |
| 3921 | "network A.B.C.D mask A.B.C.D backdoor", |
| 3922 | "Specify a network to announce via BGP\n" |
| 3923 | "Network number\n" |
| 3924 | "Network mask\n" |
| 3925 | "Network mask\n" |
| 3926 | "Specify a BGP backdoor route\n") |
| 3927 | { |
| 3928 | int ret; |
| 3929 | char prefix_str[BUFSIZ]; |
| 3930 | |
| 3931 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3932 | if (! ret) |
| 3933 | { |
| 3934 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3935 | return CMD_WARNING; |
| 3936 | } |
| 3937 | |
| 3938 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3939 | } |
| 3940 | |
| 3941 | DEFUN (bgp_network_mask_natural, |
| 3942 | bgp_network_mask_natural_cmd, |
| 3943 | "network A.B.C.D", |
| 3944 | "Specify a network to announce via BGP\n" |
| 3945 | "Network number\n") |
| 3946 | { |
| 3947 | int ret; |
| 3948 | char prefix_str[BUFSIZ]; |
| 3949 | |
| 3950 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3951 | if (! ret) |
| 3952 | { |
| 3953 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3954 | return CMD_WARNING; |
| 3955 | } |
| 3956 | |
| 3957 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3958 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3959 | } |
| 3960 | |
| 3961 | DEFUN (bgp_network_mask_natural_route_map, |
| 3962 | bgp_network_mask_natural_route_map_cmd, |
| 3963 | "network A.B.C.D route-map WORD", |
| 3964 | "Specify a network to announce via BGP\n" |
| 3965 | "Network number\n" |
| 3966 | "Route-map to modify the attributes\n" |
| 3967 | "Name of the route map\n") |
| 3968 | { |
| 3969 | int ret; |
| 3970 | char prefix_str[BUFSIZ]; |
| 3971 | |
| 3972 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3973 | if (! ret) |
| 3974 | { |
| 3975 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3976 | return CMD_WARNING; |
| 3977 | } |
| 3978 | |
| 3979 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3980 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3981 | } |
| 3982 | |
| 3983 | DEFUN (bgp_network_mask_natural_backdoor, |
| 3984 | bgp_network_mask_natural_backdoor_cmd, |
| 3985 | "network A.B.C.D backdoor", |
| 3986 | "Specify a network to announce via BGP\n" |
| 3987 | "Network number\n" |
| 3988 | "Specify a BGP backdoor route\n") |
| 3989 | { |
| 3990 | int ret; |
| 3991 | char prefix_str[BUFSIZ]; |
| 3992 | |
| 3993 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3994 | if (! ret) |
| 3995 | { |
| 3996 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3997 | return CMD_WARNING; |
| 3998 | } |
| 3999 | |
| 4000 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 4001 | } |
| 4002 | |
| 4003 | DEFUN (no_bgp_network, |
| 4004 | no_bgp_network_cmd, |
| 4005 | "no network A.B.C.D/M", |
| 4006 | NO_STR |
| 4007 | "Specify a network to announce via BGP\n" |
| 4008 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4009 | { |
| 4010 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4011 | bgp_node_safi (vty)); |
| 4012 | } |
| 4013 | |
| 4014 | ALIAS (no_bgp_network, |
| 4015 | no_bgp_network_route_map_cmd, |
| 4016 | "no network A.B.C.D/M route-map WORD", |
| 4017 | NO_STR |
| 4018 | "Specify a network to announce via BGP\n" |
| 4019 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4020 | "Route-map to modify the attributes\n" |
| 4021 | "Name of the route map\n") |
| 4022 | |
| 4023 | ALIAS (no_bgp_network, |
| 4024 | no_bgp_network_backdoor_cmd, |
| 4025 | "no network A.B.C.D/M backdoor", |
| 4026 | NO_STR |
| 4027 | "Specify a network to announce via BGP\n" |
| 4028 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4029 | "Specify a BGP backdoor route\n") |
| 4030 | |
| 4031 | DEFUN (no_bgp_network_mask, |
| 4032 | no_bgp_network_mask_cmd, |
| 4033 | "no network A.B.C.D mask A.B.C.D", |
| 4034 | NO_STR |
| 4035 | "Specify a network to announce via BGP\n" |
| 4036 | "Network number\n" |
| 4037 | "Network mask\n" |
| 4038 | "Network mask\n") |
| 4039 | { |
| 4040 | int ret; |
| 4041 | char prefix_str[BUFSIZ]; |
| 4042 | |
| 4043 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4044 | if (! ret) |
| 4045 | { |
| 4046 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4047 | return CMD_WARNING; |
| 4048 | } |
| 4049 | |
| 4050 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4051 | bgp_node_safi (vty)); |
| 4052 | } |
| 4053 | |
| 4054 | ALIAS (no_bgp_network_mask, |
| 4055 | no_bgp_network_mask_route_map_cmd, |
| 4056 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4057 | NO_STR |
| 4058 | "Specify a network to announce via BGP\n" |
| 4059 | "Network number\n" |
| 4060 | "Network mask\n" |
| 4061 | "Network mask\n" |
| 4062 | "Route-map to modify the attributes\n" |
| 4063 | "Name of the route map\n") |
| 4064 | |
| 4065 | ALIAS (no_bgp_network_mask, |
| 4066 | no_bgp_network_mask_backdoor_cmd, |
| 4067 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4068 | NO_STR |
| 4069 | "Specify a network to announce via BGP\n" |
| 4070 | "Network number\n" |
| 4071 | "Network mask\n" |
| 4072 | "Network mask\n" |
| 4073 | "Specify a BGP backdoor route\n") |
| 4074 | |
| 4075 | DEFUN (no_bgp_network_mask_natural, |
| 4076 | no_bgp_network_mask_natural_cmd, |
| 4077 | "no network A.B.C.D", |
| 4078 | NO_STR |
| 4079 | "Specify a network to announce via BGP\n" |
| 4080 | "Network number\n") |
| 4081 | { |
| 4082 | int ret; |
| 4083 | char prefix_str[BUFSIZ]; |
| 4084 | |
| 4085 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4086 | if (! ret) |
| 4087 | { |
| 4088 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4089 | return CMD_WARNING; |
| 4090 | } |
| 4091 | |
| 4092 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4093 | bgp_node_safi (vty)); |
| 4094 | } |
| 4095 | |
| 4096 | ALIAS (no_bgp_network_mask_natural, |
| 4097 | no_bgp_network_mask_natural_route_map_cmd, |
| 4098 | "no network A.B.C.D route-map WORD", |
| 4099 | NO_STR |
| 4100 | "Specify a network to announce via BGP\n" |
| 4101 | "Network number\n" |
| 4102 | "Route-map to modify the attributes\n" |
| 4103 | "Name of the route map\n") |
| 4104 | |
| 4105 | ALIAS (no_bgp_network_mask_natural, |
| 4106 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4107 | "no network A.B.C.D backdoor", |
| 4108 | NO_STR |
| 4109 | "Specify a network to announce via BGP\n" |
| 4110 | "Network number\n" |
| 4111 | "Specify a BGP backdoor route\n") |
| 4112 | |
| 4113 | #ifdef HAVE_IPV6 |
| 4114 | DEFUN (ipv6_bgp_network, |
| 4115 | ipv6_bgp_network_cmd, |
| 4116 | "network X:X::X:X/M", |
| 4117 | "Specify a network to announce via BGP\n" |
| 4118 | "IPv6 prefix <network>/<length>\n") |
| 4119 | { |
| 4120 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 4121 | } |
| 4122 | |
| 4123 | DEFUN (ipv6_bgp_network_route_map, |
| 4124 | ipv6_bgp_network_route_map_cmd, |
| 4125 | "network X:X::X:X/M route-map WORD", |
| 4126 | "Specify a network to announce via BGP\n" |
| 4127 | "IPv6 prefix <network>/<length>\n" |
| 4128 | "Route-map to modify the attributes\n" |
| 4129 | "Name of the route map\n") |
| 4130 | { |
| 4131 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
| 4132 | bgp_node_safi (vty), argv[1], 0); |
| 4133 | } |
| 4134 | |
| 4135 | DEFUN (no_ipv6_bgp_network, |
| 4136 | no_ipv6_bgp_network_cmd, |
| 4137 | "no network X:X::X:X/M", |
| 4138 | NO_STR |
| 4139 | "Specify a network to announce via BGP\n" |
| 4140 | "IPv6 prefix <network>/<length>\n") |
| 4141 | { |
| 4142 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4143 | } |
| 4144 | |
| 4145 | ALIAS (no_ipv6_bgp_network, |
| 4146 | no_ipv6_bgp_network_route_map_cmd, |
| 4147 | "no network X:X::X:X/M route-map WORD", |
| 4148 | NO_STR |
| 4149 | "Specify a network to announce via BGP\n" |
| 4150 | "IPv6 prefix <network>/<length>\n" |
| 4151 | "Route-map to modify the attributes\n" |
| 4152 | "Name of the route map\n") |
| 4153 | |
| 4154 | ALIAS (ipv6_bgp_network, |
| 4155 | old_ipv6_bgp_network_cmd, |
| 4156 | "ipv6 bgp network X:X::X:X/M", |
| 4157 | IPV6_STR |
| 4158 | BGP_STR |
| 4159 | "Specify a network to announce via BGP\n" |
| 4160 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4161 | |
| 4162 | ALIAS (no_ipv6_bgp_network, |
| 4163 | old_no_ipv6_bgp_network_cmd, |
| 4164 | "no ipv6 bgp network X:X::X:X/M", |
| 4165 | NO_STR |
| 4166 | IPV6_STR |
| 4167 | BGP_STR |
| 4168 | "Specify a network to announce via BGP\n" |
| 4169 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4170 | #endif /* HAVE_IPV6 */ |
| 4171 | |
| 4172 | /* Aggreagete address: |
| 4173 | |
| 4174 | advertise-map Set condition to advertise attribute |
| 4175 | as-set Generate AS set path information |
| 4176 | attribute-map Set attributes of aggregate |
| 4177 | route-map Set parameters of aggregate |
| 4178 | summary-only Filter more specific routes from updates |
| 4179 | suppress-map Conditionally filter more specific routes from updates |
| 4180 | <cr> |
| 4181 | */ |
| 4182 | struct bgp_aggregate |
| 4183 | { |
| 4184 | /* Summary-only flag. */ |
| 4185 | u_char summary_only; |
| 4186 | |
| 4187 | /* AS set generation. */ |
| 4188 | u_char as_set; |
| 4189 | |
| 4190 | /* Route-map for aggregated route. */ |
| 4191 | struct route_map *map; |
| 4192 | |
| 4193 | /* Suppress-count. */ |
| 4194 | unsigned long count; |
| 4195 | |
| 4196 | /* SAFI configuration. */ |
| 4197 | safi_t safi; |
| 4198 | }; |
| 4199 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4200 | static struct bgp_aggregate * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4201 | bgp_aggregate_new () |
| 4202 | { |
| 4203 | struct bgp_aggregate *new; |
| 4204 | new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
| 4205 | memset (new, 0, sizeof (struct bgp_aggregate)); |
| 4206 | return new; |
| 4207 | } |
| 4208 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4209 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4210 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4211 | { |
| 4212 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4213 | } |
| 4214 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4215 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4216 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4217 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4218 | struct bgp_aggregate *aggregate) |
| 4219 | { |
| 4220 | struct bgp_table *table; |
| 4221 | struct bgp_node *top; |
| 4222 | struct bgp_node *rn; |
| 4223 | u_char origin; |
| 4224 | struct aspath *aspath = NULL; |
| 4225 | struct aspath *asmerge = NULL; |
| 4226 | struct community *community = NULL; |
| 4227 | struct community *commerge = NULL; |
| 4228 | struct in_addr nexthop; |
| 4229 | u_int32_t med = 0; |
| 4230 | struct bgp_info *ri; |
| 4231 | struct bgp_info *new; |
| 4232 | int first = 1; |
| 4233 | unsigned long match = 0; |
| 4234 | |
| 4235 | /* Record adding route's nexthop and med. */ |
| 4236 | if (rinew) |
| 4237 | { |
| 4238 | nexthop = rinew->attr->nexthop; |
| 4239 | med = rinew->attr->med; |
| 4240 | } |
| 4241 | |
| 4242 | /* ORIGIN attribute: If at least one route among routes that are |
| 4243 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4244 | aggregated route must have the ORIGIN attribute with the value |
| 4245 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4246 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4247 | route must have the origin attribute with the value EGP. In all |
| 4248 | other case the value of the ORIGIN attribute of the aggregated |
| 4249 | route is INTERNAL. */ |
| 4250 | origin = BGP_ORIGIN_IGP; |
| 4251 | |
| 4252 | table = bgp->rib[afi][safi]; |
| 4253 | |
| 4254 | top = bgp_node_get (table, p); |
| 4255 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4256 | if (rn->p.prefixlen > p->prefixlen) |
| 4257 | { |
| 4258 | match = 0; |
| 4259 | |
| 4260 | for (ri = rn->info; ri; ri = ri->next) |
| 4261 | { |
| 4262 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4263 | continue; |
| 4264 | |
| 4265 | if (del && ri == del) |
| 4266 | continue; |
| 4267 | |
| 4268 | if (! rinew && first) |
| 4269 | { |
| 4270 | nexthop = ri->attr->nexthop; |
| 4271 | med = ri->attr->med; |
| 4272 | first = 0; |
| 4273 | } |
| 4274 | |
| 4275 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4276 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4277 | || ri->attr->med != med) |
| 4278 | { |
| 4279 | if (aspath) |
| 4280 | aspath_free (aspath); |
| 4281 | if (community) |
| 4282 | community_free (community); |
| 4283 | bgp_unlock_node (rn); |
| 4284 | bgp_unlock_node (top); |
| 4285 | return; |
| 4286 | } |
| 4287 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4288 | |
| 4289 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4290 | { |
| 4291 | if (aggregate->summary_only) |
| 4292 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4293 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4294 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4295 | match++; |
| 4296 | } |
| 4297 | |
| 4298 | aggregate->count++; |
| 4299 | |
| 4300 | if (aggregate->as_set) |
| 4301 | { |
| 4302 | if (origin < ri->attr->origin) |
| 4303 | origin = ri->attr->origin; |
| 4304 | |
| 4305 | if (aspath) |
| 4306 | { |
| 4307 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4308 | aspath_free (aspath); |
| 4309 | aspath = asmerge; |
| 4310 | } |
| 4311 | else |
| 4312 | aspath = aspath_dup (ri->attr->aspath); |
| 4313 | |
| 4314 | if (ri->attr->community) |
| 4315 | { |
| 4316 | if (community) |
| 4317 | { |
| 4318 | commerge = community_merge (community, |
| 4319 | ri->attr->community); |
| 4320 | community = community_uniq_sort (commerge); |
| 4321 | community_free (commerge); |
| 4322 | } |
| 4323 | else |
| 4324 | community = community_dup (ri->attr->community); |
| 4325 | } |
| 4326 | } |
| 4327 | } |
| 4328 | } |
| 4329 | if (match) |
| 4330 | bgp_process (bgp, rn, afi, safi); |
| 4331 | } |
| 4332 | bgp_unlock_node (top); |
| 4333 | |
| 4334 | if (rinew) |
| 4335 | { |
| 4336 | aggregate->count++; |
| 4337 | |
| 4338 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4339 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4340 | |
| 4341 | if (aggregate->as_set) |
| 4342 | { |
| 4343 | if (origin < rinew->attr->origin) |
| 4344 | origin = rinew->attr->origin; |
| 4345 | |
| 4346 | if (aspath) |
| 4347 | { |
| 4348 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4349 | aspath_free (aspath); |
| 4350 | aspath = asmerge; |
| 4351 | } |
| 4352 | else |
| 4353 | aspath = aspath_dup (rinew->attr->aspath); |
| 4354 | |
| 4355 | if (rinew->attr->community) |
| 4356 | { |
| 4357 | if (community) |
| 4358 | { |
| 4359 | commerge = community_merge (community, |
| 4360 | rinew->attr->community); |
| 4361 | community = community_uniq_sort (commerge); |
| 4362 | community_free (commerge); |
| 4363 | } |
| 4364 | else |
| 4365 | community = community_dup (rinew->attr->community); |
| 4366 | } |
| 4367 | } |
| 4368 | } |
| 4369 | |
| 4370 | if (aggregate->count > 0) |
| 4371 | { |
| 4372 | rn = bgp_node_get (table, p); |
| 4373 | new = bgp_info_new (); |
| 4374 | new->type = ZEBRA_ROUTE_BGP; |
| 4375 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4376 | new->peer = bgp->peer_self; |
| 4377 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4378 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4379 | new->uptime = time (NULL); |
| 4380 | |
| 4381 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4382 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4383 | bgp_process (bgp, rn, afi, safi); |
| 4384 | } |
| 4385 | else |
| 4386 | { |
| 4387 | if (aspath) |
| 4388 | aspath_free (aspath); |
| 4389 | if (community) |
| 4390 | community_free (community); |
| 4391 | } |
| 4392 | } |
| 4393 | |
| 4394 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4395 | struct bgp_aggregate *); |
| 4396 | |
| 4397 | void |
| 4398 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4399 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4400 | { |
| 4401 | struct bgp_node *child; |
| 4402 | struct bgp_node *rn; |
| 4403 | struct bgp_aggregate *aggregate; |
| 4404 | |
| 4405 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4406 | if (safi == SAFI_MPLS_VPN) |
| 4407 | return; |
| 4408 | |
| 4409 | if (p->prefixlen == 0) |
| 4410 | return; |
| 4411 | |
| 4412 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4413 | return; |
| 4414 | |
| 4415 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4416 | |
| 4417 | /* Aggregate address configuration check. */ |
| 4418 | for (rn = child; rn; rn = rn->parent) |
| 4419 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4420 | { |
| 4421 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4422 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4423 | } |
| 4424 | bgp_unlock_node (child); |
| 4425 | } |
| 4426 | |
| 4427 | void |
| 4428 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4429 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4430 | { |
| 4431 | struct bgp_node *child; |
| 4432 | struct bgp_node *rn; |
| 4433 | struct bgp_aggregate *aggregate; |
| 4434 | |
| 4435 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4436 | if (safi == SAFI_MPLS_VPN) |
| 4437 | return; |
| 4438 | |
| 4439 | if (p->prefixlen == 0) |
| 4440 | return; |
| 4441 | |
| 4442 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4443 | |
| 4444 | /* Aggregate address configuration check. */ |
| 4445 | for (rn = child; rn; rn = rn->parent) |
| 4446 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4447 | { |
| 4448 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4449 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4450 | } |
| 4451 | bgp_unlock_node (child); |
| 4452 | } |
| 4453 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4454 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4455 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4456 | struct bgp_aggregate *aggregate) |
| 4457 | { |
| 4458 | struct bgp_table *table; |
| 4459 | struct bgp_node *top; |
| 4460 | struct bgp_node *rn; |
| 4461 | struct bgp_info *new; |
| 4462 | struct bgp_info *ri; |
| 4463 | unsigned long match; |
| 4464 | u_char origin = BGP_ORIGIN_IGP; |
| 4465 | struct aspath *aspath = NULL; |
| 4466 | struct aspath *asmerge = NULL; |
| 4467 | struct community *community = NULL; |
| 4468 | struct community *commerge = NULL; |
| 4469 | |
| 4470 | table = bgp->rib[afi][safi]; |
| 4471 | |
| 4472 | /* Sanity check. */ |
| 4473 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4474 | return; |
| 4475 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4476 | return; |
| 4477 | |
| 4478 | /* If routes exists below this node, generate aggregate routes. */ |
| 4479 | top = bgp_node_get (table, p); |
| 4480 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4481 | if (rn->p.prefixlen > p->prefixlen) |
| 4482 | { |
| 4483 | match = 0; |
| 4484 | |
| 4485 | for (ri = rn->info; ri; ri = ri->next) |
| 4486 | { |
| 4487 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4488 | continue; |
| 4489 | |
| 4490 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4491 | { |
| 4492 | /* summary-only aggregate route suppress aggregated |
| 4493 | route announcement. */ |
| 4494 | if (aggregate->summary_only) |
| 4495 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4496 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4497 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4498 | match++; |
| 4499 | } |
| 4500 | /* as-set aggregate route generate origin, as path, |
| 4501 | community aggregation. */ |
| 4502 | if (aggregate->as_set) |
| 4503 | { |
| 4504 | if (origin < ri->attr->origin) |
| 4505 | origin = ri->attr->origin; |
| 4506 | |
| 4507 | if (aspath) |
| 4508 | { |
| 4509 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4510 | aspath_free (aspath); |
| 4511 | aspath = asmerge; |
| 4512 | } |
| 4513 | else |
| 4514 | aspath = aspath_dup (ri->attr->aspath); |
| 4515 | |
| 4516 | if (ri->attr->community) |
| 4517 | { |
| 4518 | if (community) |
| 4519 | { |
| 4520 | commerge = community_merge (community, |
| 4521 | ri->attr->community); |
| 4522 | community = community_uniq_sort (commerge); |
| 4523 | community_free (commerge); |
| 4524 | } |
| 4525 | else |
| 4526 | community = community_dup (ri->attr->community); |
| 4527 | } |
| 4528 | } |
| 4529 | aggregate->count++; |
| 4530 | } |
| 4531 | } |
| 4532 | |
| 4533 | /* If this node is suppressed, process the change. */ |
| 4534 | if (match) |
| 4535 | bgp_process (bgp, rn, afi, safi); |
| 4536 | } |
| 4537 | bgp_unlock_node (top); |
| 4538 | |
| 4539 | /* Add aggregate route to BGP table. */ |
| 4540 | if (aggregate->count) |
| 4541 | { |
| 4542 | rn = bgp_node_get (table, p); |
| 4543 | |
| 4544 | new = bgp_info_new (); |
| 4545 | new->type = ZEBRA_ROUTE_BGP; |
| 4546 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4547 | new->peer = bgp->peer_self; |
| 4548 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4549 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4550 | new->uptime = time (NULL); |
| 4551 | |
| 4552 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4553 | bgp_unlock_node (rn); |
| 4554 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4555 | /* Process change. */ |
| 4556 | bgp_process (bgp, rn, afi, safi); |
| 4557 | } |
| 4558 | } |
| 4559 | |
| 4560 | void |
| 4561 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4562 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4563 | { |
| 4564 | struct bgp_table *table; |
| 4565 | struct bgp_node *top; |
| 4566 | struct bgp_node *rn; |
| 4567 | struct bgp_info *ri; |
| 4568 | unsigned long match; |
| 4569 | |
| 4570 | table = bgp->rib[afi][safi]; |
| 4571 | |
| 4572 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4573 | return; |
| 4574 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4575 | return; |
| 4576 | |
| 4577 | /* If routes exists below this node, generate aggregate routes. */ |
| 4578 | top = bgp_node_get (table, p); |
| 4579 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4580 | if (rn->p.prefixlen > p->prefixlen) |
| 4581 | { |
| 4582 | match = 0; |
| 4583 | |
| 4584 | for (ri = rn->info; ri; ri = ri->next) |
| 4585 | { |
| 4586 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4587 | continue; |
| 4588 | |
| 4589 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4590 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4591 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4592 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4593 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4594 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4595 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4596 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4597 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4598 | match++; |
| 4599 | } |
| 4600 | } |
| 4601 | aggregate->count--; |
| 4602 | } |
| 4603 | } |
| 4604 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4605 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4606 | if (match) |
| 4607 | bgp_process (bgp, rn, afi, safi); |
| 4608 | } |
| 4609 | bgp_unlock_node (top); |
| 4610 | |
| 4611 | /* Delete aggregate route from BGP table. */ |
| 4612 | rn = bgp_node_get (table, p); |
| 4613 | |
| 4614 | for (ri = rn->info; ri; ri = ri->next) |
| 4615 | if (ri->peer == bgp->peer_self |
| 4616 | && ri->type == ZEBRA_ROUTE_BGP |
| 4617 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4618 | break; |
| 4619 | |
| 4620 | /* Withdraw static BGP route from routing table. */ |
| 4621 | if (ri) |
| 4622 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4623 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4624 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4625 | } |
| 4626 | |
| 4627 | /* Unlock bgp_node_lookup. */ |
| 4628 | bgp_unlock_node (rn); |
| 4629 | } |
| 4630 | |
| 4631 | /* Aggregate route attribute. */ |
| 4632 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4633 | #define AGGREGATE_AS_SET 1 |
| 4634 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4635 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4636 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
| 4637 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4638 | u_char summary_only, u_char as_set) |
| 4639 | { |
| 4640 | int ret; |
| 4641 | struct prefix p; |
| 4642 | struct bgp_node *rn; |
| 4643 | struct bgp *bgp; |
| 4644 | struct bgp_aggregate *aggregate; |
| 4645 | |
| 4646 | /* Convert string to prefix structure. */ |
| 4647 | ret = str2prefix (prefix_str, &p); |
| 4648 | if (!ret) |
| 4649 | { |
| 4650 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4651 | return CMD_WARNING; |
| 4652 | } |
| 4653 | apply_mask (&p); |
| 4654 | |
| 4655 | /* Get BGP structure. */ |
| 4656 | bgp = vty->index; |
| 4657 | |
| 4658 | /* Old configuration check. */ |
| 4659 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4660 | |
| 4661 | if (rn->info) |
| 4662 | { |
| 4663 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
| 4664 | bgp_unlock_node (rn); |
| 4665 | return CMD_WARNING; |
| 4666 | } |
| 4667 | |
| 4668 | /* Make aggregate address structure. */ |
| 4669 | aggregate = bgp_aggregate_new (); |
| 4670 | aggregate->summary_only = summary_only; |
| 4671 | aggregate->as_set = as_set; |
| 4672 | aggregate->safi = safi; |
| 4673 | rn->info = aggregate; |
| 4674 | |
| 4675 | /* Aggregate address insert into BGP routing table. */ |
| 4676 | if (safi & SAFI_UNICAST) |
| 4677 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4678 | if (safi & SAFI_MULTICAST) |
| 4679 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4680 | |
| 4681 | return CMD_SUCCESS; |
| 4682 | } |
| 4683 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4684 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4685 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4686 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4687 | { |
| 4688 | int ret; |
| 4689 | struct prefix p; |
| 4690 | struct bgp_node *rn; |
| 4691 | struct bgp *bgp; |
| 4692 | struct bgp_aggregate *aggregate; |
| 4693 | |
| 4694 | /* Convert string to prefix structure. */ |
| 4695 | ret = str2prefix (prefix_str, &p); |
| 4696 | if (!ret) |
| 4697 | { |
| 4698 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4699 | return CMD_WARNING; |
| 4700 | } |
| 4701 | apply_mask (&p); |
| 4702 | |
| 4703 | /* Get BGP structure. */ |
| 4704 | bgp = vty->index; |
| 4705 | |
| 4706 | /* Old configuration check. */ |
| 4707 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4708 | if (! rn) |
| 4709 | { |
| 4710 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4711 | VTY_NEWLINE); |
| 4712 | return CMD_WARNING; |
| 4713 | } |
| 4714 | |
| 4715 | aggregate = rn->info; |
| 4716 | if (aggregate->safi & SAFI_UNICAST) |
| 4717 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4718 | if (aggregate->safi & SAFI_MULTICAST) |
| 4719 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4720 | |
| 4721 | /* Unlock aggregate address configuration. */ |
| 4722 | rn->info = NULL; |
| 4723 | bgp_aggregate_free (aggregate); |
| 4724 | bgp_unlock_node (rn); |
| 4725 | bgp_unlock_node (rn); |
| 4726 | |
| 4727 | return CMD_SUCCESS; |
| 4728 | } |
| 4729 | |
| 4730 | DEFUN (aggregate_address, |
| 4731 | aggregate_address_cmd, |
| 4732 | "aggregate-address A.B.C.D/M", |
| 4733 | "Configure BGP aggregate entries\n" |
| 4734 | "Aggregate prefix\n") |
| 4735 | { |
| 4736 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 4737 | } |
| 4738 | |
| 4739 | DEFUN (aggregate_address_mask, |
| 4740 | aggregate_address_mask_cmd, |
| 4741 | "aggregate-address A.B.C.D A.B.C.D", |
| 4742 | "Configure BGP aggregate entries\n" |
| 4743 | "Aggregate address\n" |
| 4744 | "Aggregate mask\n") |
| 4745 | { |
| 4746 | int ret; |
| 4747 | char prefix_str[BUFSIZ]; |
| 4748 | |
| 4749 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4750 | |
| 4751 | if (! ret) |
| 4752 | { |
| 4753 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4754 | return CMD_WARNING; |
| 4755 | } |
| 4756 | |
| 4757 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4758 | 0, 0); |
| 4759 | } |
| 4760 | |
| 4761 | DEFUN (aggregate_address_summary_only, |
| 4762 | aggregate_address_summary_only_cmd, |
| 4763 | "aggregate-address A.B.C.D/M summary-only", |
| 4764 | "Configure BGP aggregate entries\n" |
| 4765 | "Aggregate prefix\n" |
| 4766 | "Filter more specific routes from updates\n") |
| 4767 | { |
| 4768 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4769 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4770 | } |
| 4771 | |
| 4772 | DEFUN (aggregate_address_mask_summary_only, |
| 4773 | aggregate_address_mask_summary_only_cmd, |
| 4774 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4775 | "Configure BGP aggregate entries\n" |
| 4776 | "Aggregate address\n" |
| 4777 | "Aggregate mask\n" |
| 4778 | "Filter more specific routes from updates\n") |
| 4779 | { |
| 4780 | int ret; |
| 4781 | char prefix_str[BUFSIZ]; |
| 4782 | |
| 4783 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4784 | |
| 4785 | if (! ret) |
| 4786 | { |
| 4787 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4788 | return CMD_WARNING; |
| 4789 | } |
| 4790 | |
| 4791 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4792 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4793 | } |
| 4794 | |
| 4795 | DEFUN (aggregate_address_as_set, |
| 4796 | aggregate_address_as_set_cmd, |
| 4797 | "aggregate-address A.B.C.D/M as-set", |
| 4798 | "Configure BGP aggregate entries\n" |
| 4799 | "Aggregate prefix\n" |
| 4800 | "Generate AS set path information\n") |
| 4801 | { |
| 4802 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4803 | 0, AGGREGATE_AS_SET); |
| 4804 | } |
| 4805 | |
| 4806 | DEFUN (aggregate_address_mask_as_set, |
| 4807 | aggregate_address_mask_as_set_cmd, |
| 4808 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 4809 | "Configure BGP aggregate entries\n" |
| 4810 | "Aggregate address\n" |
| 4811 | "Aggregate mask\n" |
| 4812 | "Generate AS set path information\n") |
| 4813 | { |
| 4814 | int ret; |
| 4815 | char prefix_str[BUFSIZ]; |
| 4816 | |
| 4817 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4818 | |
| 4819 | if (! ret) |
| 4820 | { |
| 4821 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4822 | return CMD_WARNING; |
| 4823 | } |
| 4824 | |
| 4825 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4826 | 0, AGGREGATE_AS_SET); |
| 4827 | } |
| 4828 | |
| 4829 | |
| 4830 | DEFUN (aggregate_address_as_set_summary, |
| 4831 | aggregate_address_as_set_summary_cmd, |
| 4832 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 4833 | "Configure BGP aggregate entries\n" |
| 4834 | "Aggregate prefix\n" |
| 4835 | "Generate AS set path information\n" |
| 4836 | "Filter more specific routes from updates\n") |
| 4837 | { |
| 4838 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4839 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4840 | } |
| 4841 | |
| 4842 | ALIAS (aggregate_address_as_set_summary, |
| 4843 | aggregate_address_summary_as_set_cmd, |
| 4844 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 4845 | "Configure BGP aggregate entries\n" |
| 4846 | "Aggregate prefix\n" |
| 4847 | "Filter more specific routes from updates\n" |
| 4848 | "Generate AS set path information\n") |
| 4849 | |
| 4850 | DEFUN (aggregate_address_mask_as_set_summary, |
| 4851 | aggregate_address_mask_as_set_summary_cmd, |
| 4852 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4853 | "Configure BGP aggregate entries\n" |
| 4854 | "Aggregate address\n" |
| 4855 | "Aggregate mask\n" |
| 4856 | "Generate AS set path information\n" |
| 4857 | "Filter more specific routes from updates\n") |
| 4858 | { |
| 4859 | int ret; |
| 4860 | char prefix_str[BUFSIZ]; |
| 4861 | |
| 4862 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4863 | |
| 4864 | if (! ret) |
| 4865 | { |
| 4866 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4867 | return CMD_WARNING; |
| 4868 | } |
| 4869 | |
| 4870 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4871 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4872 | } |
| 4873 | |
| 4874 | ALIAS (aggregate_address_mask_as_set_summary, |
| 4875 | aggregate_address_mask_summary_as_set_cmd, |
| 4876 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4877 | "Configure BGP aggregate entries\n" |
| 4878 | "Aggregate address\n" |
| 4879 | "Aggregate mask\n" |
| 4880 | "Filter more specific routes from updates\n" |
| 4881 | "Generate AS set path information\n") |
| 4882 | |
| 4883 | DEFUN (no_aggregate_address, |
| 4884 | no_aggregate_address_cmd, |
| 4885 | "no aggregate-address A.B.C.D/M", |
| 4886 | NO_STR |
| 4887 | "Configure BGP aggregate entries\n" |
| 4888 | "Aggregate prefix\n") |
| 4889 | { |
| 4890 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 4891 | } |
| 4892 | |
| 4893 | ALIAS (no_aggregate_address, |
| 4894 | no_aggregate_address_summary_only_cmd, |
| 4895 | "no aggregate-address A.B.C.D/M summary-only", |
| 4896 | NO_STR |
| 4897 | "Configure BGP aggregate entries\n" |
| 4898 | "Aggregate prefix\n" |
| 4899 | "Filter more specific routes from updates\n") |
| 4900 | |
| 4901 | ALIAS (no_aggregate_address, |
| 4902 | no_aggregate_address_as_set_cmd, |
| 4903 | "no aggregate-address A.B.C.D/M as-set", |
| 4904 | NO_STR |
| 4905 | "Configure BGP aggregate entries\n" |
| 4906 | "Aggregate prefix\n" |
| 4907 | "Generate AS set path information\n") |
| 4908 | |
| 4909 | ALIAS (no_aggregate_address, |
| 4910 | no_aggregate_address_as_set_summary_cmd, |
| 4911 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 4912 | NO_STR |
| 4913 | "Configure BGP aggregate entries\n" |
| 4914 | "Aggregate prefix\n" |
| 4915 | "Generate AS set path information\n" |
| 4916 | "Filter more specific routes from updates\n") |
| 4917 | |
| 4918 | ALIAS (no_aggregate_address, |
| 4919 | no_aggregate_address_summary_as_set_cmd, |
| 4920 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 4921 | NO_STR |
| 4922 | "Configure BGP aggregate entries\n" |
| 4923 | "Aggregate prefix\n" |
| 4924 | "Filter more specific routes from updates\n" |
| 4925 | "Generate AS set path information\n") |
| 4926 | |
| 4927 | DEFUN (no_aggregate_address_mask, |
| 4928 | no_aggregate_address_mask_cmd, |
| 4929 | "no aggregate-address A.B.C.D A.B.C.D", |
| 4930 | NO_STR |
| 4931 | "Configure BGP aggregate entries\n" |
| 4932 | "Aggregate address\n" |
| 4933 | "Aggregate mask\n") |
| 4934 | { |
| 4935 | int ret; |
| 4936 | char prefix_str[BUFSIZ]; |
| 4937 | |
| 4938 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4939 | |
| 4940 | if (! ret) |
| 4941 | { |
| 4942 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4943 | return CMD_WARNING; |
| 4944 | } |
| 4945 | |
| 4946 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 4947 | } |
| 4948 | |
| 4949 | ALIAS (no_aggregate_address_mask, |
| 4950 | no_aggregate_address_mask_summary_only_cmd, |
| 4951 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4952 | NO_STR |
| 4953 | "Configure BGP aggregate entries\n" |
| 4954 | "Aggregate address\n" |
| 4955 | "Aggregate mask\n" |
| 4956 | "Filter more specific routes from updates\n") |
| 4957 | |
| 4958 | ALIAS (no_aggregate_address_mask, |
| 4959 | no_aggregate_address_mask_as_set_cmd, |
| 4960 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 4961 | NO_STR |
| 4962 | "Configure BGP aggregate entries\n" |
| 4963 | "Aggregate address\n" |
| 4964 | "Aggregate mask\n" |
| 4965 | "Generate AS set path information\n") |
| 4966 | |
| 4967 | ALIAS (no_aggregate_address_mask, |
| 4968 | no_aggregate_address_mask_as_set_summary_cmd, |
| 4969 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4970 | NO_STR |
| 4971 | "Configure BGP aggregate entries\n" |
| 4972 | "Aggregate address\n" |
| 4973 | "Aggregate mask\n" |
| 4974 | "Generate AS set path information\n" |
| 4975 | "Filter more specific routes from updates\n") |
| 4976 | |
| 4977 | ALIAS (no_aggregate_address_mask, |
| 4978 | no_aggregate_address_mask_summary_as_set_cmd, |
| 4979 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4980 | NO_STR |
| 4981 | "Configure BGP aggregate entries\n" |
| 4982 | "Aggregate address\n" |
| 4983 | "Aggregate mask\n" |
| 4984 | "Filter more specific routes from updates\n" |
| 4985 | "Generate AS set path information\n") |
| 4986 | |
| 4987 | #ifdef HAVE_IPV6 |
| 4988 | DEFUN (ipv6_aggregate_address, |
| 4989 | ipv6_aggregate_address_cmd, |
| 4990 | "aggregate-address X:X::X:X/M", |
| 4991 | "Configure BGP aggregate entries\n" |
| 4992 | "Aggregate prefix\n") |
| 4993 | { |
| 4994 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 4995 | } |
| 4996 | |
| 4997 | DEFUN (ipv6_aggregate_address_summary_only, |
| 4998 | ipv6_aggregate_address_summary_only_cmd, |
| 4999 | "aggregate-address X:X::X:X/M summary-only", |
| 5000 | "Configure BGP aggregate entries\n" |
| 5001 | "Aggregate prefix\n" |
| 5002 | "Filter more specific routes from updates\n") |
| 5003 | { |
| 5004 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5005 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5006 | } |
| 5007 | |
| 5008 | DEFUN (no_ipv6_aggregate_address, |
| 5009 | no_ipv6_aggregate_address_cmd, |
| 5010 | "no aggregate-address X:X::X:X/M", |
| 5011 | NO_STR |
| 5012 | "Configure BGP aggregate entries\n" |
| 5013 | "Aggregate prefix\n") |
| 5014 | { |
| 5015 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5016 | } |
| 5017 | |
| 5018 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5019 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5020 | "no aggregate-address X:X::X:X/M summary-only", |
| 5021 | NO_STR |
| 5022 | "Configure BGP aggregate entries\n" |
| 5023 | "Aggregate prefix\n" |
| 5024 | "Filter more specific routes from updates\n") |
| 5025 | { |
| 5026 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5027 | } |
| 5028 | |
| 5029 | ALIAS (ipv6_aggregate_address, |
| 5030 | old_ipv6_aggregate_address_cmd, |
| 5031 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5032 | IPV6_STR |
| 5033 | BGP_STR |
| 5034 | "Configure BGP aggregate entries\n" |
| 5035 | "Aggregate prefix\n") |
| 5036 | |
| 5037 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5038 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5039 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5040 | IPV6_STR |
| 5041 | BGP_STR |
| 5042 | "Configure BGP aggregate entries\n" |
| 5043 | "Aggregate prefix\n" |
| 5044 | "Filter more specific routes from updates\n") |
| 5045 | |
| 5046 | ALIAS (no_ipv6_aggregate_address, |
| 5047 | old_no_ipv6_aggregate_address_cmd, |
| 5048 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5049 | NO_STR |
| 5050 | IPV6_STR |
| 5051 | BGP_STR |
| 5052 | "Configure BGP aggregate entries\n" |
| 5053 | "Aggregate prefix\n") |
| 5054 | |
| 5055 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5056 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5057 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5058 | NO_STR |
| 5059 | IPV6_STR |
| 5060 | BGP_STR |
| 5061 | "Configure BGP aggregate entries\n" |
| 5062 | "Aggregate prefix\n" |
| 5063 | "Filter more specific routes from updates\n") |
| 5064 | #endif /* HAVE_IPV6 */ |
| 5065 | |
| 5066 | /* Redistribute route treatment. */ |
| 5067 | void |
| 5068 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, |
| 5069 | u_int32_t metric, u_char type) |
| 5070 | { |
| 5071 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5072 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5073 | struct bgp_info *new; |
| 5074 | struct bgp_info *bi; |
| 5075 | struct bgp_info info; |
| 5076 | struct bgp_node *bn; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5077 | struct attr attr = { 0 }; |
| 5078 | struct attr attr_new = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5079 | struct attr *new_attr; |
| 5080 | afi_t afi; |
| 5081 | int ret; |
| 5082 | |
| 5083 | /* Make default attribute. */ |
| 5084 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5085 | if (nexthop) |
| 5086 | attr.nexthop = *nexthop; |
| 5087 | |
| 5088 | attr.med = metric; |
| 5089 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5090 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5091 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5092 | { |
| 5093 | afi = family2afi (p->family); |
| 5094 | |
| 5095 | if (bgp->redist[afi][type]) |
| 5096 | { |
| 5097 | /* Copy attribute for modification. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5098 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5099 | |
| 5100 | if (bgp->redist_metric_flag[afi][type]) |
| 5101 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5102 | |
| 5103 | /* Apply route-map. */ |
| 5104 | if (bgp->rmap[afi][type].map) |
| 5105 | { |
| 5106 | info.peer = bgp->peer_self; |
| 5107 | info.attr = &attr_new; |
| 5108 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5109 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5110 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5111 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5112 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5113 | |
| 5114 | bgp->peer_self->rmap_type = 0; |
| 5115 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5116 | if (ret == RMAP_DENYMATCH) |
| 5117 | { |
| 5118 | /* Free uninterned attribute. */ |
| 5119 | bgp_attr_flush (&attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5120 | bgp_attr_extra_free (&attr_new); |
| 5121 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5122 | /* Unintern original. */ |
| 5123 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5124 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5125 | bgp_redistribute_delete (p, type); |
| 5126 | return; |
| 5127 | } |
| 5128 | } |
| 5129 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5130 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5131 | afi, SAFI_UNICAST, p, NULL); |
| 5132 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5133 | new_attr = bgp_attr_intern (&attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5134 | bgp_attr_extra_free (&attr_new); |
| 5135 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5136 | for (bi = bn->info; bi; bi = bi->next) |
| 5137 | if (bi->peer == bgp->peer_self |
| 5138 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5139 | break; |
| 5140 | |
| 5141 | if (bi) |
| 5142 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5143 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5144 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5145 | { |
| 5146 | bgp_attr_unintern (new_attr); |
| 5147 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5148 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5149 | bgp_unlock_node (bn); |
| 5150 | return; |
| 5151 | } |
| 5152 | else |
| 5153 | { |
| 5154 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5155 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5156 | |
| 5157 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5158 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5159 | bgp_info_restore(bn, bi); |
| 5160 | else |
| 5161 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5162 | bgp_attr_unintern (bi->attr); |
| 5163 | bi->attr = new_attr; |
| 5164 | bi->uptime = time (NULL); |
| 5165 | |
| 5166 | /* Process change. */ |
| 5167 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5168 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5169 | bgp_unlock_node (bn); |
| 5170 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5171 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5172 | return; |
| 5173 | } |
| 5174 | } |
| 5175 | |
| 5176 | new = bgp_info_new (); |
| 5177 | new->type = type; |
| 5178 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5179 | new->peer = bgp->peer_self; |
| 5180 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5181 | new->attr = new_attr; |
| 5182 | new->uptime = time (NULL); |
| 5183 | |
| 5184 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5185 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5186 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5187 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5188 | } |
| 5189 | } |
| 5190 | |
| 5191 | /* Unintern original. */ |
| 5192 | aspath_unintern (attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5193 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5194 | } |
| 5195 | |
| 5196 | void |
| 5197 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5198 | { |
| 5199 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5200 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5201 | afi_t afi; |
| 5202 | struct bgp_node *rn; |
| 5203 | struct bgp_info *ri; |
| 5204 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5205 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5206 | { |
| 5207 | afi = family2afi (p->family); |
| 5208 | |
| 5209 | if (bgp->redist[afi][type]) |
| 5210 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5211 | 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] | 5212 | |
| 5213 | for (ri = rn->info; ri; ri = ri->next) |
| 5214 | if (ri->peer == bgp->peer_self |
| 5215 | && ri->type == type) |
| 5216 | break; |
| 5217 | |
| 5218 | if (ri) |
| 5219 | { |
| 5220 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5221 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5222 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5223 | } |
| 5224 | bgp_unlock_node (rn); |
| 5225 | } |
| 5226 | } |
| 5227 | } |
| 5228 | |
| 5229 | /* Withdraw specified route type's route. */ |
| 5230 | void |
| 5231 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5232 | { |
| 5233 | struct bgp_node *rn; |
| 5234 | struct bgp_info *ri; |
| 5235 | struct bgp_table *table; |
| 5236 | |
| 5237 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5238 | |
| 5239 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5240 | { |
| 5241 | for (ri = rn->info; ri; ri = ri->next) |
| 5242 | if (ri->peer == bgp->peer_self |
| 5243 | && ri->type == type) |
| 5244 | break; |
| 5245 | |
| 5246 | if (ri) |
| 5247 | { |
| 5248 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5249 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5250 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5251 | } |
| 5252 | } |
| 5253 | } |
| 5254 | |
| 5255 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5256 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5257 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5258 | { |
| 5259 | int len; |
| 5260 | u_int32_t destination; |
| 5261 | char buf[BUFSIZ]; |
| 5262 | |
| 5263 | if (p->family == AF_INET) |
| 5264 | { |
| 5265 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5266 | destination = ntohl (p->u.prefix4.s_addr); |
| 5267 | |
| 5268 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5269 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5270 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5271 | || p->u.prefix4.s_addr == 0) |
| 5272 | { |
| 5273 | /* When mask is natural, mask is not displayed. */ |
| 5274 | } |
| 5275 | else |
| 5276 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5277 | } |
| 5278 | else |
| 5279 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5280 | p->prefixlen); |
| 5281 | |
| 5282 | len = 17 - len; |
| 5283 | if (len < 1) |
| 5284 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5285 | else |
| 5286 | vty_out (vty, "%*s", len, " "); |
| 5287 | } |
| 5288 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5289 | enum bgp_display_type |
| 5290 | { |
| 5291 | normal_list, |
| 5292 | }; |
| 5293 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5294 | /* Print the short form route status for a bgp_info */ |
| 5295 | static void |
| 5296 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5297 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5298 | /* Route status display. */ |
| 5299 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5300 | vty_out (vty, "R"); |
| 5301 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5302 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5303 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5304 | vty_out (vty, "s"); |
| 5305 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5306 | vty_out (vty, "*"); |
| 5307 | else |
| 5308 | vty_out (vty, " "); |
| 5309 | |
| 5310 | /* Selected */ |
| 5311 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5312 | vty_out (vty, "h"); |
| 5313 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5314 | vty_out (vty, "d"); |
| 5315 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5316 | vty_out (vty, ">"); |
| 5317 | else |
| 5318 | vty_out (vty, " "); |
| 5319 | |
| 5320 | /* Internal route. */ |
| 5321 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5322 | vty_out (vty, "i"); |
| 5323 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5324 | vty_out (vty, " "); |
| 5325 | } |
| 5326 | |
| 5327 | /* called from terminal list command */ |
| 5328 | void |
| 5329 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5330 | struct bgp_info *binfo, int display, safi_t safi) |
| 5331 | { |
| 5332 | struct attr *attr; |
| 5333 | |
| 5334 | /* short status lead text */ |
| 5335 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5336 | |
| 5337 | /* print prefix and mask */ |
| 5338 | if (! display) |
| 5339 | route_vty_out_route (p, vty); |
| 5340 | else |
| 5341 | vty_out (vty, "%*s", 17, " "); |
| 5342 | |
| 5343 | /* Print attribute */ |
| 5344 | attr = binfo->attr; |
| 5345 | if (attr) |
| 5346 | { |
| 5347 | if (p->family == AF_INET) |
| 5348 | { |
| 5349 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5350 | vty_out (vty, "%-16s", |
| 5351 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5352 | else |
| 5353 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5354 | } |
| 5355 | #ifdef HAVE_IPV6 |
| 5356 | else if (p->family == AF_INET6) |
| 5357 | { |
| 5358 | int len; |
| 5359 | char buf[BUFSIZ]; |
| 5360 | |
| 5361 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5362 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5363 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5364 | len = 16 - len; |
| 5365 | if (len < 1) |
| 5366 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5367 | else |
| 5368 | vty_out (vty, "%*s", len, " "); |
| 5369 | } |
| 5370 | #endif /* HAVE_IPV6 */ |
| 5371 | |
| 5372 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 5373 | vty_out (vty, "%10d", attr->med); |
| 5374 | else |
| 5375 | vty_out (vty, " "); |
| 5376 | |
| 5377 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 5378 | vty_out (vty, "%7d", attr->local_pref); |
| 5379 | else |
| 5380 | vty_out (vty, " "); |
| 5381 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5382 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5383 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5384 | /* Print aspath */ |
| 5385 | if (attr->aspath) |
| 5386 | aspath_print_vty (vty, "%s ", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5387 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5388 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5389 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5390 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5391 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5392 | } |
| 5393 | |
| 5394 | /* called from terminal list command */ |
| 5395 | void |
| 5396 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5397 | struct attr *attr, safi_t safi) |
| 5398 | { |
| 5399 | /* Route status display. */ |
| 5400 | vty_out (vty, "*"); |
| 5401 | vty_out (vty, ">"); |
| 5402 | vty_out (vty, " "); |
| 5403 | |
| 5404 | /* print prefix and mask */ |
| 5405 | route_vty_out_route (p, vty); |
| 5406 | |
| 5407 | /* Print attribute */ |
| 5408 | if (attr) |
| 5409 | { |
| 5410 | if (p->family == AF_INET) |
| 5411 | { |
| 5412 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5413 | vty_out (vty, "%-16s", |
| 5414 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5415 | else |
| 5416 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5417 | } |
| 5418 | #ifdef HAVE_IPV6 |
| 5419 | else if (p->family == AF_INET6) |
| 5420 | { |
| 5421 | int len; |
| 5422 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5423 | |
| 5424 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5425 | |
| 5426 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5427 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5428 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5429 | len = 16 - len; |
| 5430 | if (len < 1) |
| 5431 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5432 | else |
| 5433 | vty_out (vty, "%*s", len, " "); |
| 5434 | } |
| 5435 | #endif /* HAVE_IPV6 */ |
| 5436 | |
| 5437 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 5438 | vty_out (vty, "%10d", attr->med); |
| 5439 | else |
| 5440 | vty_out (vty, " "); |
| 5441 | |
| 5442 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 5443 | vty_out (vty, "%7d", attr->local_pref); |
| 5444 | else |
| 5445 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5446 | |
| 5447 | vty_out (vty, "%7d ", (attr->extra ? attr->extra->weight : 0)); |
| 5448 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5449 | /* Print aspath */ |
| 5450 | if (attr->aspath) |
| 5451 | aspath_print_vty (vty, "%s ", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5452 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5453 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5454 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5455 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5456 | |
| 5457 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5458 | } |
| 5459 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5460 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5461 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5462 | struct bgp_info *binfo, int display, safi_t safi) |
| 5463 | { |
| 5464 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5465 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5466 | |
| 5467 | if (!binfo->extra) |
| 5468 | return; |
| 5469 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5470 | /* short status lead text */ |
| 5471 | route_vty_short_status_out (vty, binfo); |
| 5472 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5473 | /* print prefix and mask */ |
| 5474 | if (! display) |
| 5475 | route_vty_out_route (p, vty); |
| 5476 | else |
| 5477 | vty_out (vty, "%*s", 17, " "); |
| 5478 | |
| 5479 | /* Print attribute */ |
| 5480 | attr = binfo->attr; |
| 5481 | if (attr) |
| 5482 | { |
| 5483 | if (p->family == AF_INET) |
| 5484 | { |
| 5485 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5486 | vty_out (vty, "%-16s", |
| 5487 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5488 | else |
| 5489 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5490 | } |
| 5491 | #ifdef HAVE_IPV6 |
| 5492 | else if (p->family == AF_INET6) |
| 5493 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5494 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5495 | char buf[BUFSIZ]; |
| 5496 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5497 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5498 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5499 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5500 | buf, BUFSIZ)); |
| 5501 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5502 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5503 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5504 | buf, BUFSIZ), |
| 5505 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5506 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5507 | |
| 5508 | } |
| 5509 | #endif /* HAVE_IPV6 */ |
| 5510 | } |
| 5511 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5512 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5513 | |
| 5514 | vty_out (vty, "notag/%d", label); |
| 5515 | |
| 5516 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5517 | } |
| 5518 | |
| 5519 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5520 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5521 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5522 | struct bgp_info *binfo, int display, safi_t safi) |
| 5523 | { |
| 5524 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5525 | int len; |
| 5526 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5527 | /* short status lead text */ |
| 5528 | route_vty_short_status_out (vty, binfo); |
| 5529 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5530 | /* print prefix and mask */ |
| 5531 | if (! display) |
| 5532 | route_vty_out_route (p, vty); |
| 5533 | else |
| 5534 | vty_out (vty, "%*s", 17, " "); |
| 5535 | |
| 5536 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5537 | len = 17 - len; |
| 5538 | if (len < 1) |
| 5539 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5540 | else |
| 5541 | vty_out (vty, "%*s", len, " "); |
| 5542 | |
| 5543 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5544 | |
| 5545 | /* Print attribute */ |
| 5546 | attr = binfo->attr; |
| 5547 | if (attr) |
| 5548 | { |
| 5549 | /* Print aspath */ |
| 5550 | if (attr->aspath) |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5551 | aspath_print_vty (vty, "%s ", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5552 | |
| 5553 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5554 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5555 | } |
| 5556 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5557 | } |
| 5558 | |
| 5559 | #define BGP_UPTIME_LEN 25 |
| 5560 | |
| 5561 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5562 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5563 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5564 | struct bgp_info *binfo, int display, safi_t safi) |
| 5565 | { |
| 5566 | struct attr *attr; |
| 5567 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5568 | char timebuf[BGP_UPTIME_LEN]; |
| 5569 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5570 | |
| 5571 | if (!binfo->extra) |
| 5572 | return; |
| 5573 | |
| 5574 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5575 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5576 | /* short status lead text */ |
| 5577 | route_vty_short_status_out (vty, binfo); |
| 5578 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5579 | /* print prefix and mask */ |
| 5580 | if (! display) |
| 5581 | route_vty_out_route (p, vty); |
| 5582 | else |
| 5583 | vty_out (vty, "%*s", 17, " "); |
| 5584 | |
| 5585 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5586 | len = 16 - len; |
| 5587 | if (len < 1) |
| 5588 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5589 | else |
| 5590 | vty_out (vty, "%*s", len, " "); |
| 5591 | |
| 5592 | len = vty_out (vty, "%d", bdi->flap); |
| 5593 | len = 5 - len; |
| 5594 | if (len < 1) |
| 5595 | vty_out (vty, " "); |
| 5596 | else |
| 5597 | vty_out (vty, "%*s ", len, " "); |
| 5598 | |
| 5599 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5600 | timebuf, BGP_UPTIME_LEN)); |
| 5601 | |
| 5602 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5603 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5604 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5605 | else |
| 5606 | vty_out (vty, "%*s ", 8, " "); |
| 5607 | |
| 5608 | /* Print attribute */ |
| 5609 | attr = binfo->attr; |
| 5610 | if (attr) |
| 5611 | { |
| 5612 | /* Print aspath */ |
| 5613 | if (attr->aspath) |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5614 | aspath_print_vty (vty, "%s ", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5615 | |
| 5616 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5617 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5618 | } |
| 5619 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5620 | } |
| 5621 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5622 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5623 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5624 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5625 | { |
| 5626 | char buf[INET6_ADDRSTRLEN]; |
| 5627 | char buf1[BUFSIZ]; |
| 5628 | struct attr *attr; |
| 5629 | int sockunion_vty_out (struct vty *, union sockunion *); |
| 5630 | |
| 5631 | attr = binfo->attr; |
| 5632 | |
| 5633 | if (attr) |
| 5634 | { |
| 5635 | /* Line1 display AS-path, Aggregator */ |
| 5636 | if (attr->aspath) |
| 5637 | { |
| 5638 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5639 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5640 | vty_out (vty, "Local"); |
| 5641 | else |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5642 | aspath_print_vty (vty, "%s", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5643 | } |
| 5644 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5645 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5646 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5647 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5648 | vty_out (vty, ", (stale)"); |
| 5649 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5650 | vty_out (vty, ", (aggregated by %d %s)", |
| 5651 | attr->extra->aggregator_as, |
| 5652 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5653 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5654 | vty_out (vty, ", (Received from a RR-client)"); |
| 5655 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5656 | vty_out (vty, ", (Received from a RS-client)"); |
| 5657 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5658 | vty_out (vty, ", (history entry)"); |
| 5659 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5660 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5661 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5662 | |
| 5663 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5664 | if (p->family == AF_INET) |
| 5665 | { |
| 5666 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5667 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5668 | inet_ntoa (attr->nexthop)); |
| 5669 | } |
| 5670 | #ifdef HAVE_IPV6 |
| 5671 | else |
| 5672 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5673 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5674 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5675 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5676 | buf, INET6_ADDRSTRLEN)); |
| 5677 | } |
| 5678 | #endif /* HAVE_IPV6 */ |
| 5679 | |
| 5680 | if (binfo->peer == bgp->peer_self) |
| 5681 | { |
| 5682 | vty_out (vty, " from %s ", |
| 5683 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5684 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5685 | } |
| 5686 | else |
| 5687 | { |
| 5688 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5689 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5690 | else if (binfo->extra && binfo->extra->igpmetric) |
| 5691 | vty_out (vty, " (metric %d)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5692 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5693 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5694 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5695 | else |
| 5696 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5697 | } |
| 5698 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5699 | |
| 5700 | #ifdef HAVE_IPV6 |
| 5701 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5702 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5703 | { |
| 5704 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5705 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5706 | buf, INET6_ADDRSTRLEN), |
| 5707 | VTY_NEWLINE); |
| 5708 | } |
| 5709 | #endif /* HAVE_IPV6 */ |
| 5710 | |
| 5711 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5712 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5713 | |
| 5714 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
| 5715 | vty_out (vty, ", metric %d", attr->med); |
| 5716 | |
| 5717 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
| 5718 | vty_out (vty, ", localpref %d", attr->local_pref); |
| 5719 | else |
| 5720 | vty_out (vty, ", localpref %d", bgp->default_local_pref); |
| 5721 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5722 | if (attr->extra && attr->extra->weight != 0) |
| 5723 | vty_out (vty, ", weight %d", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5724 | |
| 5725 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5726 | vty_out (vty, ", valid"); |
| 5727 | |
| 5728 | if (binfo->peer != bgp->peer_self) |
| 5729 | { |
| 5730 | if (binfo->peer->as == binfo->peer->local_as) |
| 5731 | vty_out (vty, ", internal"); |
| 5732 | else |
| 5733 | vty_out (vty, ", %s", |
| 5734 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 5735 | } |
| 5736 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 5737 | vty_out (vty, ", aggregated, local"); |
| 5738 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 5739 | vty_out (vty, ", sourced"); |
| 5740 | else |
| 5741 | vty_out (vty, ", sourced, local"); |
| 5742 | |
| 5743 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5744 | vty_out (vty, ", atomic-aggregate"); |
| 5745 | |
| 5746 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5747 | vty_out (vty, ", best"); |
| 5748 | |
| 5749 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5750 | |
| 5751 | /* Line 4 display Community */ |
| 5752 | if (attr->community) |
| 5753 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 5754 | VTY_NEWLINE); |
| 5755 | |
| 5756 | /* Line 5 display Extended-community */ |
| 5757 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5758 | vty_out (vty, " Extended Community: %s%s", |
| 5759 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5760 | |
| 5761 | /* Line 6 display Originator, Cluster-id */ |
| 5762 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 5763 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 5764 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5765 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5766 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5767 | vty_out (vty, " Originator: %s", |
| 5768 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5769 | |
| 5770 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 5771 | { |
| 5772 | int i; |
| 5773 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5774 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 5775 | vty_out (vty, "%s ", |
| 5776 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5777 | } |
| 5778 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5779 | } |
| 5780 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5781 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5782 | bgp_damp_info_vty (vty, binfo); |
| 5783 | |
| 5784 | /* Line 7 display Uptime */ |
| 5785 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); |
| 5786 | } |
| 5787 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5788 | } |
| 5789 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5790 | #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] | 5791 | #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] | 5792 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 5793 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 5794 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 5795 | |
| 5796 | enum bgp_show_type |
| 5797 | { |
| 5798 | bgp_show_type_normal, |
| 5799 | bgp_show_type_regexp, |
| 5800 | bgp_show_type_prefix_list, |
| 5801 | bgp_show_type_filter_list, |
| 5802 | bgp_show_type_route_map, |
| 5803 | bgp_show_type_neighbor, |
| 5804 | bgp_show_type_cidr_only, |
| 5805 | bgp_show_type_prefix_longer, |
| 5806 | bgp_show_type_community_all, |
| 5807 | bgp_show_type_community, |
| 5808 | bgp_show_type_community_exact, |
| 5809 | bgp_show_type_community_list, |
| 5810 | bgp_show_type_community_list_exact, |
| 5811 | bgp_show_type_flap_statistics, |
| 5812 | bgp_show_type_flap_address, |
| 5813 | bgp_show_type_flap_prefix, |
| 5814 | bgp_show_type_flap_cidr_only, |
| 5815 | bgp_show_type_flap_regexp, |
| 5816 | bgp_show_type_flap_filter_list, |
| 5817 | bgp_show_type_flap_prefix_list, |
| 5818 | bgp_show_type_flap_prefix_longer, |
| 5819 | bgp_show_type_flap_route_map, |
| 5820 | bgp_show_type_flap_neighbor, |
| 5821 | bgp_show_type_dampend_paths, |
| 5822 | bgp_show_type_damp_neighbor |
| 5823 | }; |
| 5824 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5825 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5826 | 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] | 5827 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5828 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5829 | struct bgp_info *ri; |
| 5830 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5831 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5832 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5833 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5834 | |
| 5835 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5836 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5837 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5838 | /* Start processing of routes. */ |
| 5839 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5840 | if (rn->info != NULL) |
| 5841 | { |
| 5842 | display = 0; |
| 5843 | |
| 5844 | for (ri = rn->info; ri; ri = ri->next) |
| 5845 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5846 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5847 | || type == bgp_show_type_flap_address |
| 5848 | || type == bgp_show_type_flap_prefix |
| 5849 | || type == bgp_show_type_flap_cidr_only |
| 5850 | || type == bgp_show_type_flap_regexp |
| 5851 | || type == bgp_show_type_flap_filter_list |
| 5852 | || type == bgp_show_type_flap_prefix_list |
| 5853 | || type == bgp_show_type_flap_prefix_longer |
| 5854 | || type == bgp_show_type_flap_route_map |
| 5855 | || type == bgp_show_type_flap_neighbor |
| 5856 | || type == bgp_show_type_dampend_paths |
| 5857 | || type == bgp_show_type_damp_neighbor) |
| 5858 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5859 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5860 | continue; |
| 5861 | } |
| 5862 | if (type == bgp_show_type_regexp |
| 5863 | || type == bgp_show_type_flap_regexp) |
| 5864 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5865 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5866 | |
| 5867 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 5868 | continue; |
| 5869 | } |
| 5870 | if (type == bgp_show_type_prefix_list |
| 5871 | || type == bgp_show_type_flap_prefix_list) |
| 5872 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5873 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5874 | |
| 5875 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 5876 | continue; |
| 5877 | } |
| 5878 | if (type == bgp_show_type_filter_list |
| 5879 | || type == bgp_show_type_flap_filter_list) |
| 5880 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5881 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5882 | |
| 5883 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 5884 | continue; |
| 5885 | } |
| 5886 | if (type == bgp_show_type_route_map |
| 5887 | || type == bgp_show_type_flap_route_map) |
| 5888 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5889 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5890 | struct bgp_info binfo; |
| 5891 | struct attr dummy_attr; |
| 5892 | int ret; |
| 5893 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5894 | bgp_attr_dup (&dummy_attr, ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5895 | binfo.peer = ri->peer; |
| 5896 | binfo.attr = &dummy_attr; |
| 5897 | |
| 5898 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5899 | |
| 5900 | bgp_attr_extra_free (&dummy_attr); |
| 5901 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5902 | if (ret == RMAP_DENYMATCH) |
| 5903 | continue; |
| 5904 | } |
| 5905 | if (type == bgp_show_type_neighbor |
| 5906 | || type == bgp_show_type_flap_neighbor |
| 5907 | || type == bgp_show_type_damp_neighbor) |
| 5908 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5909 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5910 | |
| 5911 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 5912 | continue; |
| 5913 | } |
| 5914 | if (type == bgp_show_type_cidr_only |
| 5915 | || type == bgp_show_type_flap_cidr_only) |
| 5916 | { |
| 5917 | u_int32_t destination; |
| 5918 | |
| 5919 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 5920 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 5921 | continue; |
| 5922 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 5923 | continue; |
| 5924 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 5925 | continue; |
| 5926 | } |
| 5927 | if (type == bgp_show_type_prefix_longer |
| 5928 | || type == bgp_show_type_flap_prefix_longer) |
| 5929 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5930 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5931 | |
| 5932 | if (! prefix_match (p, &rn->p)) |
| 5933 | continue; |
| 5934 | } |
| 5935 | if (type == bgp_show_type_community_all) |
| 5936 | { |
| 5937 | if (! ri->attr->community) |
| 5938 | continue; |
| 5939 | } |
| 5940 | if (type == bgp_show_type_community) |
| 5941 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5942 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5943 | |
| 5944 | if (! ri->attr->community || |
| 5945 | ! community_match (ri->attr->community, com)) |
| 5946 | continue; |
| 5947 | } |
| 5948 | if (type == bgp_show_type_community_exact) |
| 5949 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5950 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5951 | |
| 5952 | if (! ri->attr->community || |
| 5953 | ! community_cmp (ri->attr->community, com)) |
| 5954 | continue; |
| 5955 | } |
| 5956 | if (type == bgp_show_type_community_list) |
| 5957 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5958 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5959 | |
| 5960 | if (! community_list_match (ri->attr->community, list)) |
| 5961 | continue; |
| 5962 | } |
| 5963 | if (type == bgp_show_type_community_list_exact) |
| 5964 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5965 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5966 | |
| 5967 | if (! community_list_exact_match (ri->attr->community, list)) |
| 5968 | continue; |
| 5969 | } |
| 5970 | if (type == bgp_show_type_flap_address |
| 5971 | || type == bgp_show_type_flap_prefix) |
| 5972 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5973 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5974 | |
| 5975 | if (! prefix_match (&rn->p, p)) |
| 5976 | continue; |
| 5977 | |
| 5978 | if (type == bgp_show_type_flap_prefix) |
| 5979 | if (p->prefixlen != rn->p.prefixlen) |
| 5980 | continue; |
| 5981 | } |
| 5982 | if (type == bgp_show_type_dampend_paths |
| 5983 | || type == bgp_show_type_damp_neighbor) |
| 5984 | { |
| 5985 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 5986 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 5987 | continue; |
| 5988 | } |
| 5989 | |
| 5990 | if (header) |
| 5991 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5992 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 5993 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 5994 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5995 | if (type == bgp_show_type_dampend_paths |
| 5996 | || type == bgp_show_type_damp_neighbor) |
| 5997 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 5998 | else if (type == bgp_show_type_flap_statistics |
| 5999 | || type == bgp_show_type_flap_address |
| 6000 | || type == bgp_show_type_flap_prefix |
| 6001 | || type == bgp_show_type_flap_cidr_only |
| 6002 | || type == bgp_show_type_flap_regexp |
| 6003 | || type == bgp_show_type_flap_filter_list |
| 6004 | || type == bgp_show_type_flap_prefix_list |
| 6005 | || type == bgp_show_type_flap_prefix_longer |
| 6006 | || type == bgp_show_type_flap_route_map |
| 6007 | || type == bgp_show_type_flap_neighbor) |
| 6008 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6009 | else |
| 6010 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6011 | header = 0; |
| 6012 | } |
| 6013 | |
| 6014 | if (type == bgp_show_type_dampend_paths |
| 6015 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6016 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | else if (type == bgp_show_type_flap_statistics |
| 6018 | || type == bgp_show_type_flap_address |
| 6019 | || type == bgp_show_type_flap_prefix |
| 6020 | || type == bgp_show_type_flap_cidr_only |
| 6021 | || type == bgp_show_type_flap_regexp |
| 6022 | || type == bgp_show_type_flap_filter_list |
| 6023 | || type == bgp_show_type_flap_prefix_list |
| 6024 | || type == bgp_show_type_flap_prefix_longer |
| 6025 | || type == bgp_show_type_flap_route_map |
| 6026 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6027 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6028 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6029 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6030 | display++; |
| 6031 | } |
| 6032 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6033 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6034 | } |
| 6035 | |
| 6036 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6037 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6038 | { |
| 6039 | if (type == bgp_show_type_normal) |
| 6040 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6041 | } |
| 6042 | else |
| 6043 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6044 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6045 | |
| 6046 | return CMD_SUCCESS; |
| 6047 | } |
| 6048 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6049 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6050 | 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] | 6051 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6052 | { |
| 6053 | struct bgp_table *table; |
| 6054 | |
| 6055 | if (bgp == NULL) { |
| 6056 | bgp = bgp_get_default (); |
| 6057 | } |
| 6058 | |
| 6059 | if (bgp == NULL) |
| 6060 | { |
| 6061 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6062 | return CMD_WARNING; |
| 6063 | } |
| 6064 | |
| 6065 | |
| 6066 | table = bgp->rib[afi][safi]; |
| 6067 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6068 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6069 | } |
| 6070 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6071 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6072 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6073 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6074 | struct bgp_node *rn, |
| 6075 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6076 | { |
| 6077 | struct bgp_info *ri; |
| 6078 | struct prefix *p; |
| 6079 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6080 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6081 | char buf1[INET6_ADDRSTRLEN]; |
| 6082 | char buf2[INET6_ADDRSTRLEN]; |
| 6083 | int count = 0; |
| 6084 | int best = 0; |
| 6085 | int suppress = 0; |
| 6086 | int no_export = 0; |
| 6087 | int no_advertise = 0; |
| 6088 | int local_as = 0; |
| 6089 | int first = 0; |
| 6090 | |
| 6091 | p = &rn->p; |
| 6092 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6093 | (safi == SAFI_MPLS_VPN ? |
| 6094 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6095 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6096 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6097 | p->prefixlen, VTY_NEWLINE); |
| 6098 | |
| 6099 | for (ri = rn->info; ri; ri = ri->next) |
| 6100 | { |
| 6101 | count++; |
| 6102 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6103 | { |
| 6104 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6105 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6106 | suppress = 1; |
| 6107 | if (ri->attr->community != NULL) |
| 6108 | { |
| 6109 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6110 | no_advertise = 1; |
| 6111 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6112 | no_export = 1; |
| 6113 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6114 | local_as = 1; |
| 6115 | } |
| 6116 | } |
| 6117 | } |
| 6118 | |
| 6119 | vty_out (vty, "Paths: (%d available", count); |
| 6120 | if (best) |
| 6121 | { |
| 6122 | vty_out (vty, ", best #%d", best); |
| 6123 | if (safi == SAFI_UNICAST) |
| 6124 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6125 | } |
| 6126 | else |
| 6127 | vty_out (vty, ", no best path"); |
| 6128 | if (no_advertise) |
| 6129 | vty_out (vty, ", not advertised to any peer"); |
| 6130 | else if (no_export) |
| 6131 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6132 | else if (local_as) |
| 6133 | vty_out (vty, ", not advertised outside local AS"); |
| 6134 | if (suppress) |
| 6135 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6136 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6137 | |
| 6138 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6139 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6140 | { |
| 6141 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6142 | { |
| 6143 | if (! first) |
| 6144 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6145 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6146 | first = 1; |
| 6147 | } |
| 6148 | } |
| 6149 | if (! first) |
| 6150 | vty_out (vty, " Not advertised to any peer"); |
| 6151 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6152 | } |
| 6153 | |
| 6154 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6155 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6156 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6157 | struct bgp_table *rib, const char *ip_str, |
| 6158 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6159 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6160 | { |
| 6161 | int ret; |
| 6162 | int header; |
| 6163 | int display = 0; |
| 6164 | struct prefix match; |
| 6165 | struct bgp_node *rn; |
| 6166 | struct bgp_node *rm; |
| 6167 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6168 | struct bgp_table *table; |
| 6169 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6170 | /* Check IP address argument. */ |
| 6171 | ret = str2prefix (ip_str, &match); |
| 6172 | if (! ret) |
| 6173 | { |
| 6174 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6175 | return CMD_WARNING; |
| 6176 | } |
| 6177 | |
| 6178 | match.family = afi2family (afi); |
| 6179 | |
| 6180 | if (safi == SAFI_MPLS_VPN) |
| 6181 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6182 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6183 | { |
| 6184 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6185 | continue; |
| 6186 | |
| 6187 | if ((table = rn->info) != NULL) |
| 6188 | { |
| 6189 | header = 1; |
| 6190 | |
| 6191 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6192 | { |
| 6193 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 6194 | continue; |
| 6195 | |
| 6196 | for (ri = rm->info; ri; ri = ri->next) |
| 6197 | { |
| 6198 | if (header) |
| 6199 | { |
| 6200 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6201 | AFI_IP, SAFI_MPLS_VPN); |
| 6202 | |
| 6203 | header = 0; |
| 6204 | } |
| 6205 | display++; |
| 6206 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6207 | } |
| 6208 | } |
| 6209 | } |
| 6210 | } |
| 6211 | } |
| 6212 | else |
| 6213 | { |
| 6214 | header = 1; |
| 6215 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6216 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6217 | { |
| 6218 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6219 | { |
| 6220 | for (ri = rn->info; ri; ri = ri->next) |
| 6221 | { |
| 6222 | if (header) |
| 6223 | { |
| 6224 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6225 | header = 0; |
| 6226 | } |
| 6227 | display++; |
| 6228 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6229 | } |
| 6230 | } |
| 6231 | } |
| 6232 | } |
| 6233 | |
| 6234 | if (! display) |
| 6235 | { |
| 6236 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6237 | return CMD_WARNING; |
| 6238 | } |
| 6239 | |
| 6240 | return CMD_SUCCESS; |
| 6241 | } |
| 6242 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6243 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6244 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6245 | 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] | 6246 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6247 | int prefix_check) |
| 6248 | { |
| 6249 | struct bgp *bgp; |
| 6250 | |
| 6251 | /* BGP structure lookup. */ |
| 6252 | if (view_name) |
| 6253 | { |
| 6254 | bgp = bgp_lookup_by_name (view_name); |
| 6255 | if (bgp == NULL) |
| 6256 | { |
| 6257 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6258 | return CMD_WARNING; |
| 6259 | } |
| 6260 | } |
| 6261 | else |
| 6262 | { |
| 6263 | bgp = bgp_get_default (); |
| 6264 | if (bgp == NULL) |
| 6265 | { |
| 6266 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6267 | return CMD_WARNING; |
| 6268 | } |
| 6269 | } |
| 6270 | |
| 6271 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6272 | afi, safi, prd, prefix_check); |
| 6273 | } |
| 6274 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6275 | /* BGP route print out function. */ |
| 6276 | DEFUN (show_ip_bgp, |
| 6277 | show_ip_bgp_cmd, |
| 6278 | "show ip bgp", |
| 6279 | SHOW_STR |
| 6280 | IP_STR |
| 6281 | BGP_STR) |
| 6282 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6283 | 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] | 6284 | } |
| 6285 | |
| 6286 | DEFUN (show_ip_bgp_ipv4, |
| 6287 | show_ip_bgp_ipv4_cmd, |
| 6288 | "show ip bgp ipv4 (unicast|multicast)", |
| 6289 | SHOW_STR |
| 6290 | IP_STR |
| 6291 | BGP_STR |
| 6292 | "Address family\n" |
| 6293 | "Address Family modifier\n" |
| 6294 | "Address Family modifier\n") |
| 6295 | { |
| 6296 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6297 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6298 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6299 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6300 | 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] | 6301 | } |
| 6302 | |
| 6303 | DEFUN (show_ip_bgp_route, |
| 6304 | show_ip_bgp_route_cmd, |
| 6305 | "show ip bgp A.B.C.D", |
| 6306 | SHOW_STR |
| 6307 | IP_STR |
| 6308 | BGP_STR |
| 6309 | "Network in the BGP routing table to display\n") |
| 6310 | { |
| 6311 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6312 | } |
| 6313 | |
| 6314 | DEFUN (show_ip_bgp_ipv4_route, |
| 6315 | show_ip_bgp_ipv4_route_cmd, |
| 6316 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6317 | SHOW_STR |
| 6318 | IP_STR |
| 6319 | BGP_STR |
| 6320 | "Address family\n" |
| 6321 | "Address Family modifier\n" |
| 6322 | "Address Family modifier\n" |
| 6323 | "Network in the BGP routing table to display\n") |
| 6324 | { |
| 6325 | if (strncmp (argv[0], "m", 1) == 0) |
| 6326 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6327 | |
| 6328 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6329 | } |
| 6330 | |
| 6331 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6332 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6333 | "show ip bgp vpnv4 all A.B.C.D", |
| 6334 | SHOW_STR |
| 6335 | IP_STR |
| 6336 | BGP_STR |
| 6337 | "Display VPNv4 NLRI specific information\n" |
| 6338 | "Display information about all VPNv4 NLRIs\n" |
| 6339 | "Network in the BGP routing table to display\n") |
| 6340 | { |
| 6341 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6342 | } |
| 6343 | |
| 6344 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6345 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6346 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6347 | SHOW_STR |
| 6348 | IP_STR |
| 6349 | BGP_STR |
| 6350 | "Display VPNv4 NLRI specific information\n" |
| 6351 | "Display information for a route distinguisher\n" |
| 6352 | "VPN Route Distinguisher\n" |
| 6353 | "Network in the BGP routing table to display\n") |
| 6354 | { |
| 6355 | int ret; |
| 6356 | struct prefix_rd prd; |
| 6357 | |
| 6358 | ret = str2prefix_rd (argv[0], &prd); |
| 6359 | if (! ret) |
| 6360 | { |
| 6361 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6362 | return CMD_WARNING; |
| 6363 | } |
| 6364 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6365 | } |
| 6366 | |
| 6367 | DEFUN (show_ip_bgp_prefix, |
| 6368 | show_ip_bgp_prefix_cmd, |
| 6369 | "show ip bgp A.B.C.D/M", |
| 6370 | SHOW_STR |
| 6371 | IP_STR |
| 6372 | BGP_STR |
| 6373 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6374 | { |
| 6375 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6376 | } |
| 6377 | |
| 6378 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6379 | show_ip_bgp_ipv4_prefix_cmd, |
| 6380 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6381 | SHOW_STR |
| 6382 | IP_STR |
| 6383 | BGP_STR |
| 6384 | "Address family\n" |
| 6385 | "Address Family modifier\n" |
| 6386 | "Address Family modifier\n" |
| 6387 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6388 | { |
| 6389 | if (strncmp (argv[0], "m", 1) == 0) |
| 6390 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6391 | |
| 6392 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6393 | } |
| 6394 | |
| 6395 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6396 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6397 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6398 | SHOW_STR |
| 6399 | IP_STR |
| 6400 | BGP_STR |
| 6401 | "Display VPNv4 NLRI specific information\n" |
| 6402 | "Display information about all VPNv4 NLRIs\n" |
| 6403 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6404 | { |
| 6405 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6406 | } |
| 6407 | |
| 6408 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6409 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6410 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6411 | SHOW_STR |
| 6412 | IP_STR |
| 6413 | BGP_STR |
| 6414 | "Display VPNv4 NLRI specific information\n" |
| 6415 | "Display information for a route distinguisher\n" |
| 6416 | "VPN Route Distinguisher\n" |
| 6417 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6418 | { |
| 6419 | int ret; |
| 6420 | struct prefix_rd prd; |
| 6421 | |
| 6422 | ret = str2prefix_rd (argv[0], &prd); |
| 6423 | if (! ret) |
| 6424 | { |
| 6425 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6426 | return CMD_WARNING; |
| 6427 | } |
| 6428 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6429 | } |
| 6430 | |
| 6431 | DEFUN (show_ip_bgp_view, |
| 6432 | show_ip_bgp_view_cmd, |
| 6433 | "show ip bgp view WORD", |
| 6434 | SHOW_STR |
| 6435 | IP_STR |
| 6436 | BGP_STR |
| 6437 | "BGP view\n" |
| 6438 | "BGP view name\n") |
| 6439 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6440 | struct bgp *bgp; |
| 6441 | |
| 6442 | /* BGP structure lookup. */ |
| 6443 | bgp = bgp_lookup_by_name (argv[0]); |
| 6444 | if (bgp == NULL) |
| 6445 | { |
| 6446 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6447 | return CMD_WARNING; |
| 6448 | } |
| 6449 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6450 | 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] | 6451 | } |
| 6452 | |
| 6453 | DEFUN (show_ip_bgp_view_route, |
| 6454 | show_ip_bgp_view_route_cmd, |
| 6455 | "show ip bgp view WORD A.B.C.D", |
| 6456 | SHOW_STR |
| 6457 | IP_STR |
| 6458 | BGP_STR |
| 6459 | "BGP view\n" |
| 6460 | "BGP view name\n" |
| 6461 | "Network in the BGP routing table to display\n") |
| 6462 | { |
| 6463 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6464 | } |
| 6465 | |
| 6466 | DEFUN (show_ip_bgp_view_prefix, |
| 6467 | show_ip_bgp_view_prefix_cmd, |
| 6468 | "show ip bgp view WORD A.B.C.D/M", |
| 6469 | SHOW_STR |
| 6470 | IP_STR |
| 6471 | BGP_STR |
| 6472 | "BGP view\n" |
| 6473 | "BGP view name\n" |
| 6474 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6475 | { |
| 6476 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6477 | } |
| 6478 | |
| 6479 | #ifdef HAVE_IPV6 |
| 6480 | DEFUN (show_bgp, |
| 6481 | show_bgp_cmd, |
| 6482 | "show bgp", |
| 6483 | SHOW_STR |
| 6484 | BGP_STR) |
| 6485 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6486 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6487 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6488 | } |
| 6489 | |
| 6490 | ALIAS (show_bgp, |
| 6491 | show_bgp_ipv6_cmd, |
| 6492 | "show bgp ipv6", |
| 6493 | SHOW_STR |
| 6494 | BGP_STR |
| 6495 | "Address family\n") |
| 6496 | |
| 6497 | /* old command */ |
| 6498 | DEFUN (show_ipv6_bgp, |
| 6499 | show_ipv6_bgp_cmd, |
| 6500 | "show ipv6 bgp", |
| 6501 | SHOW_STR |
| 6502 | IP_STR |
| 6503 | BGP_STR) |
| 6504 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6505 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6506 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6507 | } |
| 6508 | |
| 6509 | DEFUN (show_bgp_route, |
| 6510 | show_bgp_route_cmd, |
| 6511 | "show bgp X:X::X:X", |
| 6512 | SHOW_STR |
| 6513 | BGP_STR |
| 6514 | "Network in the BGP routing table to display\n") |
| 6515 | { |
| 6516 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6517 | } |
| 6518 | |
| 6519 | ALIAS (show_bgp_route, |
| 6520 | show_bgp_ipv6_route_cmd, |
| 6521 | "show bgp ipv6 X:X::X:X", |
| 6522 | SHOW_STR |
| 6523 | BGP_STR |
| 6524 | "Address family\n" |
| 6525 | "Network in the BGP routing table to display\n") |
| 6526 | |
| 6527 | /* old command */ |
| 6528 | DEFUN (show_ipv6_bgp_route, |
| 6529 | show_ipv6_bgp_route_cmd, |
| 6530 | "show ipv6 bgp X:X::X:X", |
| 6531 | SHOW_STR |
| 6532 | IP_STR |
| 6533 | BGP_STR |
| 6534 | "Network in the BGP routing table to display\n") |
| 6535 | { |
| 6536 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6537 | } |
| 6538 | |
| 6539 | DEFUN (show_bgp_prefix, |
| 6540 | show_bgp_prefix_cmd, |
| 6541 | "show bgp X:X::X:X/M", |
| 6542 | SHOW_STR |
| 6543 | BGP_STR |
| 6544 | "IPv6 prefix <network>/<length>\n") |
| 6545 | { |
| 6546 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6547 | } |
| 6548 | |
| 6549 | ALIAS (show_bgp_prefix, |
| 6550 | show_bgp_ipv6_prefix_cmd, |
| 6551 | "show bgp ipv6 X:X::X:X/M", |
| 6552 | SHOW_STR |
| 6553 | BGP_STR |
| 6554 | "Address family\n" |
| 6555 | "IPv6 prefix <network>/<length>\n") |
| 6556 | |
| 6557 | /* old command */ |
| 6558 | DEFUN (show_ipv6_bgp_prefix, |
| 6559 | show_ipv6_bgp_prefix_cmd, |
| 6560 | "show ipv6 bgp X:X::X:X/M", |
| 6561 | SHOW_STR |
| 6562 | IP_STR |
| 6563 | BGP_STR |
| 6564 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6565 | { |
| 6566 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6567 | } |
| 6568 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6569 | DEFUN (show_bgp_view, |
| 6570 | show_bgp_view_cmd, |
| 6571 | "show bgp view WORD", |
| 6572 | SHOW_STR |
| 6573 | BGP_STR |
| 6574 | "BGP view\n" |
| 6575 | "View name\n") |
| 6576 | { |
| 6577 | struct bgp *bgp; |
| 6578 | |
| 6579 | /* BGP structure lookup. */ |
| 6580 | bgp = bgp_lookup_by_name (argv[0]); |
| 6581 | if (bgp == NULL) |
| 6582 | { |
| 6583 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6584 | return CMD_WARNING; |
| 6585 | } |
| 6586 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6587 | 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] | 6588 | } |
| 6589 | |
| 6590 | ALIAS (show_bgp_view, |
| 6591 | show_bgp_view_ipv6_cmd, |
| 6592 | "show bgp view WORD ipv6", |
| 6593 | SHOW_STR |
| 6594 | BGP_STR |
| 6595 | "BGP view\n" |
| 6596 | "View name\n" |
| 6597 | "Address family\n") |
| 6598 | |
| 6599 | DEFUN (show_bgp_view_route, |
| 6600 | show_bgp_view_route_cmd, |
| 6601 | "show bgp view WORD X:X::X:X", |
| 6602 | SHOW_STR |
| 6603 | BGP_STR |
| 6604 | "BGP view\n" |
| 6605 | "View name\n" |
| 6606 | "Network in the BGP routing table to display\n") |
| 6607 | { |
| 6608 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6609 | } |
| 6610 | |
| 6611 | ALIAS (show_bgp_view_route, |
| 6612 | show_bgp_view_ipv6_route_cmd, |
| 6613 | "show bgp view WORD ipv6 X:X::X:X", |
| 6614 | SHOW_STR |
| 6615 | BGP_STR |
| 6616 | "BGP view\n" |
| 6617 | "View name\n" |
| 6618 | "Address family\n" |
| 6619 | "Network in the BGP routing table to display\n") |
| 6620 | |
| 6621 | DEFUN (show_bgp_view_prefix, |
| 6622 | show_bgp_view_prefix_cmd, |
| 6623 | "show bgp view WORD X:X::X:X/M", |
| 6624 | SHOW_STR |
| 6625 | BGP_STR |
| 6626 | "BGP view\n" |
| 6627 | "View name\n" |
| 6628 | "IPv6 prefix <network>/<length>\n") |
| 6629 | { |
| 6630 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6631 | } |
| 6632 | |
| 6633 | ALIAS (show_bgp_view_prefix, |
| 6634 | show_bgp_view_ipv6_prefix_cmd, |
| 6635 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 6636 | SHOW_STR |
| 6637 | BGP_STR |
| 6638 | "BGP view\n" |
| 6639 | "View name\n" |
| 6640 | "Address family\n" |
| 6641 | "IPv6 prefix <network>/<length>\n") |
| 6642 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6643 | /* old command */ |
| 6644 | DEFUN (show_ipv6_mbgp, |
| 6645 | show_ipv6_mbgp_cmd, |
| 6646 | "show ipv6 mbgp", |
| 6647 | SHOW_STR |
| 6648 | IP_STR |
| 6649 | MBGP_STR) |
| 6650 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6651 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6652 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6653 | } |
| 6654 | |
| 6655 | /* old command */ |
| 6656 | DEFUN (show_ipv6_mbgp_route, |
| 6657 | show_ipv6_mbgp_route_cmd, |
| 6658 | "show ipv6 mbgp X:X::X:X", |
| 6659 | SHOW_STR |
| 6660 | IP_STR |
| 6661 | MBGP_STR |
| 6662 | "Network in the MBGP routing table to display\n") |
| 6663 | { |
| 6664 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6665 | } |
| 6666 | |
| 6667 | /* old command */ |
| 6668 | DEFUN (show_ipv6_mbgp_prefix, |
| 6669 | show_ipv6_mbgp_prefix_cmd, |
| 6670 | "show ipv6 mbgp X:X::X:X/M", |
| 6671 | SHOW_STR |
| 6672 | IP_STR |
| 6673 | MBGP_STR |
| 6674 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6675 | { |
| 6676 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6677 | } |
| 6678 | #endif |
| 6679 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6680 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6681 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6682 | 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] | 6683 | safi_t safi, enum bgp_show_type type) |
| 6684 | { |
| 6685 | int i; |
| 6686 | struct buffer *b; |
| 6687 | char *regstr; |
| 6688 | int first; |
| 6689 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6690 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6691 | |
| 6692 | first = 0; |
| 6693 | b = buffer_new (1024); |
| 6694 | for (i = 0; i < argc; i++) |
| 6695 | { |
| 6696 | if (first) |
| 6697 | buffer_putc (b, ' '); |
| 6698 | else |
| 6699 | { |
| 6700 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6701 | continue; |
| 6702 | first = 1; |
| 6703 | } |
| 6704 | |
| 6705 | buffer_putstr (b, argv[i]); |
| 6706 | } |
| 6707 | buffer_putc (b, '\0'); |
| 6708 | |
| 6709 | regstr = buffer_getstr (b); |
| 6710 | buffer_free (b); |
| 6711 | |
| 6712 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6713 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6714 | if (! regex) |
| 6715 | { |
| 6716 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 6717 | VTY_NEWLINE); |
| 6718 | return CMD_WARNING; |
| 6719 | } |
| 6720 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6721 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 6722 | bgp_regex_free (regex); |
| 6723 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6724 | } |
| 6725 | |
| 6726 | DEFUN (show_ip_bgp_regexp, |
| 6727 | show_ip_bgp_regexp_cmd, |
| 6728 | "show ip bgp regexp .LINE", |
| 6729 | SHOW_STR |
| 6730 | IP_STR |
| 6731 | BGP_STR |
| 6732 | "Display routes matching the AS path regular expression\n" |
| 6733 | "A regular-expression to match the BGP AS paths\n") |
| 6734 | { |
| 6735 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6736 | bgp_show_type_regexp); |
| 6737 | } |
| 6738 | |
| 6739 | DEFUN (show_ip_bgp_flap_regexp, |
| 6740 | show_ip_bgp_flap_regexp_cmd, |
| 6741 | "show ip bgp flap-statistics regexp .LINE", |
| 6742 | SHOW_STR |
| 6743 | IP_STR |
| 6744 | BGP_STR |
| 6745 | "Display flap statistics of routes\n" |
| 6746 | "Display routes matching the AS path regular expression\n" |
| 6747 | "A regular-expression to match the BGP AS paths\n") |
| 6748 | { |
| 6749 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6750 | bgp_show_type_flap_regexp); |
| 6751 | } |
| 6752 | |
| 6753 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 6754 | show_ip_bgp_ipv4_regexp_cmd, |
| 6755 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 6756 | SHOW_STR |
| 6757 | IP_STR |
| 6758 | BGP_STR |
| 6759 | "Address family\n" |
| 6760 | "Address Family modifier\n" |
| 6761 | "Address Family modifier\n" |
| 6762 | "Display routes matching the AS path regular expression\n" |
| 6763 | "A regular-expression to match the BGP AS paths\n") |
| 6764 | { |
| 6765 | if (strncmp (argv[0], "m", 1) == 0) |
| 6766 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 6767 | bgp_show_type_regexp); |
| 6768 | |
| 6769 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6770 | bgp_show_type_regexp); |
| 6771 | } |
| 6772 | |
| 6773 | #ifdef HAVE_IPV6 |
| 6774 | DEFUN (show_bgp_regexp, |
| 6775 | show_bgp_regexp_cmd, |
| 6776 | "show bgp regexp .LINE", |
| 6777 | SHOW_STR |
| 6778 | BGP_STR |
| 6779 | "Display routes matching the AS path regular expression\n" |
| 6780 | "A regular-expression to match the BGP AS paths\n") |
| 6781 | { |
| 6782 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6783 | bgp_show_type_regexp); |
| 6784 | } |
| 6785 | |
| 6786 | ALIAS (show_bgp_regexp, |
| 6787 | show_bgp_ipv6_regexp_cmd, |
| 6788 | "show bgp ipv6 regexp .LINE", |
| 6789 | SHOW_STR |
| 6790 | BGP_STR |
| 6791 | "Address family\n" |
| 6792 | "Display routes matching the AS path regular expression\n" |
| 6793 | "A regular-expression to match the BGP AS paths\n") |
| 6794 | |
| 6795 | /* old command */ |
| 6796 | DEFUN (show_ipv6_bgp_regexp, |
| 6797 | show_ipv6_bgp_regexp_cmd, |
| 6798 | "show ipv6 bgp regexp .LINE", |
| 6799 | SHOW_STR |
| 6800 | IP_STR |
| 6801 | BGP_STR |
| 6802 | "Display routes matching the AS path regular expression\n" |
| 6803 | "A regular-expression to match the BGP AS paths\n") |
| 6804 | { |
| 6805 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6806 | bgp_show_type_regexp); |
| 6807 | } |
| 6808 | |
| 6809 | /* old command */ |
| 6810 | DEFUN (show_ipv6_mbgp_regexp, |
| 6811 | show_ipv6_mbgp_regexp_cmd, |
| 6812 | "show ipv6 mbgp regexp .LINE", |
| 6813 | SHOW_STR |
| 6814 | IP_STR |
| 6815 | BGP_STR |
| 6816 | "Display routes matching the AS path regular expression\n" |
| 6817 | "A regular-expression to match the MBGP AS paths\n") |
| 6818 | { |
| 6819 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 6820 | bgp_show_type_regexp); |
| 6821 | } |
| 6822 | #endif /* HAVE_IPV6 */ |
| 6823 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6824 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6825 | 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] | 6826 | safi_t safi, enum bgp_show_type type) |
| 6827 | { |
| 6828 | struct prefix_list *plist; |
| 6829 | |
| 6830 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 6831 | if (plist == NULL) |
| 6832 | { |
| 6833 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 6834 | prefix_list_str, VTY_NEWLINE); |
| 6835 | return CMD_WARNING; |
| 6836 | } |
| 6837 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6838 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6839 | } |
| 6840 | |
| 6841 | DEFUN (show_ip_bgp_prefix_list, |
| 6842 | show_ip_bgp_prefix_list_cmd, |
| 6843 | "show ip bgp prefix-list WORD", |
| 6844 | SHOW_STR |
| 6845 | IP_STR |
| 6846 | BGP_STR |
| 6847 | "Display routes conforming to the prefix-list\n" |
| 6848 | "IP prefix-list name\n") |
| 6849 | { |
| 6850 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6851 | bgp_show_type_prefix_list); |
| 6852 | } |
| 6853 | |
| 6854 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 6855 | show_ip_bgp_flap_prefix_list_cmd, |
| 6856 | "show ip bgp flap-statistics prefix-list WORD", |
| 6857 | SHOW_STR |
| 6858 | IP_STR |
| 6859 | BGP_STR |
| 6860 | "Display flap statistics of routes\n" |
| 6861 | "Display routes conforming to the prefix-list\n" |
| 6862 | "IP prefix-list name\n") |
| 6863 | { |
| 6864 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6865 | bgp_show_type_flap_prefix_list); |
| 6866 | } |
| 6867 | |
| 6868 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 6869 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 6870 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 6871 | SHOW_STR |
| 6872 | IP_STR |
| 6873 | BGP_STR |
| 6874 | "Address family\n" |
| 6875 | "Address Family modifier\n" |
| 6876 | "Address Family modifier\n" |
| 6877 | "Display routes conforming to the prefix-list\n" |
| 6878 | "IP prefix-list name\n") |
| 6879 | { |
| 6880 | if (strncmp (argv[0], "m", 1) == 0) |
| 6881 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6882 | bgp_show_type_prefix_list); |
| 6883 | |
| 6884 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6885 | bgp_show_type_prefix_list); |
| 6886 | } |
| 6887 | |
| 6888 | #ifdef HAVE_IPV6 |
| 6889 | DEFUN (show_bgp_prefix_list, |
| 6890 | show_bgp_prefix_list_cmd, |
| 6891 | "show bgp prefix-list WORD", |
| 6892 | SHOW_STR |
| 6893 | BGP_STR |
| 6894 | "Display routes conforming to the prefix-list\n" |
| 6895 | "IPv6 prefix-list name\n") |
| 6896 | { |
| 6897 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6898 | bgp_show_type_prefix_list); |
| 6899 | } |
| 6900 | |
| 6901 | ALIAS (show_bgp_prefix_list, |
| 6902 | show_bgp_ipv6_prefix_list_cmd, |
| 6903 | "show bgp ipv6 prefix-list WORD", |
| 6904 | SHOW_STR |
| 6905 | BGP_STR |
| 6906 | "Address family\n" |
| 6907 | "Display routes conforming to the prefix-list\n" |
| 6908 | "IPv6 prefix-list name\n") |
| 6909 | |
| 6910 | /* old command */ |
| 6911 | DEFUN (show_ipv6_bgp_prefix_list, |
| 6912 | show_ipv6_bgp_prefix_list_cmd, |
| 6913 | "show ipv6 bgp prefix-list WORD", |
| 6914 | SHOW_STR |
| 6915 | IPV6_STR |
| 6916 | BGP_STR |
| 6917 | "Display routes matching the prefix-list\n" |
| 6918 | "IPv6 prefix-list name\n") |
| 6919 | { |
| 6920 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6921 | bgp_show_type_prefix_list); |
| 6922 | } |
| 6923 | |
| 6924 | /* old command */ |
| 6925 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 6926 | show_ipv6_mbgp_prefix_list_cmd, |
| 6927 | "show ipv6 mbgp prefix-list WORD", |
| 6928 | SHOW_STR |
| 6929 | IPV6_STR |
| 6930 | MBGP_STR |
| 6931 | "Display routes matching the prefix-list\n" |
| 6932 | "IPv6 prefix-list name\n") |
| 6933 | { |
| 6934 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6935 | bgp_show_type_prefix_list); |
| 6936 | } |
| 6937 | #endif /* HAVE_IPV6 */ |
| 6938 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6939 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6940 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6941 | safi_t safi, enum bgp_show_type type) |
| 6942 | { |
| 6943 | struct as_list *as_list; |
| 6944 | |
| 6945 | as_list = as_list_lookup (filter); |
| 6946 | if (as_list == NULL) |
| 6947 | { |
| 6948 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 6949 | return CMD_WARNING; |
| 6950 | } |
| 6951 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6952 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6953 | } |
| 6954 | |
| 6955 | DEFUN (show_ip_bgp_filter_list, |
| 6956 | show_ip_bgp_filter_list_cmd, |
| 6957 | "show ip bgp filter-list WORD", |
| 6958 | SHOW_STR |
| 6959 | IP_STR |
| 6960 | BGP_STR |
| 6961 | "Display routes conforming to the filter-list\n" |
| 6962 | "Regular expression access list name\n") |
| 6963 | { |
| 6964 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6965 | bgp_show_type_filter_list); |
| 6966 | } |
| 6967 | |
| 6968 | DEFUN (show_ip_bgp_flap_filter_list, |
| 6969 | show_ip_bgp_flap_filter_list_cmd, |
| 6970 | "show ip bgp flap-statistics filter-list WORD", |
| 6971 | SHOW_STR |
| 6972 | IP_STR |
| 6973 | BGP_STR |
| 6974 | "Display flap statistics of routes\n" |
| 6975 | "Display routes conforming to the filter-list\n" |
| 6976 | "Regular expression access list name\n") |
| 6977 | { |
| 6978 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6979 | bgp_show_type_flap_filter_list); |
| 6980 | } |
| 6981 | |
| 6982 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 6983 | show_ip_bgp_ipv4_filter_list_cmd, |
| 6984 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 6985 | SHOW_STR |
| 6986 | IP_STR |
| 6987 | BGP_STR |
| 6988 | "Address family\n" |
| 6989 | "Address Family modifier\n" |
| 6990 | "Address Family modifier\n" |
| 6991 | "Display routes conforming to the filter-list\n" |
| 6992 | "Regular expression access list name\n") |
| 6993 | { |
| 6994 | if (strncmp (argv[0], "m", 1) == 0) |
| 6995 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6996 | bgp_show_type_filter_list); |
| 6997 | |
| 6998 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6999 | bgp_show_type_filter_list); |
| 7000 | } |
| 7001 | |
| 7002 | #ifdef HAVE_IPV6 |
| 7003 | DEFUN (show_bgp_filter_list, |
| 7004 | show_bgp_filter_list_cmd, |
| 7005 | "show bgp filter-list WORD", |
| 7006 | SHOW_STR |
| 7007 | BGP_STR |
| 7008 | "Display routes conforming to the filter-list\n" |
| 7009 | "Regular expression access list name\n") |
| 7010 | { |
| 7011 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7012 | bgp_show_type_filter_list); |
| 7013 | } |
| 7014 | |
| 7015 | ALIAS (show_bgp_filter_list, |
| 7016 | show_bgp_ipv6_filter_list_cmd, |
| 7017 | "show bgp ipv6 filter-list WORD", |
| 7018 | SHOW_STR |
| 7019 | BGP_STR |
| 7020 | "Address family\n" |
| 7021 | "Display routes conforming to the filter-list\n" |
| 7022 | "Regular expression access list name\n") |
| 7023 | |
| 7024 | /* old command */ |
| 7025 | DEFUN (show_ipv6_bgp_filter_list, |
| 7026 | show_ipv6_bgp_filter_list_cmd, |
| 7027 | "show ipv6 bgp filter-list WORD", |
| 7028 | SHOW_STR |
| 7029 | IPV6_STR |
| 7030 | BGP_STR |
| 7031 | "Display routes conforming to the filter-list\n" |
| 7032 | "Regular expression access list name\n") |
| 7033 | { |
| 7034 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7035 | bgp_show_type_filter_list); |
| 7036 | } |
| 7037 | |
| 7038 | /* old command */ |
| 7039 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7040 | show_ipv6_mbgp_filter_list_cmd, |
| 7041 | "show ipv6 mbgp filter-list WORD", |
| 7042 | SHOW_STR |
| 7043 | IPV6_STR |
| 7044 | MBGP_STR |
| 7045 | "Display routes conforming to the filter-list\n" |
| 7046 | "Regular expression access list name\n") |
| 7047 | { |
| 7048 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7049 | bgp_show_type_filter_list); |
| 7050 | } |
| 7051 | #endif /* HAVE_IPV6 */ |
| 7052 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7053 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7054 | 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] | 7055 | safi_t safi, enum bgp_show_type type) |
| 7056 | { |
| 7057 | struct route_map *rmap; |
| 7058 | |
| 7059 | rmap = route_map_lookup_by_name (rmap_str); |
| 7060 | if (! rmap) |
| 7061 | { |
| 7062 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7063 | rmap_str, VTY_NEWLINE); |
| 7064 | return CMD_WARNING; |
| 7065 | } |
| 7066 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7067 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7068 | } |
| 7069 | |
| 7070 | DEFUN (show_ip_bgp_route_map, |
| 7071 | show_ip_bgp_route_map_cmd, |
| 7072 | "show ip bgp route-map WORD", |
| 7073 | SHOW_STR |
| 7074 | IP_STR |
| 7075 | BGP_STR |
| 7076 | "Display routes matching the route-map\n" |
| 7077 | "A route-map to match on\n") |
| 7078 | { |
| 7079 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7080 | bgp_show_type_route_map); |
| 7081 | } |
| 7082 | |
| 7083 | DEFUN (show_ip_bgp_flap_route_map, |
| 7084 | show_ip_bgp_flap_route_map_cmd, |
| 7085 | "show ip bgp flap-statistics route-map WORD", |
| 7086 | SHOW_STR |
| 7087 | IP_STR |
| 7088 | BGP_STR |
| 7089 | "Display flap statistics of routes\n" |
| 7090 | "Display routes matching the route-map\n" |
| 7091 | "A route-map to match on\n") |
| 7092 | { |
| 7093 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7094 | bgp_show_type_flap_route_map); |
| 7095 | } |
| 7096 | |
| 7097 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7098 | show_ip_bgp_ipv4_route_map_cmd, |
| 7099 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7100 | SHOW_STR |
| 7101 | IP_STR |
| 7102 | BGP_STR |
| 7103 | "Address family\n" |
| 7104 | "Address Family modifier\n" |
| 7105 | "Address Family modifier\n" |
| 7106 | "Display routes matching the route-map\n" |
| 7107 | "A route-map to match on\n") |
| 7108 | { |
| 7109 | if (strncmp (argv[0], "m", 1) == 0) |
| 7110 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7111 | bgp_show_type_route_map); |
| 7112 | |
| 7113 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7114 | bgp_show_type_route_map); |
| 7115 | } |
| 7116 | |
| 7117 | DEFUN (show_bgp_route_map, |
| 7118 | show_bgp_route_map_cmd, |
| 7119 | "show bgp route-map WORD", |
| 7120 | SHOW_STR |
| 7121 | BGP_STR |
| 7122 | "Display routes matching the route-map\n" |
| 7123 | "A route-map to match on\n") |
| 7124 | { |
| 7125 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7126 | bgp_show_type_route_map); |
| 7127 | } |
| 7128 | |
| 7129 | ALIAS (show_bgp_route_map, |
| 7130 | show_bgp_ipv6_route_map_cmd, |
| 7131 | "show bgp ipv6 route-map WORD", |
| 7132 | SHOW_STR |
| 7133 | BGP_STR |
| 7134 | "Address family\n" |
| 7135 | "Display routes matching the route-map\n" |
| 7136 | "A route-map to match on\n") |
| 7137 | |
| 7138 | DEFUN (show_ip_bgp_cidr_only, |
| 7139 | show_ip_bgp_cidr_only_cmd, |
| 7140 | "show ip bgp cidr-only", |
| 7141 | SHOW_STR |
| 7142 | IP_STR |
| 7143 | BGP_STR |
| 7144 | "Display only routes with non-natural netmasks\n") |
| 7145 | { |
| 7146 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7147 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7148 | } |
| 7149 | |
| 7150 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7151 | show_ip_bgp_flap_cidr_only_cmd, |
| 7152 | "show ip bgp flap-statistics cidr-only", |
| 7153 | SHOW_STR |
| 7154 | IP_STR |
| 7155 | BGP_STR |
| 7156 | "Display flap statistics of routes\n" |
| 7157 | "Display only routes with non-natural netmasks\n") |
| 7158 | { |
| 7159 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7160 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7161 | } |
| 7162 | |
| 7163 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7164 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7165 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7166 | SHOW_STR |
| 7167 | IP_STR |
| 7168 | BGP_STR |
| 7169 | "Address family\n" |
| 7170 | "Address Family modifier\n" |
| 7171 | "Address Family modifier\n" |
| 7172 | "Display only routes with non-natural netmasks\n") |
| 7173 | { |
| 7174 | if (strncmp (argv[0], "m", 1) == 0) |
| 7175 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7176 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7177 | |
| 7178 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7179 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7180 | } |
| 7181 | |
| 7182 | DEFUN (show_ip_bgp_community_all, |
| 7183 | show_ip_bgp_community_all_cmd, |
| 7184 | "show ip bgp community", |
| 7185 | SHOW_STR |
| 7186 | IP_STR |
| 7187 | BGP_STR |
| 7188 | "Display routes matching the communities\n") |
| 7189 | { |
| 7190 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7191 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7192 | } |
| 7193 | |
| 7194 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7195 | show_ip_bgp_ipv4_community_all_cmd, |
| 7196 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7197 | SHOW_STR |
| 7198 | IP_STR |
| 7199 | BGP_STR |
| 7200 | "Address family\n" |
| 7201 | "Address Family modifier\n" |
| 7202 | "Address Family modifier\n" |
| 7203 | "Display routes matching the communities\n") |
| 7204 | { |
| 7205 | if (strncmp (argv[0], "m", 1) == 0) |
| 7206 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7207 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7208 | |
| 7209 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7210 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7211 | } |
| 7212 | |
| 7213 | #ifdef HAVE_IPV6 |
| 7214 | DEFUN (show_bgp_community_all, |
| 7215 | show_bgp_community_all_cmd, |
| 7216 | "show bgp community", |
| 7217 | SHOW_STR |
| 7218 | BGP_STR |
| 7219 | "Display routes matching the communities\n") |
| 7220 | { |
| 7221 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7222 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7223 | } |
| 7224 | |
| 7225 | ALIAS (show_bgp_community_all, |
| 7226 | show_bgp_ipv6_community_all_cmd, |
| 7227 | "show bgp ipv6 community", |
| 7228 | SHOW_STR |
| 7229 | BGP_STR |
| 7230 | "Address family\n" |
| 7231 | "Display routes matching the communities\n") |
| 7232 | |
| 7233 | /* old command */ |
| 7234 | DEFUN (show_ipv6_bgp_community_all, |
| 7235 | show_ipv6_bgp_community_all_cmd, |
| 7236 | "show ipv6 bgp community", |
| 7237 | SHOW_STR |
| 7238 | IPV6_STR |
| 7239 | BGP_STR |
| 7240 | "Display routes matching the communities\n") |
| 7241 | { |
| 7242 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7243 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7244 | } |
| 7245 | |
| 7246 | /* old command */ |
| 7247 | DEFUN (show_ipv6_mbgp_community_all, |
| 7248 | show_ipv6_mbgp_community_all_cmd, |
| 7249 | "show ipv6 mbgp community", |
| 7250 | SHOW_STR |
| 7251 | IPV6_STR |
| 7252 | MBGP_STR |
| 7253 | "Display routes matching the communities\n") |
| 7254 | { |
| 7255 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7256 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7257 | } |
| 7258 | #endif /* HAVE_IPV6 */ |
| 7259 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7260 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7261 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
| 7262 | u_int16_t afi, u_char safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7263 | { |
| 7264 | struct community *com; |
| 7265 | struct buffer *b; |
| 7266 | int i; |
| 7267 | char *str; |
| 7268 | int first = 0; |
| 7269 | |
| 7270 | b = buffer_new (1024); |
| 7271 | for (i = 0; i < argc; i++) |
| 7272 | { |
| 7273 | if (first) |
| 7274 | buffer_putc (b, ' '); |
| 7275 | else |
| 7276 | { |
| 7277 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7278 | continue; |
| 7279 | first = 1; |
| 7280 | } |
| 7281 | |
| 7282 | buffer_putstr (b, argv[i]); |
| 7283 | } |
| 7284 | buffer_putc (b, '\0'); |
| 7285 | |
| 7286 | str = buffer_getstr (b); |
| 7287 | buffer_free (b); |
| 7288 | |
| 7289 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7290 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7291 | if (! com) |
| 7292 | { |
| 7293 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7294 | return CMD_WARNING; |
| 7295 | } |
| 7296 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7297 | return bgp_show (vty, NULL, afi, safi, |
| 7298 | (exact ? bgp_show_type_community_exact : |
| 7299 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7300 | } |
| 7301 | |
| 7302 | DEFUN (show_ip_bgp_community, |
| 7303 | show_ip_bgp_community_cmd, |
| 7304 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7305 | SHOW_STR |
| 7306 | IP_STR |
| 7307 | BGP_STR |
| 7308 | "Display routes matching the communities\n" |
| 7309 | "community number\n" |
| 7310 | "Do not send outside local AS (well-known community)\n" |
| 7311 | "Do not advertise to any peer (well-known community)\n" |
| 7312 | "Do not export to next AS (well-known community)\n") |
| 7313 | { |
| 7314 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 7315 | } |
| 7316 | |
| 7317 | ALIAS (show_ip_bgp_community, |
| 7318 | show_ip_bgp_community2_cmd, |
| 7319 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7320 | SHOW_STR |
| 7321 | IP_STR |
| 7322 | BGP_STR |
| 7323 | "Display routes matching the communities\n" |
| 7324 | "community number\n" |
| 7325 | "Do not send outside local AS (well-known community)\n" |
| 7326 | "Do not advertise to any peer (well-known community)\n" |
| 7327 | "Do not export to next AS (well-known community)\n" |
| 7328 | "community number\n" |
| 7329 | "Do not send outside local AS (well-known community)\n" |
| 7330 | "Do not advertise to any peer (well-known community)\n" |
| 7331 | "Do not export to next AS (well-known community)\n") |
| 7332 | |
| 7333 | ALIAS (show_ip_bgp_community, |
| 7334 | show_ip_bgp_community3_cmd, |
| 7335 | "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)", |
| 7336 | SHOW_STR |
| 7337 | IP_STR |
| 7338 | BGP_STR |
| 7339 | "Display routes matching the communities\n" |
| 7340 | "community number\n" |
| 7341 | "Do not send outside local AS (well-known community)\n" |
| 7342 | "Do not advertise to any peer (well-known community)\n" |
| 7343 | "Do not export to next AS (well-known community)\n" |
| 7344 | "community number\n" |
| 7345 | "Do not send outside local AS (well-known community)\n" |
| 7346 | "Do not advertise to any peer (well-known community)\n" |
| 7347 | "Do not export to next AS (well-known community)\n" |
| 7348 | "community number\n" |
| 7349 | "Do not send outside local AS (well-known community)\n" |
| 7350 | "Do not advertise to any peer (well-known community)\n" |
| 7351 | "Do not export to next AS (well-known community)\n") |
| 7352 | |
| 7353 | ALIAS (show_ip_bgp_community, |
| 7354 | show_ip_bgp_community4_cmd, |
| 7355 | "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)", |
| 7356 | SHOW_STR |
| 7357 | IP_STR |
| 7358 | BGP_STR |
| 7359 | "Display routes matching the communities\n" |
| 7360 | "community number\n" |
| 7361 | "Do not send outside local AS (well-known community)\n" |
| 7362 | "Do not advertise to any peer (well-known community)\n" |
| 7363 | "Do not export to next AS (well-known community)\n" |
| 7364 | "community number\n" |
| 7365 | "Do not send outside local AS (well-known community)\n" |
| 7366 | "Do not advertise to any peer (well-known community)\n" |
| 7367 | "Do not export to next AS (well-known community)\n" |
| 7368 | "community number\n" |
| 7369 | "Do not send outside local AS (well-known community)\n" |
| 7370 | "Do not advertise to any peer (well-known community)\n" |
| 7371 | "Do not export to next AS (well-known community)\n" |
| 7372 | "community number\n" |
| 7373 | "Do not send outside local AS (well-known community)\n" |
| 7374 | "Do not advertise to any peer (well-known community)\n" |
| 7375 | "Do not export to next AS (well-known community)\n") |
| 7376 | |
| 7377 | DEFUN (show_ip_bgp_ipv4_community, |
| 7378 | show_ip_bgp_ipv4_community_cmd, |
| 7379 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7380 | SHOW_STR |
| 7381 | IP_STR |
| 7382 | BGP_STR |
| 7383 | "Address family\n" |
| 7384 | "Address Family modifier\n" |
| 7385 | "Address Family modifier\n" |
| 7386 | "Display routes matching the communities\n" |
| 7387 | "community number\n" |
| 7388 | "Do not send outside local AS (well-known community)\n" |
| 7389 | "Do not advertise to any peer (well-known community)\n" |
| 7390 | "Do not export to next AS (well-known community)\n") |
| 7391 | { |
| 7392 | if (strncmp (argv[0], "m", 1) == 0) |
| 7393 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 7394 | |
| 7395 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 7396 | } |
| 7397 | |
| 7398 | ALIAS (show_ip_bgp_ipv4_community, |
| 7399 | show_ip_bgp_ipv4_community2_cmd, |
| 7400 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7401 | SHOW_STR |
| 7402 | IP_STR |
| 7403 | BGP_STR |
| 7404 | "Address family\n" |
| 7405 | "Address Family modifier\n" |
| 7406 | "Address Family modifier\n" |
| 7407 | "Display routes matching the communities\n" |
| 7408 | "community number\n" |
| 7409 | "Do not send outside local AS (well-known community)\n" |
| 7410 | "Do not advertise to any peer (well-known community)\n" |
| 7411 | "Do not export to next AS (well-known community)\n" |
| 7412 | "community number\n" |
| 7413 | "Do not send outside local AS (well-known community)\n" |
| 7414 | "Do not advertise to any peer (well-known community)\n" |
| 7415 | "Do not export to next AS (well-known community)\n") |
| 7416 | |
| 7417 | ALIAS (show_ip_bgp_ipv4_community, |
| 7418 | show_ip_bgp_ipv4_community3_cmd, |
| 7419 | "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)", |
| 7420 | SHOW_STR |
| 7421 | IP_STR |
| 7422 | BGP_STR |
| 7423 | "Address family\n" |
| 7424 | "Address Family modifier\n" |
| 7425 | "Address Family modifier\n" |
| 7426 | "Display routes matching the communities\n" |
| 7427 | "community number\n" |
| 7428 | "Do not send outside local AS (well-known community)\n" |
| 7429 | "Do not advertise to any peer (well-known community)\n" |
| 7430 | "Do not export to next AS (well-known community)\n" |
| 7431 | "community number\n" |
| 7432 | "Do not send outside local AS (well-known community)\n" |
| 7433 | "Do not advertise to any peer (well-known community)\n" |
| 7434 | "Do not export to next AS (well-known community)\n" |
| 7435 | "community number\n" |
| 7436 | "Do not send outside local AS (well-known community)\n" |
| 7437 | "Do not advertise to any peer (well-known community)\n" |
| 7438 | "Do not export to next AS (well-known community)\n") |
| 7439 | |
| 7440 | ALIAS (show_ip_bgp_ipv4_community, |
| 7441 | show_ip_bgp_ipv4_community4_cmd, |
| 7442 | "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)", |
| 7443 | SHOW_STR |
| 7444 | IP_STR |
| 7445 | BGP_STR |
| 7446 | "Address family\n" |
| 7447 | "Address Family modifier\n" |
| 7448 | "Address Family modifier\n" |
| 7449 | "Display routes matching the communities\n" |
| 7450 | "community number\n" |
| 7451 | "Do not send outside local AS (well-known community)\n" |
| 7452 | "Do not advertise to any peer (well-known community)\n" |
| 7453 | "Do not export to next AS (well-known community)\n" |
| 7454 | "community number\n" |
| 7455 | "Do not send outside local AS (well-known community)\n" |
| 7456 | "Do not advertise to any peer (well-known community)\n" |
| 7457 | "Do not export to next AS (well-known community)\n" |
| 7458 | "community number\n" |
| 7459 | "Do not send outside local AS (well-known community)\n" |
| 7460 | "Do not advertise to any peer (well-known community)\n" |
| 7461 | "Do not export to next AS (well-known community)\n" |
| 7462 | "community number\n" |
| 7463 | "Do not send outside local AS (well-known community)\n" |
| 7464 | "Do not advertise to any peer (well-known community)\n" |
| 7465 | "Do not export to next AS (well-known community)\n") |
| 7466 | |
| 7467 | DEFUN (show_ip_bgp_community_exact, |
| 7468 | show_ip_bgp_community_exact_cmd, |
| 7469 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7470 | SHOW_STR |
| 7471 | IP_STR |
| 7472 | BGP_STR |
| 7473 | "Display routes matching the communities\n" |
| 7474 | "community number\n" |
| 7475 | "Do not send outside local AS (well-known community)\n" |
| 7476 | "Do not advertise to any peer (well-known community)\n" |
| 7477 | "Do not export to next AS (well-known community)\n" |
| 7478 | "Exact match of the communities") |
| 7479 | { |
| 7480 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7481 | } |
| 7482 | |
| 7483 | ALIAS (show_ip_bgp_community_exact, |
| 7484 | show_ip_bgp_community2_exact_cmd, |
| 7485 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7486 | SHOW_STR |
| 7487 | IP_STR |
| 7488 | BGP_STR |
| 7489 | "Display routes matching the communities\n" |
| 7490 | "community number\n" |
| 7491 | "Do not send outside local AS (well-known community)\n" |
| 7492 | "Do not advertise to any peer (well-known community)\n" |
| 7493 | "Do not export to next AS (well-known community)\n" |
| 7494 | "community number\n" |
| 7495 | "Do not send outside local AS (well-known community)\n" |
| 7496 | "Do not advertise to any peer (well-known community)\n" |
| 7497 | "Do not export to next AS (well-known community)\n" |
| 7498 | "Exact match of the communities") |
| 7499 | |
| 7500 | ALIAS (show_ip_bgp_community_exact, |
| 7501 | show_ip_bgp_community3_exact_cmd, |
| 7502 | "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", |
| 7503 | SHOW_STR |
| 7504 | IP_STR |
| 7505 | BGP_STR |
| 7506 | "Display routes matching the communities\n" |
| 7507 | "community number\n" |
| 7508 | "Do not send outside local AS (well-known community)\n" |
| 7509 | "Do not advertise to any peer (well-known community)\n" |
| 7510 | "Do not export to next AS (well-known community)\n" |
| 7511 | "community number\n" |
| 7512 | "Do not send outside local AS (well-known community)\n" |
| 7513 | "Do not advertise to any peer (well-known community)\n" |
| 7514 | "Do not export to next AS (well-known community)\n" |
| 7515 | "community number\n" |
| 7516 | "Do not send outside local AS (well-known community)\n" |
| 7517 | "Do not advertise to any peer (well-known community)\n" |
| 7518 | "Do not export to next AS (well-known community)\n" |
| 7519 | "Exact match of the communities") |
| 7520 | |
| 7521 | ALIAS (show_ip_bgp_community_exact, |
| 7522 | show_ip_bgp_community4_exact_cmd, |
| 7523 | "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", |
| 7524 | SHOW_STR |
| 7525 | IP_STR |
| 7526 | BGP_STR |
| 7527 | "Display routes matching the communities\n" |
| 7528 | "community number\n" |
| 7529 | "Do not send outside local AS (well-known community)\n" |
| 7530 | "Do not advertise to any peer (well-known community)\n" |
| 7531 | "Do not export to next AS (well-known community)\n" |
| 7532 | "community number\n" |
| 7533 | "Do not send outside local AS (well-known community)\n" |
| 7534 | "Do not advertise to any peer (well-known community)\n" |
| 7535 | "Do not export to next AS (well-known community)\n" |
| 7536 | "community number\n" |
| 7537 | "Do not send outside local AS (well-known community)\n" |
| 7538 | "Do not advertise to any peer (well-known community)\n" |
| 7539 | "Do not export to next AS (well-known community)\n" |
| 7540 | "community number\n" |
| 7541 | "Do not send outside local AS (well-known community)\n" |
| 7542 | "Do not advertise to any peer (well-known community)\n" |
| 7543 | "Do not export to next AS (well-known community)\n" |
| 7544 | "Exact match of the communities") |
| 7545 | |
| 7546 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 7547 | show_ip_bgp_ipv4_community_exact_cmd, |
| 7548 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7549 | SHOW_STR |
| 7550 | IP_STR |
| 7551 | BGP_STR |
| 7552 | "Address family\n" |
| 7553 | "Address Family modifier\n" |
| 7554 | "Address Family modifier\n" |
| 7555 | "Display routes matching the communities\n" |
| 7556 | "community number\n" |
| 7557 | "Do not send outside local AS (well-known community)\n" |
| 7558 | "Do not advertise to any peer (well-known community)\n" |
| 7559 | "Do not export to next AS (well-known community)\n" |
| 7560 | "Exact match of the communities") |
| 7561 | { |
| 7562 | if (strncmp (argv[0], "m", 1) == 0) |
| 7563 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 7564 | |
| 7565 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7566 | } |
| 7567 | |
| 7568 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7569 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 7570 | "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", |
| 7571 | SHOW_STR |
| 7572 | IP_STR |
| 7573 | BGP_STR |
| 7574 | "Address family\n" |
| 7575 | "Address Family modifier\n" |
| 7576 | "Address Family modifier\n" |
| 7577 | "Display routes matching the communities\n" |
| 7578 | "community number\n" |
| 7579 | "Do not send outside local AS (well-known community)\n" |
| 7580 | "Do not advertise to any peer (well-known community)\n" |
| 7581 | "Do not export to next AS (well-known community)\n" |
| 7582 | "community number\n" |
| 7583 | "Do not send outside local AS (well-known community)\n" |
| 7584 | "Do not advertise to any peer (well-known community)\n" |
| 7585 | "Do not export to next AS (well-known community)\n" |
| 7586 | "Exact match of the communities") |
| 7587 | |
| 7588 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7589 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 7590 | "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", |
| 7591 | SHOW_STR |
| 7592 | IP_STR |
| 7593 | BGP_STR |
| 7594 | "Address family\n" |
| 7595 | "Address Family modifier\n" |
| 7596 | "Address Family modifier\n" |
| 7597 | "Display routes matching the communities\n" |
| 7598 | "community number\n" |
| 7599 | "Do not send outside local AS (well-known community)\n" |
| 7600 | "Do not advertise to any peer (well-known community)\n" |
| 7601 | "Do not export to next AS (well-known community)\n" |
| 7602 | "community number\n" |
| 7603 | "Do not send outside local AS (well-known community)\n" |
| 7604 | "Do not advertise to any peer (well-known community)\n" |
| 7605 | "Do not export to next AS (well-known community)\n" |
| 7606 | "community number\n" |
| 7607 | "Do not send outside local AS (well-known community)\n" |
| 7608 | "Do not advertise to any peer (well-known community)\n" |
| 7609 | "Do not export to next AS (well-known community)\n" |
| 7610 | "Exact match of the communities") |
| 7611 | |
| 7612 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7613 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 7614 | "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", |
| 7615 | SHOW_STR |
| 7616 | IP_STR |
| 7617 | BGP_STR |
| 7618 | "Address family\n" |
| 7619 | "Address Family modifier\n" |
| 7620 | "Address Family modifier\n" |
| 7621 | "Display routes matching the communities\n" |
| 7622 | "community number\n" |
| 7623 | "Do not send outside local AS (well-known community)\n" |
| 7624 | "Do not advertise to any peer (well-known community)\n" |
| 7625 | "Do not export to next AS (well-known community)\n" |
| 7626 | "community number\n" |
| 7627 | "Do not send outside local AS (well-known community)\n" |
| 7628 | "Do not advertise to any peer (well-known community)\n" |
| 7629 | "Do not export to next AS (well-known community)\n" |
| 7630 | "community number\n" |
| 7631 | "Do not send outside local AS (well-known community)\n" |
| 7632 | "Do not advertise to any peer (well-known community)\n" |
| 7633 | "Do not export to next AS (well-known community)\n" |
| 7634 | "community number\n" |
| 7635 | "Do not send outside local AS (well-known community)\n" |
| 7636 | "Do not advertise to any peer (well-known community)\n" |
| 7637 | "Do not export to next AS (well-known community)\n" |
| 7638 | "Exact match of the communities") |
| 7639 | |
| 7640 | #ifdef HAVE_IPV6 |
| 7641 | DEFUN (show_bgp_community, |
| 7642 | show_bgp_community_cmd, |
| 7643 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7644 | SHOW_STR |
| 7645 | BGP_STR |
| 7646 | "Display routes matching the communities\n" |
| 7647 | "community number\n" |
| 7648 | "Do not send outside local AS (well-known community)\n" |
| 7649 | "Do not advertise to any peer (well-known community)\n" |
| 7650 | "Do not export to next AS (well-known community)\n") |
| 7651 | { |
| 7652 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7653 | } |
| 7654 | |
| 7655 | ALIAS (show_bgp_community, |
| 7656 | show_bgp_ipv6_community_cmd, |
| 7657 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 7658 | SHOW_STR |
| 7659 | BGP_STR |
| 7660 | "Address family\n" |
| 7661 | "Display routes matching the communities\n" |
| 7662 | "community number\n" |
| 7663 | "Do not send outside local AS (well-known community)\n" |
| 7664 | "Do not advertise to any peer (well-known community)\n" |
| 7665 | "Do not export to next AS (well-known community)\n") |
| 7666 | |
| 7667 | ALIAS (show_bgp_community, |
| 7668 | show_bgp_community2_cmd, |
| 7669 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7670 | SHOW_STR |
| 7671 | BGP_STR |
| 7672 | "Display routes matching the communities\n" |
| 7673 | "community number\n" |
| 7674 | "Do not send outside local AS (well-known community)\n" |
| 7675 | "Do not advertise to any peer (well-known community)\n" |
| 7676 | "Do not export to next AS (well-known community)\n" |
| 7677 | "community number\n" |
| 7678 | "Do not send outside local AS (well-known community)\n" |
| 7679 | "Do not advertise to any peer (well-known community)\n" |
| 7680 | "Do not export to next AS (well-known community)\n") |
| 7681 | |
| 7682 | ALIAS (show_bgp_community, |
| 7683 | show_bgp_ipv6_community2_cmd, |
| 7684 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7685 | SHOW_STR |
| 7686 | BGP_STR |
| 7687 | "Address family\n" |
| 7688 | "Display routes matching the communities\n" |
| 7689 | "community number\n" |
| 7690 | "Do not send outside local AS (well-known community)\n" |
| 7691 | "Do not advertise to any peer (well-known community)\n" |
| 7692 | "Do not export to next AS (well-known community)\n" |
| 7693 | "community number\n" |
| 7694 | "Do not send outside local AS (well-known community)\n" |
| 7695 | "Do not advertise to any peer (well-known community)\n" |
| 7696 | "Do not export to next AS (well-known community)\n") |
| 7697 | |
| 7698 | ALIAS (show_bgp_community, |
| 7699 | show_bgp_community3_cmd, |
| 7700 | "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)", |
| 7701 | SHOW_STR |
| 7702 | BGP_STR |
| 7703 | "Display routes matching the communities\n" |
| 7704 | "community number\n" |
| 7705 | "Do not send outside local AS (well-known community)\n" |
| 7706 | "Do not advertise to any peer (well-known community)\n" |
| 7707 | "Do not export to next AS (well-known community)\n" |
| 7708 | "community number\n" |
| 7709 | "Do not send outside local AS (well-known community)\n" |
| 7710 | "Do not advertise to any peer (well-known community)\n" |
| 7711 | "Do not export to next AS (well-known community)\n" |
| 7712 | "community number\n" |
| 7713 | "Do not send outside local AS (well-known community)\n" |
| 7714 | "Do not advertise to any peer (well-known community)\n" |
| 7715 | "Do not export to next AS (well-known community)\n") |
| 7716 | |
| 7717 | ALIAS (show_bgp_community, |
| 7718 | show_bgp_ipv6_community3_cmd, |
| 7719 | "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)", |
| 7720 | SHOW_STR |
| 7721 | BGP_STR |
| 7722 | "Address family\n" |
| 7723 | "Display routes matching the communities\n" |
| 7724 | "community number\n" |
| 7725 | "Do not send outside local AS (well-known community)\n" |
| 7726 | "Do not advertise to any peer (well-known community)\n" |
| 7727 | "Do not export to next AS (well-known community)\n" |
| 7728 | "community number\n" |
| 7729 | "Do not send outside local AS (well-known community)\n" |
| 7730 | "Do not advertise to any peer (well-known community)\n" |
| 7731 | "Do not export to next AS (well-known community)\n" |
| 7732 | "community number\n" |
| 7733 | "Do not send outside local AS (well-known community)\n" |
| 7734 | "Do not advertise to any peer (well-known community)\n" |
| 7735 | "Do not export to next AS (well-known community)\n") |
| 7736 | |
| 7737 | ALIAS (show_bgp_community, |
| 7738 | show_bgp_community4_cmd, |
| 7739 | "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)", |
| 7740 | SHOW_STR |
| 7741 | BGP_STR |
| 7742 | "Display routes matching the communities\n" |
| 7743 | "community number\n" |
| 7744 | "Do not send outside local AS (well-known community)\n" |
| 7745 | "Do not advertise to any peer (well-known community)\n" |
| 7746 | "Do not export to next AS (well-known community)\n" |
| 7747 | "community number\n" |
| 7748 | "Do not send outside local AS (well-known community)\n" |
| 7749 | "Do not advertise to any peer (well-known community)\n" |
| 7750 | "Do not export to next AS (well-known community)\n" |
| 7751 | "community number\n" |
| 7752 | "Do not send outside local AS (well-known community)\n" |
| 7753 | "Do not advertise to any peer (well-known community)\n" |
| 7754 | "Do not export to next AS (well-known community)\n" |
| 7755 | "community number\n" |
| 7756 | "Do not send outside local AS (well-known community)\n" |
| 7757 | "Do not advertise to any peer (well-known community)\n" |
| 7758 | "Do not export to next AS (well-known community)\n") |
| 7759 | |
| 7760 | ALIAS (show_bgp_community, |
| 7761 | show_bgp_ipv6_community4_cmd, |
| 7762 | "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)", |
| 7763 | SHOW_STR |
| 7764 | BGP_STR |
| 7765 | "Address family\n" |
| 7766 | "Display routes matching the communities\n" |
| 7767 | "community number\n" |
| 7768 | "Do not send outside local AS (well-known community)\n" |
| 7769 | "Do not advertise to any peer (well-known community)\n" |
| 7770 | "Do not export to next AS (well-known community)\n" |
| 7771 | "community number\n" |
| 7772 | "Do not send outside local AS (well-known community)\n" |
| 7773 | "Do not advertise to any peer (well-known community)\n" |
| 7774 | "Do not export to next AS (well-known community)\n" |
| 7775 | "community number\n" |
| 7776 | "Do not send outside local AS (well-known community)\n" |
| 7777 | "Do not advertise to any peer (well-known community)\n" |
| 7778 | "Do not export to next AS (well-known community)\n" |
| 7779 | "community number\n" |
| 7780 | "Do not send outside local AS (well-known community)\n" |
| 7781 | "Do not advertise to any peer (well-known community)\n" |
| 7782 | "Do not export to next AS (well-known community)\n") |
| 7783 | |
| 7784 | /* old command */ |
| 7785 | DEFUN (show_ipv6_bgp_community, |
| 7786 | show_ipv6_bgp_community_cmd, |
| 7787 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7788 | SHOW_STR |
| 7789 | IPV6_STR |
| 7790 | BGP_STR |
| 7791 | "Display routes matching the communities\n" |
| 7792 | "community number\n" |
| 7793 | "Do not send outside local AS (well-known community)\n" |
| 7794 | "Do not advertise to any peer (well-known community)\n" |
| 7795 | "Do not export to next AS (well-known community)\n") |
| 7796 | { |
| 7797 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7798 | } |
| 7799 | |
| 7800 | /* old command */ |
| 7801 | ALIAS (show_ipv6_bgp_community, |
| 7802 | show_ipv6_bgp_community2_cmd, |
| 7803 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7804 | SHOW_STR |
| 7805 | IPV6_STR |
| 7806 | BGP_STR |
| 7807 | "Display routes matching the communities\n" |
| 7808 | "community number\n" |
| 7809 | "Do not send outside local AS (well-known community)\n" |
| 7810 | "Do not advertise to any peer (well-known community)\n" |
| 7811 | "Do not export to next AS (well-known community)\n" |
| 7812 | "community number\n" |
| 7813 | "Do not send outside local AS (well-known community)\n" |
| 7814 | "Do not advertise to any peer (well-known community)\n" |
| 7815 | "Do not export to next AS (well-known community)\n") |
| 7816 | |
| 7817 | /* old command */ |
| 7818 | ALIAS (show_ipv6_bgp_community, |
| 7819 | show_ipv6_bgp_community3_cmd, |
| 7820 | "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)", |
| 7821 | SHOW_STR |
| 7822 | IPV6_STR |
| 7823 | BGP_STR |
| 7824 | "Display routes matching the communities\n" |
| 7825 | "community number\n" |
| 7826 | "Do not send outside local AS (well-known community)\n" |
| 7827 | "Do not advertise to any peer (well-known community)\n" |
| 7828 | "Do not export to next AS (well-known community)\n" |
| 7829 | "community number\n" |
| 7830 | "Do not send outside local AS (well-known community)\n" |
| 7831 | "Do not advertise to any peer (well-known community)\n" |
| 7832 | "Do not export to next AS (well-known community)\n" |
| 7833 | "community number\n" |
| 7834 | "Do not send outside local AS (well-known community)\n" |
| 7835 | "Do not advertise to any peer (well-known community)\n" |
| 7836 | "Do not export to next AS (well-known community)\n") |
| 7837 | |
| 7838 | /* old command */ |
| 7839 | ALIAS (show_ipv6_bgp_community, |
| 7840 | show_ipv6_bgp_community4_cmd, |
| 7841 | "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)", |
| 7842 | SHOW_STR |
| 7843 | IPV6_STR |
| 7844 | BGP_STR |
| 7845 | "Display routes matching the communities\n" |
| 7846 | "community number\n" |
| 7847 | "Do not send outside local AS (well-known community)\n" |
| 7848 | "Do not advertise to any peer (well-known community)\n" |
| 7849 | "Do not export to next AS (well-known community)\n" |
| 7850 | "community number\n" |
| 7851 | "Do not send outside local AS (well-known community)\n" |
| 7852 | "Do not advertise to any peer (well-known community)\n" |
| 7853 | "Do not export to next AS (well-known community)\n" |
| 7854 | "community number\n" |
| 7855 | "Do not send outside local AS (well-known community)\n" |
| 7856 | "Do not advertise to any peer (well-known community)\n" |
| 7857 | "Do not export to next AS (well-known community)\n" |
| 7858 | "community number\n" |
| 7859 | "Do not send outside local AS (well-known community)\n" |
| 7860 | "Do not advertise to any peer (well-known community)\n" |
| 7861 | "Do not export to next AS (well-known community)\n") |
| 7862 | |
| 7863 | DEFUN (show_bgp_community_exact, |
| 7864 | show_bgp_community_exact_cmd, |
| 7865 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7866 | SHOW_STR |
| 7867 | BGP_STR |
| 7868 | "Display routes matching the communities\n" |
| 7869 | "community number\n" |
| 7870 | "Do not send outside local AS (well-known community)\n" |
| 7871 | "Do not advertise to any peer (well-known community)\n" |
| 7872 | "Do not export to next AS (well-known community)\n" |
| 7873 | "Exact match of the communities") |
| 7874 | { |
| 7875 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7876 | } |
| 7877 | |
| 7878 | ALIAS (show_bgp_community_exact, |
| 7879 | show_bgp_ipv6_community_exact_cmd, |
| 7880 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7881 | SHOW_STR |
| 7882 | BGP_STR |
| 7883 | "Address family\n" |
| 7884 | "Display routes matching the communities\n" |
| 7885 | "community number\n" |
| 7886 | "Do not send outside local AS (well-known community)\n" |
| 7887 | "Do not advertise to any peer (well-known community)\n" |
| 7888 | "Do not export to next AS (well-known community)\n" |
| 7889 | "Exact match of the communities") |
| 7890 | |
| 7891 | ALIAS (show_bgp_community_exact, |
| 7892 | show_bgp_community2_exact_cmd, |
| 7893 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7894 | SHOW_STR |
| 7895 | BGP_STR |
| 7896 | "Display routes matching the communities\n" |
| 7897 | "community number\n" |
| 7898 | "Do not send outside local AS (well-known community)\n" |
| 7899 | "Do not advertise to any peer (well-known community)\n" |
| 7900 | "Do not export to next AS (well-known community)\n" |
| 7901 | "community number\n" |
| 7902 | "Do not send outside local AS (well-known community)\n" |
| 7903 | "Do not advertise to any peer (well-known community)\n" |
| 7904 | "Do not export to next AS (well-known community)\n" |
| 7905 | "Exact match of the communities") |
| 7906 | |
| 7907 | ALIAS (show_bgp_community_exact, |
| 7908 | show_bgp_ipv6_community2_exact_cmd, |
| 7909 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7910 | SHOW_STR |
| 7911 | BGP_STR |
| 7912 | "Address family\n" |
| 7913 | "Display routes matching the communities\n" |
| 7914 | "community number\n" |
| 7915 | "Do not send outside local AS (well-known community)\n" |
| 7916 | "Do not advertise to any peer (well-known community)\n" |
| 7917 | "Do not export to next AS (well-known community)\n" |
| 7918 | "community number\n" |
| 7919 | "Do not send outside local AS (well-known community)\n" |
| 7920 | "Do not advertise to any peer (well-known community)\n" |
| 7921 | "Do not export to next AS (well-known community)\n" |
| 7922 | "Exact match of the communities") |
| 7923 | |
| 7924 | ALIAS (show_bgp_community_exact, |
| 7925 | show_bgp_community3_exact_cmd, |
| 7926 | "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", |
| 7927 | SHOW_STR |
| 7928 | BGP_STR |
| 7929 | "Display routes matching the communities\n" |
| 7930 | "community number\n" |
| 7931 | "Do not send outside local AS (well-known community)\n" |
| 7932 | "Do not advertise to any peer (well-known community)\n" |
| 7933 | "Do not export to next AS (well-known community)\n" |
| 7934 | "community number\n" |
| 7935 | "Do not send outside local AS (well-known community)\n" |
| 7936 | "Do not advertise to any peer (well-known community)\n" |
| 7937 | "Do not export to next AS (well-known community)\n" |
| 7938 | "community number\n" |
| 7939 | "Do not send outside local AS (well-known community)\n" |
| 7940 | "Do not advertise to any peer (well-known community)\n" |
| 7941 | "Do not export to next AS (well-known community)\n" |
| 7942 | "Exact match of the communities") |
| 7943 | |
| 7944 | ALIAS (show_bgp_community_exact, |
| 7945 | show_bgp_ipv6_community3_exact_cmd, |
| 7946 | "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", |
| 7947 | SHOW_STR |
| 7948 | BGP_STR |
| 7949 | "Address family\n" |
| 7950 | "Display routes matching the communities\n" |
| 7951 | "community number\n" |
| 7952 | "Do not send outside local AS (well-known community)\n" |
| 7953 | "Do not advertise to any peer (well-known community)\n" |
| 7954 | "Do not export to next AS (well-known community)\n" |
| 7955 | "community number\n" |
| 7956 | "Do not send outside local AS (well-known community)\n" |
| 7957 | "Do not advertise to any peer (well-known community)\n" |
| 7958 | "Do not export to next AS (well-known community)\n" |
| 7959 | "community number\n" |
| 7960 | "Do not send outside local AS (well-known community)\n" |
| 7961 | "Do not advertise to any peer (well-known community)\n" |
| 7962 | "Do not export to next AS (well-known community)\n" |
| 7963 | "Exact match of the communities") |
| 7964 | |
| 7965 | ALIAS (show_bgp_community_exact, |
| 7966 | show_bgp_community4_exact_cmd, |
| 7967 | "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", |
| 7968 | SHOW_STR |
| 7969 | BGP_STR |
| 7970 | "Display routes matching the communities\n" |
| 7971 | "community number\n" |
| 7972 | "Do not send outside local AS (well-known community)\n" |
| 7973 | "Do not advertise to any peer (well-known community)\n" |
| 7974 | "Do not export to next AS (well-known community)\n" |
| 7975 | "community number\n" |
| 7976 | "Do not send outside local AS (well-known community)\n" |
| 7977 | "Do not advertise to any peer (well-known community)\n" |
| 7978 | "Do not export to next AS (well-known community)\n" |
| 7979 | "community number\n" |
| 7980 | "Do not send outside local AS (well-known community)\n" |
| 7981 | "Do not advertise to any peer (well-known community)\n" |
| 7982 | "Do not export to next AS (well-known community)\n" |
| 7983 | "community number\n" |
| 7984 | "Do not send outside local AS (well-known community)\n" |
| 7985 | "Do not advertise to any peer (well-known community)\n" |
| 7986 | "Do not export to next AS (well-known community)\n" |
| 7987 | "Exact match of the communities") |
| 7988 | |
| 7989 | ALIAS (show_bgp_community_exact, |
| 7990 | show_bgp_ipv6_community4_exact_cmd, |
| 7991 | "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", |
| 7992 | SHOW_STR |
| 7993 | BGP_STR |
| 7994 | "Address family\n" |
| 7995 | "Display routes matching the communities\n" |
| 7996 | "community number\n" |
| 7997 | "Do not send outside local AS (well-known community)\n" |
| 7998 | "Do not advertise to any peer (well-known community)\n" |
| 7999 | "Do not export to next AS (well-known community)\n" |
| 8000 | "community number\n" |
| 8001 | "Do not send outside local AS (well-known community)\n" |
| 8002 | "Do not advertise to any peer (well-known community)\n" |
| 8003 | "Do not export to next AS (well-known community)\n" |
| 8004 | "community number\n" |
| 8005 | "Do not send outside local AS (well-known community)\n" |
| 8006 | "Do not advertise to any peer (well-known community)\n" |
| 8007 | "Do not export to next AS (well-known community)\n" |
| 8008 | "community number\n" |
| 8009 | "Do not send outside local AS (well-known community)\n" |
| 8010 | "Do not advertise to any peer (well-known community)\n" |
| 8011 | "Do not export to next AS (well-known community)\n" |
| 8012 | "Exact match of the communities") |
| 8013 | |
| 8014 | /* old command */ |
| 8015 | DEFUN (show_ipv6_bgp_community_exact, |
| 8016 | show_ipv6_bgp_community_exact_cmd, |
| 8017 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8018 | SHOW_STR |
| 8019 | IPV6_STR |
| 8020 | BGP_STR |
| 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 | "Exact match of the communities") |
| 8027 | { |
| 8028 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 8029 | } |
| 8030 | |
| 8031 | /* old command */ |
| 8032 | ALIAS (show_ipv6_bgp_community_exact, |
| 8033 | show_ipv6_bgp_community2_exact_cmd, |
| 8034 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8035 | SHOW_STR |
| 8036 | IPV6_STR |
| 8037 | BGP_STR |
| 8038 | "Display routes matching the communities\n" |
| 8039 | "community number\n" |
| 8040 | "Do not send outside local AS (well-known community)\n" |
| 8041 | "Do not advertise to any peer (well-known community)\n" |
| 8042 | "Do not export to next AS (well-known community)\n" |
| 8043 | "community number\n" |
| 8044 | "Do not send outside local AS (well-known community)\n" |
| 8045 | "Do not advertise to any peer (well-known community)\n" |
| 8046 | "Do not export to next AS (well-known community)\n" |
| 8047 | "Exact match of the communities") |
| 8048 | |
| 8049 | /* old command */ |
| 8050 | ALIAS (show_ipv6_bgp_community_exact, |
| 8051 | show_ipv6_bgp_community3_exact_cmd, |
| 8052 | "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", |
| 8053 | SHOW_STR |
| 8054 | IPV6_STR |
| 8055 | BGP_STR |
| 8056 | "Display routes matching the communities\n" |
| 8057 | "community number\n" |
| 8058 | "Do not send outside local AS (well-known community)\n" |
| 8059 | "Do not advertise to any peer (well-known community)\n" |
| 8060 | "Do not export to next AS (well-known community)\n" |
| 8061 | "community number\n" |
| 8062 | "Do not send outside local AS (well-known community)\n" |
| 8063 | "Do not advertise to any peer (well-known community)\n" |
| 8064 | "Do not export to next AS (well-known community)\n" |
| 8065 | "community number\n" |
| 8066 | "Do not send outside local AS (well-known community)\n" |
| 8067 | "Do not advertise to any peer (well-known community)\n" |
| 8068 | "Do not export to next AS (well-known community)\n" |
| 8069 | "Exact match of the communities") |
| 8070 | |
| 8071 | /* old command */ |
| 8072 | ALIAS (show_ipv6_bgp_community_exact, |
| 8073 | show_ipv6_bgp_community4_exact_cmd, |
| 8074 | "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", |
| 8075 | SHOW_STR |
| 8076 | IPV6_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 | "community number\n" |
| 8092 | "Do not send outside local AS (well-known community)\n" |
| 8093 | "Do not advertise to any peer (well-known community)\n" |
| 8094 | "Do not export to next AS (well-known community)\n" |
| 8095 | "Exact match of the communities") |
| 8096 | |
| 8097 | /* old command */ |
| 8098 | DEFUN (show_ipv6_mbgp_community, |
| 8099 | show_ipv6_mbgp_community_cmd, |
| 8100 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8101 | SHOW_STR |
| 8102 | IPV6_STR |
| 8103 | MBGP_STR |
| 8104 | "Display routes matching the communities\n" |
| 8105 | "community number\n" |
| 8106 | "Do not send outside local AS (well-known community)\n" |
| 8107 | "Do not advertise to any peer (well-known community)\n" |
| 8108 | "Do not export to next AS (well-known community)\n") |
| 8109 | { |
| 8110 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 8111 | } |
| 8112 | |
| 8113 | /* old command */ |
| 8114 | ALIAS (show_ipv6_mbgp_community, |
| 8115 | show_ipv6_mbgp_community2_cmd, |
| 8116 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8117 | SHOW_STR |
| 8118 | IPV6_STR |
| 8119 | MBGP_STR |
| 8120 | "Display routes matching the communities\n" |
| 8121 | "community number\n" |
| 8122 | "Do not send outside local AS (well-known community)\n" |
| 8123 | "Do not advertise to any peer (well-known community)\n" |
| 8124 | "Do not export to next AS (well-known community)\n" |
| 8125 | "community number\n" |
| 8126 | "Do not send outside local AS (well-known community)\n" |
| 8127 | "Do not advertise to any peer (well-known community)\n" |
| 8128 | "Do not export to next AS (well-known community)\n") |
| 8129 | |
| 8130 | /* old command */ |
| 8131 | ALIAS (show_ipv6_mbgp_community, |
| 8132 | show_ipv6_mbgp_community3_cmd, |
| 8133 | "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)", |
| 8134 | SHOW_STR |
| 8135 | IPV6_STR |
| 8136 | MBGP_STR |
| 8137 | "Display routes matching the communities\n" |
| 8138 | "community number\n" |
| 8139 | "Do not send outside local AS (well-known community)\n" |
| 8140 | "Do not advertise to any peer (well-known community)\n" |
| 8141 | "Do not export to next AS (well-known community)\n" |
| 8142 | "community number\n" |
| 8143 | "Do not send outside local AS (well-known community)\n" |
| 8144 | "Do not advertise to any peer (well-known community)\n" |
| 8145 | "Do not export to next AS (well-known community)\n" |
| 8146 | "community number\n" |
| 8147 | "Do not send outside local AS (well-known community)\n" |
| 8148 | "Do not advertise to any peer (well-known community)\n" |
| 8149 | "Do not export to next AS (well-known community)\n") |
| 8150 | |
| 8151 | /* old command */ |
| 8152 | ALIAS (show_ipv6_mbgp_community, |
| 8153 | show_ipv6_mbgp_community4_cmd, |
| 8154 | "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)", |
| 8155 | SHOW_STR |
| 8156 | IPV6_STR |
| 8157 | MBGP_STR |
| 8158 | "Display routes matching the communities\n" |
| 8159 | "community number\n" |
| 8160 | "Do not send outside local AS (well-known community)\n" |
| 8161 | "Do not advertise to any peer (well-known community)\n" |
| 8162 | "Do not export to next AS (well-known community)\n" |
| 8163 | "community number\n" |
| 8164 | "Do not send outside local AS (well-known community)\n" |
| 8165 | "Do not advertise to any peer (well-known community)\n" |
| 8166 | "Do not export to next AS (well-known community)\n" |
| 8167 | "community number\n" |
| 8168 | "Do not send outside local AS (well-known community)\n" |
| 8169 | "Do not advertise to any peer (well-known community)\n" |
| 8170 | "Do not export to next AS (well-known community)\n" |
| 8171 | "community number\n" |
| 8172 | "Do not send outside local AS (well-known community)\n" |
| 8173 | "Do not advertise to any peer (well-known community)\n" |
| 8174 | "Do not export to next AS (well-known community)\n") |
| 8175 | |
| 8176 | /* old command */ |
| 8177 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8178 | show_ipv6_mbgp_community_exact_cmd, |
| 8179 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8180 | SHOW_STR |
| 8181 | IPV6_STR |
| 8182 | MBGP_STR |
| 8183 | "Display routes matching the communities\n" |
| 8184 | "community number\n" |
| 8185 | "Do not send outside local AS (well-known community)\n" |
| 8186 | "Do not advertise to any peer (well-known community)\n" |
| 8187 | "Do not export to next AS (well-known community)\n" |
| 8188 | "Exact match of the communities") |
| 8189 | { |
| 8190 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 8191 | } |
| 8192 | |
| 8193 | /* old command */ |
| 8194 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8195 | show_ipv6_mbgp_community2_exact_cmd, |
| 8196 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8197 | SHOW_STR |
| 8198 | IPV6_STR |
| 8199 | MBGP_STR |
| 8200 | "Display routes matching the communities\n" |
| 8201 | "community number\n" |
| 8202 | "Do not send outside local AS (well-known community)\n" |
| 8203 | "Do not advertise to any peer (well-known community)\n" |
| 8204 | "Do not export to next AS (well-known community)\n" |
| 8205 | "community number\n" |
| 8206 | "Do not send outside local AS (well-known community)\n" |
| 8207 | "Do not advertise to any peer (well-known community)\n" |
| 8208 | "Do not export to next AS (well-known community)\n" |
| 8209 | "Exact match of the communities") |
| 8210 | |
| 8211 | /* old command */ |
| 8212 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8213 | show_ipv6_mbgp_community3_exact_cmd, |
| 8214 | "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", |
| 8215 | SHOW_STR |
| 8216 | IPV6_STR |
| 8217 | MBGP_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 | "community number\n" |
| 8224 | "Do not send outside local AS (well-known community)\n" |
| 8225 | "Do not advertise to any peer (well-known community)\n" |
| 8226 | "Do not export to next AS (well-known community)\n" |
| 8227 | "community number\n" |
| 8228 | "Do not send outside local AS (well-known community)\n" |
| 8229 | "Do not advertise to any peer (well-known community)\n" |
| 8230 | "Do not export to next AS (well-known community)\n" |
| 8231 | "Exact match of the communities") |
| 8232 | |
| 8233 | /* old command */ |
| 8234 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8235 | show_ipv6_mbgp_community4_exact_cmd, |
| 8236 | "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", |
| 8237 | SHOW_STR |
| 8238 | IPV6_STR |
| 8239 | MBGP_STR |
| 8240 | "Display routes matching the communities\n" |
| 8241 | "community number\n" |
| 8242 | "Do not send outside local AS (well-known community)\n" |
| 8243 | "Do not advertise to any peer (well-known community)\n" |
| 8244 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 8254 | "Do not send outside local AS (well-known community)\n" |
| 8255 | "Do not advertise to any peer (well-known community)\n" |
| 8256 | "Do not export to next AS (well-known community)\n" |
| 8257 | "Exact match of the communities") |
| 8258 | #endif /* HAVE_IPV6 */ |
| 8259 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8260 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8261 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8262 | u_int16_t afi, u_char safi) |
| 8263 | { |
| 8264 | struct community_list *list; |
| 8265 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8266 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8267 | if (list == NULL) |
| 8268 | { |
| 8269 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8270 | VTY_NEWLINE); |
| 8271 | return CMD_WARNING; |
| 8272 | } |
| 8273 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8274 | return bgp_show (vty, NULL, afi, safi, |
| 8275 | (exact ? bgp_show_type_community_list_exact : |
| 8276 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8277 | } |
| 8278 | |
| 8279 | DEFUN (show_ip_bgp_community_list, |
| 8280 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8281 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8282 | SHOW_STR |
| 8283 | IP_STR |
| 8284 | BGP_STR |
| 8285 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8286 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8287 | "community-list name\n") |
| 8288 | { |
| 8289 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8290 | } |
| 8291 | |
| 8292 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8293 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8294 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8295 | SHOW_STR |
| 8296 | IP_STR |
| 8297 | BGP_STR |
| 8298 | "Address family\n" |
| 8299 | "Address Family modifier\n" |
| 8300 | "Address Family modifier\n" |
| 8301 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8302 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8303 | "community-list name\n") |
| 8304 | { |
| 8305 | if (strncmp (argv[0], "m", 1) == 0) |
| 8306 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8307 | |
| 8308 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8309 | } |
| 8310 | |
| 8311 | DEFUN (show_ip_bgp_community_list_exact, |
| 8312 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8313 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8314 | SHOW_STR |
| 8315 | IP_STR |
| 8316 | BGP_STR |
| 8317 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8318 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8319 | "community-list name\n" |
| 8320 | "Exact match of the communities\n") |
| 8321 | { |
| 8322 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8323 | } |
| 8324 | |
| 8325 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8326 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8327 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8328 | SHOW_STR |
| 8329 | IP_STR |
| 8330 | BGP_STR |
| 8331 | "Address family\n" |
| 8332 | "Address Family modifier\n" |
| 8333 | "Address Family modifier\n" |
| 8334 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8335 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8336 | "community-list name\n" |
| 8337 | "Exact match of the communities\n") |
| 8338 | { |
| 8339 | if (strncmp (argv[0], "m", 1) == 0) |
| 8340 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8341 | |
| 8342 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8343 | } |
| 8344 | |
| 8345 | #ifdef HAVE_IPV6 |
| 8346 | DEFUN (show_bgp_community_list, |
| 8347 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8348 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8349 | SHOW_STR |
| 8350 | BGP_STR |
| 8351 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8352 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8353 | "community-list name\n") |
| 8354 | { |
| 8355 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8356 | } |
| 8357 | |
| 8358 | ALIAS (show_bgp_community_list, |
| 8359 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8360 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8361 | SHOW_STR |
| 8362 | BGP_STR |
| 8363 | "Address family\n" |
| 8364 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8365 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8366 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8367 | |
| 8368 | /* old command */ |
| 8369 | DEFUN (show_ipv6_bgp_community_list, |
| 8370 | show_ipv6_bgp_community_list_cmd, |
| 8371 | "show ipv6 bgp community-list WORD", |
| 8372 | SHOW_STR |
| 8373 | IPV6_STR |
| 8374 | BGP_STR |
| 8375 | "Display routes matching the community-list\n" |
| 8376 | "community-list name\n") |
| 8377 | { |
| 8378 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8379 | } |
| 8380 | |
| 8381 | /* old command */ |
| 8382 | DEFUN (show_ipv6_mbgp_community_list, |
| 8383 | show_ipv6_mbgp_community_list_cmd, |
| 8384 | "show ipv6 mbgp community-list WORD", |
| 8385 | SHOW_STR |
| 8386 | IPV6_STR |
| 8387 | MBGP_STR |
| 8388 | "Display routes matching the community-list\n" |
| 8389 | "community-list name\n") |
| 8390 | { |
| 8391 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8392 | } |
| 8393 | |
| 8394 | DEFUN (show_bgp_community_list_exact, |
| 8395 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8396 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8397 | SHOW_STR |
| 8398 | BGP_STR |
| 8399 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8400 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8401 | "community-list name\n" |
| 8402 | "Exact match of the communities\n") |
| 8403 | { |
| 8404 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8405 | } |
| 8406 | |
| 8407 | ALIAS (show_bgp_community_list_exact, |
| 8408 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8409 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8410 | SHOW_STR |
| 8411 | BGP_STR |
| 8412 | "Address family\n" |
| 8413 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8414 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8415 | "community-list name\n" |
| 8416 | "Exact match of the communities\n") |
| 8417 | |
| 8418 | /* old command */ |
| 8419 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 8420 | show_ipv6_bgp_community_list_exact_cmd, |
| 8421 | "show ipv6 bgp community-list WORD exact-match", |
| 8422 | SHOW_STR |
| 8423 | IPV6_STR |
| 8424 | BGP_STR |
| 8425 | "Display routes matching the community-list\n" |
| 8426 | "community-list name\n" |
| 8427 | "Exact match of the communities\n") |
| 8428 | { |
| 8429 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8430 | } |
| 8431 | |
| 8432 | /* old command */ |
| 8433 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 8434 | show_ipv6_mbgp_community_list_exact_cmd, |
| 8435 | "show ipv6 mbgp community-list WORD exact-match", |
| 8436 | SHOW_STR |
| 8437 | IPV6_STR |
| 8438 | MBGP_STR |
| 8439 | "Display routes matching the community-list\n" |
| 8440 | "community-list name\n" |
| 8441 | "Exact match of the communities\n") |
| 8442 | { |
| 8443 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 8444 | } |
| 8445 | #endif /* HAVE_IPV6 */ |
| 8446 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8447 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8448 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8449 | safi_t safi, enum bgp_show_type type) |
| 8450 | { |
| 8451 | int ret; |
| 8452 | struct prefix *p; |
| 8453 | |
| 8454 | p = prefix_new(); |
| 8455 | |
| 8456 | ret = str2prefix (prefix, p); |
| 8457 | if (! ret) |
| 8458 | { |
| 8459 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 8460 | return CMD_WARNING; |
| 8461 | } |
| 8462 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8463 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 8464 | prefix_free(p); |
| 8465 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8466 | } |
| 8467 | |
| 8468 | DEFUN (show_ip_bgp_prefix_longer, |
| 8469 | show_ip_bgp_prefix_longer_cmd, |
| 8470 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 8471 | SHOW_STR |
| 8472 | IP_STR |
| 8473 | BGP_STR |
| 8474 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8475 | "Display route and more specific routes\n") |
| 8476 | { |
| 8477 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8478 | bgp_show_type_prefix_longer); |
| 8479 | } |
| 8480 | |
| 8481 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 8482 | show_ip_bgp_flap_prefix_longer_cmd, |
| 8483 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 8484 | SHOW_STR |
| 8485 | IP_STR |
| 8486 | BGP_STR |
| 8487 | "Display flap statistics of routes\n" |
| 8488 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8489 | "Display route and more specific routes\n") |
| 8490 | { |
| 8491 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8492 | bgp_show_type_flap_prefix_longer); |
| 8493 | } |
| 8494 | |
| 8495 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 8496 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 8497 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 8498 | SHOW_STR |
| 8499 | IP_STR |
| 8500 | BGP_STR |
| 8501 | "Address family\n" |
| 8502 | "Address Family modifier\n" |
| 8503 | "Address Family modifier\n" |
| 8504 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8505 | "Display route and more specific routes\n") |
| 8506 | { |
| 8507 | if (strncmp (argv[0], "m", 1) == 0) |
| 8508 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8509 | bgp_show_type_prefix_longer); |
| 8510 | |
| 8511 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8512 | bgp_show_type_prefix_longer); |
| 8513 | } |
| 8514 | |
| 8515 | DEFUN (show_ip_bgp_flap_address, |
| 8516 | show_ip_bgp_flap_address_cmd, |
| 8517 | "show ip bgp flap-statistics A.B.C.D", |
| 8518 | SHOW_STR |
| 8519 | IP_STR |
| 8520 | BGP_STR |
| 8521 | "Display flap statistics of routes\n" |
| 8522 | "Network in the BGP routing table to display\n") |
| 8523 | { |
| 8524 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8525 | bgp_show_type_flap_address); |
| 8526 | } |
| 8527 | |
| 8528 | DEFUN (show_ip_bgp_flap_prefix, |
| 8529 | show_ip_bgp_flap_prefix_cmd, |
| 8530 | "show ip bgp flap-statistics A.B.C.D/M", |
| 8531 | SHOW_STR |
| 8532 | IP_STR |
| 8533 | BGP_STR |
| 8534 | "Display flap statistics of routes\n" |
| 8535 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8536 | { |
| 8537 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8538 | bgp_show_type_flap_prefix); |
| 8539 | } |
| 8540 | #ifdef HAVE_IPV6 |
| 8541 | DEFUN (show_bgp_prefix_longer, |
| 8542 | show_bgp_prefix_longer_cmd, |
| 8543 | "show bgp X:X::X:X/M longer-prefixes", |
| 8544 | SHOW_STR |
| 8545 | BGP_STR |
| 8546 | "IPv6 prefix <network>/<length>\n" |
| 8547 | "Display route and more specific routes\n") |
| 8548 | { |
| 8549 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8550 | bgp_show_type_prefix_longer); |
| 8551 | } |
| 8552 | |
| 8553 | ALIAS (show_bgp_prefix_longer, |
| 8554 | show_bgp_ipv6_prefix_longer_cmd, |
| 8555 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 8556 | SHOW_STR |
| 8557 | BGP_STR |
| 8558 | "Address family\n" |
| 8559 | "IPv6 prefix <network>/<length>\n" |
| 8560 | "Display route and more specific routes\n") |
| 8561 | |
| 8562 | /* old command */ |
| 8563 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 8564 | show_ipv6_bgp_prefix_longer_cmd, |
| 8565 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 8566 | SHOW_STR |
| 8567 | IPV6_STR |
| 8568 | BGP_STR |
| 8569 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8570 | "Display route and more specific routes\n") |
| 8571 | { |
| 8572 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8573 | bgp_show_type_prefix_longer); |
| 8574 | } |
| 8575 | |
| 8576 | /* old command */ |
| 8577 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 8578 | show_ipv6_mbgp_prefix_longer_cmd, |
| 8579 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 8580 | SHOW_STR |
| 8581 | IPV6_STR |
| 8582 | MBGP_STR |
| 8583 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8584 | "Display route and more specific routes\n") |
| 8585 | { |
| 8586 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8587 | bgp_show_type_prefix_longer); |
| 8588 | } |
| 8589 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8590 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8591 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8592 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 8593 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8594 | { |
| 8595 | int ret; |
| 8596 | struct bgp *bgp; |
| 8597 | struct peer *peer; |
| 8598 | union sockunion su; |
| 8599 | |
| 8600 | /* BGP structure lookup. */ |
| 8601 | if (view_name) |
| 8602 | { |
| 8603 | bgp = bgp_lookup_by_name (view_name); |
| 8604 | if (! bgp) |
| 8605 | { |
| 8606 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8607 | return NULL; |
| 8608 | } |
| 8609 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 8610 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8611 | { |
| 8612 | bgp = bgp_get_default (); |
| 8613 | if (! bgp) |
| 8614 | { |
| 8615 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8616 | return NULL; |
| 8617 | } |
| 8618 | } |
| 8619 | |
| 8620 | /* Get peer sockunion. */ |
| 8621 | ret = str2sockunion (ip_str, &su); |
| 8622 | if (ret < 0) |
| 8623 | { |
| 8624 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 8625 | return NULL; |
| 8626 | } |
| 8627 | |
| 8628 | /* Peer structure lookup. */ |
| 8629 | peer = peer_lookup (bgp, &su); |
| 8630 | if (! peer) |
| 8631 | { |
| 8632 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 8633 | return NULL; |
| 8634 | } |
| 8635 | |
| 8636 | return peer; |
| 8637 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8638 | |
| 8639 | enum bgp_stats |
| 8640 | { |
| 8641 | BGP_STATS_MAXBITLEN = 0, |
| 8642 | BGP_STATS_RIB, |
| 8643 | BGP_STATS_PREFIXES, |
| 8644 | BGP_STATS_TOTPLEN, |
| 8645 | BGP_STATS_UNAGGREGATEABLE, |
| 8646 | BGP_STATS_MAX_AGGREGATEABLE, |
| 8647 | BGP_STATS_AGGREGATES, |
| 8648 | BGP_STATS_SPACE, |
| 8649 | BGP_STATS_ASPATH_COUNT, |
| 8650 | BGP_STATS_ASPATH_MAXHOPS, |
| 8651 | BGP_STATS_ASPATH_TOTHOPS, |
| 8652 | BGP_STATS_ASPATH_MAXSIZE, |
| 8653 | BGP_STATS_ASPATH_TOTSIZE, |
| 8654 | BGP_STATS_ASN_HIGHEST, |
| 8655 | BGP_STATS_MAX, |
| 8656 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8657 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8658 | static const char *table_stats_strs[] = |
| 8659 | { |
| 8660 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 8661 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 8662 | [BGP_STATS_RIB] = "Total Advertisements", |
| 8663 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 8664 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 8665 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 8666 | [BGP_STATS_SPACE] = "Address space advertised", |
| 8667 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 8668 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 8669 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 8670 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 8671 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 8672 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 8673 | [BGP_STATS_MAX] = NULL, |
| 8674 | }; |
| 8675 | |
| 8676 | struct bgp_table_stats |
| 8677 | { |
| 8678 | struct bgp_table *table; |
| 8679 | unsigned long long counts[BGP_STATS_MAX]; |
| 8680 | }; |
| 8681 | |
| 8682 | #if 0 |
| 8683 | #define TALLY_SIGFIG 100000 |
| 8684 | static unsigned long |
| 8685 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 8686 | { |
| 8687 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 8688 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 8689 | unsigned long ret = newtot / count; |
| 8690 | |
| 8691 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 8692 | return ret + 1; |
| 8693 | else |
| 8694 | return ret; |
| 8695 | } |
| 8696 | #endif |
| 8697 | |
| 8698 | static int |
| 8699 | bgp_table_stats_walker (struct thread *t) |
| 8700 | { |
| 8701 | struct bgp_node *rn; |
| 8702 | struct bgp_node *top; |
| 8703 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 8704 | unsigned int space = 0; |
| 8705 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 8706 | if (!(top = bgp_table_top (ts->table))) |
| 8707 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8708 | |
| 8709 | switch (top->p.family) |
| 8710 | { |
| 8711 | case AF_INET: |
| 8712 | space = IPV4_MAX_BITLEN; |
| 8713 | break; |
| 8714 | case AF_INET6: |
| 8715 | space = IPV6_MAX_BITLEN; |
| 8716 | break; |
| 8717 | } |
| 8718 | |
| 8719 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 8720 | |
| 8721 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 8722 | { |
| 8723 | struct bgp_info *ri; |
| 8724 | struct bgp_node *prn = rn->parent; |
| 8725 | unsigned int rinum = 0; |
| 8726 | |
| 8727 | if (rn == top) |
| 8728 | continue; |
| 8729 | |
| 8730 | if (!rn->info) |
| 8731 | continue; |
| 8732 | |
| 8733 | ts->counts[BGP_STATS_PREFIXES]++; |
| 8734 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 8735 | |
| 8736 | #if 0 |
| 8737 | ts->counts[BGP_STATS_AVGPLEN] |
| 8738 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 8739 | ts->counts[BGP_STATS_AVGPLEN], |
| 8740 | rn->p.prefixlen); |
| 8741 | #endif |
| 8742 | |
| 8743 | /* check if the prefix is included by any other announcements */ |
| 8744 | while (prn && !prn->info) |
| 8745 | prn = prn->parent; |
| 8746 | |
| 8747 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 8748 | { |
| 8749 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 8750 | /* announced address space */ |
| 8751 | if (space) |
| 8752 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 8753 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8754 | else if (prn->info) |
| 8755 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 8756 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8757 | for (ri = rn->info; ri; ri = ri->next) |
| 8758 | { |
| 8759 | rinum++; |
| 8760 | ts->counts[BGP_STATS_RIB]++; |
| 8761 | |
| 8762 | if (ri->attr && |
| 8763 | (CHECK_FLAG (ri->attr->flag, |
| 8764 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 8765 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 8766 | |
| 8767 | /* as-path stats */ |
| 8768 | if (ri->attr && ri->attr->aspath) |
| 8769 | { |
| 8770 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 8771 | unsigned int size = aspath_size (ri->attr->aspath); |
| 8772 | as_t highest = aspath_highest (ri->attr->aspath); |
| 8773 | |
| 8774 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 8775 | |
| 8776 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 8777 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 8778 | |
| 8779 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 8780 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 8781 | |
| 8782 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 8783 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 8784 | #if 0 |
| 8785 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 8786 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 8787 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 8788 | hops); |
| 8789 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 8790 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 8791 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 8792 | size); |
| 8793 | #endif |
| 8794 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 8795 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 8796 | } |
| 8797 | } |
| 8798 | } |
| 8799 | return 0; |
| 8800 | } |
| 8801 | |
| 8802 | static int |
| 8803 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 8804 | { |
| 8805 | struct bgp_table_stats ts; |
| 8806 | unsigned int i; |
| 8807 | |
| 8808 | if (!bgp->rib[afi][safi]) |
| 8809 | { |
| 8810 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 8811 | return CMD_WARNING; |
| 8812 | } |
| 8813 | |
| 8814 | memset (&ts, 0, sizeof (ts)); |
| 8815 | ts.table = bgp->rib[afi][safi]; |
| 8816 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 8817 | |
| 8818 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 8819 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 8820 | |
| 8821 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 8822 | { |
| 8823 | if (!table_stats_strs[i]) |
| 8824 | continue; |
| 8825 | |
| 8826 | switch (i) |
| 8827 | { |
| 8828 | #if 0 |
| 8829 | case BGP_STATS_ASPATH_AVGHOPS: |
| 8830 | case BGP_STATS_ASPATH_AVGSIZE: |
| 8831 | case BGP_STATS_AVGPLEN: |
| 8832 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8833 | vty_out (vty, "%12.2f", |
| 8834 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 8835 | break; |
| 8836 | #endif |
| 8837 | case BGP_STATS_ASPATH_TOTHOPS: |
| 8838 | case BGP_STATS_ASPATH_TOTSIZE: |
| 8839 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8840 | vty_out (vty, "%12.2f", |
| 8841 | ts.counts[i] ? |
| 8842 | (float)ts.counts[i] / |
| 8843 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 8844 | : 0); |
| 8845 | break; |
| 8846 | case BGP_STATS_TOTPLEN: |
| 8847 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8848 | vty_out (vty, "%12.2f", |
| 8849 | ts.counts[i] ? |
| 8850 | (float)ts.counts[i] / |
| 8851 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 8852 | : 0); |
| 8853 | break; |
| 8854 | case BGP_STATS_SPACE: |
| 8855 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8856 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 8857 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 8858 | break; |
| 8859 | vty_out (vty, "%30s: ", "\% announced "); |
| 8860 | vty_out (vty, "%12.2f%s", |
| 8861 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 8862 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8863 | VTY_NEWLINE); |
| 8864 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 8865 | vty_out (vty, "%12.2f%s", |
| 8866 | (float)ts.counts[BGP_STATS_SPACE] / |
| 8867 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 8868 | VTY_NEWLINE); |
| 8869 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 8870 | break; |
| 8871 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 8872 | vty_out (vty, "%12.2f", |
| 8873 | (float)ts.counts[BGP_STATS_SPACE] / |
| 8874 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 8875 | break; |
| 8876 | default: |
| 8877 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8878 | vty_out (vty, "%12llu", ts.counts[i]); |
| 8879 | } |
| 8880 | |
| 8881 | vty_out (vty, "%s", VTY_NEWLINE); |
| 8882 | } |
| 8883 | return CMD_SUCCESS; |
| 8884 | } |
| 8885 | |
| 8886 | static int |
| 8887 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 8888 | const char *afi_str, const char *safi_str) |
| 8889 | { |
| 8890 | struct bgp *bgp; |
| 8891 | afi_t afi; |
| 8892 | safi_t safi; |
| 8893 | |
| 8894 | if (name) |
| 8895 | bgp = bgp_lookup_by_name (name); |
| 8896 | else |
| 8897 | bgp = bgp_get_default (); |
| 8898 | |
| 8899 | if (!bgp) |
| 8900 | { |
| 8901 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 8902 | return CMD_WARNING; |
| 8903 | } |
| 8904 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 8905 | { |
| 8906 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 8907 | afi = AFI_IP; |
| 8908 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 8909 | afi = AFI_IP6; |
| 8910 | else |
| 8911 | { |
| 8912 | vty_out (vty, "%% Invalid address family %s%s", |
| 8913 | afi_str, VTY_NEWLINE); |
| 8914 | return CMD_WARNING; |
| 8915 | } |
| 8916 | if (strncmp (safi_str, "m", 1) == 0) |
| 8917 | safi = SAFI_MULTICAST; |
| 8918 | else if (strncmp (safi_str, "u", 1) == 0) |
| 8919 | safi = SAFI_UNICAST; |
| 8920 | else if (strncmp (safi_str, "vpnv4", 5) == 0) |
| 8921 | safi = BGP_SAFI_VPNV4; |
| 8922 | else if (strncmp (safi_str, "vpnv6", 6) == 0) |
| 8923 | safi = BGP_SAFI_VPNV6; |
| 8924 | else |
| 8925 | { |
| 8926 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 8927 | safi_str, VTY_NEWLINE); |
| 8928 | return CMD_WARNING; |
| 8929 | } |
| 8930 | } |
| 8931 | else |
| 8932 | { |
| 8933 | vty_out (vty, "%% Invalid address family %s%s", |
| 8934 | afi_str, VTY_NEWLINE); |
| 8935 | return CMD_WARNING; |
| 8936 | } |
| 8937 | |
| 8938 | if ((afi == AFI_IP && safi == BGP_SAFI_VPNV6) |
| 8939 | || (afi == AFI_IP6 && safi == BGP_SAFI_VPNV4)) |
| 8940 | { |
| 8941 | vty_out (vty, "%% Invalid subsequent address family %s for %s%s", |
| 8942 | afi_str, safi_str, VTY_NEWLINE); |
| 8943 | return CMD_WARNING; |
| 8944 | } |
| 8945 | return bgp_table_stats (vty, bgp, afi, safi); |
| 8946 | } |
| 8947 | |
| 8948 | DEFUN (show_bgp_statistics, |
| 8949 | show_bgp_statistics_cmd, |
| 8950 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 8951 | SHOW_STR |
| 8952 | BGP_STR |
| 8953 | "Address family\n" |
| 8954 | "Address family\n" |
| 8955 | "Address Family modifier\n" |
| 8956 | "Address Family modifier\n" |
| 8957 | "BGP RIB advertisement statistics\n") |
| 8958 | { |
| 8959 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 8960 | } |
| 8961 | |
| 8962 | ALIAS (show_bgp_statistics, |
| 8963 | show_bgp_statistics_vpnv4_cmd, |
| 8964 | "show bgp (ipv4) (vpnv4) statistics", |
| 8965 | SHOW_STR |
| 8966 | BGP_STR |
| 8967 | "Address family\n" |
| 8968 | "Address Family modifier\n" |
| 8969 | "BGP RIB advertisement statistics\n") |
| 8970 | |
| 8971 | DEFUN (show_bgp_statistics_view, |
| 8972 | show_bgp_statistics_view_cmd, |
| 8973 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 8974 | SHOW_STR |
| 8975 | BGP_STR |
| 8976 | "BGP view\n" |
| 8977 | "Address family\n" |
| 8978 | "Address family\n" |
| 8979 | "Address Family modifier\n" |
| 8980 | "Address Family modifier\n" |
| 8981 | "BGP RIB advertisement statistics\n") |
| 8982 | { |
| 8983 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 8984 | } |
| 8985 | |
| 8986 | ALIAS (show_bgp_statistics_view, |
| 8987 | show_bgp_statistics_view_vpnv4_cmd, |
| 8988 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 8989 | SHOW_STR |
| 8990 | BGP_STR |
| 8991 | "BGP view\n" |
| 8992 | "Address family\n" |
| 8993 | "Address Family modifier\n" |
| 8994 | "BGP RIB advertisement statistics\n") |
| 8995 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8996 | enum bgp_pcounts |
| 8997 | { |
| 8998 | PCOUNT_ADJ_IN = 0, |
| 8999 | PCOUNT_DAMPED, |
| 9000 | PCOUNT_REMOVED, |
| 9001 | PCOUNT_HISTORY, |
| 9002 | PCOUNT_STALE, |
| 9003 | PCOUNT_VALID, |
| 9004 | PCOUNT_ALL, |
| 9005 | PCOUNT_COUNTED, |
| 9006 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9007 | PCOUNT_MAX, |
| 9008 | }; |
| 9009 | |
| 9010 | static const char *pcount_strs[] = |
| 9011 | { |
| 9012 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9013 | [PCOUNT_DAMPED] = "Damped", |
| 9014 | [PCOUNT_REMOVED] = "Removed", |
| 9015 | [PCOUNT_HISTORY] = "History", |
| 9016 | [PCOUNT_STALE] = "Stale", |
| 9017 | [PCOUNT_VALID] = "Valid", |
| 9018 | [PCOUNT_ALL] = "All RIB", |
| 9019 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9020 | [PCOUNT_PFCNT] = "Useable", |
| 9021 | [PCOUNT_MAX] = NULL, |
| 9022 | }; |
| 9023 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9024 | struct peer_pcounts |
| 9025 | { |
| 9026 | unsigned int count[PCOUNT_MAX]; |
| 9027 | const struct peer *peer; |
| 9028 | const struct bgp_table *table; |
| 9029 | }; |
| 9030 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9031 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9032 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9033 | { |
| 9034 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9035 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9036 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9037 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9038 | 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] | 9039 | { |
| 9040 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9041 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9042 | |
| 9043 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9044 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9045 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9046 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9047 | for (ri = rn->info; ri; ri = ri->next) |
| 9048 | { |
| 9049 | char buf[SU_ADDRSTRLEN]; |
| 9050 | |
| 9051 | if (ri->peer != peer) |
| 9052 | continue; |
| 9053 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9054 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9055 | |
| 9056 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9057 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9058 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9059 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9060 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9061 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9062 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9063 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9064 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9065 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9066 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9067 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9068 | |
| 9069 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9070 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9071 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9072 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9073 | plog_warn (peer->log, |
| 9074 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9075 | peer->host, |
| 9076 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9077 | buf, SU_ADDRSTRLEN), |
| 9078 | rn->p.prefixlen, |
| 9079 | ri->flags); |
| 9080 | } |
| 9081 | else |
| 9082 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9083 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9084 | plog_warn (peer->log, |
| 9085 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9086 | peer->host, |
| 9087 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9088 | buf, SU_ADDRSTRLEN), |
| 9089 | rn->p.prefixlen, |
| 9090 | ri->flags); |
| 9091 | } |
| 9092 | } |
| 9093 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9094 | return 0; |
| 9095 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9096 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9097 | static int |
| 9098 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9099 | { |
| 9100 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9101 | unsigned int i; |
| 9102 | |
| 9103 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9104 | || !peer->bgp->rib[afi][safi]) |
| 9105 | { |
| 9106 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9107 | return CMD_WARNING; |
| 9108 | } |
| 9109 | |
| 9110 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9111 | pcounts.peer = peer; |
| 9112 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9113 | |
| 9114 | /* in-place call via thread subsystem so as to record execution time |
| 9115 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9116 | * on just vty_read()). |
| 9117 | */ |
| 9118 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9119 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9120 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9121 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9122 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9123 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9124 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9125 | |
| 9126 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9127 | vty_out (vty, "%20s: %-10d%s", |
| 9128 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9129 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9130 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9131 | { |
| 9132 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9133 | peer->host, VTY_NEWLINE); |
| 9134 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9135 | VTY_NEWLINE); |
| 9136 | } |
| 9137 | |
| 9138 | return CMD_SUCCESS; |
| 9139 | } |
| 9140 | |
| 9141 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9142 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9143 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9144 | SHOW_STR |
| 9145 | IP_STR |
| 9146 | BGP_STR |
| 9147 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9148 | "Neighbor to display information about\n" |
| 9149 | "Neighbor to display information about\n" |
| 9150 | "Display detailed prefix count information\n") |
| 9151 | { |
| 9152 | struct peer *peer; |
| 9153 | |
| 9154 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9155 | if (! peer) |
| 9156 | return CMD_WARNING; |
| 9157 | |
| 9158 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9159 | } |
| 9160 | |
| 9161 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9162 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9163 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9164 | SHOW_STR |
| 9165 | BGP_STR |
| 9166 | "Address family\n" |
| 9167 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9168 | "Neighbor to display information about\n" |
| 9169 | "Neighbor to display information about\n" |
| 9170 | "Display detailed prefix count information\n") |
| 9171 | { |
| 9172 | struct peer *peer; |
| 9173 | |
| 9174 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9175 | if (! peer) |
| 9176 | return CMD_WARNING; |
| 9177 | |
| 9178 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9179 | } |
| 9180 | |
| 9181 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9182 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9183 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9184 | SHOW_STR |
| 9185 | IP_STR |
| 9186 | BGP_STR |
| 9187 | "Address family\n" |
| 9188 | "Address Family modifier\n" |
| 9189 | "Address Family modifier\n" |
| 9190 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9191 | "Neighbor to display information about\n" |
| 9192 | "Neighbor to display information about\n" |
| 9193 | "Display detailed prefix count information\n") |
| 9194 | { |
| 9195 | struct peer *peer; |
| 9196 | |
| 9197 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9198 | if (! peer) |
| 9199 | return CMD_WARNING; |
| 9200 | |
| 9201 | if (strncmp (argv[0], "m", 1) == 0) |
| 9202 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9203 | |
| 9204 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9205 | } |
| 9206 | |
| 9207 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9208 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9209 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9210 | SHOW_STR |
| 9211 | IP_STR |
| 9212 | BGP_STR |
| 9213 | "Address family\n" |
| 9214 | "Address Family modifier\n" |
| 9215 | "Address Family modifier\n" |
| 9216 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9217 | "Neighbor to display information about\n" |
| 9218 | "Neighbor to display information about\n" |
| 9219 | "Display detailed prefix count information\n") |
| 9220 | { |
| 9221 | struct peer *peer; |
| 9222 | |
| 9223 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9224 | if (! peer) |
| 9225 | return CMD_WARNING; |
| 9226 | |
| 9227 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9228 | } |
| 9229 | |
| 9230 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9231 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9232 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9233 | int in) |
| 9234 | { |
| 9235 | struct bgp_table *table; |
| 9236 | struct bgp_adj_in *ain; |
| 9237 | struct bgp_adj_out *adj; |
| 9238 | unsigned long output_count; |
| 9239 | struct bgp_node *rn; |
| 9240 | int header1 = 1; |
| 9241 | struct bgp *bgp; |
| 9242 | int header2 = 1; |
| 9243 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9244 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9245 | |
| 9246 | if (! bgp) |
| 9247 | return; |
| 9248 | |
| 9249 | table = bgp->rib[afi][safi]; |
| 9250 | |
| 9251 | output_count = 0; |
| 9252 | |
| 9253 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9254 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9255 | { |
| 9256 | 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] | 9257 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9258 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9259 | |
| 9260 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9261 | VTY_NEWLINE, VTY_NEWLINE); |
| 9262 | header1 = 0; |
| 9263 | } |
| 9264 | |
| 9265 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9266 | if (in) |
| 9267 | { |
| 9268 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9269 | if (ain->peer == peer) |
| 9270 | { |
| 9271 | if (header1) |
| 9272 | { |
| 9273 | 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] | 9274 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9275 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9276 | header1 = 0; |
| 9277 | } |
| 9278 | if (header2) |
| 9279 | { |
| 9280 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9281 | header2 = 0; |
| 9282 | } |
| 9283 | if (ain->attr) |
| 9284 | { |
| 9285 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9286 | output_count++; |
| 9287 | } |
| 9288 | } |
| 9289 | } |
| 9290 | else |
| 9291 | { |
| 9292 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9293 | if (adj->peer == peer) |
| 9294 | { |
| 9295 | if (header1) |
| 9296 | { |
| 9297 | 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] | 9298 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9299 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9300 | header1 = 0; |
| 9301 | } |
| 9302 | if (header2) |
| 9303 | { |
| 9304 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9305 | header2 = 0; |
| 9306 | } |
| 9307 | if (adj->attr) |
| 9308 | { |
| 9309 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9310 | output_count++; |
| 9311 | } |
| 9312 | } |
| 9313 | } |
| 9314 | |
| 9315 | if (output_count != 0) |
| 9316 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9317 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9318 | } |
| 9319 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9320 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9321 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9322 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9323 | if (! peer || ! peer->afc[afi][safi]) |
| 9324 | { |
| 9325 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9326 | return CMD_WARNING; |
| 9327 | } |
| 9328 | |
| 9329 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9330 | { |
| 9331 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9332 | VTY_NEWLINE); |
| 9333 | return CMD_WARNING; |
| 9334 | } |
| 9335 | |
| 9336 | show_adj_route (vty, peer, afi, safi, in); |
| 9337 | |
| 9338 | return CMD_SUCCESS; |
| 9339 | } |
| 9340 | |
| 9341 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 9342 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9343 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9344 | SHOW_STR |
| 9345 | IP_STR |
| 9346 | BGP_STR |
| 9347 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9348 | "Neighbor to display information about\n" |
| 9349 | "Neighbor to display information about\n" |
| 9350 | "Display the routes advertised to a BGP neighbor\n") |
| 9351 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9352 | struct peer *peer; |
| 9353 | |
| 9354 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9355 | if (! peer) |
| 9356 | return CMD_WARNING; |
| 9357 | |
| 9358 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9359 | } |
| 9360 | |
| 9361 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9362 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9363 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9364 | SHOW_STR |
| 9365 | IP_STR |
| 9366 | BGP_STR |
| 9367 | "Address family\n" |
| 9368 | "Address Family modifier\n" |
| 9369 | "Address Family modifier\n" |
| 9370 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9371 | "Neighbor to display information about\n" |
| 9372 | "Neighbor to display information about\n" |
| 9373 | "Display the routes advertised to a BGP neighbor\n") |
| 9374 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9375 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9376 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9377 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9378 | if (! peer) |
| 9379 | return CMD_WARNING; |
| 9380 | |
| 9381 | if (strncmp (argv[0], "m", 1) == 0) |
| 9382 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 9383 | |
| 9384 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9385 | } |
| 9386 | |
| 9387 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9388 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 9389 | show_bgp_view_neighbor_advertised_route_cmd, |
| 9390 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9391 | SHOW_STR |
| 9392 | BGP_STR |
| 9393 | "BGP view\n" |
| 9394 | "View name\n" |
| 9395 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9396 | "Neighbor to display information about\n" |
| 9397 | "Neighbor to display information about\n" |
| 9398 | "Display the routes advertised to a BGP neighbor\n") |
| 9399 | { |
| 9400 | struct peer *peer; |
| 9401 | |
| 9402 | if (argc == 2) |
| 9403 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9404 | else |
| 9405 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9406 | |
| 9407 | if (! peer) |
| 9408 | return CMD_WARNING; |
| 9409 | |
| 9410 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 9411 | } |
| 9412 | |
| 9413 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 9414 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 9415 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9416 | SHOW_STR |
| 9417 | BGP_STR |
| 9418 | "BGP view\n" |
| 9419 | "View name\n" |
| 9420 | "Address family\n" |
| 9421 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9422 | "Neighbor to display information about\n" |
| 9423 | "Neighbor to display information about\n" |
| 9424 | "Display the routes advertised to a BGP neighbor\n") |
| 9425 | |
| 9426 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 9427 | show_bgp_view_neighbor_received_routes_cmd, |
| 9428 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9429 | SHOW_STR |
| 9430 | BGP_STR |
| 9431 | "BGP view\n" |
| 9432 | "View name\n" |
| 9433 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9434 | "Neighbor to display information about\n" |
| 9435 | "Neighbor to display information about\n" |
| 9436 | "Display the received routes from neighbor\n") |
| 9437 | { |
| 9438 | struct peer *peer; |
| 9439 | |
| 9440 | if (argc == 2) |
| 9441 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9442 | else |
| 9443 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9444 | |
| 9445 | if (! peer) |
| 9446 | return CMD_WARNING; |
| 9447 | |
| 9448 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 9449 | } |
| 9450 | |
| 9451 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 9452 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 9453 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9454 | SHOW_STR |
| 9455 | BGP_STR |
| 9456 | "BGP view\n" |
| 9457 | "View name\n" |
| 9458 | "Address family\n" |
| 9459 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9460 | "Neighbor to display information about\n" |
| 9461 | "Neighbor to display information about\n" |
| 9462 | "Display the received routes from neighbor\n") |
| 9463 | |
| 9464 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9465 | show_bgp_neighbor_advertised_route_cmd, |
| 9466 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9467 | SHOW_STR |
| 9468 | BGP_STR |
| 9469 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9470 | "Neighbor to display information about\n" |
| 9471 | "Neighbor to display information about\n" |
| 9472 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9473 | |
| 9474 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9475 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 9476 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9477 | SHOW_STR |
| 9478 | BGP_STR |
| 9479 | "Address family\n" |
| 9480 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9481 | "Neighbor to display information about\n" |
| 9482 | "Neighbor to display information about\n" |
| 9483 | "Display the routes advertised to a BGP neighbor\n") |
| 9484 | |
| 9485 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9486 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9487 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 9488 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9489 | SHOW_STR |
| 9490 | IPV6_STR |
| 9491 | BGP_STR |
| 9492 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9493 | "Neighbor to display information about\n" |
| 9494 | "Neighbor to display information about\n" |
| 9495 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9496 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9497 | /* old command */ |
| 9498 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 9499 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 9500 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9501 | SHOW_STR |
| 9502 | IPV6_STR |
| 9503 | MBGP_STR |
| 9504 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9505 | "Neighbor to display information about\n" |
| 9506 | "Neighbor to display information about\n" |
| 9507 | "Display the routes advertised to a BGP neighbor\n") |
| 9508 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9509 | struct peer *peer; |
| 9510 | |
| 9511 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9512 | if (! peer) |
| 9513 | return CMD_WARNING; |
| 9514 | |
| 9515 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9516 | } |
| 9517 | #endif /* HAVE_IPV6 */ |
| 9518 | |
| 9519 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 9520 | show_ip_bgp_neighbor_received_routes_cmd, |
| 9521 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9522 | SHOW_STR |
| 9523 | IP_STR |
| 9524 | BGP_STR |
| 9525 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9526 | "Neighbor to display information about\n" |
| 9527 | "Neighbor to display information about\n" |
| 9528 | "Display the received routes from neighbor\n") |
| 9529 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9530 | struct peer *peer; |
| 9531 | |
| 9532 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9533 | if (! peer) |
| 9534 | return CMD_WARNING; |
| 9535 | |
| 9536 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9537 | } |
| 9538 | |
| 9539 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 9540 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 9541 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9542 | SHOW_STR |
| 9543 | IP_STR |
| 9544 | BGP_STR |
| 9545 | "Address family\n" |
| 9546 | "Address Family modifier\n" |
| 9547 | "Address Family modifier\n" |
| 9548 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9549 | "Neighbor to display information about\n" |
| 9550 | "Neighbor to display information about\n" |
| 9551 | "Display the received routes from neighbor\n") |
| 9552 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9553 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9554 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9555 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9556 | if (! peer) |
| 9557 | return CMD_WARNING; |
| 9558 | |
| 9559 | if (strncmp (argv[0], "m", 1) == 0) |
| 9560 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 9561 | |
| 9562 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9563 | } |
| 9564 | |
| 9565 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 9566 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 9567 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9568 | SHOW_STR |
| 9569 | IP_STR |
| 9570 | BGP_STR |
| 9571 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9572 | "Neighbor to display information about\n" |
| 9573 | "Neighbor to display information about\n" |
| 9574 | "Display information received from a BGP neighbor\n" |
| 9575 | "Display the prefixlist filter\n") |
| 9576 | { |
| 9577 | char name[BUFSIZ]; |
| 9578 | union sockunion *su; |
| 9579 | struct peer *peer; |
| 9580 | int count; |
| 9581 | |
| 9582 | su = sockunion_str2su (argv[0]); |
| 9583 | if (su == NULL) |
| 9584 | return CMD_WARNING; |
| 9585 | |
| 9586 | peer = peer_lookup (NULL, su); |
| 9587 | if (! peer) |
| 9588 | return CMD_WARNING; |
| 9589 | |
| 9590 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 9591 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 9592 | if (count) |
| 9593 | { |
| 9594 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 9595 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 9596 | } |
| 9597 | |
| 9598 | return CMD_SUCCESS; |
| 9599 | } |
| 9600 | |
| 9601 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 9602 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 9603 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9604 | SHOW_STR |
| 9605 | IP_STR |
| 9606 | BGP_STR |
| 9607 | "Address family\n" |
| 9608 | "Address Family modifier\n" |
| 9609 | "Address Family modifier\n" |
| 9610 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9611 | "Neighbor to display information about\n" |
| 9612 | "Neighbor to display information about\n" |
| 9613 | "Display information received from a BGP neighbor\n" |
| 9614 | "Display the prefixlist filter\n") |
| 9615 | { |
| 9616 | char name[BUFSIZ]; |
| 9617 | union sockunion *su; |
| 9618 | struct peer *peer; |
| 9619 | int count; |
| 9620 | |
| 9621 | su = sockunion_str2su (argv[1]); |
| 9622 | if (su == NULL) |
| 9623 | return CMD_WARNING; |
| 9624 | |
| 9625 | peer = peer_lookup (NULL, su); |
| 9626 | if (! peer) |
| 9627 | return CMD_WARNING; |
| 9628 | |
| 9629 | if (strncmp (argv[0], "m", 1) == 0) |
| 9630 | { |
| 9631 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 9632 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 9633 | if (count) |
| 9634 | { |
| 9635 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 9636 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 9637 | } |
| 9638 | } |
| 9639 | else |
| 9640 | { |
| 9641 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 9642 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 9643 | if (count) |
| 9644 | { |
| 9645 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 9646 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 9647 | } |
| 9648 | } |
| 9649 | |
| 9650 | return CMD_SUCCESS; |
| 9651 | } |
| 9652 | |
| 9653 | |
| 9654 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9655 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9656 | show_bgp_neighbor_received_routes_cmd, |
| 9657 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9658 | SHOW_STR |
| 9659 | BGP_STR |
| 9660 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9661 | "Neighbor to display information about\n" |
| 9662 | "Neighbor to display information about\n" |
| 9663 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9664 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9665 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9666 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 9667 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9668 | SHOW_STR |
| 9669 | BGP_STR |
| 9670 | "Address family\n" |
| 9671 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9672 | "Neighbor to display information about\n" |
| 9673 | "Neighbor to display information about\n" |
| 9674 | "Display the received routes from neighbor\n") |
| 9675 | |
| 9676 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 9677 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 9678 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9679 | SHOW_STR |
| 9680 | BGP_STR |
| 9681 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9682 | "Neighbor to display information about\n" |
| 9683 | "Neighbor to display information about\n" |
| 9684 | "Display information received from a BGP neighbor\n" |
| 9685 | "Display the prefixlist filter\n") |
| 9686 | { |
| 9687 | char name[BUFSIZ]; |
| 9688 | union sockunion *su; |
| 9689 | struct peer *peer; |
| 9690 | int count; |
| 9691 | |
| 9692 | su = sockunion_str2su (argv[0]); |
| 9693 | if (su == NULL) |
| 9694 | return CMD_WARNING; |
| 9695 | |
| 9696 | peer = peer_lookup (NULL, su); |
| 9697 | if (! peer) |
| 9698 | return CMD_WARNING; |
| 9699 | |
| 9700 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 9701 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 9702 | if (count) |
| 9703 | { |
| 9704 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 9705 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 9706 | } |
| 9707 | |
| 9708 | return CMD_SUCCESS; |
| 9709 | } |
| 9710 | |
| 9711 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 9712 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 9713 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9714 | SHOW_STR |
| 9715 | BGP_STR |
| 9716 | "Address family\n" |
| 9717 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9718 | "Neighbor to display information about\n" |
| 9719 | "Neighbor to display information about\n" |
| 9720 | "Display information received from a BGP neighbor\n" |
| 9721 | "Display the prefixlist filter\n") |
| 9722 | |
| 9723 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9724 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9725 | ipv6_bgp_neighbor_received_routes_cmd, |
| 9726 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9727 | SHOW_STR |
| 9728 | IPV6_STR |
| 9729 | BGP_STR |
| 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 the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9734 | |
| 9735 | /* old command */ |
| 9736 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 9737 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 9738 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9739 | SHOW_STR |
| 9740 | IPV6_STR |
| 9741 | MBGP_STR |
| 9742 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9743 | "Neighbor to display information about\n" |
| 9744 | "Neighbor to display information about\n" |
| 9745 | "Display the received routes from neighbor\n") |
| 9746 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9747 | struct peer *peer; |
| 9748 | |
| 9749 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9750 | if (! peer) |
| 9751 | return CMD_WARNING; |
| 9752 | |
| 9753 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9754 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9755 | |
| 9756 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 9757 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 9758 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9759 | SHOW_STR |
| 9760 | BGP_STR |
| 9761 | "BGP view\n" |
| 9762 | "View name\n" |
| 9763 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9764 | "Neighbor to display information about\n" |
| 9765 | "Neighbor to display information about\n" |
| 9766 | "Display information received from a BGP neighbor\n" |
| 9767 | "Display the prefixlist filter\n") |
| 9768 | { |
| 9769 | char name[BUFSIZ]; |
| 9770 | union sockunion *su; |
| 9771 | struct peer *peer; |
| 9772 | struct bgp *bgp; |
| 9773 | int count; |
| 9774 | |
| 9775 | /* BGP structure lookup. */ |
| 9776 | bgp = bgp_lookup_by_name (argv[0]); |
| 9777 | if (bgp == NULL) |
| 9778 | { |
| 9779 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9780 | return CMD_WARNING; |
| 9781 | } |
| 9782 | |
| 9783 | su = sockunion_str2su (argv[1]); |
| 9784 | if (su == NULL) |
| 9785 | return CMD_WARNING; |
| 9786 | |
| 9787 | peer = peer_lookup (bgp, su); |
| 9788 | if (! peer) |
| 9789 | return CMD_WARNING; |
| 9790 | |
| 9791 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 9792 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 9793 | if (count) |
| 9794 | { |
| 9795 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 9796 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 9797 | } |
| 9798 | |
| 9799 | return CMD_SUCCESS; |
| 9800 | } |
| 9801 | |
| 9802 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 9803 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 9804 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9805 | SHOW_STR |
| 9806 | BGP_STR |
| 9807 | "BGP view\n" |
| 9808 | "View name\n" |
| 9809 | "Address family\n" |
| 9810 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9811 | "Neighbor to display information about\n" |
| 9812 | "Neighbor to display information about\n" |
| 9813 | "Display information received from a BGP neighbor\n" |
| 9814 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9815 | #endif /* HAVE_IPV6 */ |
| 9816 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9817 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9818 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9819 | safi_t safi, enum bgp_show_type type) |
| 9820 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9821 | if (! peer || ! peer->afc[afi][safi]) |
| 9822 | { |
| 9823 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9824 | return CMD_WARNING; |
| 9825 | } |
| 9826 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9827 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9828 | } |
| 9829 | |
| 9830 | DEFUN (show_ip_bgp_neighbor_routes, |
| 9831 | show_ip_bgp_neighbor_routes_cmd, |
| 9832 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9833 | SHOW_STR |
| 9834 | IP_STR |
| 9835 | BGP_STR |
| 9836 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9837 | "Neighbor to display information about\n" |
| 9838 | "Neighbor to display information about\n" |
| 9839 | "Display routes learned from neighbor\n") |
| 9840 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9841 | struct peer *peer; |
| 9842 | |
| 9843 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9844 | if (! peer) |
| 9845 | return CMD_WARNING; |
| 9846 | |
| 9847 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9848 | bgp_show_type_neighbor); |
| 9849 | } |
| 9850 | |
| 9851 | DEFUN (show_ip_bgp_neighbor_flap, |
| 9852 | show_ip_bgp_neighbor_flap_cmd, |
| 9853 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9854 | SHOW_STR |
| 9855 | IP_STR |
| 9856 | BGP_STR |
| 9857 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9858 | "Neighbor to display information about\n" |
| 9859 | "Neighbor to display information about\n" |
| 9860 | "Display flap statistics of the routes learned from neighbor\n") |
| 9861 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9862 | struct peer *peer; |
| 9863 | |
| 9864 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9865 | if (! peer) |
| 9866 | return CMD_WARNING; |
| 9867 | |
| 9868 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9869 | bgp_show_type_flap_neighbor); |
| 9870 | } |
| 9871 | |
| 9872 | DEFUN (show_ip_bgp_neighbor_damp, |
| 9873 | show_ip_bgp_neighbor_damp_cmd, |
| 9874 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9875 | SHOW_STR |
| 9876 | IP_STR |
| 9877 | BGP_STR |
| 9878 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9879 | "Neighbor to display information about\n" |
| 9880 | "Neighbor to display information about\n" |
| 9881 | "Display the dampened routes received from neighbor\n") |
| 9882 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9883 | struct peer *peer; |
| 9884 | |
| 9885 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9886 | if (! peer) |
| 9887 | return CMD_WARNING; |
| 9888 | |
| 9889 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9890 | bgp_show_type_damp_neighbor); |
| 9891 | } |
| 9892 | |
| 9893 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 9894 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 9895 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 9896 | SHOW_STR |
| 9897 | IP_STR |
| 9898 | BGP_STR |
| 9899 | "Address family\n" |
| 9900 | "Address Family modifier\n" |
| 9901 | "Address Family modifier\n" |
| 9902 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9903 | "Neighbor to display information about\n" |
| 9904 | "Neighbor to display information about\n" |
| 9905 | "Display routes learned from neighbor\n") |
| 9906 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9907 | struct peer *peer; |
| 9908 | |
| 9909 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9910 | if (! peer) |
| 9911 | return CMD_WARNING; |
| 9912 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9913 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9914 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9915 | bgp_show_type_neighbor); |
| 9916 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9917 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9918 | bgp_show_type_neighbor); |
| 9919 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9920 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9921 | DEFUN (show_ip_bgp_view_rsclient, |
| 9922 | show_ip_bgp_view_rsclient_cmd, |
| 9923 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9924 | SHOW_STR |
| 9925 | IP_STR |
| 9926 | BGP_STR |
| 9927 | "BGP view\n" |
| 9928 | "BGP view name\n" |
| 9929 | "Information about Route Server Client\n" |
| 9930 | NEIGHBOR_ADDR_STR) |
| 9931 | { |
| 9932 | struct bgp_table *table; |
| 9933 | struct peer *peer; |
| 9934 | |
| 9935 | if (argc == 2) |
| 9936 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9937 | else |
| 9938 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9939 | |
| 9940 | if (! peer) |
| 9941 | return CMD_WARNING; |
| 9942 | |
| 9943 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9944 | { |
| 9945 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9946 | VTY_NEWLINE); |
| 9947 | return CMD_WARNING; |
| 9948 | } |
| 9949 | |
| 9950 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9951 | PEER_FLAG_RSERVER_CLIENT)) |
| 9952 | { |
| 9953 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9954 | VTY_NEWLINE); |
| 9955 | return CMD_WARNING; |
| 9956 | } |
| 9957 | |
| 9958 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 9959 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9960 | 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] | 9961 | } |
| 9962 | |
| 9963 | ALIAS (show_ip_bgp_view_rsclient, |
| 9964 | show_ip_bgp_rsclient_cmd, |
| 9965 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9966 | SHOW_STR |
| 9967 | IP_STR |
| 9968 | BGP_STR |
| 9969 | "Information about Route Server Client\n" |
| 9970 | NEIGHBOR_ADDR_STR) |
| 9971 | |
| 9972 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 9973 | show_ip_bgp_view_rsclient_route_cmd, |
| 9974 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 9975 | SHOW_STR |
| 9976 | IP_STR |
| 9977 | BGP_STR |
| 9978 | "BGP view\n" |
| 9979 | "BGP view name\n" |
| 9980 | "Information about Route Server Client\n" |
| 9981 | NEIGHBOR_ADDR_STR |
| 9982 | "Network in the BGP routing table to display\n") |
| 9983 | { |
| 9984 | struct bgp *bgp; |
| 9985 | struct peer *peer; |
| 9986 | |
| 9987 | /* BGP structure lookup. */ |
| 9988 | if (argc == 3) |
| 9989 | { |
| 9990 | bgp = bgp_lookup_by_name (argv[0]); |
| 9991 | if (bgp == NULL) |
| 9992 | { |
| 9993 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9994 | return CMD_WARNING; |
| 9995 | } |
| 9996 | } |
| 9997 | else |
| 9998 | { |
| 9999 | bgp = bgp_get_default (); |
| 10000 | if (bgp == NULL) |
| 10001 | { |
| 10002 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10003 | return CMD_WARNING; |
| 10004 | } |
| 10005 | } |
| 10006 | |
| 10007 | if (argc == 3) |
| 10008 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10009 | else |
| 10010 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10011 | |
| 10012 | if (! peer) |
| 10013 | return CMD_WARNING; |
| 10014 | |
| 10015 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10016 | { |
| 10017 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10018 | VTY_NEWLINE); |
| 10019 | return CMD_WARNING; |
| 10020 | } |
| 10021 | |
| 10022 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10023 | PEER_FLAG_RSERVER_CLIENT)) |
| 10024 | { |
| 10025 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10026 | VTY_NEWLINE); |
| 10027 | return CMD_WARNING; |
| 10028 | } |
| 10029 | |
| 10030 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10031 | (argc == 3) ? argv[2] : argv[1], |
| 10032 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10033 | } |
| 10034 | |
| 10035 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10036 | show_ip_bgp_rsclient_route_cmd, |
| 10037 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10038 | SHOW_STR |
| 10039 | IP_STR |
| 10040 | BGP_STR |
| 10041 | "Information about Route Server Client\n" |
| 10042 | NEIGHBOR_ADDR_STR |
| 10043 | "Network in the BGP routing table to display\n") |
| 10044 | |
| 10045 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10046 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10047 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10048 | SHOW_STR |
| 10049 | IP_STR |
| 10050 | BGP_STR |
| 10051 | "BGP view\n" |
| 10052 | "BGP view name\n" |
| 10053 | "Information about Route Server Client\n" |
| 10054 | NEIGHBOR_ADDR_STR |
| 10055 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10056 | { |
| 10057 | struct bgp *bgp; |
| 10058 | struct peer *peer; |
| 10059 | |
| 10060 | /* BGP structure lookup. */ |
| 10061 | if (argc == 3) |
| 10062 | { |
| 10063 | bgp = bgp_lookup_by_name (argv[0]); |
| 10064 | if (bgp == NULL) |
| 10065 | { |
| 10066 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10067 | return CMD_WARNING; |
| 10068 | } |
| 10069 | } |
| 10070 | else |
| 10071 | { |
| 10072 | bgp = bgp_get_default (); |
| 10073 | if (bgp == NULL) |
| 10074 | { |
| 10075 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10076 | return CMD_WARNING; |
| 10077 | } |
| 10078 | } |
| 10079 | |
| 10080 | if (argc == 3) |
| 10081 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10082 | else |
| 10083 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10084 | |
| 10085 | if (! peer) |
| 10086 | return CMD_WARNING; |
| 10087 | |
| 10088 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10089 | { |
| 10090 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10091 | VTY_NEWLINE); |
| 10092 | return CMD_WARNING; |
| 10093 | } |
| 10094 | |
| 10095 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10096 | PEER_FLAG_RSERVER_CLIENT)) |
| 10097 | { |
| 10098 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10099 | VTY_NEWLINE); |
| 10100 | return CMD_WARNING; |
| 10101 | } |
| 10102 | |
| 10103 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10104 | (argc == 3) ? argv[2] : argv[1], |
| 10105 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 10106 | } |
| 10107 | |
| 10108 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 10109 | show_ip_bgp_rsclient_prefix_cmd, |
| 10110 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10111 | SHOW_STR |
| 10112 | IP_STR |
| 10113 | BGP_STR |
| 10114 | "Information about Route Server Client\n" |
| 10115 | NEIGHBOR_ADDR_STR |
| 10116 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10117 | |
| 10118 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10119 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10120 | DEFUN (show_bgp_view_neighbor_routes, |
| 10121 | show_bgp_view_neighbor_routes_cmd, |
| 10122 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 10123 | SHOW_STR |
| 10124 | BGP_STR |
| 10125 | "BGP view\n" |
| 10126 | "BGP view name\n" |
| 10127 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10128 | "Neighbor to display information about\n" |
| 10129 | "Neighbor to display information about\n" |
| 10130 | "Display routes learned from neighbor\n") |
| 10131 | { |
| 10132 | struct peer *peer; |
| 10133 | |
| 10134 | if (argc == 2) |
| 10135 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10136 | else |
| 10137 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10138 | |
| 10139 | if (! peer) |
| 10140 | return CMD_WARNING; |
| 10141 | |
| 10142 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 10143 | bgp_show_type_neighbor); |
| 10144 | } |
| 10145 | |
| 10146 | ALIAS (show_bgp_view_neighbor_routes, |
| 10147 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 10148 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 10149 | SHOW_STR |
| 10150 | BGP_STR |
| 10151 | "BGP view\n" |
| 10152 | "BGP view name\n" |
| 10153 | "Address family\n" |
| 10154 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10155 | "Neighbor to display information about\n" |
| 10156 | "Neighbor to display information about\n" |
| 10157 | "Display routes learned from neighbor\n") |
| 10158 | |
| 10159 | DEFUN (show_bgp_view_neighbor_damp, |
| 10160 | show_bgp_view_neighbor_damp_cmd, |
| 10161 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10162 | SHOW_STR |
| 10163 | BGP_STR |
| 10164 | "BGP view\n" |
| 10165 | "BGP view name\n" |
| 10166 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10167 | "Neighbor to display information about\n" |
| 10168 | "Neighbor to display information about\n" |
| 10169 | "Display the dampened routes received from neighbor\n") |
| 10170 | { |
| 10171 | struct peer *peer; |
| 10172 | |
| 10173 | if (argc == 2) |
| 10174 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10175 | else |
| 10176 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10177 | |
| 10178 | if (! peer) |
| 10179 | return CMD_WARNING; |
| 10180 | |
| 10181 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 10182 | bgp_show_type_damp_neighbor); |
| 10183 | } |
| 10184 | |
| 10185 | ALIAS (show_bgp_view_neighbor_damp, |
| 10186 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 10187 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10188 | SHOW_STR |
| 10189 | BGP_STR |
| 10190 | "BGP view\n" |
| 10191 | "BGP view name\n" |
| 10192 | "Address family\n" |
| 10193 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10194 | "Neighbor to display information about\n" |
| 10195 | "Neighbor to display information about\n" |
| 10196 | "Display the dampened routes received from neighbor\n") |
| 10197 | |
| 10198 | DEFUN (show_bgp_view_neighbor_flap, |
| 10199 | show_bgp_view_neighbor_flap_cmd, |
| 10200 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10201 | SHOW_STR |
| 10202 | BGP_STR |
| 10203 | "BGP view\n" |
| 10204 | "BGP view name\n" |
| 10205 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10206 | "Neighbor to display information about\n" |
| 10207 | "Neighbor to display information about\n" |
| 10208 | "Display flap statistics of the routes learned from neighbor\n") |
| 10209 | { |
| 10210 | struct peer *peer; |
| 10211 | |
| 10212 | if (argc == 2) |
| 10213 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10214 | else |
| 10215 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10216 | |
| 10217 | if (! peer) |
| 10218 | return CMD_WARNING; |
| 10219 | |
| 10220 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 10221 | bgp_show_type_flap_neighbor); |
| 10222 | } |
| 10223 | |
| 10224 | ALIAS (show_bgp_view_neighbor_flap, |
| 10225 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 10226 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10227 | SHOW_STR |
| 10228 | BGP_STR |
| 10229 | "BGP view\n" |
| 10230 | "BGP view name\n" |
| 10231 | "Address family\n" |
| 10232 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10233 | "Neighbor to display information about\n" |
| 10234 | "Neighbor to display information about\n" |
| 10235 | "Display flap statistics of the routes learned from neighbor\n") |
| 10236 | |
| 10237 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10238 | show_bgp_neighbor_routes_cmd, |
| 10239 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10240 | SHOW_STR |
| 10241 | BGP_STR |
| 10242 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10243 | "Neighbor to display information about\n" |
| 10244 | "Neighbor to display information about\n" |
| 10245 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10246 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10247 | |
| 10248 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10249 | show_bgp_ipv6_neighbor_routes_cmd, |
| 10250 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 10251 | SHOW_STR |
| 10252 | BGP_STR |
| 10253 | "Address family\n" |
| 10254 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10255 | "Neighbor to display information about\n" |
| 10256 | "Neighbor to display information about\n" |
| 10257 | "Display routes learned from neighbor\n") |
| 10258 | |
| 10259 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10260 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10261 | ipv6_bgp_neighbor_routes_cmd, |
| 10262 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10263 | SHOW_STR |
| 10264 | IPV6_STR |
| 10265 | BGP_STR |
| 10266 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10267 | "Neighbor to display information about\n" |
| 10268 | "Neighbor to display information about\n" |
| 10269 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10270 | |
| 10271 | /* old command */ |
| 10272 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 10273 | ipv6_mbgp_neighbor_routes_cmd, |
| 10274 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10275 | SHOW_STR |
| 10276 | IPV6_STR |
| 10277 | MBGP_STR |
| 10278 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10279 | "Neighbor to display information about\n" |
| 10280 | "Neighbor to display information about\n" |
| 10281 | "Display routes learned from neighbor\n") |
| 10282 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10283 | struct peer *peer; |
| 10284 | |
| 10285 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10286 | if (! peer) |
| 10287 | return CMD_WARNING; |
| 10288 | |
| 10289 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10290 | bgp_show_type_neighbor); |
| 10291 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10292 | |
| 10293 | ALIAS (show_bgp_view_neighbor_flap, |
| 10294 | show_bgp_neighbor_flap_cmd, |
| 10295 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10296 | SHOW_STR |
| 10297 | BGP_STR |
| 10298 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10299 | "Neighbor to display information about\n" |
| 10300 | "Neighbor to display information about\n" |
| 10301 | "Display flap statistics of the routes learned from neighbor\n") |
| 10302 | |
| 10303 | ALIAS (show_bgp_view_neighbor_flap, |
| 10304 | show_bgp_ipv6_neighbor_flap_cmd, |
| 10305 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10306 | SHOW_STR |
| 10307 | BGP_STR |
| 10308 | "Address family\n" |
| 10309 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10310 | "Neighbor to display information about\n" |
| 10311 | "Neighbor to display information about\n" |
| 10312 | "Display flap statistics of the routes learned from neighbor\n") |
| 10313 | |
| 10314 | ALIAS (show_bgp_view_neighbor_damp, |
| 10315 | show_bgp_neighbor_damp_cmd, |
| 10316 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10317 | SHOW_STR |
| 10318 | BGP_STR |
| 10319 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10320 | "Neighbor to display information about\n" |
| 10321 | "Neighbor to display information about\n" |
| 10322 | "Display the dampened routes received from neighbor\n") |
| 10323 | |
| 10324 | ALIAS (show_bgp_view_neighbor_damp, |
| 10325 | show_bgp_ipv6_neighbor_damp_cmd, |
| 10326 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10327 | SHOW_STR |
| 10328 | BGP_STR |
| 10329 | "Address family\n" |
| 10330 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10331 | "Neighbor to display information about\n" |
| 10332 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 10333 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10334 | |
| 10335 | DEFUN (show_bgp_view_rsclient, |
| 10336 | show_bgp_view_rsclient_cmd, |
| 10337 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10338 | SHOW_STR |
| 10339 | BGP_STR |
| 10340 | "BGP view\n" |
| 10341 | "BGP view name\n" |
| 10342 | "Information about Route Server Client\n" |
| 10343 | NEIGHBOR_ADDR_STR) |
| 10344 | { |
| 10345 | struct bgp_table *table; |
| 10346 | struct peer *peer; |
| 10347 | |
| 10348 | if (argc == 2) |
| 10349 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10350 | else |
| 10351 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10352 | |
| 10353 | if (! peer) |
| 10354 | return CMD_WARNING; |
| 10355 | |
| 10356 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 10357 | { |
| 10358 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10359 | VTY_NEWLINE); |
| 10360 | return CMD_WARNING; |
| 10361 | } |
| 10362 | |
| 10363 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 10364 | PEER_FLAG_RSERVER_CLIENT)) |
| 10365 | { |
| 10366 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10367 | VTY_NEWLINE); |
| 10368 | return CMD_WARNING; |
| 10369 | } |
| 10370 | |
| 10371 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 10372 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10373 | 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] | 10374 | } |
| 10375 | |
| 10376 | ALIAS (show_bgp_view_rsclient, |
| 10377 | show_bgp_rsclient_cmd, |
| 10378 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10379 | SHOW_STR |
| 10380 | BGP_STR |
| 10381 | "Information about Route Server Client\n" |
| 10382 | NEIGHBOR_ADDR_STR) |
| 10383 | |
| 10384 | DEFUN (show_bgp_view_rsclient_route, |
| 10385 | show_bgp_view_rsclient_route_cmd, |
| 10386 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 10387 | SHOW_STR |
| 10388 | BGP_STR |
| 10389 | "BGP view\n" |
| 10390 | "BGP view name\n" |
| 10391 | "Information about Route Server Client\n" |
| 10392 | NEIGHBOR_ADDR_STR |
| 10393 | "Network in the BGP routing table to display\n") |
| 10394 | { |
| 10395 | struct bgp *bgp; |
| 10396 | struct peer *peer; |
| 10397 | |
| 10398 | /* BGP structure lookup. */ |
| 10399 | if (argc == 3) |
| 10400 | { |
| 10401 | bgp = bgp_lookup_by_name (argv[0]); |
| 10402 | if (bgp == NULL) |
| 10403 | { |
| 10404 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10405 | return CMD_WARNING; |
| 10406 | } |
| 10407 | } |
| 10408 | else |
| 10409 | { |
| 10410 | bgp = bgp_get_default (); |
| 10411 | if (bgp == NULL) |
| 10412 | { |
| 10413 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10414 | return CMD_WARNING; |
| 10415 | } |
| 10416 | } |
| 10417 | |
| 10418 | if (argc == 3) |
| 10419 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10420 | else |
| 10421 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10422 | |
| 10423 | if (! peer) |
| 10424 | return CMD_WARNING; |
| 10425 | |
| 10426 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 10427 | { |
| 10428 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10429 | VTY_NEWLINE); |
| 10430 | return CMD_WARNING; |
| 10431 | } |
| 10432 | |
| 10433 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 10434 | PEER_FLAG_RSERVER_CLIENT)) |
| 10435 | { |
| 10436 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10437 | VTY_NEWLINE); |
| 10438 | return CMD_WARNING; |
| 10439 | } |
| 10440 | |
| 10441 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 10442 | (argc == 3) ? argv[2] : argv[1], |
| 10443 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 10444 | } |
| 10445 | |
| 10446 | ALIAS (show_bgp_view_rsclient_route, |
| 10447 | show_bgp_rsclient_route_cmd, |
| 10448 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 10449 | SHOW_STR |
| 10450 | BGP_STR |
| 10451 | "Information about Route Server Client\n" |
| 10452 | NEIGHBOR_ADDR_STR |
| 10453 | "Network in the BGP routing table to display\n") |
| 10454 | |
| 10455 | DEFUN (show_bgp_view_rsclient_prefix, |
| 10456 | show_bgp_view_rsclient_prefix_cmd, |
| 10457 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 10458 | SHOW_STR |
| 10459 | BGP_STR |
| 10460 | "BGP view\n" |
| 10461 | "BGP view name\n" |
| 10462 | "Information about Route Server Client\n" |
| 10463 | NEIGHBOR_ADDR_STR |
| 10464 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 10465 | { |
| 10466 | struct bgp *bgp; |
| 10467 | struct peer *peer; |
| 10468 | |
| 10469 | /* BGP structure lookup. */ |
| 10470 | if (argc == 3) |
| 10471 | { |
| 10472 | bgp = bgp_lookup_by_name (argv[0]); |
| 10473 | if (bgp == NULL) |
| 10474 | { |
| 10475 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10476 | return CMD_WARNING; |
| 10477 | } |
| 10478 | } |
| 10479 | else |
| 10480 | { |
| 10481 | bgp = bgp_get_default (); |
| 10482 | if (bgp == NULL) |
| 10483 | { |
| 10484 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10485 | return CMD_WARNING; |
| 10486 | } |
| 10487 | } |
| 10488 | |
| 10489 | if (argc == 3) |
| 10490 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10491 | else |
| 10492 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10493 | |
| 10494 | if (! peer) |
| 10495 | return CMD_WARNING; |
| 10496 | |
| 10497 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 10498 | { |
| 10499 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10500 | VTY_NEWLINE); |
| 10501 | return CMD_WARNING; |
| 10502 | } |
| 10503 | |
| 10504 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 10505 | PEER_FLAG_RSERVER_CLIENT)) |
| 10506 | { |
| 10507 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10508 | VTY_NEWLINE); |
| 10509 | return CMD_WARNING; |
| 10510 | } |
| 10511 | |
| 10512 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 10513 | (argc == 3) ? argv[2] : argv[1], |
| 10514 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 10515 | } |
| 10516 | |
| 10517 | ALIAS (show_bgp_view_rsclient_prefix, |
| 10518 | show_bgp_rsclient_prefix_cmd, |
| 10519 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 10520 | SHOW_STR |
| 10521 | BGP_STR |
| 10522 | "Information about Route Server Client\n" |
| 10523 | NEIGHBOR_ADDR_STR |
| 10524 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 10525 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10526 | #endif /* HAVE_IPV6 */ |
| 10527 | |
| 10528 | struct bgp_table *bgp_distance_table; |
| 10529 | |
| 10530 | struct bgp_distance |
| 10531 | { |
| 10532 | /* Distance value for the IP source prefix. */ |
| 10533 | u_char distance; |
| 10534 | |
| 10535 | /* Name of the access-list to be matched. */ |
| 10536 | char *access_list; |
| 10537 | }; |
| 10538 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10539 | static struct bgp_distance * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10540 | bgp_distance_new () |
| 10541 | { |
| 10542 | struct bgp_distance *new; |
| 10543 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 10544 | memset (new, 0, sizeof (struct bgp_distance)); |
| 10545 | return new; |
| 10546 | } |
| 10547 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10548 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10549 | bgp_distance_free (struct bgp_distance *bdistance) |
| 10550 | { |
| 10551 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 10552 | } |
| 10553 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10554 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10555 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 10556 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10557 | { |
| 10558 | int ret; |
| 10559 | struct prefix_ipv4 p; |
| 10560 | u_char distance; |
| 10561 | struct bgp_node *rn; |
| 10562 | struct bgp_distance *bdistance; |
| 10563 | |
| 10564 | ret = str2prefix_ipv4 (ip_str, &p); |
| 10565 | if (ret == 0) |
| 10566 | { |
| 10567 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 10568 | return CMD_WARNING; |
| 10569 | } |
| 10570 | |
| 10571 | distance = atoi (distance_str); |
| 10572 | |
| 10573 | /* Get BGP distance node. */ |
| 10574 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 10575 | if (rn->info) |
| 10576 | { |
| 10577 | bdistance = rn->info; |
| 10578 | bgp_unlock_node (rn); |
| 10579 | } |
| 10580 | else |
| 10581 | { |
| 10582 | bdistance = bgp_distance_new (); |
| 10583 | rn->info = bdistance; |
| 10584 | } |
| 10585 | |
| 10586 | /* Set distance value. */ |
| 10587 | bdistance->distance = distance; |
| 10588 | |
| 10589 | /* Reset access-list configuration. */ |
| 10590 | if (bdistance->access_list) |
| 10591 | { |
| 10592 | free (bdistance->access_list); |
| 10593 | bdistance->access_list = NULL; |
| 10594 | } |
| 10595 | if (access_list_str) |
| 10596 | bdistance->access_list = strdup (access_list_str); |
| 10597 | |
| 10598 | return CMD_SUCCESS; |
| 10599 | } |
| 10600 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10601 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10602 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 10603 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10604 | { |
| 10605 | int ret; |
| 10606 | struct prefix_ipv4 p; |
| 10607 | u_char distance; |
| 10608 | struct bgp_node *rn; |
| 10609 | struct bgp_distance *bdistance; |
| 10610 | |
| 10611 | ret = str2prefix_ipv4 (ip_str, &p); |
| 10612 | if (ret == 0) |
| 10613 | { |
| 10614 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 10615 | return CMD_WARNING; |
| 10616 | } |
| 10617 | |
| 10618 | distance = atoi (distance_str); |
| 10619 | |
| 10620 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 10621 | if (! rn) |
| 10622 | { |
| 10623 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 10624 | return CMD_WARNING; |
| 10625 | } |
| 10626 | |
| 10627 | bdistance = rn->info; |
| 10628 | |
| 10629 | if (bdistance->access_list) |
| 10630 | free (bdistance->access_list); |
| 10631 | bgp_distance_free (bdistance); |
| 10632 | |
| 10633 | rn->info = NULL; |
| 10634 | bgp_unlock_node (rn); |
| 10635 | bgp_unlock_node (rn); |
| 10636 | |
| 10637 | return CMD_SUCCESS; |
| 10638 | } |
| 10639 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10640 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10641 | bgp_distance_reset () |
| 10642 | { |
| 10643 | struct bgp_node *rn; |
| 10644 | struct bgp_distance *bdistance; |
| 10645 | |
| 10646 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 10647 | if ((bdistance = rn->info) != NULL) |
| 10648 | { |
| 10649 | if (bdistance->access_list) |
| 10650 | free (bdistance->access_list); |
| 10651 | bgp_distance_free (bdistance); |
| 10652 | rn->info = NULL; |
| 10653 | bgp_unlock_node (rn); |
| 10654 | } |
| 10655 | } |
| 10656 | |
| 10657 | /* Apply BGP information to distance method. */ |
| 10658 | u_char |
| 10659 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 10660 | { |
| 10661 | struct bgp_node *rn; |
| 10662 | struct prefix_ipv4 q; |
| 10663 | struct peer *peer; |
| 10664 | struct bgp_distance *bdistance; |
| 10665 | struct access_list *alist; |
| 10666 | struct bgp_static *bgp_static; |
| 10667 | |
| 10668 | if (! bgp) |
| 10669 | return 0; |
| 10670 | |
| 10671 | if (p->family != AF_INET) |
| 10672 | return 0; |
| 10673 | |
| 10674 | peer = rinfo->peer; |
| 10675 | |
| 10676 | if (peer->su.sa.sa_family != AF_INET) |
| 10677 | return 0; |
| 10678 | |
| 10679 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 10680 | q.family = AF_INET; |
| 10681 | q.prefix = peer->su.sin.sin_addr; |
| 10682 | q.prefixlen = IPV4_MAX_BITLEN; |
| 10683 | |
| 10684 | /* Check source address. */ |
| 10685 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 10686 | if (rn) |
| 10687 | { |
| 10688 | bdistance = rn->info; |
| 10689 | bgp_unlock_node (rn); |
| 10690 | |
| 10691 | if (bdistance->access_list) |
| 10692 | { |
| 10693 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 10694 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 10695 | return bdistance->distance; |
| 10696 | } |
| 10697 | else |
| 10698 | return bdistance->distance; |
| 10699 | } |
| 10700 | |
| 10701 | /* Backdoor check. */ |
| 10702 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 10703 | if (rn) |
| 10704 | { |
| 10705 | bgp_static = rn->info; |
| 10706 | bgp_unlock_node (rn); |
| 10707 | |
| 10708 | if (bgp_static->backdoor) |
| 10709 | { |
| 10710 | if (bgp->distance_local) |
| 10711 | return bgp->distance_local; |
| 10712 | else |
| 10713 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 10714 | } |
| 10715 | } |
| 10716 | |
| 10717 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 10718 | { |
| 10719 | if (bgp->distance_ebgp) |
| 10720 | return bgp->distance_ebgp; |
| 10721 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 10722 | } |
| 10723 | else |
| 10724 | { |
| 10725 | if (bgp->distance_ibgp) |
| 10726 | return bgp->distance_ibgp; |
| 10727 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 10728 | } |
| 10729 | } |
| 10730 | |
| 10731 | DEFUN (bgp_distance, |
| 10732 | bgp_distance_cmd, |
| 10733 | "distance bgp <1-255> <1-255> <1-255>", |
| 10734 | "Define an administrative distance\n" |
| 10735 | "BGP distance\n" |
| 10736 | "Distance for routes external to the AS\n" |
| 10737 | "Distance for routes internal to the AS\n" |
| 10738 | "Distance for local routes\n") |
| 10739 | { |
| 10740 | struct bgp *bgp; |
| 10741 | |
| 10742 | bgp = vty->index; |
| 10743 | |
| 10744 | bgp->distance_ebgp = atoi (argv[0]); |
| 10745 | bgp->distance_ibgp = atoi (argv[1]); |
| 10746 | bgp->distance_local = atoi (argv[2]); |
| 10747 | return CMD_SUCCESS; |
| 10748 | } |
| 10749 | |
| 10750 | DEFUN (no_bgp_distance, |
| 10751 | no_bgp_distance_cmd, |
| 10752 | "no distance bgp <1-255> <1-255> <1-255>", |
| 10753 | NO_STR |
| 10754 | "Define an administrative distance\n" |
| 10755 | "BGP distance\n" |
| 10756 | "Distance for routes external to the AS\n" |
| 10757 | "Distance for routes internal to the AS\n" |
| 10758 | "Distance for local routes\n") |
| 10759 | { |
| 10760 | struct bgp *bgp; |
| 10761 | |
| 10762 | bgp = vty->index; |
| 10763 | |
| 10764 | bgp->distance_ebgp= 0; |
| 10765 | bgp->distance_ibgp = 0; |
| 10766 | bgp->distance_local = 0; |
| 10767 | return CMD_SUCCESS; |
| 10768 | } |
| 10769 | |
| 10770 | ALIAS (no_bgp_distance, |
| 10771 | no_bgp_distance2_cmd, |
| 10772 | "no distance bgp", |
| 10773 | NO_STR |
| 10774 | "Define an administrative distance\n" |
| 10775 | "BGP distance\n") |
| 10776 | |
| 10777 | DEFUN (bgp_distance_source, |
| 10778 | bgp_distance_source_cmd, |
| 10779 | "distance <1-255> A.B.C.D/M", |
| 10780 | "Define an administrative distance\n" |
| 10781 | "Administrative distance\n" |
| 10782 | "IP source prefix\n") |
| 10783 | { |
| 10784 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 10785 | return CMD_SUCCESS; |
| 10786 | } |
| 10787 | |
| 10788 | DEFUN (no_bgp_distance_source, |
| 10789 | no_bgp_distance_source_cmd, |
| 10790 | "no distance <1-255> A.B.C.D/M", |
| 10791 | NO_STR |
| 10792 | "Define an administrative distance\n" |
| 10793 | "Administrative distance\n" |
| 10794 | "IP source prefix\n") |
| 10795 | { |
| 10796 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 10797 | return CMD_SUCCESS; |
| 10798 | } |
| 10799 | |
| 10800 | DEFUN (bgp_distance_source_access_list, |
| 10801 | bgp_distance_source_access_list_cmd, |
| 10802 | "distance <1-255> A.B.C.D/M WORD", |
| 10803 | "Define an administrative distance\n" |
| 10804 | "Administrative distance\n" |
| 10805 | "IP source prefix\n" |
| 10806 | "Access list name\n") |
| 10807 | { |
| 10808 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 10809 | return CMD_SUCCESS; |
| 10810 | } |
| 10811 | |
| 10812 | DEFUN (no_bgp_distance_source_access_list, |
| 10813 | no_bgp_distance_source_access_list_cmd, |
| 10814 | "no distance <1-255> A.B.C.D/M WORD", |
| 10815 | NO_STR |
| 10816 | "Define an administrative distance\n" |
| 10817 | "Administrative distance\n" |
| 10818 | "IP source prefix\n" |
| 10819 | "Access list name\n") |
| 10820 | { |
| 10821 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 10822 | return CMD_SUCCESS; |
| 10823 | } |
| 10824 | |
| 10825 | DEFUN (bgp_damp_set, |
| 10826 | bgp_damp_set_cmd, |
| 10827 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 10828 | "BGP Specific commands\n" |
| 10829 | "Enable route-flap dampening\n" |
| 10830 | "Half-life time for the penalty\n" |
| 10831 | "Value to start reusing a route\n" |
| 10832 | "Value to start suppressing a route\n" |
| 10833 | "Maximum duration to suppress a stable route\n") |
| 10834 | { |
| 10835 | struct bgp *bgp; |
| 10836 | int half = DEFAULT_HALF_LIFE * 60; |
| 10837 | int reuse = DEFAULT_REUSE; |
| 10838 | int suppress = DEFAULT_SUPPRESS; |
| 10839 | int max = 4 * half; |
| 10840 | |
| 10841 | if (argc == 4) |
| 10842 | { |
| 10843 | half = atoi (argv[0]) * 60; |
| 10844 | reuse = atoi (argv[1]); |
| 10845 | suppress = atoi (argv[2]); |
| 10846 | max = atoi (argv[3]) * 60; |
| 10847 | } |
| 10848 | else if (argc == 1) |
| 10849 | { |
| 10850 | half = atoi (argv[0]) * 60; |
| 10851 | max = 4 * half; |
| 10852 | } |
| 10853 | |
| 10854 | bgp = vty->index; |
| 10855 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 10856 | half, reuse, suppress, max); |
| 10857 | } |
| 10858 | |
| 10859 | ALIAS (bgp_damp_set, |
| 10860 | bgp_damp_set2_cmd, |
| 10861 | "bgp dampening <1-45>", |
| 10862 | "BGP Specific commands\n" |
| 10863 | "Enable route-flap dampening\n" |
| 10864 | "Half-life time for the penalty\n") |
| 10865 | |
| 10866 | ALIAS (bgp_damp_set, |
| 10867 | bgp_damp_set3_cmd, |
| 10868 | "bgp dampening", |
| 10869 | "BGP Specific commands\n" |
| 10870 | "Enable route-flap dampening\n") |
| 10871 | |
| 10872 | DEFUN (bgp_damp_unset, |
| 10873 | bgp_damp_unset_cmd, |
| 10874 | "no bgp dampening", |
| 10875 | NO_STR |
| 10876 | "BGP Specific commands\n" |
| 10877 | "Enable route-flap dampening\n") |
| 10878 | { |
| 10879 | struct bgp *bgp; |
| 10880 | |
| 10881 | bgp = vty->index; |
| 10882 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 10883 | } |
| 10884 | |
| 10885 | ALIAS (bgp_damp_unset, |
| 10886 | bgp_damp_unset2_cmd, |
| 10887 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 10888 | NO_STR |
| 10889 | "BGP Specific commands\n" |
| 10890 | "Enable route-flap dampening\n" |
| 10891 | "Half-life time for the penalty\n" |
| 10892 | "Value to start reusing a route\n" |
| 10893 | "Value to start suppressing a route\n" |
| 10894 | "Maximum duration to suppress a stable route\n") |
| 10895 | |
| 10896 | DEFUN (show_ip_bgp_dampened_paths, |
| 10897 | show_ip_bgp_dampened_paths_cmd, |
| 10898 | "show ip bgp dampened-paths", |
| 10899 | SHOW_STR |
| 10900 | IP_STR |
| 10901 | BGP_STR |
| 10902 | "Display paths suppressed due to dampening\n") |
| 10903 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10904 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 10905 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10906 | } |
| 10907 | |
| 10908 | DEFUN (show_ip_bgp_flap_statistics, |
| 10909 | show_ip_bgp_flap_statistics_cmd, |
| 10910 | "show ip bgp flap-statistics", |
| 10911 | SHOW_STR |
| 10912 | IP_STR |
| 10913 | BGP_STR |
| 10914 | "Display flap statistics of routes\n") |
| 10915 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10916 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 10917 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10918 | } |
| 10919 | |
| 10920 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10921 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10922 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 10923 | const char *ip_str, afi_t afi, safi_t safi, |
| 10924 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10925 | { |
| 10926 | int ret; |
| 10927 | struct prefix match; |
| 10928 | struct bgp_node *rn; |
| 10929 | struct bgp_node *rm; |
| 10930 | struct bgp_info *ri; |
| 10931 | struct bgp_info *ri_temp; |
| 10932 | struct bgp *bgp; |
| 10933 | struct bgp_table *table; |
| 10934 | |
| 10935 | /* BGP structure lookup. */ |
| 10936 | if (view_name) |
| 10937 | { |
| 10938 | bgp = bgp_lookup_by_name (view_name); |
| 10939 | if (bgp == NULL) |
| 10940 | { |
| 10941 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, 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 | /* Check IP address argument. */ |
| 10956 | ret = str2prefix (ip_str, &match); |
| 10957 | if (! ret) |
| 10958 | { |
| 10959 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 10960 | return CMD_WARNING; |
| 10961 | } |
| 10962 | |
| 10963 | match.family = afi2family (afi); |
| 10964 | |
| 10965 | if (safi == SAFI_MPLS_VPN) |
| 10966 | { |
| 10967 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 10968 | { |
| 10969 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 10970 | continue; |
| 10971 | |
| 10972 | if ((table = rn->info) != NULL) |
| 10973 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 10974 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 10975 | { |
| 10976 | ri = rm->info; |
| 10977 | while (ri) |
| 10978 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 10979 | if (ri->extra && ri->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10980 | { |
| 10981 | ri_temp = ri->next; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 10982 | bgp_damp_info_free (ri->extra->damp_info, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10983 | ri = ri_temp; |
| 10984 | } |
| 10985 | else |
| 10986 | ri = ri->next; |
| 10987 | } |
| 10988 | } |
| 10989 | } |
| 10990 | } |
| 10991 | else |
| 10992 | { |
| 10993 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 10994 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 10995 | { |
| 10996 | ri = rn->info; |
| 10997 | while (ri) |
| 10998 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 10999 | if (ri->extra && ri->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11000 | { |
| 11001 | ri_temp = ri->next; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 11002 | bgp_damp_info_free (ri->extra->damp_info, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11003 | ri = ri_temp; |
| 11004 | } |
| 11005 | else |
| 11006 | ri = ri->next; |
| 11007 | } |
| 11008 | } |
| 11009 | } |
| 11010 | |
| 11011 | return CMD_SUCCESS; |
| 11012 | } |
| 11013 | |
| 11014 | DEFUN (clear_ip_bgp_dampening, |
| 11015 | clear_ip_bgp_dampening_cmd, |
| 11016 | "clear ip bgp dampening", |
| 11017 | CLEAR_STR |
| 11018 | IP_STR |
| 11019 | BGP_STR |
| 11020 | "Clear route flap dampening information\n") |
| 11021 | { |
| 11022 | bgp_damp_info_clean (); |
| 11023 | return CMD_SUCCESS; |
| 11024 | } |
| 11025 | |
| 11026 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 11027 | clear_ip_bgp_dampening_prefix_cmd, |
| 11028 | "clear ip bgp dampening A.B.C.D/M", |
| 11029 | CLEAR_STR |
| 11030 | IP_STR |
| 11031 | BGP_STR |
| 11032 | "Clear route flap dampening information\n" |
| 11033 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11034 | { |
| 11035 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 11036 | SAFI_UNICAST, NULL, 1); |
| 11037 | } |
| 11038 | |
| 11039 | DEFUN (clear_ip_bgp_dampening_address, |
| 11040 | clear_ip_bgp_dampening_address_cmd, |
| 11041 | "clear ip bgp dampening A.B.C.D", |
| 11042 | CLEAR_STR |
| 11043 | IP_STR |
| 11044 | BGP_STR |
| 11045 | "Clear route flap dampening information\n" |
| 11046 | "Network to clear damping information\n") |
| 11047 | { |
| 11048 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 11049 | SAFI_UNICAST, NULL, 0); |
| 11050 | } |
| 11051 | |
| 11052 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 11053 | clear_ip_bgp_dampening_address_mask_cmd, |
| 11054 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 11055 | CLEAR_STR |
| 11056 | IP_STR |
| 11057 | BGP_STR |
| 11058 | "Clear route flap dampening information\n" |
| 11059 | "Network to clear damping information\n" |
| 11060 | "Network mask\n") |
| 11061 | { |
| 11062 | int ret; |
| 11063 | char prefix_str[BUFSIZ]; |
| 11064 | |
| 11065 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 11066 | if (! ret) |
| 11067 | { |
| 11068 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 11069 | return CMD_WARNING; |
| 11070 | } |
| 11071 | |
| 11072 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 11073 | SAFI_UNICAST, NULL, 0); |
| 11074 | } |
| 11075 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11076 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11077 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 11078 | afi_t afi, safi_t safi, int *write) |
| 11079 | { |
| 11080 | struct bgp_node *prn; |
| 11081 | struct bgp_node *rn; |
| 11082 | struct bgp_table *table; |
| 11083 | struct prefix *p; |
| 11084 | struct prefix_rd *prd; |
| 11085 | struct bgp_static *bgp_static; |
| 11086 | u_int32_t label; |
| 11087 | char buf[SU_ADDRSTRLEN]; |
| 11088 | char rdbuf[RD_ADDRSTRLEN]; |
| 11089 | |
| 11090 | /* Network configuration. */ |
| 11091 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 11092 | if ((table = prn->info) != NULL) |
| 11093 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 11094 | if ((bgp_static = rn->info) != NULL) |
| 11095 | { |
| 11096 | p = &rn->p; |
| 11097 | prd = (struct prefix_rd *) &prn->p; |
| 11098 | |
| 11099 | /* "address-family" display. */ |
| 11100 | bgp_config_write_family_header (vty, afi, safi, write); |
| 11101 | |
| 11102 | /* "network" configuration display. */ |
| 11103 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 11104 | label = decode_label (bgp_static->tag); |
| 11105 | |
| 11106 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 11107 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 11108 | p->prefixlen, |
| 11109 | rdbuf, label); |
| 11110 | vty_out (vty, "%s", VTY_NEWLINE); |
| 11111 | } |
| 11112 | return 0; |
| 11113 | } |
| 11114 | |
| 11115 | /* Configuration of static route announcement and aggregate |
| 11116 | information. */ |
| 11117 | int |
| 11118 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 11119 | afi_t afi, safi_t safi, int *write) |
| 11120 | { |
| 11121 | struct bgp_node *rn; |
| 11122 | struct prefix *p; |
| 11123 | struct bgp_static *bgp_static; |
| 11124 | struct bgp_aggregate *bgp_aggregate; |
| 11125 | char buf[SU_ADDRSTRLEN]; |
| 11126 | |
| 11127 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 11128 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 11129 | |
| 11130 | /* Network configuration. */ |
| 11131 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 11132 | if ((bgp_static = rn->info) != NULL) |
| 11133 | { |
| 11134 | p = &rn->p; |
| 11135 | |
| 11136 | /* "address-family" display. */ |
| 11137 | bgp_config_write_family_header (vty, afi, safi, write); |
| 11138 | |
| 11139 | /* "network" configuration display. */ |
| 11140 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 11141 | { |
| 11142 | u_int32_t destination; |
| 11143 | struct in_addr netmask; |
| 11144 | |
| 11145 | destination = ntohl (p->u.prefix4.s_addr); |
| 11146 | masklen2ip (p->prefixlen, &netmask); |
| 11147 | vty_out (vty, " network %s", |
| 11148 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 11149 | |
| 11150 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 11151 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 11152 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 11153 | || p->u.prefix4.s_addr == 0) |
| 11154 | { |
| 11155 | /* Natural mask is not display. */ |
| 11156 | } |
| 11157 | else |
| 11158 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 11159 | } |
| 11160 | else |
| 11161 | { |
| 11162 | vty_out (vty, " network %s/%d", |
| 11163 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 11164 | p->prefixlen); |
| 11165 | } |
| 11166 | |
| 11167 | if (bgp_static->rmap.name) |
| 11168 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 11169 | else if (bgp_static->backdoor) |
| 11170 | vty_out (vty, " backdoor"); |
| 11171 | |
| 11172 | vty_out (vty, "%s", VTY_NEWLINE); |
| 11173 | } |
| 11174 | |
| 11175 | /* Aggregate-address configuration. */ |
| 11176 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 11177 | if ((bgp_aggregate = rn->info) != NULL) |
| 11178 | { |
| 11179 | p = &rn->p; |
| 11180 | |
| 11181 | /* "address-family" display. */ |
| 11182 | bgp_config_write_family_header (vty, afi, safi, write); |
| 11183 | |
| 11184 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 11185 | { |
| 11186 | struct in_addr netmask; |
| 11187 | |
| 11188 | masklen2ip (p->prefixlen, &netmask); |
| 11189 | vty_out (vty, " aggregate-address %s %s", |
| 11190 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 11191 | inet_ntoa (netmask)); |
| 11192 | } |
| 11193 | else |
| 11194 | { |
| 11195 | vty_out (vty, " aggregate-address %s/%d", |
| 11196 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 11197 | p->prefixlen); |
| 11198 | } |
| 11199 | |
| 11200 | if (bgp_aggregate->as_set) |
| 11201 | vty_out (vty, " as-set"); |
| 11202 | |
| 11203 | if (bgp_aggregate->summary_only) |
| 11204 | vty_out (vty, " summary-only"); |
| 11205 | |
| 11206 | vty_out (vty, "%s", VTY_NEWLINE); |
| 11207 | } |
| 11208 | |
| 11209 | return 0; |
| 11210 | } |
| 11211 | |
| 11212 | int |
| 11213 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 11214 | { |
| 11215 | struct bgp_node *rn; |
| 11216 | struct bgp_distance *bdistance; |
| 11217 | |
| 11218 | /* Distance configuration. */ |
| 11219 | if (bgp->distance_ebgp |
| 11220 | && bgp->distance_ibgp |
| 11221 | && bgp->distance_local |
| 11222 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 11223 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 11224 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 11225 | vty_out (vty, " distance bgp %d %d %d%s", |
| 11226 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 11227 | VTY_NEWLINE); |
| 11228 | |
| 11229 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 11230 | if ((bdistance = rn->info) != NULL) |
| 11231 | { |
| 11232 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 11233 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 11234 | bdistance->access_list ? bdistance->access_list : "", |
| 11235 | VTY_NEWLINE); |
| 11236 | } |
| 11237 | |
| 11238 | return 0; |
| 11239 | } |
| 11240 | |
| 11241 | /* Allocate routing table structure and install commands. */ |
| 11242 | void |
| 11243 | bgp_route_init () |
| 11244 | { |
| 11245 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 11246 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11247 | |
| 11248 | /* IPv4 BGP commands. */ |
| 11249 | install_element (BGP_NODE, &bgp_network_cmd); |
| 11250 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 11251 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 11252 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 11253 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 11254 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 11255 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 11256 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 11257 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 11258 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 11259 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 11260 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 11261 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 11262 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 11263 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 11264 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 11265 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 11266 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 11267 | |
| 11268 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 11269 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 11270 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 11271 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 11272 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 11273 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 11274 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 11275 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 11276 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 11277 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 11278 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 11279 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 11280 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 11281 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 11282 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 11283 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 11284 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 11285 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 11286 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 11287 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 11288 | |
| 11289 | /* IPv4 unicast configuration. */ |
| 11290 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 11291 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 11292 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 11293 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 11294 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 11295 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 11296 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 11297 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 11298 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 11299 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 11300 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 11301 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 11302 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 11303 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 11304 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 11305 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 11306 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 11307 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 11308 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 11309 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 11310 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 11311 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 11312 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 11313 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 11314 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 11315 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 11316 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 11317 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 11318 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 11319 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 11320 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 11321 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 11322 | |
| 11323 | /* IPv4 multicast configuration. */ |
| 11324 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 11325 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 11326 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 11327 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 11328 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 11329 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 11330 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 11331 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 11332 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 11333 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 11334 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 11335 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 11336 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 11337 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 11338 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 11339 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 11340 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 11341 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 11342 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 11343 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 11344 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 11345 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 11346 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 11347 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 11348 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 11349 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 11350 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 11351 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 11352 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 11353 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 11354 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 11355 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 11356 | |
| 11357 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 11358 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 11359 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 11360 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 11361 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 11362 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 11363 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 11364 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 11365 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 11366 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 11367 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 11368 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 11369 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 11370 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 11371 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 11372 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 11373 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 11374 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 11375 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 11376 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 11377 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 11378 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 11379 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 11380 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 11381 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 11382 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 11383 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 11384 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 11385 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 11386 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 11387 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 11388 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 11389 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 11390 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 11391 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 11392 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 11393 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 11394 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 11395 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 11396 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 11397 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 11398 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 11399 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 11400 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 11401 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 11402 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 11403 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 11404 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 11405 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 11406 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 11407 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 11408 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 11409 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 11410 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 11411 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 11412 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 11413 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 11414 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 11415 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 11416 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 11417 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 11418 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 11419 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 11420 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 11421 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 11422 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 11423 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11424 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 11425 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 11426 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 11427 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 11428 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 11429 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11430 | |
| 11431 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 11432 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 11433 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 11434 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 11435 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 11436 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 11437 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 11438 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 11439 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 11440 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 11441 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 11442 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 11443 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 11444 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 11445 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 11446 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 11447 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 11448 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 11449 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 11450 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 11451 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 11452 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 11453 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 11454 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 11455 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 11456 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 11457 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 11458 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 11459 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 11460 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 11461 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 11462 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 11463 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 11464 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 11465 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 11466 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 11467 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 11468 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 11469 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 11470 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 11471 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 11472 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 11473 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 11474 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 11475 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 11476 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 11477 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 11478 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 11479 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 11480 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 11481 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 11482 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 11483 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 11484 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 11485 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 11486 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 11487 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 11488 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 11489 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 11490 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 11491 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 11492 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 11493 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 11494 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 11495 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 11496 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 11497 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11498 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 11499 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 11500 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 11501 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 11502 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 11503 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11504 | |
| 11505 | /* BGP dampening clear commands */ |
| 11506 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 11507 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 11508 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 11509 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 11510 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11511 | /* prefix count */ |
| 11512 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 11513 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 11514 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11515 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11516 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 11517 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11518 | /* New config IPv6 BGP commands. */ |
| 11519 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 11520 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 11521 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 11522 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 11523 | |
| 11524 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 11525 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 11526 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 11527 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 11528 | |
| 11529 | /* Old config IPv6 BGP commands. */ |
| 11530 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 11531 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 11532 | |
| 11533 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 11534 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 11535 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 11536 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 11537 | |
| 11538 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 11539 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 11540 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 11541 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 11542 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 11543 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 11544 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 11545 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 11546 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 11547 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 11548 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 11549 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 11550 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 11551 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 11552 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 11553 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 11554 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 11555 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 11556 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 11557 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 11558 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 11559 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 11560 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 11561 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 11562 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 11563 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 11564 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 11565 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 11566 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 11567 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 11568 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 11569 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 11570 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 11571 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 11572 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 11573 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 11574 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 11575 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 11576 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 11577 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 11578 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 11579 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 11580 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 11581 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 11582 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 11583 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11584 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 11585 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 11586 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 11587 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11588 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 11589 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 11590 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11591 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 11592 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 11593 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 11594 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 11595 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 11596 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 11597 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 11598 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 11599 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 11600 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 11601 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 11602 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 11603 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 11604 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 11605 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 11606 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 11607 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 11608 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11609 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 11610 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 11611 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11612 | |
| 11613 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 11614 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 11615 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 11616 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 11617 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 11618 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 11619 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 11620 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 11621 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 11622 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 11623 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 11624 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 11625 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 11626 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 11627 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 11628 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 11629 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 11630 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 11631 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 11632 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 11633 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 11634 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 11635 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 11636 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 11637 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 11638 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 11639 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 11640 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 11641 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 11642 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 11643 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 11644 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 11645 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 11646 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 11647 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 11648 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 11649 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 11650 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 11651 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 11652 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 11653 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 11654 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 11655 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 11656 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 11657 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 11658 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11659 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 11660 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 11661 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 11662 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11663 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 11664 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 11665 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11666 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 11667 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 11668 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 11669 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 11670 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 11671 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 11672 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 11673 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 11674 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 11675 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 11676 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 11677 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 11678 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 11679 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 11680 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 11681 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 11682 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 11683 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11684 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 11685 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 11686 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11687 | |
| 11688 | /* Statistics */ |
| 11689 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 11690 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 11691 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 11692 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 11693 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11694 | /* old command */ |
| 11695 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 11696 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 11697 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 11698 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 11699 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 11700 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 11701 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 11702 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 11703 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 11704 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 11705 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 11706 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 11707 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 11708 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 11709 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 11710 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 11711 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 11712 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 11713 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 11714 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 11715 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 11716 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 11717 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 11718 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 11719 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 11720 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 11721 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 11722 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 11723 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 11724 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 11725 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 11726 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 11727 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 11728 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 11729 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 11730 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11731 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11732 | /* old command */ |
| 11733 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 11734 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 11735 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 11736 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 11737 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 11738 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 11739 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 11740 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 11741 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 11742 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 11743 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 11744 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 11745 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 11746 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 11747 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 11748 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 11749 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 11750 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 11751 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 11752 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 11753 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 11754 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 11755 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 11756 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 11757 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 11758 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 11759 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 11760 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 11761 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 11762 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 11763 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 11764 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 11765 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 11766 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 11767 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 11768 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 11769 | |
| 11770 | /* old command */ |
| 11771 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 11772 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 11773 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 11774 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 11775 | |
| 11776 | /* old command */ |
| 11777 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 11778 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 11779 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 11780 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 11781 | |
| 11782 | /* old command */ |
| 11783 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 11784 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 11785 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 11786 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 11787 | #endif /* HAVE_IPV6 */ |
| 11788 | |
| 11789 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 11790 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 11791 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 11792 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 11793 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 11794 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 11795 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 11796 | |
| 11797 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 11798 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 11799 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 11800 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 11801 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 11802 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 11803 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 11804 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 11805 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 11806 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 11807 | } |