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" |
| 36 | |
| 37 | #include "bgpd/bgpd.h" |
| 38 | #include "bgpd/bgp_table.h" |
| 39 | #include "bgpd/bgp_route.h" |
| 40 | #include "bgpd/bgp_attr.h" |
| 41 | #include "bgpd/bgp_debug.h" |
| 42 | #include "bgpd/bgp_aspath.h" |
| 43 | #include "bgpd/bgp_regex.h" |
| 44 | #include "bgpd/bgp_community.h" |
| 45 | #include "bgpd/bgp_ecommunity.h" |
| 46 | #include "bgpd/bgp_clist.h" |
| 47 | #include "bgpd/bgp_packet.h" |
| 48 | #include "bgpd/bgp_filter.h" |
| 49 | #include "bgpd/bgp_fsm.h" |
| 50 | #include "bgpd/bgp_mplsvpn.h" |
| 51 | #include "bgpd/bgp_nexthop.h" |
| 52 | #include "bgpd/bgp_damp.h" |
| 53 | #include "bgpd/bgp_advertise.h" |
| 54 | #include "bgpd/bgp_zebra.h" |
| 55 | |
| 56 | /* Extern from bgp_dump.c */ |
| 57 | extern char *bgp_origin_str[]; |
| 58 | extern char *bgp_origin_long_str[]; |
| 59 | |
| 60 | struct bgp_node * |
| 61 | bgp_afi_node_get (struct bgp *bgp, afi_t afi, safi_t safi, struct prefix *p, |
| 62 | struct prefix_rd *prd) |
| 63 | { |
| 64 | struct bgp_node *rn; |
| 65 | struct bgp_node *prn = NULL; |
| 66 | struct bgp_table *table; |
| 67 | |
| 68 | if (safi == SAFI_MPLS_VPN) |
| 69 | { |
| 70 | prn = bgp_node_get (bgp->rib[afi][safi], (struct prefix *) prd); |
| 71 | |
| 72 | if (prn->info == NULL) |
| 73 | prn->info = bgp_table_init (); |
| 74 | else |
| 75 | bgp_unlock_node (prn); |
| 76 | table = prn->info; |
| 77 | } |
| 78 | else |
| 79 | table = bgp->rib[afi][safi]; |
| 80 | |
| 81 | rn = bgp_node_get (table, p); |
| 82 | |
| 83 | if (safi == SAFI_MPLS_VPN) |
| 84 | rn->prn = prn; |
| 85 | |
| 86 | return rn; |
| 87 | } |
| 88 | |
| 89 | /* Allocate new bgp info structure. */ |
| 90 | struct bgp_info * |
| 91 | bgp_info_new () |
| 92 | { |
| 93 | struct bgp_info *new; |
| 94 | |
| 95 | new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 96 | memset (new, 0, sizeof (struct bgp_info)); |
| 97 | |
| 98 | return new; |
| 99 | } |
| 100 | |
| 101 | /* Free bgp route information. */ |
| 102 | void |
| 103 | bgp_info_free (struct bgp_info *binfo) |
| 104 | { |
| 105 | if (binfo->attr) |
| 106 | bgp_attr_unintern (binfo->attr); |
| 107 | |
| 108 | if (binfo->damp_info) |
| 109 | bgp_damp_info_free (binfo->damp_info, 0); |
| 110 | |
| 111 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 112 | } |
| 113 | |
| 114 | void |
| 115 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 116 | { |
| 117 | struct bgp_info *top; |
| 118 | |
| 119 | top = rn->info; |
| 120 | |
| 121 | ri->next = rn->info; |
| 122 | ri->prev = NULL; |
| 123 | if (top) |
| 124 | top->prev = ri; |
| 125 | rn->info = ri; |
| 126 | } |
| 127 | |
| 128 | void |
| 129 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 130 | { |
| 131 | if (ri->next) |
| 132 | ri->next->prev = ri->prev; |
| 133 | if (ri->prev) |
| 134 | ri->prev->next = ri->next; |
| 135 | else |
| 136 | rn->info = ri->next; |
| 137 | } |
| 138 | |
| 139 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 140 | missing-as-worst" is specified, treat it as the worst value. */ |
| 141 | u_int32_t |
| 142 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 143 | { |
| 144 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 145 | return attr->med; |
| 146 | else |
| 147 | { |
| 148 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 149 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 150 | else |
| 151 | return 0; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | /* Compare two bgp route entity. br is preferable then return 1. */ |
| 156 | int |
| 157 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) |
| 158 | { |
| 159 | u_int32_t new_pref; |
| 160 | u_int32_t exist_pref; |
| 161 | u_int32_t new_med; |
| 162 | u_int32_t exist_med; |
| 163 | struct in_addr new_id; |
| 164 | struct in_addr exist_id; |
| 165 | int new_cluster; |
| 166 | int exist_cluster; |
| 167 | int internal_as_route = 0; |
| 168 | int confed_as_route = 0; |
| 169 | int ret; |
| 170 | |
| 171 | /* 0. Null check. */ |
| 172 | if (new == NULL) |
| 173 | return 0; |
| 174 | if (exist == NULL) |
| 175 | return 1; |
| 176 | |
| 177 | /* 1. Weight check. */ |
| 178 | if (new->attr->weight > exist->attr->weight) |
| 179 | return 1; |
| 180 | if (new->attr->weight < exist->attr->weight) |
| 181 | return 0; |
| 182 | |
| 183 | /* 2. Local preference check. */ |
| 184 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 185 | new_pref = new->attr->local_pref; |
| 186 | else |
| 187 | new_pref = bgp->default_local_pref; |
| 188 | |
| 189 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 190 | exist_pref = exist->attr->local_pref; |
| 191 | else |
| 192 | exist_pref = bgp->default_local_pref; |
| 193 | |
| 194 | if (new_pref > exist_pref) |
| 195 | return 1; |
| 196 | if (new_pref < exist_pref) |
| 197 | return 0; |
| 198 | |
| 199 | /* 3. Local route check. */ |
| 200 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 201 | return 1; |
| 202 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 203 | return 0; |
| 204 | |
| 205 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 206 | return 1; |
| 207 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 208 | return 0; |
| 209 | |
| 210 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 211 | return 1; |
| 212 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 213 | return 0; |
| 214 | |
| 215 | /* 4. AS path length check. */ |
| 216 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 217 | { |
| 218 | if (new->attr->aspath->count < exist->attr->aspath->count) |
| 219 | return 1; |
| 220 | if (new->attr->aspath->count > exist->attr->aspath->count) |
| 221 | return 0; |
| 222 | } |
| 223 | |
| 224 | /* 5. Origin check. */ |
| 225 | if (new->attr->origin < exist->attr->origin) |
| 226 | return 1; |
| 227 | if (new->attr->origin > exist->attr->origin) |
| 228 | return 0; |
| 229 | |
| 230 | /* 6. MED check. */ |
| 231 | internal_as_route = (new->attr->aspath->length == 0 |
| 232 | && exist->attr->aspath->length == 0); |
| 233 | confed_as_route = (new->attr->aspath->length > 0 |
| 234 | && exist->attr->aspath->length > 0 |
| 235 | && new->attr->aspath->count == 0 |
| 236 | && exist->attr->aspath->count == 0); |
| 237 | |
| 238 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 239 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 240 | && confed_as_route) |
| 241 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 242 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 243 | || internal_as_route) |
| 244 | { |
| 245 | new_med = bgp_med_value (new->attr, bgp); |
| 246 | exist_med = bgp_med_value (exist->attr, bgp); |
| 247 | |
| 248 | if (new_med < exist_med) |
| 249 | return 1; |
| 250 | if (new_med > exist_med) |
| 251 | return 0; |
| 252 | } |
| 253 | |
| 254 | /* 7. Peer type check. */ |
| 255 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 256 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 257 | return 1; |
| 258 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 259 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 260 | return 1; |
| 261 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 262 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 263 | return 0; |
| 264 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 265 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 266 | return 0; |
| 267 | |
| 268 | /* 8. IGP metric check. */ |
| 269 | if (new->igpmetric < exist->igpmetric) |
| 270 | return 1; |
| 271 | if (new->igpmetric > exist->igpmetric) |
| 272 | return 0; |
| 273 | |
| 274 | /* 9. Maximum path check. */ |
| 275 | |
| 276 | /* 10. If both paths are external, prefer the path that was received |
| 277 | first (the oldest one). This step minimizes route-flap, since a |
| 278 | newer path won't displace an older one, even if it was the |
| 279 | preferred route based on the additional decision criteria below. */ |
| 280 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 281 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 282 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 283 | { |
| 284 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 285 | return 1; |
| 286 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | /* 11. Rourter-ID comparision. */ |
| 291 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 292 | new_id.s_addr = new->attr->originator_id.s_addr; |
| 293 | else |
| 294 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 295 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 296 | exist_id.s_addr = exist->attr->originator_id.s_addr; |
| 297 | else |
| 298 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 299 | |
| 300 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 301 | return 1; |
| 302 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 303 | return 0; |
| 304 | |
| 305 | /* 12. Cluster length comparision. */ |
| 306 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 307 | new_cluster = new->attr->cluster->length; |
| 308 | else |
| 309 | new_cluster = 0; |
| 310 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 311 | exist_cluster = exist->attr->cluster->length; |
| 312 | else |
| 313 | exist_cluster = 0; |
| 314 | |
| 315 | if (new_cluster < exist_cluster) |
| 316 | return 1; |
| 317 | if (new_cluster > exist_cluster) |
| 318 | return 0; |
| 319 | |
| 320 | /* 13. Neighbor address comparision. */ |
| 321 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 322 | |
| 323 | if (ret == 1) |
| 324 | return 0; |
| 325 | if (ret == -1) |
| 326 | return 1; |
| 327 | |
| 328 | return 1; |
| 329 | } |
| 330 | |
| 331 | enum filter_type |
| 332 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 333 | afi_t afi, safi_t safi) |
| 334 | { |
| 335 | struct bgp_filter *filter; |
| 336 | |
| 337 | filter = &peer->filter[afi][safi]; |
| 338 | |
| 339 | if (DISTRIBUTE_IN_NAME (filter)) |
| 340 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 341 | return FILTER_DENY; |
| 342 | |
| 343 | if (PREFIX_LIST_IN_NAME (filter)) |
| 344 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 345 | return FILTER_DENY; |
| 346 | |
| 347 | if (FILTER_LIST_IN_NAME (filter)) |
| 348 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 349 | return FILTER_DENY; |
| 350 | |
| 351 | return FILTER_PERMIT; |
| 352 | } |
| 353 | |
| 354 | enum filter_type |
| 355 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 356 | afi_t afi, safi_t safi) |
| 357 | { |
| 358 | struct bgp_filter *filter; |
| 359 | |
| 360 | filter = &peer->filter[afi][safi]; |
| 361 | |
| 362 | if (DISTRIBUTE_OUT_NAME (filter)) |
| 363 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 364 | return FILTER_DENY; |
| 365 | |
| 366 | if (PREFIX_LIST_OUT_NAME (filter)) |
| 367 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 368 | return FILTER_DENY; |
| 369 | |
| 370 | if (FILTER_LIST_OUT_NAME (filter)) |
| 371 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 372 | return FILTER_DENY; |
| 373 | |
| 374 | return FILTER_PERMIT; |
| 375 | } |
| 376 | |
| 377 | /* If community attribute includes no_export then return 1. */ |
| 378 | int |
| 379 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 380 | { |
| 381 | if (attr->community) |
| 382 | { |
| 383 | /* NO_ADVERTISE check. */ |
| 384 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 385 | return 1; |
| 386 | |
| 387 | /* NO_EXPORT check. */ |
| 388 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 389 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 390 | return 1; |
| 391 | |
| 392 | /* NO_EXPORT_SUBCONFED check. */ |
| 393 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 394 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 395 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 396 | return 1; |
| 397 | } |
| 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | /* Route reflection loop check. */ |
| 402 | static int |
| 403 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 404 | { |
| 405 | struct in_addr cluster_id; |
| 406 | |
| 407 | if (attr->cluster) |
| 408 | { |
| 409 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 410 | cluster_id = peer->bgp->cluster_id; |
| 411 | else |
| 412 | cluster_id = peer->bgp->router_id; |
| 413 | |
| 414 | if (cluster_loop_check (attr->cluster, cluster_id)) |
| 415 | return 1; |
| 416 | } |
| 417 | return 0; |
| 418 | } |
| 419 | |
| 420 | int |
| 421 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 422 | afi_t afi, safi_t safi) |
| 423 | { |
| 424 | struct bgp_filter *filter; |
| 425 | struct bgp_info info; |
| 426 | route_map_result_t ret; |
| 427 | |
| 428 | filter = &peer->filter[afi][safi]; |
| 429 | |
| 430 | /* Apply default weight value. */ |
| 431 | attr->weight = peer->weight; |
| 432 | |
| 433 | /* Route map apply. */ |
| 434 | if (ROUTE_MAP_IN_NAME (filter)) |
| 435 | { |
| 436 | /* Duplicate current value to new strucutre for modification. */ |
| 437 | info.peer = peer; |
| 438 | info.attr = attr; |
| 439 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 440 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 441 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 442 | /* Apply BGP route map to the attribute. */ |
| 443 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 444 | |
| 445 | peer->rmap_type = 0; |
| 446 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 447 | if (ret == RMAP_DENYMATCH) |
| 448 | { |
| 449 | /* Free newly generated AS path and community by route-map. */ |
| 450 | bgp_attr_flush (attr); |
| 451 | return RMAP_DENY; |
| 452 | } |
| 453 | } |
| 454 | return RMAP_PERMIT; |
| 455 | } |
| 456 | |
| 457 | int |
| 458 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 459 | struct attr *attr, afi_t afi, safi_t safi) |
| 460 | { |
| 461 | int ret; |
| 462 | char buf[SU_ADDRSTRLEN]; |
| 463 | struct bgp_filter *filter; |
| 464 | struct bgp_info info; |
| 465 | struct peer *from; |
| 466 | struct bgp *bgp; |
| 467 | struct attr dummy_attr; |
| 468 | int transparent; |
| 469 | int reflect; |
| 470 | |
| 471 | from = ri->peer; |
| 472 | filter = &peer->filter[afi][safi]; |
| 473 | bgp = peer->bgp; |
| 474 | |
| 475 | #ifdef DISABLE_BGP_ANNOUNCE |
| 476 | return 0; |
| 477 | #endif |
| 478 | |
| 479 | /* Do not send back route to sender. */ |
| 480 | if (from == peer) |
| 481 | return 0; |
| 482 | |
| 483 | /* Aggregate-address suppress check. */ |
| 484 | if (ri->suppress) |
| 485 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 486 | return 0; |
| 487 | |
| 488 | /* Default route check. */ |
| 489 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 490 | { |
| 491 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 492 | return 0; |
| 493 | #ifdef HAVE_IPV6 |
| 494 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 495 | return 0; |
| 496 | #endif /* HAVE_IPV6 */ |
| 497 | } |
| 498 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 499 | /* Transparency check. */ |
| 500 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 501 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 502 | transparent = 1; |
| 503 | else |
| 504 | transparent = 0; |
| 505 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 506 | /* If community is not disabled check the no-export and local. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 507 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | return 0; |
| 509 | |
| 510 | /* If the attribute has originator-id and it is same as remote |
| 511 | peer's id. */ |
| 512 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 513 | { |
| 514 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id)) |
| 515 | { |
| 516 | if (BGP_DEBUG (filter, FILTER)) |
| 517 | zlog (peer->log, LOG_INFO, |
| 518 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 519 | peer->host, |
| 520 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 521 | p->prefixlen); |
| 522 | return 0; |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | /* ORF prefix-list filter check */ |
| 527 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 528 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 529 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 530 | if (peer->orf_plist[afi][safi]) |
| 531 | { |
| 532 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 533 | return 0; |
| 534 | } |
| 535 | |
| 536 | /* Output filter check. */ |
| 537 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) |
| 538 | { |
| 539 | if (BGP_DEBUG (filter, FILTER)) |
| 540 | zlog (peer->log, LOG_INFO, |
| 541 | "%s [Update:SEND] %s/%d is filtered", |
| 542 | peer->host, |
| 543 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 544 | p->prefixlen); |
| 545 | return 0; |
| 546 | } |
| 547 | |
| 548 | #ifdef BGP_SEND_ASPATH_CHECK |
| 549 | /* AS path loop check. */ |
| 550 | if (aspath_loop_check (ri->attr->aspath, peer->as)) |
| 551 | { |
| 552 | if (BGP_DEBUG (filter, FILTER)) |
| 553 | zlog (peer->log, LOG_INFO, |
| 554 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 555 | peer->host, peer->as); |
| 556 | return 0; |
| 557 | } |
| 558 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 559 | |
| 560 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 561 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 562 | { |
| 563 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) |
| 564 | { |
| 565 | if (BGP_DEBUG (filter, FILTER)) |
| 566 | zlog (peer->log, LOG_INFO, |
| 567 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 568 | peer->host, |
| 569 | bgp->confed_id); |
| 570 | return 0; |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | /* Route-Reflect check. */ |
| 575 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 576 | reflect = 1; |
| 577 | else |
| 578 | reflect = 0; |
| 579 | |
| 580 | /* IBGP reflection check. */ |
| 581 | if (reflect) |
| 582 | { |
| 583 | /* A route from a Client peer. */ |
| 584 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 585 | { |
| 586 | /* Reflect to all the Non-Client peers and also to the |
| 587 | Client peers other than the originator. Originator check |
| 588 | is already done. So there is noting to do. */ |
| 589 | /* no bgp client-to-client reflection check. */ |
| 590 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 591 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 592 | return 0; |
| 593 | } |
| 594 | else |
| 595 | { |
| 596 | /* A route from a Non-client peer. Reflect to all other |
| 597 | clients. */ |
| 598 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 599 | return 0; |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | /* For modify attribute, copy it to temporary structure. */ |
| 604 | *attr = *ri->attr; |
| 605 | |
| 606 | /* If local-preference is not set. */ |
| 607 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 608 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 609 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 610 | { |
| 611 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 612 | attr->local_pref = bgp->default_local_pref; |
| 613 | } |
| 614 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 615 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 616 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 617 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 618 | { |
| 619 | if (ri->peer != bgp->peer_self && ! transparent |
| 620 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 621 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 622 | } |
| 623 | |
| 624 | /* next-hop-set */ |
| 625 | if (transparent || reflect |
| 626 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 627 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 628 | #ifdef HAVE_IPV6 |
| 629 | || (p->family == AF_INET6 && ri->peer != bgp->peer_self) |
| 630 | #endif /* HAVE_IPV6 */ |
| 631 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 632 | { |
| 633 | /* NEXT-HOP Unchanged. */ |
| 634 | } |
| 635 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 636 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 637 | #ifdef HAVE_IPV6 |
| 638 | || (p->family == AF_INET6 && ri->peer == bgp->peer_self) |
| 639 | #endif /* HAVE_IPV6 */ |
| 640 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 641 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 642 | { |
| 643 | /* Set IPv4 nexthop. */ |
| 644 | if (p->family == AF_INET) |
| 645 | { |
| 646 | if (safi == SAFI_MPLS_VPN) |
| 647 | memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 648 | else |
| 649 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 650 | } |
| 651 | #ifdef HAVE_IPV6 |
| 652 | /* Set IPv6 nexthop. */ |
| 653 | if (p->family == AF_INET6) |
| 654 | { |
| 655 | /* IPv6 global nexthop must be included. */ |
| 656 | memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global, |
| 657 | IPV6_MAX_BYTELEN); |
| 658 | attr->mp_nexthop_len = 16; |
| 659 | } |
| 660 | #endif /* HAVE_IPV6 */ |
| 661 | } |
| 662 | |
| 663 | #ifdef HAVE_IPV6 |
| 664 | if (p->family == AF_INET6) |
| 665 | { |
| 666 | /* Link-local address should not be transit to different peer. */ |
| 667 | attr->mp_nexthop_len = 16; |
| 668 | |
| 669 | /* Set link-local address for shared network peer. */ |
| 670 | if (peer->shared_network |
| 671 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 672 | { |
| 673 | memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local, |
| 674 | IPV6_MAX_BYTELEN); |
| 675 | attr->mp_nexthop_len = 32; |
| 676 | } |
| 677 | |
| 678 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 679 | address.*/ |
| 680 | if (reflect) |
| 681 | attr->mp_nexthop_len = 16; |
| 682 | |
| 683 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 684 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
| 685 | attr->mp_nexthop_len = 16; |
| 686 | } |
| 687 | #endif /* HAVE_IPV6 */ |
| 688 | |
| 689 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 690 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 691 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 692 | && aspath_private_as_check (attr->aspath)) |
| 693 | attr->aspath = aspath_empty_get (); |
| 694 | |
| 695 | /* Route map & unsuppress-map apply. */ |
| 696 | if (ROUTE_MAP_OUT_NAME (filter) |
| 697 | || ri->suppress) |
| 698 | { |
| 699 | info.peer = peer; |
| 700 | info.attr = attr; |
| 701 | |
| 702 | /* The route reflector is not allowed to modify the attributes |
| 703 | of the reflected IBGP routes. */ |
| 704 | if (peer_sort (from) == BGP_PEER_IBGP |
| 705 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 706 | { |
| 707 | dummy_attr = *attr; |
| 708 | info.attr = &dummy_attr; |
| 709 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 710 | |
| 711 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 712 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 713 | if (ri->suppress) |
| 714 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 715 | else |
| 716 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 717 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 718 | peer->rmap_type = 0; |
| 719 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 720 | if (ret == RMAP_DENYMATCH) |
| 721 | { |
| 722 | bgp_attr_flush (attr); |
| 723 | return 0; |
| 724 | } |
| 725 | } |
| 726 | return 1; |
| 727 | } |
| 728 | |
| 729 | int |
| 730 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 731 | { |
| 732 | struct prefix *p; |
| 733 | struct bgp_info *ri; |
| 734 | struct bgp_info *new_select; |
| 735 | struct bgp_info *old_select; |
| 736 | struct listnode *nn; |
| 737 | struct peer *peer; |
| 738 | struct attr attr; |
| 739 | struct bgp_info *ri1; |
| 740 | struct bgp_info *ri2; |
| 741 | |
| 742 | p = &rn->p; |
| 743 | |
| 744 | /* bgp deterministic-med */ |
| 745 | new_select = NULL; |
| 746 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 747 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 748 | { |
| 749 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 750 | continue; |
| 751 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 752 | continue; |
| 753 | |
| 754 | new_select = ri1; |
| 755 | if (ri1->next) |
| 756 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 757 | { |
| 758 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 759 | continue; |
| 760 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 761 | continue; |
| 762 | |
| 763 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 764 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 765 | ri2->attr->aspath)) |
| 766 | { |
| 767 | if (bgp_info_cmp (bgp, ri2, new_select)) |
| 768 | { |
| 769 | UNSET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 770 | new_select = ri2; |
| 771 | } |
| 772 | |
| 773 | SET_FLAG (ri2->flags, BGP_INFO_DMED_CHECK); |
| 774 | } |
| 775 | } |
| 776 | SET_FLAG (new_select->flags, BGP_INFO_DMED_CHECK); |
| 777 | SET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 778 | } |
| 779 | |
| 780 | /* Check old selected route and new selected route. */ |
| 781 | old_select = NULL; |
| 782 | new_select = NULL; |
| 783 | for (ri = rn->info; ri; ri = ri->next) |
| 784 | { |
| 785 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 786 | old_select = ri; |
| 787 | |
| 788 | if (BGP_INFO_HOLDDOWN (ri)) |
| 789 | continue; |
| 790 | |
| 791 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 792 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 793 | { |
| 794 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 795 | continue; |
| 796 | } |
| 797 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 798 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_SELECTED); |
| 799 | |
| 800 | if (bgp_info_cmp (bgp, ri, new_select)) |
| 801 | new_select = ri; |
| 802 | } |
| 803 | |
| 804 | /* Nothing to do. */ |
| 805 | if (old_select && old_select == new_select) |
| 806 | { |
| 807 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 808 | { |
| 809 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) |
| 810 | bgp_zebra_announce (p, old_select, bgp); |
| 811 | return 0; |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | if (old_select) |
| 816 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 817 | if (new_select) |
| 818 | { |
| 819 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 820 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 821 | } |
| 822 | |
| 823 | /* Check each BGP peer. */ |
| 824 | LIST_LOOP (bgp->peer, peer, nn) |
| 825 | { |
| 826 | /* Announce route to Established peer. */ |
| 827 | if (peer->status != Established) |
| 828 | continue; |
| 829 | |
| 830 | /* Address family configuration check. */ |
| 831 | if (! peer->afc_nego[afi][safi]) |
| 832 | continue; |
| 833 | |
| 834 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 835 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 836 | continue; |
| 837 | |
| 838 | /* Announcement to peer->conf. If the route is filtered, |
| 839 | withdraw it. */ |
| 840 | if (new_select |
| 841 | && bgp_announce_check (new_select, peer, p, &attr, afi, safi)) |
| 842 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, new_select); |
| 843 | else |
| 844 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 845 | } |
| 846 | |
| 847 | /* FIB update. */ |
| 848 | if (safi == SAFI_UNICAST && ! bgp->name && |
| 849 | ! bgp_option_check (BGP_OPT_NO_FIB)) |
| 850 | { |
| 851 | if (new_select |
| 852 | && new_select->type == ZEBRA_ROUTE_BGP |
| 853 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
| 854 | bgp_zebra_announce (p, new_select, bgp); |
| 855 | else |
| 856 | { |
| 857 | /* Withdraw the route from the kernel. */ |
| 858 | if (old_select |
| 859 | && old_select->type == ZEBRA_ROUTE_BGP |
| 860 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
| 861 | bgp_zebra_withdraw (p, old_select); |
| 862 | } |
| 863 | } |
| 864 | return 0; |
| 865 | } |
| 866 | |
| 867 | int |
| 868 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, safi_t safi) |
| 869 | { |
paul | c22854b | 2003-08-27 07:07:02 +0000 | [diff] [blame] | 870 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 871 | { |
paul | 50d649a | 2003-08-27 12:25:49 +0000 | [diff] [blame] | 872 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 873 | { |
paul | c22854b | 2003-08-27 07:07:02 +0000 | [diff] [blame] | 874 | zlog (peer->log, LOG_INFO, |
| 875 | "MAXPFXEXCEED: No. of prefix received from %s (afi %d): %ld exceed limit %ld", peer->host, afi, peer->pcount[afi][safi], peer->pmax[afi][safi]); |
| 876 | if (! CHECK_FLAG (peer->af_flags[afi][safi], |
| 877 | PEER_FLAG_MAX_PREFIX_WARNING)) |
| 878 | { |
| 879 | char ndata[7]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 880 | |
paul | c22854b | 2003-08-27 07:07:02 +0000 | [diff] [blame] | 881 | ndata[0] = (u_char)(afi >> 8); |
| 882 | ndata[1] = (u_char) afi; |
| 883 | ndata[3] = (u_char)(peer->pmax[afi][safi] >> 24); |
| 884 | ndata[4] = (u_char)(peer->pmax[afi][safi] >> 16); |
| 885 | ndata[5] = (u_char)(peer->pmax[afi][safi] >> 8); |
| 886 | ndata[6] = (u_char)(peer->pmax[afi][safi]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 887 | |
paul | c22854b | 2003-08-27 07:07:02 +0000 | [diff] [blame] | 888 | if (safi == SAFI_MPLS_VPN) |
| 889 | safi = BGP_SAFI_VPNV4; |
| 890 | ndata[2] = (u_char) safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 891 | |
paul | c22854b | 2003-08-27 07:07:02 +0000 | [diff] [blame] | 892 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 893 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 894 | BGP_NOTIFY_CEASE_MAX_PREFIX, |
| 895 | ndata, 7); |
| 896 | return 1; |
| 897 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 898 | } |
| 899 | } |
| 900 | return 0; |
| 901 | } |
| 902 | |
| 903 | void |
| 904 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 905 | afi_t afi, safi_t safi) |
| 906 | { |
| 907 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 908 | { |
| 909 | peer->pcount[afi][safi]--; |
| 910 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 911 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 912 | bgp_process (peer->bgp, rn, afi, safi); |
| 913 | } |
| 914 | bgp_info_delete (rn, ri); |
| 915 | bgp_info_free (ri); |
| 916 | bgp_unlock_node (rn); |
| 917 | } |
| 918 | |
| 919 | void |
| 920 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 921 | afi_t afi, safi_t safi, int force) |
| 922 | { |
| 923 | int valid; |
| 924 | int status = BGP_DAMP_NONE; |
| 925 | |
| 926 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 927 | { |
| 928 | peer->pcount[afi][safi]--; |
| 929 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 930 | } |
| 931 | |
| 932 | if (! force) |
| 933 | { |
| 934 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 935 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 936 | status = bgp_damp_withdraw (ri, rn, afi, safi, 0); |
| 937 | |
| 938 | if (status == BGP_DAMP_SUPPRESSED) |
| 939 | return; |
| 940 | } |
| 941 | |
| 942 | valid = CHECK_FLAG (ri->flags, BGP_INFO_VALID); |
| 943 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 944 | bgp_process (peer->bgp, rn, afi, safi); |
| 945 | |
| 946 | if (valid) |
| 947 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 948 | |
| 949 | if (status != BGP_DAMP_USED) |
| 950 | { |
| 951 | bgp_info_delete (rn, ri); |
| 952 | bgp_info_free (ri); |
| 953 | bgp_unlock_node (rn); |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | int |
| 958 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 959 | afi_t afi, safi_t safi, int type, int sub_type, |
| 960 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 961 | { |
| 962 | int ret; |
| 963 | int aspath_loop_count = 0; |
| 964 | struct bgp_node *rn; |
| 965 | struct bgp *bgp; |
| 966 | struct attr new_attr; |
| 967 | struct attr *attr_new; |
| 968 | struct bgp_info *ri; |
| 969 | struct bgp_info *new; |
| 970 | char *reason; |
| 971 | char buf[SU_ADDRSTRLEN]; |
| 972 | |
| 973 | bgp = peer->bgp; |
| 974 | rn = bgp_afi_node_get (bgp, afi, safi, p, prd); |
| 975 | |
| 976 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 977 | Adj-RIBs-In. */ |
| 978 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 979 | && peer != bgp->peer_self && ! soft_reconfig) |
| 980 | bgp_adj_in_set (rn, peer, attr); |
| 981 | |
| 982 | /* Check previously received route. */ |
| 983 | for (ri = rn->info; ri; ri = ri->next) |
| 984 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 985 | break; |
| 986 | |
| 987 | /* AS path local-as loop check. */ |
| 988 | if (peer->change_local_as) |
| 989 | { |
| 990 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 991 | aspath_loop_count = 1; |
| 992 | |
| 993 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 994 | { |
| 995 | reason = "as-path contains our own AS;"; |
| 996 | goto filtered; |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | /* AS path loop check. */ |
| 1001 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 1002 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 1003 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 1004 | > peer->allowas_in[afi][safi])) |
| 1005 | { |
| 1006 | reason = "as-path contains our own AS;"; |
| 1007 | goto filtered; |
| 1008 | } |
| 1009 | |
| 1010 | /* Route reflector originator ID check. */ |
| 1011 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1012 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id)) |
| 1013 | { |
| 1014 | reason = "originator is us;"; |
| 1015 | goto filtered; |
| 1016 | } |
| 1017 | |
| 1018 | /* Route reflector cluster ID check. */ |
| 1019 | if (bgp_cluster_filter (peer, attr)) |
| 1020 | { |
| 1021 | reason = "reflected from the same cluster;"; |
| 1022 | goto filtered; |
| 1023 | } |
| 1024 | |
| 1025 | /* Apply incoming filter. */ |
| 1026 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 1027 | { |
| 1028 | reason = "filter;"; |
| 1029 | goto filtered; |
| 1030 | } |
| 1031 | |
| 1032 | /* Apply incoming route-map. */ |
| 1033 | new_attr = *attr; |
| 1034 | |
| 1035 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1036 | { |
| 1037 | reason = "route-map;"; |
| 1038 | goto filtered; |
| 1039 | } |
| 1040 | |
| 1041 | /* IPv4 unicast next hop check. */ |
| 1042 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1043 | { |
| 1044 | /* If the peer is EBGP and nexthop is not on connected route, |
| 1045 | discard it. */ |
| 1046 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
| 1047 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) |
| 1048 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP)) |
| 1049 | { |
| 1050 | reason = "non-connected next-hop;"; |
| 1051 | goto filtered; |
| 1052 | } |
| 1053 | |
| 1054 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop |
| 1055 | must not be my own address. */ |
| 1056 | if (bgp_nexthop_self (afi, &new_attr) |
| 1057 | || new_attr.nexthop.s_addr == 0 |
| 1058 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1059 | { |
| 1060 | reason = "martian next-hop;"; |
| 1061 | goto filtered; |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | attr_new = bgp_attr_intern (&new_attr); |
| 1066 | |
| 1067 | /* If the update is implicit withdraw. */ |
| 1068 | if (ri) |
| 1069 | { |
| 1070 | ri->uptime = time (NULL); |
| 1071 | |
| 1072 | /* Same attribute comes in. */ |
| 1073 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1074 | { |
| 1075 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1076 | |
| 1077 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1078 | && peer_sort (peer) == BGP_PEER_EBGP |
| 1079 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1080 | { |
| 1081 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1082 | zlog (peer->log, LOG_INFO, "%s rcvd %s/%d", |
| 1083 | peer->host, |
| 1084 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1085 | p->prefixlen); |
| 1086 | |
| 1087 | peer->pcount[afi][safi]++; |
| 1088 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1089 | if (ret != BGP_DAMP_SUPPRESSED) |
| 1090 | { |
| 1091 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1092 | bgp_process (bgp, rn, afi, safi); |
| 1093 | } |
| 1094 | } |
| 1095 | else |
| 1096 | { |
| 1097 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1098 | zlog (peer->log, LOG_INFO, |
| 1099 | "%s rcvd %s/%d...duplicate ignored", |
| 1100 | peer->host, |
| 1101 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1102 | p->prefixlen); |
| 1103 | } |
| 1104 | |
| 1105 | bgp_unlock_node (rn); |
| 1106 | bgp_attr_unintern (attr_new); |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
| 1110 | /* Received Logging. */ |
| 1111 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1112 | zlog (peer->log, LOG_INFO, "%s rcvd %s/%d", |
| 1113 | peer->host, |
| 1114 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1115 | p->prefixlen); |
| 1116 | |
| 1117 | /* The attribute is changed. */ |
| 1118 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1119 | |
| 1120 | /* Update bgp route dampening information. */ |
| 1121 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1122 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1123 | { |
| 1124 | /* This is implicit withdraw so we should update dampening |
| 1125 | information. */ |
| 1126 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1127 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
| 1128 | else |
| 1129 | peer->pcount[afi][safi]++; |
| 1130 | } |
| 1131 | |
| 1132 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 1133 | |
| 1134 | /* Update to new attribute. */ |
| 1135 | bgp_attr_unintern (ri->attr); |
| 1136 | ri->attr = attr_new; |
| 1137 | |
| 1138 | /* Update MPLS tag. */ |
| 1139 | if (safi == SAFI_MPLS_VPN) |
| 1140 | memcpy (ri->tag, tag, 3); |
| 1141 | |
| 1142 | /* Update bgp route dampening information. */ |
| 1143 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1144 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1145 | { |
| 1146 | /* Now we do normal update dampening. */ |
| 1147 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1148 | if (ret == BGP_DAMP_SUPPRESSED) |
| 1149 | { |
| 1150 | bgp_unlock_node (rn); |
| 1151 | return 0; |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | /* Nexthop reachability check. */ |
| 1156 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 1157 | && safi == SAFI_UNICAST |
| 1158 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 1159 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
| 1160 | || CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP))) |
| 1161 | { |
| 1162 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
| 1163 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1164 | else |
| 1165 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1166 | } |
| 1167 | else |
| 1168 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1169 | |
| 1170 | /* Process change. */ |
| 1171 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1172 | |
| 1173 | bgp_process (bgp, rn, afi, safi); |
| 1174 | bgp_unlock_node (rn); |
| 1175 | return 0; |
| 1176 | } |
| 1177 | |
| 1178 | /* Received Logging. */ |
| 1179 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1180 | { |
| 1181 | zlog (peer->log, LOG_INFO, "%s rcvd %s/%d", |
| 1182 | peer->host, |
| 1183 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1184 | p->prefixlen); |
| 1185 | } |
| 1186 | |
| 1187 | /* Increment prefix counter */ |
| 1188 | peer->pcount[afi][safi]++; |
| 1189 | |
| 1190 | /* Make new BGP info. */ |
| 1191 | new = bgp_info_new (); |
| 1192 | new->type = type; |
| 1193 | new->sub_type = sub_type; |
| 1194 | new->peer = peer; |
| 1195 | new->attr = attr_new; |
| 1196 | new->uptime = time (NULL); |
| 1197 | |
| 1198 | /* Update MPLS tag. */ |
| 1199 | if (safi == SAFI_MPLS_VPN) |
| 1200 | memcpy (new->tag, tag, 3); |
| 1201 | |
| 1202 | /* Nexthop reachability check. */ |
| 1203 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 1204 | && safi == SAFI_UNICAST |
| 1205 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 1206 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
| 1207 | || CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP))) |
| 1208 | { |
| 1209 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
| 1210 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1211 | else |
| 1212 | UNSET_FLAG (new->flags, BGP_INFO_VALID); |
| 1213 | } |
| 1214 | else |
| 1215 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1216 | |
| 1217 | /* Aggregate address increment. */ |
| 1218 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 1219 | |
| 1220 | /* Register new BGP information. */ |
| 1221 | bgp_info_add (rn, new); |
| 1222 | |
| 1223 | /* If maximum prefix count is configured and current prefix |
| 1224 | count exeed it. */ |
| 1225 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1226 | if (bgp_maximum_prefix_overflow (peer, afi, safi)) |
| 1227 | return -1; |
| 1228 | |
| 1229 | /* Process change. */ |
| 1230 | bgp_process (bgp, rn, afi, safi); |
| 1231 | |
| 1232 | return 0; |
| 1233 | |
| 1234 | /* This BGP update is filtered. Log the reason then update BGP |
| 1235 | entry. */ |
| 1236 | filtered: |
| 1237 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1238 | zlog (peer->log, LOG_INFO, |
| 1239 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 1240 | peer->host, |
| 1241 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1242 | p->prefixlen, reason); |
| 1243 | |
| 1244 | if (ri) |
| 1245 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 1); |
| 1246 | |
| 1247 | bgp_unlock_node (rn); |
| 1248 | |
| 1249 | return 0; |
| 1250 | } |
| 1251 | |
| 1252 | int |
| 1253 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
| 1254 | int afi, int safi, int type, int sub_type, struct prefix_rd *prd, |
| 1255 | u_char *tag) |
| 1256 | { |
| 1257 | struct bgp *bgp; |
| 1258 | char buf[SU_ADDRSTRLEN]; |
| 1259 | struct bgp_node *rn; |
| 1260 | struct bgp_info *ri; |
| 1261 | |
| 1262 | bgp = peer->bgp; |
| 1263 | |
| 1264 | /* Logging. */ |
| 1265 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1266 | zlog (peer->log, LOG_INFO, "%s rcvd UPDATE about %s/%d -- withdrawn", |
| 1267 | peer->host, |
| 1268 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1269 | p->prefixlen); |
| 1270 | |
| 1271 | /* Lookup node. */ |
| 1272 | rn = bgp_afi_node_get (bgp, afi, safi, p, prd); |
| 1273 | |
| 1274 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 1275 | further calculation. */ |
| 1276 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1277 | && peer != bgp->peer_self) |
| 1278 | bgp_adj_in_unset (rn, peer); |
| 1279 | |
| 1280 | /* Lookup withdrawn route. */ |
| 1281 | for (ri = rn->info; ri; ri = ri->next) |
| 1282 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1283 | break; |
| 1284 | |
| 1285 | /* Withdraw specified route from routing table. */ |
| 1286 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1287 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 0); |
| 1288 | else if (BGP_DEBUG (update, UPDATE_IN)) |
| 1289 | zlog (peer->log, LOG_INFO, |
| 1290 | "%s Can't find the route %s/%d", peer->host, |
| 1291 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1292 | p->prefixlen); |
| 1293 | |
| 1294 | /* Unlock bgp_node_get() lock. */ |
| 1295 | bgp_unlock_node (rn); |
| 1296 | |
| 1297 | return 0; |
| 1298 | } |
| 1299 | |
| 1300 | void |
| 1301 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 1302 | { |
| 1303 | struct bgp *bgp; |
| 1304 | struct attr attr; |
| 1305 | struct aspath *aspath; |
| 1306 | struct prefix p; |
| 1307 | struct bgp_info binfo; |
| 1308 | struct peer *from; |
| 1309 | int ret = RMAP_DENYMATCH; |
| 1310 | |
| 1311 | bgp = peer->bgp; |
| 1312 | from = bgp->peer_self; |
| 1313 | |
| 1314 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 1315 | aspath = attr.aspath; |
| 1316 | attr.local_pref = bgp->default_local_pref; |
| 1317 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1318 | |
| 1319 | if (afi == AFI_IP) |
| 1320 | str2prefix ("0.0.0.0/0", &p); |
| 1321 | #ifdef HAVE_IPV6 |
| 1322 | else if (afi == AFI_IP6) |
| 1323 | { |
| 1324 | str2prefix ("::/0", &p); |
| 1325 | |
| 1326 | /* IPv6 global nexthop must be included. */ |
| 1327 | memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global, |
| 1328 | IPV6_MAX_BYTELEN); |
| 1329 | attr.mp_nexthop_len = 16; |
| 1330 | |
| 1331 | /* If the peer is on shared nextwork and we have link-local |
| 1332 | nexthop set it. */ |
| 1333 | if (peer->shared_network |
| 1334 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1335 | { |
| 1336 | memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local, |
| 1337 | IPV6_MAX_BYTELEN); |
| 1338 | attr.mp_nexthop_len = 32; |
| 1339 | } |
| 1340 | } |
| 1341 | #endif /* HAVE_IPV6 */ |
| 1342 | else |
| 1343 | return; |
| 1344 | |
| 1345 | if (peer->default_rmap[afi][safi].name) |
| 1346 | { |
| 1347 | binfo.peer = bgp->peer_self; |
| 1348 | binfo.attr = &attr; |
| 1349 | |
| 1350 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 1351 | RMAP_BGP, &binfo); |
| 1352 | |
| 1353 | if (ret == RMAP_DENYMATCH) |
| 1354 | { |
| 1355 | bgp_attr_flush (&attr); |
| 1356 | withdraw = 1; |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | if (withdraw) |
| 1361 | { |
| 1362 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1363 | bgp_default_withdraw_send (peer, afi, safi); |
| 1364 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 1365 | } |
| 1366 | else |
| 1367 | { |
| 1368 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 1369 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 1370 | } |
| 1371 | |
| 1372 | aspath_unintern (aspath); |
| 1373 | } |
| 1374 | |
| 1375 | static void |
| 1376 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
| 1377 | struct bgp_table *table) |
| 1378 | { |
| 1379 | struct bgp_node *rn; |
| 1380 | struct bgp_info *ri; |
| 1381 | struct attr attr; |
| 1382 | |
| 1383 | if (! table) |
| 1384 | table = peer->bgp->rib[afi][safi]; |
| 1385 | |
| 1386 | if (safi != SAFI_MPLS_VPN |
| 1387 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 1388 | bgp_default_originate (peer, afi, safi, 0); |
| 1389 | |
| 1390 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 1391 | for (ri = rn->info; ri; ri = ri->next) |
| 1392 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 1393 | { |
| 1394 | if (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)) |
| 1395 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 1396 | else |
| 1397 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 1398 | } |
| 1399 | } |
| 1400 | |
| 1401 | void |
| 1402 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 1403 | { |
| 1404 | struct bgp_node *rn; |
| 1405 | struct bgp_table *table; |
| 1406 | |
| 1407 | if (peer->status != Established) |
| 1408 | return; |
| 1409 | |
| 1410 | if (! peer->afc_nego[afi][safi]) |
| 1411 | return; |
| 1412 | |
| 1413 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 1414 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1415 | return; |
| 1416 | |
| 1417 | if (safi != SAFI_MPLS_VPN) |
| 1418 | bgp_announce_table (peer, afi, safi, NULL); |
| 1419 | else |
| 1420 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 1421 | rn = bgp_route_next(rn)) |
| 1422 | if ((table = (rn->info)) != NULL) |
| 1423 | bgp_announce_table (peer, afi, safi, table); |
| 1424 | } |
| 1425 | |
| 1426 | void |
| 1427 | bgp_announce_route_all (struct peer *peer) |
| 1428 | { |
| 1429 | afi_t afi; |
| 1430 | safi_t safi; |
| 1431 | |
| 1432 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 1433 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 1434 | bgp_announce_route (peer, afi, safi); |
| 1435 | } |
| 1436 | |
| 1437 | static void |
| 1438 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 1439 | struct bgp_table *table) |
| 1440 | { |
| 1441 | int ret; |
| 1442 | struct bgp_node *rn; |
| 1443 | struct bgp_adj_in *ain; |
| 1444 | |
| 1445 | if (! table) |
| 1446 | table = peer->bgp->rib[afi][safi]; |
| 1447 | |
| 1448 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 1449 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 1450 | { |
| 1451 | if (ain->peer == peer) |
| 1452 | { |
| 1453 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 1454 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 1455 | NULL, NULL, 1); |
| 1456 | if (ret < 0) |
| 1457 | { |
| 1458 | bgp_unlock_node (rn); |
| 1459 | return; |
| 1460 | } |
| 1461 | continue; |
| 1462 | } |
| 1463 | } |
| 1464 | } |
| 1465 | |
| 1466 | void |
| 1467 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 1468 | { |
| 1469 | struct bgp_node *rn; |
| 1470 | struct bgp_table *table; |
| 1471 | |
| 1472 | if (peer->status != Established) |
| 1473 | return; |
| 1474 | |
| 1475 | if (safi != SAFI_MPLS_VPN) |
| 1476 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 1477 | else |
| 1478 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 1479 | rn = bgp_route_next (rn)) |
| 1480 | if ((table = rn->info) != NULL) |
| 1481 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 1482 | } |
| 1483 | |
| 1484 | static void |
| 1485 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
| 1486 | struct bgp_table *table) |
| 1487 | { |
| 1488 | struct bgp_node *rn; |
| 1489 | struct bgp_adj_in *ain; |
| 1490 | struct bgp_adj_out *aout; |
| 1491 | struct bgp_info *ri; |
| 1492 | |
| 1493 | if (! table) |
| 1494 | table = peer->bgp->rib[afi][safi]; |
| 1495 | |
| 1496 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 1497 | { |
| 1498 | for (ri = rn->info; ri; ri = ri->next) |
| 1499 | if (ri->peer == peer) |
| 1500 | { |
| 1501 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 1502 | break; |
| 1503 | } |
| 1504 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 1505 | if (ain->peer == peer) |
| 1506 | { |
| 1507 | bgp_adj_in_remove (rn, ain); |
| 1508 | bgp_unlock_node (rn); |
| 1509 | break; |
| 1510 | } |
| 1511 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 1512 | if (aout->peer == peer) |
| 1513 | { |
| 1514 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 1515 | bgp_unlock_node (rn); |
| 1516 | break; |
| 1517 | } |
| 1518 | } |
| 1519 | } |
| 1520 | |
| 1521 | void |
| 1522 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
| 1523 | { |
| 1524 | struct bgp_node *rn; |
| 1525 | struct bgp_table *table; |
| 1526 | |
| 1527 | if (! peer->afc[afi][safi]) |
| 1528 | return; |
| 1529 | |
| 1530 | if (safi != SAFI_MPLS_VPN) |
| 1531 | bgp_clear_route_table (peer, afi, safi, NULL); |
| 1532 | else |
| 1533 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 1534 | rn = bgp_route_next (rn)) |
| 1535 | if ((table = rn->info) != NULL) |
| 1536 | bgp_clear_route_table (peer, afi, safi, table); |
| 1537 | } |
| 1538 | |
| 1539 | void |
| 1540 | bgp_clear_route_all (struct peer *peer) |
| 1541 | { |
| 1542 | afi_t afi; |
| 1543 | safi_t safi; |
| 1544 | |
| 1545 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 1546 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 1547 | bgp_clear_route (peer, afi, safi); |
| 1548 | } |
| 1549 | |
| 1550 | void |
| 1551 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 1552 | { |
| 1553 | struct bgp_table *table; |
| 1554 | struct bgp_node *rn; |
| 1555 | struct bgp_adj_in *ain; |
| 1556 | |
| 1557 | table = peer->bgp->rib[afi][safi]; |
| 1558 | |
| 1559 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 1560 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 1561 | if (ain->peer == peer) |
| 1562 | { |
| 1563 | bgp_adj_in_remove (rn, ain); |
| 1564 | bgp_unlock_node (rn); |
| 1565 | break; |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | /* Delete all kernel routes. */ |
| 1570 | void |
| 1571 | bgp_terminate () |
| 1572 | { |
| 1573 | struct bgp *bgp; |
| 1574 | struct listnode *nn; |
| 1575 | struct bgp_node *rn; |
| 1576 | struct bgp_table *table; |
| 1577 | struct bgp_info *ri; |
| 1578 | |
| 1579 | LIST_LOOP (bm->bgp, bgp, nn) |
| 1580 | { |
| 1581 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 1582 | |
| 1583 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 1584 | for (ri = rn->info; ri; ri = ri->next) |
| 1585 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 1586 | && ri->type == ZEBRA_ROUTE_BGP |
| 1587 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 1588 | bgp_zebra_withdraw (&rn->p, ri); |
| 1589 | |
| 1590 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 1591 | |
| 1592 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 1593 | for (ri = rn->info; ri; ri = ri->next) |
| 1594 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 1595 | && ri->type == ZEBRA_ROUTE_BGP |
| 1596 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 1597 | bgp_zebra_withdraw (&rn->p, ri); |
| 1598 | } |
| 1599 | } |
| 1600 | |
| 1601 | void |
| 1602 | bgp_reset () |
| 1603 | { |
| 1604 | vty_reset (); |
| 1605 | bgp_zclient_reset (); |
| 1606 | access_list_reset (); |
| 1607 | prefix_list_reset (); |
| 1608 | } |
| 1609 | |
| 1610 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 1611 | value. */ |
| 1612 | int |
| 1613 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 1614 | { |
| 1615 | u_char *pnt; |
| 1616 | u_char *lim; |
| 1617 | struct prefix p; |
| 1618 | int psize; |
| 1619 | int ret; |
| 1620 | |
| 1621 | /* Check peer status. */ |
| 1622 | if (peer->status != Established) |
| 1623 | return 0; |
| 1624 | |
| 1625 | pnt = packet->nlri; |
| 1626 | lim = pnt + packet->length; |
| 1627 | |
| 1628 | for (; pnt < lim; pnt += psize) |
| 1629 | { |
| 1630 | /* Clear prefix structure. */ |
| 1631 | memset (&p, 0, sizeof (struct prefix)); |
| 1632 | |
| 1633 | /* Fetch prefix length. */ |
| 1634 | p.prefixlen = *pnt++; |
| 1635 | p.family = afi2family (packet->afi); |
| 1636 | |
| 1637 | /* Already checked in nlri_sanity_check(). We do double check |
| 1638 | here. */ |
| 1639 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 1640 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 1641 | return -1; |
| 1642 | |
| 1643 | /* Packet size overflow check. */ |
| 1644 | psize = PSIZE (p.prefixlen); |
| 1645 | |
| 1646 | /* When packet overflow occur return immediately. */ |
| 1647 | if (pnt + psize > lim) |
| 1648 | return -1; |
| 1649 | |
| 1650 | /* Fetch prefix from NLRI packet. */ |
| 1651 | memcpy (&p.u.prefix, pnt, psize); |
| 1652 | |
| 1653 | /* Check address. */ |
| 1654 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 1655 | { |
| 1656 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 1657 | { |
| 1658 | zlog (peer->log, LOG_ERR, |
| 1659 | "IPv4 unicast NLRI is multicast address %s", |
| 1660 | inet_ntoa (p.u.prefix4)); |
| 1661 | bgp_notify_send (peer, |
| 1662 | BGP_NOTIFY_UPDATE_ERR, |
| 1663 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 1664 | return -1; |
| 1665 | } |
| 1666 | } |
| 1667 | |
| 1668 | #ifdef HAVE_IPV6 |
| 1669 | /* Check address. */ |
| 1670 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 1671 | { |
| 1672 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 1673 | { |
| 1674 | char buf[BUFSIZ]; |
| 1675 | |
| 1676 | zlog (peer->log, LOG_WARNING, |
| 1677 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 1678 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 1679 | |
| 1680 | continue; |
| 1681 | } |
| 1682 | } |
| 1683 | #endif /* HAVE_IPV6 */ |
| 1684 | |
| 1685 | /* Normal process. */ |
| 1686 | if (attr) |
| 1687 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 1688 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 1689 | else |
| 1690 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 1691 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 1692 | |
| 1693 | /* Address family configuration mismatch or maximum-prefix count |
| 1694 | overflow. */ |
| 1695 | if (ret < 0) |
| 1696 | return -1; |
| 1697 | } |
| 1698 | |
| 1699 | /* Packet length consistency check. */ |
| 1700 | if (pnt != lim) |
| 1701 | return -1; |
| 1702 | |
| 1703 | return 0; |
| 1704 | } |
| 1705 | |
| 1706 | /* NLRI encode syntax check routine. */ |
| 1707 | int |
| 1708 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 1709 | bgp_size_t length) |
| 1710 | { |
| 1711 | u_char *end; |
| 1712 | u_char prefixlen; |
| 1713 | int psize; |
| 1714 | |
| 1715 | end = pnt + length; |
| 1716 | |
| 1717 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 1718 | syntactic validity. If the field is syntactically incorrect, |
| 1719 | then the Error Subcode is set to Invalid Network Field. */ |
| 1720 | |
| 1721 | while (pnt < end) |
| 1722 | { |
| 1723 | prefixlen = *pnt++; |
| 1724 | |
| 1725 | /* Prefix length check. */ |
| 1726 | if ((afi == AFI_IP && prefixlen > 32) |
| 1727 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 1728 | { |
| 1729 | plog_err (peer->log, |
| 1730 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 1731 | peer->host, prefixlen); |
| 1732 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 1733 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 1734 | return -1; |
| 1735 | } |
| 1736 | |
| 1737 | /* Packet size overflow check. */ |
| 1738 | psize = PSIZE (prefixlen); |
| 1739 | |
| 1740 | if (pnt + psize > end) |
| 1741 | { |
| 1742 | plog_err (peer->log, |
| 1743 | "%s [Error] Update packet error" |
| 1744 | " (prefix data overflow prefix size is %d)", |
| 1745 | peer->host, psize); |
| 1746 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 1747 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 1748 | return -1; |
| 1749 | } |
| 1750 | |
| 1751 | pnt += psize; |
| 1752 | } |
| 1753 | |
| 1754 | /* Packet length consistency check. */ |
| 1755 | if (pnt != end) |
| 1756 | { |
| 1757 | plog_err (peer->log, |
| 1758 | "%s [Error] Update packet error" |
| 1759 | " (prefix length mismatch with total length)", |
| 1760 | peer->host); |
| 1761 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 1762 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 1763 | return -1; |
| 1764 | } |
| 1765 | return 0; |
| 1766 | } |
| 1767 | |
| 1768 | struct bgp_static * |
| 1769 | bgp_static_new () |
| 1770 | { |
| 1771 | struct bgp_static *new; |
| 1772 | new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
| 1773 | memset (new, 0, sizeof (struct bgp_static)); |
| 1774 | return new; |
| 1775 | } |
| 1776 | |
| 1777 | void |
| 1778 | bgp_static_free (struct bgp_static *bgp_static) |
| 1779 | { |
| 1780 | if (bgp_static->rmap.name) |
| 1781 | free (bgp_static->rmap.name); |
| 1782 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 1783 | } |
| 1784 | |
| 1785 | void |
| 1786 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 1787 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 1788 | { |
| 1789 | struct bgp_node *rn; |
| 1790 | struct bgp_info *ri; |
| 1791 | struct bgp_info *new; |
| 1792 | struct bgp_info info; |
| 1793 | struct attr attr; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1794 | struct attr attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1795 | struct attr *attr_new; |
| 1796 | int ret; |
| 1797 | |
| 1798 | rn = bgp_afi_node_get (bgp, afi, safi, p, NULL); |
| 1799 | |
| 1800 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 1801 | if (bgp_static) |
| 1802 | { |
| 1803 | attr.nexthop = bgp_static->igpnexthop; |
| 1804 | attr.med = bgp_static->igpmetric; |
| 1805 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 1806 | } |
| 1807 | |
| 1808 | /* Apply route-map. */ |
| 1809 | if (bgp_static->rmap.name) |
| 1810 | { |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1811 | attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1812 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1813 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1814 | |
| 1815 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1816 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1817 | if (ret == RMAP_DENYMATCH) |
| 1818 | { |
| 1819 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1820 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1821 | |
| 1822 | /* Unintern original. */ |
| 1823 | aspath_unintern (attr.aspath); |
| 1824 | bgp_static_withdraw (bgp, p, afi, safi); |
| 1825 | return; |
| 1826 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1827 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1828 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1829 | else |
| 1830 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1831 | |
| 1832 | for (ri = rn->info; ri; ri = ri->next) |
| 1833 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 1834 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 1835 | break; |
| 1836 | |
| 1837 | if (ri) |
| 1838 | { |
| 1839 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1840 | { |
| 1841 | bgp_unlock_node (rn); |
| 1842 | bgp_attr_unintern (attr_new); |
| 1843 | aspath_unintern (attr.aspath); |
| 1844 | return; |
| 1845 | } |
| 1846 | else |
| 1847 | { |
| 1848 | /* The attribute is changed. */ |
| 1849 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1850 | |
| 1851 | /* Rewrite BGP route information. */ |
| 1852 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 1853 | bgp_attr_unintern (ri->attr); |
| 1854 | ri->attr = attr_new; |
| 1855 | ri->uptime = time (NULL); |
| 1856 | |
| 1857 | /* Process change. */ |
| 1858 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1859 | bgp_process (bgp, rn, afi, safi); |
| 1860 | bgp_unlock_node (rn); |
| 1861 | aspath_unintern (attr.aspath); |
| 1862 | return; |
| 1863 | } |
| 1864 | } |
| 1865 | |
| 1866 | /* Make new BGP info. */ |
| 1867 | new = bgp_info_new (); |
| 1868 | new->type = ZEBRA_ROUTE_BGP; |
| 1869 | new->sub_type = BGP_ROUTE_STATIC; |
| 1870 | new->peer = bgp->peer_self; |
| 1871 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1872 | new->attr = attr_new; |
| 1873 | new->uptime = time (NULL); |
| 1874 | |
| 1875 | /* Aggregate address increment. */ |
| 1876 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 1877 | |
| 1878 | /* Register new BGP information. */ |
| 1879 | bgp_info_add (rn, new); |
| 1880 | |
| 1881 | /* Process change. */ |
| 1882 | bgp_process (bgp, rn, afi, safi); |
| 1883 | |
| 1884 | /* Unintern original. */ |
| 1885 | aspath_unintern (attr.aspath); |
| 1886 | } |
| 1887 | |
| 1888 | void |
| 1889 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 1890 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 1891 | { |
| 1892 | struct bgp_node *rn; |
| 1893 | struct bgp_info *new; |
| 1894 | |
| 1895 | rn = bgp_afi_node_get (bgp, afi, safi, p, prd); |
| 1896 | |
| 1897 | /* Make new BGP info. */ |
| 1898 | new = bgp_info_new (); |
| 1899 | new->type = ZEBRA_ROUTE_BGP; |
| 1900 | new->sub_type = BGP_ROUTE_STATIC; |
| 1901 | new->peer = bgp->peer_self; |
| 1902 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 1903 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1904 | new->uptime = time (NULL); |
| 1905 | memcpy (new->tag, tag, 3); |
| 1906 | |
| 1907 | /* Aggregate address increment. */ |
| 1908 | bgp_aggregate_increment (bgp, p, (struct bgp_info *) new, afi, safi); |
| 1909 | |
| 1910 | /* Register new BGP information. */ |
| 1911 | bgp_info_add (rn, (struct bgp_info *) new); |
| 1912 | |
| 1913 | /* Process change. */ |
| 1914 | bgp_process (bgp, rn, afi, safi); |
| 1915 | } |
| 1916 | |
| 1917 | void |
| 1918 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 1919 | safi_t safi) |
| 1920 | { |
| 1921 | struct bgp_node *rn; |
| 1922 | struct bgp_info *ri; |
| 1923 | |
| 1924 | rn = bgp_afi_node_get (bgp, afi, safi, p, NULL); |
| 1925 | |
| 1926 | /* Check selected route and self inserted route. */ |
| 1927 | for (ri = rn->info; ri; ri = ri->next) |
| 1928 | if (ri->peer == bgp->peer_self |
| 1929 | && ri->type == ZEBRA_ROUTE_BGP |
| 1930 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 1931 | break; |
| 1932 | |
| 1933 | /* Withdraw static BGP route from routing table. */ |
| 1934 | if (ri) |
| 1935 | { |
| 1936 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 1937 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1938 | bgp_process (bgp, rn, afi, safi); |
| 1939 | bgp_info_delete (rn, ri); |
| 1940 | bgp_info_free (ri); |
| 1941 | bgp_unlock_node (rn); |
| 1942 | } |
| 1943 | |
| 1944 | /* Unlock bgp_node_lookup. */ |
| 1945 | bgp_unlock_node (rn); |
| 1946 | } |
| 1947 | |
| 1948 | void |
| 1949 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 1950 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 1951 | { |
| 1952 | struct bgp_node *rn; |
| 1953 | struct bgp_info *ri; |
| 1954 | |
| 1955 | rn = bgp_afi_node_get (bgp, afi, safi, p, prd); |
| 1956 | |
| 1957 | /* Check selected route and self inserted route. */ |
| 1958 | for (ri = rn->info; ri; ri = ri->next) |
| 1959 | if (ri->peer == bgp->peer_self |
| 1960 | && ri->type == ZEBRA_ROUTE_BGP |
| 1961 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 1962 | break; |
| 1963 | |
| 1964 | /* Withdraw static BGP route from routing table. */ |
| 1965 | if (ri) |
| 1966 | { |
| 1967 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 1968 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1969 | bgp_process (bgp, rn, afi, safi); |
| 1970 | bgp_info_delete (rn, ri); |
| 1971 | bgp_info_free (ri); |
| 1972 | bgp_unlock_node (rn); |
| 1973 | } |
| 1974 | |
| 1975 | /* Unlock bgp_node_lookup. */ |
| 1976 | bgp_unlock_node (rn); |
| 1977 | } |
| 1978 | |
| 1979 | /* Configure static BGP network. When user don't run zebra, static |
| 1980 | route should be installed as valid. */ |
| 1981 | int |
| 1982 | bgp_static_set (struct vty *vty, struct bgp *bgp, char *ip_str, u_int16_t afi, |
| 1983 | u_char safi, char *rmap, int backdoor) |
| 1984 | { |
| 1985 | int ret; |
| 1986 | struct prefix p; |
| 1987 | struct bgp_static *bgp_static; |
| 1988 | struct bgp_node *rn; |
| 1989 | int need_update = 0; |
| 1990 | |
| 1991 | /* Convert IP prefix string to struct prefix. */ |
| 1992 | ret = str2prefix (ip_str, &p); |
| 1993 | if (! ret) |
| 1994 | { |
| 1995 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 1996 | return CMD_WARNING; |
| 1997 | } |
| 1998 | #ifdef HAVE_IPV6 |
| 1999 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2000 | { |
| 2001 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 2002 | VTY_NEWLINE); |
| 2003 | return CMD_WARNING; |
| 2004 | } |
| 2005 | #endif /* HAVE_IPV6 */ |
| 2006 | |
| 2007 | apply_mask (&p); |
| 2008 | |
| 2009 | /* Set BGP static route configuration. */ |
| 2010 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 2011 | |
| 2012 | if (rn->info) |
| 2013 | { |
| 2014 | /* Configuration change. */ |
| 2015 | bgp_static = rn->info; |
| 2016 | |
| 2017 | /* Check previous routes are installed into BGP. */ |
| 2018 | if (! bgp_static->backdoor && bgp_static->valid) |
| 2019 | need_update = 1; |
| 2020 | |
| 2021 | bgp_static->backdoor = backdoor; |
| 2022 | if (rmap) |
| 2023 | { |
| 2024 | if (bgp_static->rmap.name) |
| 2025 | free (bgp_static->rmap.name); |
| 2026 | bgp_static->rmap.name = strdup (rmap); |
| 2027 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 2028 | } |
| 2029 | else |
| 2030 | { |
| 2031 | if (bgp_static->rmap.name) |
| 2032 | free (bgp_static->rmap.name); |
| 2033 | bgp_static->rmap.name = NULL; |
| 2034 | bgp_static->rmap.map = NULL; |
| 2035 | bgp_static->valid = 0; |
| 2036 | } |
| 2037 | bgp_unlock_node (rn); |
| 2038 | } |
| 2039 | else |
| 2040 | { |
| 2041 | /* New configuration. */ |
| 2042 | bgp_static = bgp_static_new (); |
| 2043 | bgp_static->backdoor = backdoor; |
| 2044 | bgp_static->valid = 0; |
| 2045 | bgp_static->igpmetric = 0; |
| 2046 | bgp_static->igpnexthop.s_addr = 0; |
| 2047 | if (rmap) |
| 2048 | { |
| 2049 | if (bgp_static->rmap.name) |
| 2050 | free (bgp_static->rmap.name); |
| 2051 | bgp_static->rmap.name = strdup (rmap); |
| 2052 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 2053 | } |
| 2054 | rn->info = bgp_static; |
| 2055 | } |
| 2056 | |
| 2057 | /* If BGP scan is not enabled, we should install this route here. */ |
| 2058 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 2059 | { |
| 2060 | bgp_static->valid = 1; |
| 2061 | |
| 2062 | if (need_update) |
| 2063 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 2064 | |
| 2065 | if (! bgp_static->backdoor) |
| 2066 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 2067 | } |
| 2068 | |
| 2069 | return CMD_SUCCESS; |
| 2070 | } |
| 2071 | |
| 2072 | /* Configure static BGP network. */ |
| 2073 | int |
| 2074 | bgp_static_unset (struct vty *vty, struct bgp *bgp, char *ip_str, |
| 2075 | u_int16_t afi, u_char safi) |
| 2076 | { |
| 2077 | int ret; |
| 2078 | struct prefix p; |
| 2079 | struct bgp_static *bgp_static; |
| 2080 | struct bgp_node *rn; |
| 2081 | |
| 2082 | /* Convert IP prefix string to struct prefix. */ |
| 2083 | ret = str2prefix (ip_str, &p); |
| 2084 | if (! ret) |
| 2085 | { |
| 2086 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 2087 | return CMD_WARNING; |
| 2088 | } |
| 2089 | #ifdef HAVE_IPV6 |
| 2090 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2091 | { |
| 2092 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 2093 | VTY_NEWLINE); |
| 2094 | return CMD_WARNING; |
| 2095 | } |
| 2096 | #endif /* HAVE_IPV6 */ |
| 2097 | |
| 2098 | apply_mask (&p); |
| 2099 | |
| 2100 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 2101 | if (! rn) |
| 2102 | { |
| 2103 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 2104 | VTY_NEWLINE); |
| 2105 | return CMD_WARNING; |
| 2106 | } |
| 2107 | |
| 2108 | bgp_static = rn->info; |
| 2109 | |
| 2110 | /* Update BGP RIB. */ |
| 2111 | if (! bgp_static->backdoor) |
| 2112 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 2113 | |
| 2114 | /* Clear configuration. */ |
| 2115 | bgp_static_free (bgp_static); |
| 2116 | rn->info = NULL; |
| 2117 | bgp_unlock_node (rn); |
| 2118 | bgp_unlock_node (rn); |
| 2119 | |
| 2120 | return CMD_SUCCESS; |
| 2121 | } |
| 2122 | |
| 2123 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 2124 | instance. */ |
| 2125 | void |
| 2126 | bgp_static_delete (struct bgp *bgp) |
| 2127 | { |
| 2128 | afi_t afi; |
| 2129 | safi_t safi; |
| 2130 | struct bgp_node *rn; |
| 2131 | struct bgp_node *rm; |
| 2132 | struct bgp_table *table; |
| 2133 | struct bgp_static *bgp_static; |
| 2134 | |
| 2135 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2136 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2137 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 2138 | if (rn->info != NULL) |
| 2139 | { |
| 2140 | if (safi == SAFI_MPLS_VPN) |
| 2141 | { |
| 2142 | table = rn->info; |
| 2143 | |
| 2144 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 2145 | { |
| 2146 | bgp_static = rn->info; |
| 2147 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 2148 | AFI_IP, SAFI_MPLS_VPN, |
| 2149 | (struct prefix_rd *)&rn->p, |
| 2150 | bgp_static->tag); |
| 2151 | bgp_static_free (bgp_static); |
| 2152 | rn->info = NULL; |
| 2153 | bgp_unlock_node (rn); |
| 2154 | } |
| 2155 | } |
| 2156 | else |
| 2157 | { |
| 2158 | bgp_static = rn->info; |
| 2159 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 2160 | bgp_static_free (bgp_static); |
| 2161 | rn->info = NULL; |
| 2162 | bgp_unlock_node (rn); |
| 2163 | } |
| 2164 | } |
| 2165 | } |
| 2166 | |
| 2167 | int |
| 2168 | bgp_static_set_vpnv4 (struct vty *vty, char *ip_str, char *rd_str, |
| 2169 | char *tag_str) |
| 2170 | { |
| 2171 | int ret; |
| 2172 | struct prefix p; |
| 2173 | struct prefix_rd prd; |
| 2174 | struct bgp *bgp; |
| 2175 | struct bgp_node *prn; |
| 2176 | struct bgp_node *rn; |
| 2177 | struct bgp_table *table; |
| 2178 | struct bgp_static *bgp_static; |
| 2179 | u_char tag[3]; |
| 2180 | |
| 2181 | bgp = vty->index; |
| 2182 | |
| 2183 | ret = str2prefix (ip_str, &p); |
| 2184 | if (! ret) |
| 2185 | { |
| 2186 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 2187 | return CMD_WARNING; |
| 2188 | } |
| 2189 | apply_mask (&p); |
| 2190 | |
| 2191 | ret = str2prefix_rd (rd_str, &prd); |
| 2192 | if (! ret) |
| 2193 | { |
| 2194 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 2195 | return CMD_WARNING; |
| 2196 | } |
| 2197 | |
| 2198 | ret = str2tag (tag_str, tag); |
| 2199 | if (! ret) |
| 2200 | { |
| 2201 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 2202 | return CMD_WARNING; |
| 2203 | } |
| 2204 | |
| 2205 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 2206 | (struct prefix *)&prd); |
| 2207 | if (prn->info == NULL) |
| 2208 | prn->info = bgp_table_init (); |
| 2209 | else |
| 2210 | bgp_unlock_node (prn); |
| 2211 | table = prn->info; |
| 2212 | |
| 2213 | rn = bgp_node_get (table, &p); |
| 2214 | |
| 2215 | if (rn->info) |
| 2216 | { |
| 2217 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 2218 | bgp_unlock_node (rn); |
| 2219 | } |
| 2220 | else |
| 2221 | { |
| 2222 | /* New configuration. */ |
| 2223 | bgp_static = bgp_static_new (); |
| 2224 | bgp_static->valid = 1; |
| 2225 | memcpy (bgp_static->tag, tag, 3); |
| 2226 | rn->info = bgp_static; |
| 2227 | |
| 2228 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 2229 | } |
| 2230 | |
| 2231 | return CMD_SUCCESS; |
| 2232 | } |
| 2233 | |
| 2234 | /* Configure static BGP network. */ |
| 2235 | int |
| 2236 | bgp_static_unset_vpnv4 (struct vty *vty, char *ip_str, char *rd_str, |
| 2237 | char *tag_str) |
| 2238 | { |
| 2239 | int ret; |
| 2240 | struct bgp *bgp; |
| 2241 | struct prefix p; |
| 2242 | struct prefix_rd prd; |
| 2243 | struct bgp_node *prn; |
| 2244 | struct bgp_node *rn; |
| 2245 | struct bgp_table *table; |
| 2246 | struct bgp_static *bgp_static; |
| 2247 | u_char tag[3]; |
| 2248 | |
| 2249 | bgp = vty->index; |
| 2250 | |
| 2251 | /* Convert IP prefix string to struct prefix. */ |
| 2252 | ret = str2prefix (ip_str, &p); |
| 2253 | if (! ret) |
| 2254 | { |
| 2255 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 2256 | return CMD_WARNING; |
| 2257 | } |
| 2258 | apply_mask (&p); |
| 2259 | |
| 2260 | ret = str2prefix_rd (rd_str, &prd); |
| 2261 | if (! ret) |
| 2262 | { |
| 2263 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 2264 | return CMD_WARNING; |
| 2265 | } |
| 2266 | |
| 2267 | ret = str2tag (tag_str, tag); |
| 2268 | if (! ret) |
| 2269 | { |
| 2270 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 2271 | return CMD_WARNING; |
| 2272 | } |
| 2273 | |
| 2274 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 2275 | (struct prefix *)&prd); |
| 2276 | if (prn->info == NULL) |
| 2277 | prn->info = bgp_table_init (); |
| 2278 | else |
| 2279 | bgp_unlock_node (prn); |
| 2280 | table = prn->info; |
| 2281 | |
| 2282 | rn = bgp_node_lookup (table, &p); |
| 2283 | |
| 2284 | if (rn) |
| 2285 | { |
| 2286 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 2287 | |
| 2288 | bgp_static = rn->info; |
| 2289 | bgp_static_free (bgp_static); |
| 2290 | rn->info = NULL; |
| 2291 | bgp_unlock_node (rn); |
| 2292 | bgp_unlock_node (rn); |
| 2293 | } |
| 2294 | else |
| 2295 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 2296 | |
| 2297 | return CMD_SUCCESS; |
| 2298 | } |
| 2299 | |
| 2300 | DEFUN (bgp_network, |
| 2301 | bgp_network_cmd, |
| 2302 | "network A.B.C.D/M", |
| 2303 | "Specify a network to announce via BGP\n" |
| 2304 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 2305 | { |
| 2306 | return bgp_static_set (vty, vty->index, argv[0], |
| 2307 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 2308 | } |
| 2309 | |
| 2310 | DEFUN (bgp_network_route_map, |
| 2311 | bgp_network_route_map_cmd, |
| 2312 | "network A.B.C.D/M route-map WORD", |
| 2313 | "Specify a network to announce via BGP\n" |
| 2314 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 2315 | "Route-map to modify the attributes\n" |
| 2316 | "Name of the route map\n") |
| 2317 | { |
| 2318 | return bgp_static_set (vty, vty->index, argv[0], |
| 2319 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 2320 | } |
| 2321 | |
| 2322 | DEFUN (bgp_network_backdoor, |
| 2323 | bgp_network_backdoor_cmd, |
| 2324 | "network A.B.C.D/M backdoor", |
| 2325 | "Specify a network to announce via BGP\n" |
| 2326 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 2327 | "Specify a BGP backdoor route\n") |
| 2328 | { |
| 2329 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 2330 | } |
| 2331 | |
| 2332 | DEFUN (bgp_network_mask, |
| 2333 | bgp_network_mask_cmd, |
| 2334 | "network A.B.C.D mask A.B.C.D", |
| 2335 | "Specify a network to announce via BGP\n" |
| 2336 | "Network number\n" |
| 2337 | "Network mask\n" |
| 2338 | "Network mask\n") |
| 2339 | { |
| 2340 | int ret; |
| 2341 | char prefix_str[BUFSIZ]; |
| 2342 | |
| 2343 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 2344 | if (! ret) |
| 2345 | { |
| 2346 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 2347 | return CMD_WARNING; |
| 2348 | } |
| 2349 | |
| 2350 | return bgp_static_set (vty, vty->index, prefix_str, |
| 2351 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 2352 | } |
| 2353 | |
| 2354 | DEFUN (bgp_network_mask_route_map, |
| 2355 | bgp_network_mask_route_map_cmd, |
| 2356 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 2357 | "Specify a network to announce via BGP\n" |
| 2358 | "Network number\n" |
| 2359 | "Network mask\n" |
| 2360 | "Network mask\n" |
| 2361 | "Route-map to modify the attributes\n" |
| 2362 | "Name of the route map\n") |
| 2363 | { |
| 2364 | int ret; |
| 2365 | char prefix_str[BUFSIZ]; |
| 2366 | |
| 2367 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 2368 | if (! ret) |
| 2369 | { |
| 2370 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 2371 | return CMD_WARNING; |
| 2372 | } |
| 2373 | |
| 2374 | return bgp_static_set (vty, vty->index, prefix_str, |
| 2375 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
| 2376 | } |
| 2377 | |
| 2378 | DEFUN (bgp_network_mask_backdoor, |
| 2379 | bgp_network_mask_backdoor_cmd, |
| 2380 | "network A.B.C.D mask A.B.C.D backdoor", |
| 2381 | "Specify a network to announce via BGP\n" |
| 2382 | "Network number\n" |
| 2383 | "Network mask\n" |
| 2384 | "Network mask\n" |
| 2385 | "Specify a BGP backdoor route\n") |
| 2386 | { |
| 2387 | int ret; |
| 2388 | char prefix_str[BUFSIZ]; |
| 2389 | |
| 2390 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 2391 | if (! ret) |
| 2392 | { |
| 2393 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 2394 | return CMD_WARNING; |
| 2395 | } |
| 2396 | |
| 2397 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 2398 | } |
| 2399 | |
| 2400 | DEFUN (bgp_network_mask_natural, |
| 2401 | bgp_network_mask_natural_cmd, |
| 2402 | "network A.B.C.D", |
| 2403 | "Specify a network to announce via BGP\n" |
| 2404 | "Network number\n") |
| 2405 | { |
| 2406 | int ret; |
| 2407 | char prefix_str[BUFSIZ]; |
| 2408 | |
| 2409 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 2410 | if (! ret) |
| 2411 | { |
| 2412 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 2413 | return CMD_WARNING; |
| 2414 | } |
| 2415 | |
| 2416 | return bgp_static_set (vty, vty->index, prefix_str, |
| 2417 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 2418 | } |
| 2419 | |
| 2420 | DEFUN (bgp_network_mask_natural_route_map, |
| 2421 | bgp_network_mask_natural_route_map_cmd, |
| 2422 | "network A.B.C.D route-map WORD", |
| 2423 | "Specify a network to announce via BGP\n" |
| 2424 | "Network number\n" |
| 2425 | "Route-map to modify the attributes\n" |
| 2426 | "Name of the route map\n") |
| 2427 | { |
| 2428 | int ret; |
| 2429 | char prefix_str[BUFSIZ]; |
| 2430 | |
| 2431 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 2432 | if (! ret) |
| 2433 | { |
| 2434 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 2435 | return CMD_WARNING; |
| 2436 | } |
| 2437 | |
| 2438 | return bgp_static_set (vty, vty->index, prefix_str, |
| 2439 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 2440 | } |
| 2441 | |
| 2442 | DEFUN (bgp_network_mask_natural_backdoor, |
| 2443 | bgp_network_mask_natural_backdoor_cmd, |
| 2444 | "network A.B.C.D backdoor", |
| 2445 | "Specify a network to announce via BGP\n" |
| 2446 | "Network number\n" |
| 2447 | "Specify a BGP backdoor route\n") |
| 2448 | { |
| 2449 | int ret; |
| 2450 | char prefix_str[BUFSIZ]; |
| 2451 | |
| 2452 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 2453 | if (! ret) |
| 2454 | { |
| 2455 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 2456 | return CMD_WARNING; |
| 2457 | } |
| 2458 | |
| 2459 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 2460 | } |
| 2461 | |
| 2462 | DEFUN (no_bgp_network, |
| 2463 | no_bgp_network_cmd, |
| 2464 | "no network A.B.C.D/M", |
| 2465 | NO_STR |
| 2466 | "Specify a network to announce via BGP\n" |
| 2467 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 2468 | { |
| 2469 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 2470 | bgp_node_safi (vty)); |
| 2471 | } |
| 2472 | |
| 2473 | ALIAS (no_bgp_network, |
| 2474 | no_bgp_network_route_map_cmd, |
| 2475 | "no network A.B.C.D/M route-map WORD", |
| 2476 | NO_STR |
| 2477 | "Specify a network to announce via BGP\n" |
| 2478 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 2479 | "Route-map to modify the attributes\n" |
| 2480 | "Name of the route map\n") |
| 2481 | |
| 2482 | ALIAS (no_bgp_network, |
| 2483 | no_bgp_network_backdoor_cmd, |
| 2484 | "no network A.B.C.D/M backdoor", |
| 2485 | NO_STR |
| 2486 | "Specify a network to announce via BGP\n" |
| 2487 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 2488 | "Specify a BGP backdoor route\n") |
| 2489 | |
| 2490 | DEFUN (no_bgp_network_mask, |
| 2491 | no_bgp_network_mask_cmd, |
| 2492 | "no network A.B.C.D mask A.B.C.D", |
| 2493 | NO_STR |
| 2494 | "Specify a network to announce via BGP\n" |
| 2495 | "Network number\n" |
| 2496 | "Network mask\n" |
| 2497 | "Network mask\n") |
| 2498 | { |
| 2499 | int ret; |
| 2500 | char prefix_str[BUFSIZ]; |
| 2501 | |
| 2502 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 2503 | if (! ret) |
| 2504 | { |
| 2505 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 2506 | return CMD_WARNING; |
| 2507 | } |
| 2508 | |
| 2509 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 2510 | bgp_node_safi (vty)); |
| 2511 | } |
| 2512 | |
| 2513 | ALIAS (no_bgp_network_mask, |
| 2514 | no_bgp_network_mask_route_map_cmd, |
| 2515 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 2516 | NO_STR |
| 2517 | "Specify a network to announce via BGP\n" |
| 2518 | "Network number\n" |
| 2519 | "Network mask\n" |
| 2520 | "Network mask\n" |
| 2521 | "Route-map to modify the attributes\n" |
| 2522 | "Name of the route map\n") |
| 2523 | |
| 2524 | ALIAS (no_bgp_network_mask, |
| 2525 | no_bgp_network_mask_backdoor_cmd, |
| 2526 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 2527 | NO_STR |
| 2528 | "Specify a network to announce via BGP\n" |
| 2529 | "Network number\n" |
| 2530 | "Network mask\n" |
| 2531 | "Network mask\n" |
| 2532 | "Specify a BGP backdoor route\n") |
| 2533 | |
| 2534 | DEFUN (no_bgp_network_mask_natural, |
| 2535 | no_bgp_network_mask_natural_cmd, |
| 2536 | "no network A.B.C.D", |
| 2537 | NO_STR |
| 2538 | "Specify a network to announce via BGP\n" |
| 2539 | "Network number\n") |
| 2540 | { |
| 2541 | int ret; |
| 2542 | char prefix_str[BUFSIZ]; |
| 2543 | |
| 2544 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 2545 | if (! ret) |
| 2546 | { |
| 2547 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 2548 | return CMD_WARNING; |
| 2549 | } |
| 2550 | |
| 2551 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 2552 | bgp_node_safi (vty)); |
| 2553 | } |
| 2554 | |
| 2555 | ALIAS (no_bgp_network_mask_natural, |
| 2556 | no_bgp_network_mask_natural_route_map_cmd, |
| 2557 | "no network A.B.C.D route-map WORD", |
| 2558 | NO_STR |
| 2559 | "Specify a network to announce via BGP\n" |
| 2560 | "Network number\n" |
| 2561 | "Route-map to modify the attributes\n" |
| 2562 | "Name of the route map\n") |
| 2563 | |
| 2564 | ALIAS (no_bgp_network_mask_natural, |
| 2565 | no_bgp_network_mask_natural_backdoor_cmd, |
| 2566 | "no network A.B.C.D backdoor", |
| 2567 | NO_STR |
| 2568 | "Specify a network to announce via BGP\n" |
| 2569 | "Network number\n" |
| 2570 | "Specify a BGP backdoor route\n") |
| 2571 | |
| 2572 | #ifdef HAVE_IPV6 |
| 2573 | DEFUN (ipv6_bgp_network, |
| 2574 | ipv6_bgp_network_cmd, |
| 2575 | "network X:X::X:X/M", |
| 2576 | "Specify a network to announce via BGP\n" |
| 2577 | "IPv6 prefix <network>/<length>\n") |
| 2578 | { |
| 2579 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 2580 | } |
| 2581 | |
| 2582 | DEFUN (ipv6_bgp_network_route_map, |
| 2583 | ipv6_bgp_network_route_map_cmd, |
| 2584 | "network X:X::X:X/M route-map WORD", |
| 2585 | "Specify a network to announce via BGP\n" |
| 2586 | "IPv6 prefix <network>/<length>\n" |
| 2587 | "Route-map to modify the attributes\n" |
| 2588 | "Name of the route map\n") |
| 2589 | { |
| 2590 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
| 2591 | bgp_node_safi (vty), argv[1], 0); |
| 2592 | } |
| 2593 | |
| 2594 | DEFUN (no_ipv6_bgp_network, |
| 2595 | no_ipv6_bgp_network_cmd, |
| 2596 | "no network X:X::X:X/M", |
| 2597 | NO_STR |
| 2598 | "Specify a network to announce via BGP\n" |
| 2599 | "IPv6 prefix <network>/<length>\n") |
| 2600 | { |
| 2601 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); |
| 2602 | } |
| 2603 | |
| 2604 | ALIAS (no_ipv6_bgp_network, |
| 2605 | no_ipv6_bgp_network_route_map_cmd, |
| 2606 | "no network X:X::X:X/M route-map WORD", |
| 2607 | NO_STR |
| 2608 | "Specify a network to announce via BGP\n" |
| 2609 | "IPv6 prefix <network>/<length>\n" |
| 2610 | "Route-map to modify the attributes\n" |
| 2611 | "Name of the route map\n") |
| 2612 | |
| 2613 | ALIAS (ipv6_bgp_network, |
| 2614 | old_ipv6_bgp_network_cmd, |
| 2615 | "ipv6 bgp network X:X::X:X/M", |
| 2616 | IPV6_STR |
| 2617 | BGP_STR |
| 2618 | "Specify a network to announce via BGP\n" |
| 2619 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 2620 | |
| 2621 | ALIAS (no_ipv6_bgp_network, |
| 2622 | old_no_ipv6_bgp_network_cmd, |
| 2623 | "no ipv6 bgp network X:X::X:X/M", |
| 2624 | NO_STR |
| 2625 | IPV6_STR |
| 2626 | BGP_STR |
| 2627 | "Specify a network to announce via BGP\n" |
| 2628 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 2629 | #endif /* HAVE_IPV6 */ |
| 2630 | |
| 2631 | /* Aggreagete address: |
| 2632 | |
| 2633 | advertise-map Set condition to advertise attribute |
| 2634 | as-set Generate AS set path information |
| 2635 | attribute-map Set attributes of aggregate |
| 2636 | route-map Set parameters of aggregate |
| 2637 | summary-only Filter more specific routes from updates |
| 2638 | suppress-map Conditionally filter more specific routes from updates |
| 2639 | <cr> |
| 2640 | */ |
| 2641 | struct bgp_aggregate |
| 2642 | { |
| 2643 | /* Summary-only flag. */ |
| 2644 | u_char summary_only; |
| 2645 | |
| 2646 | /* AS set generation. */ |
| 2647 | u_char as_set; |
| 2648 | |
| 2649 | /* Route-map for aggregated route. */ |
| 2650 | struct route_map *map; |
| 2651 | |
| 2652 | /* Suppress-count. */ |
| 2653 | unsigned long count; |
| 2654 | |
| 2655 | /* SAFI configuration. */ |
| 2656 | safi_t safi; |
| 2657 | }; |
| 2658 | |
| 2659 | struct bgp_aggregate * |
| 2660 | bgp_aggregate_new () |
| 2661 | { |
| 2662 | struct bgp_aggregate *new; |
| 2663 | new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
| 2664 | memset (new, 0, sizeof (struct bgp_aggregate)); |
| 2665 | return new; |
| 2666 | } |
| 2667 | |
| 2668 | void |
| 2669 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 2670 | { |
| 2671 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 2672 | } |
| 2673 | |
| 2674 | void |
| 2675 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 2676 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 2677 | struct bgp_aggregate *aggregate) |
| 2678 | { |
| 2679 | struct bgp_table *table; |
| 2680 | struct bgp_node *top; |
| 2681 | struct bgp_node *rn; |
| 2682 | u_char origin; |
| 2683 | struct aspath *aspath = NULL; |
| 2684 | struct aspath *asmerge = NULL; |
| 2685 | struct community *community = NULL; |
| 2686 | struct community *commerge = NULL; |
| 2687 | struct in_addr nexthop; |
| 2688 | u_int32_t med = 0; |
| 2689 | struct bgp_info *ri; |
| 2690 | struct bgp_info *new; |
| 2691 | int first = 1; |
| 2692 | unsigned long match = 0; |
| 2693 | |
| 2694 | /* Record adding route's nexthop and med. */ |
| 2695 | if (rinew) |
| 2696 | { |
| 2697 | nexthop = rinew->attr->nexthop; |
| 2698 | med = rinew->attr->med; |
| 2699 | } |
| 2700 | |
| 2701 | /* ORIGIN attribute: If at least one route among routes that are |
| 2702 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 2703 | aggregated route must have the ORIGIN attribute with the value |
| 2704 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 2705 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 2706 | route must have the origin attribute with the value EGP. In all |
| 2707 | other case the value of the ORIGIN attribute of the aggregated |
| 2708 | route is INTERNAL. */ |
| 2709 | origin = BGP_ORIGIN_IGP; |
| 2710 | |
| 2711 | table = bgp->rib[afi][safi]; |
| 2712 | |
| 2713 | top = bgp_node_get (table, p); |
| 2714 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 2715 | if (rn->p.prefixlen > p->prefixlen) |
| 2716 | { |
| 2717 | match = 0; |
| 2718 | |
| 2719 | for (ri = rn->info; ri; ri = ri->next) |
| 2720 | { |
| 2721 | if (BGP_INFO_HOLDDOWN (ri)) |
| 2722 | continue; |
| 2723 | |
| 2724 | if (del && ri == del) |
| 2725 | continue; |
| 2726 | |
| 2727 | if (! rinew && first) |
| 2728 | { |
| 2729 | nexthop = ri->attr->nexthop; |
| 2730 | med = ri->attr->med; |
| 2731 | first = 0; |
| 2732 | } |
| 2733 | |
| 2734 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 2735 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 2736 | || ri->attr->med != med) |
| 2737 | { |
| 2738 | if (aspath) |
| 2739 | aspath_free (aspath); |
| 2740 | if (community) |
| 2741 | community_free (community); |
| 2742 | bgp_unlock_node (rn); |
| 2743 | bgp_unlock_node (top); |
| 2744 | return; |
| 2745 | } |
| 2746 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 2747 | |
| 2748 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 2749 | { |
| 2750 | if (aggregate->summary_only) |
| 2751 | { |
| 2752 | ri->suppress++; |
| 2753 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2754 | match++; |
| 2755 | } |
| 2756 | |
| 2757 | aggregate->count++; |
| 2758 | |
| 2759 | if (aggregate->as_set) |
| 2760 | { |
| 2761 | if (origin < ri->attr->origin) |
| 2762 | origin = ri->attr->origin; |
| 2763 | |
| 2764 | if (aspath) |
| 2765 | { |
| 2766 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 2767 | aspath_free (aspath); |
| 2768 | aspath = asmerge; |
| 2769 | } |
| 2770 | else |
| 2771 | aspath = aspath_dup (ri->attr->aspath); |
| 2772 | |
| 2773 | if (ri->attr->community) |
| 2774 | { |
| 2775 | if (community) |
| 2776 | { |
| 2777 | commerge = community_merge (community, |
| 2778 | ri->attr->community); |
| 2779 | community = community_uniq_sort (commerge); |
| 2780 | community_free (commerge); |
| 2781 | } |
| 2782 | else |
| 2783 | community = community_dup (ri->attr->community); |
| 2784 | } |
| 2785 | } |
| 2786 | } |
| 2787 | } |
| 2788 | if (match) |
| 2789 | bgp_process (bgp, rn, afi, safi); |
| 2790 | } |
| 2791 | bgp_unlock_node (top); |
| 2792 | |
| 2793 | if (rinew) |
| 2794 | { |
| 2795 | aggregate->count++; |
| 2796 | |
| 2797 | if (aggregate->summary_only) |
| 2798 | rinew->suppress++; |
| 2799 | |
| 2800 | if (aggregate->as_set) |
| 2801 | { |
| 2802 | if (origin < rinew->attr->origin) |
| 2803 | origin = rinew->attr->origin; |
| 2804 | |
| 2805 | if (aspath) |
| 2806 | { |
| 2807 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 2808 | aspath_free (aspath); |
| 2809 | aspath = asmerge; |
| 2810 | } |
| 2811 | else |
| 2812 | aspath = aspath_dup (rinew->attr->aspath); |
| 2813 | |
| 2814 | if (rinew->attr->community) |
| 2815 | { |
| 2816 | if (community) |
| 2817 | { |
| 2818 | commerge = community_merge (community, |
| 2819 | rinew->attr->community); |
| 2820 | community = community_uniq_sort (commerge); |
| 2821 | community_free (commerge); |
| 2822 | } |
| 2823 | else |
| 2824 | community = community_dup (rinew->attr->community); |
| 2825 | } |
| 2826 | } |
| 2827 | } |
| 2828 | |
| 2829 | if (aggregate->count > 0) |
| 2830 | { |
| 2831 | rn = bgp_node_get (table, p); |
| 2832 | new = bgp_info_new (); |
| 2833 | new->type = ZEBRA_ROUTE_BGP; |
| 2834 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 2835 | new->peer = bgp->peer_self; |
| 2836 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2837 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 2838 | new->uptime = time (NULL); |
| 2839 | |
| 2840 | bgp_info_add (rn, new); |
| 2841 | bgp_process (bgp, rn, afi, safi); |
| 2842 | } |
| 2843 | else |
| 2844 | { |
| 2845 | if (aspath) |
| 2846 | aspath_free (aspath); |
| 2847 | if (community) |
| 2848 | community_free (community); |
| 2849 | } |
| 2850 | } |
| 2851 | |
| 2852 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 2853 | struct bgp_aggregate *); |
| 2854 | |
| 2855 | void |
| 2856 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 2857 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 2858 | { |
| 2859 | struct bgp_node *child; |
| 2860 | struct bgp_node *rn; |
| 2861 | struct bgp_aggregate *aggregate; |
| 2862 | |
| 2863 | /* MPLS-VPN aggregation is not yet supported. */ |
| 2864 | if (safi == SAFI_MPLS_VPN) |
| 2865 | return; |
| 2866 | |
| 2867 | if (p->prefixlen == 0) |
| 2868 | return; |
| 2869 | |
| 2870 | if (BGP_INFO_HOLDDOWN (ri)) |
| 2871 | return; |
| 2872 | |
| 2873 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 2874 | |
| 2875 | /* Aggregate address configuration check. */ |
| 2876 | for (rn = child; rn; rn = rn->parent) |
| 2877 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 2878 | { |
| 2879 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2880 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2881 | } |
| 2882 | bgp_unlock_node (child); |
| 2883 | } |
| 2884 | |
| 2885 | void |
| 2886 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 2887 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 2888 | { |
| 2889 | struct bgp_node *child; |
| 2890 | struct bgp_node *rn; |
| 2891 | struct bgp_aggregate *aggregate; |
| 2892 | |
| 2893 | /* MPLS-VPN aggregation is not yet supported. */ |
| 2894 | if (safi == SAFI_MPLS_VPN) |
| 2895 | return; |
| 2896 | |
| 2897 | if (p->prefixlen == 0) |
| 2898 | return; |
| 2899 | |
| 2900 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 2901 | |
| 2902 | /* Aggregate address configuration check. */ |
| 2903 | for (rn = child; rn; rn = rn->parent) |
| 2904 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 2905 | { |
| 2906 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2907 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2908 | } |
| 2909 | bgp_unlock_node (child); |
| 2910 | } |
| 2911 | |
| 2912 | void |
| 2913 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 2914 | struct bgp_aggregate *aggregate) |
| 2915 | { |
| 2916 | struct bgp_table *table; |
| 2917 | struct bgp_node *top; |
| 2918 | struct bgp_node *rn; |
| 2919 | struct bgp_info *new; |
| 2920 | struct bgp_info *ri; |
| 2921 | unsigned long match; |
| 2922 | u_char origin = BGP_ORIGIN_IGP; |
| 2923 | struct aspath *aspath = NULL; |
| 2924 | struct aspath *asmerge = NULL; |
| 2925 | struct community *community = NULL; |
| 2926 | struct community *commerge = NULL; |
| 2927 | |
| 2928 | table = bgp->rib[afi][safi]; |
| 2929 | |
| 2930 | /* Sanity check. */ |
| 2931 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 2932 | return; |
| 2933 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 2934 | return; |
| 2935 | |
| 2936 | /* If routes exists below this node, generate aggregate routes. */ |
| 2937 | top = bgp_node_get (table, p); |
| 2938 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 2939 | if (rn->p.prefixlen > p->prefixlen) |
| 2940 | { |
| 2941 | match = 0; |
| 2942 | |
| 2943 | for (ri = rn->info; ri; ri = ri->next) |
| 2944 | { |
| 2945 | if (BGP_INFO_HOLDDOWN (ri)) |
| 2946 | continue; |
| 2947 | |
| 2948 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 2949 | { |
| 2950 | /* summary-only aggregate route suppress aggregated |
| 2951 | route announcement. */ |
| 2952 | if (aggregate->summary_only) |
| 2953 | { |
| 2954 | ri->suppress++; |
| 2955 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2956 | match++; |
| 2957 | } |
| 2958 | /* as-set aggregate route generate origin, as path, |
| 2959 | community aggregation. */ |
| 2960 | if (aggregate->as_set) |
| 2961 | { |
| 2962 | if (origin < ri->attr->origin) |
| 2963 | origin = ri->attr->origin; |
| 2964 | |
| 2965 | if (aspath) |
| 2966 | { |
| 2967 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 2968 | aspath_free (aspath); |
| 2969 | aspath = asmerge; |
| 2970 | } |
| 2971 | else |
| 2972 | aspath = aspath_dup (ri->attr->aspath); |
| 2973 | |
| 2974 | if (ri->attr->community) |
| 2975 | { |
| 2976 | if (community) |
| 2977 | { |
| 2978 | commerge = community_merge (community, |
| 2979 | ri->attr->community); |
| 2980 | community = community_uniq_sort (commerge); |
| 2981 | community_free (commerge); |
| 2982 | } |
| 2983 | else |
| 2984 | community = community_dup (ri->attr->community); |
| 2985 | } |
| 2986 | } |
| 2987 | aggregate->count++; |
| 2988 | } |
| 2989 | } |
| 2990 | |
| 2991 | /* If this node is suppressed, process the change. */ |
| 2992 | if (match) |
| 2993 | bgp_process (bgp, rn, afi, safi); |
| 2994 | } |
| 2995 | bgp_unlock_node (top); |
| 2996 | |
| 2997 | /* Add aggregate route to BGP table. */ |
| 2998 | if (aggregate->count) |
| 2999 | { |
| 3000 | rn = bgp_node_get (table, p); |
| 3001 | |
| 3002 | new = bgp_info_new (); |
| 3003 | new->type = ZEBRA_ROUTE_BGP; |
| 3004 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 3005 | new->peer = bgp->peer_self; |
| 3006 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3007 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 3008 | new->uptime = time (NULL); |
| 3009 | |
| 3010 | bgp_info_add (rn, new); |
| 3011 | |
| 3012 | /* Process change. */ |
| 3013 | bgp_process (bgp, rn, afi, safi); |
| 3014 | } |
| 3015 | } |
| 3016 | |
| 3017 | void |
| 3018 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3019 | safi_t safi, struct bgp_aggregate *aggregate) |
| 3020 | { |
| 3021 | struct bgp_table *table; |
| 3022 | struct bgp_node *top; |
| 3023 | struct bgp_node *rn; |
| 3024 | struct bgp_info *ri; |
| 3025 | unsigned long match; |
| 3026 | |
| 3027 | table = bgp->rib[afi][safi]; |
| 3028 | |
| 3029 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 3030 | return; |
| 3031 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 3032 | return; |
| 3033 | |
| 3034 | /* If routes exists below this node, generate aggregate routes. */ |
| 3035 | top = bgp_node_get (table, p); |
| 3036 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 3037 | if (rn->p.prefixlen > p->prefixlen) |
| 3038 | { |
| 3039 | match = 0; |
| 3040 | |
| 3041 | for (ri = rn->info; ri; ri = ri->next) |
| 3042 | { |
| 3043 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3044 | continue; |
| 3045 | |
| 3046 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 3047 | { |
| 3048 | if (aggregate->summary_only) |
| 3049 | { |
| 3050 | ri->suppress--; |
| 3051 | |
| 3052 | if (ri->suppress == 0) |
| 3053 | { |
| 3054 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3055 | match++; |
| 3056 | } |
| 3057 | } |
| 3058 | aggregate->count--; |
| 3059 | } |
| 3060 | } |
| 3061 | |
| 3062 | /* If this node is suppressed, process the change. */ |
| 3063 | if (match) |
| 3064 | bgp_process (bgp, rn, afi, safi); |
| 3065 | } |
| 3066 | bgp_unlock_node (top); |
| 3067 | |
| 3068 | /* Delete aggregate route from BGP table. */ |
| 3069 | rn = bgp_node_get (table, p); |
| 3070 | |
| 3071 | for (ri = rn->info; ri; ri = ri->next) |
| 3072 | if (ri->peer == bgp->peer_self |
| 3073 | && ri->type == ZEBRA_ROUTE_BGP |
| 3074 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 3075 | break; |
| 3076 | |
| 3077 | /* Withdraw static BGP route from routing table. */ |
| 3078 | if (ri) |
| 3079 | { |
| 3080 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 3081 | bgp_process (bgp, rn, afi, safi); |
| 3082 | bgp_info_delete (rn, ri); |
| 3083 | bgp_info_free (ri); |
| 3084 | bgp_unlock_node (rn); |
| 3085 | } |
| 3086 | |
| 3087 | /* Unlock bgp_node_lookup. */ |
| 3088 | bgp_unlock_node (rn); |
| 3089 | } |
| 3090 | |
| 3091 | /* Aggregate route attribute. */ |
| 3092 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 3093 | #define AGGREGATE_AS_SET 1 |
| 3094 | |
| 3095 | int |
| 3096 | bgp_aggregate_set (struct vty *vty, char *prefix_str, afi_t afi, safi_t safi, |
| 3097 | u_char summary_only, u_char as_set) |
| 3098 | { |
| 3099 | int ret; |
| 3100 | struct prefix p; |
| 3101 | struct bgp_node *rn; |
| 3102 | struct bgp *bgp; |
| 3103 | struct bgp_aggregate *aggregate; |
| 3104 | |
| 3105 | /* Convert string to prefix structure. */ |
| 3106 | ret = str2prefix (prefix_str, &p); |
| 3107 | if (!ret) |
| 3108 | { |
| 3109 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 3110 | return CMD_WARNING; |
| 3111 | } |
| 3112 | apply_mask (&p); |
| 3113 | |
| 3114 | /* Get BGP structure. */ |
| 3115 | bgp = vty->index; |
| 3116 | |
| 3117 | /* Old configuration check. */ |
| 3118 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 3119 | |
| 3120 | if (rn->info) |
| 3121 | { |
| 3122 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
| 3123 | bgp_unlock_node (rn); |
| 3124 | return CMD_WARNING; |
| 3125 | } |
| 3126 | |
| 3127 | /* Make aggregate address structure. */ |
| 3128 | aggregate = bgp_aggregate_new (); |
| 3129 | aggregate->summary_only = summary_only; |
| 3130 | aggregate->as_set = as_set; |
| 3131 | aggregate->safi = safi; |
| 3132 | rn->info = aggregate; |
| 3133 | |
| 3134 | /* Aggregate address insert into BGP routing table. */ |
| 3135 | if (safi & SAFI_UNICAST) |
| 3136 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 3137 | if (safi & SAFI_MULTICAST) |
| 3138 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 3139 | |
| 3140 | return CMD_SUCCESS; |
| 3141 | } |
| 3142 | |
| 3143 | int |
| 3144 | bgp_aggregate_unset (struct vty *vty, char *prefix_str, afi_t afi, safi_t safi) |
| 3145 | { |
| 3146 | int ret; |
| 3147 | struct prefix p; |
| 3148 | struct bgp_node *rn; |
| 3149 | struct bgp *bgp; |
| 3150 | struct bgp_aggregate *aggregate; |
| 3151 | |
| 3152 | /* Convert string to prefix structure. */ |
| 3153 | ret = str2prefix (prefix_str, &p); |
| 3154 | if (!ret) |
| 3155 | { |
| 3156 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 3157 | return CMD_WARNING; |
| 3158 | } |
| 3159 | apply_mask (&p); |
| 3160 | |
| 3161 | /* Get BGP structure. */ |
| 3162 | bgp = vty->index; |
| 3163 | |
| 3164 | /* Old configuration check. */ |
| 3165 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 3166 | if (! rn) |
| 3167 | { |
| 3168 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 3169 | VTY_NEWLINE); |
| 3170 | return CMD_WARNING; |
| 3171 | } |
| 3172 | |
| 3173 | aggregate = rn->info; |
| 3174 | if (aggregate->safi & SAFI_UNICAST) |
| 3175 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 3176 | if (aggregate->safi & SAFI_MULTICAST) |
| 3177 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 3178 | |
| 3179 | /* Unlock aggregate address configuration. */ |
| 3180 | rn->info = NULL; |
| 3181 | bgp_aggregate_free (aggregate); |
| 3182 | bgp_unlock_node (rn); |
| 3183 | bgp_unlock_node (rn); |
| 3184 | |
| 3185 | return CMD_SUCCESS; |
| 3186 | } |
| 3187 | |
| 3188 | DEFUN (aggregate_address, |
| 3189 | aggregate_address_cmd, |
| 3190 | "aggregate-address A.B.C.D/M", |
| 3191 | "Configure BGP aggregate entries\n" |
| 3192 | "Aggregate prefix\n") |
| 3193 | { |
| 3194 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 3195 | } |
| 3196 | |
| 3197 | DEFUN (aggregate_address_mask, |
| 3198 | aggregate_address_mask_cmd, |
| 3199 | "aggregate-address A.B.C.D A.B.C.D", |
| 3200 | "Configure BGP aggregate entries\n" |
| 3201 | "Aggregate address\n" |
| 3202 | "Aggregate mask\n") |
| 3203 | { |
| 3204 | int ret; |
| 3205 | char prefix_str[BUFSIZ]; |
| 3206 | |
| 3207 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3208 | |
| 3209 | if (! ret) |
| 3210 | { |
| 3211 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3212 | return CMD_WARNING; |
| 3213 | } |
| 3214 | |
| 3215 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 3216 | 0, 0); |
| 3217 | } |
| 3218 | |
| 3219 | DEFUN (aggregate_address_summary_only, |
| 3220 | aggregate_address_summary_only_cmd, |
| 3221 | "aggregate-address A.B.C.D/M summary-only", |
| 3222 | "Configure BGP aggregate entries\n" |
| 3223 | "Aggregate prefix\n" |
| 3224 | "Filter more specific routes from updates\n") |
| 3225 | { |
| 3226 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 3227 | AGGREGATE_SUMMARY_ONLY, 0); |
| 3228 | } |
| 3229 | |
| 3230 | DEFUN (aggregate_address_mask_summary_only, |
| 3231 | aggregate_address_mask_summary_only_cmd, |
| 3232 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 3233 | "Configure BGP aggregate entries\n" |
| 3234 | "Aggregate address\n" |
| 3235 | "Aggregate mask\n" |
| 3236 | "Filter more specific routes from updates\n") |
| 3237 | { |
| 3238 | int ret; |
| 3239 | char prefix_str[BUFSIZ]; |
| 3240 | |
| 3241 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3242 | |
| 3243 | if (! ret) |
| 3244 | { |
| 3245 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3246 | return CMD_WARNING; |
| 3247 | } |
| 3248 | |
| 3249 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 3250 | AGGREGATE_SUMMARY_ONLY, 0); |
| 3251 | } |
| 3252 | |
| 3253 | DEFUN (aggregate_address_as_set, |
| 3254 | aggregate_address_as_set_cmd, |
| 3255 | "aggregate-address A.B.C.D/M as-set", |
| 3256 | "Configure BGP aggregate entries\n" |
| 3257 | "Aggregate prefix\n" |
| 3258 | "Generate AS set path information\n") |
| 3259 | { |
| 3260 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 3261 | 0, AGGREGATE_AS_SET); |
| 3262 | } |
| 3263 | |
| 3264 | DEFUN (aggregate_address_mask_as_set, |
| 3265 | aggregate_address_mask_as_set_cmd, |
| 3266 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 3267 | "Configure BGP aggregate entries\n" |
| 3268 | "Aggregate address\n" |
| 3269 | "Aggregate mask\n" |
| 3270 | "Generate AS set path information\n") |
| 3271 | { |
| 3272 | int ret; |
| 3273 | char prefix_str[BUFSIZ]; |
| 3274 | |
| 3275 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3276 | |
| 3277 | if (! ret) |
| 3278 | { |
| 3279 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3280 | return CMD_WARNING; |
| 3281 | } |
| 3282 | |
| 3283 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 3284 | 0, AGGREGATE_AS_SET); |
| 3285 | } |
| 3286 | |
| 3287 | |
| 3288 | DEFUN (aggregate_address_as_set_summary, |
| 3289 | aggregate_address_as_set_summary_cmd, |
| 3290 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 3291 | "Configure BGP aggregate entries\n" |
| 3292 | "Aggregate prefix\n" |
| 3293 | "Generate AS set path information\n" |
| 3294 | "Filter more specific routes from updates\n") |
| 3295 | { |
| 3296 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 3297 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 3298 | } |
| 3299 | |
| 3300 | ALIAS (aggregate_address_as_set_summary, |
| 3301 | aggregate_address_summary_as_set_cmd, |
| 3302 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 3303 | "Configure BGP aggregate entries\n" |
| 3304 | "Aggregate prefix\n" |
| 3305 | "Filter more specific routes from updates\n" |
| 3306 | "Generate AS set path information\n") |
| 3307 | |
| 3308 | DEFUN (aggregate_address_mask_as_set_summary, |
| 3309 | aggregate_address_mask_as_set_summary_cmd, |
| 3310 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 3311 | "Configure BGP aggregate entries\n" |
| 3312 | "Aggregate address\n" |
| 3313 | "Aggregate mask\n" |
| 3314 | "Generate AS set path information\n" |
| 3315 | "Filter more specific routes from updates\n") |
| 3316 | { |
| 3317 | int ret; |
| 3318 | char prefix_str[BUFSIZ]; |
| 3319 | |
| 3320 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3321 | |
| 3322 | if (! ret) |
| 3323 | { |
| 3324 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3325 | return CMD_WARNING; |
| 3326 | } |
| 3327 | |
| 3328 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 3329 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 3330 | } |
| 3331 | |
| 3332 | ALIAS (aggregate_address_mask_as_set_summary, |
| 3333 | aggregate_address_mask_summary_as_set_cmd, |
| 3334 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 3335 | "Configure BGP aggregate entries\n" |
| 3336 | "Aggregate address\n" |
| 3337 | "Aggregate mask\n" |
| 3338 | "Filter more specific routes from updates\n" |
| 3339 | "Generate AS set path information\n") |
| 3340 | |
| 3341 | DEFUN (no_aggregate_address, |
| 3342 | no_aggregate_address_cmd, |
| 3343 | "no aggregate-address A.B.C.D/M", |
| 3344 | NO_STR |
| 3345 | "Configure BGP aggregate entries\n" |
| 3346 | "Aggregate prefix\n") |
| 3347 | { |
| 3348 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 3349 | } |
| 3350 | |
| 3351 | ALIAS (no_aggregate_address, |
| 3352 | no_aggregate_address_summary_only_cmd, |
| 3353 | "no aggregate-address A.B.C.D/M summary-only", |
| 3354 | NO_STR |
| 3355 | "Configure BGP aggregate entries\n" |
| 3356 | "Aggregate prefix\n" |
| 3357 | "Filter more specific routes from updates\n") |
| 3358 | |
| 3359 | ALIAS (no_aggregate_address, |
| 3360 | no_aggregate_address_as_set_cmd, |
| 3361 | "no aggregate-address A.B.C.D/M as-set", |
| 3362 | NO_STR |
| 3363 | "Configure BGP aggregate entries\n" |
| 3364 | "Aggregate prefix\n" |
| 3365 | "Generate AS set path information\n") |
| 3366 | |
| 3367 | ALIAS (no_aggregate_address, |
| 3368 | no_aggregate_address_as_set_summary_cmd, |
| 3369 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 3370 | NO_STR |
| 3371 | "Configure BGP aggregate entries\n" |
| 3372 | "Aggregate prefix\n" |
| 3373 | "Generate AS set path information\n" |
| 3374 | "Filter more specific routes from updates\n") |
| 3375 | |
| 3376 | ALIAS (no_aggregate_address, |
| 3377 | no_aggregate_address_summary_as_set_cmd, |
| 3378 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 3379 | NO_STR |
| 3380 | "Configure BGP aggregate entries\n" |
| 3381 | "Aggregate prefix\n" |
| 3382 | "Filter more specific routes from updates\n" |
| 3383 | "Generate AS set path information\n") |
| 3384 | |
| 3385 | DEFUN (no_aggregate_address_mask, |
| 3386 | no_aggregate_address_mask_cmd, |
| 3387 | "no aggregate-address A.B.C.D A.B.C.D", |
| 3388 | NO_STR |
| 3389 | "Configure BGP aggregate entries\n" |
| 3390 | "Aggregate address\n" |
| 3391 | "Aggregate mask\n") |
| 3392 | { |
| 3393 | int ret; |
| 3394 | char prefix_str[BUFSIZ]; |
| 3395 | |
| 3396 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3397 | |
| 3398 | if (! ret) |
| 3399 | { |
| 3400 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3401 | return CMD_WARNING; |
| 3402 | } |
| 3403 | |
| 3404 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 3405 | } |
| 3406 | |
| 3407 | ALIAS (no_aggregate_address_mask, |
| 3408 | no_aggregate_address_mask_summary_only_cmd, |
| 3409 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 3410 | NO_STR |
| 3411 | "Configure BGP aggregate entries\n" |
| 3412 | "Aggregate address\n" |
| 3413 | "Aggregate mask\n" |
| 3414 | "Filter more specific routes from updates\n") |
| 3415 | |
| 3416 | ALIAS (no_aggregate_address_mask, |
| 3417 | no_aggregate_address_mask_as_set_cmd, |
| 3418 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 3419 | NO_STR |
| 3420 | "Configure BGP aggregate entries\n" |
| 3421 | "Aggregate address\n" |
| 3422 | "Aggregate mask\n" |
| 3423 | "Generate AS set path information\n") |
| 3424 | |
| 3425 | ALIAS (no_aggregate_address_mask, |
| 3426 | no_aggregate_address_mask_as_set_summary_cmd, |
| 3427 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 3428 | NO_STR |
| 3429 | "Configure BGP aggregate entries\n" |
| 3430 | "Aggregate address\n" |
| 3431 | "Aggregate mask\n" |
| 3432 | "Generate AS set path information\n" |
| 3433 | "Filter more specific routes from updates\n") |
| 3434 | |
| 3435 | ALIAS (no_aggregate_address_mask, |
| 3436 | no_aggregate_address_mask_summary_as_set_cmd, |
| 3437 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 3438 | NO_STR |
| 3439 | "Configure BGP aggregate entries\n" |
| 3440 | "Aggregate address\n" |
| 3441 | "Aggregate mask\n" |
| 3442 | "Filter more specific routes from updates\n" |
| 3443 | "Generate AS set path information\n") |
| 3444 | |
| 3445 | #ifdef HAVE_IPV6 |
| 3446 | DEFUN (ipv6_aggregate_address, |
| 3447 | ipv6_aggregate_address_cmd, |
| 3448 | "aggregate-address X:X::X:X/M", |
| 3449 | "Configure BGP aggregate entries\n" |
| 3450 | "Aggregate prefix\n") |
| 3451 | { |
| 3452 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 3453 | } |
| 3454 | |
| 3455 | DEFUN (ipv6_aggregate_address_summary_only, |
| 3456 | ipv6_aggregate_address_summary_only_cmd, |
| 3457 | "aggregate-address X:X::X:X/M summary-only", |
| 3458 | "Configure BGP aggregate entries\n" |
| 3459 | "Aggregate prefix\n" |
| 3460 | "Filter more specific routes from updates\n") |
| 3461 | { |
| 3462 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 3463 | AGGREGATE_SUMMARY_ONLY, 0); |
| 3464 | } |
| 3465 | |
| 3466 | DEFUN (no_ipv6_aggregate_address, |
| 3467 | no_ipv6_aggregate_address_cmd, |
| 3468 | "no aggregate-address X:X::X:X/M", |
| 3469 | NO_STR |
| 3470 | "Configure BGP aggregate entries\n" |
| 3471 | "Aggregate prefix\n") |
| 3472 | { |
| 3473 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 3474 | } |
| 3475 | |
| 3476 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 3477 | no_ipv6_aggregate_address_summary_only_cmd, |
| 3478 | "no aggregate-address X:X::X:X/M summary-only", |
| 3479 | NO_STR |
| 3480 | "Configure BGP aggregate entries\n" |
| 3481 | "Aggregate prefix\n" |
| 3482 | "Filter more specific routes from updates\n") |
| 3483 | { |
| 3484 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 3485 | } |
| 3486 | |
| 3487 | ALIAS (ipv6_aggregate_address, |
| 3488 | old_ipv6_aggregate_address_cmd, |
| 3489 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 3490 | IPV6_STR |
| 3491 | BGP_STR |
| 3492 | "Configure BGP aggregate entries\n" |
| 3493 | "Aggregate prefix\n") |
| 3494 | |
| 3495 | ALIAS (ipv6_aggregate_address_summary_only, |
| 3496 | old_ipv6_aggregate_address_summary_only_cmd, |
| 3497 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 3498 | IPV6_STR |
| 3499 | BGP_STR |
| 3500 | "Configure BGP aggregate entries\n" |
| 3501 | "Aggregate prefix\n" |
| 3502 | "Filter more specific routes from updates\n") |
| 3503 | |
| 3504 | ALIAS (no_ipv6_aggregate_address, |
| 3505 | old_no_ipv6_aggregate_address_cmd, |
| 3506 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 3507 | NO_STR |
| 3508 | IPV6_STR |
| 3509 | BGP_STR |
| 3510 | "Configure BGP aggregate entries\n" |
| 3511 | "Aggregate prefix\n") |
| 3512 | |
| 3513 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 3514 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 3515 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 3516 | NO_STR |
| 3517 | IPV6_STR |
| 3518 | BGP_STR |
| 3519 | "Configure BGP aggregate entries\n" |
| 3520 | "Aggregate prefix\n" |
| 3521 | "Filter more specific routes from updates\n") |
| 3522 | #endif /* HAVE_IPV6 */ |
| 3523 | |
| 3524 | /* Redistribute route treatment. */ |
| 3525 | void |
| 3526 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, |
| 3527 | u_int32_t metric, u_char type) |
| 3528 | { |
| 3529 | struct bgp *bgp; |
| 3530 | struct listnode *nn; |
| 3531 | struct bgp_info *new; |
| 3532 | struct bgp_info *bi; |
| 3533 | struct bgp_info info; |
| 3534 | struct bgp_node *bn; |
| 3535 | struct attr attr; |
| 3536 | struct attr attr_new; |
| 3537 | struct attr *new_attr; |
| 3538 | afi_t afi; |
| 3539 | int ret; |
| 3540 | |
| 3541 | /* Make default attribute. */ |
| 3542 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 3543 | if (nexthop) |
| 3544 | attr.nexthop = *nexthop; |
| 3545 | |
| 3546 | attr.med = metric; |
| 3547 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3548 | |
| 3549 | LIST_LOOP (bm->bgp, bgp, nn) |
| 3550 | { |
| 3551 | afi = family2afi (p->family); |
| 3552 | |
| 3553 | if (bgp->redist[afi][type]) |
| 3554 | { |
| 3555 | /* Copy attribute for modification. */ |
| 3556 | attr_new = attr; |
| 3557 | |
| 3558 | if (bgp->redist_metric_flag[afi][type]) |
| 3559 | attr_new.med = bgp->redist_metric[afi][type]; |
| 3560 | |
| 3561 | /* Apply route-map. */ |
| 3562 | if (bgp->rmap[afi][type].map) |
| 3563 | { |
| 3564 | info.peer = bgp->peer_self; |
| 3565 | info.attr = &attr_new; |
| 3566 | |
| 3567 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 3568 | &info); |
| 3569 | if (ret == RMAP_DENYMATCH) |
| 3570 | { |
| 3571 | /* Free uninterned attribute. */ |
| 3572 | bgp_attr_flush (&attr_new); |
| 3573 | |
| 3574 | /* Unintern original. */ |
| 3575 | aspath_unintern (attr.aspath); |
| 3576 | bgp_redistribute_delete (p, type); |
| 3577 | return; |
| 3578 | } |
| 3579 | } |
| 3580 | |
| 3581 | bn = bgp_afi_node_get (bgp, afi, SAFI_UNICAST, p, NULL); |
| 3582 | new_attr = bgp_attr_intern (&attr_new); |
| 3583 | |
| 3584 | for (bi = bn->info; bi; bi = bi->next) |
| 3585 | if (bi->peer == bgp->peer_self |
| 3586 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 3587 | break; |
| 3588 | |
| 3589 | if (bi) |
| 3590 | { |
| 3591 | if (attrhash_cmp (bi->attr, new_attr)) |
| 3592 | { |
| 3593 | bgp_attr_unintern (new_attr); |
| 3594 | aspath_unintern (attr.aspath); |
| 3595 | bgp_unlock_node (bn); |
| 3596 | return; |
| 3597 | } |
| 3598 | else |
| 3599 | { |
| 3600 | /* The attribute is changed. */ |
| 3601 | SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED); |
| 3602 | |
| 3603 | /* Rewrite BGP route information. */ |
| 3604 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
| 3605 | bgp_attr_unintern (bi->attr); |
| 3606 | bi->attr = new_attr; |
| 3607 | bi->uptime = time (NULL); |
| 3608 | |
| 3609 | /* Process change. */ |
| 3610 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 3611 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 3612 | bgp_unlock_node (bn); |
| 3613 | aspath_unintern (attr.aspath); |
| 3614 | return; |
| 3615 | } |
| 3616 | } |
| 3617 | |
| 3618 | new = bgp_info_new (); |
| 3619 | new->type = type; |
| 3620 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 3621 | new->peer = bgp->peer_self; |
| 3622 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3623 | new->attr = new_attr; |
| 3624 | new->uptime = time (NULL); |
| 3625 | |
| 3626 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 3627 | bgp_info_add (bn, new); |
| 3628 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 3629 | } |
| 3630 | } |
| 3631 | |
| 3632 | /* Unintern original. */ |
| 3633 | aspath_unintern (attr.aspath); |
| 3634 | } |
| 3635 | |
| 3636 | void |
| 3637 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 3638 | { |
| 3639 | struct bgp *bgp; |
| 3640 | struct listnode *nn; |
| 3641 | afi_t afi; |
| 3642 | struct bgp_node *rn; |
| 3643 | struct bgp_info *ri; |
| 3644 | |
| 3645 | LIST_LOOP (bm->bgp, bgp, nn) |
| 3646 | { |
| 3647 | afi = family2afi (p->family); |
| 3648 | |
| 3649 | if (bgp->redist[afi][type]) |
| 3650 | { |
| 3651 | rn = bgp_afi_node_get (bgp, afi, SAFI_UNICAST, p, NULL); |
| 3652 | |
| 3653 | for (ri = rn->info; ri; ri = ri->next) |
| 3654 | if (ri->peer == bgp->peer_self |
| 3655 | && ri->type == type) |
| 3656 | break; |
| 3657 | |
| 3658 | if (ri) |
| 3659 | { |
| 3660 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
| 3661 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 3662 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 3663 | bgp_info_delete (rn, ri); |
| 3664 | bgp_info_free (ri); |
| 3665 | bgp_unlock_node (rn); |
| 3666 | } |
| 3667 | bgp_unlock_node (rn); |
| 3668 | } |
| 3669 | } |
| 3670 | } |
| 3671 | |
| 3672 | /* Withdraw specified route type's route. */ |
| 3673 | void |
| 3674 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 3675 | { |
| 3676 | struct bgp_node *rn; |
| 3677 | struct bgp_info *ri; |
| 3678 | struct bgp_table *table; |
| 3679 | |
| 3680 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 3681 | |
| 3682 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3683 | { |
| 3684 | for (ri = rn->info; ri; ri = ri->next) |
| 3685 | if (ri->peer == bgp->peer_self |
| 3686 | && ri->type == type) |
| 3687 | break; |
| 3688 | |
| 3689 | if (ri) |
| 3690 | { |
| 3691 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
| 3692 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 3693 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 3694 | bgp_info_delete (rn, ri); |
| 3695 | bgp_info_free (ri); |
| 3696 | bgp_unlock_node (rn); |
| 3697 | } |
| 3698 | } |
| 3699 | } |
| 3700 | |
| 3701 | /* Static function to display route. */ |
| 3702 | void |
| 3703 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 3704 | { |
| 3705 | int len; |
| 3706 | u_int32_t destination; |
| 3707 | char buf[BUFSIZ]; |
| 3708 | |
| 3709 | if (p->family == AF_INET) |
| 3710 | { |
| 3711 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 3712 | destination = ntohl (p->u.prefix4.s_addr); |
| 3713 | |
| 3714 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 3715 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 3716 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 3717 | || p->u.prefix4.s_addr == 0) |
| 3718 | { |
| 3719 | /* When mask is natural, mask is not displayed. */ |
| 3720 | } |
| 3721 | else |
| 3722 | len += vty_out (vty, "/%d", p->prefixlen); |
| 3723 | } |
| 3724 | else |
| 3725 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 3726 | p->prefixlen); |
| 3727 | |
| 3728 | len = 17 - len; |
| 3729 | if (len < 1) |
| 3730 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 3731 | else |
| 3732 | vty_out (vty, "%*s", len, " "); |
| 3733 | } |
| 3734 | |
| 3735 | /* Calculate line number of output data. */ |
| 3736 | int |
| 3737 | vty_calc_line (struct vty *vty, unsigned long length) |
| 3738 | { |
| 3739 | return vty->width ? (((vty->obuf->length - length) / vty->width) + 1) : 1; |
| 3740 | } |
| 3741 | |
| 3742 | enum bgp_display_type |
| 3743 | { |
| 3744 | normal_list, |
| 3745 | }; |
| 3746 | |
| 3747 | /* called from terminal list command */ |
| 3748 | int |
| 3749 | route_vty_out (struct vty *vty, struct prefix *p, |
| 3750 | struct bgp_info *binfo, int display, safi_t safi) |
| 3751 | { |
| 3752 | struct attr *attr; |
| 3753 | unsigned long length = 0; |
| 3754 | |
| 3755 | length = vty->obuf->length; |
| 3756 | |
| 3757 | /* Route status display. */ |
| 3758 | if (binfo->suppress) |
| 3759 | vty_out (vty, "s"); |
| 3760 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 3761 | vty_out (vty, "*"); |
| 3762 | else |
| 3763 | vty_out (vty, " "); |
| 3764 | |
| 3765 | /* Selected */ |
| 3766 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 3767 | vty_out (vty, "h"); |
| 3768 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 3769 | vty_out (vty, "d"); |
| 3770 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 3771 | vty_out (vty, ">"); |
| 3772 | else |
| 3773 | vty_out (vty, " "); |
| 3774 | |
| 3775 | /* Internal route. */ |
| 3776 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 3777 | vty_out (vty, "i"); |
| 3778 | else |
| 3779 | vty_out (vty, " "); |
| 3780 | |
| 3781 | /* print prefix and mask */ |
| 3782 | if (! display) |
| 3783 | route_vty_out_route (p, vty); |
| 3784 | else |
| 3785 | vty_out (vty, "%*s", 17, " "); |
| 3786 | |
| 3787 | /* Print attribute */ |
| 3788 | attr = binfo->attr; |
| 3789 | if (attr) |
| 3790 | { |
| 3791 | if (p->family == AF_INET) |
| 3792 | { |
| 3793 | if (safi == SAFI_MPLS_VPN) |
| 3794 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 3795 | else |
| 3796 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 3797 | } |
| 3798 | #ifdef HAVE_IPV6 |
| 3799 | else if (p->family == AF_INET6) |
| 3800 | { |
| 3801 | int len; |
| 3802 | char buf[BUFSIZ]; |
| 3803 | |
| 3804 | len = vty_out (vty, "%s", |
| 3805 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 3806 | len = 16 - len; |
| 3807 | if (len < 1) |
| 3808 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 3809 | else |
| 3810 | vty_out (vty, "%*s", len, " "); |
| 3811 | } |
| 3812 | #endif /* HAVE_IPV6 */ |
| 3813 | |
| 3814 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 3815 | vty_out (vty, "%10d", attr->med); |
| 3816 | else |
| 3817 | vty_out (vty, " "); |
| 3818 | |
| 3819 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 3820 | vty_out (vty, "%7d", attr->local_pref); |
| 3821 | else |
| 3822 | vty_out (vty, " "); |
| 3823 | |
| 3824 | vty_out (vty, "%7u ",attr->weight); |
| 3825 | |
| 3826 | /* Print aspath */ |
| 3827 | if (attr->aspath) |
| 3828 | aspath_print_vty (vty, attr->aspath); |
| 3829 | |
| 3830 | /* Print origin */ |
| 3831 | if (strlen (attr->aspath->str) == 0) |
| 3832 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 3833 | else |
| 3834 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 3835 | } |
| 3836 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3837 | |
| 3838 | return vty_calc_line (vty, length); |
| 3839 | } |
| 3840 | |
| 3841 | /* called from terminal list command */ |
| 3842 | void |
| 3843 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 3844 | struct attr *attr, safi_t safi) |
| 3845 | { |
| 3846 | /* Route status display. */ |
| 3847 | vty_out (vty, "*"); |
| 3848 | vty_out (vty, ">"); |
| 3849 | vty_out (vty, " "); |
| 3850 | |
| 3851 | /* print prefix and mask */ |
| 3852 | route_vty_out_route (p, vty); |
| 3853 | |
| 3854 | /* Print attribute */ |
| 3855 | if (attr) |
| 3856 | { |
| 3857 | if (p->family == AF_INET) |
| 3858 | { |
| 3859 | if (safi == SAFI_MPLS_VPN) |
| 3860 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 3861 | else |
| 3862 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 3863 | } |
| 3864 | #ifdef HAVE_IPV6 |
| 3865 | else if (p->family == AF_INET6) |
| 3866 | { |
| 3867 | int len; |
| 3868 | char buf[BUFSIZ]; |
| 3869 | |
| 3870 | len = vty_out (vty, "%s", |
| 3871 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 3872 | len = 16 - len; |
| 3873 | if (len < 1) |
| 3874 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 3875 | else |
| 3876 | vty_out (vty, "%*s", len, " "); |
| 3877 | } |
| 3878 | #endif /* HAVE_IPV6 */ |
| 3879 | |
| 3880 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 3881 | vty_out (vty, "%10d", attr->med); |
| 3882 | else |
| 3883 | vty_out (vty, " "); |
| 3884 | |
| 3885 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 3886 | vty_out (vty, "%7d", attr->local_pref); |
| 3887 | else |
| 3888 | vty_out (vty, " "); |
| 3889 | |
| 3890 | vty_out (vty, "%7d ",attr->weight); |
| 3891 | |
| 3892 | /* Print aspath */ |
| 3893 | if (attr->aspath) |
| 3894 | aspath_print_vty (vty, attr->aspath); |
| 3895 | |
| 3896 | /* Print origin */ |
| 3897 | if (strlen (attr->aspath->str) == 0) |
| 3898 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 3899 | else |
| 3900 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 3901 | } |
| 3902 | |
| 3903 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3904 | } |
| 3905 | |
| 3906 | int |
| 3907 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 3908 | struct bgp_info *binfo, int display, safi_t safi) |
| 3909 | { |
| 3910 | struct attr *attr; |
| 3911 | unsigned long length = 0; |
| 3912 | u_int32_t label = 0; |
| 3913 | |
| 3914 | length = vty->obuf->length; |
| 3915 | |
| 3916 | /* Route status display. */ |
| 3917 | if (binfo->suppress) |
| 3918 | vty_out (vty, "s"); |
| 3919 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 3920 | vty_out (vty, "*"); |
| 3921 | else |
| 3922 | vty_out (vty, " "); |
| 3923 | |
| 3924 | /* Selected */ |
| 3925 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 3926 | vty_out (vty, "h"); |
| 3927 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 3928 | vty_out (vty, "d"); |
| 3929 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 3930 | vty_out (vty, ">"); |
| 3931 | else |
| 3932 | vty_out (vty, " "); |
| 3933 | |
| 3934 | /* Internal route. */ |
| 3935 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 3936 | vty_out (vty, "i"); |
| 3937 | else |
| 3938 | vty_out (vty, " "); |
| 3939 | |
| 3940 | /* print prefix and mask */ |
| 3941 | if (! display) |
| 3942 | route_vty_out_route (p, vty); |
| 3943 | else |
| 3944 | vty_out (vty, "%*s", 17, " "); |
| 3945 | |
| 3946 | /* Print attribute */ |
| 3947 | attr = binfo->attr; |
| 3948 | if (attr) |
| 3949 | { |
| 3950 | if (p->family == AF_INET) |
| 3951 | { |
| 3952 | if (safi == SAFI_MPLS_VPN) |
| 3953 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 3954 | else |
| 3955 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 3956 | } |
| 3957 | #ifdef HAVE_IPV6 |
| 3958 | else if (p->family == AF_INET6) |
| 3959 | { |
| 3960 | char buf[BUFSIZ]; |
| 3961 | char buf1[BUFSIZ]; |
| 3962 | if (attr->mp_nexthop_len == 16) |
| 3963 | vty_out (vty, "%s", |
| 3964 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 3965 | else if (attr->mp_nexthop_len == 32) |
| 3966 | vty_out (vty, "%s(%s)", |
| 3967 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ), |
| 3968 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ)); |
| 3969 | |
| 3970 | } |
| 3971 | #endif /* HAVE_IPV6 */ |
| 3972 | } |
| 3973 | |
| 3974 | label = decode_label (binfo->tag); |
| 3975 | |
| 3976 | vty_out (vty, "notag/%d", label); |
| 3977 | |
| 3978 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3979 | |
| 3980 | return vty_calc_line (vty, length); |
| 3981 | } |
| 3982 | |
| 3983 | /* dampening route */ |
| 3984 | int |
| 3985 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 3986 | struct bgp_info *binfo, int display, safi_t safi) |
| 3987 | { |
| 3988 | struct attr *attr; |
| 3989 | unsigned long length = 0; |
| 3990 | int len; |
| 3991 | |
| 3992 | length = vty->obuf->length; |
| 3993 | |
| 3994 | /* Route status display. */ |
| 3995 | if (binfo->suppress) |
| 3996 | vty_out (vty, "s"); |
| 3997 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 3998 | vty_out (vty, "*"); |
| 3999 | else |
| 4000 | vty_out (vty, " "); |
| 4001 | |
| 4002 | /* Selected */ |
| 4003 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4004 | vty_out (vty, "h"); |
| 4005 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4006 | vty_out (vty, "d"); |
| 4007 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4008 | vty_out (vty, ">"); |
| 4009 | else |
| 4010 | vty_out (vty, " "); |
| 4011 | |
| 4012 | vty_out (vty, " "); |
| 4013 | |
| 4014 | /* print prefix and mask */ |
| 4015 | if (! display) |
| 4016 | route_vty_out_route (p, vty); |
| 4017 | else |
| 4018 | vty_out (vty, "%*s", 17, " "); |
| 4019 | |
| 4020 | len = vty_out (vty, "%s", binfo->peer->host); |
| 4021 | len = 17 - len; |
| 4022 | if (len < 1) |
| 4023 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 4024 | else |
| 4025 | vty_out (vty, "%*s", len, " "); |
| 4026 | |
| 4027 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 4028 | |
| 4029 | /* Print attribute */ |
| 4030 | attr = binfo->attr; |
| 4031 | if (attr) |
| 4032 | { |
| 4033 | /* Print aspath */ |
| 4034 | if (attr->aspath) |
| 4035 | aspath_print_vty (vty, attr->aspath); |
| 4036 | |
| 4037 | /* Print origin */ |
| 4038 | if (strlen (attr->aspath->str) == 0) |
| 4039 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4040 | else |
| 4041 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4042 | } |
| 4043 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4044 | |
| 4045 | return vty_calc_line (vty, length); |
| 4046 | } |
| 4047 | |
| 4048 | #define BGP_UPTIME_LEN 25 |
| 4049 | |
| 4050 | /* flap route */ |
| 4051 | int |
| 4052 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 4053 | struct bgp_info *binfo, int display, safi_t safi) |
| 4054 | { |
| 4055 | struct attr *attr; |
| 4056 | struct bgp_damp_info *bdi; |
| 4057 | unsigned long length = 0; |
| 4058 | char timebuf[BGP_UPTIME_LEN]; |
| 4059 | int len; |
| 4060 | |
| 4061 | length = vty->obuf->length; |
| 4062 | bdi = binfo->damp_info; |
| 4063 | |
| 4064 | /* Route status display. */ |
| 4065 | if (binfo->suppress) |
| 4066 | vty_out (vty, "s"); |
| 4067 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4068 | vty_out (vty, "*"); |
| 4069 | else |
| 4070 | vty_out (vty, " "); |
| 4071 | |
| 4072 | /* Selected */ |
| 4073 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4074 | vty_out (vty, "h"); |
| 4075 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4076 | vty_out (vty, "d"); |
| 4077 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4078 | vty_out (vty, ">"); |
| 4079 | else |
| 4080 | vty_out (vty, " "); |
| 4081 | |
| 4082 | vty_out (vty, " "); |
| 4083 | |
| 4084 | /* print prefix and mask */ |
| 4085 | if (! display) |
| 4086 | route_vty_out_route (p, vty); |
| 4087 | else |
| 4088 | vty_out (vty, "%*s", 17, " "); |
| 4089 | |
| 4090 | len = vty_out (vty, "%s", binfo->peer->host); |
| 4091 | len = 16 - len; |
| 4092 | if (len < 1) |
| 4093 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 4094 | else |
| 4095 | vty_out (vty, "%*s", len, " "); |
| 4096 | |
| 4097 | len = vty_out (vty, "%d", bdi->flap); |
| 4098 | len = 5 - len; |
| 4099 | if (len < 1) |
| 4100 | vty_out (vty, " "); |
| 4101 | else |
| 4102 | vty_out (vty, "%*s ", len, " "); |
| 4103 | |
| 4104 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 4105 | timebuf, BGP_UPTIME_LEN)); |
| 4106 | |
| 4107 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 4108 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4109 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 4110 | else |
| 4111 | vty_out (vty, "%*s ", 8, " "); |
| 4112 | |
| 4113 | /* Print attribute */ |
| 4114 | attr = binfo->attr; |
| 4115 | if (attr) |
| 4116 | { |
| 4117 | /* Print aspath */ |
| 4118 | if (attr->aspath) |
| 4119 | aspath_print_vty (vty, attr->aspath); |
| 4120 | |
| 4121 | /* Print origin */ |
| 4122 | if (strlen (attr->aspath->str) == 0) |
| 4123 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4124 | else |
| 4125 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4126 | } |
| 4127 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4128 | |
| 4129 | return vty_calc_line (vty, length); |
| 4130 | } |
| 4131 | |
| 4132 | void |
| 4133 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 4134 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 4135 | { |
| 4136 | char buf[INET6_ADDRSTRLEN]; |
| 4137 | char buf1[BUFSIZ]; |
| 4138 | struct attr *attr; |
| 4139 | int sockunion_vty_out (struct vty *, union sockunion *); |
| 4140 | |
| 4141 | attr = binfo->attr; |
| 4142 | |
| 4143 | if (attr) |
| 4144 | { |
| 4145 | /* Line1 display AS-path, Aggregator */ |
| 4146 | if (attr->aspath) |
| 4147 | { |
| 4148 | vty_out (vty, " "); |
| 4149 | if (attr->aspath->length == 0) |
| 4150 | vty_out (vty, "Local"); |
| 4151 | else |
| 4152 | aspath_print_vty (vty, attr->aspath); |
| 4153 | } |
| 4154 | |
| 4155 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR) |
| 4156 | || CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT) |
| 4157 | || CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 4158 | || CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY) |
| 4159 | || CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4160 | { |
| 4161 | vty_out (vty, ","); |
| 4162 | |
| 4163 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)) |
| 4164 | vty_out (vty, " (aggregated by %d %s)", attr->aggregator_as, |
| 4165 | inet_ntoa (attr->aggregator_addr)); |
| 4166 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 4167 | vty_out (vty, " (Received from a RR-client)"); |
| 4168 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 4169 | vty_out (vty, " (Received from a RS-client)"); |
| 4170 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4171 | vty_out (vty, " (history entry)"); |
| 4172 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4173 | vty_out (vty, " (suppressed due to dampening)"); |
| 4174 | } |
| 4175 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4176 | |
| 4177 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 4178 | if (p->family == AF_INET) |
| 4179 | { |
| 4180 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
| 4181 | inet_ntoa (attr->mp_nexthop_global_in) : |
| 4182 | inet_ntoa (attr->nexthop)); |
| 4183 | } |
| 4184 | #ifdef HAVE_IPV6 |
| 4185 | else |
| 4186 | { |
| 4187 | vty_out (vty, " %s", |
| 4188 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, |
| 4189 | buf, INET6_ADDRSTRLEN)); |
| 4190 | } |
| 4191 | #endif /* HAVE_IPV6 */ |
| 4192 | |
| 4193 | if (binfo->peer == bgp->peer_self) |
| 4194 | { |
| 4195 | vty_out (vty, " from %s ", |
| 4196 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 4197 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 4198 | } |
| 4199 | else |
| 4200 | { |
| 4201 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 4202 | vty_out (vty, " (inaccessible)"); |
| 4203 | else if (binfo->igpmetric) |
| 4204 | vty_out (vty, " (metric %d)", binfo->igpmetric); |
| 4205 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
| 4206 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 4207 | vty_out (vty, " (%s)", inet_ntoa (attr->originator_id)); |
| 4208 | else |
| 4209 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 4210 | } |
| 4211 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4212 | |
| 4213 | #ifdef HAVE_IPV6 |
| 4214 | /* display nexthop local */ |
| 4215 | if (attr->mp_nexthop_len == 32) |
| 4216 | { |
| 4217 | vty_out (vty, " (%s)%s", |
| 4218 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, |
| 4219 | buf, INET6_ADDRSTRLEN), |
| 4220 | VTY_NEWLINE); |
| 4221 | } |
| 4222 | #endif /* HAVE_IPV6 */ |
| 4223 | |
| 4224 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 4225 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 4226 | |
| 4227 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
| 4228 | vty_out (vty, ", metric %d", attr->med); |
| 4229 | |
| 4230 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
| 4231 | vty_out (vty, ", localpref %d", attr->local_pref); |
| 4232 | else |
| 4233 | vty_out (vty, ", localpref %d", bgp->default_local_pref); |
| 4234 | |
| 4235 | if (attr->weight != 0) |
| 4236 | vty_out (vty, ", weight %d", attr->weight); |
| 4237 | |
| 4238 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4239 | vty_out (vty, ", valid"); |
| 4240 | |
| 4241 | if (binfo->peer != bgp->peer_self) |
| 4242 | { |
| 4243 | if (binfo->peer->as == binfo->peer->local_as) |
| 4244 | vty_out (vty, ", internal"); |
| 4245 | else |
| 4246 | vty_out (vty, ", %s", |
| 4247 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 4248 | } |
| 4249 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 4250 | vty_out (vty, ", aggregated, local"); |
| 4251 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 4252 | vty_out (vty, ", sourced"); |
| 4253 | else |
| 4254 | vty_out (vty, ", sourced, local"); |
| 4255 | |
| 4256 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 4257 | vty_out (vty, ", atomic-aggregate"); |
| 4258 | |
| 4259 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4260 | vty_out (vty, ", best"); |
| 4261 | |
| 4262 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4263 | |
| 4264 | /* Line 4 display Community */ |
| 4265 | if (attr->community) |
| 4266 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 4267 | VTY_NEWLINE); |
| 4268 | |
| 4269 | /* Line 5 display Extended-community */ |
| 4270 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
| 4271 | vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str, |
| 4272 | VTY_NEWLINE); |
| 4273 | |
| 4274 | /* Line 6 display Originator, Cluster-id */ |
| 4275 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 4276 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 4277 | { |
| 4278 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 4279 | vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id)); |
| 4280 | |
| 4281 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 4282 | { |
| 4283 | int i; |
| 4284 | vty_out (vty, ", Cluster list: "); |
| 4285 | for (i = 0; i < attr->cluster->length / 4; i++) |
| 4286 | vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i])); |
| 4287 | } |
| 4288 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4289 | } |
| 4290 | |
| 4291 | if (binfo->damp_info) |
| 4292 | bgp_damp_info_vty (vty, binfo); |
| 4293 | |
| 4294 | /* Line 7 display Uptime */ |
| 4295 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); |
| 4296 | } |
| 4297 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4298 | } |
| 4299 | |
| 4300 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 4301 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 4302 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 4303 | |
| 4304 | enum bgp_show_type |
| 4305 | { |
| 4306 | bgp_show_type_normal, |
| 4307 | bgp_show_type_regexp, |
| 4308 | bgp_show_type_prefix_list, |
| 4309 | bgp_show_type_filter_list, |
| 4310 | bgp_show_type_route_map, |
| 4311 | bgp_show_type_neighbor, |
| 4312 | bgp_show_type_cidr_only, |
| 4313 | bgp_show_type_prefix_longer, |
| 4314 | bgp_show_type_community_all, |
| 4315 | bgp_show_type_community, |
| 4316 | bgp_show_type_community_exact, |
| 4317 | bgp_show_type_community_list, |
| 4318 | bgp_show_type_community_list_exact, |
| 4319 | bgp_show_type_flap_statistics, |
| 4320 | bgp_show_type_flap_address, |
| 4321 | bgp_show_type_flap_prefix, |
| 4322 | bgp_show_type_flap_cidr_only, |
| 4323 | bgp_show_type_flap_regexp, |
| 4324 | bgp_show_type_flap_filter_list, |
| 4325 | bgp_show_type_flap_prefix_list, |
| 4326 | bgp_show_type_flap_prefix_longer, |
| 4327 | bgp_show_type_flap_route_map, |
| 4328 | bgp_show_type_flap_neighbor, |
| 4329 | bgp_show_type_dampend_paths, |
| 4330 | bgp_show_type_damp_neighbor |
| 4331 | }; |
| 4332 | |
| 4333 | int |
| 4334 | bgp_show_callback (struct vty *vty, int unlock) |
| 4335 | { |
| 4336 | struct bgp_node *rn; |
| 4337 | struct bgp_info *ri; |
| 4338 | int count; |
| 4339 | int limit; |
| 4340 | int display; |
| 4341 | |
| 4342 | rn = vty->output_rn; |
| 4343 | count = 0; |
| 4344 | limit = ((vty->lines == 0) |
| 4345 | ? 10 : (vty->lines > 0 |
| 4346 | ? vty->lines : vty->height - 2)); |
| 4347 | limit = limit > 0 ? limit : 2; |
| 4348 | |
| 4349 | /* Quit of display. */ |
| 4350 | if (unlock && rn) |
| 4351 | { |
| 4352 | bgp_unlock_node (rn); |
| 4353 | if (vty->output_clean) |
| 4354 | (*vty->output_clean) (vty); |
| 4355 | vty->output_rn = NULL; |
| 4356 | vty->output_func = NULL; |
| 4357 | vty->output_clean = NULL; |
| 4358 | vty->output_arg = NULL; |
| 4359 | return 0; |
| 4360 | } |
| 4361 | |
| 4362 | for (; rn; rn = bgp_route_next (rn)) |
| 4363 | if (rn->info != NULL) |
| 4364 | { |
| 4365 | display = 0; |
| 4366 | |
| 4367 | for (ri = rn->info; ri; ri = ri->next) |
| 4368 | { |
| 4369 | if (vty->output_type == bgp_show_type_flap_statistics |
| 4370 | || vty->output_type == bgp_show_type_flap_address |
| 4371 | || vty->output_type == bgp_show_type_flap_prefix |
| 4372 | || vty->output_type == bgp_show_type_flap_cidr_only |
| 4373 | || vty->output_type == bgp_show_type_flap_regexp |
| 4374 | || vty->output_type == bgp_show_type_flap_filter_list |
| 4375 | || vty->output_type == bgp_show_type_flap_prefix_list |
| 4376 | || vty->output_type == bgp_show_type_flap_prefix_longer |
| 4377 | || vty->output_type == bgp_show_type_flap_route_map |
| 4378 | || vty->output_type == bgp_show_type_flap_neighbor |
| 4379 | || vty->output_type == bgp_show_type_dampend_paths |
| 4380 | || vty->output_type == bgp_show_type_damp_neighbor) |
| 4381 | { |
| 4382 | if (! ri->damp_info) |
| 4383 | continue; |
| 4384 | } |
| 4385 | if (vty->output_type == bgp_show_type_regexp |
| 4386 | || vty->output_type == bgp_show_type_flap_regexp) |
| 4387 | { |
| 4388 | regex_t *regex = vty->output_arg; |
| 4389 | |
| 4390 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 4391 | continue; |
| 4392 | } |
| 4393 | if (vty->output_type == bgp_show_type_prefix_list |
| 4394 | || vty->output_type == bgp_show_type_flap_prefix_list) |
| 4395 | { |
| 4396 | struct prefix_list *plist = vty->output_arg; |
| 4397 | |
| 4398 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 4399 | continue; |
| 4400 | } |
| 4401 | if (vty->output_type == bgp_show_type_filter_list |
| 4402 | || vty->output_type == bgp_show_type_flap_filter_list) |
| 4403 | { |
| 4404 | struct as_list *as_list = vty->output_arg; |
| 4405 | |
| 4406 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 4407 | continue; |
| 4408 | } |
| 4409 | if (vty->output_type == bgp_show_type_route_map |
| 4410 | || vty->output_type == bgp_show_type_flap_route_map) |
| 4411 | { |
| 4412 | struct route_map *rmap = vty->output_arg; |
| 4413 | struct bgp_info binfo; |
| 4414 | struct attr dummy_attr; |
| 4415 | int ret; |
| 4416 | |
| 4417 | dummy_attr = *ri->attr; |
| 4418 | binfo.peer = ri->peer; |
| 4419 | binfo.attr = &dummy_attr; |
| 4420 | |
| 4421 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 4422 | |
| 4423 | if (ret == RMAP_DENYMATCH) |
| 4424 | continue; |
| 4425 | } |
| 4426 | if (vty->output_type == bgp_show_type_neighbor |
| 4427 | || vty->output_type == bgp_show_type_flap_neighbor |
| 4428 | || vty->output_type == bgp_show_type_damp_neighbor) |
| 4429 | { |
| 4430 | union sockunion *su = vty->output_arg; |
| 4431 | |
| 4432 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 4433 | continue; |
| 4434 | } |
| 4435 | if (vty->output_type == bgp_show_type_cidr_only |
| 4436 | || vty->output_type == bgp_show_type_flap_cidr_only) |
| 4437 | { |
| 4438 | u_int32_t destination; |
| 4439 | |
| 4440 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 4441 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 4442 | continue; |
| 4443 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 4444 | continue; |
| 4445 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 4446 | continue; |
| 4447 | } |
| 4448 | if (vty->output_type == bgp_show_type_prefix_longer |
| 4449 | || vty->output_type == bgp_show_type_flap_prefix_longer) |
| 4450 | { |
| 4451 | struct prefix *p = vty->output_arg; |
| 4452 | |
| 4453 | if (! prefix_match (p, &rn->p)) |
| 4454 | continue; |
| 4455 | } |
| 4456 | if (vty->output_type == bgp_show_type_community_all) |
| 4457 | { |
| 4458 | if (! ri->attr->community) |
| 4459 | continue; |
| 4460 | } |
| 4461 | if (vty->output_type == bgp_show_type_community) |
| 4462 | { |
| 4463 | struct community *com = vty->output_arg; |
| 4464 | |
| 4465 | if (! ri->attr->community || |
| 4466 | ! community_match (ri->attr->community, com)) |
| 4467 | continue; |
| 4468 | } |
| 4469 | if (vty->output_type == bgp_show_type_community_exact) |
| 4470 | { |
| 4471 | struct community *com = vty->output_arg; |
| 4472 | |
| 4473 | if (! ri->attr->community || |
| 4474 | ! community_cmp (ri->attr->community, com)) |
| 4475 | continue; |
| 4476 | } |
| 4477 | if (vty->output_type == bgp_show_type_community_list) |
| 4478 | { |
| 4479 | struct community_list *list = vty->output_arg; |
| 4480 | |
| 4481 | if (! community_list_match (ri->attr->community, list)) |
| 4482 | continue; |
| 4483 | } |
| 4484 | if (vty->output_type == bgp_show_type_community_list_exact) |
| 4485 | { |
| 4486 | struct community_list *list = vty->output_arg; |
| 4487 | |
| 4488 | if (! community_list_exact_match (ri->attr->community, list)) |
| 4489 | continue; |
| 4490 | } |
| 4491 | if (vty->output_type == bgp_show_type_flap_address |
| 4492 | || vty->output_type == bgp_show_type_flap_prefix) |
| 4493 | { |
| 4494 | struct prefix *p = vty->output_arg; |
| 4495 | |
| 4496 | if (! prefix_match (&rn->p, p)) |
| 4497 | continue; |
| 4498 | |
| 4499 | if (vty->output_type == bgp_show_type_flap_prefix) |
| 4500 | if (p->prefixlen != rn->p.prefixlen) |
| 4501 | continue; |
| 4502 | } |
| 4503 | if (vty->output_type == bgp_show_type_dampend_paths |
| 4504 | || vty->output_type == bgp_show_type_damp_neighbor) |
| 4505 | { |
| 4506 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 4507 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 4508 | continue; |
| 4509 | } |
| 4510 | |
| 4511 | if (vty->output_type == bgp_show_type_dampend_paths |
| 4512 | || vty->output_type == bgp_show_type_damp_neighbor) |
| 4513 | count += damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4514 | else if (vty->output_type == bgp_show_type_flap_statistics |
| 4515 | || vty->output_type == bgp_show_type_flap_address |
| 4516 | || vty->output_type == bgp_show_type_flap_prefix |
| 4517 | || vty->output_type == bgp_show_type_flap_cidr_only |
| 4518 | || vty->output_type == bgp_show_type_flap_regexp |
| 4519 | || vty->output_type == bgp_show_type_flap_filter_list |
| 4520 | || vty->output_type == bgp_show_type_flap_prefix_list |
| 4521 | || vty->output_type == bgp_show_type_flap_prefix_longer |
| 4522 | || vty->output_type == bgp_show_type_flap_route_map |
| 4523 | || vty->output_type == bgp_show_type_flap_neighbor) |
| 4524 | count += flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4525 | else |
| 4526 | count += route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4527 | display++; |
| 4528 | } |
| 4529 | |
| 4530 | if (display) |
| 4531 | vty->output_count++; |
| 4532 | |
| 4533 | /* Remember current pointer then suspend output. */ |
| 4534 | if (count >= limit) |
| 4535 | { |
| 4536 | vty->status = VTY_CONTINUE; |
| 4537 | vty->output_rn = bgp_route_next (rn);; |
| 4538 | vty->output_func = bgp_show_callback; |
| 4539 | return 0; |
| 4540 | } |
| 4541 | } |
| 4542 | |
| 4543 | /* Total line display. */ |
| 4544 | if (vty->output_count) |
| 4545 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 4546 | VTY_NEWLINE, vty->output_count, VTY_NEWLINE); |
| 4547 | |
| 4548 | if (vty->output_clean) |
| 4549 | (*vty->output_clean) (vty); |
| 4550 | |
| 4551 | vty->status = VTY_CONTINUE; |
| 4552 | vty->output_rn = NULL; |
| 4553 | vty->output_func = NULL; |
| 4554 | vty->output_clean = NULL; |
| 4555 | vty->output_arg = NULL; |
| 4556 | |
| 4557 | return 0; |
| 4558 | } |
| 4559 | |
| 4560 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 4561 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4562 | enum bgp_show_type type) |
| 4563 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4564 | struct bgp_info *ri; |
| 4565 | struct bgp_node *rn; |
| 4566 | struct bgp_table *table; |
| 4567 | int header = 1; |
| 4568 | int count; |
| 4569 | int limit; |
| 4570 | int display; |
| 4571 | |
| 4572 | limit = ((vty->lines == 0) |
| 4573 | ? 10 : (vty->lines > 0 |
| 4574 | ? vty->lines : vty->height - 2)); |
| 4575 | limit = limit > 0 ? limit : 2; |
| 4576 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 4577 | if (bgp == NULL) { |
| 4578 | bgp = bgp_get_default (); |
| 4579 | } |
| 4580 | |
| 4581 | if (bgp == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4582 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 4583 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 4584 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4585 | } |
| 4586 | |
| 4587 | count = 0; |
| 4588 | |
| 4589 | /* This is first entry point, so reset total line. */ |
| 4590 | vty->output_count = 0; |
| 4591 | vty->output_type = type; |
| 4592 | |
| 4593 | table = bgp->rib[afi][safi]; |
| 4594 | |
| 4595 | /* Start processing of routes. */ |
| 4596 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 4597 | if (rn->info != NULL) |
| 4598 | { |
| 4599 | display = 0; |
| 4600 | |
| 4601 | for (ri = rn->info; ri; ri = ri->next) |
| 4602 | { |
| 4603 | if (vty->output_type == bgp_show_type_flap_statistics |
| 4604 | || type == bgp_show_type_flap_address |
| 4605 | || type == bgp_show_type_flap_prefix |
| 4606 | || type == bgp_show_type_flap_cidr_only |
| 4607 | || type == bgp_show_type_flap_regexp |
| 4608 | || type == bgp_show_type_flap_filter_list |
| 4609 | || type == bgp_show_type_flap_prefix_list |
| 4610 | || type == bgp_show_type_flap_prefix_longer |
| 4611 | || type == bgp_show_type_flap_route_map |
| 4612 | || type == bgp_show_type_flap_neighbor |
| 4613 | || type == bgp_show_type_dampend_paths |
| 4614 | || type == bgp_show_type_damp_neighbor) |
| 4615 | { |
| 4616 | if (! ri->damp_info) |
| 4617 | continue; |
| 4618 | } |
| 4619 | if (type == bgp_show_type_regexp |
| 4620 | || type == bgp_show_type_flap_regexp) |
| 4621 | { |
| 4622 | regex_t *regex = vty->output_arg; |
| 4623 | |
| 4624 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 4625 | continue; |
| 4626 | } |
| 4627 | if (type == bgp_show_type_prefix_list |
| 4628 | || type == bgp_show_type_flap_prefix_list) |
| 4629 | { |
| 4630 | struct prefix_list *plist = vty->output_arg; |
| 4631 | |
| 4632 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 4633 | continue; |
| 4634 | } |
| 4635 | if (type == bgp_show_type_filter_list |
| 4636 | || type == bgp_show_type_flap_filter_list) |
| 4637 | { |
| 4638 | struct as_list *as_list = vty->output_arg; |
| 4639 | |
| 4640 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 4641 | continue; |
| 4642 | } |
| 4643 | if (type == bgp_show_type_route_map |
| 4644 | || type == bgp_show_type_flap_route_map) |
| 4645 | { |
| 4646 | struct route_map *rmap = vty->output_arg; |
| 4647 | struct bgp_info binfo; |
| 4648 | struct attr dummy_attr; |
| 4649 | int ret; |
| 4650 | |
| 4651 | dummy_attr = *ri->attr; |
| 4652 | binfo.peer = ri->peer; |
| 4653 | binfo.attr = &dummy_attr; |
| 4654 | |
| 4655 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 4656 | |
| 4657 | if (ret == RMAP_DENYMATCH) |
| 4658 | continue; |
| 4659 | } |
| 4660 | if (type == bgp_show_type_neighbor |
| 4661 | || type == bgp_show_type_flap_neighbor |
| 4662 | || type == bgp_show_type_damp_neighbor) |
| 4663 | { |
| 4664 | union sockunion *su = vty->output_arg; |
| 4665 | |
| 4666 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 4667 | continue; |
| 4668 | } |
| 4669 | if (type == bgp_show_type_cidr_only |
| 4670 | || type == bgp_show_type_flap_cidr_only) |
| 4671 | { |
| 4672 | u_int32_t destination; |
| 4673 | |
| 4674 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 4675 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 4676 | continue; |
| 4677 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 4678 | continue; |
| 4679 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 4680 | continue; |
| 4681 | } |
| 4682 | if (type == bgp_show_type_prefix_longer |
| 4683 | || type == bgp_show_type_flap_prefix_longer) |
| 4684 | { |
| 4685 | struct prefix *p = vty->output_arg; |
| 4686 | |
| 4687 | if (! prefix_match (p, &rn->p)) |
| 4688 | continue; |
| 4689 | } |
| 4690 | if (type == bgp_show_type_community_all) |
| 4691 | { |
| 4692 | if (! ri->attr->community) |
| 4693 | continue; |
| 4694 | } |
| 4695 | if (type == bgp_show_type_community) |
| 4696 | { |
| 4697 | struct community *com = vty->output_arg; |
| 4698 | |
| 4699 | if (! ri->attr->community || |
| 4700 | ! community_match (ri->attr->community, com)) |
| 4701 | continue; |
| 4702 | } |
| 4703 | if (type == bgp_show_type_community_exact) |
| 4704 | { |
| 4705 | struct community *com = vty->output_arg; |
| 4706 | |
| 4707 | if (! ri->attr->community || |
| 4708 | ! community_cmp (ri->attr->community, com)) |
| 4709 | continue; |
| 4710 | } |
| 4711 | if (type == bgp_show_type_community_list) |
| 4712 | { |
| 4713 | struct community_list *list = vty->output_arg; |
| 4714 | |
| 4715 | if (! community_list_match (ri->attr->community, list)) |
| 4716 | continue; |
| 4717 | } |
| 4718 | if (type == bgp_show_type_community_list_exact) |
| 4719 | { |
| 4720 | struct community_list *list = vty->output_arg; |
| 4721 | |
| 4722 | if (! community_list_exact_match (ri->attr->community, list)) |
| 4723 | continue; |
| 4724 | } |
| 4725 | if (type == bgp_show_type_flap_address |
| 4726 | || type == bgp_show_type_flap_prefix) |
| 4727 | { |
| 4728 | struct prefix *p = vty->output_arg; |
| 4729 | |
| 4730 | if (! prefix_match (&rn->p, p)) |
| 4731 | continue; |
| 4732 | |
| 4733 | if (type == bgp_show_type_flap_prefix) |
| 4734 | if (p->prefixlen != rn->p.prefixlen) |
| 4735 | continue; |
| 4736 | } |
| 4737 | if (type == bgp_show_type_dampend_paths |
| 4738 | || type == bgp_show_type_damp_neighbor) |
| 4739 | { |
| 4740 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 4741 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 4742 | continue; |
| 4743 | } |
| 4744 | |
| 4745 | if (header) |
| 4746 | { |
| 4747 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 4748 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 4749 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 4750 | if (type == bgp_show_type_dampend_paths |
| 4751 | || type == bgp_show_type_damp_neighbor) |
| 4752 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 4753 | else if (type == bgp_show_type_flap_statistics |
| 4754 | || type == bgp_show_type_flap_address |
| 4755 | || type == bgp_show_type_flap_prefix |
| 4756 | || type == bgp_show_type_flap_cidr_only |
| 4757 | || type == bgp_show_type_flap_regexp |
| 4758 | || type == bgp_show_type_flap_filter_list |
| 4759 | || type == bgp_show_type_flap_prefix_list |
| 4760 | || type == bgp_show_type_flap_prefix_longer |
| 4761 | || type == bgp_show_type_flap_route_map |
| 4762 | || type == bgp_show_type_flap_neighbor) |
| 4763 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 4764 | else |
| 4765 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 4766 | count += 5; |
| 4767 | header = 0; |
| 4768 | } |
| 4769 | |
| 4770 | if (type == bgp_show_type_dampend_paths |
| 4771 | || type == bgp_show_type_damp_neighbor) |
| 4772 | count += damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4773 | else if (type == bgp_show_type_flap_statistics |
| 4774 | || type == bgp_show_type_flap_address |
| 4775 | || type == bgp_show_type_flap_prefix |
| 4776 | || type == bgp_show_type_flap_cidr_only |
| 4777 | || type == bgp_show_type_flap_regexp |
| 4778 | || type == bgp_show_type_flap_filter_list |
| 4779 | || type == bgp_show_type_flap_prefix_list |
| 4780 | || type == bgp_show_type_flap_prefix_longer |
| 4781 | || type == bgp_show_type_flap_route_map |
| 4782 | || type == bgp_show_type_flap_neighbor) |
| 4783 | count += flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4784 | else |
| 4785 | count += route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4786 | display++; |
| 4787 | } |
| 4788 | if (display) |
| 4789 | vty->output_count++; |
| 4790 | |
| 4791 | /* Remember current pointer then suspend output. */ |
| 4792 | if (count >= limit && vty->type != VTY_SHELL_SERV) |
| 4793 | { |
| 4794 | vty->status = VTY_START; |
| 4795 | vty->output_rn = bgp_route_next (rn); |
| 4796 | vty->output_func = bgp_show_callback; |
| 4797 | vty->output_type = type; |
| 4798 | |
| 4799 | return CMD_SUCCESS; |
| 4800 | } |
| 4801 | } |
| 4802 | |
| 4803 | /* No route is displayed */ |
| 4804 | if (vty->output_count == 0) |
| 4805 | { |
| 4806 | if (type == bgp_show_type_normal) |
| 4807 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 4808 | } |
| 4809 | else |
| 4810 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 4811 | VTY_NEWLINE, vty->output_count, VTY_NEWLINE); |
| 4812 | |
| 4813 | /* Clean up allocated resources. */ |
| 4814 | if (vty->output_clean) |
| 4815 | (*vty->output_clean) (vty); |
| 4816 | |
| 4817 | vty->status = VTY_START; |
| 4818 | vty->output_rn = NULL; |
| 4819 | vty->output_func = NULL; |
| 4820 | vty->output_clean = NULL; |
| 4821 | vty->output_arg = NULL; |
| 4822 | |
| 4823 | return CMD_SUCCESS; |
| 4824 | } |
| 4825 | |
| 4826 | /* Header of detailed BGP route information */ |
| 4827 | void |
| 4828 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 4829 | struct bgp_node *rn, |
| 4830 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 4831 | { |
| 4832 | struct bgp_info *ri; |
| 4833 | struct prefix *p; |
| 4834 | struct peer *peer; |
| 4835 | struct listnode *nn; |
| 4836 | char buf1[INET6_ADDRSTRLEN]; |
| 4837 | char buf2[INET6_ADDRSTRLEN]; |
| 4838 | int count = 0; |
| 4839 | int best = 0; |
| 4840 | int suppress = 0; |
| 4841 | int no_export = 0; |
| 4842 | int no_advertise = 0; |
| 4843 | int local_as = 0; |
| 4844 | int first = 0; |
| 4845 | |
| 4846 | p = &rn->p; |
| 4847 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 4848 | (safi == SAFI_MPLS_VPN ? |
| 4849 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 4850 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 4851 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 4852 | p->prefixlen, VTY_NEWLINE); |
| 4853 | |
| 4854 | for (ri = rn->info; ri; ri = ri->next) |
| 4855 | { |
| 4856 | count++; |
| 4857 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 4858 | { |
| 4859 | best = count; |
| 4860 | if (ri->suppress) |
| 4861 | suppress = 1; |
| 4862 | if (ri->attr->community != NULL) |
| 4863 | { |
| 4864 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 4865 | no_advertise = 1; |
| 4866 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 4867 | no_export = 1; |
| 4868 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 4869 | local_as = 1; |
| 4870 | } |
| 4871 | } |
| 4872 | } |
| 4873 | |
| 4874 | vty_out (vty, "Paths: (%d available", count); |
| 4875 | if (best) |
| 4876 | { |
| 4877 | vty_out (vty, ", best #%d", best); |
| 4878 | if (safi == SAFI_UNICAST) |
| 4879 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 4880 | } |
| 4881 | else |
| 4882 | vty_out (vty, ", no best path"); |
| 4883 | if (no_advertise) |
| 4884 | vty_out (vty, ", not advertised to any peer"); |
| 4885 | else if (no_export) |
| 4886 | vty_out (vty, ", not advertised to EBGP peer"); |
| 4887 | else if (local_as) |
| 4888 | vty_out (vty, ", not advertised outside local AS"); |
| 4889 | if (suppress) |
| 4890 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 4891 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 4892 | |
| 4893 | /* advertised peer */ |
| 4894 | LIST_LOOP (bgp->peer, peer, nn) |
| 4895 | { |
| 4896 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 4897 | { |
| 4898 | if (! first) |
| 4899 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 4900 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 4901 | first = 1; |
| 4902 | } |
| 4903 | } |
| 4904 | if (! first) |
| 4905 | vty_out (vty, " Not advertised to any peer"); |
| 4906 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4907 | } |
| 4908 | |
| 4909 | /* Display specified route of BGP table. */ |
| 4910 | int |
| 4911 | bgp_show_route (struct vty *vty, char *view_name, char *ip_str, |
| 4912 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 4913 | int prefix_check) |
| 4914 | { |
| 4915 | int ret; |
| 4916 | int header; |
| 4917 | int display = 0; |
| 4918 | struct prefix match; |
| 4919 | struct bgp_node *rn; |
| 4920 | struct bgp_node *rm; |
| 4921 | struct bgp_info *ri; |
| 4922 | struct bgp *bgp; |
| 4923 | struct bgp_table *table; |
| 4924 | |
| 4925 | /* BGP structure lookup. */ |
| 4926 | if (view_name) |
| 4927 | { |
| 4928 | bgp = bgp_lookup_by_name (view_name); |
| 4929 | if (bgp == NULL) |
| 4930 | { |
| 4931 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 4932 | return CMD_WARNING; |
| 4933 | } |
| 4934 | } |
| 4935 | else |
| 4936 | { |
| 4937 | bgp = bgp_get_default (); |
| 4938 | if (bgp == NULL) |
| 4939 | { |
| 4940 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 4941 | return CMD_WARNING; |
| 4942 | } |
| 4943 | } |
| 4944 | |
| 4945 | /* Check IP address argument. */ |
| 4946 | ret = str2prefix (ip_str, &match); |
| 4947 | if (! ret) |
| 4948 | { |
| 4949 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 4950 | return CMD_WARNING; |
| 4951 | } |
| 4952 | |
| 4953 | match.family = afi2family (afi); |
| 4954 | |
| 4955 | if (safi == SAFI_MPLS_VPN) |
| 4956 | { |
| 4957 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 4958 | { |
| 4959 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 4960 | continue; |
| 4961 | |
| 4962 | if ((table = rn->info) != NULL) |
| 4963 | { |
| 4964 | header = 1; |
| 4965 | |
| 4966 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 4967 | { |
| 4968 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 4969 | continue; |
| 4970 | |
| 4971 | for (ri = rm->info; ri; ri = ri->next) |
| 4972 | { |
| 4973 | if (header) |
| 4974 | { |
| 4975 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 4976 | AFI_IP, SAFI_MPLS_VPN); |
| 4977 | |
| 4978 | header = 0; |
| 4979 | } |
| 4980 | display++; |
| 4981 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 4982 | } |
| 4983 | } |
| 4984 | } |
| 4985 | } |
| 4986 | } |
| 4987 | else |
| 4988 | { |
| 4989 | header = 1; |
| 4990 | |
| 4991 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 4992 | { |
| 4993 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 4994 | { |
| 4995 | for (ri = rn->info; ri; ri = ri->next) |
| 4996 | { |
| 4997 | if (header) |
| 4998 | { |
| 4999 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 5000 | header = 0; |
| 5001 | } |
| 5002 | display++; |
| 5003 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 5004 | } |
| 5005 | } |
| 5006 | } |
| 5007 | } |
| 5008 | |
| 5009 | if (! display) |
| 5010 | { |
| 5011 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 5012 | return CMD_WARNING; |
| 5013 | } |
| 5014 | |
| 5015 | return CMD_SUCCESS; |
| 5016 | } |
| 5017 | |
| 5018 | /* BGP route print out function. */ |
| 5019 | DEFUN (show_ip_bgp, |
| 5020 | show_ip_bgp_cmd, |
| 5021 | "show ip bgp", |
| 5022 | SHOW_STR |
| 5023 | IP_STR |
| 5024 | BGP_STR) |
| 5025 | { |
| 5026 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal); |
| 5027 | } |
| 5028 | |
| 5029 | DEFUN (show_ip_bgp_ipv4, |
| 5030 | show_ip_bgp_ipv4_cmd, |
| 5031 | "show ip bgp ipv4 (unicast|multicast)", |
| 5032 | SHOW_STR |
| 5033 | IP_STR |
| 5034 | BGP_STR |
| 5035 | "Address family\n" |
| 5036 | "Address Family modifier\n" |
| 5037 | "Address Family modifier\n") |
| 5038 | { |
| 5039 | if (strncmp (argv[0], "m", 1) == 0) |
| 5040 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal); |
| 5041 | |
| 5042 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal); |
| 5043 | } |
| 5044 | |
| 5045 | DEFUN (show_ip_bgp_route, |
| 5046 | show_ip_bgp_route_cmd, |
| 5047 | "show ip bgp A.B.C.D", |
| 5048 | SHOW_STR |
| 5049 | IP_STR |
| 5050 | BGP_STR |
| 5051 | "Network in the BGP routing table to display\n") |
| 5052 | { |
| 5053 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5054 | } |
| 5055 | |
| 5056 | DEFUN (show_ip_bgp_ipv4_route, |
| 5057 | show_ip_bgp_ipv4_route_cmd, |
| 5058 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 5059 | SHOW_STR |
| 5060 | IP_STR |
| 5061 | BGP_STR |
| 5062 | "Address family\n" |
| 5063 | "Address Family modifier\n" |
| 5064 | "Address Family modifier\n" |
| 5065 | "Network in the BGP routing table to display\n") |
| 5066 | { |
| 5067 | if (strncmp (argv[0], "m", 1) == 0) |
| 5068 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 5069 | |
| 5070 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5071 | } |
| 5072 | |
| 5073 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 5074 | show_ip_bgp_vpnv4_all_route_cmd, |
| 5075 | "show ip bgp vpnv4 all A.B.C.D", |
| 5076 | SHOW_STR |
| 5077 | IP_STR |
| 5078 | BGP_STR |
| 5079 | "Display VPNv4 NLRI specific information\n" |
| 5080 | "Display information about all VPNv4 NLRIs\n" |
| 5081 | "Network in the BGP routing table to display\n") |
| 5082 | { |
| 5083 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 5084 | } |
| 5085 | |
| 5086 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 5087 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 5088 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 5089 | SHOW_STR |
| 5090 | IP_STR |
| 5091 | BGP_STR |
| 5092 | "Display VPNv4 NLRI specific information\n" |
| 5093 | "Display information for a route distinguisher\n" |
| 5094 | "VPN Route Distinguisher\n" |
| 5095 | "Network in the BGP routing table to display\n") |
| 5096 | { |
| 5097 | int ret; |
| 5098 | struct prefix_rd prd; |
| 5099 | |
| 5100 | ret = str2prefix_rd (argv[0], &prd); |
| 5101 | if (! ret) |
| 5102 | { |
| 5103 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5104 | return CMD_WARNING; |
| 5105 | } |
| 5106 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 5107 | } |
| 5108 | |
| 5109 | DEFUN (show_ip_bgp_prefix, |
| 5110 | show_ip_bgp_prefix_cmd, |
| 5111 | "show ip bgp A.B.C.D/M", |
| 5112 | SHOW_STR |
| 5113 | IP_STR |
| 5114 | BGP_STR |
| 5115 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5116 | { |
| 5117 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5118 | } |
| 5119 | |
| 5120 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 5121 | show_ip_bgp_ipv4_prefix_cmd, |
| 5122 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 5123 | SHOW_STR |
| 5124 | IP_STR |
| 5125 | BGP_STR |
| 5126 | "Address family\n" |
| 5127 | "Address Family modifier\n" |
| 5128 | "Address Family modifier\n" |
| 5129 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5130 | { |
| 5131 | if (strncmp (argv[0], "m", 1) == 0) |
| 5132 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 5133 | |
| 5134 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5135 | } |
| 5136 | |
| 5137 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 5138 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 5139 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 5140 | SHOW_STR |
| 5141 | IP_STR |
| 5142 | BGP_STR |
| 5143 | "Display VPNv4 NLRI specific information\n" |
| 5144 | "Display information about all VPNv4 NLRIs\n" |
| 5145 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5146 | { |
| 5147 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 5148 | } |
| 5149 | |
| 5150 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 5151 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 5152 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 5153 | SHOW_STR |
| 5154 | IP_STR |
| 5155 | BGP_STR |
| 5156 | "Display VPNv4 NLRI specific information\n" |
| 5157 | "Display information for a route distinguisher\n" |
| 5158 | "VPN Route Distinguisher\n" |
| 5159 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5160 | { |
| 5161 | int ret; |
| 5162 | struct prefix_rd prd; |
| 5163 | |
| 5164 | ret = str2prefix_rd (argv[0], &prd); |
| 5165 | if (! ret) |
| 5166 | { |
| 5167 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5168 | return CMD_WARNING; |
| 5169 | } |
| 5170 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 5171 | } |
| 5172 | |
| 5173 | DEFUN (show_ip_bgp_view, |
| 5174 | show_ip_bgp_view_cmd, |
| 5175 | "show ip bgp view WORD", |
| 5176 | SHOW_STR |
| 5177 | IP_STR |
| 5178 | BGP_STR |
| 5179 | "BGP view\n" |
| 5180 | "BGP view name\n") |
| 5181 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 5182 | struct bgp *bgp; |
| 5183 | |
| 5184 | /* BGP structure lookup. */ |
| 5185 | bgp = bgp_lookup_by_name (argv[0]); |
| 5186 | if (bgp == NULL) |
| 5187 | { |
| 5188 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 5189 | return CMD_WARNING; |
| 5190 | } |
| 5191 | |
| 5192 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5193 | } |
| 5194 | |
| 5195 | DEFUN (show_ip_bgp_view_route, |
| 5196 | show_ip_bgp_view_route_cmd, |
| 5197 | "show ip bgp view WORD A.B.C.D", |
| 5198 | SHOW_STR |
| 5199 | IP_STR |
| 5200 | BGP_STR |
| 5201 | "BGP view\n" |
| 5202 | "BGP view name\n" |
| 5203 | "Network in the BGP routing table to display\n") |
| 5204 | { |
| 5205 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5206 | } |
| 5207 | |
| 5208 | DEFUN (show_ip_bgp_view_prefix, |
| 5209 | show_ip_bgp_view_prefix_cmd, |
| 5210 | "show ip bgp view WORD A.B.C.D/M", |
| 5211 | SHOW_STR |
| 5212 | IP_STR |
| 5213 | BGP_STR |
| 5214 | "BGP view\n" |
| 5215 | "BGP view name\n" |
| 5216 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5217 | { |
| 5218 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5219 | } |
| 5220 | |
| 5221 | #ifdef HAVE_IPV6 |
| 5222 | DEFUN (show_bgp, |
| 5223 | show_bgp_cmd, |
| 5224 | "show bgp", |
| 5225 | SHOW_STR |
| 5226 | BGP_STR) |
| 5227 | { |
| 5228 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal); |
| 5229 | } |
| 5230 | |
| 5231 | ALIAS (show_bgp, |
| 5232 | show_bgp_ipv6_cmd, |
| 5233 | "show bgp ipv6", |
| 5234 | SHOW_STR |
| 5235 | BGP_STR |
| 5236 | "Address family\n") |
| 5237 | |
| 5238 | /* old command */ |
| 5239 | DEFUN (show_ipv6_bgp, |
| 5240 | show_ipv6_bgp_cmd, |
| 5241 | "show ipv6 bgp", |
| 5242 | SHOW_STR |
| 5243 | IP_STR |
| 5244 | BGP_STR) |
| 5245 | { |
| 5246 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal); |
| 5247 | } |
| 5248 | |
| 5249 | DEFUN (show_bgp_route, |
| 5250 | show_bgp_route_cmd, |
| 5251 | "show bgp X:X::X:X", |
| 5252 | SHOW_STR |
| 5253 | BGP_STR |
| 5254 | "Network in the BGP routing table to display\n") |
| 5255 | { |
| 5256 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5257 | } |
| 5258 | |
| 5259 | ALIAS (show_bgp_route, |
| 5260 | show_bgp_ipv6_route_cmd, |
| 5261 | "show bgp ipv6 X:X::X:X", |
| 5262 | SHOW_STR |
| 5263 | BGP_STR |
| 5264 | "Address family\n" |
| 5265 | "Network in the BGP routing table to display\n") |
| 5266 | |
| 5267 | /* old command */ |
| 5268 | DEFUN (show_ipv6_bgp_route, |
| 5269 | show_ipv6_bgp_route_cmd, |
| 5270 | "show ipv6 bgp X:X::X:X", |
| 5271 | SHOW_STR |
| 5272 | IP_STR |
| 5273 | BGP_STR |
| 5274 | "Network in the BGP routing table to display\n") |
| 5275 | { |
| 5276 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5277 | } |
| 5278 | |
| 5279 | DEFUN (show_bgp_prefix, |
| 5280 | show_bgp_prefix_cmd, |
| 5281 | "show bgp X:X::X:X/M", |
| 5282 | SHOW_STR |
| 5283 | BGP_STR |
| 5284 | "IPv6 prefix <network>/<length>\n") |
| 5285 | { |
| 5286 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 5287 | } |
| 5288 | |
| 5289 | ALIAS (show_bgp_prefix, |
| 5290 | show_bgp_ipv6_prefix_cmd, |
| 5291 | "show bgp ipv6 X:X::X:X/M", |
| 5292 | SHOW_STR |
| 5293 | BGP_STR |
| 5294 | "Address family\n" |
| 5295 | "IPv6 prefix <network>/<length>\n") |
| 5296 | |
| 5297 | /* old command */ |
| 5298 | DEFUN (show_ipv6_bgp_prefix, |
| 5299 | show_ipv6_bgp_prefix_cmd, |
| 5300 | "show ipv6 bgp X:X::X:X/M", |
| 5301 | SHOW_STR |
| 5302 | IP_STR |
| 5303 | BGP_STR |
| 5304 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 5305 | { |
| 5306 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 5307 | } |
| 5308 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 5309 | DEFUN (show_bgp_view, |
| 5310 | show_bgp_view_cmd, |
| 5311 | "show bgp view WORD", |
| 5312 | SHOW_STR |
| 5313 | BGP_STR |
| 5314 | "BGP view\n" |
| 5315 | "View name\n") |
| 5316 | { |
| 5317 | struct bgp *bgp; |
| 5318 | |
| 5319 | /* BGP structure lookup. */ |
| 5320 | bgp = bgp_lookup_by_name (argv[0]); |
| 5321 | if (bgp == NULL) |
| 5322 | { |
| 5323 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 5324 | return CMD_WARNING; |
| 5325 | } |
| 5326 | |
| 5327 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal); |
| 5328 | } |
| 5329 | |
| 5330 | ALIAS (show_bgp_view, |
| 5331 | show_bgp_view_ipv6_cmd, |
| 5332 | "show bgp view WORD ipv6", |
| 5333 | SHOW_STR |
| 5334 | BGP_STR |
| 5335 | "BGP view\n" |
| 5336 | "View name\n" |
| 5337 | "Address family\n") |
| 5338 | |
| 5339 | DEFUN (show_bgp_view_route, |
| 5340 | show_bgp_view_route_cmd, |
| 5341 | "show bgp view WORD X:X::X:X", |
| 5342 | SHOW_STR |
| 5343 | BGP_STR |
| 5344 | "BGP view\n" |
| 5345 | "View name\n" |
| 5346 | "Network in the BGP routing table to display\n") |
| 5347 | { |
| 5348 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5349 | } |
| 5350 | |
| 5351 | ALIAS (show_bgp_view_route, |
| 5352 | show_bgp_view_ipv6_route_cmd, |
| 5353 | "show bgp view WORD ipv6 X:X::X:X", |
| 5354 | SHOW_STR |
| 5355 | BGP_STR |
| 5356 | "BGP view\n" |
| 5357 | "View name\n" |
| 5358 | "Address family\n" |
| 5359 | "Network in the BGP routing table to display\n") |
| 5360 | |
| 5361 | DEFUN (show_bgp_view_prefix, |
| 5362 | show_bgp_view_prefix_cmd, |
| 5363 | "show bgp view WORD X:X::X:X/M", |
| 5364 | SHOW_STR |
| 5365 | BGP_STR |
| 5366 | "BGP view\n" |
| 5367 | "View name\n" |
| 5368 | "IPv6 prefix <network>/<length>\n") |
| 5369 | { |
| 5370 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 5371 | } |
| 5372 | |
| 5373 | ALIAS (show_bgp_view_prefix, |
| 5374 | show_bgp_view_ipv6_prefix_cmd, |
| 5375 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 5376 | SHOW_STR |
| 5377 | BGP_STR |
| 5378 | "BGP view\n" |
| 5379 | "View name\n" |
| 5380 | "Address family\n" |
| 5381 | "IPv6 prefix <network>/<length>\n") |
| 5382 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5383 | /* old command */ |
| 5384 | DEFUN (show_ipv6_mbgp, |
| 5385 | show_ipv6_mbgp_cmd, |
| 5386 | "show ipv6 mbgp", |
| 5387 | SHOW_STR |
| 5388 | IP_STR |
| 5389 | MBGP_STR) |
| 5390 | { |
| 5391 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal); |
| 5392 | } |
| 5393 | |
| 5394 | /* old command */ |
| 5395 | DEFUN (show_ipv6_mbgp_route, |
| 5396 | show_ipv6_mbgp_route_cmd, |
| 5397 | "show ipv6 mbgp X:X::X:X", |
| 5398 | SHOW_STR |
| 5399 | IP_STR |
| 5400 | MBGP_STR |
| 5401 | "Network in the MBGP routing table to display\n") |
| 5402 | { |
| 5403 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 5404 | } |
| 5405 | |
| 5406 | /* old command */ |
| 5407 | DEFUN (show_ipv6_mbgp_prefix, |
| 5408 | show_ipv6_mbgp_prefix_cmd, |
| 5409 | "show ipv6 mbgp X:X::X:X/M", |
| 5410 | SHOW_STR |
| 5411 | IP_STR |
| 5412 | MBGP_STR |
| 5413 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 5414 | { |
| 5415 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 5416 | } |
| 5417 | #endif |
| 5418 | |
| 5419 | void |
| 5420 | bgp_show_regexp_clean (struct vty *vty) |
| 5421 | { |
| 5422 | bgp_regex_free (vty->output_arg); |
| 5423 | } |
| 5424 | |
| 5425 | int |
| 5426 | bgp_show_regexp (struct vty *vty, int argc, char **argv, afi_t afi, |
| 5427 | safi_t safi, enum bgp_show_type type) |
| 5428 | { |
| 5429 | int i; |
| 5430 | struct buffer *b; |
| 5431 | char *regstr; |
| 5432 | int first; |
| 5433 | regex_t *regex; |
| 5434 | |
| 5435 | first = 0; |
| 5436 | b = buffer_new (1024); |
| 5437 | for (i = 0; i < argc; i++) |
| 5438 | { |
| 5439 | if (first) |
| 5440 | buffer_putc (b, ' '); |
| 5441 | else |
| 5442 | { |
| 5443 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 5444 | continue; |
| 5445 | first = 1; |
| 5446 | } |
| 5447 | |
| 5448 | buffer_putstr (b, argv[i]); |
| 5449 | } |
| 5450 | buffer_putc (b, '\0'); |
| 5451 | |
| 5452 | regstr = buffer_getstr (b); |
| 5453 | buffer_free (b); |
| 5454 | |
| 5455 | regex = bgp_regcomp (regstr); |
| 5456 | if (! regex) |
| 5457 | { |
| 5458 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 5459 | VTY_NEWLINE); |
| 5460 | return CMD_WARNING; |
| 5461 | } |
| 5462 | |
| 5463 | vty->output_arg = regex; |
| 5464 | vty->output_clean = bgp_show_regexp_clean; |
| 5465 | |
| 5466 | return bgp_show (vty, NULL, afi, safi, type); |
| 5467 | } |
| 5468 | |
| 5469 | DEFUN (show_ip_bgp_regexp, |
| 5470 | show_ip_bgp_regexp_cmd, |
| 5471 | "show ip bgp regexp .LINE", |
| 5472 | SHOW_STR |
| 5473 | IP_STR |
| 5474 | BGP_STR |
| 5475 | "Display routes matching the AS path regular expression\n" |
| 5476 | "A regular-expression to match the BGP AS paths\n") |
| 5477 | { |
| 5478 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 5479 | bgp_show_type_regexp); |
| 5480 | } |
| 5481 | |
| 5482 | DEFUN (show_ip_bgp_flap_regexp, |
| 5483 | show_ip_bgp_flap_regexp_cmd, |
| 5484 | "show ip bgp flap-statistics regexp .LINE", |
| 5485 | SHOW_STR |
| 5486 | IP_STR |
| 5487 | BGP_STR |
| 5488 | "Display flap statistics of routes\n" |
| 5489 | "Display routes matching the AS path regular expression\n" |
| 5490 | "A regular-expression to match the BGP AS paths\n") |
| 5491 | { |
| 5492 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 5493 | bgp_show_type_flap_regexp); |
| 5494 | } |
| 5495 | |
| 5496 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 5497 | show_ip_bgp_ipv4_regexp_cmd, |
| 5498 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 5499 | SHOW_STR |
| 5500 | IP_STR |
| 5501 | BGP_STR |
| 5502 | "Address family\n" |
| 5503 | "Address Family modifier\n" |
| 5504 | "Address Family modifier\n" |
| 5505 | "Display routes matching the AS path regular expression\n" |
| 5506 | "A regular-expression to match the BGP AS paths\n") |
| 5507 | { |
| 5508 | if (strncmp (argv[0], "m", 1) == 0) |
| 5509 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 5510 | bgp_show_type_regexp); |
| 5511 | |
| 5512 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 5513 | bgp_show_type_regexp); |
| 5514 | } |
| 5515 | |
| 5516 | #ifdef HAVE_IPV6 |
| 5517 | DEFUN (show_bgp_regexp, |
| 5518 | show_bgp_regexp_cmd, |
| 5519 | "show bgp regexp .LINE", |
| 5520 | SHOW_STR |
| 5521 | BGP_STR |
| 5522 | "Display routes matching the AS path regular expression\n" |
| 5523 | "A regular-expression to match the BGP AS paths\n") |
| 5524 | { |
| 5525 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 5526 | bgp_show_type_regexp); |
| 5527 | } |
| 5528 | |
| 5529 | ALIAS (show_bgp_regexp, |
| 5530 | show_bgp_ipv6_regexp_cmd, |
| 5531 | "show bgp ipv6 regexp .LINE", |
| 5532 | SHOW_STR |
| 5533 | BGP_STR |
| 5534 | "Address family\n" |
| 5535 | "Display routes matching the AS path regular expression\n" |
| 5536 | "A regular-expression to match the BGP AS paths\n") |
| 5537 | |
| 5538 | /* old command */ |
| 5539 | DEFUN (show_ipv6_bgp_regexp, |
| 5540 | show_ipv6_bgp_regexp_cmd, |
| 5541 | "show ipv6 bgp regexp .LINE", |
| 5542 | SHOW_STR |
| 5543 | IP_STR |
| 5544 | BGP_STR |
| 5545 | "Display routes matching the AS path regular expression\n" |
| 5546 | "A regular-expression to match the BGP AS paths\n") |
| 5547 | { |
| 5548 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 5549 | bgp_show_type_regexp); |
| 5550 | } |
| 5551 | |
| 5552 | /* old command */ |
| 5553 | DEFUN (show_ipv6_mbgp_regexp, |
| 5554 | show_ipv6_mbgp_regexp_cmd, |
| 5555 | "show ipv6 mbgp regexp .LINE", |
| 5556 | SHOW_STR |
| 5557 | IP_STR |
| 5558 | BGP_STR |
| 5559 | "Display routes matching the AS path regular expression\n" |
| 5560 | "A regular-expression to match the MBGP AS paths\n") |
| 5561 | { |
| 5562 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 5563 | bgp_show_type_regexp); |
| 5564 | } |
| 5565 | #endif /* HAVE_IPV6 */ |
| 5566 | |
| 5567 | int |
| 5568 | bgp_show_prefix_list (struct vty *vty, char *prefix_list_str, afi_t afi, |
| 5569 | safi_t safi, enum bgp_show_type type) |
| 5570 | { |
| 5571 | struct prefix_list *plist; |
| 5572 | |
| 5573 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 5574 | if (plist == NULL) |
| 5575 | { |
| 5576 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 5577 | prefix_list_str, VTY_NEWLINE); |
| 5578 | return CMD_WARNING; |
| 5579 | } |
| 5580 | |
| 5581 | vty->output_arg = plist; |
| 5582 | |
| 5583 | return bgp_show (vty, NULL, afi, safi, type); |
| 5584 | } |
| 5585 | |
| 5586 | DEFUN (show_ip_bgp_prefix_list, |
| 5587 | show_ip_bgp_prefix_list_cmd, |
| 5588 | "show ip bgp prefix-list WORD", |
| 5589 | SHOW_STR |
| 5590 | IP_STR |
| 5591 | BGP_STR |
| 5592 | "Display routes conforming to the prefix-list\n" |
| 5593 | "IP prefix-list name\n") |
| 5594 | { |
| 5595 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5596 | bgp_show_type_prefix_list); |
| 5597 | } |
| 5598 | |
| 5599 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 5600 | show_ip_bgp_flap_prefix_list_cmd, |
| 5601 | "show ip bgp flap-statistics prefix-list WORD", |
| 5602 | SHOW_STR |
| 5603 | IP_STR |
| 5604 | BGP_STR |
| 5605 | "Display flap statistics of routes\n" |
| 5606 | "Display routes conforming to the prefix-list\n" |
| 5607 | "IP prefix-list name\n") |
| 5608 | { |
| 5609 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5610 | bgp_show_type_flap_prefix_list); |
| 5611 | } |
| 5612 | |
| 5613 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 5614 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 5615 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 5616 | SHOW_STR |
| 5617 | IP_STR |
| 5618 | BGP_STR |
| 5619 | "Address family\n" |
| 5620 | "Address Family modifier\n" |
| 5621 | "Address Family modifier\n" |
| 5622 | "Display routes conforming to the prefix-list\n" |
| 5623 | "IP prefix-list name\n") |
| 5624 | { |
| 5625 | if (strncmp (argv[0], "m", 1) == 0) |
| 5626 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 5627 | bgp_show_type_prefix_list); |
| 5628 | |
| 5629 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 5630 | bgp_show_type_prefix_list); |
| 5631 | } |
| 5632 | |
| 5633 | #ifdef HAVE_IPV6 |
| 5634 | DEFUN (show_bgp_prefix_list, |
| 5635 | show_bgp_prefix_list_cmd, |
| 5636 | "show bgp prefix-list WORD", |
| 5637 | SHOW_STR |
| 5638 | BGP_STR |
| 5639 | "Display routes conforming to the prefix-list\n" |
| 5640 | "IPv6 prefix-list name\n") |
| 5641 | { |
| 5642 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5643 | bgp_show_type_prefix_list); |
| 5644 | } |
| 5645 | |
| 5646 | ALIAS (show_bgp_prefix_list, |
| 5647 | show_bgp_ipv6_prefix_list_cmd, |
| 5648 | "show bgp ipv6 prefix-list WORD", |
| 5649 | SHOW_STR |
| 5650 | BGP_STR |
| 5651 | "Address family\n" |
| 5652 | "Display routes conforming to the prefix-list\n" |
| 5653 | "IPv6 prefix-list name\n") |
| 5654 | |
| 5655 | /* old command */ |
| 5656 | DEFUN (show_ipv6_bgp_prefix_list, |
| 5657 | show_ipv6_bgp_prefix_list_cmd, |
| 5658 | "show ipv6 bgp prefix-list WORD", |
| 5659 | SHOW_STR |
| 5660 | IPV6_STR |
| 5661 | BGP_STR |
| 5662 | "Display routes matching the prefix-list\n" |
| 5663 | "IPv6 prefix-list name\n") |
| 5664 | { |
| 5665 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5666 | bgp_show_type_prefix_list); |
| 5667 | } |
| 5668 | |
| 5669 | /* old command */ |
| 5670 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 5671 | show_ipv6_mbgp_prefix_list_cmd, |
| 5672 | "show ipv6 mbgp prefix-list WORD", |
| 5673 | SHOW_STR |
| 5674 | IPV6_STR |
| 5675 | MBGP_STR |
| 5676 | "Display routes matching the prefix-list\n" |
| 5677 | "IPv6 prefix-list name\n") |
| 5678 | { |
| 5679 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 5680 | bgp_show_type_prefix_list); |
| 5681 | } |
| 5682 | #endif /* HAVE_IPV6 */ |
| 5683 | |
| 5684 | int |
| 5685 | bgp_show_filter_list (struct vty *vty, char *filter, afi_t afi, |
| 5686 | safi_t safi, enum bgp_show_type type) |
| 5687 | { |
| 5688 | struct as_list *as_list; |
| 5689 | |
| 5690 | as_list = as_list_lookup (filter); |
| 5691 | if (as_list == NULL) |
| 5692 | { |
| 5693 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 5694 | return CMD_WARNING; |
| 5695 | } |
| 5696 | |
| 5697 | vty->output_arg = as_list; |
| 5698 | |
| 5699 | return bgp_show (vty, NULL, afi, safi, type); |
| 5700 | } |
| 5701 | |
| 5702 | DEFUN (show_ip_bgp_filter_list, |
| 5703 | show_ip_bgp_filter_list_cmd, |
| 5704 | "show ip bgp filter-list WORD", |
| 5705 | SHOW_STR |
| 5706 | IP_STR |
| 5707 | BGP_STR |
| 5708 | "Display routes conforming to the filter-list\n" |
| 5709 | "Regular expression access list name\n") |
| 5710 | { |
| 5711 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5712 | bgp_show_type_filter_list); |
| 5713 | } |
| 5714 | |
| 5715 | DEFUN (show_ip_bgp_flap_filter_list, |
| 5716 | show_ip_bgp_flap_filter_list_cmd, |
| 5717 | "show ip bgp flap-statistics filter-list WORD", |
| 5718 | SHOW_STR |
| 5719 | IP_STR |
| 5720 | BGP_STR |
| 5721 | "Display flap statistics of routes\n" |
| 5722 | "Display routes conforming to the filter-list\n" |
| 5723 | "Regular expression access list name\n") |
| 5724 | { |
| 5725 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5726 | bgp_show_type_flap_filter_list); |
| 5727 | } |
| 5728 | |
| 5729 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 5730 | show_ip_bgp_ipv4_filter_list_cmd, |
| 5731 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 5732 | SHOW_STR |
| 5733 | IP_STR |
| 5734 | BGP_STR |
| 5735 | "Address family\n" |
| 5736 | "Address Family modifier\n" |
| 5737 | "Address Family modifier\n" |
| 5738 | "Display routes conforming to the filter-list\n" |
| 5739 | "Regular expression access list name\n") |
| 5740 | { |
| 5741 | if (strncmp (argv[0], "m", 1) == 0) |
| 5742 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 5743 | bgp_show_type_filter_list); |
| 5744 | |
| 5745 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 5746 | bgp_show_type_filter_list); |
| 5747 | } |
| 5748 | |
| 5749 | #ifdef HAVE_IPV6 |
| 5750 | DEFUN (show_bgp_filter_list, |
| 5751 | show_bgp_filter_list_cmd, |
| 5752 | "show bgp filter-list WORD", |
| 5753 | SHOW_STR |
| 5754 | BGP_STR |
| 5755 | "Display routes conforming to the filter-list\n" |
| 5756 | "Regular expression access list name\n") |
| 5757 | { |
| 5758 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5759 | bgp_show_type_filter_list); |
| 5760 | } |
| 5761 | |
| 5762 | ALIAS (show_bgp_filter_list, |
| 5763 | show_bgp_ipv6_filter_list_cmd, |
| 5764 | "show bgp ipv6 filter-list WORD", |
| 5765 | SHOW_STR |
| 5766 | BGP_STR |
| 5767 | "Address family\n" |
| 5768 | "Display routes conforming to the filter-list\n" |
| 5769 | "Regular expression access list name\n") |
| 5770 | |
| 5771 | /* old command */ |
| 5772 | DEFUN (show_ipv6_bgp_filter_list, |
| 5773 | show_ipv6_bgp_filter_list_cmd, |
| 5774 | "show ipv6 bgp filter-list WORD", |
| 5775 | SHOW_STR |
| 5776 | IPV6_STR |
| 5777 | BGP_STR |
| 5778 | "Display routes conforming to the filter-list\n" |
| 5779 | "Regular expression access list name\n") |
| 5780 | { |
| 5781 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5782 | bgp_show_type_filter_list); |
| 5783 | } |
| 5784 | |
| 5785 | /* old command */ |
| 5786 | DEFUN (show_ipv6_mbgp_filter_list, |
| 5787 | show_ipv6_mbgp_filter_list_cmd, |
| 5788 | "show ipv6 mbgp filter-list WORD", |
| 5789 | SHOW_STR |
| 5790 | IPV6_STR |
| 5791 | MBGP_STR |
| 5792 | "Display routes conforming to the filter-list\n" |
| 5793 | "Regular expression access list name\n") |
| 5794 | { |
| 5795 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 5796 | bgp_show_type_filter_list); |
| 5797 | } |
| 5798 | #endif /* HAVE_IPV6 */ |
| 5799 | |
| 5800 | int |
| 5801 | bgp_show_route_map (struct vty *vty, char *rmap_str, afi_t afi, |
| 5802 | safi_t safi, enum bgp_show_type type) |
| 5803 | { |
| 5804 | struct route_map *rmap; |
| 5805 | |
| 5806 | rmap = route_map_lookup_by_name (rmap_str); |
| 5807 | if (! rmap) |
| 5808 | { |
| 5809 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 5810 | rmap_str, VTY_NEWLINE); |
| 5811 | return CMD_WARNING; |
| 5812 | } |
| 5813 | |
| 5814 | vty->output_arg = rmap; |
| 5815 | |
| 5816 | return bgp_show (vty, NULL, afi, safi, type); |
| 5817 | } |
| 5818 | |
| 5819 | DEFUN (show_ip_bgp_route_map, |
| 5820 | show_ip_bgp_route_map_cmd, |
| 5821 | "show ip bgp route-map WORD", |
| 5822 | SHOW_STR |
| 5823 | IP_STR |
| 5824 | BGP_STR |
| 5825 | "Display routes matching the route-map\n" |
| 5826 | "A route-map to match on\n") |
| 5827 | { |
| 5828 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5829 | bgp_show_type_route_map); |
| 5830 | } |
| 5831 | |
| 5832 | DEFUN (show_ip_bgp_flap_route_map, |
| 5833 | show_ip_bgp_flap_route_map_cmd, |
| 5834 | "show ip bgp flap-statistics route-map WORD", |
| 5835 | SHOW_STR |
| 5836 | IP_STR |
| 5837 | BGP_STR |
| 5838 | "Display flap statistics of routes\n" |
| 5839 | "Display routes matching the route-map\n" |
| 5840 | "A route-map to match on\n") |
| 5841 | { |
| 5842 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5843 | bgp_show_type_flap_route_map); |
| 5844 | } |
| 5845 | |
| 5846 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 5847 | show_ip_bgp_ipv4_route_map_cmd, |
| 5848 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 5849 | SHOW_STR |
| 5850 | IP_STR |
| 5851 | BGP_STR |
| 5852 | "Address family\n" |
| 5853 | "Address Family modifier\n" |
| 5854 | "Address Family modifier\n" |
| 5855 | "Display routes matching the route-map\n" |
| 5856 | "A route-map to match on\n") |
| 5857 | { |
| 5858 | if (strncmp (argv[0], "m", 1) == 0) |
| 5859 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 5860 | bgp_show_type_route_map); |
| 5861 | |
| 5862 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 5863 | bgp_show_type_route_map); |
| 5864 | } |
| 5865 | |
| 5866 | DEFUN (show_bgp_route_map, |
| 5867 | show_bgp_route_map_cmd, |
| 5868 | "show bgp route-map WORD", |
| 5869 | SHOW_STR |
| 5870 | BGP_STR |
| 5871 | "Display routes matching the route-map\n" |
| 5872 | "A route-map to match on\n") |
| 5873 | { |
| 5874 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5875 | bgp_show_type_route_map); |
| 5876 | } |
| 5877 | |
| 5878 | ALIAS (show_bgp_route_map, |
| 5879 | show_bgp_ipv6_route_map_cmd, |
| 5880 | "show bgp ipv6 route-map WORD", |
| 5881 | SHOW_STR |
| 5882 | BGP_STR |
| 5883 | "Address family\n" |
| 5884 | "Display routes matching the route-map\n" |
| 5885 | "A route-map to match on\n") |
| 5886 | |
| 5887 | DEFUN (show_ip_bgp_cidr_only, |
| 5888 | show_ip_bgp_cidr_only_cmd, |
| 5889 | "show ip bgp cidr-only", |
| 5890 | SHOW_STR |
| 5891 | IP_STR |
| 5892 | BGP_STR |
| 5893 | "Display only routes with non-natural netmasks\n") |
| 5894 | { |
| 5895 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5896 | bgp_show_type_cidr_only); |
| 5897 | } |
| 5898 | |
| 5899 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 5900 | show_ip_bgp_flap_cidr_only_cmd, |
| 5901 | "show ip bgp flap-statistics cidr-only", |
| 5902 | SHOW_STR |
| 5903 | IP_STR |
| 5904 | BGP_STR |
| 5905 | "Display flap statistics of routes\n" |
| 5906 | "Display only routes with non-natural netmasks\n") |
| 5907 | { |
| 5908 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5909 | bgp_show_type_flap_cidr_only); |
| 5910 | } |
| 5911 | |
| 5912 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 5913 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 5914 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 5915 | SHOW_STR |
| 5916 | IP_STR |
| 5917 | BGP_STR |
| 5918 | "Address family\n" |
| 5919 | "Address Family modifier\n" |
| 5920 | "Address Family modifier\n" |
| 5921 | "Display only routes with non-natural netmasks\n") |
| 5922 | { |
| 5923 | if (strncmp (argv[0], "m", 1) == 0) |
| 5924 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 5925 | bgp_show_type_cidr_only); |
| 5926 | |
| 5927 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5928 | bgp_show_type_cidr_only); |
| 5929 | } |
| 5930 | |
| 5931 | DEFUN (show_ip_bgp_community_all, |
| 5932 | show_ip_bgp_community_all_cmd, |
| 5933 | "show ip bgp community", |
| 5934 | SHOW_STR |
| 5935 | IP_STR |
| 5936 | BGP_STR |
| 5937 | "Display routes matching the communities\n") |
| 5938 | { |
| 5939 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5940 | bgp_show_type_community_all); |
| 5941 | } |
| 5942 | |
| 5943 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 5944 | show_ip_bgp_ipv4_community_all_cmd, |
| 5945 | "show ip bgp ipv4 (unicast|multicast) community", |
| 5946 | SHOW_STR |
| 5947 | IP_STR |
| 5948 | BGP_STR |
| 5949 | "Address family\n" |
| 5950 | "Address Family modifier\n" |
| 5951 | "Address Family modifier\n" |
| 5952 | "Display routes matching the communities\n") |
| 5953 | { |
| 5954 | if (strncmp (argv[0], "m", 1) == 0) |
| 5955 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 5956 | bgp_show_type_community_all); |
| 5957 | |
| 5958 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5959 | bgp_show_type_community_all); |
| 5960 | } |
| 5961 | |
| 5962 | #ifdef HAVE_IPV6 |
| 5963 | DEFUN (show_bgp_community_all, |
| 5964 | show_bgp_community_all_cmd, |
| 5965 | "show bgp community", |
| 5966 | SHOW_STR |
| 5967 | BGP_STR |
| 5968 | "Display routes matching the communities\n") |
| 5969 | { |
| 5970 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 5971 | bgp_show_type_community_all); |
| 5972 | } |
| 5973 | |
| 5974 | ALIAS (show_bgp_community_all, |
| 5975 | show_bgp_ipv6_community_all_cmd, |
| 5976 | "show bgp ipv6 community", |
| 5977 | SHOW_STR |
| 5978 | BGP_STR |
| 5979 | "Address family\n" |
| 5980 | "Display routes matching the communities\n") |
| 5981 | |
| 5982 | /* old command */ |
| 5983 | DEFUN (show_ipv6_bgp_community_all, |
| 5984 | show_ipv6_bgp_community_all_cmd, |
| 5985 | "show ipv6 bgp community", |
| 5986 | SHOW_STR |
| 5987 | IPV6_STR |
| 5988 | BGP_STR |
| 5989 | "Display routes matching the communities\n") |
| 5990 | { |
| 5991 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 5992 | bgp_show_type_community_all); |
| 5993 | } |
| 5994 | |
| 5995 | /* old command */ |
| 5996 | DEFUN (show_ipv6_mbgp_community_all, |
| 5997 | show_ipv6_mbgp_community_all_cmd, |
| 5998 | "show ipv6 mbgp community", |
| 5999 | SHOW_STR |
| 6000 | IPV6_STR |
| 6001 | MBGP_STR |
| 6002 | "Display routes matching the communities\n") |
| 6003 | { |
| 6004 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
| 6005 | bgp_show_type_community_all); |
| 6006 | } |
| 6007 | #endif /* HAVE_IPV6 */ |
| 6008 | |
| 6009 | int |
| 6010 | bgp_show_community (struct vty *vty, int argc, char **argv, int exact, |
| 6011 | u_int16_t afi, u_char safi) |
| 6012 | { |
| 6013 | struct community *com; |
| 6014 | struct buffer *b; |
| 6015 | int i; |
| 6016 | char *str; |
| 6017 | int first = 0; |
| 6018 | |
| 6019 | b = buffer_new (1024); |
| 6020 | for (i = 0; i < argc; i++) |
| 6021 | { |
| 6022 | if (first) |
| 6023 | buffer_putc (b, ' '); |
| 6024 | else |
| 6025 | { |
| 6026 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6027 | continue; |
| 6028 | first = 1; |
| 6029 | } |
| 6030 | |
| 6031 | buffer_putstr (b, argv[i]); |
| 6032 | } |
| 6033 | buffer_putc (b, '\0'); |
| 6034 | |
| 6035 | str = buffer_getstr (b); |
| 6036 | buffer_free (b); |
| 6037 | |
| 6038 | com = community_str2com (str); |
| 6039 | free (str); |
| 6040 | if (! com) |
| 6041 | { |
| 6042 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 6043 | return CMD_WARNING; |
| 6044 | } |
| 6045 | |
| 6046 | vty->output_arg = com; |
| 6047 | |
| 6048 | if (exact) |
| 6049 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_exact); |
| 6050 | |
| 6051 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community); |
| 6052 | } |
| 6053 | |
| 6054 | DEFUN (show_ip_bgp_community, |
| 6055 | show_ip_bgp_community_cmd, |
| 6056 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6057 | SHOW_STR |
| 6058 | IP_STR |
| 6059 | BGP_STR |
| 6060 | "Display routes matching the communities\n" |
| 6061 | "community number\n" |
| 6062 | "Do not send outside local AS (well-known community)\n" |
| 6063 | "Do not advertise to any peer (well-known community)\n" |
| 6064 | "Do not export to next AS (well-known community)\n") |
| 6065 | { |
| 6066 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6067 | } |
| 6068 | |
| 6069 | ALIAS (show_ip_bgp_community, |
| 6070 | show_ip_bgp_community2_cmd, |
| 6071 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6072 | SHOW_STR |
| 6073 | IP_STR |
| 6074 | BGP_STR |
| 6075 | "Display routes matching the communities\n" |
| 6076 | "community number\n" |
| 6077 | "Do not send outside local AS (well-known community)\n" |
| 6078 | "Do not advertise to any peer (well-known community)\n" |
| 6079 | "Do not export to next AS (well-known community)\n" |
| 6080 | "community number\n" |
| 6081 | "Do not send outside local AS (well-known community)\n" |
| 6082 | "Do not advertise to any peer (well-known community)\n" |
| 6083 | "Do not export to next AS (well-known community)\n") |
| 6084 | |
| 6085 | ALIAS (show_ip_bgp_community, |
| 6086 | show_ip_bgp_community3_cmd, |
| 6087 | "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)", |
| 6088 | SHOW_STR |
| 6089 | IP_STR |
| 6090 | BGP_STR |
| 6091 | "Display routes matching the communities\n" |
| 6092 | "community number\n" |
| 6093 | "Do not send outside local AS (well-known community)\n" |
| 6094 | "Do not advertise to any peer (well-known community)\n" |
| 6095 | "Do not export to next AS (well-known community)\n" |
| 6096 | "community number\n" |
| 6097 | "Do not send outside local AS (well-known community)\n" |
| 6098 | "Do not advertise to any peer (well-known community)\n" |
| 6099 | "Do not export to next AS (well-known community)\n" |
| 6100 | "community number\n" |
| 6101 | "Do not send outside local AS (well-known community)\n" |
| 6102 | "Do not advertise to any peer (well-known community)\n" |
| 6103 | "Do not export to next AS (well-known community)\n") |
| 6104 | |
| 6105 | ALIAS (show_ip_bgp_community, |
| 6106 | show_ip_bgp_community4_cmd, |
| 6107 | "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)", |
| 6108 | SHOW_STR |
| 6109 | IP_STR |
| 6110 | BGP_STR |
| 6111 | "Display routes matching the communities\n" |
| 6112 | "community number\n" |
| 6113 | "Do not send outside local AS (well-known community)\n" |
| 6114 | "Do not advertise to any peer (well-known community)\n" |
| 6115 | "Do not export to next AS (well-known community)\n" |
| 6116 | "community number\n" |
| 6117 | "Do not send outside local AS (well-known community)\n" |
| 6118 | "Do not advertise to any peer (well-known community)\n" |
| 6119 | "Do not export to next AS (well-known community)\n" |
| 6120 | "community number\n" |
| 6121 | "Do not send outside local AS (well-known community)\n" |
| 6122 | "Do not advertise to any peer (well-known community)\n" |
| 6123 | "Do not export to next AS (well-known community)\n" |
| 6124 | "community number\n" |
| 6125 | "Do not send outside local AS (well-known community)\n" |
| 6126 | "Do not advertise to any peer (well-known community)\n" |
| 6127 | "Do not export to next AS (well-known community)\n") |
| 6128 | |
| 6129 | DEFUN (show_ip_bgp_ipv4_community, |
| 6130 | show_ip_bgp_ipv4_community_cmd, |
| 6131 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 6132 | SHOW_STR |
| 6133 | IP_STR |
| 6134 | BGP_STR |
| 6135 | "Address family\n" |
| 6136 | "Address Family modifier\n" |
| 6137 | "Address Family modifier\n" |
| 6138 | "Display routes matching the communities\n" |
| 6139 | "community number\n" |
| 6140 | "Do not send outside local AS (well-known community)\n" |
| 6141 | "Do not advertise to any peer (well-known community)\n" |
| 6142 | "Do not export to next AS (well-known community)\n") |
| 6143 | { |
| 6144 | if (strncmp (argv[0], "m", 1) == 0) |
| 6145 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 6146 | |
| 6147 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6148 | } |
| 6149 | |
| 6150 | ALIAS (show_ip_bgp_ipv4_community, |
| 6151 | show_ip_bgp_ipv4_community2_cmd, |
| 6152 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6153 | SHOW_STR |
| 6154 | IP_STR |
| 6155 | BGP_STR |
| 6156 | "Address family\n" |
| 6157 | "Address Family modifier\n" |
| 6158 | "Address Family modifier\n" |
| 6159 | "Display routes matching the communities\n" |
| 6160 | "community number\n" |
| 6161 | "Do not send outside local AS (well-known community)\n" |
| 6162 | "Do not advertise to any peer (well-known community)\n" |
| 6163 | "Do not export to next AS (well-known community)\n" |
| 6164 | "community number\n" |
| 6165 | "Do not send outside local AS (well-known community)\n" |
| 6166 | "Do not advertise to any peer (well-known community)\n" |
| 6167 | "Do not export to next AS (well-known community)\n") |
| 6168 | |
| 6169 | ALIAS (show_ip_bgp_ipv4_community, |
| 6170 | show_ip_bgp_ipv4_community3_cmd, |
| 6171 | "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)", |
| 6172 | SHOW_STR |
| 6173 | IP_STR |
| 6174 | BGP_STR |
| 6175 | "Address family\n" |
| 6176 | "Address Family modifier\n" |
| 6177 | "Address Family modifier\n" |
| 6178 | "Display routes matching the communities\n" |
| 6179 | "community number\n" |
| 6180 | "Do not send outside local AS (well-known community)\n" |
| 6181 | "Do not advertise to any peer (well-known community)\n" |
| 6182 | "Do not export to next AS (well-known community)\n" |
| 6183 | "community number\n" |
| 6184 | "Do not send outside local AS (well-known community)\n" |
| 6185 | "Do not advertise to any peer (well-known community)\n" |
| 6186 | "Do not export to next AS (well-known community)\n" |
| 6187 | "community number\n" |
| 6188 | "Do not send outside local AS (well-known community)\n" |
| 6189 | "Do not advertise to any peer (well-known community)\n" |
| 6190 | "Do not export to next AS (well-known community)\n") |
| 6191 | |
| 6192 | ALIAS (show_ip_bgp_ipv4_community, |
| 6193 | show_ip_bgp_ipv4_community4_cmd, |
| 6194 | "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)", |
| 6195 | SHOW_STR |
| 6196 | IP_STR |
| 6197 | BGP_STR |
| 6198 | "Address family\n" |
| 6199 | "Address Family modifier\n" |
| 6200 | "Address Family modifier\n" |
| 6201 | "Display routes matching the communities\n" |
| 6202 | "community number\n" |
| 6203 | "Do not send outside local AS (well-known community)\n" |
| 6204 | "Do not advertise to any peer (well-known community)\n" |
| 6205 | "Do not export to next AS (well-known community)\n" |
| 6206 | "community number\n" |
| 6207 | "Do not send outside local AS (well-known community)\n" |
| 6208 | "Do not advertise to any peer (well-known community)\n" |
| 6209 | "Do not export to next AS (well-known community)\n" |
| 6210 | "community number\n" |
| 6211 | "Do not send outside local AS (well-known community)\n" |
| 6212 | "Do not advertise to any peer (well-known community)\n" |
| 6213 | "Do not export to next AS (well-known community)\n" |
| 6214 | "community number\n" |
| 6215 | "Do not send outside local AS (well-known community)\n" |
| 6216 | "Do not advertise to any peer (well-known community)\n" |
| 6217 | "Do not export to next AS (well-known community)\n") |
| 6218 | |
| 6219 | DEFUN (show_ip_bgp_community_exact, |
| 6220 | show_ip_bgp_community_exact_cmd, |
| 6221 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6222 | SHOW_STR |
| 6223 | IP_STR |
| 6224 | BGP_STR |
| 6225 | "Display routes matching the communities\n" |
| 6226 | "community number\n" |
| 6227 | "Do not send outside local AS (well-known community)\n" |
| 6228 | "Do not advertise to any peer (well-known community)\n" |
| 6229 | "Do not export to next AS (well-known community)\n" |
| 6230 | "Exact match of the communities") |
| 6231 | { |
| 6232 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 6233 | } |
| 6234 | |
| 6235 | ALIAS (show_ip_bgp_community_exact, |
| 6236 | show_ip_bgp_community2_exact_cmd, |
| 6237 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6238 | SHOW_STR |
| 6239 | IP_STR |
| 6240 | BGP_STR |
| 6241 | "Display routes matching the communities\n" |
| 6242 | "community number\n" |
| 6243 | "Do not send outside local AS (well-known community)\n" |
| 6244 | "Do not advertise to any peer (well-known community)\n" |
| 6245 | "Do not export to next AS (well-known community)\n" |
| 6246 | "community number\n" |
| 6247 | "Do not send outside local AS (well-known community)\n" |
| 6248 | "Do not advertise to any peer (well-known community)\n" |
| 6249 | "Do not export to next AS (well-known community)\n" |
| 6250 | "Exact match of the communities") |
| 6251 | |
| 6252 | ALIAS (show_ip_bgp_community_exact, |
| 6253 | show_ip_bgp_community3_exact_cmd, |
| 6254 | "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", |
| 6255 | SHOW_STR |
| 6256 | IP_STR |
| 6257 | BGP_STR |
| 6258 | "Display routes matching the communities\n" |
| 6259 | "community number\n" |
| 6260 | "Do not send outside local AS (well-known community)\n" |
| 6261 | "Do not advertise to any peer (well-known community)\n" |
| 6262 | "Do not export to next AS (well-known community)\n" |
| 6263 | "community number\n" |
| 6264 | "Do not send outside local AS (well-known community)\n" |
| 6265 | "Do not advertise to any peer (well-known community)\n" |
| 6266 | "Do not export to next AS (well-known community)\n" |
| 6267 | "community number\n" |
| 6268 | "Do not send outside local AS (well-known community)\n" |
| 6269 | "Do not advertise to any peer (well-known community)\n" |
| 6270 | "Do not export to next AS (well-known community)\n" |
| 6271 | "Exact match of the communities") |
| 6272 | |
| 6273 | ALIAS (show_ip_bgp_community_exact, |
| 6274 | show_ip_bgp_community4_exact_cmd, |
| 6275 | "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", |
| 6276 | SHOW_STR |
| 6277 | IP_STR |
| 6278 | BGP_STR |
| 6279 | "Display routes matching the communities\n" |
| 6280 | "community number\n" |
| 6281 | "Do not send outside local AS (well-known community)\n" |
| 6282 | "Do not advertise to any peer (well-known community)\n" |
| 6283 | "Do not export to next AS (well-known community)\n" |
| 6284 | "community number\n" |
| 6285 | "Do not send outside local AS (well-known community)\n" |
| 6286 | "Do not advertise to any peer (well-known community)\n" |
| 6287 | "Do not export to next AS (well-known community)\n" |
| 6288 | "community number\n" |
| 6289 | "Do not send outside local AS (well-known community)\n" |
| 6290 | "Do not advertise to any peer (well-known community)\n" |
| 6291 | "Do not export to next AS (well-known community)\n" |
| 6292 | "community number\n" |
| 6293 | "Do not send outside local AS (well-known community)\n" |
| 6294 | "Do not advertise to any peer (well-known community)\n" |
| 6295 | "Do not export to next AS (well-known community)\n" |
| 6296 | "Exact match of the communities") |
| 6297 | |
| 6298 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 6299 | show_ip_bgp_ipv4_community_exact_cmd, |
| 6300 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6301 | SHOW_STR |
| 6302 | IP_STR |
| 6303 | BGP_STR |
| 6304 | "Address family\n" |
| 6305 | "Address Family modifier\n" |
| 6306 | "Address Family modifier\n" |
| 6307 | "Display routes matching the communities\n" |
| 6308 | "community number\n" |
| 6309 | "Do not send outside local AS (well-known community)\n" |
| 6310 | "Do not advertise to any peer (well-known community)\n" |
| 6311 | "Do not export to next AS (well-known community)\n" |
| 6312 | "Exact match of the communities") |
| 6313 | { |
| 6314 | if (strncmp (argv[0], "m", 1) == 0) |
| 6315 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 6316 | |
| 6317 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 6318 | } |
| 6319 | |
| 6320 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 6321 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 6322 | "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", |
| 6323 | SHOW_STR |
| 6324 | IP_STR |
| 6325 | BGP_STR |
| 6326 | "Address family\n" |
| 6327 | "Address Family modifier\n" |
| 6328 | "Address Family modifier\n" |
| 6329 | "Display routes matching the communities\n" |
| 6330 | "community number\n" |
| 6331 | "Do not send outside local AS (well-known community)\n" |
| 6332 | "Do not advertise to any peer (well-known community)\n" |
| 6333 | "Do not export to next AS (well-known community)\n" |
| 6334 | "community number\n" |
| 6335 | "Do not send outside local AS (well-known community)\n" |
| 6336 | "Do not advertise to any peer (well-known community)\n" |
| 6337 | "Do not export to next AS (well-known community)\n" |
| 6338 | "Exact match of the communities") |
| 6339 | |
| 6340 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 6341 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 6342 | "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", |
| 6343 | SHOW_STR |
| 6344 | IP_STR |
| 6345 | BGP_STR |
| 6346 | "Address family\n" |
| 6347 | "Address Family modifier\n" |
| 6348 | "Address Family modifier\n" |
| 6349 | "Display routes matching the communities\n" |
| 6350 | "community number\n" |
| 6351 | "Do not send outside local AS (well-known community)\n" |
| 6352 | "Do not advertise to any peer (well-known community)\n" |
| 6353 | "Do not export to next AS (well-known community)\n" |
| 6354 | "community number\n" |
| 6355 | "Do not send outside local AS (well-known community)\n" |
| 6356 | "Do not advertise to any peer (well-known community)\n" |
| 6357 | "Do not export to next AS (well-known community)\n" |
| 6358 | "community number\n" |
| 6359 | "Do not send outside local AS (well-known community)\n" |
| 6360 | "Do not advertise to any peer (well-known community)\n" |
| 6361 | "Do not export to next AS (well-known community)\n" |
| 6362 | "Exact match of the communities") |
| 6363 | |
| 6364 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 6365 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 6366 | "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", |
| 6367 | SHOW_STR |
| 6368 | IP_STR |
| 6369 | BGP_STR |
| 6370 | "Address family\n" |
| 6371 | "Address Family modifier\n" |
| 6372 | "Address Family modifier\n" |
| 6373 | "Display routes matching the communities\n" |
| 6374 | "community number\n" |
| 6375 | "Do not send outside local AS (well-known community)\n" |
| 6376 | "Do not advertise to any peer (well-known community)\n" |
| 6377 | "Do not export to next AS (well-known community)\n" |
| 6378 | "community number\n" |
| 6379 | "Do not send outside local AS (well-known community)\n" |
| 6380 | "Do not advertise to any peer (well-known community)\n" |
| 6381 | "Do not export to next AS (well-known community)\n" |
| 6382 | "community number\n" |
| 6383 | "Do not send outside local AS (well-known community)\n" |
| 6384 | "Do not advertise to any peer (well-known community)\n" |
| 6385 | "Do not export to next AS (well-known community)\n" |
| 6386 | "community number\n" |
| 6387 | "Do not send outside local AS (well-known community)\n" |
| 6388 | "Do not advertise to any peer (well-known community)\n" |
| 6389 | "Do not export to next AS (well-known community)\n" |
| 6390 | "Exact match of the communities") |
| 6391 | |
| 6392 | #ifdef HAVE_IPV6 |
| 6393 | DEFUN (show_bgp_community, |
| 6394 | show_bgp_community_cmd, |
| 6395 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6396 | SHOW_STR |
| 6397 | BGP_STR |
| 6398 | "Display routes matching the communities\n" |
| 6399 | "community number\n" |
| 6400 | "Do not send outside local AS (well-known community)\n" |
| 6401 | "Do not advertise to any peer (well-known community)\n" |
| 6402 | "Do not export to next AS (well-known community)\n") |
| 6403 | { |
| 6404 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 6405 | } |
| 6406 | |
| 6407 | ALIAS (show_bgp_community, |
| 6408 | show_bgp_ipv6_community_cmd, |
| 6409 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 6410 | SHOW_STR |
| 6411 | BGP_STR |
| 6412 | "Address family\n" |
| 6413 | "Display routes matching the communities\n" |
| 6414 | "community number\n" |
| 6415 | "Do not send outside local AS (well-known community)\n" |
| 6416 | "Do not advertise to any peer (well-known community)\n" |
| 6417 | "Do not export to next AS (well-known community)\n") |
| 6418 | |
| 6419 | ALIAS (show_bgp_community, |
| 6420 | show_bgp_community2_cmd, |
| 6421 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6422 | SHOW_STR |
| 6423 | BGP_STR |
| 6424 | "Display routes matching the communities\n" |
| 6425 | "community number\n" |
| 6426 | "Do not send outside local AS (well-known community)\n" |
| 6427 | "Do not advertise to any peer (well-known community)\n" |
| 6428 | "Do not export to next AS (well-known community)\n" |
| 6429 | "community number\n" |
| 6430 | "Do not send outside local AS (well-known community)\n" |
| 6431 | "Do not advertise to any peer (well-known community)\n" |
| 6432 | "Do not export to next AS (well-known community)\n") |
| 6433 | |
| 6434 | ALIAS (show_bgp_community, |
| 6435 | show_bgp_ipv6_community2_cmd, |
| 6436 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6437 | SHOW_STR |
| 6438 | BGP_STR |
| 6439 | "Address family\n" |
| 6440 | "Display routes matching the communities\n" |
| 6441 | "community number\n" |
| 6442 | "Do not send outside local AS (well-known community)\n" |
| 6443 | "Do not advertise to any peer (well-known community)\n" |
| 6444 | "Do not export to next AS (well-known community)\n" |
| 6445 | "community number\n" |
| 6446 | "Do not send outside local AS (well-known community)\n" |
| 6447 | "Do not advertise to any peer (well-known community)\n" |
| 6448 | "Do not export to next AS (well-known community)\n") |
| 6449 | |
| 6450 | ALIAS (show_bgp_community, |
| 6451 | show_bgp_community3_cmd, |
| 6452 | "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)", |
| 6453 | SHOW_STR |
| 6454 | BGP_STR |
| 6455 | "Display routes matching the communities\n" |
| 6456 | "community number\n" |
| 6457 | "Do not send outside local AS (well-known community)\n" |
| 6458 | "Do not advertise to any peer (well-known community)\n" |
| 6459 | "Do not export to next AS (well-known community)\n" |
| 6460 | "community number\n" |
| 6461 | "Do not send outside local AS (well-known community)\n" |
| 6462 | "Do not advertise to any peer (well-known community)\n" |
| 6463 | "Do not export to next AS (well-known community)\n" |
| 6464 | "community number\n" |
| 6465 | "Do not send outside local AS (well-known community)\n" |
| 6466 | "Do not advertise to any peer (well-known community)\n" |
| 6467 | "Do not export to next AS (well-known community)\n") |
| 6468 | |
| 6469 | ALIAS (show_bgp_community, |
| 6470 | show_bgp_ipv6_community3_cmd, |
| 6471 | "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)", |
| 6472 | SHOW_STR |
| 6473 | BGP_STR |
| 6474 | "Address family\n" |
| 6475 | "Display routes matching the communities\n" |
| 6476 | "community number\n" |
| 6477 | "Do not send outside local AS (well-known community)\n" |
| 6478 | "Do not advertise to any peer (well-known community)\n" |
| 6479 | "Do not export to next AS (well-known community)\n" |
| 6480 | "community number\n" |
| 6481 | "Do not send outside local AS (well-known community)\n" |
| 6482 | "Do not advertise to any peer (well-known community)\n" |
| 6483 | "Do not export to next AS (well-known community)\n" |
| 6484 | "community number\n" |
| 6485 | "Do not send outside local AS (well-known community)\n" |
| 6486 | "Do not advertise to any peer (well-known community)\n" |
| 6487 | "Do not export to next AS (well-known community)\n") |
| 6488 | |
| 6489 | ALIAS (show_bgp_community, |
| 6490 | show_bgp_community4_cmd, |
| 6491 | "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)", |
| 6492 | SHOW_STR |
| 6493 | BGP_STR |
| 6494 | "Display routes matching the communities\n" |
| 6495 | "community number\n" |
| 6496 | "Do not send outside local AS (well-known community)\n" |
| 6497 | "Do not advertise to any peer (well-known community)\n" |
| 6498 | "Do not export to next AS (well-known community)\n" |
| 6499 | "community number\n" |
| 6500 | "Do not send outside local AS (well-known community)\n" |
| 6501 | "Do not advertise to any peer (well-known community)\n" |
| 6502 | "Do not export to next AS (well-known community)\n" |
| 6503 | "community number\n" |
| 6504 | "Do not send outside local AS (well-known community)\n" |
| 6505 | "Do not advertise to any peer (well-known community)\n" |
| 6506 | "Do not export to next AS (well-known community)\n" |
| 6507 | "community number\n" |
| 6508 | "Do not send outside local AS (well-known community)\n" |
| 6509 | "Do not advertise to any peer (well-known community)\n" |
| 6510 | "Do not export to next AS (well-known community)\n") |
| 6511 | |
| 6512 | ALIAS (show_bgp_community, |
| 6513 | show_bgp_ipv6_community4_cmd, |
| 6514 | "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)", |
| 6515 | SHOW_STR |
| 6516 | BGP_STR |
| 6517 | "Address family\n" |
| 6518 | "Display routes matching the communities\n" |
| 6519 | "community number\n" |
| 6520 | "Do not send outside local AS (well-known community)\n" |
| 6521 | "Do not advertise to any peer (well-known community)\n" |
| 6522 | "Do not export to next AS (well-known community)\n" |
| 6523 | "community number\n" |
| 6524 | "Do not send outside local AS (well-known community)\n" |
| 6525 | "Do not advertise to any peer (well-known community)\n" |
| 6526 | "Do not export to next AS (well-known community)\n" |
| 6527 | "community number\n" |
| 6528 | "Do not send outside local AS (well-known community)\n" |
| 6529 | "Do not advertise to any peer (well-known community)\n" |
| 6530 | "Do not export to next AS (well-known community)\n" |
| 6531 | "community number\n" |
| 6532 | "Do not send outside local AS (well-known community)\n" |
| 6533 | "Do not advertise to any peer (well-known community)\n" |
| 6534 | "Do not export to next AS (well-known community)\n") |
| 6535 | |
| 6536 | /* old command */ |
| 6537 | DEFUN (show_ipv6_bgp_community, |
| 6538 | show_ipv6_bgp_community_cmd, |
| 6539 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6540 | SHOW_STR |
| 6541 | IPV6_STR |
| 6542 | BGP_STR |
| 6543 | "Display routes matching the communities\n" |
| 6544 | "community number\n" |
| 6545 | "Do not send outside local AS (well-known community)\n" |
| 6546 | "Do not advertise to any peer (well-known community)\n" |
| 6547 | "Do not export to next AS (well-known community)\n") |
| 6548 | { |
| 6549 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 6550 | } |
| 6551 | |
| 6552 | /* old command */ |
| 6553 | ALIAS (show_ipv6_bgp_community, |
| 6554 | show_ipv6_bgp_community2_cmd, |
| 6555 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6556 | SHOW_STR |
| 6557 | IPV6_STR |
| 6558 | BGP_STR |
| 6559 | "Display routes matching the communities\n" |
| 6560 | "community number\n" |
| 6561 | "Do not send outside local AS (well-known community)\n" |
| 6562 | "Do not advertise to any peer (well-known community)\n" |
| 6563 | "Do not export to next AS (well-known community)\n" |
| 6564 | "community number\n" |
| 6565 | "Do not send outside local AS (well-known community)\n" |
| 6566 | "Do not advertise to any peer (well-known community)\n" |
| 6567 | "Do not export to next AS (well-known community)\n") |
| 6568 | |
| 6569 | /* old command */ |
| 6570 | ALIAS (show_ipv6_bgp_community, |
| 6571 | show_ipv6_bgp_community3_cmd, |
| 6572 | "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)", |
| 6573 | SHOW_STR |
| 6574 | IPV6_STR |
| 6575 | BGP_STR |
| 6576 | "Display routes matching the communities\n" |
| 6577 | "community number\n" |
| 6578 | "Do not send outside local AS (well-known community)\n" |
| 6579 | "Do not advertise to any peer (well-known community)\n" |
| 6580 | "Do not export to next AS (well-known community)\n" |
| 6581 | "community number\n" |
| 6582 | "Do not send outside local AS (well-known community)\n" |
| 6583 | "Do not advertise to any peer (well-known community)\n" |
| 6584 | "Do not export to next AS (well-known community)\n" |
| 6585 | "community number\n" |
| 6586 | "Do not send outside local AS (well-known community)\n" |
| 6587 | "Do not advertise to any peer (well-known community)\n" |
| 6588 | "Do not export to next AS (well-known community)\n") |
| 6589 | |
| 6590 | /* old command */ |
| 6591 | ALIAS (show_ipv6_bgp_community, |
| 6592 | show_ipv6_bgp_community4_cmd, |
| 6593 | "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)", |
| 6594 | SHOW_STR |
| 6595 | IPV6_STR |
| 6596 | BGP_STR |
| 6597 | "Display routes matching the communities\n" |
| 6598 | "community number\n" |
| 6599 | "Do not send outside local AS (well-known community)\n" |
| 6600 | "Do not advertise to any peer (well-known community)\n" |
| 6601 | "Do not export to next AS (well-known community)\n" |
| 6602 | "community number\n" |
| 6603 | "Do not send outside local AS (well-known community)\n" |
| 6604 | "Do not advertise to any peer (well-known community)\n" |
| 6605 | "Do not export to next AS (well-known community)\n" |
| 6606 | "community number\n" |
| 6607 | "Do not send outside local AS (well-known community)\n" |
| 6608 | "Do not advertise to any peer (well-known community)\n" |
| 6609 | "Do not export to next AS (well-known community)\n" |
| 6610 | "community number\n" |
| 6611 | "Do not send outside local AS (well-known community)\n" |
| 6612 | "Do not advertise to any peer (well-known community)\n" |
| 6613 | "Do not export to next AS (well-known community)\n") |
| 6614 | |
| 6615 | DEFUN (show_bgp_community_exact, |
| 6616 | show_bgp_community_exact_cmd, |
| 6617 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6618 | SHOW_STR |
| 6619 | BGP_STR |
| 6620 | "Display routes matching the communities\n" |
| 6621 | "community number\n" |
| 6622 | "Do not send outside local AS (well-known community)\n" |
| 6623 | "Do not advertise to any peer (well-known community)\n" |
| 6624 | "Do not export to next AS (well-known community)\n" |
| 6625 | "Exact match of the communities") |
| 6626 | { |
| 6627 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 6628 | } |
| 6629 | |
| 6630 | ALIAS (show_bgp_community_exact, |
| 6631 | show_bgp_ipv6_community_exact_cmd, |
| 6632 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6633 | SHOW_STR |
| 6634 | BGP_STR |
| 6635 | "Address family\n" |
| 6636 | "Display routes matching the communities\n" |
| 6637 | "community number\n" |
| 6638 | "Do not send outside local AS (well-known community)\n" |
| 6639 | "Do not advertise to any peer (well-known community)\n" |
| 6640 | "Do not export to next AS (well-known community)\n" |
| 6641 | "Exact match of the communities") |
| 6642 | |
| 6643 | ALIAS (show_bgp_community_exact, |
| 6644 | show_bgp_community2_exact_cmd, |
| 6645 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6646 | SHOW_STR |
| 6647 | BGP_STR |
| 6648 | "Display routes matching the communities\n" |
| 6649 | "community number\n" |
| 6650 | "Do not send outside local AS (well-known community)\n" |
| 6651 | "Do not advertise to any peer (well-known community)\n" |
| 6652 | "Do not export to next AS (well-known community)\n" |
| 6653 | "community number\n" |
| 6654 | "Do not send outside local AS (well-known community)\n" |
| 6655 | "Do not advertise to any peer (well-known community)\n" |
| 6656 | "Do not export to next AS (well-known community)\n" |
| 6657 | "Exact match of the communities") |
| 6658 | |
| 6659 | ALIAS (show_bgp_community_exact, |
| 6660 | show_bgp_ipv6_community2_exact_cmd, |
| 6661 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6662 | SHOW_STR |
| 6663 | BGP_STR |
| 6664 | "Address family\n" |
| 6665 | "Display routes matching the communities\n" |
| 6666 | "community number\n" |
| 6667 | "Do not send outside local AS (well-known community)\n" |
| 6668 | "Do not advertise to any peer (well-known community)\n" |
| 6669 | "Do not export to next AS (well-known community)\n" |
| 6670 | "community number\n" |
| 6671 | "Do not send outside local AS (well-known community)\n" |
| 6672 | "Do not advertise to any peer (well-known community)\n" |
| 6673 | "Do not export to next AS (well-known community)\n" |
| 6674 | "Exact match of the communities") |
| 6675 | |
| 6676 | ALIAS (show_bgp_community_exact, |
| 6677 | show_bgp_community3_exact_cmd, |
| 6678 | "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", |
| 6679 | SHOW_STR |
| 6680 | BGP_STR |
| 6681 | "Display routes matching the communities\n" |
| 6682 | "community number\n" |
| 6683 | "Do not send outside local AS (well-known community)\n" |
| 6684 | "Do not advertise to any peer (well-known community)\n" |
| 6685 | "Do not export to next AS (well-known community)\n" |
| 6686 | "community number\n" |
| 6687 | "Do not send outside local AS (well-known community)\n" |
| 6688 | "Do not advertise to any peer (well-known community)\n" |
| 6689 | "Do not export to next AS (well-known community)\n" |
| 6690 | "community number\n" |
| 6691 | "Do not send outside local AS (well-known community)\n" |
| 6692 | "Do not advertise to any peer (well-known community)\n" |
| 6693 | "Do not export to next AS (well-known community)\n" |
| 6694 | "Exact match of the communities") |
| 6695 | |
| 6696 | ALIAS (show_bgp_community_exact, |
| 6697 | show_bgp_ipv6_community3_exact_cmd, |
| 6698 | "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", |
| 6699 | SHOW_STR |
| 6700 | BGP_STR |
| 6701 | "Address family\n" |
| 6702 | "Display routes matching the communities\n" |
| 6703 | "community number\n" |
| 6704 | "Do not send outside local AS (well-known community)\n" |
| 6705 | "Do not advertise to any peer (well-known community)\n" |
| 6706 | "Do not export to next AS (well-known community)\n" |
| 6707 | "community number\n" |
| 6708 | "Do not send outside local AS (well-known community)\n" |
| 6709 | "Do not advertise to any peer (well-known community)\n" |
| 6710 | "Do not export to next AS (well-known community)\n" |
| 6711 | "community number\n" |
| 6712 | "Do not send outside local AS (well-known community)\n" |
| 6713 | "Do not advertise to any peer (well-known community)\n" |
| 6714 | "Do not export to next AS (well-known community)\n" |
| 6715 | "Exact match of the communities") |
| 6716 | |
| 6717 | ALIAS (show_bgp_community_exact, |
| 6718 | show_bgp_community4_exact_cmd, |
| 6719 | "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", |
| 6720 | SHOW_STR |
| 6721 | BGP_STR |
| 6722 | "Display routes matching the communities\n" |
| 6723 | "community number\n" |
| 6724 | "Do not send outside local AS (well-known community)\n" |
| 6725 | "Do not advertise to any peer (well-known community)\n" |
| 6726 | "Do not export to next AS (well-known community)\n" |
| 6727 | "community number\n" |
| 6728 | "Do not send outside local AS (well-known community)\n" |
| 6729 | "Do not advertise to any peer (well-known community)\n" |
| 6730 | "Do not export to next AS (well-known community)\n" |
| 6731 | "community number\n" |
| 6732 | "Do not send outside local AS (well-known community)\n" |
| 6733 | "Do not advertise to any peer (well-known community)\n" |
| 6734 | "Do not export to next AS (well-known community)\n" |
| 6735 | "community number\n" |
| 6736 | "Do not send outside local AS (well-known community)\n" |
| 6737 | "Do not advertise to any peer (well-known community)\n" |
| 6738 | "Do not export to next AS (well-known community)\n" |
| 6739 | "Exact match of the communities") |
| 6740 | |
| 6741 | ALIAS (show_bgp_community_exact, |
| 6742 | show_bgp_ipv6_community4_exact_cmd, |
| 6743 | "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", |
| 6744 | SHOW_STR |
| 6745 | BGP_STR |
| 6746 | "Address family\n" |
| 6747 | "Display routes matching the communities\n" |
| 6748 | "community number\n" |
| 6749 | "Do not send outside local AS (well-known community)\n" |
| 6750 | "Do not advertise to any peer (well-known community)\n" |
| 6751 | "Do not export to next AS (well-known community)\n" |
| 6752 | "community number\n" |
| 6753 | "Do not send outside local AS (well-known community)\n" |
| 6754 | "Do not advertise to any peer (well-known community)\n" |
| 6755 | "Do not export to next AS (well-known community)\n" |
| 6756 | "community number\n" |
| 6757 | "Do not send outside local AS (well-known community)\n" |
| 6758 | "Do not advertise to any peer (well-known community)\n" |
| 6759 | "Do not export to next AS (well-known community)\n" |
| 6760 | "community number\n" |
| 6761 | "Do not send outside local AS (well-known community)\n" |
| 6762 | "Do not advertise to any peer (well-known community)\n" |
| 6763 | "Do not export to next AS (well-known community)\n" |
| 6764 | "Exact match of the communities") |
| 6765 | |
| 6766 | /* old command */ |
| 6767 | DEFUN (show_ipv6_bgp_community_exact, |
| 6768 | show_ipv6_bgp_community_exact_cmd, |
| 6769 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6770 | SHOW_STR |
| 6771 | IPV6_STR |
| 6772 | BGP_STR |
| 6773 | "Display routes matching the communities\n" |
| 6774 | "community number\n" |
| 6775 | "Do not send outside local AS (well-known community)\n" |
| 6776 | "Do not advertise to any peer (well-known community)\n" |
| 6777 | "Do not export to next AS (well-known community)\n" |
| 6778 | "Exact match of the communities") |
| 6779 | { |
| 6780 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 6781 | } |
| 6782 | |
| 6783 | /* old command */ |
| 6784 | ALIAS (show_ipv6_bgp_community_exact, |
| 6785 | show_ipv6_bgp_community2_exact_cmd, |
| 6786 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6787 | SHOW_STR |
| 6788 | IPV6_STR |
| 6789 | BGP_STR |
| 6790 | "Display routes matching the communities\n" |
| 6791 | "community number\n" |
| 6792 | "Do not send outside local AS (well-known community)\n" |
| 6793 | "Do not advertise to any peer (well-known community)\n" |
| 6794 | "Do not export to next AS (well-known community)\n" |
| 6795 | "community number\n" |
| 6796 | "Do not send outside local AS (well-known community)\n" |
| 6797 | "Do not advertise to any peer (well-known community)\n" |
| 6798 | "Do not export to next AS (well-known community)\n" |
| 6799 | "Exact match of the communities") |
| 6800 | |
| 6801 | /* old command */ |
| 6802 | ALIAS (show_ipv6_bgp_community_exact, |
| 6803 | show_ipv6_bgp_community3_exact_cmd, |
| 6804 | "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", |
| 6805 | SHOW_STR |
| 6806 | IPV6_STR |
| 6807 | BGP_STR |
| 6808 | "Display routes matching the communities\n" |
| 6809 | "community number\n" |
| 6810 | "Do not send outside local AS (well-known community)\n" |
| 6811 | "Do not advertise to any peer (well-known community)\n" |
| 6812 | "Do not export to next AS (well-known community)\n" |
| 6813 | "community number\n" |
| 6814 | "Do not send outside local AS (well-known community)\n" |
| 6815 | "Do not advertise to any peer (well-known community)\n" |
| 6816 | "Do not export to next AS (well-known community)\n" |
| 6817 | "community number\n" |
| 6818 | "Do not send outside local AS (well-known community)\n" |
| 6819 | "Do not advertise to any peer (well-known community)\n" |
| 6820 | "Do not export to next AS (well-known community)\n" |
| 6821 | "Exact match of the communities") |
| 6822 | |
| 6823 | /* old command */ |
| 6824 | ALIAS (show_ipv6_bgp_community_exact, |
| 6825 | show_ipv6_bgp_community4_exact_cmd, |
| 6826 | "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", |
| 6827 | SHOW_STR |
| 6828 | IPV6_STR |
| 6829 | BGP_STR |
| 6830 | "Display routes matching the communities\n" |
| 6831 | "community number\n" |
| 6832 | "Do not send outside local AS (well-known community)\n" |
| 6833 | "Do not advertise to any peer (well-known community)\n" |
| 6834 | "Do not export to next AS (well-known community)\n" |
| 6835 | "community number\n" |
| 6836 | "Do not send outside local AS (well-known community)\n" |
| 6837 | "Do not advertise to any peer (well-known community)\n" |
| 6838 | "Do not export to next AS (well-known community)\n" |
| 6839 | "community number\n" |
| 6840 | "Do not send outside local AS (well-known community)\n" |
| 6841 | "Do not advertise to any peer (well-known community)\n" |
| 6842 | "Do not export to next AS (well-known community)\n" |
| 6843 | "community number\n" |
| 6844 | "Do not send outside local AS (well-known community)\n" |
| 6845 | "Do not advertise to any peer (well-known community)\n" |
| 6846 | "Do not export to next AS (well-known community)\n" |
| 6847 | "Exact match of the communities") |
| 6848 | |
| 6849 | /* old command */ |
| 6850 | DEFUN (show_ipv6_mbgp_community, |
| 6851 | show_ipv6_mbgp_community_cmd, |
| 6852 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6853 | SHOW_STR |
| 6854 | IPV6_STR |
| 6855 | MBGP_STR |
| 6856 | "Display routes matching the communities\n" |
| 6857 | "community number\n" |
| 6858 | "Do not send outside local AS (well-known community)\n" |
| 6859 | "Do not advertise to any peer (well-known community)\n" |
| 6860 | "Do not export to next AS (well-known community)\n") |
| 6861 | { |
| 6862 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 6863 | } |
| 6864 | |
| 6865 | /* old command */ |
| 6866 | ALIAS (show_ipv6_mbgp_community, |
| 6867 | show_ipv6_mbgp_community2_cmd, |
| 6868 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6869 | SHOW_STR |
| 6870 | IPV6_STR |
| 6871 | MBGP_STR |
| 6872 | "Display routes matching the communities\n" |
| 6873 | "community number\n" |
| 6874 | "Do not send outside local AS (well-known community)\n" |
| 6875 | "Do not advertise to any peer (well-known community)\n" |
| 6876 | "Do not export to next AS (well-known community)\n" |
| 6877 | "community number\n" |
| 6878 | "Do not send outside local AS (well-known community)\n" |
| 6879 | "Do not advertise to any peer (well-known community)\n" |
| 6880 | "Do not export to next AS (well-known community)\n") |
| 6881 | |
| 6882 | /* old command */ |
| 6883 | ALIAS (show_ipv6_mbgp_community, |
| 6884 | show_ipv6_mbgp_community3_cmd, |
| 6885 | "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)", |
| 6886 | SHOW_STR |
| 6887 | IPV6_STR |
| 6888 | MBGP_STR |
| 6889 | "Display routes matching the communities\n" |
| 6890 | "community number\n" |
| 6891 | "Do not send outside local AS (well-known community)\n" |
| 6892 | "Do not advertise to any peer (well-known community)\n" |
| 6893 | "Do not export to next AS (well-known community)\n" |
| 6894 | "community number\n" |
| 6895 | "Do not send outside local AS (well-known community)\n" |
| 6896 | "Do not advertise to any peer (well-known community)\n" |
| 6897 | "Do not export to next AS (well-known community)\n" |
| 6898 | "community number\n" |
| 6899 | "Do not send outside local AS (well-known community)\n" |
| 6900 | "Do not advertise to any peer (well-known community)\n" |
| 6901 | "Do not export to next AS (well-known community)\n") |
| 6902 | |
| 6903 | /* old command */ |
| 6904 | ALIAS (show_ipv6_mbgp_community, |
| 6905 | show_ipv6_mbgp_community4_cmd, |
| 6906 | "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)", |
| 6907 | SHOW_STR |
| 6908 | IPV6_STR |
| 6909 | MBGP_STR |
| 6910 | "Display routes matching the communities\n" |
| 6911 | "community number\n" |
| 6912 | "Do not send outside local AS (well-known community)\n" |
| 6913 | "Do not advertise to any peer (well-known community)\n" |
| 6914 | "Do not export to next AS (well-known community)\n" |
| 6915 | "community number\n" |
| 6916 | "Do not send outside local AS (well-known community)\n" |
| 6917 | "Do not advertise to any peer (well-known community)\n" |
| 6918 | "Do not export to next AS (well-known community)\n" |
| 6919 | "community number\n" |
| 6920 | "Do not send outside local AS (well-known community)\n" |
| 6921 | "Do not advertise to any peer (well-known community)\n" |
| 6922 | "Do not export to next AS (well-known community)\n" |
| 6923 | "community number\n" |
| 6924 | "Do not send outside local AS (well-known community)\n" |
| 6925 | "Do not advertise to any peer (well-known community)\n" |
| 6926 | "Do not export to next AS (well-known community)\n") |
| 6927 | |
| 6928 | /* old command */ |
| 6929 | DEFUN (show_ipv6_mbgp_community_exact, |
| 6930 | show_ipv6_mbgp_community_exact_cmd, |
| 6931 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6932 | SHOW_STR |
| 6933 | IPV6_STR |
| 6934 | MBGP_STR |
| 6935 | "Display routes matching the communities\n" |
| 6936 | "community number\n" |
| 6937 | "Do not send outside local AS (well-known community)\n" |
| 6938 | "Do not advertise to any peer (well-known community)\n" |
| 6939 | "Do not export to next AS (well-known community)\n" |
| 6940 | "Exact match of the communities") |
| 6941 | { |
| 6942 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 6943 | } |
| 6944 | |
| 6945 | /* old command */ |
| 6946 | ALIAS (show_ipv6_mbgp_community_exact, |
| 6947 | show_ipv6_mbgp_community2_exact_cmd, |
| 6948 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6949 | SHOW_STR |
| 6950 | IPV6_STR |
| 6951 | MBGP_STR |
| 6952 | "Display routes matching the communities\n" |
| 6953 | "community number\n" |
| 6954 | "Do not send outside local AS (well-known community)\n" |
| 6955 | "Do not advertise to any peer (well-known community)\n" |
| 6956 | "Do not export to next AS (well-known community)\n" |
| 6957 | "community number\n" |
| 6958 | "Do not send outside local AS (well-known community)\n" |
| 6959 | "Do not advertise to any peer (well-known community)\n" |
| 6960 | "Do not export to next AS (well-known community)\n" |
| 6961 | "Exact match of the communities") |
| 6962 | |
| 6963 | /* old command */ |
| 6964 | ALIAS (show_ipv6_mbgp_community_exact, |
| 6965 | show_ipv6_mbgp_community3_exact_cmd, |
| 6966 | "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", |
| 6967 | SHOW_STR |
| 6968 | IPV6_STR |
| 6969 | MBGP_STR |
| 6970 | "Display routes matching the communities\n" |
| 6971 | "community number\n" |
| 6972 | "Do not send outside local AS (well-known community)\n" |
| 6973 | "Do not advertise to any peer (well-known community)\n" |
| 6974 | "Do not export to next AS (well-known community)\n" |
| 6975 | "community number\n" |
| 6976 | "Do not send outside local AS (well-known community)\n" |
| 6977 | "Do not advertise to any peer (well-known community)\n" |
| 6978 | "Do not export to next AS (well-known community)\n" |
| 6979 | "community number\n" |
| 6980 | "Do not send outside local AS (well-known community)\n" |
| 6981 | "Do not advertise to any peer (well-known community)\n" |
| 6982 | "Do not export to next AS (well-known community)\n" |
| 6983 | "Exact match of the communities") |
| 6984 | |
| 6985 | /* old command */ |
| 6986 | ALIAS (show_ipv6_mbgp_community_exact, |
| 6987 | show_ipv6_mbgp_community4_exact_cmd, |
| 6988 | "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", |
| 6989 | SHOW_STR |
| 6990 | IPV6_STR |
| 6991 | MBGP_STR |
| 6992 | "Display routes matching the communities\n" |
| 6993 | "community number\n" |
| 6994 | "Do not send outside local AS (well-known community)\n" |
| 6995 | "Do not advertise to any peer (well-known community)\n" |
| 6996 | "Do not export to next AS (well-known community)\n" |
| 6997 | "community number\n" |
| 6998 | "Do not send outside local AS (well-known community)\n" |
| 6999 | "Do not advertise to any peer (well-known community)\n" |
| 7000 | "Do not export to next AS (well-known community)\n" |
| 7001 | "community number\n" |
| 7002 | "Do not send outside local AS (well-known community)\n" |
| 7003 | "Do not advertise to any peer (well-known community)\n" |
| 7004 | "Do not export to next AS (well-known community)\n" |
| 7005 | "community number\n" |
| 7006 | "Do not send outside local AS (well-known community)\n" |
| 7007 | "Do not advertise to any peer (well-known community)\n" |
| 7008 | "Do not export to next AS (well-known community)\n" |
| 7009 | "Exact match of the communities") |
| 7010 | #endif /* HAVE_IPV6 */ |
| 7011 | |
| 7012 | int |
| 7013 | bgp_show_community_list (struct vty *vty, char *com, int exact, |
| 7014 | u_int16_t afi, u_char safi) |
| 7015 | { |
| 7016 | struct community_list *list; |
| 7017 | |
| 7018 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_AUTO); |
| 7019 | if (list == NULL) |
| 7020 | { |
| 7021 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 7022 | VTY_NEWLINE); |
| 7023 | return CMD_WARNING; |
| 7024 | } |
| 7025 | |
| 7026 | vty->output_arg = list; |
| 7027 | |
| 7028 | if (exact) |
| 7029 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_list_exact); |
| 7030 | |
| 7031 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_list); |
| 7032 | } |
| 7033 | |
| 7034 | DEFUN (show_ip_bgp_community_list, |
| 7035 | show_ip_bgp_community_list_cmd, |
| 7036 | "show ip bgp community-list WORD", |
| 7037 | SHOW_STR |
| 7038 | IP_STR |
| 7039 | BGP_STR |
| 7040 | "Display routes matching the community-list\n" |
| 7041 | "community-list name\n") |
| 7042 | { |
| 7043 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 7044 | } |
| 7045 | |
| 7046 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 7047 | show_ip_bgp_ipv4_community_list_cmd, |
| 7048 | "show ip bgp ipv4 (unicast|multicast) community-list WORD", |
| 7049 | SHOW_STR |
| 7050 | IP_STR |
| 7051 | BGP_STR |
| 7052 | "Address family\n" |
| 7053 | "Address Family modifier\n" |
| 7054 | "Address Family modifier\n" |
| 7055 | "Display routes matching the community-list\n" |
| 7056 | "community-list name\n") |
| 7057 | { |
| 7058 | if (strncmp (argv[0], "m", 1) == 0) |
| 7059 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 7060 | |
| 7061 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 7062 | } |
| 7063 | |
| 7064 | DEFUN (show_ip_bgp_community_list_exact, |
| 7065 | show_ip_bgp_community_list_exact_cmd, |
| 7066 | "show ip bgp community-list WORD exact-match", |
| 7067 | SHOW_STR |
| 7068 | IP_STR |
| 7069 | BGP_STR |
| 7070 | "Display routes matching the community-list\n" |
| 7071 | "community-list name\n" |
| 7072 | "Exact match of the communities\n") |
| 7073 | { |
| 7074 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 7075 | } |
| 7076 | |
| 7077 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 7078 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 7079 | "show ip bgp ipv4 (unicast|multicast) community-list WORD exact-match", |
| 7080 | SHOW_STR |
| 7081 | IP_STR |
| 7082 | BGP_STR |
| 7083 | "Address family\n" |
| 7084 | "Address Family modifier\n" |
| 7085 | "Address Family modifier\n" |
| 7086 | "Display routes matching the community-list\n" |
| 7087 | "community-list name\n" |
| 7088 | "Exact match of the communities\n") |
| 7089 | { |
| 7090 | if (strncmp (argv[0], "m", 1) == 0) |
| 7091 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 7092 | |
| 7093 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 7094 | } |
| 7095 | |
| 7096 | #ifdef HAVE_IPV6 |
| 7097 | DEFUN (show_bgp_community_list, |
| 7098 | show_bgp_community_list_cmd, |
| 7099 | "show bgp community-list WORD", |
| 7100 | SHOW_STR |
| 7101 | BGP_STR |
| 7102 | "Display routes matching the community-list\n" |
| 7103 | "community-list name\n") |
| 7104 | { |
| 7105 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7106 | } |
| 7107 | |
| 7108 | ALIAS (show_bgp_community_list, |
| 7109 | show_bgp_ipv6_community_list_cmd, |
| 7110 | "show bgp ipv6 community-list WORD", |
| 7111 | SHOW_STR |
| 7112 | BGP_STR |
| 7113 | "Address family\n" |
| 7114 | "Display routes matching the community-list\n" |
| 7115 | "community-list name\n") |
| 7116 | |
| 7117 | /* old command */ |
| 7118 | DEFUN (show_ipv6_bgp_community_list, |
| 7119 | show_ipv6_bgp_community_list_cmd, |
| 7120 | "show ipv6 bgp community-list WORD", |
| 7121 | SHOW_STR |
| 7122 | IPV6_STR |
| 7123 | BGP_STR |
| 7124 | "Display routes matching the community-list\n" |
| 7125 | "community-list name\n") |
| 7126 | { |
| 7127 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7128 | } |
| 7129 | |
| 7130 | /* old command */ |
| 7131 | DEFUN (show_ipv6_mbgp_community_list, |
| 7132 | show_ipv6_mbgp_community_list_cmd, |
| 7133 | "show ipv6 mbgp community-list WORD", |
| 7134 | SHOW_STR |
| 7135 | IPV6_STR |
| 7136 | MBGP_STR |
| 7137 | "Display routes matching the community-list\n" |
| 7138 | "community-list name\n") |
| 7139 | { |
| 7140 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 7141 | } |
| 7142 | |
| 7143 | DEFUN (show_bgp_community_list_exact, |
| 7144 | show_bgp_community_list_exact_cmd, |
| 7145 | "show bgp community-list WORD exact-match", |
| 7146 | SHOW_STR |
| 7147 | BGP_STR |
| 7148 | "Display routes matching the community-list\n" |
| 7149 | "community-list name\n" |
| 7150 | "Exact match of the communities\n") |
| 7151 | { |
| 7152 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7153 | } |
| 7154 | |
| 7155 | ALIAS (show_bgp_community_list_exact, |
| 7156 | show_bgp_ipv6_community_list_exact_cmd, |
| 7157 | "show bgp ipv6 community-list WORD exact-match", |
| 7158 | SHOW_STR |
| 7159 | BGP_STR |
| 7160 | "Address family\n" |
| 7161 | "Display routes matching the community-list\n" |
| 7162 | "community-list name\n" |
| 7163 | "Exact match of the communities\n") |
| 7164 | |
| 7165 | /* old command */ |
| 7166 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 7167 | show_ipv6_bgp_community_list_exact_cmd, |
| 7168 | "show ipv6 bgp community-list WORD exact-match", |
| 7169 | SHOW_STR |
| 7170 | IPV6_STR |
| 7171 | BGP_STR |
| 7172 | "Display routes matching the community-list\n" |
| 7173 | "community-list name\n" |
| 7174 | "Exact match of the communities\n") |
| 7175 | { |
| 7176 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7177 | } |
| 7178 | |
| 7179 | /* old command */ |
| 7180 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 7181 | show_ipv6_mbgp_community_list_exact_cmd, |
| 7182 | "show ipv6 mbgp community-list WORD exact-match", |
| 7183 | SHOW_STR |
| 7184 | IPV6_STR |
| 7185 | MBGP_STR |
| 7186 | "Display routes matching the community-list\n" |
| 7187 | "community-list name\n" |
| 7188 | "Exact match of the communities\n") |
| 7189 | { |
| 7190 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 7191 | } |
| 7192 | #endif /* HAVE_IPV6 */ |
| 7193 | |
| 7194 | void |
| 7195 | bgp_show_prefix_longer_clean (struct vty *vty) |
| 7196 | { |
| 7197 | struct prefix *p; |
| 7198 | |
| 7199 | p = vty->output_arg; |
| 7200 | prefix_free (p); |
| 7201 | } |
| 7202 | |
| 7203 | int |
| 7204 | bgp_show_prefix_longer (struct vty *vty, char *prefix, afi_t afi, |
| 7205 | safi_t safi, enum bgp_show_type type) |
| 7206 | { |
| 7207 | int ret; |
| 7208 | struct prefix *p; |
| 7209 | |
| 7210 | p = prefix_new(); |
| 7211 | |
| 7212 | ret = str2prefix (prefix, p); |
| 7213 | if (! ret) |
| 7214 | { |
| 7215 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 7216 | return CMD_WARNING; |
| 7217 | } |
| 7218 | |
| 7219 | vty->output_arg = p; |
| 7220 | vty->output_clean = bgp_show_prefix_longer_clean; |
| 7221 | |
| 7222 | return bgp_show (vty, NULL, afi, safi, type); |
| 7223 | } |
| 7224 | |
| 7225 | DEFUN (show_ip_bgp_prefix_longer, |
| 7226 | show_ip_bgp_prefix_longer_cmd, |
| 7227 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 7228 | SHOW_STR |
| 7229 | IP_STR |
| 7230 | BGP_STR |
| 7231 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7232 | "Display route and more specific routes\n") |
| 7233 | { |
| 7234 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7235 | bgp_show_type_prefix_longer); |
| 7236 | } |
| 7237 | |
| 7238 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 7239 | show_ip_bgp_flap_prefix_longer_cmd, |
| 7240 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 7241 | SHOW_STR |
| 7242 | IP_STR |
| 7243 | BGP_STR |
| 7244 | "Display flap statistics of routes\n" |
| 7245 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7246 | "Display route and more specific routes\n") |
| 7247 | { |
| 7248 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7249 | bgp_show_type_flap_prefix_longer); |
| 7250 | } |
| 7251 | |
| 7252 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 7253 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 7254 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 7255 | SHOW_STR |
| 7256 | IP_STR |
| 7257 | BGP_STR |
| 7258 | "Address family\n" |
| 7259 | "Address Family modifier\n" |
| 7260 | "Address Family modifier\n" |
| 7261 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7262 | "Display route and more specific routes\n") |
| 7263 | { |
| 7264 | if (strncmp (argv[0], "m", 1) == 0) |
| 7265 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7266 | bgp_show_type_prefix_longer); |
| 7267 | |
| 7268 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7269 | bgp_show_type_prefix_longer); |
| 7270 | } |
| 7271 | |
| 7272 | DEFUN (show_ip_bgp_flap_address, |
| 7273 | show_ip_bgp_flap_address_cmd, |
| 7274 | "show ip bgp flap-statistics A.B.C.D", |
| 7275 | SHOW_STR |
| 7276 | IP_STR |
| 7277 | BGP_STR |
| 7278 | "Display flap statistics of routes\n" |
| 7279 | "Network in the BGP routing table to display\n") |
| 7280 | { |
| 7281 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7282 | bgp_show_type_flap_address); |
| 7283 | } |
| 7284 | |
| 7285 | DEFUN (show_ip_bgp_flap_prefix, |
| 7286 | show_ip_bgp_flap_prefix_cmd, |
| 7287 | "show ip bgp flap-statistics A.B.C.D/M", |
| 7288 | SHOW_STR |
| 7289 | IP_STR |
| 7290 | BGP_STR |
| 7291 | "Display flap statistics of routes\n" |
| 7292 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7293 | { |
| 7294 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7295 | bgp_show_type_flap_prefix); |
| 7296 | } |
| 7297 | #ifdef HAVE_IPV6 |
| 7298 | DEFUN (show_bgp_prefix_longer, |
| 7299 | show_bgp_prefix_longer_cmd, |
| 7300 | "show bgp X:X::X:X/M longer-prefixes", |
| 7301 | SHOW_STR |
| 7302 | BGP_STR |
| 7303 | "IPv6 prefix <network>/<length>\n" |
| 7304 | "Display route and more specific routes\n") |
| 7305 | { |
| 7306 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7307 | bgp_show_type_prefix_longer); |
| 7308 | } |
| 7309 | |
| 7310 | ALIAS (show_bgp_prefix_longer, |
| 7311 | show_bgp_ipv6_prefix_longer_cmd, |
| 7312 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 7313 | SHOW_STR |
| 7314 | BGP_STR |
| 7315 | "Address family\n" |
| 7316 | "IPv6 prefix <network>/<length>\n" |
| 7317 | "Display route and more specific routes\n") |
| 7318 | |
| 7319 | /* old command */ |
| 7320 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 7321 | show_ipv6_bgp_prefix_longer_cmd, |
| 7322 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 7323 | SHOW_STR |
| 7324 | IPV6_STR |
| 7325 | BGP_STR |
| 7326 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 7327 | "Display route and more specific routes\n") |
| 7328 | { |
| 7329 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7330 | bgp_show_type_prefix_longer); |
| 7331 | } |
| 7332 | |
| 7333 | /* old command */ |
| 7334 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 7335 | show_ipv6_mbgp_prefix_longer_cmd, |
| 7336 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 7337 | SHOW_STR |
| 7338 | IPV6_STR |
| 7339 | MBGP_STR |
| 7340 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 7341 | "Display route and more specific routes\n") |
| 7342 | { |
| 7343 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7344 | bgp_show_type_prefix_longer); |
| 7345 | } |
| 7346 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7347 | |
| 7348 | struct peer * |
| 7349 | peer_lookup_in_view (struct vty *vty, char *view_name, char *ip_str) |
| 7350 | { |
| 7351 | int ret; |
| 7352 | struct bgp *bgp; |
| 7353 | struct peer *peer; |
| 7354 | union sockunion su; |
| 7355 | |
| 7356 | /* BGP structure lookup. */ |
| 7357 | if (view_name) |
| 7358 | { |
| 7359 | bgp = bgp_lookup_by_name (view_name); |
| 7360 | if (! bgp) |
| 7361 | { |
| 7362 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7363 | return NULL; |
| 7364 | } |
| 7365 | } |
| 7366 | else // view_name==NULL |
| 7367 | { |
| 7368 | bgp = bgp_get_default (); |
| 7369 | if (! bgp) |
| 7370 | { |
| 7371 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7372 | return NULL; |
| 7373 | } |
| 7374 | } |
| 7375 | |
| 7376 | /* Get peer sockunion. */ |
| 7377 | ret = str2sockunion (ip_str, &su); |
| 7378 | if (ret < 0) |
| 7379 | { |
| 7380 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 7381 | return NULL; |
| 7382 | } |
| 7383 | |
| 7384 | /* Peer structure lookup. */ |
| 7385 | peer = peer_lookup (bgp, &su); |
| 7386 | if (! peer) |
| 7387 | { |
| 7388 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 7389 | return NULL; |
| 7390 | } |
| 7391 | |
| 7392 | return peer; |
| 7393 | } |
| 7394 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7395 | void |
| 7396 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 7397 | int in) |
| 7398 | { |
| 7399 | struct bgp_table *table; |
| 7400 | struct bgp_adj_in *ain; |
| 7401 | struct bgp_adj_out *adj; |
| 7402 | unsigned long output_count; |
| 7403 | struct bgp_node *rn; |
| 7404 | int header1 = 1; |
| 7405 | struct bgp *bgp; |
| 7406 | int header2 = 1; |
| 7407 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7408 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7409 | |
| 7410 | if (! bgp) |
| 7411 | return; |
| 7412 | |
| 7413 | table = bgp->rib[afi][safi]; |
| 7414 | |
| 7415 | output_count = 0; |
| 7416 | |
| 7417 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 7418 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 7419 | { |
| 7420 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 7421 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 7422 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 7423 | |
| 7424 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 7425 | VTY_NEWLINE, VTY_NEWLINE); |
| 7426 | header1 = 0; |
| 7427 | } |
| 7428 | |
| 7429 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 7430 | if (in) |
| 7431 | { |
| 7432 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 7433 | if (ain->peer == peer) |
| 7434 | { |
| 7435 | if (header1) |
| 7436 | { |
| 7437 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 7438 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 7439 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 7440 | header1 = 0; |
| 7441 | } |
| 7442 | if (header2) |
| 7443 | { |
| 7444 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 7445 | header2 = 0; |
| 7446 | } |
| 7447 | if (ain->attr) |
| 7448 | { |
| 7449 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 7450 | output_count++; |
| 7451 | } |
| 7452 | } |
| 7453 | } |
| 7454 | else |
| 7455 | { |
| 7456 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 7457 | if (adj->peer == peer) |
| 7458 | { |
| 7459 | if (header1) |
| 7460 | { |
| 7461 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 7462 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 7463 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 7464 | header1 = 0; |
| 7465 | } |
| 7466 | if (header2) |
| 7467 | { |
| 7468 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 7469 | header2 = 0; |
| 7470 | } |
| 7471 | if (adj->attr) |
| 7472 | { |
| 7473 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 7474 | output_count++; |
| 7475 | } |
| 7476 | } |
| 7477 | } |
| 7478 | |
| 7479 | if (output_count != 0) |
| 7480 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 7481 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 7482 | } |
| 7483 | |
| 7484 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7485 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 7486 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7487 | if (! peer || ! peer->afc[afi][safi]) |
| 7488 | { |
| 7489 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 7490 | return CMD_WARNING; |
| 7491 | } |
| 7492 | |
| 7493 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 7494 | { |
| 7495 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 7496 | VTY_NEWLINE); |
| 7497 | return CMD_WARNING; |
| 7498 | } |
| 7499 | |
| 7500 | show_adj_route (vty, peer, afi, safi, in); |
| 7501 | |
| 7502 | return CMD_SUCCESS; |
| 7503 | } |
| 7504 | |
| 7505 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 7506 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 7507 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7508 | SHOW_STR |
| 7509 | IP_STR |
| 7510 | BGP_STR |
| 7511 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7512 | "Neighbor to display information about\n" |
| 7513 | "Neighbor to display information about\n" |
| 7514 | "Display the routes advertised to a BGP neighbor\n") |
| 7515 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7516 | struct peer *peer; |
| 7517 | |
| 7518 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 7519 | if (! peer) |
| 7520 | return CMD_WARNING; |
| 7521 | |
| 7522 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7523 | } |
| 7524 | |
| 7525 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 7526 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 7527 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7528 | SHOW_STR |
| 7529 | IP_STR |
| 7530 | BGP_STR |
| 7531 | "Address family\n" |
| 7532 | "Address Family modifier\n" |
| 7533 | "Address Family modifier\n" |
| 7534 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7535 | "Neighbor to display information about\n" |
| 7536 | "Neighbor to display information about\n" |
| 7537 | "Display the routes advertised to a BGP neighbor\n") |
| 7538 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7539 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7540 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7541 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 7542 | if (! peer) |
| 7543 | return CMD_WARNING; |
| 7544 | |
| 7545 | if (strncmp (argv[0], "m", 1) == 0) |
| 7546 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 7547 | |
| 7548 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7549 | } |
| 7550 | |
| 7551 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7552 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 7553 | show_bgp_view_neighbor_advertised_route_cmd, |
| 7554 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7555 | SHOW_STR |
| 7556 | BGP_STR |
| 7557 | "BGP view\n" |
| 7558 | "View name\n" |
| 7559 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7560 | "Neighbor to display information about\n" |
| 7561 | "Neighbor to display information about\n" |
| 7562 | "Display the routes advertised to a BGP neighbor\n") |
| 7563 | { |
| 7564 | struct peer *peer; |
| 7565 | |
| 7566 | if (argc == 2) |
| 7567 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 7568 | else |
| 7569 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 7570 | |
| 7571 | if (! peer) |
| 7572 | return CMD_WARNING; |
| 7573 | |
| 7574 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 7575 | } |
| 7576 | |
| 7577 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 7578 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 7579 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7580 | SHOW_STR |
| 7581 | BGP_STR |
| 7582 | "BGP view\n" |
| 7583 | "View name\n" |
| 7584 | "Address family\n" |
| 7585 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7586 | "Neighbor to display information about\n" |
| 7587 | "Neighbor to display information about\n" |
| 7588 | "Display the routes advertised to a BGP neighbor\n") |
| 7589 | |
| 7590 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 7591 | show_bgp_view_neighbor_received_routes_cmd, |
| 7592 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7593 | SHOW_STR |
| 7594 | BGP_STR |
| 7595 | "BGP view\n" |
| 7596 | "View name\n" |
| 7597 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7598 | "Neighbor to display information about\n" |
| 7599 | "Neighbor to display information about\n" |
| 7600 | "Display the received routes from neighbor\n") |
| 7601 | { |
| 7602 | struct peer *peer; |
| 7603 | |
| 7604 | if (argc == 2) |
| 7605 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 7606 | else |
| 7607 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 7608 | |
| 7609 | if (! peer) |
| 7610 | return CMD_WARNING; |
| 7611 | |
| 7612 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 7613 | } |
| 7614 | |
| 7615 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 7616 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 7617 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7618 | SHOW_STR |
| 7619 | BGP_STR |
| 7620 | "BGP view\n" |
| 7621 | "View name\n" |
| 7622 | "Address family\n" |
| 7623 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7624 | "Neighbor to display information about\n" |
| 7625 | "Neighbor to display information about\n" |
| 7626 | "Display the received routes from neighbor\n") |
| 7627 | |
| 7628 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7629 | show_bgp_neighbor_advertised_route_cmd, |
| 7630 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7631 | SHOW_STR |
| 7632 | BGP_STR |
| 7633 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7634 | "Neighbor to display information about\n" |
| 7635 | "Neighbor to display information about\n" |
| 7636 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7637 | |
| 7638 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7639 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 7640 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7641 | SHOW_STR |
| 7642 | BGP_STR |
| 7643 | "Address family\n" |
| 7644 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7645 | "Neighbor to display information about\n" |
| 7646 | "Neighbor to display information about\n" |
| 7647 | "Display the routes advertised to a BGP neighbor\n") |
| 7648 | |
| 7649 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7650 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7651 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 7652 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7653 | SHOW_STR |
| 7654 | IPV6_STR |
| 7655 | BGP_STR |
| 7656 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7657 | "Neighbor to display information about\n" |
| 7658 | "Neighbor to display information about\n" |
| 7659 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7660 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7661 | /* old command */ |
| 7662 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 7663 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 7664 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7665 | SHOW_STR |
| 7666 | IPV6_STR |
| 7667 | MBGP_STR |
| 7668 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7669 | "Neighbor to display information about\n" |
| 7670 | "Neighbor to display information about\n" |
| 7671 | "Display the routes advertised to a BGP neighbor\n") |
| 7672 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7673 | struct peer *peer; |
| 7674 | |
| 7675 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 7676 | if (! peer) |
| 7677 | return CMD_WARNING; |
| 7678 | |
| 7679 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7680 | } |
| 7681 | #endif /* HAVE_IPV6 */ |
| 7682 | |
| 7683 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 7684 | show_ip_bgp_neighbor_received_routes_cmd, |
| 7685 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7686 | SHOW_STR |
| 7687 | IP_STR |
| 7688 | BGP_STR |
| 7689 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7690 | "Neighbor to display information about\n" |
| 7691 | "Neighbor to display information about\n" |
| 7692 | "Display the received routes from neighbor\n") |
| 7693 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7694 | struct peer *peer; |
| 7695 | |
| 7696 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 7697 | if (! peer) |
| 7698 | return CMD_WARNING; |
| 7699 | |
| 7700 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7701 | } |
| 7702 | |
| 7703 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 7704 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 7705 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7706 | SHOW_STR |
| 7707 | IP_STR |
| 7708 | BGP_STR |
| 7709 | "Address family\n" |
| 7710 | "Address Family modifier\n" |
| 7711 | "Address Family modifier\n" |
| 7712 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7713 | "Neighbor to display information about\n" |
| 7714 | "Neighbor to display information about\n" |
| 7715 | "Display the received routes from neighbor\n") |
| 7716 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7717 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7718 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7719 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 7720 | if (! peer) |
| 7721 | return CMD_WARNING; |
| 7722 | |
| 7723 | if (strncmp (argv[0], "m", 1) == 0) |
| 7724 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 7725 | |
| 7726 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7727 | } |
| 7728 | |
| 7729 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 7730 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 7731 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7732 | SHOW_STR |
| 7733 | IP_STR |
| 7734 | BGP_STR |
| 7735 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7736 | "Neighbor to display information about\n" |
| 7737 | "Neighbor to display information about\n" |
| 7738 | "Display information received from a BGP neighbor\n" |
| 7739 | "Display the prefixlist filter\n") |
| 7740 | { |
| 7741 | char name[BUFSIZ]; |
| 7742 | union sockunion *su; |
| 7743 | struct peer *peer; |
| 7744 | int count; |
| 7745 | |
| 7746 | su = sockunion_str2su (argv[0]); |
| 7747 | if (su == NULL) |
| 7748 | return CMD_WARNING; |
| 7749 | |
| 7750 | peer = peer_lookup (NULL, su); |
| 7751 | if (! peer) |
| 7752 | return CMD_WARNING; |
| 7753 | |
| 7754 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 7755 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 7756 | if (count) |
| 7757 | { |
| 7758 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 7759 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 7760 | } |
| 7761 | |
| 7762 | return CMD_SUCCESS; |
| 7763 | } |
| 7764 | |
| 7765 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 7766 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 7767 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7768 | SHOW_STR |
| 7769 | IP_STR |
| 7770 | BGP_STR |
| 7771 | "Address family\n" |
| 7772 | "Address Family modifier\n" |
| 7773 | "Address Family modifier\n" |
| 7774 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7775 | "Neighbor to display information about\n" |
| 7776 | "Neighbor to display information about\n" |
| 7777 | "Display information received from a BGP neighbor\n" |
| 7778 | "Display the prefixlist filter\n") |
| 7779 | { |
| 7780 | char name[BUFSIZ]; |
| 7781 | union sockunion *su; |
| 7782 | struct peer *peer; |
| 7783 | int count; |
| 7784 | |
| 7785 | su = sockunion_str2su (argv[1]); |
| 7786 | if (su == NULL) |
| 7787 | return CMD_WARNING; |
| 7788 | |
| 7789 | peer = peer_lookup (NULL, su); |
| 7790 | if (! peer) |
| 7791 | return CMD_WARNING; |
| 7792 | |
| 7793 | if (strncmp (argv[0], "m", 1) == 0) |
| 7794 | { |
| 7795 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 7796 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 7797 | if (count) |
| 7798 | { |
| 7799 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 7800 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 7801 | } |
| 7802 | } |
| 7803 | else |
| 7804 | { |
| 7805 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 7806 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 7807 | if (count) |
| 7808 | { |
| 7809 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 7810 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 7811 | } |
| 7812 | } |
| 7813 | |
| 7814 | return CMD_SUCCESS; |
| 7815 | } |
| 7816 | |
| 7817 | |
| 7818 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7819 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7820 | show_bgp_neighbor_received_routes_cmd, |
| 7821 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7822 | SHOW_STR |
| 7823 | BGP_STR |
| 7824 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7825 | "Neighbor to display information about\n" |
| 7826 | "Neighbor to display information about\n" |
| 7827 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7828 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7829 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7830 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 7831 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7832 | SHOW_STR |
| 7833 | BGP_STR |
| 7834 | "Address family\n" |
| 7835 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7836 | "Neighbor to display information about\n" |
| 7837 | "Neighbor to display information about\n" |
| 7838 | "Display the received routes from neighbor\n") |
| 7839 | |
| 7840 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 7841 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 7842 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7843 | SHOW_STR |
| 7844 | BGP_STR |
| 7845 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7846 | "Neighbor to display information about\n" |
| 7847 | "Neighbor to display information about\n" |
| 7848 | "Display information received from a BGP neighbor\n" |
| 7849 | "Display the prefixlist filter\n") |
| 7850 | { |
| 7851 | char name[BUFSIZ]; |
| 7852 | union sockunion *su; |
| 7853 | struct peer *peer; |
| 7854 | int count; |
| 7855 | |
| 7856 | su = sockunion_str2su (argv[0]); |
| 7857 | if (su == NULL) |
| 7858 | return CMD_WARNING; |
| 7859 | |
| 7860 | peer = peer_lookup (NULL, su); |
| 7861 | if (! peer) |
| 7862 | return CMD_WARNING; |
| 7863 | |
| 7864 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 7865 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 7866 | if (count) |
| 7867 | { |
| 7868 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 7869 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 7870 | } |
| 7871 | |
| 7872 | return CMD_SUCCESS; |
| 7873 | } |
| 7874 | |
| 7875 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 7876 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 7877 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7878 | SHOW_STR |
| 7879 | BGP_STR |
| 7880 | "Address family\n" |
| 7881 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7882 | "Neighbor to display information about\n" |
| 7883 | "Neighbor to display information about\n" |
| 7884 | "Display information received from a BGP neighbor\n" |
| 7885 | "Display the prefixlist filter\n") |
| 7886 | |
| 7887 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7888 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7889 | ipv6_bgp_neighbor_received_routes_cmd, |
| 7890 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7891 | SHOW_STR |
| 7892 | IPV6_STR |
| 7893 | BGP_STR |
| 7894 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7895 | "Neighbor to display information about\n" |
| 7896 | "Neighbor to display information about\n" |
| 7897 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7898 | |
| 7899 | /* old command */ |
| 7900 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 7901 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 7902 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7903 | SHOW_STR |
| 7904 | IPV6_STR |
| 7905 | MBGP_STR |
| 7906 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7907 | "Neighbor to display information about\n" |
| 7908 | "Neighbor to display information about\n" |
| 7909 | "Display the received routes from neighbor\n") |
| 7910 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7911 | struct peer *peer; |
| 7912 | |
| 7913 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 7914 | if (! peer) |
| 7915 | return CMD_WARNING; |
| 7916 | |
| 7917 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7918 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7919 | |
| 7920 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 7921 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 7922 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7923 | SHOW_STR |
| 7924 | BGP_STR |
| 7925 | "BGP view\n" |
| 7926 | "View name\n" |
| 7927 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7928 | "Neighbor to display information about\n" |
| 7929 | "Neighbor to display information about\n" |
| 7930 | "Display information received from a BGP neighbor\n" |
| 7931 | "Display the prefixlist filter\n") |
| 7932 | { |
| 7933 | char name[BUFSIZ]; |
| 7934 | union sockunion *su; |
| 7935 | struct peer *peer; |
| 7936 | struct bgp *bgp; |
| 7937 | int count; |
| 7938 | |
| 7939 | /* BGP structure lookup. */ |
| 7940 | bgp = bgp_lookup_by_name (argv[0]); |
| 7941 | if (bgp == NULL) |
| 7942 | { |
| 7943 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7944 | return CMD_WARNING; |
| 7945 | } |
| 7946 | |
| 7947 | su = sockunion_str2su (argv[1]); |
| 7948 | if (su == NULL) |
| 7949 | return CMD_WARNING; |
| 7950 | |
| 7951 | peer = peer_lookup (bgp, su); |
| 7952 | if (! peer) |
| 7953 | return CMD_WARNING; |
| 7954 | |
| 7955 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 7956 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 7957 | if (count) |
| 7958 | { |
| 7959 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 7960 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 7961 | } |
| 7962 | |
| 7963 | return CMD_SUCCESS; |
| 7964 | } |
| 7965 | |
| 7966 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 7967 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 7968 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7969 | SHOW_STR |
| 7970 | BGP_STR |
| 7971 | "BGP view\n" |
| 7972 | "View name\n" |
| 7973 | "Address family\n" |
| 7974 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7975 | "Neighbor to display information about\n" |
| 7976 | "Neighbor to display information about\n" |
| 7977 | "Display information received from a BGP neighbor\n" |
| 7978 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7979 | #endif /* HAVE_IPV6 */ |
| 7980 | |
| 7981 | void |
| 7982 | bgp_show_neighbor_route_clean (struct vty *vty) |
| 7983 | { |
| 7984 | union sockunion *su; |
| 7985 | |
| 7986 | su = vty->output_arg; |
| 7987 | XFREE (MTYPE_SOCKUNION, su); |
| 7988 | } |
| 7989 | |
| 7990 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7991 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7992 | safi_t safi, enum bgp_show_type type) |
| 7993 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7994 | if (! peer || ! peer->afc[afi][safi]) |
| 7995 | { |
| 7996 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7997 | return CMD_WARNING; |
| 7998 | } |
| 7999 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8000 | vty->output_arg = sockunion_dup (&peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8001 | vty->output_clean = bgp_show_neighbor_route_clean; |
| 8002 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8003 | return bgp_show (vty, peer->bgp, afi, safi, type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8004 | } |
| 8005 | |
| 8006 | DEFUN (show_ip_bgp_neighbor_routes, |
| 8007 | show_ip_bgp_neighbor_routes_cmd, |
| 8008 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8009 | SHOW_STR |
| 8010 | IP_STR |
| 8011 | BGP_STR |
| 8012 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8013 | "Neighbor to display information about\n" |
| 8014 | "Neighbor to display information about\n" |
| 8015 | "Display routes learned from neighbor\n") |
| 8016 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8017 | struct peer *peer; |
| 8018 | |
| 8019 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8020 | if (! peer) |
| 8021 | return CMD_WARNING; |
| 8022 | |
| 8023 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8024 | bgp_show_type_neighbor); |
| 8025 | } |
| 8026 | |
| 8027 | DEFUN (show_ip_bgp_neighbor_flap, |
| 8028 | show_ip_bgp_neighbor_flap_cmd, |
| 8029 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8030 | SHOW_STR |
| 8031 | IP_STR |
| 8032 | BGP_STR |
| 8033 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8034 | "Neighbor to display information about\n" |
| 8035 | "Neighbor to display information about\n" |
| 8036 | "Display flap statistics of the routes learned from neighbor\n") |
| 8037 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8038 | struct peer *peer; |
| 8039 | |
| 8040 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8041 | if (! peer) |
| 8042 | return CMD_WARNING; |
| 8043 | |
| 8044 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8045 | bgp_show_type_flap_neighbor); |
| 8046 | } |
| 8047 | |
| 8048 | DEFUN (show_ip_bgp_neighbor_damp, |
| 8049 | show_ip_bgp_neighbor_damp_cmd, |
| 8050 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8051 | SHOW_STR |
| 8052 | IP_STR |
| 8053 | BGP_STR |
| 8054 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8055 | "Neighbor to display information about\n" |
| 8056 | "Neighbor to display information about\n" |
| 8057 | "Display the dampened routes received from neighbor\n") |
| 8058 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8059 | struct peer *peer; |
| 8060 | |
| 8061 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8062 | if (! peer) |
| 8063 | return CMD_WARNING; |
| 8064 | |
| 8065 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8066 | bgp_show_type_damp_neighbor); |
| 8067 | } |
| 8068 | |
| 8069 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 8070 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 8071 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 8072 | SHOW_STR |
| 8073 | IP_STR |
| 8074 | BGP_STR |
| 8075 | "Address family\n" |
| 8076 | "Address Family modifier\n" |
| 8077 | "Address Family modifier\n" |
| 8078 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8079 | "Neighbor to display information about\n" |
| 8080 | "Neighbor to display information about\n" |
| 8081 | "Display routes learned from neighbor\n") |
| 8082 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8083 | struct peer *peer; |
| 8084 | |
| 8085 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8086 | if (! peer) |
| 8087 | return CMD_WARNING; |
| 8088 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8089 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8090 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8091 | bgp_show_type_neighbor); |
| 8092 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8093 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8094 | bgp_show_type_neighbor); |
| 8095 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8096 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8097 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8098 | DEFUN (show_bgp_view_neighbor_routes, |
| 8099 | show_bgp_view_neighbor_routes_cmd, |
| 8100 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 8101 | SHOW_STR |
| 8102 | BGP_STR |
| 8103 | "BGP view\n" |
| 8104 | "BGP view name\n" |
| 8105 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8106 | "Neighbor to display information about\n" |
| 8107 | "Neighbor to display information about\n" |
| 8108 | "Display routes learned from neighbor\n") |
| 8109 | { |
| 8110 | struct peer *peer; |
| 8111 | |
| 8112 | if (argc == 2) |
| 8113 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8114 | else |
| 8115 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8116 | |
| 8117 | if (! peer) |
| 8118 | return CMD_WARNING; |
| 8119 | |
| 8120 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 8121 | bgp_show_type_neighbor); |
| 8122 | } |
| 8123 | |
| 8124 | ALIAS (show_bgp_view_neighbor_routes, |
| 8125 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 8126 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 8127 | SHOW_STR |
| 8128 | BGP_STR |
| 8129 | "BGP view\n" |
| 8130 | "BGP view name\n" |
| 8131 | "Address family\n" |
| 8132 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8133 | "Neighbor to display information about\n" |
| 8134 | "Neighbor to display information about\n" |
| 8135 | "Display routes learned from neighbor\n") |
| 8136 | |
| 8137 | DEFUN (show_bgp_view_neighbor_damp, |
| 8138 | show_bgp_view_neighbor_damp_cmd, |
| 8139 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8140 | SHOW_STR |
| 8141 | BGP_STR |
| 8142 | "BGP view\n" |
| 8143 | "BGP view name\n" |
| 8144 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8145 | "Neighbor to display information about\n" |
| 8146 | "Neighbor to display information about\n" |
| 8147 | "Display the dampened routes received from neighbor\n") |
| 8148 | { |
| 8149 | struct peer *peer; |
| 8150 | |
| 8151 | if (argc == 2) |
| 8152 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8153 | else |
| 8154 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8155 | |
| 8156 | if (! peer) |
| 8157 | return CMD_WARNING; |
| 8158 | |
| 8159 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 8160 | bgp_show_type_damp_neighbor); |
| 8161 | } |
| 8162 | |
| 8163 | ALIAS (show_bgp_view_neighbor_damp, |
| 8164 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 8165 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8166 | SHOW_STR |
| 8167 | BGP_STR |
| 8168 | "BGP view\n" |
| 8169 | "BGP view name\n" |
| 8170 | "Address family\n" |
| 8171 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8172 | "Neighbor to display information about\n" |
| 8173 | "Neighbor to display information about\n" |
| 8174 | "Display the dampened routes received from neighbor\n") |
| 8175 | |
| 8176 | DEFUN (show_bgp_view_neighbor_flap, |
| 8177 | show_bgp_view_neighbor_flap_cmd, |
| 8178 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8179 | SHOW_STR |
| 8180 | BGP_STR |
| 8181 | "BGP view\n" |
| 8182 | "BGP view name\n" |
| 8183 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8184 | "Neighbor to display information about\n" |
| 8185 | "Neighbor to display information about\n" |
| 8186 | "Display flap statistics of the routes learned from neighbor\n") |
| 8187 | { |
| 8188 | struct peer *peer; |
| 8189 | |
| 8190 | if (argc == 2) |
| 8191 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8192 | else |
| 8193 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8194 | |
| 8195 | if (! peer) |
| 8196 | return CMD_WARNING; |
| 8197 | |
| 8198 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 8199 | bgp_show_type_flap_neighbor); |
| 8200 | } |
| 8201 | |
| 8202 | ALIAS (show_bgp_view_neighbor_flap, |
| 8203 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 8204 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8205 | SHOW_STR |
| 8206 | BGP_STR |
| 8207 | "BGP view\n" |
| 8208 | "BGP view name\n" |
| 8209 | "Address family\n" |
| 8210 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8211 | "Neighbor to display information about\n" |
| 8212 | "Neighbor to display information about\n" |
| 8213 | "Display flap statistics of the routes learned from neighbor\n") |
| 8214 | |
| 8215 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8216 | show_bgp_neighbor_routes_cmd, |
| 8217 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8218 | SHOW_STR |
| 8219 | BGP_STR |
| 8220 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8221 | "Neighbor to display information about\n" |
| 8222 | "Neighbor to display information about\n" |
| 8223 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8224 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8225 | |
| 8226 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8227 | show_bgp_ipv6_neighbor_routes_cmd, |
| 8228 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 8229 | SHOW_STR |
| 8230 | BGP_STR |
| 8231 | "Address family\n" |
| 8232 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8233 | "Neighbor to display information about\n" |
| 8234 | "Neighbor to display information about\n" |
| 8235 | "Display routes learned from neighbor\n") |
| 8236 | |
| 8237 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8238 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8239 | ipv6_bgp_neighbor_routes_cmd, |
| 8240 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8241 | SHOW_STR |
| 8242 | IPV6_STR |
| 8243 | BGP_STR |
| 8244 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8245 | "Neighbor to display information about\n" |
| 8246 | "Neighbor to display information about\n" |
| 8247 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8248 | |
| 8249 | /* old command */ |
| 8250 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 8251 | ipv6_mbgp_neighbor_routes_cmd, |
| 8252 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8253 | SHOW_STR |
| 8254 | IPV6_STR |
| 8255 | MBGP_STR |
| 8256 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8257 | "Neighbor to display information about\n" |
| 8258 | "Neighbor to display information about\n" |
| 8259 | "Display routes learned from neighbor\n") |
| 8260 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8261 | struct peer *peer; |
| 8262 | |
| 8263 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8264 | if (! peer) |
| 8265 | return CMD_WARNING; |
| 8266 | |
| 8267 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8268 | bgp_show_type_neighbor); |
| 8269 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8270 | |
| 8271 | ALIAS (show_bgp_view_neighbor_flap, |
| 8272 | show_bgp_neighbor_flap_cmd, |
| 8273 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8274 | SHOW_STR |
| 8275 | BGP_STR |
| 8276 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8277 | "Neighbor to display information about\n" |
| 8278 | "Neighbor to display information about\n" |
| 8279 | "Display flap statistics of the routes learned from neighbor\n") |
| 8280 | |
| 8281 | ALIAS (show_bgp_view_neighbor_flap, |
| 8282 | show_bgp_ipv6_neighbor_flap_cmd, |
| 8283 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8284 | SHOW_STR |
| 8285 | BGP_STR |
| 8286 | "Address family\n" |
| 8287 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8288 | "Neighbor to display information about\n" |
| 8289 | "Neighbor to display information about\n" |
| 8290 | "Display flap statistics of the routes learned from neighbor\n") |
| 8291 | |
| 8292 | ALIAS (show_bgp_view_neighbor_damp, |
| 8293 | show_bgp_neighbor_damp_cmd, |
| 8294 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8295 | SHOW_STR |
| 8296 | BGP_STR |
| 8297 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8298 | "Neighbor to display information about\n" |
| 8299 | "Neighbor to display information about\n" |
| 8300 | "Display the dampened routes received from neighbor\n") |
| 8301 | |
| 8302 | ALIAS (show_bgp_view_neighbor_damp, |
| 8303 | show_bgp_ipv6_neighbor_damp_cmd, |
| 8304 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8305 | SHOW_STR |
| 8306 | BGP_STR |
| 8307 | "Address family\n" |
| 8308 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8309 | "Neighbor to display information about\n" |
| 8310 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame^] | 8311 | "Display the dampened routes received from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8312 | #endif /* HAVE_IPV6 */ |
| 8313 | |
| 8314 | struct bgp_table *bgp_distance_table; |
| 8315 | |
| 8316 | struct bgp_distance |
| 8317 | { |
| 8318 | /* Distance value for the IP source prefix. */ |
| 8319 | u_char distance; |
| 8320 | |
| 8321 | /* Name of the access-list to be matched. */ |
| 8322 | char *access_list; |
| 8323 | }; |
| 8324 | |
| 8325 | struct bgp_distance * |
| 8326 | bgp_distance_new () |
| 8327 | { |
| 8328 | struct bgp_distance *new; |
| 8329 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 8330 | memset (new, 0, sizeof (struct bgp_distance)); |
| 8331 | return new; |
| 8332 | } |
| 8333 | |
| 8334 | void |
| 8335 | bgp_distance_free (struct bgp_distance *bdistance) |
| 8336 | { |
| 8337 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 8338 | } |
| 8339 | |
| 8340 | int |
| 8341 | bgp_distance_set (struct vty *vty, char *distance_str, char *ip_str, |
| 8342 | char *access_list_str) |
| 8343 | { |
| 8344 | int ret; |
| 8345 | struct prefix_ipv4 p; |
| 8346 | u_char distance; |
| 8347 | struct bgp_node *rn; |
| 8348 | struct bgp_distance *bdistance; |
| 8349 | |
| 8350 | ret = str2prefix_ipv4 (ip_str, &p); |
| 8351 | if (ret == 0) |
| 8352 | { |
| 8353 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 8354 | return CMD_WARNING; |
| 8355 | } |
| 8356 | |
| 8357 | distance = atoi (distance_str); |
| 8358 | |
| 8359 | /* Get BGP distance node. */ |
| 8360 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 8361 | if (rn->info) |
| 8362 | { |
| 8363 | bdistance = rn->info; |
| 8364 | bgp_unlock_node (rn); |
| 8365 | } |
| 8366 | else |
| 8367 | { |
| 8368 | bdistance = bgp_distance_new (); |
| 8369 | rn->info = bdistance; |
| 8370 | } |
| 8371 | |
| 8372 | /* Set distance value. */ |
| 8373 | bdistance->distance = distance; |
| 8374 | |
| 8375 | /* Reset access-list configuration. */ |
| 8376 | if (bdistance->access_list) |
| 8377 | { |
| 8378 | free (bdistance->access_list); |
| 8379 | bdistance->access_list = NULL; |
| 8380 | } |
| 8381 | if (access_list_str) |
| 8382 | bdistance->access_list = strdup (access_list_str); |
| 8383 | |
| 8384 | return CMD_SUCCESS; |
| 8385 | } |
| 8386 | |
| 8387 | int |
| 8388 | bgp_distance_unset (struct vty *vty, char *distance_str, char *ip_str, |
| 8389 | char *access_list_str) |
| 8390 | { |
| 8391 | int ret; |
| 8392 | struct prefix_ipv4 p; |
| 8393 | u_char distance; |
| 8394 | struct bgp_node *rn; |
| 8395 | struct bgp_distance *bdistance; |
| 8396 | |
| 8397 | ret = str2prefix_ipv4 (ip_str, &p); |
| 8398 | if (ret == 0) |
| 8399 | { |
| 8400 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 8401 | return CMD_WARNING; |
| 8402 | } |
| 8403 | |
| 8404 | distance = atoi (distance_str); |
| 8405 | |
| 8406 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 8407 | if (! rn) |
| 8408 | { |
| 8409 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 8410 | return CMD_WARNING; |
| 8411 | } |
| 8412 | |
| 8413 | bdistance = rn->info; |
| 8414 | |
| 8415 | if (bdistance->access_list) |
| 8416 | free (bdistance->access_list); |
| 8417 | bgp_distance_free (bdistance); |
| 8418 | |
| 8419 | rn->info = NULL; |
| 8420 | bgp_unlock_node (rn); |
| 8421 | bgp_unlock_node (rn); |
| 8422 | |
| 8423 | return CMD_SUCCESS; |
| 8424 | } |
| 8425 | |
| 8426 | void |
| 8427 | bgp_distance_reset () |
| 8428 | { |
| 8429 | struct bgp_node *rn; |
| 8430 | struct bgp_distance *bdistance; |
| 8431 | |
| 8432 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 8433 | if ((bdistance = rn->info) != NULL) |
| 8434 | { |
| 8435 | if (bdistance->access_list) |
| 8436 | free (bdistance->access_list); |
| 8437 | bgp_distance_free (bdistance); |
| 8438 | rn->info = NULL; |
| 8439 | bgp_unlock_node (rn); |
| 8440 | } |
| 8441 | } |
| 8442 | |
| 8443 | /* Apply BGP information to distance method. */ |
| 8444 | u_char |
| 8445 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 8446 | { |
| 8447 | struct bgp_node *rn; |
| 8448 | struct prefix_ipv4 q; |
| 8449 | struct peer *peer; |
| 8450 | struct bgp_distance *bdistance; |
| 8451 | struct access_list *alist; |
| 8452 | struct bgp_static *bgp_static; |
| 8453 | |
| 8454 | if (! bgp) |
| 8455 | return 0; |
| 8456 | |
| 8457 | if (p->family != AF_INET) |
| 8458 | return 0; |
| 8459 | |
| 8460 | peer = rinfo->peer; |
| 8461 | |
| 8462 | if (peer->su.sa.sa_family != AF_INET) |
| 8463 | return 0; |
| 8464 | |
| 8465 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 8466 | q.family = AF_INET; |
| 8467 | q.prefix = peer->su.sin.sin_addr; |
| 8468 | q.prefixlen = IPV4_MAX_BITLEN; |
| 8469 | |
| 8470 | /* Check source address. */ |
| 8471 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 8472 | if (rn) |
| 8473 | { |
| 8474 | bdistance = rn->info; |
| 8475 | bgp_unlock_node (rn); |
| 8476 | |
| 8477 | if (bdistance->access_list) |
| 8478 | { |
| 8479 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 8480 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 8481 | return bdistance->distance; |
| 8482 | } |
| 8483 | else |
| 8484 | return bdistance->distance; |
| 8485 | } |
| 8486 | |
| 8487 | /* Backdoor check. */ |
| 8488 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 8489 | if (rn) |
| 8490 | { |
| 8491 | bgp_static = rn->info; |
| 8492 | bgp_unlock_node (rn); |
| 8493 | |
| 8494 | if (bgp_static->backdoor) |
| 8495 | { |
| 8496 | if (bgp->distance_local) |
| 8497 | return bgp->distance_local; |
| 8498 | else |
| 8499 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 8500 | } |
| 8501 | } |
| 8502 | |
| 8503 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 8504 | { |
| 8505 | if (bgp->distance_ebgp) |
| 8506 | return bgp->distance_ebgp; |
| 8507 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 8508 | } |
| 8509 | else |
| 8510 | { |
| 8511 | if (bgp->distance_ibgp) |
| 8512 | return bgp->distance_ibgp; |
| 8513 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 8514 | } |
| 8515 | } |
| 8516 | |
| 8517 | DEFUN (bgp_distance, |
| 8518 | bgp_distance_cmd, |
| 8519 | "distance bgp <1-255> <1-255> <1-255>", |
| 8520 | "Define an administrative distance\n" |
| 8521 | "BGP distance\n" |
| 8522 | "Distance for routes external to the AS\n" |
| 8523 | "Distance for routes internal to the AS\n" |
| 8524 | "Distance for local routes\n") |
| 8525 | { |
| 8526 | struct bgp *bgp; |
| 8527 | |
| 8528 | bgp = vty->index; |
| 8529 | |
| 8530 | bgp->distance_ebgp = atoi (argv[0]); |
| 8531 | bgp->distance_ibgp = atoi (argv[1]); |
| 8532 | bgp->distance_local = atoi (argv[2]); |
| 8533 | return CMD_SUCCESS; |
| 8534 | } |
| 8535 | |
| 8536 | DEFUN (no_bgp_distance, |
| 8537 | no_bgp_distance_cmd, |
| 8538 | "no distance bgp <1-255> <1-255> <1-255>", |
| 8539 | NO_STR |
| 8540 | "Define an administrative distance\n" |
| 8541 | "BGP distance\n" |
| 8542 | "Distance for routes external to the AS\n" |
| 8543 | "Distance for routes internal to the AS\n" |
| 8544 | "Distance for local routes\n") |
| 8545 | { |
| 8546 | struct bgp *bgp; |
| 8547 | |
| 8548 | bgp = vty->index; |
| 8549 | |
| 8550 | bgp->distance_ebgp= 0; |
| 8551 | bgp->distance_ibgp = 0; |
| 8552 | bgp->distance_local = 0; |
| 8553 | return CMD_SUCCESS; |
| 8554 | } |
| 8555 | |
| 8556 | ALIAS (no_bgp_distance, |
| 8557 | no_bgp_distance2_cmd, |
| 8558 | "no distance bgp", |
| 8559 | NO_STR |
| 8560 | "Define an administrative distance\n" |
| 8561 | "BGP distance\n") |
| 8562 | |
| 8563 | DEFUN (bgp_distance_source, |
| 8564 | bgp_distance_source_cmd, |
| 8565 | "distance <1-255> A.B.C.D/M", |
| 8566 | "Define an administrative distance\n" |
| 8567 | "Administrative distance\n" |
| 8568 | "IP source prefix\n") |
| 8569 | { |
| 8570 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 8571 | return CMD_SUCCESS; |
| 8572 | } |
| 8573 | |
| 8574 | DEFUN (no_bgp_distance_source, |
| 8575 | no_bgp_distance_source_cmd, |
| 8576 | "no distance <1-255> A.B.C.D/M", |
| 8577 | NO_STR |
| 8578 | "Define an administrative distance\n" |
| 8579 | "Administrative distance\n" |
| 8580 | "IP source prefix\n") |
| 8581 | { |
| 8582 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 8583 | return CMD_SUCCESS; |
| 8584 | } |
| 8585 | |
| 8586 | DEFUN (bgp_distance_source_access_list, |
| 8587 | bgp_distance_source_access_list_cmd, |
| 8588 | "distance <1-255> A.B.C.D/M WORD", |
| 8589 | "Define an administrative distance\n" |
| 8590 | "Administrative distance\n" |
| 8591 | "IP source prefix\n" |
| 8592 | "Access list name\n") |
| 8593 | { |
| 8594 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 8595 | return CMD_SUCCESS; |
| 8596 | } |
| 8597 | |
| 8598 | DEFUN (no_bgp_distance_source_access_list, |
| 8599 | no_bgp_distance_source_access_list_cmd, |
| 8600 | "no distance <1-255> A.B.C.D/M WORD", |
| 8601 | NO_STR |
| 8602 | "Define an administrative distance\n" |
| 8603 | "Administrative distance\n" |
| 8604 | "IP source prefix\n" |
| 8605 | "Access list name\n") |
| 8606 | { |
| 8607 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 8608 | return CMD_SUCCESS; |
| 8609 | } |
| 8610 | |
| 8611 | DEFUN (bgp_damp_set, |
| 8612 | bgp_damp_set_cmd, |
| 8613 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 8614 | "BGP Specific commands\n" |
| 8615 | "Enable route-flap dampening\n" |
| 8616 | "Half-life time for the penalty\n" |
| 8617 | "Value to start reusing a route\n" |
| 8618 | "Value to start suppressing a route\n" |
| 8619 | "Maximum duration to suppress a stable route\n") |
| 8620 | { |
| 8621 | struct bgp *bgp; |
| 8622 | int half = DEFAULT_HALF_LIFE * 60; |
| 8623 | int reuse = DEFAULT_REUSE; |
| 8624 | int suppress = DEFAULT_SUPPRESS; |
| 8625 | int max = 4 * half; |
| 8626 | |
| 8627 | if (argc == 4) |
| 8628 | { |
| 8629 | half = atoi (argv[0]) * 60; |
| 8630 | reuse = atoi (argv[1]); |
| 8631 | suppress = atoi (argv[2]); |
| 8632 | max = atoi (argv[3]) * 60; |
| 8633 | } |
| 8634 | else if (argc == 1) |
| 8635 | { |
| 8636 | half = atoi (argv[0]) * 60; |
| 8637 | max = 4 * half; |
| 8638 | } |
| 8639 | |
| 8640 | bgp = vty->index; |
| 8641 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 8642 | half, reuse, suppress, max); |
| 8643 | } |
| 8644 | |
| 8645 | ALIAS (bgp_damp_set, |
| 8646 | bgp_damp_set2_cmd, |
| 8647 | "bgp dampening <1-45>", |
| 8648 | "BGP Specific commands\n" |
| 8649 | "Enable route-flap dampening\n" |
| 8650 | "Half-life time for the penalty\n") |
| 8651 | |
| 8652 | ALIAS (bgp_damp_set, |
| 8653 | bgp_damp_set3_cmd, |
| 8654 | "bgp dampening", |
| 8655 | "BGP Specific commands\n" |
| 8656 | "Enable route-flap dampening\n") |
| 8657 | |
| 8658 | DEFUN (bgp_damp_unset, |
| 8659 | bgp_damp_unset_cmd, |
| 8660 | "no bgp dampening", |
| 8661 | NO_STR |
| 8662 | "BGP Specific commands\n" |
| 8663 | "Enable route-flap dampening\n") |
| 8664 | { |
| 8665 | struct bgp *bgp; |
| 8666 | |
| 8667 | bgp = vty->index; |
| 8668 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 8669 | } |
| 8670 | |
| 8671 | ALIAS (bgp_damp_unset, |
| 8672 | bgp_damp_unset2_cmd, |
| 8673 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 8674 | NO_STR |
| 8675 | "BGP Specific commands\n" |
| 8676 | "Enable route-flap dampening\n" |
| 8677 | "Half-life time for the penalty\n" |
| 8678 | "Value to start reusing a route\n" |
| 8679 | "Value to start suppressing a route\n" |
| 8680 | "Maximum duration to suppress a stable route\n") |
| 8681 | |
| 8682 | DEFUN (show_ip_bgp_dampened_paths, |
| 8683 | show_ip_bgp_dampened_paths_cmd, |
| 8684 | "show ip bgp dampened-paths", |
| 8685 | SHOW_STR |
| 8686 | IP_STR |
| 8687 | BGP_STR |
| 8688 | "Display paths suppressed due to dampening\n") |
| 8689 | { |
| 8690 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths); |
| 8691 | } |
| 8692 | |
| 8693 | DEFUN (show_ip_bgp_flap_statistics, |
| 8694 | show_ip_bgp_flap_statistics_cmd, |
| 8695 | "show ip bgp flap-statistics", |
| 8696 | SHOW_STR |
| 8697 | IP_STR |
| 8698 | BGP_STR |
| 8699 | "Display flap statistics of routes\n") |
| 8700 | { |
| 8701 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_statistics); |
| 8702 | } |
| 8703 | |
| 8704 | /* Display specified route of BGP table. */ |
| 8705 | int |
| 8706 | bgp_clear_damp_route (struct vty *vty, char *view_name, char *ip_str, |
| 8707 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 8708 | int prefix_check) |
| 8709 | { |
| 8710 | int ret; |
| 8711 | struct prefix match; |
| 8712 | struct bgp_node *rn; |
| 8713 | struct bgp_node *rm; |
| 8714 | struct bgp_info *ri; |
| 8715 | struct bgp_info *ri_temp; |
| 8716 | struct bgp *bgp; |
| 8717 | struct bgp_table *table; |
| 8718 | |
| 8719 | /* BGP structure lookup. */ |
| 8720 | if (view_name) |
| 8721 | { |
| 8722 | bgp = bgp_lookup_by_name (view_name); |
| 8723 | if (bgp == NULL) |
| 8724 | { |
| 8725 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8726 | return CMD_WARNING; |
| 8727 | } |
| 8728 | } |
| 8729 | else |
| 8730 | { |
| 8731 | bgp = bgp_get_default (); |
| 8732 | if (bgp == NULL) |
| 8733 | { |
| 8734 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 8735 | return CMD_WARNING; |
| 8736 | } |
| 8737 | } |
| 8738 | |
| 8739 | /* Check IP address argument. */ |
| 8740 | ret = str2prefix (ip_str, &match); |
| 8741 | if (! ret) |
| 8742 | { |
| 8743 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 8744 | return CMD_WARNING; |
| 8745 | } |
| 8746 | |
| 8747 | match.family = afi2family (afi); |
| 8748 | |
| 8749 | if (safi == SAFI_MPLS_VPN) |
| 8750 | { |
| 8751 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 8752 | { |
| 8753 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 8754 | continue; |
| 8755 | |
| 8756 | if ((table = rn->info) != NULL) |
| 8757 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 8758 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 8759 | { |
| 8760 | ri = rm->info; |
| 8761 | while (ri) |
| 8762 | { |
| 8763 | if (ri->damp_info) |
| 8764 | { |
| 8765 | ri_temp = ri->next; |
| 8766 | bgp_damp_info_free (ri->damp_info, 1); |
| 8767 | ri = ri_temp; |
| 8768 | } |
| 8769 | else |
| 8770 | ri = ri->next; |
| 8771 | } |
| 8772 | } |
| 8773 | } |
| 8774 | } |
| 8775 | else |
| 8776 | { |
| 8777 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 8778 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 8779 | { |
| 8780 | ri = rn->info; |
| 8781 | while (ri) |
| 8782 | { |
| 8783 | if (ri->damp_info) |
| 8784 | { |
| 8785 | ri_temp = ri->next; |
| 8786 | bgp_damp_info_free (ri->damp_info, 1); |
| 8787 | ri = ri_temp; |
| 8788 | } |
| 8789 | else |
| 8790 | ri = ri->next; |
| 8791 | } |
| 8792 | } |
| 8793 | } |
| 8794 | |
| 8795 | return CMD_SUCCESS; |
| 8796 | } |
| 8797 | |
| 8798 | DEFUN (clear_ip_bgp_dampening, |
| 8799 | clear_ip_bgp_dampening_cmd, |
| 8800 | "clear ip bgp dampening", |
| 8801 | CLEAR_STR |
| 8802 | IP_STR |
| 8803 | BGP_STR |
| 8804 | "Clear route flap dampening information\n") |
| 8805 | { |
| 8806 | bgp_damp_info_clean (); |
| 8807 | return CMD_SUCCESS; |
| 8808 | } |
| 8809 | |
| 8810 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 8811 | clear_ip_bgp_dampening_prefix_cmd, |
| 8812 | "clear ip bgp dampening A.B.C.D/M", |
| 8813 | CLEAR_STR |
| 8814 | IP_STR |
| 8815 | BGP_STR |
| 8816 | "Clear route flap dampening information\n" |
| 8817 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8818 | { |
| 8819 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 8820 | SAFI_UNICAST, NULL, 1); |
| 8821 | } |
| 8822 | |
| 8823 | DEFUN (clear_ip_bgp_dampening_address, |
| 8824 | clear_ip_bgp_dampening_address_cmd, |
| 8825 | "clear ip bgp dampening A.B.C.D", |
| 8826 | CLEAR_STR |
| 8827 | IP_STR |
| 8828 | BGP_STR |
| 8829 | "Clear route flap dampening information\n" |
| 8830 | "Network to clear damping information\n") |
| 8831 | { |
| 8832 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 8833 | SAFI_UNICAST, NULL, 0); |
| 8834 | } |
| 8835 | |
| 8836 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 8837 | clear_ip_bgp_dampening_address_mask_cmd, |
| 8838 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 8839 | CLEAR_STR |
| 8840 | IP_STR |
| 8841 | BGP_STR |
| 8842 | "Clear route flap dampening information\n" |
| 8843 | "Network to clear damping information\n" |
| 8844 | "Network mask\n") |
| 8845 | { |
| 8846 | int ret; |
| 8847 | char prefix_str[BUFSIZ]; |
| 8848 | |
| 8849 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 8850 | if (! ret) |
| 8851 | { |
| 8852 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 8853 | return CMD_WARNING; |
| 8854 | } |
| 8855 | |
| 8856 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 8857 | SAFI_UNICAST, NULL, 0); |
| 8858 | } |
| 8859 | |
| 8860 | int |
| 8861 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 8862 | afi_t afi, safi_t safi, int *write) |
| 8863 | { |
| 8864 | struct bgp_node *prn; |
| 8865 | struct bgp_node *rn; |
| 8866 | struct bgp_table *table; |
| 8867 | struct prefix *p; |
| 8868 | struct prefix_rd *prd; |
| 8869 | struct bgp_static *bgp_static; |
| 8870 | u_int32_t label; |
| 8871 | char buf[SU_ADDRSTRLEN]; |
| 8872 | char rdbuf[RD_ADDRSTRLEN]; |
| 8873 | |
| 8874 | /* Network configuration. */ |
| 8875 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 8876 | if ((table = prn->info) != NULL) |
| 8877 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 8878 | if ((bgp_static = rn->info) != NULL) |
| 8879 | { |
| 8880 | p = &rn->p; |
| 8881 | prd = (struct prefix_rd *) &prn->p; |
| 8882 | |
| 8883 | /* "address-family" display. */ |
| 8884 | bgp_config_write_family_header (vty, afi, safi, write); |
| 8885 | |
| 8886 | /* "network" configuration display. */ |
| 8887 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 8888 | label = decode_label (bgp_static->tag); |
| 8889 | |
| 8890 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 8891 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 8892 | p->prefixlen, |
| 8893 | rdbuf, label); |
| 8894 | vty_out (vty, "%s", VTY_NEWLINE); |
| 8895 | } |
| 8896 | return 0; |
| 8897 | } |
| 8898 | |
| 8899 | /* Configuration of static route announcement and aggregate |
| 8900 | information. */ |
| 8901 | int |
| 8902 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 8903 | afi_t afi, safi_t safi, int *write) |
| 8904 | { |
| 8905 | struct bgp_node *rn; |
| 8906 | struct prefix *p; |
| 8907 | struct bgp_static *bgp_static; |
| 8908 | struct bgp_aggregate *bgp_aggregate; |
| 8909 | char buf[SU_ADDRSTRLEN]; |
| 8910 | |
| 8911 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 8912 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 8913 | |
| 8914 | /* Network configuration. */ |
| 8915 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 8916 | if ((bgp_static = rn->info) != NULL) |
| 8917 | { |
| 8918 | p = &rn->p; |
| 8919 | |
| 8920 | /* "address-family" display. */ |
| 8921 | bgp_config_write_family_header (vty, afi, safi, write); |
| 8922 | |
| 8923 | /* "network" configuration display. */ |
| 8924 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 8925 | { |
| 8926 | u_int32_t destination; |
| 8927 | struct in_addr netmask; |
| 8928 | |
| 8929 | destination = ntohl (p->u.prefix4.s_addr); |
| 8930 | masklen2ip (p->prefixlen, &netmask); |
| 8931 | vty_out (vty, " network %s", |
| 8932 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 8933 | |
| 8934 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 8935 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 8936 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 8937 | || p->u.prefix4.s_addr == 0) |
| 8938 | { |
| 8939 | /* Natural mask is not display. */ |
| 8940 | } |
| 8941 | else |
| 8942 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 8943 | } |
| 8944 | else |
| 8945 | { |
| 8946 | vty_out (vty, " network %s/%d", |
| 8947 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 8948 | p->prefixlen); |
| 8949 | } |
| 8950 | |
| 8951 | if (bgp_static->rmap.name) |
| 8952 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 8953 | else if (bgp_static->backdoor) |
| 8954 | vty_out (vty, " backdoor"); |
| 8955 | |
| 8956 | vty_out (vty, "%s", VTY_NEWLINE); |
| 8957 | } |
| 8958 | |
| 8959 | /* Aggregate-address configuration. */ |
| 8960 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 8961 | if ((bgp_aggregate = rn->info) != NULL) |
| 8962 | { |
| 8963 | p = &rn->p; |
| 8964 | |
| 8965 | /* "address-family" display. */ |
| 8966 | bgp_config_write_family_header (vty, afi, safi, write); |
| 8967 | |
| 8968 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 8969 | { |
| 8970 | struct in_addr netmask; |
| 8971 | |
| 8972 | masklen2ip (p->prefixlen, &netmask); |
| 8973 | vty_out (vty, " aggregate-address %s %s", |
| 8974 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 8975 | inet_ntoa (netmask)); |
| 8976 | } |
| 8977 | else |
| 8978 | { |
| 8979 | vty_out (vty, " aggregate-address %s/%d", |
| 8980 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 8981 | p->prefixlen); |
| 8982 | } |
| 8983 | |
| 8984 | if (bgp_aggregate->as_set) |
| 8985 | vty_out (vty, " as-set"); |
| 8986 | |
| 8987 | if (bgp_aggregate->summary_only) |
| 8988 | vty_out (vty, " summary-only"); |
| 8989 | |
| 8990 | vty_out (vty, "%s", VTY_NEWLINE); |
| 8991 | } |
| 8992 | |
| 8993 | return 0; |
| 8994 | } |
| 8995 | |
| 8996 | int |
| 8997 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 8998 | { |
| 8999 | struct bgp_node *rn; |
| 9000 | struct bgp_distance *bdistance; |
| 9001 | |
| 9002 | /* Distance configuration. */ |
| 9003 | if (bgp->distance_ebgp |
| 9004 | && bgp->distance_ibgp |
| 9005 | && bgp->distance_local |
| 9006 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 9007 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 9008 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 9009 | vty_out (vty, " distance bgp %d %d %d%s", |
| 9010 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 9011 | VTY_NEWLINE); |
| 9012 | |
| 9013 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 9014 | if ((bdistance = rn->info) != NULL) |
| 9015 | { |
| 9016 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 9017 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 9018 | bdistance->access_list ? bdistance->access_list : "", |
| 9019 | VTY_NEWLINE); |
| 9020 | } |
| 9021 | |
| 9022 | return 0; |
| 9023 | } |
| 9024 | |
| 9025 | /* Allocate routing table structure and install commands. */ |
| 9026 | void |
| 9027 | bgp_route_init () |
| 9028 | { |
| 9029 | /* Init BGP distance table. */ |
| 9030 | bgp_distance_table = bgp_table_init (); |
| 9031 | |
| 9032 | /* IPv4 BGP commands. */ |
| 9033 | install_element (BGP_NODE, &bgp_network_cmd); |
| 9034 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 9035 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 9036 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 9037 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 9038 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 9039 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 9040 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 9041 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 9042 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 9043 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 9044 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 9045 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 9046 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 9047 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 9048 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 9049 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 9050 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 9051 | |
| 9052 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 9053 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 9054 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 9055 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 9056 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 9057 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 9058 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 9059 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 9060 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 9061 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 9062 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 9063 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 9064 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 9065 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 9066 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 9067 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 9068 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 9069 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 9070 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 9071 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 9072 | |
| 9073 | /* IPv4 unicast configuration. */ |
| 9074 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 9075 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 9076 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 9077 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 9078 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 9079 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 9080 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 9081 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 9082 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 9083 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 9084 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 9085 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 9086 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 9087 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 9088 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 9089 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 9090 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 9091 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 9092 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 9093 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 9094 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 9095 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 9096 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 9097 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 9098 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 9099 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 9100 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 9101 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 9102 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 9103 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 9104 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 9105 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 9106 | |
| 9107 | /* IPv4 multicast configuration. */ |
| 9108 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 9109 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 9110 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 9111 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 9112 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 9113 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 9114 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 9115 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 9116 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 9117 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 9118 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 9119 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 9120 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 9121 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 9122 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 9123 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 9124 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 9125 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 9126 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 9127 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 9128 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 9129 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 9130 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 9131 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 9132 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 9133 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 9134 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 9135 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 9136 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 9137 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 9138 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 9139 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 9140 | |
| 9141 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 9142 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 9143 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 9144 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 9145 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 9146 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 9147 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 9148 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 9149 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 9150 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 9151 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 9152 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 9153 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 9154 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 9155 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 9156 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 9157 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 9158 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 9159 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 9160 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 9161 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 9162 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 9163 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 9164 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 9165 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 9166 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 9167 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 9168 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 9169 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 9170 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 9171 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 9172 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 9173 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 9174 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 9175 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 9176 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 9177 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 9178 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 9179 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 9180 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 9181 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 9182 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 9183 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 9184 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 9185 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 9186 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 9187 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 9188 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 9189 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 9190 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 9191 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 9192 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 9193 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 9194 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 9195 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 9196 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 9197 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 9198 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 9199 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 9200 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 9201 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 9202 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 9203 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 9204 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 9205 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 9206 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 9207 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 9208 | |
| 9209 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 9210 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 9211 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 9212 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 9213 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 9214 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 9215 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 9216 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 9217 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 9218 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 9219 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 9220 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 9221 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 9222 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 9223 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 9224 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 9225 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 9226 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 9227 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 9228 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 9229 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 9230 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 9231 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 9232 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 9233 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 9234 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 9235 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 9236 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 9237 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 9238 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 9239 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 9240 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 9241 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 9242 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 9243 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 9244 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 9245 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 9246 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 9247 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 9248 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 9249 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 9250 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 9251 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 9252 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 9253 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 9254 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 9255 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 9256 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 9257 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 9258 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 9259 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 9260 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 9261 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 9262 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 9263 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 9264 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 9265 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 9266 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 9267 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 9268 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 9269 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 9270 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 9271 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 9272 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 9273 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 9274 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 9275 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 9276 | |
| 9277 | /* BGP dampening clear commands */ |
| 9278 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 9279 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 9280 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 9281 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 9282 | |
| 9283 | #ifdef HAVE_IPV6 |
| 9284 | /* New config IPv6 BGP commands. */ |
| 9285 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 9286 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 9287 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 9288 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 9289 | |
| 9290 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 9291 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 9292 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 9293 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 9294 | |
| 9295 | /* Old config IPv6 BGP commands. */ |
| 9296 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 9297 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 9298 | |
| 9299 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 9300 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 9301 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 9302 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 9303 | |
| 9304 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 9305 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 9306 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 9307 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 9308 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 9309 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 9310 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 9311 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 9312 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 9313 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 9314 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 9315 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 9316 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 9317 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 9318 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 9319 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 9320 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 9321 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 9322 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 9323 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 9324 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 9325 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 9326 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 9327 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 9328 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 9329 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 9330 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 9331 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 9332 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 9333 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 9334 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 9335 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 9336 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 9337 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 9338 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 9339 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 9340 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 9341 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 9342 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 9343 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 9344 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 9345 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 9346 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 9347 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 9348 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 9349 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9350 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 9351 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 9352 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 9353 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
| 9354 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 9355 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 9356 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 9357 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 9358 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 9359 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 9360 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 9361 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 9362 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 9363 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 9364 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 9365 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 9366 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 9367 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 9368 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 9369 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 9370 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 9371 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9372 | |
| 9373 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 9374 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 9375 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 9376 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 9377 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 9378 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 9379 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 9380 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 9381 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 9382 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 9383 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 9384 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 9385 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 9386 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 9387 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 9388 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 9389 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 9390 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 9391 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 9392 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 9393 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 9394 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 9395 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 9396 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 9397 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 9398 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 9399 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 9400 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 9401 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 9402 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 9403 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 9404 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 9405 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 9406 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 9407 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 9408 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 9409 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 9410 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 9411 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 9412 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 9413 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 9414 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 9415 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 9416 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 9417 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 9418 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9419 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 9420 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 9421 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 9422 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
| 9423 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 9424 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 9425 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 9426 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 9427 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 9428 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 9429 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 9430 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 9431 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 9432 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 9433 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 9434 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 9435 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 9436 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 9437 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 9438 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 9439 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 9440 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9441 | |
| 9442 | /* old command */ |
| 9443 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 9444 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 9445 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 9446 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 9447 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 9448 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 9449 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 9450 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 9451 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 9452 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 9453 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 9454 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 9455 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 9456 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 9457 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 9458 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 9459 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 9460 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 9461 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 9462 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 9463 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 9464 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 9465 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 9466 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 9467 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 9468 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 9469 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 9470 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 9471 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 9472 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 9473 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 9474 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 9475 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 9476 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 9477 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 9478 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9479 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9480 | /* old command */ |
| 9481 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 9482 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 9483 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 9484 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 9485 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 9486 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 9487 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 9488 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 9489 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 9490 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 9491 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 9492 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 9493 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 9494 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 9495 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 9496 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 9497 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 9498 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 9499 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 9500 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 9501 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 9502 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 9503 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 9504 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 9505 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 9506 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 9507 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 9508 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 9509 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 9510 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 9511 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 9512 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 9513 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 9514 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 9515 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 9516 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 9517 | |
| 9518 | /* old command */ |
| 9519 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 9520 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 9521 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 9522 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 9523 | |
| 9524 | /* old command */ |
| 9525 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 9526 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 9527 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 9528 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 9529 | |
| 9530 | /* old command */ |
| 9531 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 9532 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 9533 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 9534 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 9535 | #endif /* HAVE_IPV6 */ |
| 9536 | |
| 9537 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 9538 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 9539 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 9540 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 9541 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 9542 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 9543 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 9544 | |
| 9545 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 9546 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 9547 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 9548 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 9549 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 9550 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 9551 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 9552 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 9553 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 9554 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 9555 | } |