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)) |
| 149 | return 4294967295ul; |
| 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 |
| 4561 | bgp_show (struct vty *vty, char *view_name, afi_t afi, safi_t safi, |
| 4562 | enum bgp_show_type type) |
| 4563 | { |
| 4564 | struct bgp *bgp; |
| 4565 | struct bgp_info *ri; |
| 4566 | struct bgp_node *rn; |
| 4567 | struct bgp_table *table; |
| 4568 | int header = 1; |
| 4569 | int count; |
| 4570 | int limit; |
| 4571 | int display; |
| 4572 | |
| 4573 | limit = ((vty->lines == 0) |
| 4574 | ? 10 : (vty->lines > 0 |
| 4575 | ? vty->lines : vty->height - 2)); |
| 4576 | limit = limit > 0 ? limit : 2; |
| 4577 | |
| 4578 | /* BGP structure lookup. */ |
| 4579 | if (view_name) |
| 4580 | { |
| 4581 | bgp = bgp_lookup_by_name (view_name); |
| 4582 | if (bgp == NULL) |
| 4583 | { |
| 4584 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 4585 | return CMD_WARNING; |
| 4586 | } |
| 4587 | } |
| 4588 | else |
| 4589 | { |
| 4590 | bgp = bgp_get_default (); |
| 4591 | if (bgp == NULL) |
| 4592 | { |
| 4593 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 4594 | return CMD_WARNING; |
| 4595 | } |
| 4596 | } |
| 4597 | |
| 4598 | count = 0; |
| 4599 | |
| 4600 | /* This is first entry point, so reset total line. */ |
| 4601 | vty->output_count = 0; |
| 4602 | vty->output_type = type; |
| 4603 | |
| 4604 | table = bgp->rib[afi][safi]; |
| 4605 | |
| 4606 | /* Start processing of routes. */ |
| 4607 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 4608 | if (rn->info != NULL) |
| 4609 | { |
| 4610 | display = 0; |
| 4611 | |
| 4612 | for (ri = rn->info; ri; ri = ri->next) |
| 4613 | { |
| 4614 | if (vty->output_type == bgp_show_type_flap_statistics |
| 4615 | || type == bgp_show_type_flap_address |
| 4616 | || type == bgp_show_type_flap_prefix |
| 4617 | || type == bgp_show_type_flap_cidr_only |
| 4618 | || type == bgp_show_type_flap_regexp |
| 4619 | || type == bgp_show_type_flap_filter_list |
| 4620 | || type == bgp_show_type_flap_prefix_list |
| 4621 | || type == bgp_show_type_flap_prefix_longer |
| 4622 | || type == bgp_show_type_flap_route_map |
| 4623 | || type == bgp_show_type_flap_neighbor |
| 4624 | || type == bgp_show_type_dampend_paths |
| 4625 | || type == bgp_show_type_damp_neighbor) |
| 4626 | { |
| 4627 | if (! ri->damp_info) |
| 4628 | continue; |
| 4629 | } |
| 4630 | if (type == bgp_show_type_regexp |
| 4631 | || type == bgp_show_type_flap_regexp) |
| 4632 | { |
| 4633 | regex_t *regex = vty->output_arg; |
| 4634 | |
| 4635 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 4636 | continue; |
| 4637 | } |
| 4638 | if (type == bgp_show_type_prefix_list |
| 4639 | || type == bgp_show_type_flap_prefix_list) |
| 4640 | { |
| 4641 | struct prefix_list *plist = vty->output_arg; |
| 4642 | |
| 4643 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 4644 | continue; |
| 4645 | } |
| 4646 | if (type == bgp_show_type_filter_list |
| 4647 | || type == bgp_show_type_flap_filter_list) |
| 4648 | { |
| 4649 | struct as_list *as_list = vty->output_arg; |
| 4650 | |
| 4651 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 4652 | continue; |
| 4653 | } |
| 4654 | if (type == bgp_show_type_route_map |
| 4655 | || type == bgp_show_type_flap_route_map) |
| 4656 | { |
| 4657 | struct route_map *rmap = vty->output_arg; |
| 4658 | struct bgp_info binfo; |
| 4659 | struct attr dummy_attr; |
| 4660 | int ret; |
| 4661 | |
| 4662 | dummy_attr = *ri->attr; |
| 4663 | binfo.peer = ri->peer; |
| 4664 | binfo.attr = &dummy_attr; |
| 4665 | |
| 4666 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 4667 | |
| 4668 | if (ret == RMAP_DENYMATCH) |
| 4669 | continue; |
| 4670 | } |
| 4671 | if (type == bgp_show_type_neighbor |
| 4672 | || type == bgp_show_type_flap_neighbor |
| 4673 | || type == bgp_show_type_damp_neighbor) |
| 4674 | { |
| 4675 | union sockunion *su = vty->output_arg; |
| 4676 | |
| 4677 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 4678 | continue; |
| 4679 | } |
| 4680 | if (type == bgp_show_type_cidr_only |
| 4681 | || type == bgp_show_type_flap_cidr_only) |
| 4682 | { |
| 4683 | u_int32_t destination; |
| 4684 | |
| 4685 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 4686 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 4687 | continue; |
| 4688 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 4689 | continue; |
| 4690 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 4691 | continue; |
| 4692 | } |
| 4693 | if (type == bgp_show_type_prefix_longer |
| 4694 | || type == bgp_show_type_flap_prefix_longer) |
| 4695 | { |
| 4696 | struct prefix *p = vty->output_arg; |
| 4697 | |
| 4698 | if (! prefix_match (p, &rn->p)) |
| 4699 | continue; |
| 4700 | } |
| 4701 | if (type == bgp_show_type_community_all) |
| 4702 | { |
| 4703 | if (! ri->attr->community) |
| 4704 | continue; |
| 4705 | } |
| 4706 | if (type == bgp_show_type_community) |
| 4707 | { |
| 4708 | struct community *com = vty->output_arg; |
| 4709 | |
| 4710 | if (! ri->attr->community || |
| 4711 | ! community_match (ri->attr->community, com)) |
| 4712 | continue; |
| 4713 | } |
| 4714 | if (type == bgp_show_type_community_exact) |
| 4715 | { |
| 4716 | struct community *com = vty->output_arg; |
| 4717 | |
| 4718 | if (! ri->attr->community || |
| 4719 | ! community_cmp (ri->attr->community, com)) |
| 4720 | continue; |
| 4721 | } |
| 4722 | if (type == bgp_show_type_community_list) |
| 4723 | { |
| 4724 | struct community_list *list = vty->output_arg; |
| 4725 | |
| 4726 | if (! community_list_match (ri->attr->community, list)) |
| 4727 | continue; |
| 4728 | } |
| 4729 | if (type == bgp_show_type_community_list_exact) |
| 4730 | { |
| 4731 | struct community_list *list = vty->output_arg; |
| 4732 | |
| 4733 | if (! community_list_exact_match (ri->attr->community, list)) |
| 4734 | continue; |
| 4735 | } |
| 4736 | if (type == bgp_show_type_flap_address |
| 4737 | || type == bgp_show_type_flap_prefix) |
| 4738 | { |
| 4739 | struct prefix *p = vty->output_arg; |
| 4740 | |
| 4741 | if (! prefix_match (&rn->p, p)) |
| 4742 | continue; |
| 4743 | |
| 4744 | if (type == bgp_show_type_flap_prefix) |
| 4745 | if (p->prefixlen != rn->p.prefixlen) |
| 4746 | continue; |
| 4747 | } |
| 4748 | if (type == bgp_show_type_dampend_paths |
| 4749 | || type == bgp_show_type_damp_neighbor) |
| 4750 | { |
| 4751 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 4752 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 4753 | continue; |
| 4754 | } |
| 4755 | |
| 4756 | if (header) |
| 4757 | { |
| 4758 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 4759 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 4760 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 4761 | if (type == bgp_show_type_dampend_paths |
| 4762 | || type == bgp_show_type_damp_neighbor) |
| 4763 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 4764 | else if (type == bgp_show_type_flap_statistics |
| 4765 | || type == bgp_show_type_flap_address |
| 4766 | || type == bgp_show_type_flap_prefix |
| 4767 | || type == bgp_show_type_flap_cidr_only |
| 4768 | || type == bgp_show_type_flap_regexp |
| 4769 | || type == bgp_show_type_flap_filter_list |
| 4770 | || type == bgp_show_type_flap_prefix_list |
| 4771 | || type == bgp_show_type_flap_prefix_longer |
| 4772 | || type == bgp_show_type_flap_route_map |
| 4773 | || type == bgp_show_type_flap_neighbor) |
| 4774 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 4775 | else |
| 4776 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 4777 | count += 5; |
| 4778 | header = 0; |
| 4779 | } |
| 4780 | |
| 4781 | if (type == bgp_show_type_dampend_paths |
| 4782 | || type == bgp_show_type_damp_neighbor) |
| 4783 | count += damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4784 | else if (type == bgp_show_type_flap_statistics |
| 4785 | || type == bgp_show_type_flap_address |
| 4786 | || type == bgp_show_type_flap_prefix |
| 4787 | || type == bgp_show_type_flap_cidr_only |
| 4788 | || type == bgp_show_type_flap_regexp |
| 4789 | || type == bgp_show_type_flap_filter_list |
| 4790 | || type == bgp_show_type_flap_prefix_list |
| 4791 | || type == bgp_show_type_flap_prefix_longer |
| 4792 | || type == bgp_show_type_flap_route_map |
| 4793 | || type == bgp_show_type_flap_neighbor) |
| 4794 | count += flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4795 | else |
| 4796 | count += route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
| 4797 | display++; |
| 4798 | } |
| 4799 | if (display) |
| 4800 | vty->output_count++; |
| 4801 | |
| 4802 | /* Remember current pointer then suspend output. */ |
| 4803 | if (count >= limit && vty->type != VTY_SHELL_SERV) |
| 4804 | { |
| 4805 | vty->status = VTY_START; |
| 4806 | vty->output_rn = bgp_route_next (rn); |
| 4807 | vty->output_func = bgp_show_callback; |
| 4808 | vty->output_type = type; |
| 4809 | |
| 4810 | return CMD_SUCCESS; |
| 4811 | } |
| 4812 | } |
| 4813 | |
| 4814 | /* No route is displayed */ |
| 4815 | if (vty->output_count == 0) |
| 4816 | { |
| 4817 | if (type == bgp_show_type_normal) |
| 4818 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 4819 | } |
| 4820 | else |
| 4821 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 4822 | VTY_NEWLINE, vty->output_count, VTY_NEWLINE); |
| 4823 | |
| 4824 | /* Clean up allocated resources. */ |
| 4825 | if (vty->output_clean) |
| 4826 | (*vty->output_clean) (vty); |
| 4827 | |
| 4828 | vty->status = VTY_START; |
| 4829 | vty->output_rn = NULL; |
| 4830 | vty->output_func = NULL; |
| 4831 | vty->output_clean = NULL; |
| 4832 | vty->output_arg = NULL; |
| 4833 | |
| 4834 | return CMD_SUCCESS; |
| 4835 | } |
| 4836 | |
| 4837 | /* Header of detailed BGP route information */ |
| 4838 | void |
| 4839 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 4840 | struct bgp_node *rn, |
| 4841 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 4842 | { |
| 4843 | struct bgp_info *ri; |
| 4844 | struct prefix *p; |
| 4845 | struct peer *peer; |
| 4846 | struct listnode *nn; |
| 4847 | char buf1[INET6_ADDRSTRLEN]; |
| 4848 | char buf2[INET6_ADDRSTRLEN]; |
| 4849 | int count = 0; |
| 4850 | int best = 0; |
| 4851 | int suppress = 0; |
| 4852 | int no_export = 0; |
| 4853 | int no_advertise = 0; |
| 4854 | int local_as = 0; |
| 4855 | int first = 0; |
| 4856 | |
| 4857 | p = &rn->p; |
| 4858 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 4859 | (safi == SAFI_MPLS_VPN ? |
| 4860 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 4861 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 4862 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 4863 | p->prefixlen, VTY_NEWLINE); |
| 4864 | |
| 4865 | for (ri = rn->info; ri; ri = ri->next) |
| 4866 | { |
| 4867 | count++; |
| 4868 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 4869 | { |
| 4870 | best = count; |
| 4871 | if (ri->suppress) |
| 4872 | suppress = 1; |
| 4873 | if (ri->attr->community != NULL) |
| 4874 | { |
| 4875 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 4876 | no_advertise = 1; |
| 4877 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 4878 | no_export = 1; |
| 4879 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 4880 | local_as = 1; |
| 4881 | } |
| 4882 | } |
| 4883 | } |
| 4884 | |
| 4885 | vty_out (vty, "Paths: (%d available", count); |
| 4886 | if (best) |
| 4887 | { |
| 4888 | vty_out (vty, ", best #%d", best); |
| 4889 | if (safi == SAFI_UNICAST) |
| 4890 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 4891 | } |
| 4892 | else |
| 4893 | vty_out (vty, ", no best path"); |
| 4894 | if (no_advertise) |
| 4895 | vty_out (vty, ", not advertised to any peer"); |
| 4896 | else if (no_export) |
| 4897 | vty_out (vty, ", not advertised to EBGP peer"); |
| 4898 | else if (local_as) |
| 4899 | vty_out (vty, ", not advertised outside local AS"); |
| 4900 | if (suppress) |
| 4901 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 4902 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 4903 | |
| 4904 | /* advertised peer */ |
| 4905 | LIST_LOOP (bgp->peer, peer, nn) |
| 4906 | { |
| 4907 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 4908 | { |
| 4909 | if (! first) |
| 4910 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 4911 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 4912 | first = 1; |
| 4913 | } |
| 4914 | } |
| 4915 | if (! first) |
| 4916 | vty_out (vty, " Not advertised to any peer"); |
| 4917 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4918 | } |
| 4919 | |
| 4920 | /* Display specified route of BGP table. */ |
| 4921 | int |
| 4922 | bgp_show_route (struct vty *vty, char *view_name, char *ip_str, |
| 4923 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 4924 | int prefix_check) |
| 4925 | { |
| 4926 | int ret; |
| 4927 | int header; |
| 4928 | int display = 0; |
| 4929 | struct prefix match; |
| 4930 | struct bgp_node *rn; |
| 4931 | struct bgp_node *rm; |
| 4932 | struct bgp_info *ri; |
| 4933 | struct bgp *bgp; |
| 4934 | struct bgp_table *table; |
| 4935 | |
| 4936 | /* BGP structure lookup. */ |
| 4937 | if (view_name) |
| 4938 | { |
| 4939 | bgp = bgp_lookup_by_name (view_name); |
| 4940 | if (bgp == NULL) |
| 4941 | { |
| 4942 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 4943 | return CMD_WARNING; |
| 4944 | } |
| 4945 | } |
| 4946 | else |
| 4947 | { |
| 4948 | bgp = bgp_get_default (); |
| 4949 | if (bgp == NULL) |
| 4950 | { |
| 4951 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 4952 | return CMD_WARNING; |
| 4953 | } |
| 4954 | } |
| 4955 | |
| 4956 | /* Check IP address argument. */ |
| 4957 | ret = str2prefix (ip_str, &match); |
| 4958 | if (! ret) |
| 4959 | { |
| 4960 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 4961 | return CMD_WARNING; |
| 4962 | } |
| 4963 | |
| 4964 | match.family = afi2family (afi); |
| 4965 | |
| 4966 | if (safi == SAFI_MPLS_VPN) |
| 4967 | { |
| 4968 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 4969 | { |
| 4970 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 4971 | continue; |
| 4972 | |
| 4973 | if ((table = rn->info) != NULL) |
| 4974 | { |
| 4975 | header = 1; |
| 4976 | |
| 4977 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 4978 | { |
| 4979 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 4980 | continue; |
| 4981 | |
| 4982 | for (ri = rm->info; ri; ri = ri->next) |
| 4983 | { |
| 4984 | if (header) |
| 4985 | { |
| 4986 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 4987 | AFI_IP, SAFI_MPLS_VPN); |
| 4988 | |
| 4989 | header = 0; |
| 4990 | } |
| 4991 | display++; |
| 4992 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 4993 | } |
| 4994 | } |
| 4995 | } |
| 4996 | } |
| 4997 | } |
| 4998 | else |
| 4999 | { |
| 5000 | header = 1; |
| 5001 | |
| 5002 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 5003 | { |
| 5004 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 5005 | { |
| 5006 | for (ri = rn->info; ri; ri = ri->next) |
| 5007 | { |
| 5008 | if (header) |
| 5009 | { |
| 5010 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 5011 | header = 0; |
| 5012 | } |
| 5013 | display++; |
| 5014 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 5015 | } |
| 5016 | } |
| 5017 | } |
| 5018 | } |
| 5019 | |
| 5020 | if (! display) |
| 5021 | { |
| 5022 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 5023 | return CMD_WARNING; |
| 5024 | } |
| 5025 | |
| 5026 | return CMD_SUCCESS; |
| 5027 | } |
| 5028 | |
| 5029 | /* BGP route print out function. */ |
| 5030 | DEFUN (show_ip_bgp, |
| 5031 | show_ip_bgp_cmd, |
| 5032 | "show ip bgp", |
| 5033 | SHOW_STR |
| 5034 | IP_STR |
| 5035 | BGP_STR) |
| 5036 | { |
| 5037 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal); |
| 5038 | } |
| 5039 | |
| 5040 | DEFUN (show_ip_bgp_ipv4, |
| 5041 | show_ip_bgp_ipv4_cmd, |
| 5042 | "show ip bgp ipv4 (unicast|multicast)", |
| 5043 | SHOW_STR |
| 5044 | IP_STR |
| 5045 | BGP_STR |
| 5046 | "Address family\n" |
| 5047 | "Address Family modifier\n" |
| 5048 | "Address Family modifier\n") |
| 5049 | { |
| 5050 | if (strncmp (argv[0], "m", 1) == 0) |
| 5051 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal); |
| 5052 | |
| 5053 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal); |
| 5054 | } |
| 5055 | |
| 5056 | DEFUN (show_ip_bgp_route, |
| 5057 | show_ip_bgp_route_cmd, |
| 5058 | "show ip bgp A.B.C.D", |
| 5059 | SHOW_STR |
| 5060 | IP_STR |
| 5061 | BGP_STR |
| 5062 | "Network in the BGP routing table to display\n") |
| 5063 | { |
| 5064 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5065 | } |
| 5066 | |
| 5067 | DEFUN (show_ip_bgp_ipv4_route, |
| 5068 | show_ip_bgp_ipv4_route_cmd, |
| 5069 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 5070 | SHOW_STR |
| 5071 | IP_STR |
| 5072 | BGP_STR |
| 5073 | "Address family\n" |
| 5074 | "Address Family modifier\n" |
| 5075 | "Address Family modifier\n" |
| 5076 | "Network in the BGP routing table to display\n") |
| 5077 | { |
| 5078 | if (strncmp (argv[0], "m", 1) == 0) |
| 5079 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 5080 | |
| 5081 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5082 | } |
| 5083 | |
| 5084 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 5085 | show_ip_bgp_vpnv4_all_route_cmd, |
| 5086 | "show ip bgp vpnv4 all A.B.C.D", |
| 5087 | SHOW_STR |
| 5088 | IP_STR |
| 5089 | BGP_STR |
| 5090 | "Display VPNv4 NLRI specific information\n" |
| 5091 | "Display information about all VPNv4 NLRIs\n" |
| 5092 | "Network in the BGP routing table to display\n") |
| 5093 | { |
| 5094 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 5095 | } |
| 5096 | |
| 5097 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 5098 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 5099 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 5100 | SHOW_STR |
| 5101 | IP_STR |
| 5102 | BGP_STR |
| 5103 | "Display VPNv4 NLRI specific information\n" |
| 5104 | "Display information for a route distinguisher\n" |
| 5105 | "VPN Route Distinguisher\n" |
| 5106 | "Network in the BGP routing table to display\n") |
| 5107 | { |
| 5108 | int ret; |
| 5109 | struct prefix_rd prd; |
| 5110 | |
| 5111 | ret = str2prefix_rd (argv[0], &prd); |
| 5112 | if (! ret) |
| 5113 | { |
| 5114 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5115 | return CMD_WARNING; |
| 5116 | } |
| 5117 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 5118 | } |
| 5119 | |
| 5120 | DEFUN (show_ip_bgp_prefix, |
| 5121 | show_ip_bgp_prefix_cmd, |
| 5122 | "show ip bgp A.B.C.D/M", |
| 5123 | SHOW_STR |
| 5124 | IP_STR |
| 5125 | BGP_STR |
| 5126 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5127 | { |
| 5128 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5129 | } |
| 5130 | |
| 5131 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 5132 | show_ip_bgp_ipv4_prefix_cmd, |
| 5133 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 5134 | SHOW_STR |
| 5135 | IP_STR |
| 5136 | BGP_STR |
| 5137 | "Address family\n" |
| 5138 | "Address Family modifier\n" |
| 5139 | "Address Family modifier\n" |
| 5140 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5141 | { |
| 5142 | if (strncmp (argv[0], "m", 1) == 0) |
| 5143 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 5144 | |
| 5145 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5146 | } |
| 5147 | |
| 5148 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 5149 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 5150 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 5151 | SHOW_STR |
| 5152 | IP_STR |
| 5153 | BGP_STR |
| 5154 | "Display VPNv4 NLRI specific information\n" |
| 5155 | "Display information about all VPNv4 NLRIs\n" |
| 5156 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5157 | { |
| 5158 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 5159 | } |
| 5160 | |
| 5161 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 5162 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 5163 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 5164 | SHOW_STR |
| 5165 | IP_STR |
| 5166 | BGP_STR |
| 5167 | "Display VPNv4 NLRI specific information\n" |
| 5168 | "Display information for a route distinguisher\n" |
| 5169 | "VPN Route Distinguisher\n" |
| 5170 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5171 | { |
| 5172 | int ret; |
| 5173 | struct prefix_rd prd; |
| 5174 | |
| 5175 | ret = str2prefix_rd (argv[0], &prd); |
| 5176 | if (! ret) |
| 5177 | { |
| 5178 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5179 | return CMD_WARNING; |
| 5180 | } |
| 5181 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 5182 | } |
| 5183 | |
| 5184 | DEFUN (show_ip_bgp_view, |
| 5185 | show_ip_bgp_view_cmd, |
| 5186 | "show ip bgp view WORD", |
| 5187 | SHOW_STR |
| 5188 | IP_STR |
| 5189 | BGP_STR |
| 5190 | "BGP view\n" |
| 5191 | "BGP view name\n") |
| 5192 | { |
| 5193 | return bgp_show (vty, argv[0], AFI_IP, SAFI_UNICAST, bgp_show_type_normal); |
| 5194 | } |
| 5195 | |
| 5196 | DEFUN (show_ip_bgp_view_route, |
| 5197 | show_ip_bgp_view_route_cmd, |
| 5198 | "show ip bgp view WORD A.B.C.D", |
| 5199 | SHOW_STR |
| 5200 | IP_STR |
| 5201 | BGP_STR |
| 5202 | "BGP view\n" |
| 5203 | "BGP view name\n" |
| 5204 | "Network in the BGP routing table to display\n") |
| 5205 | { |
| 5206 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5207 | } |
| 5208 | |
| 5209 | DEFUN (show_ip_bgp_view_prefix, |
| 5210 | show_ip_bgp_view_prefix_cmd, |
| 5211 | "show ip bgp view WORD A.B.C.D/M", |
| 5212 | SHOW_STR |
| 5213 | IP_STR |
| 5214 | BGP_STR |
| 5215 | "BGP view\n" |
| 5216 | "BGP view name\n" |
| 5217 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5218 | { |
| 5219 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5220 | } |
| 5221 | |
| 5222 | #ifdef HAVE_IPV6 |
| 5223 | DEFUN (show_bgp, |
| 5224 | show_bgp_cmd, |
| 5225 | "show bgp", |
| 5226 | SHOW_STR |
| 5227 | BGP_STR) |
| 5228 | { |
| 5229 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal); |
| 5230 | } |
| 5231 | |
| 5232 | ALIAS (show_bgp, |
| 5233 | show_bgp_ipv6_cmd, |
| 5234 | "show bgp ipv6", |
| 5235 | SHOW_STR |
| 5236 | BGP_STR |
| 5237 | "Address family\n") |
| 5238 | |
| 5239 | /* old command */ |
| 5240 | DEFUN (show_ipv6_bgp, |
| 5241 | show_ipv6_bgp_cmd, |
| 5242 | "show ipv6 bgp", |
| 5243 | SHOW_STR |
| 5244 | IP_STR |
| 5245 | BGP_STR) |
| 5246 | { |
| 5247 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal); |
| 5248 | } |
| 5249 | |
| 5250 | DEFUN (show_bgp_route, |
| 5251 | show_bgp_route_cmd, |
| 5252 | "show bgp X:X::X:X", |
| 5253 | SHOW_STR |
| 5254 | BGP_STR |
| 5255 | "Network in the BGP routing table to display\n") |
| 5256 | { |
| 5257 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5258 | } |
| 5259 | |
| 5260 | ALIAS (show_bgp_route, |
| 5261 | show_bgp_ipv6_route_cmd, |
| 5262 | "show bgp ipv6 X:X::X:X", |
| 5263 | SHOW_STR |
| 5264 | BGP_STR |
| 5265 | "Address family\n" |
| 5266 | "Network in the BGP routing table to display\n") |
| 5267 | |
| 5268 | /* old command */ |
| 5269 | DEFUN (show_ipv6_bgp_route, |
| 5270 | show_ipv6_bgp_route_cmd, |
| 5271 | "show ipv6 bgp X:X::X:X", |
| 5272 | SHOW_STR |
| 5273 | IP_STR |
| 5274 | BGP_STR |
| 5275 | "Network in the BGP routing table to display\n") |
| 5276 | { |
| 5277 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5278 | } |
| 5279 | |
| 5280 | DEFUN (show_bgp_prefix, |
| 5281 | show_bgp_prefix_cmd, |
| 5282 | "show bgp X:X::X:X/M", |
| 5283 | SHOW_STR |
| 5284 | BGP_STR |
| 5285 | "IPv6 prefix <network>/<length>\n") |
| 5286 | { |
| 5287 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 5288 | } |
| 5289 | |
| 5290 | ALIAS (show_bgp_prefix, |
| 5291 | show_bgp_ipv6_prefix_cmd, |
| 5292 | "show bgp ipv6 X:X::X:X/M", |
| 5293 | SHOW_STR |
| 5294 | BGP_STR |
| 5295 | "Address family\n" |
| 5296 | "IPv6 prefix <network>/<length>\n") |
| 5297 | |
| 5298 | /* old command */ |
| 5299 | DEFUN (show_ipv6_bgp_prefix, |
| 5300 | show_ipv6_bgp_prefix_cmd, |
| 5301 | "show ipv6 bgp X:X::X:X/M", |
| 5302 | SHOW_STR |
| 5303 | IP_STR |
| 5304 | BGP_STR |
| 5305 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 5306 | { |
| 5307 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 5308 | } |
| 5309 | |
| 5310 | /* old command */ |
| 5311 | DEFUN (show_ipv6_mbgp, |
| 5312 | show_ipv6_mbgp_cmd, |
| 5313 | "show ipv6 mbgp", |
| 5314 | SHOW_STR |
| 5315 | IP_STR |
| 5316 | MBGP_STR) |
| 5317 | { |
| 5318 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal); |
| 5319 | } |
| 5320 | |
| 5321 | /* old command */ |
| 5322 | DEFUN (show_ipv6_mbgp_route, |
| 5323 | show_ipv6_mbgp_route_cmd, |
| 5324 | "show ipv6 mbgp X:X::X:X", |
| 5325 | SHOW_STR |
| 5326 | IP_STR |
| 5327 | MBGP_STR |
| 5328 | "Network in the MBGP routing table to display\n") |
| 5329 | { |
| 5330 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 5331 | } |
| 5332 | |
| 5333 | /* old command */ |
| 5334 | DEFUN (show_ipv6_mbgp_prefix, |
| 5335 | show_ipv6_mbgp_prefix_cmd, |
| 5336 | "show ipv6 mbgp X:X::X:X/M", |
| 5337 | SHOW_STR |
| 5338 | IP_STR |
| 5339 | MBGP_STR |
| 5340 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 5341 | { |
| 5342 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 5343 | } |
| 5344 | #endif |
| 5345 | |
| 5346 | void |
| 5347 | bgp_show_regexp_clean (struct vty *vty) |
| 5348 | { |
| 5349 | bgp_regex_free (vty->output_arg); |
| 5350 | } |
| 5351 | |
| 5352 | int |
| 5353 | bgp_show_regexp (struct vty *vty, int argc, char **argv, afi_t afi, |
| 5354 | safi_t safi, enum bgp_show_type type) |
| 5355 | { |
| 5356 | int i; |
| 5357 | struct buffer *b; |
| 5358 | char *regstr; |
| 5359 | int first; |
| 5360 | regex_t *regex; |
| 5361 | |
| 5362 | first = 0; |
| 5363 | b = buffer_new (1024); |
| 5364 | for (i = 0; i < argc; i++) |
| 5365 | { |
| 5366 | if (first) |
| 5367 | buffer_putc (b, ' '); |
| 5368 | else |
| 5369 | { |
| 5370 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 5371 | continue; |
| 5372 | first = 1; |
| 5373 | } |
| 5374 | |
| 5375 | buffer_putstr (b, argv[i]); |
| 5376 | } |
| 5377 | buffer_putc (b, '\0'); |
| 5378 | |
| 5379 | regstr = buffer_getstr (b); |
| 5380 | buffer_free (b); |
| 5381 | |
| 5382 | regex = bgp_regcomp (regstr); |
| 5383 | if (! regex) |
| 5384 | { |
| 5385 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 5386 | VTY_NEWLINE); |
| 5387 | return CMD_WARNING; |
| 5388 | } |
| 5389 | |
| 5390 | vty->output_arg = regex; |
| 5391 | vty->output_clean = bgp_show_regexp_clean; |
| 5392 | |
| 5393 | return bgp_show (vty, NULL, afi, safi, type); |
| 5394 | } |
| 5395 | |
| 5396 | DEFUN (show_ip_bgp_regexp, |
| 5397 | show_ip_bgp_regexp_cmd, |
| 5398 | "show ip bgp regexp .LINE", |
| 5399 | SHOW_STR |
| 5400 | IP_STR |
| 5401 | BGP_STR |
| 5402 | "Display routes matching the AS path regular expression\n" |
| 5403 | "A regular-expression to match the BGP AS paths\n") |
| 5404 | { |
| 5405 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 5406 | bgp_show_type_regexp); |
| 5407 | } |
| 5408 | |
| 5409 | DEFUN (show_ip_bgp_flap_regexp, |
| 5410 | show_ip_bgp_flap_regexp_cmd, |
| 5411 | "show ip bgp flap-statistics regexp .LINE", |
| 5412 | SHOW_STR |
| 5413 | IP_STR |
| 5414 | BGP_STR |
| 5415 | "Display flap statistics of routes\n" |
| 5416 | "Display routes matching the AS path regular expression\n" |
| 5417 | "A regular-expression to match the BGP AS paths\n") |
| 5418 | { |
| 5419 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 5420 | bgp_show_type_flap_regexp); |
| 5421 | } |
| 5422 | |
| 5423 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 5424 | show_ip_bgp_ipv4_regexp_cmd, |
| 5425 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 5426 | SHOW_STR |
| 5427 | IP_STR |
| 5428 | BGP_STR |
| 5429 | "Address family\n" |
| 5430 | "Address Family modifier\n" |
| 5431 | "Address Family modifier\n" |
| 5432 | "Display routes matching the AS path regular expression\n" |
| 5433 | "A regular-expression to match the BGP AS paths\n") |
| 5434 | { |
| 5435 | if (strncmp (argv[0], "m", 1) == 0) |
| 5436 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 5437 | bgp_show_type_regexp); |
| 5438 | |
| 5439 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 5440 | bgp_show_type_regexp); |
| 5441 | } |
| 5442 | |
| 5443 | #ifdef HAVE_IPV6 |
| 5444 | DEFUN (show_bgp_regexp, |
| 5445 | show_bgp_regexp_cmd, |
| 5446 | "show bgp regexp .LINE", |
| 5447 | SHOW_STR |
| 5448 | BGP_STR |
| 5449 | "Display routes matching the AS path regular expression\n" |
| 5450 | "A regular-expression to match the BGP AS paths\n") |
| 5451 | { |
| 5452 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 5453 | bgp_show_type_regexp); |
| 5454 | } |
| 5455 | |
| 5456 | ALIAS (show_bgp_regexp, |
| 5457 | show_bgp_ipv6_regexp_cmd, |
| 5458 | "show bgp ipv6 regexp .LINE", |
| 5459 | SHOW_STR |
| 5460 | BGP_STR |
| 5461 | "Address family\n" |
| 5462 | "Display routes matching the AS path regular expression\n" |
| 5463 | "A regular-expression to match the BGP AS paths\n") |
| 5464 | |
| 5465 | /* old command */ |
| 5466 | DEFUN (show_ipv6_bgp_regexp, |
| 5467 | show_ipv6_bgp_regexp_cmd, |
| 5468 | "show ipv6 bgp regexp .LINE", |
| 5469 | SHOW_STR |
| 5470 | IP_STR |
| 5471 | BGP_STR |
| 5472 | "Display routes matching the AS path regular expression\n" |
| 5473 | "A regular-expression to match the BGP AS paths\n") |
| 5474 | { |
| 5475 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 5476 | bgp_show_type_regexp); |
| 5477 | } |
| 5478 | |
| 5479 | /* old command */ |
| 5480 | DEFUN (show_ipv6_mbgp_regexp, |
| 5481 | show_ipv6_mbgp_regexp_cmd, |
| 5482 | "show ipv6 mbgp regexp .LINE", |
| 5483 | SHOW_STR |
| 5484 | IP_STR |
| 5485 | BGP_STR |
| 5486 | "Display routes matching the AS path regular expression\n" |
| 5487 | "A regular-expression to match the MBGP AS paths\n") |
| 5488 | { |
| 5489 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 5490 | bgp_show_type_regexp); |
| 5491 | } |
| 5492 | #endif /* HAVE_IPV6 */ |
| 5493 | |
| 5494 | int |
| 5495 | bgp_show_prefix_list (struct vty *vty, char *prefix_list_str, afi_t afi, |
| 5496 | safi_t safi, enum bgp_show_type type) |
| 5497 | { |
| 5498 | struct prefix_list *plist; |
| 5499 | |
| 5500 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 5501 | if (plist == NULL) |
| 5502 | { |
| 5503 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 5504 | prefix_list_str, VTY_NEWLINE); |
| 5505 | return CMD_WARNING; |
| 5506 | } |
| 5507 | |
| 5508 | vty->output_arg = plist; |
| 5509 | |
| 5510 | return bgp_show (vty, NULL, afi, safi, type); |
| 5511 | } |
| 5512 | |
| 5513 | DEFUN (show_ip_bgp_prefix_list, |
| 5514 | show_ip_bgp_prefix_list_cmd, |
| 5515 | "show ip bgp prefix-list WORD", |
| 5516 | SHOW_STR |
| 5517 | IP_STR |
| 5518 | BGP_STR |
| 5519 | "Display routes conforming to the prefix-list\n" |
| 5520 | "IP prefix-list name\n") |
| 5521 | { |
| 5522 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5523 | bgp_show_type_prefix_list); |
| 5524 | } |
| 5525 | |
| 5526 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 5527 | show_ip_bgp_flap_prefix_list_cmd, |
| 5528 | "show ip bgp flap-statistics prefix-list WORD", |
| 5529 | SHOW_STR |
| 5530 | IP_STR |
| 5531 | BGP_STR |
| 5532 | "Display flap statistics of routes\n" |
| 5533 | "Display routes conforming to the prefix-list\n" |
| 5534 | "IP prefix-list name\n") |
| 5535 | { |
| 5536 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5537 | bgp_show_type_flap_prefix_list); |
| 5538 | } |
| 5539 | |
| 5540 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 5541 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 5542 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 5543 | SHOW_STR |
| 5544 | IP_STR |
| 5545 | BGP_STR |
| 5546 | "Address family\n" |
| 5547 | "Address Family modifier\n" |
| 5548 | "Address Family modifier\n" |
| 5549 | "Display routes conforming to the prefix-list\n" |
| 5550 | "IP prefix-list name\n") |
| 5551 | { |
| 5552 | if (strncmp (argv[0], "m", 1) == 0) |
| 5553 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 5554 | bgp_show_type_prefix_list); |
| 5555 | |
| 5556 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 5557 | bgp_show_type_prefix_list); |
| 5558 | } |
| 5559 | |
| 5560 | #ifdef HAVE_IPV6 |
| 5561 | DEFUN (show_bgp_prefix_list, |
| 5562 | show_bgp_prefix_list_cmd, |
| 5563 | "show bgp prefix-list WORD", |
| 5564 | SHOW_STR |
| 5565 | BGP_STR |
| 5566 | "Display routes conforming to the prefix-list\n" |
| 5567 | "IPv6 prefix-list name\n") |
| 5568 | { |
| 5569 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5570 | bgp_show_type_prefix_list); |
| 5571 | } |
| 5572 | |
| 5573 | ALIAS (show_bgp_prefix_list, |
| 5574 | show_bgp_ipv6_prefix_list_cmd, |
| 5575 | "show bgp ipv6 prefix-list WORD", |
| 5576 | SHOW_STR |
| 5577 | BGP_STR |
| 5578 | "Address family\n" |
| 5579 | "Display routes conforming to the prefix-list\n" |
| 5580 | "IPv6 prefix-list name\n") |
| 5581 | |
| 5582 | /* old command */ |
| 5583 | DEFUN (show_ipv6_bgp_prefix_list, |
| 5584 | show_ipv6_bgp_prefix_list_cmd, |
| 5585 | "show ipv6 bgp prefix-list WORD", |
| 5586 | SHOW_STR |
| 5587 | IPV6_STR |
| 5588 | BGP_STR |
| 5589 | "Display routes matching the prefix-list\n" |
| 5590 | "IPv6 prefix-list name\n") |
| 5591 | { |
| 5592 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5593 | bgp_show_type_prefix_list); |
| 5594 | } |
| 5595 | |
| 5596 | /* old command */ |
| 5597 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 5598 | show_ipv6_mbgp_prefix_list_cmd, |
| 5599 | "show ipv6 mbgp prefix-list WORD", |
| 5600 | SHOW_STR |
| 5601 | IPV6_STR |
| 5602 | MBGP_STR |
| 5603 | "Display routes matching the prefix-list\n" |
| 5604 | "IPv6 prefix-list name\n") |
| 5605 | { |
| 5606 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 5607 | bgp_show_type_prefix_list); |
| 5608 | } |
| 5609 | #endif /* HAVE_IPV6 */ |
| 5610 | |
| 5611 | int |
| 5612 | bgp_show_filter_list (struct vty *vty, char *filter, afi_t afi, |
| 5613 | safi_t safi, enum bgp_show_type type) |
| 5614 | { |
| 5615 | struct as_list *as_list; |
| 5616 | |
| 5617 | as_list = as_list_lookup (filter); |
| 5618 | if (as_list == NULL) |
| 5619 | { |
| 5620 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 5621 | return CMD_WARNING; |
| 5622 | } |
| 5623 | |
| 5624 | vty->output_arg = as_list; |
| 5625 | |
| 5626 | return bgp_show (vty, NULL, afi, safi, type); |
| 5627 | } |
| 5628 | |
| 5629 | DEFUN (show_ip_bgp_filter_list, |
| 5630 | show_ip_bgp_filter_list_cmd, |
| 5631 | "show ip bgp filter-list WORD", |
| 5632 | SHOW_STR |
| 5633 | IP_STR |
| 5634 | BGP_STR |
| 5635 | "Display routes conforming to the filter-list\n" |
| 5636 | "Regular expression access list name\n") |
| 5637 | { |
| 5638 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5639 | bgp_show_type_filter_list); |
| 5640 | } |
| 5641 | |
| 5642 | DEFUN (show_ip_bgp_flap_filter_list, |
| 5643 | show_ip_bgp_flap_filter_list_cmd, |
| 5644 | "show ip bgp flap-statistics filter-list WORD", |
| 5645 | SHOW_STR |
| 5646 | IP_STR |
| 5647 | BGP_STR |
| 5648 | "Display flap statistics of routes\n" |
| 5649 | "Display routes conforming to the filter-list\n" |
| 5650 | "Regular expression access list name\n") |
| 5651 | { |
| 5652 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5653 | bgp_show_type_flap_filter_list); |
| 5654 | } |
| 5655 | |
| 5656 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 5657 | show_ip_bgp_ipv4_filter_list_cmd, |
| 5658 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 5659 | SHOW_STR |
| 5660 | IP_STR |
| 5661 | BGP_STR |
| 5662 | "Address family\n" |
| 5663 | "Address Family modifier\n" |
| 5664 | "Address Family modifier\n" |
| 5665 | "Display routes conforming to the filter-list\n" |
| 5666 | "Regular expression access list name\n") |
| 5667 | { |
| 5668 | if (strncmp (argv[0], "m", 1) == 0) |
| 5669 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 5670 | bgp_show_type_filter_list); |
| 5671 | |
| 5672 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 5673 | bgp_show_type_filter_list); |
| 5674 | } |
| 5675 | |
| 5676 | #ifdef HAVE_IPV6 |
| 5677 | DEFUN (show_bgp_filter_list, |
| 5678 | show_bgp_filter_list_cmd, |
| 5679 | "show bgp filter-list WORD", |
| 5680 | SHOW_STR |
| 5681 | BGP_STR |
| 5682 | "Display routes conforming to the filter-list\n" |
| 5683 | "Regular expression access list name\n") |
| 5684 | { |
| 5685 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5686 | bgp_show_type_filter_list); |
| 5687 | } |
| 5688 | |
| 5689 | ALIAS (show_bgp_filter_list, |
| 5690 | show_bgp_ipv6_filter_list_cmd, |
| 5691 | "show bgp ipv6 filter-list WORD", |
| 5692 | SHOW_STR |
| 5693 | BGP_STR |
| 5694 | "Address family\n" |
| 5695 | "Display routes conforming to the filter-list\n" |
| 5696 | "Regular expression access list name\n") |
| 5697 | |
| 5698 | /* old command */ |
| 5699 | DEFUN (show_ipv6_bgp_filter_list, |
| 5700 | show_ipv6_bgp_filter_list_cmd, |
| 5701 | "show ipv6 bgp filter-list WORD", |
| 5702 | SHOW_STR |
| 5703 | IPV6_STR |
| 5704 | BGP_STR |
| 5705 | "Display routes conforming to the filter-list\n" |
| 5706 | "Regular expression access list name\n") |
| 5707 | { |
| 5708 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5709 | bgp_show_type_filter_list); |
| 5710 | } |
| 5711 | |
| 5712 | /* old command */ |
| 5713 | DEFUN (show_ipv6_mbgp_filter_list, |
| 5714 | show_ipv6_mbgp_filter_list_cmd, |
| 5715 | "show ipv6 mbgp filter-list WORD", |
| 5716 | SHOW_STR |
| 5717 | IPV6_STR |
| 5718 | MBGP_STR |
| 5719 | "Display routes conforming to the filter-list\n" |
| 5720 | "Regular expression access list name\n") |
| 5721 | { |
| 5722 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 5723 | bgp_show_type_filter_list); |
| 5724 | } |
| 5725 | #endif /* HAVE_IPV6 */ |
| 5726 | |
| 5727 | int |
| 5728 | bgp_show_route_map (struct vty *vty, char *rmap_str, afi_t afi, |
| 5729 | safi_t safi, enum bgp_show_type type) |
| 5730 | { |
| 5731 | struct route_map *rmap; |
| 5732 | |
| 5733 | rmap = route_map_lookup_by_name (rmap_str); |
| 5734 | if (! rmap) |
| 5735 | { |
| 5736 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 5737 | rmap_str, VTY_NEWLINE); |
| 5738 | return CMD_WARNING; |
| 5739 | } |
| 5740 | |
| 5741 | vty->output_arg = rmap; |
| 5742 | |
| 5743 | return bgp_show (vty, NULL, afi, safi, type); |
| 5744 | } |
| 5745 | |
| 5746 | DEFUN (show_ip_bgp_route_map, |
| 5747 | show_ip_bgp_route_map_cmd, |
| 5748 | "show ip bgp route-map WORD", |
| 5749 | SHOW_STR |
| 5750 | IP_STR |
| 5751 | BGP_STR |
| 5752 | "Display routes matching the route-map\n" |
| 5753 | "A route-map to match on\n") |
| 5754 | { |
| 5755 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5756 | bgp_show_type_route_map); |
| 5757 | } |
| 5758 | |
| 5759 | DEFUN (show_ip_bgp_flap_route_map, |
| 5760 | show_ip_bgp_flap_route_map_cmd, |
| 5761 | "show ip bgp flap-statistics route-map WORD", |
| 5762 | SHOW_STR |
| 5763 | IP_STR |
| 5764 | BGP_STR |
| 5765 | "Display flap statistics of routes\n" |
| 5766 | "Display routes matching the route-map\n" |
| 5767 | "A route-map to match on\n") |
| 5768 | { |
| 5769 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 5770 | bgp_show_type_flap_route_map); |
| 5771 | } |
| 5772 | |
| 5773 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 5774 | show_ip_bgp_ipv4_route_map_cmd, |
| 5775 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 5776 | SHOW_STR |
| 5777 | IP_STR |
| 5778 | BGP_STR |
| 5779 | "Address family\n" |
| 5780 | "Address Family modifier\n" |
| 5781 | "Address Family modifier\n" |
| 5782 | "Display routes matching the route-map\n" |
| 5783 | "A route-map to match on\n") |
| 5784 | { |
| 5785 | if (strncmp (argv[0], "m", 1) == 0) |
| 5786 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 5787 | bgp_show_type_route_map); |
| 5788 | |
| 5789 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 5790 | bgp_show_type_route_map); |
| 5791 | } |
| 5792 | |
| 5793 | DEFUN (show_bgp_route_map, |
| 5794 | show_bgp_route_map_cmd, |
| 5795 | "show bgp route-map WORD", |
| 5796 | SHOW_STR |
| 5797 | BGP_STR |
| 5798 | "Display routes matching the route-map\n" |
| 5799 | "A route-map to match on\n") |
| 5800 | { |
| 5801 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5802 | bgp_show_type_route_map); |
| 5803 | } |
| 5804 | |
| 5805 | ALIAS (show_bgp_route_map, |
| 5806 | show_bgp_ipv6_route_map_cmd, |
| 5807 | "show bgp ipv6 route-map WORD", |
| 5808 | SHOW_STR |
| 5809 | BGP_STR |
| 5810 | "Address family\n" |
| 5811 | "Display routes matching the route-map\n" |
| 5812 | "A route-map to match on\n") |
| 5813 | |
| 5814 | DEFUN (show_ip_bgp_cidr_only, |
| 5815 | show_ip_bgp_cidr_only_cmd, |
| 5816 | "show ip bgp cidr-only", |
| 5817 | SHOW_STR |
| 5818 | IP_STR |
| 5819 | BGP_STR |
| 5820 | "Display only routes with non-natural netmasks\n") |
| 5821 | { |
| 5822 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5823 | bgp_show_type_cidr_only); |
| 5824 | } |
| 5825 | |
| 5826 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 5827 | show_ip_bgp_flap_cidr_only_cmd, |
| 5828 | "show ip bgp flap-statistics cidr-only", |
| 5829 | SHOW_STR |
| 5830 | IP_STR |
| 5831 | BGP_STR |
| 5832 | "Display flap statistics of routes\n" |
| 5833 | "Display only routes with non-natural netmasks\n") |
| 5834 | { |
| 5835 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5836 | bgp_show_type_flap_cidr_only); |
| 5837 | } |
| 5838 | |
| 5839 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 5840 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 5841 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 5842 | SHOW_STR |
| 5843 | IP_STR |
| 5844 | BGP_STR |
| 5845 | "Address family\n" |
| 5846 | "Address Family modifier\n" |
| 5847 | "Address Family modifier\n" |
| 5848 | "Display only routes with non-natural netmasks\n") |
| 5849 | { |
| 5850 | if (strncmp (argv[0], "m", 1) == 0) |
| 5851 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 5852 | bgp_show_type_cidr_only); |
| 5853 | |
| 5854 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5855 | bgp_show_type_cidr_only); |
| 5856 | } |
| 5857 | |
| 5858 | DEFUN (show_ip_bgp_community_all, |
| 5859 | show_ip_bgp_community_all_cmd, |
| 5860 | "show ip bgp community", |
| 5861 | SHOW_STR |
| 5862 | IP_STR |
| 5863 | BGP_STR |
| 5864 | "Display routes matching the communities\n") |
| 5865 | { |
| 5866 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5867 | bgp_show_type_community_all); |
| 5868 | } |
| 5869 | |
| 5870 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 5871 | show_ip_bgp_ipv4_community_all_cmd, |
| 5872 | "show ip bgp ipv4 (unicast|multicast) community", |
| 5873 | SHOW_STR |
| 5874 | IP_STR |
| 5875 | BGP_STR |
| 5876 | "Address family\n" |
| 5877 | "Address Family modifier\n" |
| 5878 | "Address Family modifier\n" |
| 5879 | "Display routes matching the communities\n") |
| 5880 | { |
| 5881 | if (strncmp (argv[0], "m", 1) == 0) |
| 5882 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 5883 | bgp_show_type_community_all); |
| 5884 | |
| 5885 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 5886 | bgp_show_type_community_all); |
| 5887 | } |
| 5888 | |
| 5889 | #ifdef HAVE_IPV6 |
| 5890 | DEFUN (show_bgp_community_all, |
| 5891 | show_bgp_community_all_cmd, |
| 5892 | "show bgp community", |
| 5893 | SHOW_STR |
| 5894 | BGP_STR |
| 5895 | "Display routes matching the communities\n") |
| 5896 | { |
| 5897 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 5898 | bgp_show_type_community_all); |
| 5899 | } |
| 5900 | |
| 5901 | ALIAS (show_bgp_community_all, |
| 5902 | show_bgp_ipv6_community_all_cmd, |
| 5903 | "show bgp ipv6 community", |
| 5904 | SHOW_STR |
| 5905 | BGP_STR |
| 5906 | "Address family\n" |
| 5907 | "Display routes matching the communities\n") |
| 5908 | |
| 5909 | /* old command */ |
| 5910 | DEFUN (show_ipv6_bgp_community_all, |
| 5911 | show_ipv6_bgp_community_all_cmd, |
| 5912 | "show ipv6 bgp community", |
| 5913 | SHOW_STR |
| 5914 | IPV6_STR |
| 5915 | BGP_STR |
| 5916 | "Display routes matching the communities\n") |
| 5917 | { |
| 5918 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 5919 | bgp_show_type_community_all); |
| 5920 | } |
| 5921 | |
| 5922 | /* old command */ |
| 5923 | DEFUN (show_ipv6_mbgp_community_all, |
| 5924 | show_ipv6_mbgp_community_all_cmd, |
| 5925 | "show ipv6 mbgp community", |
| 5926 | SHOW_STR |
| 5927 | IPV6_STR |
| 5928 | MBGP_STR |
| 5929 | "Display routes matching the communities\n") |
| 5930 | { |
| 5931 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
| 5932 | bgp_show_type_community_all); |
| 5933 | } |
| 5934 | #endif /* HAVE_IPV6 */ |
| 5935 | |
| 5936 | int |
| 5937 | bgp_show_community (struct vty *vty, int argc, char **argv, int exact, |
| 5938 | u_int16_t afi, u_char safi) |
| 5939 | { |
| 5940 | struct community *com; |
| 5941 | struct buffer *b; |
| 5942 | int i; |
| 5943 | char *str; |
| 5944 | int first = 0; |
| 5945 | |
| 5946 | b = buffer_new (1024); |
| 5947 | for (i = 0; i < argc; i++) |
| 5948 | { |
| 5949 | if (first) |
| 5950 | buffer_putc (b, ' '); |
| 5951 | else |
| 5952 | { |
| 5953 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 5954 | continue; |
| 5955 | first = 1; |
| 5956 | } |
| 5957 | |
| 5958 | buffer_putstr (b, argv[i]); |
| 5959 | } |
| 5960 | buffer_putc (b, '\0'); |
| 5961 | |
| 5962 | str = buffer_getstr (b); |
| 5963 | buffer_free (b); |
| 5964 | |
| 5965 | com = community_str2com (str); |
| 5966 | free (str); |
| 5967 | if (! com) |
| 5968 | { |
| 5969 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 5970 | return CMD_WARNING; |
| 5971 | } |
| 5972 | |
| 5973 | vty->output_arg = com; |
| 5974 | |
| 5975 | if (exact) |
| 5976 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_exact); |
| 5977 | |
| 5978 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community); |
| 5979 | } |
| 5980 | |
| 5981 | DEFUN (show_ip_bgp_community, |
| 5982 | show_ip_bgp_community_cmd, |
| 5983 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 5984 | SHOW_STR |
| 5985 | IP_STR |
| 5986 | BGP_STR |
| 5987 | "Display routes matching the communities\n" |
| 5988 | "community number\n" |
| 5989 | "Do not send outside local AS (well-known community)\n" |
| 5990 | "Do not advertise to any peer (well-known community)\n" |
| 5991 | "Do not export to next AS (well-known community)\n") |
| 5992 | { |
| 5993 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 5994 | } |
| 5995 | |
| 5996 | ALIAS (show_ip_bgp_community, |
| 5997 | show_ip_bgp_community2_cmd, |
| 5998 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 5999 | SHOW_STR |
| 6000 | IP_STR |
| 6001 | BGP_STR |
| 6002 | "Display routes matching the communities\n" |
| 6003 | "community number\n" |
| 6004 | "Do not send outside local AS (well-known community)\n" |
| 6005 | "Do not advertise to any peer (well-known community)\n" |
| 6006 | "Do not export to next AS (well-known community)\n" |
| 6007 | "community number\n" |
| 6008 | "Do not send outside local AS (well-known community)\n" |
| 6009 | "Do not advertise to any peer (well-known community)\n" |
| 6010 | "Do not export to next AS (well-known community)\n") |
| 6011 | |
| 6012 | ALIAS (show_ip_bgp_community, |
| 6013 | show_ip_bgp_community3_cmd, |
| 6014 | "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)", |
| 6015 | SHOW_STR |
| 6016 | IP_STR |
| 6017 | BGP_STR |
| 6018 | "Display routes matching the communities\n" |
| 6019 | "community number\n" |
| 6020 | "Do not send outside local AS (well-known community)\n" |
| 6021 | "Do not advertise to any peer (well-known community)\n" |
| 6022 | "Do not export to next AS (well-known community)\n" |
| 6023 | "community number\n" |
| 6024 | "Do not send outside local AS (well-known community)\n" |
| 6025 | "Do not advertise to any peer (well-known community)\n" |
| 6026 | "Do not export to next AS (well-known community)\n" |
| 6027 | "community number\n" |
| 6028 | "Do not send outside local AS (well-known community)\n" |
| 6029 | "Do not advertise to any peer (well-known community)\n" |
| 6030 | "Do not export to next AS (well-known community)\n") |
| 6031 | |
| 6032 | ALIAS (show_ip_bgp_community, |
| 6033 | show_ip_bgp_community4_cmd, |
| 6034 | "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)", |
| 6035 | SHOW_STR |
| 6036 | IP_STR |
| 6037 | BGP_STR |
| 6038 | "Display routes matching the communities\n" |
| 6039 | "community number\n" |
| 6040 | "Do not send outside local AS (well-known community)\n" |
| 6041 | "Do not advertise to any peer (well-known community)\n" |
| 6042 | "Do not export to next AS (well-known community)\n" |
| 6043 | "community number\n" |
| 6044 | "Do not send outside local AS (well-known community)\n" |
| 6045 | "Do not advertise to any peer (well-known community)\n" |
| 6046 | "Do not export to next AS (well-known community)\n" |
| 6047 | "community number\n" |
| 6048 | "Do not send outside local AS (well-known community)\n" |
| 6049 | "Do not advertise to any peer (well-known community)\n" |
| 6050 | "Do not export to next AS (well-known community)\n" |
| 6051 | "community number\n" |
| 6052 | "Do not send outside local AS (well-known community)\n" |
| 6053 | "Do not advertise to any peer (well-known community)\n" |
| 6054 | "Do not export to next AS (well-known community)\n") |
| 6055 | |
| 6056 | DEFUN (show_ip_bgp_ipv4_community, |
| 6057 | show_ip_bgp_ipv4_community_cmd, |
| 6058 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 6059 | SHOW_STR |
| 6060 | IP_STR |
| 6061 | BGP_STR |
| 6062 | "Address family\n" |
| 6063 | "Address Family modifier\n" |
| 6064 | "Address Family modifier\n" |
| 6065 | "Display routes matching the communities\n" |
| 6066 | "community number\n" |
| 6067 | "Do not send outside local AS (well-known community)\n" |
| 6068 | "Do not advertise to any peer (well-known community)\n" |
| 6069 | "Do not export to next AS (well-known community)\n") |
| 6070 | { |
| 6071 | if (strncmp (argv[0], "m", 1) == 0) |
| 6072 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 6073 | |
| 6074 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6075 | } |
| 6076 | |
| 6077 | ALIAS (show_ip_bgp_ipv4_community, |
| 6078 | show_ip_bgp_ipv4_community2_cmd, |
| 6079 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6080 | SHOW_STR |
| 6081 | IP_STR |
| 6082 | BGP_STR |
| 6083 | "Address family\n" |
| 6084 | "Address Family modifier\n" |
| 6085 | "Address Family modifier\n" |
| 6086 | "Display routes matching the communities\n" |
| 6087 | "community number\n" |
| 6088 | "Do not send outside local AS (well-known community)\n" |
| 6089 | "Do not advertise to any peer (well-known community)\n" |
| 6090 | "Do not export to next AS (well-known community)\n" |
| 6091 | "community number\n" |
| 6092 | "Do not send outside local AS (well-known community)\n" |
| 6093 | "Do not advertise to any peer (well-known community)\n" |
| 6094 | "Do not export to next AS (well-known community)\n") |
| 6095 | |
| 6096 | ALIAS (show_ip_bgp_ipv4_community, |
| 6097 | show_ip_bgp_ipv4_community3_cmd, |
| 6098 | "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)", |
| 6099 | SHOW_STR |
| 6100 | IP_STR |
| 6101 | BGP_STR |
| 6102 | "Address family\n" |
| 6103 | "Address Family modifier\n" |
| 6104 | "Address Family modifier\n" |
| 6105 | "Display routes matching the communities\n" |
| 6106 | "community number\n" |
| 6107 | "Do not send outside local AS (well-known community)\n" |
| 6108 | "Do not advertise to any peer (well-known community)\n" |
| 6109 | "Do not export to next AS (well-known community)\n" |
| 6110 | "community number\n" |
| 6111 | "Do not send outside local AS (well-known community)\n" |
| 6112 | "Do not advertise to any peer (well-known community)\n" |
| 6113 | "Do not export to next AS (well-known community)\n" |
| 6114 | "community number\n" |
| 6115 | "Do not send outside local AS (well-known community)\n" |
| 6116 | "Do not advertise to any peer (well-known community)\n" |
| 6117 | "Do not export to next AS (well-known community)\n") |
| 6118 | |
| 6119 | ALIAS (show_ip_bgp_ipv4_community, |
| 6120 | show_ip_bgp_ipv4_community4_cmd, |
| 6121 | "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)", |
| 6122 | SHOW_STR |
| 6123 | IP_STR |
| 6124 | BGP_STR |
| 6125 | "Address family\n" |
| 6126 | "Address Family modifier\n" |
| 6127 | "Address Family modifier\n" |
| 6128 | "Display routes matching the communities\n" |
| 6129 | "community number\n" |
| 6130 | "Do not send outside local AS (well-known community)\n" |
| 6131 | "Do not advertise to any peer (well-known community)\n" |
| 6132 | "Do not export to next AS (well-known community)\n" |
| 6133 | "community number\n" |
| 6134 | "Do not send outside local AS (well-known community)\n" |
| 6135 | "Do not advertise to any peer (well-known community)\n" |
| 6136 | "Do not export to next AS (well-known community)\n" |
| 6137 | "community number\n" |
| 6138 | "Do not send outside local AS (well-known community)\n" |
| 6139 | "Do not advertise to any peer (well-known community)\n" |
| 6140 | "Do not export to next AS (well-known community)\n" |
| 6141 | "community number\n" |
| 6142 | "Do not send outside local AS (well-known community)\n" |
| 6143 | "Do not advertise to any peer (well-known community)\n" |
| 6144 | "Do not export to next AS (well-known community)\n") |
| 6145 | |
| 6146 | DEFUN (show_ip_bgp_community_exact, |
| 6147 | show_ip_bgp_community_exact_cmd, |
| 6148 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6149 | SHOW_STR |
| 6150 | IP_STR |
| 6151 | BGP_STR |
| 6152 | "Display routes matching the communities\n" |
| 6153 | "community number\n" |
| 6154 | "Do not send outside local AS (well-known community)\n" |
| 6155 | "Do not advertise to any peer (well-known community)\n" |
| 6156 | "Do not export to next AS (well-known community)\n" |
| 6157 | "Exact match of the communities") |
| 6158 | { |
| 6159 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 6160 | } |
| 6161 | |
| 6162 | ALIAS (show_ip_bgp_community_exact, |
| 6163 | show_ip_bgp_community2_exact_cmd, |
| 6164 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6165 | SHOW_STR |
| 6166 | IP_STR |
| 6167 | BGP_STR |
| 6168 | "Display routes matching the communities\n" |
| 6169 | "community number\n" |
| 6170 | "Do not send outside local AS (well-known community)\n" |
| 6171 | "Do not advertise to any peer (well-known community)\n" |
| 6172 | "Do not export to next AS (well-known community)\n" |
| 6173 | "community number\n" |
| 6174 | "Do not send outside local AS (well-known community)\n" |
| 6175 | "Do not advertise to any peer (well-known community)\n" |
| 6176 | "Do not export to next AS (well-known community)\n" |
| 6177 | "Exact match of the communities") |
| 6178 | |
| 6179 | ALIAS (show_ip_bgp_community_exact, |
| 6180 | show_ip_bgp_community3_exact_cmd, |
| 6181 | "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", |
| 6182 | SHOW_STR |
| 6183 | IP_STR |
| 6184 | BGP_STR |
| 6185 | "Display routes matching the communities\n" |
| 6186 | "community number\n" |
| 6187 | "Do not send outside local AS (well-known community)\n" |
| 6188 | "Do not advertise to any peer (well-known community)\n" |
| 6189 | "Do not export to next AS (well-known community)\n" |
| 6190 | "community number\n" |
| 6191 | "Do not send outside local AS (well-known community)\n" |
| 6192 | "Do not advertise to any peer (well-known community)\n" |
| 6193 | "Do not export to next AS (well-known community)\n" |
| 6194 | "community number\n" |
| 6195 | "Do not send outside local AS (well-known community)\n" |
| 6196 | "Do not advertise to any peer (well-known community)\n" |
| 6197 | "Do not export to next AS (well-known community)\n" |
| 6198 | "Exact match of the communities") |
| 6199 | |
| 6200 | ALIAS (show_ip_bgp_community_exact, |
| 6201 | show_ip_bgp_community4_exact_cmd, |
| 6202 | "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", |
| 6203 | SHOW_STR |
| 6204 | IP_STR |
| 6205 | BGP_STR |
| 6206 | "Display routes matching the communities\n" |
| 6207 | "community number\n" |
| 6208 | "Do not send outside local AS (well-known community)\n" |
| 6209 | "Do not advertise to any peer (well-known community)\n" |
| 6210 | "Do not export to next AS (well-known community)\n" |
| 6211 | "community number\n" |
| 6212 | "Do not send outside local AS (well-known community)\n" |
| 6213 | "Do not advertise to any peer (well-known community)\n" |
| 6214 | "Do not export to next AS (well-known community)\n" |
| 6215 | "community number\n" |
| 6216 | "Do not send outside local AS (well-known community)\n" |
| 6217 | "Do not advertise to any peer (well-known community)\n" |
| 6218 | "Do not export to next AS (well-known community)\n" |
| 6219 | "community number\n" |
| 6220 | "Do not send outside local AS (well-known community)\n" |
| 6221 | "Do not advertise to any peer (well-known community)\n" |
| 6222 | "Do not export to next AS (well-known community)\n" |
| 6223 | "Exact match of the communities") |
| 6224 | |
| 6225 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 6226 | show_ip_bgp_ipv4_community_exact_cmd, |
| 6227 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6228 | SHOW_STR |
| 6229 | IP_STR |
| 6230 | BGP_STR |
| 6231 | "Address family\n" |
| 6232 | "Address Family modifier\n" |
| 6233 | "Address Family modifier\n" |
| 6234 | "Display routes matching the communities\n" |
| 6235 | "community number\n" |
| 6236 | "Do not send outside local AS (well-known community)\n" |
| 6237 | "Do not advertise to any peer (well-known community)\n" |
| 6238 | "Do not export to next AS (well-known community)\n" |
| 6239 | "Exact match of the communities") |
| 6240 | { |
| 6241 | if (strncmp (argv[0], "m", 1) == 0) |
| 6242 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 6243 | |
| 6244 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 6245 | } |
| 6246 | |
| 6247 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 6248 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 6249 | "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", |
| 6250 | SHOW_STR |
| 6251 | IP_STR |
| 6252 | BGP_STR |
| 6253 | "Address family\n" |
| 6254 | "Address Family modifier\n" |
| 6255 | "Address Family modifier\n" |
| 6256 | "Display routes matching the communities\n" |
| 6257 | "community number\n" |
| 6258 | "Do not send outside local AS (well-known community)\n" |
| 6259 | "Do not advertise to any peer (well-known community)\n" |
| 6260 | "Do not export to next AS (well-known community)\n" |
| 6261 | "community number\n" |
| 6262 | "Do not send outside local AS (well-known community)\n" |
| 6263 | "Do not advertise to any peer (well-known community)\n" |
| 6264 | "Do not export to next AS (well-known community)\n" |
| 6265 | "Exact match of the communities") |
| 6266 | |
| 6267 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 6268 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 6269 | "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", |
| 6270 | SHOW_STR |
| 6271 | IP_STR |
| 6272 | BGP_STR |
| 6273 | "Address family\n" |
| 6274 | "Address Family modifier\n" |
| 6275 | "Address Family modifier\n" |
| 6276 | "Display routes matching the communities\n" |
| 6277 | "community number\n" |
| 6278 | "Do not send outside local AS (well-known community)\n" |
| 6279 | "Do not advertise to any peer (well-known community)\n" |
| 6280 | "Do not export to next AS (well-known community)\n" |
| 6281 | "community number\n" |
| 6282 | "Do not send outside local AS (well-known community)\n" |
| 6283 | "Do not advertise to any peer (well-known community)\n" |
| 6284 | "Do not export to next AS (well-known community)\n" |
| 6285 | "community number\n" |
| 6286 | "Do not send outside local AS (well-known community)\n" |
| 6287 | "Do not advertise to any peer (well-known community)\n" |
| 6288 | "Do not export to next AS (well-known community)\n" |
| 6289 | "Exact match of the communities") |
| 6290 | |
| 6291 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 6292 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 6293 | "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", |
| 6294 | SHOW_STR |
| 6295 | IP_STR |
| 6296 | BGP_STR |
| 6297 | "Address family\n" |
| 6298 | "Address Family modifier\n" |
| 6299 | "Address Family modifier\n" |
| 6300 | "Display routes matching the communities\n" |
| 6301 | "community number\n" |
| 6302 | "Do not send outside local AS (well-known community)\n" |
| 6303 | "Do not advertise to any peer (well-known community)\n" |
| 6304 | "Do not export to next AS (well-known community)\n" |
| 6305 | "community number\n" |
| 6306 | "Do not send outside local AS (well-known community)\n" |
| 6307 | "Do not advertise to any peer (well-known community)\n" |
| 6308 | "Do not export to next AS (well-known community)\n" |
| 6309 | "community number\n" |
| 6310 | "Do not send outside local AS (well-known community)\n" |
| 6311 | "Do not advertise to any peer (well-known community)\n" |
| 6312 | "Do not export to next AS (well-known community)\n" |
| 6313 | "community number\n" |
| 6314 | "Do not send outside local AS (well-known community)\n" |
| 6315 | "Do not advertise to any peer (well-known community)\n" |
| 6316 | "Do not export to next AS (well-known community)\n" |
| 6317 | "Exact match of the communities") |
| 6318 | |
| 6319 | #ifdef HAVE_IPV6 |
| 6320 | DEFUN (show_bgp_community, |
| 6321 | show_bgp_community_cmd, |
| 6322 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6323 | SHOW_STR |
| 6324 | BGP_STR |
| 6325 | "Display routes matching the communities\n" |
| 6326 | "community number\n" |
| 6327 | "Do not send outside local AS (well-known community)\n" |
| 6328 | "Do not advertise to any peer (well-known community)\n" |
| 6329 | "Do not export to next AS (well-known community)\n") |
| 6330 | { |
| 6331 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 6332 | } |
| 6333 | |
| 6334 | ALIAS (show_bgp_community, |
| 6335 | show_bgp_ipv6_community_cmd, |
| 6336 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 6337 | SHOW_STR |
| 6338 | BGP_STR |
| 6339 | "Address family\n" |
| 6340 | "Display routes matching the communities\n" |
| 6341 | "community number\n" |
| 6342 | "Do not send outside local AS (well-known community)\n" |
| 6343 | "Do not advertise to any peer (well-known community)\n" |
| 6344 | "Do not export to next AS (well-known community)\n") |
| 6345 | |
| 6346 | ALIAS (show_bgp_community, |
| 6347 | show_bgp_community2_cmd, |
| 6348 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6349 | SHOW_STR |
| 6350 | BGP_STR |
| 6351 | "Display routes matching the communities\n" |
| 6352 | "community number\n" |
| 6353 | "Do not send outside local AS (well-known community)\n" |
| 6354 | "Do not advertise to any peer (well-known community)\n" |
| 6355 | "Do not export to next AS (well-known community)\n" |
| 6356 | "community number\n" |
| 6357 | "Do not send outside local AS (well-known community)\n" |
| 6358 | "Do not advertise to any peer (well-known community)\n" |
| 6359 | "Do not export to next AS (well-known community)\n") |
| 6360 | |
| 6361 | ALIAS (show_bgp_community, |
| 6362 | show_bgp_ipv6_community2_cmd, |
| 6363 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6364 | SHOW_STR |
| 6365 | BGP_STR |
| 6366 | "Address family\n" |
| 6367 | "Display routes matching the communities\n" |
| 6368 | "community number\n" |
| 6369 | "Do not send outside local AS (well-known community)\n" |
| 6370 | "Do not advertise to any peer (well-known community)\n" |
| 6371 | "Do not export to next AS (well-known community)\n" |
| 6372 | "community number\n" |
| 6373 | "Do not send outside local AS (well-known community)\n" |
| 6374 | "Do not advertise to any peer (well-known community)\n" |
| 6375 | "Do not export to next AS (well-known community)\n") |
| 6376 | |
| 6377 | ALIAS (show_bgp_community, |
| 6378 | show_bgp_community3_cmd, |
| 6379 | "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)", |
| 6380 | SHOW_STR |
| 6381 | BGP_STR |
| 6382 | "Display routes matching the communities\n" |
| 6383 | "community number\n" |
| 6384 | "Do not send outside local AS (well-known community)\n" |
| 6385 | "Do not advertise to any peer (well-known community)\n" |
| 6386 | "Do not export to next AS (well-known community)\n" |
| 6387 | "community number\n" |
| 6388 | "Do not send outside local AS (well-known community)\n" |
| 6389 | "Do not advertise to any peer (well-known community)\n" |
| 6390 | "Do not export to next AS (well-known community)\n" |
| 6391 | "community number\n" |
| 6392 | "Do not send outside local AS (well-known community)\n" |
| 6393 | "Do not advertise to any peer (well-known community)\n" |
| 6394 | "Do not export to next AS (well-known community)\n") |
| 6395 | |
| 6396 | ALIAS (show_bgp_community, |
| 6397 | show_bgp_ipv6_community3_cmd, |
| 6398 | "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)", |
| 6399 | SHOW_STR |
| 6400 | BGP_STR |
| 6401 | "Address family\n" |
| 6402 | "Display routes matching the communities\n" |
| 6403 | "community number\n" |
| 6404 | "Do not send outside local AS (well-known community)\n" |
| 6405 | "Do not advertise to any peer (well-known community)\n" |
| 6406 | "Do not export to next AS (well-known community)\n" |
| 6407 | "community number\n" |
| 6408 | "Do not send outside local AS (well-known community)\n" |
| 6409 | "Do not advertise to any peer (well-known community)\n" |
| 6410 | "Do not export to next AS (well-known community)\n" |
| 6411 | "community number\n" |
| 6412 | "Do not send outside local AS (well-known community)\n" |
| 6413 | "Do not advertise to any peer (well-known community)\n" |
| 6414 | "Do not export to next AS (well-known community)\n") |
| 6415 | |
| 6416 | ALIAS (show_bgp_community, |
| 6417 | show_bgp_community4_cmd, |
| 6418 | "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)", |
| 6419 | SHOW_STR |
| 6420 | BGP_STR |
| 6421 | "Display routes matching the communities\n" |
| 6422 | "community number\n" |
| 6423 | "Do not send outside local AS (well-known community)\n" |
| 6424 | "Do not advertise to any peer (well-known community)\n" |
| 6425 | "Do not export to next AS (well-known community)\n" |
| 6426 | "community number\n" |
| 6427 | "Do not send outside local AS (well-known community)\n" |
| 6428 | "Do not advertise to any peer (well-known community)\n" |
| 6429 | "Do not export to next AS (well-known community)\n" |
| 6430 | "community number\n" |
| 6431 | "Do not send outside local AS (well-known community)\n" |
| 6432 | "Do not advertise to any peer (well-known community)\n" |
| 6433 | "Do not export to next AS (well-known community)\n" |
| 6434 | "community number\n" |
| 6435 | "Do not send outside local AS (well-known community)\n" |
| 6436 | "Do not advertise to any peer (well-known community)\n" |
| 6437 | "Do not export to next AS (well-known community)\n") |
| 6438 | |
| 6439 | ALIAS (show_bgp_community, |
| 6440 | show_bgp_ipv6_community4_cmd, |
| 6441 | "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)", |
| 6442 | SHOW_STR |
| 6443 | BGP_STR |
| 6444 | "Address family\n" |
| 6445 | "Display routes matching the communities\n" |
| 6446 | "community number\n" |
| 6447 | "Do not send outside local AS (well-known community)\n" |
| 6448 | "Do not advertise to any peer (well-known community)\n" |
| 6449 | "Do not export to next AS (well-known community)\n" |
| 6450 | "community number\n" |
| 6451 | "Do not send outside local AS (well-known community)\n" |
| 6452 | "Do not advertise to any peer (well-known community)\n" |
| 6453 | "Do not export to next AS (well-known community)\n" |
| 6454 | "community number\n" |
| 6455 | "Do not send outside local AS (well-known community)\n" |
| 6456 | "Do not advertise to any peer (well-known community)\n" |
| 6457 | "Do not export to next AS (well-known community)\n" |
| 6458 | "community number\n" |
| 6459 | "Do not send outside local AS (well-known community)\n" |
| 6460 | "Do not advertise to any peer (well-known community)\n" |
| 6461 | "Do not export to next AS (well-known community)\n") |
| 6462 | |
| 6463 | /* old command */ |
| 6464 | DEFUN (show_ipv6_bgp_community, |
| 6465 | show_ipv6_bgp_community_cmd, |
| 6466 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6467 | SHOW_STR |
| 6468 | IPV6_STR |
| 6469 | BGP_STR |
| 6470 | "Display routes matching the communities\n" |
| 6471 | "community number\n" |
| 6472 | "Do not send outside local AS (well-known community)\n" |
| 6473 | "Do not advertise to any peer (well-known community)\n" |
| 6474 | "Do not export to next AS (well-known community)\n") |
| 6475 | { |
| 6476 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 6477 | } |
| 6478 | |
| 6479 | /* old command */ |
| 6480 | ALIAS (show_ipv6_bgp_community, |
| 6481 | show_ipv6_bgp_community2_cmd, |
| 6482 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6483 | SHOW_STR |
| 6484 | IPV6_STR |
| 6485 | BGP_STR |
| 6486 | "Display routes matching the communities\n" |
| 6487 | "community number\n" |
| 6488 | "Do not send outside local AS (well-known community)\n" |
| 6489 | "Do not advertise to any peer (well-known community)\n" |
| 6490 | "Do not export to next AS (well-known community)\n" |
| 6491 | "community number\n" |
| 6492 | "Do not send outside local AS (well-known community)\n" |
| 6493 | "Do not advertise to any peer (well-known community)\n" |
| 6494 | "Do not export to next AS (well-known community)\n") |
| 6495 | |
| 6496 | /* old command */ |
| 6497 | ALIAS (show_ipv6_bgp_community, |
| 6498 | show_ipv6_bgp_community3_cmd, |
| 6499 | "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)", |
| 6500 | SHOW_STR |
| 6501 | IPV6_STR |
| 6502 | BGP_STR |
| 6503 | "Display routes matching the communities\n" |
| 6504 | "community number\n" |
| 6505 | "Do not send outside local AS (well-known community)\n" |
| 6506 | "Do not advertise to any peer (well-known community)\n" |
| 6507 | "Do not export to next AS (well-known community)\n" |
| 6508 | "community number\n" |
| 6509 | "Do not send outside local AS (well-known community)\n" |
| 6510 | "Do not advertise to any peer (well-known community)\n" |
| 6511 | "Do not export to next AS (well-known community)\n" |
| 6512 | "community number\n" |
| 6513 | "Do not send outside local AS (well-known community)\n" |
| 6514 | "Do not advertise to any peer (well-known community)\n" |
| 6515 | "Do not export to next AS (well-known community)\n") |
| 6516 | |
| 6517 | /* old command */ |
| 6518 | ALIAS (show_ipv6_bgp_community, |
| 6519 | show_ipv6_bgp_community4_cmd, |
| 6520 | "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)", |
| 6521 | SHOW_STR |
| 6522 | IPV6_STR |
| 6523 | BGP_STR |
| 6524 | "Display routes matching the communities\n" |
| 6525 | "community number\n" |
| 6526 | "Do not send outside local AS (well-known community)\n" |
| 6527 | "Do not advertise to any peer (well-known community)\n" |
| 6528 | "Do not export to next AS (well-known community)\n" |
| 6529 | "community number\n" |
| 6530 | "Do not send outside local AS (well-known community)\n" |
| 6531 | "Do not advertise to any peer (well-known community)\n" |
| 6532 | "Do not export to next AS (well-known community)\n" |
| 6533 | "community number\n" |
| 6534 | "Do not send outside local AS (well-known community)\n" |
| 6535 | "Do not advertise to any peer (well-known community)\n" |
| 6536 | "Do not export to next AS (well-known community)\n" |
| 6537 | "community number\n" |
| 6538 | "Do not send outside local AS (well-known community)\n" |
| 6539 | "Do not advertise to any peer (well-known community)\n" |
| 6540 | "Do not export to next AS (well-known community)\n") |
| 6541 | |
| 6542 | DEFUN (show_bgp_community_exact, |
| 6543 | show_bgp_community_exact_cmd, |
| 6544 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6545 | SHOW_STR |
| 6546 | BGP_STR |
| 6547 | "Display routes matching the communities\n" |
| 6548 | "community number\n" |
| 6549 | "Do not send outside local AS (well-known community)\n" |
| 6550 | "Do not advertise to any peer (well-known community)\n" |
| 6551 | "Do not export to next AS (well-known community)\n" |
| 6552 | "Exact match of the communities") |
| 6553 | { |
| 6554 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 6555 | } |
| 6556 | |
| 6557 | ALIAS (show_bgp_community_exact, |
| 6558 | show_bgp_ipv6_community_exact_cmd, |
| 6559 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6560 | SHOW_STR |
| 6561 | BGP_STR |
| 6562 | "Address family\n" |
| 6563 | "Display routes matching the communities\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 | "Exact match of the communities") |
| 6569 | |
| 6570 | ALIAS (show_bgp_community_exact, |
| 6571 | show_bgp_community2_exact_cmd, |
| 6572 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6573 | SHOW_STR |
| 6574 | BGP_STR |
| 6575 | "Display routes matching the communities\n" |
| 6576 | "community number\n" |
| 6577 | "Do not send outside local AS (well-known community)\n" |
| 6578 | "Do not advertise to any peer (well-known community)\n" |
| 6579 | "Do not export to next AS (well-known community)\n" |
| 6580 | "community number\n" |
| 6581 | "Do not send outside local AS (well-known community)\n" |
| 6582 | "Do not advertise to any peer (well-known community)\n" |
| 6583 | "Do not export to next AS (well-known community)\n" |
| 6584 | "Exact match of the communities") |
| 6585 | |
| 6586 | ALIAS (show_bgp_community_exact, |
| 6587 | show_bgp_ipv6_community2_exact_cmd, |
| 6588 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6589 | SHOW_STR |
| 6590 | BGP_STR |
| 6591 | "Address family\n" |
| 6592 | "Display routes matching the communities\n" |
| 6593 | "community number\n" |
| 6594 | "Do not send outside local AS (well-known community)\n" |
| 6595 | "Do not advertise to any peer (well-known community)\n" |
| 6596 | "Do not export to next AS (well-known community)\n" |
| 6597 | "community number\n" |
| 6598 | "Do not send outside local AS (well-known community)\n" |
| 6599 | "Do not advertise to any peer (well-known community)\n" |
| 6600 | "Do not export to next AS (well-known community)\n" |
| 6601 | "Exact match of the communities") |
| 6602 | |
| 6603 | ALIAS (show_bgp_community_exact, |
| 6604 | show_bgp_community3_exact_cmd, |
| 6605 | "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", |
| 6606 | SHOW_STR |
| 6607 | BGP_STR |
| 6608 | "Display routes matching the communities\n" |
| 6609 | "community number\n" |
| 6610 | "Do not send outside local AS (well-known community)\n" |
| 6611 | "Do not advertise to any peer (well-known community)\n" |
| 6612 | "Do not export to next AS (well-known community)\n" |
| 6613 | "community number\n" |
| 6614 | "Do not send outside local AS (well-known community)\n" |
| 6615 | "Do not advertise to any peer (well-known community)\n" |
| 6616 | "Do not export to next AS (well-known community)\n" |
| 6617 | "community number\n" |
| 6618 | "Do not send outside local AS (well-known community)\n" |
| 6619 | "Do not advertise to any peer (well-known community)\n" |
| 6620 | "Do not export to next AS (well-known community)\n" |
| 6621 | "Exact match of the communities") |
| 6622 | |
| 6623 | ALIAS (show_bgp_community_exact, |
| 6624 | show_bgp_ipv6_community3_exact_cmd, |
| 6625 | "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", |
| 6626 | SHOW_STR |
| 6627 | BGP_STR |
| 6628 | "Address family\n" |
| 6629 | "Display routes matching the communities\n" |
| 6630 | "community number\n" |
| 6631 | "Do not send outside local AS (well-known community)\n" |
| 6632 | "Do not advertise to any peer (well-known community)\n" |
| 6633 | "Do not export to next AS (well-known community)\n" |
| 6634 | "community number\n" |
| 6635 | "Do not send outside local AS (well-known community)\n" |
| 6636 | "Do not advertise to any peer (well-known community)\n" |
| 6637 | "Do not export to next AS (well-known community)\n" |
| 6638 | "community number\n" |
| 6639 | "Do not send outside local AS (well-known community)\n" |
| 6640 | "Do not advertise to any peer (well-known community)\n" |
| 6641 | "Do not export to next AS (well-known community)\n" |
| 6642 | "Exact match of the communities") |
| 6643 | |
| 6644 | ALIAS (show_bgp_community_exact, |
| 6645 | show_bgp_community4_exact_cmd, |
| 6646 | "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", |
| 6647 | SHOW_STR |
| 6648 | BGP_STR |
| 6649 | "Display routes matching the communities\n" |
| 6650 | "community number\n" |
| 6651 | "Do not send outside local AS (well-known community)\n" |
| 6652 | "Do not advertise to any peer (well-known community)\n" |
| 6653 | "Do not export to next AS (well-known community)\n" |
| 6654 | "community number\n" |
| 6655 | "Do not send outside local AS (well-known community)\n" |
| 6656 | "Do not advertise to any peer (well-known community)\n" |
| 6657 | "Do not export to next AS (well-known community)\n" |
| 6658 | "community number\n" |
| 6659 | "Do not send outside local AS (well-known community)\n" |
| 6660 | "Do not advertise to any peer (well-known community)\n" |
| 6661 | "Do not export to next AS (well-known community)\n" |
| 6662 | "community number\n" |
| 6663 | "Do not send outside local AS (well-known community)\n" |
| 6664 | "Do not advertise to any peer (well-known community)\n" |
| 6665 | "Do not export to next AS (well-known community)\n" |
| 6666 | "Exact match of the communities") |
| 6667 | |
| 6668 | ALIAS (show_bgp_community_exact, |
| 6669 | show_bgp_ipv6_community4_exact_cmd, |
| 6670 | "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", |
| 6671 | SHOW_STR |
| 6672 | BGP_STR |
| 6673 | "Address family\n" |
| 6674 | "Display routes matching the communities\n" |
| 6675 | "community number\n" |
| 6676 | "Do not send outside local AS (well-known community)\n" |
| 6677 | "Do not advertise to any peer (well-known community)\n" |
| 6678 | "Do not export to next AS (well-known community)\n" |
| 6679 | "community number\n" |
| 6680 | "Do not send outside local AS (well-known community)\n" |
| 6681 | "Do not advertise to any peer (well-known community)\n" |
| 6682 | "Do not export to next AS (well-known community)\n" |
| 6683 | "community number\n" |
| 6684 | "Do not send outside local AS (well-known community)\n" |
| 6685 | "Do not advertise to any peer (well-known community)\n" |
| 6686 | "Do not export to next AS (well-known community)\n" |
| 6687 | "community number\n" |
| 6688 | "Do not send outside local AS (well-known community)\n" |
| 6689 | "Do not advertise to any peer (well-known community)\n" |
| 6690 | "Do not export to next AS (well-known community)\n" |
| 6691 | "Exact match of the communities") |
| 6692 | |
| 6693 | /* old command */ |
| 6694 | DEFUN (show_ipv6_bgp_community_exact, |
| 6695 | show_ipv6_bgp_community_exact_cmd, |
| 6696 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6697 | SHOW_STR |
| 6698 | IPV6_STR |
| 6699 | BGP_STR |
| 6700 | "Display routes matching the communities\n" |
| 6701 | "community number\n" |
| 6702 | "Do not send outside local AS (well-known community)\n" |
| 6703 | "Do not advertise to any peer (well-known community)\n" |
| 6704 | "Do not export to next AS (well-known community)\n" |
| 6705 | "Exact match of the communities") |
| 6706 | { |
| 6707 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 6708 | } |
| 6709 | |
| 6710 | /* old command */ |
| 6711 | ALIAS (show_ipv6_bgp_community_exact, |
| 6712 | show_ipv6_bgp_community2_exact_cmd, |
| 6713 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6714 | SHOW_STR |
| 6715 | IPV6_STR |
| 6716 | BGP_STR |
| 6717 | "Display routes matching the communities\n" |
| 6718 | "community number\n" |
| 6719 | "Do not send outside local AS (well-known community)\n" |
| 6720 | "Do not advertise to any peer (well-known community)\n" |
| 6721 | "Do not export to next AS (well-known community)\n" |
| 6722 | "community number\n" |
| 6723 | "Do not send outside local AS (well-known community)\n" |
| 6724 | "Do not advertise to any peer (well-known community)\n" |
| 6725 | "Do not export to next AS (well-known community)\n" |
| 6726 | "Exact match of the communities") |
| 6727 | |
| 6728 | /* old command */ |
| 6729 | ALIAS (show_ipv6_bgp_community_exact, |
| 6730 | show_ipv6_bgp_community3_exact_cmd, |
| 6731 | "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", |
| 6732 | SHOW_STR |
| 6733 | IPV6_STR |
| 6734 | BGP_STR |
| 6735 | "Display routes matching the communities\n" |
| 6736 | "community number\n" |
| 6737 | "Do not send outside local AS (well-known community)\n" |
| 6738 | "Do not advertise to any peer (well-known community)\n" |
| 6739 | "Do not export to next AS (well-known community)\n" |
| 6740 | "community number\n" |
| 6741 | "Do not send outside local AS (well-known community)\n" |
| 6742 | "Do not advertise to any peer (well-known community)\n" |
| 6743 | "Do not export to next AS (well-known community)\n" |
| 6744 | "community number\n" |
| 6745 | "Do not send outside local AS (well-known community)\n" |
| 6746 | "Do not advertise to any peer (well-known community)\n" |
| 6747 | "Do not export to next AS (well-known community)\n" |
| 6748 | "Exact match of the communities") |
| 6749 | |
| 6750 | /* old command */ |
| 6751 | ALIAS (show_ipv6_bgp_community_exact, |
| 6752 | show_ipv6_bgp_community4_exact_cmd, |
| 6753 | "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", |
| 6754 | SHOW_STR |
| 6755 | IPV6_STR |
| 6756 | BGP_STR |
| 6757 | "Display routes matching the communities\n" |
| 6758 | "community number\n" |
| 6759 | "Do not send outside local AS (well-known community)\n" |
| 6760 | "Do not advertise to any peer (well-known community)\n" |
| 6761 | "Do not export to next AS (well-known community)\n" |
| 6762 | "community number\n" |
| 6763 | "Do not send outside local AS (well-known community)\n" |
| 6764 | "Do not advertise to any peer (well-known community)\n" |
| 6765 | "Do not export to next AS (well-known community)\n" |
| 6766 | "community number\n" |
| 6767 | "Do not send outside local AS (well-known community)\n" |
| 6768 | "Do not advertise to any peer (well-known community)\n" |
| 6769 | "Do not export to next AS (well-known community)\n" |
| 6770 | "community number\n" |
| 6771 | "Do not send outside local AS (well-known community)\n" |
| 6772 | "Do not advertise to any peer (well-known community)\n" |
| 6773 | "Do not export to next AS (well-known community)\n" |
| 6774 | "Exact match of the communities") |
| 6775 | |
| 6776 | /* old command */ |
| 6777 | DEFUN (show_ipv6_mbgp_community, |
| 6778 | show_ipv6_mbgp_community_cmd, |
| 6779 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6780 | SHOW_STR |
| 6781 | IPV6_STR |
| 6782 | MBGP_STR |
| 6783 | "Display routes matching the communities\n" |
| 6784 | "community number\n" |
| 6785 | "Do not send outside local AS (well-known community)\n" |
| 6786 | "Do not advertise to any peer (well-known community)\n" |
| 6787 | "Do not export to next AS (well-known community)\n") |
| 6788 | { |
| 6789 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 6790 | } |
| 6791 | |
| 6792 | /* old command */ |
| 6793 | ALIAS (show_ipv6_mbgp_community, |
| 6794 | show_ipv6_mbgp_community2_cmd, |
| 6795 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6796 | SHOW_STR |
| 6797 | IPV6_STR |
| 6798 | MBGP_STR |
| 6799 | "Display routes matching the communities\n" |
| 6800 | "community number\n" |
| 6801 | "Do not send outside local AS (well-known community)\n" |
| 6802 | "Do not advertise to any peer (well-known community)\n" |
| 6803 | "Do not export to next AS (well-known community)\n" |
| 6804 | "community number\n" |
| 6805 | "Do not send outside local AS (well-known community)\n" |
| 6806 | "Do not advertise to any peer (well-known community)\n" |
| 6807 | "Do not export to next AS (well-known community)\n") |
| 6808 | |
| 6809 | /* old command */ |
| 6810 | ALIAS (show_ipv6_mbgp_community, |
| 6811 | show_ipv6_mbgp_community3_cmd, |
| 6812 | "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)", |
| 6813 | SHOW_STR |
| 6814 | IPV6_STR |
| 6815 | MBGP_STR |
| 6816 | "Display routes matching the communities\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 | "community number\n" |
| 6822 | "Do not send outside local AS (well-known community)\n" |
| 6823 | "Do not advertise to any peer (well-known community)\n" |
| 6824 | "Do not export to next AS (well-known community)\n" |
| 6825 | "community number\n" |
| 6826 | "Do not send outside local AS (well-known community)\n" |
| 6827 | "Do not advertise to any peer (well-known community)\n" |
| 6828 | "Do not export to next AS (well-known community)\n") |
| 6829 | |
| 6830 | /* old command */ |
| 6831 | ALIAS (show_ipv6_mbgp_community, |
| 6832 | show_ipv6_mbgp_community4_cmd, |
| 6833 | "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)", |
| 6834 | SHOW_STR |
| 6835 | IPV6_STR |
| 6836 | MBGP_STR |
| 6837 | "Display routes matching the communities\n" |
| 6838 | "community number\n" |
| 6839 | "Do not send outside local AS (well-known community)\n" |
| 6840 | "Do not advertise to any peer (well-known community)\n" |
| 6841 | "Do not export to next AS (well-known community)\n" |
| 6842 | "community number\n" |
| 6843 | "Do not send outside local AS (well-known community)\n" |
| 6844 | "Do not advertise to any peer (well-known community)\n" |
| 6845 | "Do not export to next AS (well-known community)\n" |
| 6846 | "community number\n" |
| 6847 | "Do not send outside local AS (well-known community)\n" |
| 6848 | "Do not advertise to any peer (well-known community)\n" |
| 6849 | "Do not export to next AS (well-known community)\n" |
| 6850 | "community number\n" |
| 6851 | "Do not send outside local AS (well-known community)\n" |
| 6852 | "Do not advertise to any peer (well-known community)\n" |
| 6853 | "Do not export to next AS (well-known community)\n") |
| 6854 | |
| 6855 | /* old command */ |
| 6856 | DEFUN (show_ipv6_mbgp_community_exact, |
| 6857 | show_ipv6_mbgp_community_exact_cmd, |
| 6858 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6859 | SHOW_STR |
| 6860 | IPV6_STR |
| 6861 | MBGP_STR |
| 6862 | "Display routes matching the communities\n" |
| 6863 | "community number\n" |
| 6864 | "Do not send outside local AS (well-known community)\n" |
| 6865 | "Do not advertise to any peer (well-known community)\n" |
| 6866 | "Do not export to next AS (well-known community)\n" |
| 6867 | "Exact match of the communities") |
| 6868 | { |
| 6869 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 6870 | } |
| 6871 | |
| 6872 | /* old command */ |
| 6873 | ALIAS (show_ipv6_mbgp_community_exact, |
| 6874 | show_ipv6_mbgp_community2_exact_cmd, |
| 6875 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6876 | SHOW_STR |
| 6877 | IPV6_STR |
| 6878 | MBGP_STR |
| 6879 | "Display routes matching the communities\n" |
| 6880 | "community number\n" |
| 6881 | "Do not send outside local AS (well-known community)\n" |
| 6882 | "Do not advertise to any peer (well-known community)\n" |
| 6883 | "Do not export to next AS (well-known community)\n" |
| 6884 | "community number\n" |
| 6885 | "Do not send outside local AS (well-known community)\n" |
| 6886 | "Do not advertise to any peer (well-known community)\n" |
| 6887 | "Do not export to next AS (well-known community)\n" |
| 6888 | "Exact match of the communities") |
| 6889 | |
| 6890 | /* old command */ |
| 6891 | ALIAS (show_ipv6_mbgp_community_exact, |
| 6892 | show_ipv6_mbgp_community3_exact_cmd, |
| 6893 | "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", |
| 6894 | SHOW_STR |
| 6895 | IPV6_STR |
| 6896 | MBGP_STR |
| 6897 | "Display routes matching the communities\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 | "community number\n" |
| 6903 | "Do not send outside local AS (well-known community)\n" |
| 6904 | "Do not advertise to any peer (well-known community)\n" |
| 6905 | "Do not export to next AS (well-known community)\n" |
| 6906 | "community number\n" |
| 6907 | "Do not send outside local AS (well-known community)\n" |
| 6908 | "Do not advertise to any peer (well-known community)\n" |
| 6909 | "Do not export to next AS (well-known community)\n" |
| 6910 | "Exact match of the communities") |
| 6911 | |
| 6912 | /* old command */ |
| 6913 | ALIAS (show_ipv6_mbgp_community_exact, |
| 6914 | show_ipv6_mbgp_community4_exact_cmd, |
| 6915 | "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", |
| 6916 | SHOW_STR |
| 6917 | IPV6_STR |
| 6918 | MBGP_STR |
| 6919 | "Display routes matching the communities\n" |
| 6920 | "community number\n" |
| 6921 | "Do not send outside local AS (well-known community)\n" |
| 6922 | "Do not advertise to any peer (well-known community)\n" |
| 6923 | "Do not export to next AS (well-known community)\n" |
| 6924 | "community number\n" |
| 6925 | "Do not send outside local AS (well-known community)\n" |
| 6926 | "Do not advertise to any peer (well-known community)\n" |
| 6927 | "Do not export to next AS (well-known community)\n" |
| 6928 | "community number\n" |
| 6929 | "Do not send outside local AS (well-known community)\n" |
| 6930 | "Do not advertise to any peer (well-known community)\n" |
| 6931 | "Do not export to next AS (well-known community)\n" |
| 6932 | "community number\n" |
| 6933 | "Do not send outside local AS (well-known community)\n" |
| 6934 | "Do not advertise to any peer (well-known community)\n" |
| 6935 | "Do not export to next AS (well-known community)\n" |
| 6936 | "Exact match of the communities") |
| 6937 | #endif /* HAVE_IPV6 */ |
| 6938 | |
| 6939 | int |
| 6940 | bgp_show_community_list (struct vty *vty, char *com, int exact, |
| 6941 | u_int16_t afi, u_char safi) |
| 6942 | { |
| 6943 | struct community_list *list; |
| 6944 | |
| 6945 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_AUTO); |
| 6946 | if (list == NULL) |
| 6947 | { |
| 6948 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 6949 | VTY_NEWLINE); |
| 6950 | return CMD_WARNING; |
| 6951 | } |
| 6952 | |
| 6953 | vty->output_arg = list; |
| 6954 | |
| 6955 | if (exact) |
| 6956 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_list_exact); |
| 6957 | |
| 6958 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_list); |
| 6959 | } |
| 6960 | |
| 6961 | DEFUN (show_ip_bgp_community_list, |
| 6962 | show_ip_bgp_community_list_cmd, |
| 6963 | "show ip bgp community-list WORD", |
| 6964 | SHOW_STR |
| 6965 | IP_STR |
| 6966 | BGP_STR |
| 6967 | "Display routes matching the community-list\n" |
| 6968 | "community-list name\n") |
| 6969 | { |
| 6970 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 6971 | } |
| 6972 | |
| 6973 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 6974 | show_ip_bgp_ipv4_community_list_cmd, |
| 6975 | "show ip bgp ipv4 (unicast|multicast) community-list WORD", |
| 6976 | SHOW_STR |
| 6977 | IP_STR |
| 6978 | BGP_STR |
| 6979 | "Address family\n" |
| 6980 | "Address Family modifier\n" |
| 6981 | "Address Family modifier\n" |
| 6982 | "Display routes matching the community-list\n" |
| 6983 | "community-list name\n") |
| 6984 | { |
| 6985 | if (strncmp (argv[0], "m", 1) == 0) |
| 6986 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 6987 | |
| 6988 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 6989 | } |
| 6990 | |
| 6991 | DEFUN (show_ip_bgp_community_list_exact, |
| 6992 | show_ip_bgp_community_list_exact_cmd, |
| 6993 | "show ip bgp community-list WORD exact-match", |
| 6994 | SHOW_STR |
| 6995 | IP_STR |
| 6996 | BGP_STR |
| 6997 | "Display routes matching the community-list\n" |
| 6998 | "community-list name\n" |
| 6999 | "Exact match of the communities\n") |
| 7000 | { |
| 7001 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 7002 | } |
| 7003 | |
| 7004 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 7005 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 7006 | "show ip bgp ipv4 (unicast|multicast) community-list WORD exact-match", |
| 7007 | SHOW_STR |
| 7008 | IP_STR |
| 7009 | BGP_STR |
| 7010 | "Address family\n" |
| 7011 | "Address Family modifier\n" |
| 7012 | "Address Family modifier\n" |
| 7013 | "Display routes matching the community-list\n" |
| 7014 | "community-list name\n" |
| 7015 | "Exact match of the communities\n") |
| 7016 | { |
| 7017 | if (strncmp (argv[0], "m", 1) == 0) |
| 7018 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 7019 | |
| 7020 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 7021 | } |
| 7022 | |
| 7023 | #ifdef HAVE_IPV6 |
| 7024 | DEFUN (show_bgp_community_list, |
| 7025 | show_bgp_community_list_cmd, |
| 7026 | "show bgp community-list WORD", |
| 7027 | SHOW_STR |
| 7028 | BGP_STR |
| 7029 | "Display routes matching the community-list\n" |
| 7030 | "community-list name\n") |
| 7031 | { |
| 7032 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7033 | } |
| 7034 | |
| 7035 | ALIAS (show_bgp_community_list, |
| 7036 | show_bgp_ipv6_community_list_cmd, |
| 7037 | "show bgp ipv6 community-list WORD", |
| 7038 | SHOW_STR |
| 7039 | BGP_STR |
| 7040 | "Address family\n" |
| 7041 | "Display routes matching the community-list\n" |
| 7042 | "community-list name\n") |
| 7043 | |
| 7044 | /* old command */ |
| 7045 | DEFUN (show_ipv6_bgp_community_list, |
| 7046 | show_ipv6_bgp_community_list_cmd, |
| 7047 | "show ipv6 bgp community-list WORD", |
| 7048 | SHOW_STR |
| 7049 | IPV6_STR |
| 7050 | BGP_STR |
| 7051 | "Display routes matching the community-list\n" |
| 7052 | "community-list name\n") |
| 7053 | { |
| 7054 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7055 | } |
| 7056 | |
| 7057 | /* old command */ |
| 7058 | DEFUN (show_ipv6_mbgp_community_list, |
| 7059 | show_ipv6_mbgp_community_list_cmd, |
| 7060 | "show ipv6 mbgp community-list WORD", |
| 7061 | SHOW_STR |
| 7062 | IPV6_STR |
| 7063 | MBGP_STR |
| 7064 | "Display routes matching the community-list\n" |
| 7065 | "community-list name\n") |
| 7066 | { |
| 7067 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 7068 | } |
| 7069 | |
| 7070 | DEFUN (show_bgp_community_list_exact, |
| 7071 | show_bgp_community_list_exact_cmd, |
| 7072 | "show bgp community-list WORD exact-match", |
| 7073 | SHOW_STR |
| 7074 | BGP_STR |
| 7075 | "Display routes matching the community-list\n" |
| 7076 | "community-list name\n" |
| 7077 | "Exact match of the communities\n") |
| 7078 | { |
| 7079 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7080 | } |
| 7081 | |
| 7082 | ALIAS (show_bgp_community_list_exact, |
| 7083 | show_bgp_ipv6_community_list_exact_cmd, |
| 7084 | "show bgp ipv6 community-list WORD exact-match", |
| 7085 | SHOW_STR |
| 7086 | BGP_STR |
| 7087 | "Address family\n" |
| 7088 | "Display routes matching the community-list\n" |
| 7089 | "community-list name\n" |
| 7090 | "Exact match of the communities\n") |
| 7091 | |
| 7092 | /* old command */ |
| 7093 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 7094 | show_ipv6_bgp_community_list_exact_cmd, |
| 7095 | "show ipv6 bgp community-list WORD exact-match", |
| 7096 | SHOW_STR |
| 7097 | IPV6_STR |
| 7098 | BGP_STR |
| 7099 | "Display routes matching the community-list\n" |
| 7100 | "community-list name\n" |
| 7101 | "Exact match of the communities\n") |
| 7102 | { |
| 7103 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7104 | } |
| 7105 | |
| 7106 | /* old command */ |
| 7107 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 7108 | show_ipv6_mbgp_community_list_exact_cmd, |
| 7109 | "show ipv6 mbgp community-list WORD exact-match", |
| 7110 | SHOW_STR |
| 7111 | IPV6_STR |
| 7112 | MBGP_STR |
| 7113 | "Display routes matching the community-list\n" |
| 7114 | "community-list name\n" |
| 7115 | "Exact match of the communities\n") |
| 7116 | { |
| 7117 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 7118 | } |
| 7119 | #endif /* HAVE_IPV6 */ |
| 7120 | |
| 7121 | void |
| 7122 | bgp_show_prefix_longer_clean (struct vty *vty) |
| 7123 | { |
| 7124 | struct prefix *p; |
| 7125 | |
| 7126 | p = vty->output_arg; |
| 7127 | prefix_free (p); |
| 7128 | } |
| 7129 | |
| 7130 | int |
| 7131 | bgp_show_prefix_longer (struct vty *vty, char *prefix, afi_t afi, |
| 7132 | safi_t safi, enum bgp_show_type type) |
| 7133 | { |
| 7134 | int ret; |
| 7135 | struct prefix *p; |
| 7136 | |
| 7137 | p = prefix_new(); |
| 7138 | |
| 7139 | ret = str2prefix (prefix, p); |
| 7140 | if (! ret) |
| 7141 | { |
| 7142 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 7143 | return CMD_WARNING; |
| 7144 | } |
| 7145 | |
| 7146 | vty->output_arg = p; |
| 7147 | vty->output_clean = bgp_show_prefix_longer_clean; |
| 7148 | |
| 7149 | return bgp_show (vty, NULL, afi, safi, type); |
| 7150 | } |
| 7151 | |
| 7152 | DEFUN (show_ip_bgp_prefix_longer, |
| 7153 | show_ip_bgp_prefix_longer_cmd, |
| 7154 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 7155 | SHOW_STR |
| 7156 | IP_STR |
| 7157 | BGP_STR |
| 7158 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7159 | "Display route and more specific routes\n") |
| 7160 | { |
| 7161 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7162 | bgp_show_type_prefix_longer); |
| 7163 | } |
| 7164 | |
| 7165 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 7166 | show_ip_bgp_flap_prefix_longer_cmd, |
| 7167 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 7168 | SHOW_STR |
| 7169 | IP_STR |
| 7170 | BGP_STR |
| 7171 | "Display flap statistics of routes\n" |
| 7172 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7173 | "Display route and more specific routes\n") |
| 7174 | { |
| 7175 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7176 | bgp_show_type_flap_prefix_longer); |
| 7177 | } |
| 7178 | |
| 7179 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 7180 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 7181 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 7182 | SHOW_STR |
| 7183 | IP_STR |
| 7184 | BGP_STR |
| 7185 | "Address family\n" |
| 7186 | "Address Family modifier\n" |
| 7187 | "Address Family modifier\n" |
| 7188 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7189 | "Display route and more specific routes\n") |
| 7190 | { |
| 7191 | if (strncmp (argv[0], "m", 1) == 0) |
| 7192 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7193 | bgp_show_type_prefix_longer); |
| 7194 | |
| 7195 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7196 | bgp_show_type_prefix_longer); |
| 7197 | } |
| 7198 | |
| 7199 | DEFUN (show_ip_bgp_flap_address, |
| 7200 | show_ip_bgp_flap_address_cmd, |
| 7201 | "show ip bgp flap-statistics A.B.C.D", |
| 7202 | SHOW_STR |
| 7203 | IP_STR |
| 7204 | BGP_STR |
| 7205 | "Display flap statistics of routes\n" |
| 7206 | "Network in the BGP routing table to display\n") |
| 7207 | { |
| 7208 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7209 | bgp_show_type_flap_address); |
| 7210 | } |
| 7211 | |
| 7212 | DEFUN (show_ip_bgp_flap_prefix, |
| 7213 | show_ip_bgp_flap_prefix_cmd, |
| 7214 | "show ip bgp flap-statistics A.B.C.D/M", |
| 7215 | SHOW_STR |
| 7216 | IP_STR |
| 7217 | BGP_STR |
| 7218 | "Display flap statistics of routes\n" |
| 7219 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7220 | { |
| 7221 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7222 | bgp_show_type_flap_prefix); |
| 7223 | } |
| 7224 | #ifdef HAVE_IPV6 |
| 7225 | DEFUN (show_bgp_prefix_longer, |
| 7226 | show_bgp_prefix_longer_cmd, |
| 7227 | "show bgp X:X::X:X/M longer-prefixes", |
| 7228 | SHOW_STR |
| 7229 | BGP_STR |
| 7230 | "IPv6 prefix <network>/<length>\n" |
| 7231 | "Display route and more specific routes\n") |
| 7232 | { |
| 7233 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7234 | bgp_show_type_prefix_longer); |
| 7235 | } |
| 7236 | |
| 7237 | ALIAS (show_bgp_prefix_longer, |
| 7238 | show_bgp_ipv6_prefix_longer_cmd, |
| 7239 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 7240 | SHOW_STR |
| 7241 | BGP_STR |
| 7242 | "Address family\n" |
| 7243 | "IPv6 prefix <network>/<length>\n" |
| 7244 | "Display route and more specific routes\n") |
| 7245 | |
| 7246 | /* old command */ |
| 7247 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 7248 | show_ipv6_bgp_prefix_longer_cmd, |
| 7249 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 7250 | SHOW_STR |
| 7251 | IPV6_STR |
| 7252 | BGP_STR |
| 7253 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 7254 | "Display route and more specific routes\n") |
| 7255 | { |
| 7256 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7257 | bgp_show_type_prefix_longer); |
| 7258 | } |
| 7259 | |
| 7260 | /* old command */ |
| 7261 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 7262 | show_ipv6_mbgp_prefix_longer_cmd, |
| 7263 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 7264 | SHOW_STR |
| 7265 | IPV6_STR |
| 7266 | MBGP_STR |
| 7267 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 7268 | "Display route and more specific routes\n") |
| 7269 | { |
| 7270 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7271 | bgp_show_type_prefix_longer); |
| 7272 | } |
| 7273 | #endif /* HAVE_IPV6 */ |
| 7274 | |
| 7275 | void |
| 7276 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 7277 | int in) |
| 7278 | { |
| 7279 | struct bgp_table *table; |
| 7280 | struct bgp_adj_in *ain; |
| 7281 | struct bgp_adj_out *adj; |
| 7282 | unsigned long output_count; |
| 7283 | struct bgp_node *rn; |
| 7284 | int header1 = 1; |
| 7285 | struct bgp *bgp; |
| 7286 | int header2 = 1; |
| 7287 | |
| 7288 | bgp = bgp_get_default (); |
| 7289 | |
| 7290 | if (! bgp) |
| 7291 | return; |
| 7292 | |
| 7293 | table = bgp->rib[afi][safi]; |
| 7294 | |
| 7295 | output_count = 0; |
| 7296 | |
| 7297 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 7298 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 7299 | { |
| 7300 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 7301 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 7302 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 7303 | |
| 7304 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 7305 | VTY_NEWLINE, VTY_NEWLINE); |
| 7306 | header1 = 0; |
| 7307 | } |
| 7308 | |
| 7309 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 7310 | if (in) |
| 7311 | { |
| 7312 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 7313 | if (ain->peer == peer) |
| 7314 | { |
| 7315 | if (header1) |
| 7316 | { |
| 7317 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 7318 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 7319 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 7320 | header1 = 0; |
| 7321 | } |
| 7322 | if (header2) |
| 7323 | { |
| 7324 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 7325 | header2 = 0; |
| 7326 | } |
| 7327 | if (ain->attr) |
| 7328 | { |
| 7329 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 7330 | output_count++; |
| 7331 | } |
| 7332 | } |
| 7333 | } |
| 7334 | else |
| 7335 | { |
| 7336 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 7337 | if (adj->peer == peer) |
| 7338 | { |
| 7339 | if (header1) |
| 7340 | { |
| 7341 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 7342 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 7343 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 7344 | header1 = 0; |
| 7345 | } |
| 7346 | if (header2) |
| 7347 | { |
| 7348 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 7349 | header2 = 0; |
| 7350 | } |
| 7351 | if (adj->attr) |
| 7352 | { |
| 7353 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 7354 | output_count++; |
| 7355 | } |
| 7356 | } |
| 7357 | } |
| 7358 | |
| 7359 | if (output_count != 0) |
| 7360 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 7361 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 7362 | } |
| 7363 | |
| 7364 | int |
| 7365 | peer_adj_routes (struct vty *vty, char *ip_str, afi_t afi, safi_t safi, int in) |
| 7366 | { |
| 7367 | int ret; |
| 7368 | struct peer *peer; |
| 7369 | union sockunion su; |
| 7370 | |
| 7371 | ret = str2sockunion (ip_str, &su); |
| 7372 | if (ret < 0) |
| 7373 | { |
| 7374 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 7375 | return CMD_WARNING; |
| 7376 | } |
| 7377 | peer = peer_lookup (NULL, &su); |
| 7378 | if (! peer || ! peer->afc[afi][safi]) |
| 7379 | { |
| 7380 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 7381 | return CMD_WARNING; |
| 7382 | } |
| 7383 | |
| 7384 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 7385 | { |
| 7386 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 7387 | VTY_NEWLINE); |
| 7388 | return CMD_WARNING; |
| 7389 | } |
| 7390 | |
| 7391 | show_adj_route (vty, peer, afi, safi, in); |
| 7392 | |
| 7393 | return CMD_SUCCESS; |
| 7394 | } |
| 7395 | |
| 7396 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 7397 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 7398 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7399 | SHOW_STR |
| 7400 | IP_STR |
| 7401 | BGP_STR |
| 7402 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7403 | "Neighbor to display information about\n" |
| 7404 | "Neighbor to display information about\n" |
| 7405 | "Display the routes advertised to a BGP neighbor\n") |
| 7406 | { |
| 7407 | return peer_adj_routes (vty, argv[0], AFI_IP, SAFI_UNICAST, 0); |
| 7408 | } |
| 7409 | |
| 7410 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 7411 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 7412 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7413 | SHOW_STR |
| 7414 | IP_STR |
| 7415 | BGP_STR |
| 7416 | "Address family\n" |
| 7417 | "Address Family modifier\n" |
| 7418 | "Address Family modifier\n" |
| 7419 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7420 | "Neighbor to display information about\n" |
| 7421 | "Neighbor to display information about\n" |
| 7422 | "Display the routes advertised to a BGP neighbor\n") |
| 7423 | { |
| 7424 | if (strncmp (argv[0], "m", 1) == 0) |
| 7425 | return peer_adj_routes (vty, argv[1], AFI_IP, SAFI_MULTICAST, 0); |
| 7426 | |
| 7427 | return peer_adj_routes (vty, argv[1], AFI_IP, SAFI_UNICAST, 0); |
| 7428 | } |
| 7429 | |
| 7430 | #ifdef HAVE_IPV6 |
| 7431 | DEFUN (show_bgp_neighbor_advertised_route, |
| 7432 | show_bgp_neighbor_advertised_route_cmd, |
| 7433 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7434 | SHOW_STR |
| 7435 | BGP_STR |
| 7436 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7437 | "Neighbor to display information about\n" |
| 7438 | "Neighbor to display information about\n" |
| 7439 | "Display the routes advertised to a BGP neighbor\n") |
| 7440 | { |
| 7441 | return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0); |
| 7442 | } |
| 7443 | |
| 7444 | ALIAS (show_bgp_neighbor_advertised_route, |
| 7445 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 7446 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7447 | SHOW_STR |
| 7448 | BGP_STR |
| 7449 | "Address family\n" |
| 7450 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7451 | "Neighbor to display information about\n" |
| 7452 | "Neighbor to display information about\n" |
| 7453 | "Display the routes advertised to a BGP neighbor\n") |
| 7454 | |
| 7455 | /* old command */ |
| 7456 | DEFUN (ipv6_bgp_neighbor_advertised_route, |
| 7457 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 7458 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7459 | SHOW_STR |
| 7460 | IPV6_STR |
| 7461 | BGP_STR |
| 7462 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7463 | "Neighbor to display information about\n" |
| 7464 | "Neighbor to display information about\n" |
| 7465 | "Display the routes advertised to a BGP neighbor\n") |
| 7466 | { |
| 7467 | return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0); |
| 7468 | } |
| 7469 | |
| 7470 | /* old command */ |
| 7471 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 7472 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 7473 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 7474 | SHOW_STR |
| 7475 | IPV6_STR |
| 7476 | MBGP_STR |
| 7477 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7478 | "Neighbor to display information about\n" |
| 7479 | "Neighbor to display information about\n" |
| 7480 | "Display the routes advertised to a BGP neighbor\n") |
| 7481 | { |
| 7482 | return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_MULTICAST, 0); |
| 7483 | } |
| 7484 | #endif /* HAVE_IPV6 */ |
| 7485 | |
| 7486 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 7487 | show_ip_bgp_neighbor_received_routes_cmd, |
| 7488 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7489 | SHOW_STR |
| 7490 | IP_STR |
| 7491 | BGP_STR |
| 7492 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7493 | "Neighbor to display information about\n" |
| 7494 | "Neighbor to display information about\n" |
| 7495 | "Display the received routes from neighbor\n") |
| 7496 | { |
| 7497 | return peer_adj_routes (vty, argv[0], AFI_IP, SAFI_UNICAST, 1); |
| 7498 | } |
| 7499 | |
| 7500 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 7501 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 7502 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7503 | SHOW_STR |
| 7504 | IP_STR |
| 7505 | BGP_STR |
| 7506 | "Address family\n" |
| 7507 | "Address Family modifier\n" |
| 7508 | "Address Family modifier\n" |
| 7509 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7510 | "Neighbor to display information about\n" |
| 7511 | "Neighbor to display information about\n" |
| 7512 | "Display the received routes from neighbor\n") |
| 7513 | { |
| 7514 | if (strncmp (argv[0], "m", 1) == 0) |
| 7515 | return peer_adj_routes (vty, argv[1], AFI_IP, SAFI_MULTICAST, 1); |
| 7516 | |
| 7517 | return peer_adj_routes (vty, argv[1], AFI_IP, SAFI_UNICAST, 1); |
| 7518 | } |
| 7519 | |
| 7520 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 7521 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 7522 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7523 | SHOW_STR |
| 7524 | IP_STR |
| 7525 | BGP_STR |
| 7526 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7527 | "Neighbor to display information about\n" |
| 7528 | "Neighbor to display information about\n" |
| 7529 | "Display information received from a BGP neighbor\n" |
| 7530 | "Display the prefixlist filter\n") |
| 7531 | { |
| 7532 | char name[BUFSIZ]; |
| 7533 | union sockunion *su; |
| 7534 | struct peer *peer; |
| 7535 | int count; |
| 7536 | |
| 7537 | su = sockunion_str2su (argv[0]); |
| 7538 | if (su == NULL) |
| 7539 | return CMD_WARNING; |
| 7540 | |
| 7541 | peer = peer_lookup (NULL, su); |
| 7542 | if (! peer) |
| 7543 | return CMD_WARNING; |
| 7544 | |
| 7545 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 7546 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 7547 | if (count) |
| 7548 | { |
| 7549 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 7550 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 7551 | } |
| 7552 | |
| 7553 | return CMD_SUCCESS; |
| 7554 | } |
| 7555 | |
| 7556 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 7557 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 7558 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7559 | SHOW_STR |
| 7560 | IP_STR |
| 7561 | BGP_STR |
| 7562 | "Address family\n" |
| 7563 | "Address Family modifier\n" |
| 7564 | "Address Family modifier\n" |
| 7565 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7566 | "Neighbor to display information about\n" |
| 7567 | "Neighbor to display information about\n" |
| 7568 | "Display information received from a BGP neighbor\n" |
| 7569 | "Display the prefixlist filter\n") |
| 7570 | { |
| 7571 | char name[BUFSIZ]; |
| 7572 | union sockunion *su; |
| 7573 | struct peer *peer; |
| 7574 | int count; |
| 7575 | |
| 7576 | su = sockunion_str2su (argv[1]); |
| 7577 | if (su == NULL) |
| 7578 | return CMD_WARNING; |
| 7579 | |
| 7580 | peer = peer_lookup (NULL, su); |
| 7581 | if (! peer) |
| 7582 | return CMD_WARNING; |
| 7583 | |
| 7584 | if (strncmp (argv[0], "m", 1) == 0) |
| 7585 | { |
| 7586 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 7587 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 7588 | if (count) |
| 7589 | { |
| 7590 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 7591 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 7592 | } |
| 7593 | } |
| 7594 | else |
| 7595 | { |
| 7596 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 7597 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 7598 | if (count) |
| 7599 | { |
| 7600 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 7601 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 7602 | } |
| 7603 | } |
| 7604 | |
| 7605 | return CMD_SUCCESS; |
| 7606 | } |
| 7607 | |
| 7608 | |
| 7609 | #ifdef HAVE_IPV6 |
| 7610 | DEFUN (show_bgp_neighbor_received_routes, |
| 7611 | show_bgp_neighbor_received_routes_cmd, |
| 7612 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7613 | SHOW_STR |
| 7614 | BGP_STR |
| 7615 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7616 | "Neighbor to display information about\n" |
| 7617 | "Neighbor to display information about\n" |
| 7618 | "Display the received routes from neighbor\n") |
| 7619 | { |
| 7620 | return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_UNICAST, 1); |
| 7621 | } |
| 7622 | |
| 7623 | ALIAS (show_bgp_neighbor_received_routes, |
| 7624 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 7625 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7626 | SHOW_STR |
| 7627 | BGP_STR |
| 7628 | "Address family\n" |
| 7629 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7630 | "Neighbor to display information about\n" |
| 7631 | "Neighbor to display information about\n" |
| 7632 | "Display the received routes from neighbor\n") |
| 7633 | |
| 7634 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 7635 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 7636 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7637 | SHOW_STR |
| 7638 | BGP_STR |
| 7639 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7640 | "Neighbor to display information about\n" |
| 7641 | "Neighbor to display information about\n" |
| 7642 | "Display information received from a BGP neighbor\n" |
| 7643 | "Display the prefixlist filter\n") |
| 7644 | { |
| 7645 | char name[BUFSIZ]; |
| 7646 | union sockunion *su; |
| 7647 | struct peer *peer; |
| 7648 | int count; |
| 7649 | |
| 7650 | su = sockunion_str2su (argv[0]); |
| 7651 | if (su == NULL) |
| 7652 | return CMD_WARNING; |
| 7653 | |
| 7654 | peer = peer_lookup (NULL, su); |
| 7655 | if (! peer) |
| 7656 | return CMD_WARNING; |
| 7657 | |
| 7658 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 7659 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 7660 | if (count) |
| 7661 | { |
| 7662 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 7663 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 7664 | } |
| 7665 | |
| 7666 | return CMD_SUCCESS; |
| 7667 | } |
| 7668 | |
| 7669 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 7670 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 7671 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 7672 | SHOW_STR |
| 7673 | BGP_STR |
| 7674 | "Address family\n" |
| 7675 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7676 | "Neighbor to display information about\n" |
| 7677 | "Neighbor to display information about\n" |
| 7678 | "Display information received from a BGP neighbor\n" |
| 7679 | "Display the prefixlist filter\n") |
| 7680 | |
| 7681 | /* old command */ |
| 7682 | DEFUN (ipv6_bgp_neighbor_received_routes, |
| 7683 | ipv6_bgp_neighbor_received_routes_cmd, |
| 7684 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7685 | SHOW_STR |
| 7686 | IPV6_STR |
| 7687 | BGP_STR |
| 7688 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7689 | "Neighbor to display information about\n" |
| 7690 | "Neighbor to display information about\n" |
| 7691 | "Display the received routes from neighbor\n") |
| 7692 | { |
| 7693 | return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_UNICAST, 1); |
| 7694 | } |
| 7695 | |
| 7696 | /* old command */ |
| 7697 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 7698 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 7699 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 7700 | SHOW_STR |
| 7701 | IPV6_STR |
| 7702 | MBGP_STR |
| 7703 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7704 | "Neighbor to display information about\n" |
| 7705 | "Neighbor to display information about\n" |
| 7706 | "Display the received routes from neighbor\n") |
| 7707 | { |
| 7708 | return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_MULTICAST, 1); |
| 7709 | } |
| 7710 | #endif /* HAVE_IPV6 */ |
| 7711 | |
| 7712 | void |
| 7713 | bgp_show_neighbor_route_clean (struct vty *vty) |
| 7714 | { |
| 7715 | union sockunion *su; |
| 7716 | |
| 7717 | su = vty->output_arg; |
| 7718 | XFREE (MTYPE_SOCKUNION, su); |
| 7719 | } |
| 7720 | |
| 7721 | int |
| 7722 | bgp_show_neighbor_route (struct vty *vty, char *ip_str, afi_t afi, |
| 7723 | safi_t safi, enum bgp_show_type type) |
| 7724 | { |
| 7725 | union sockunion *su; |
| 7726 | struct peer *peer; |
| 7727 | |
| 7728 | su = sockunion_str2su (ip_str); |
| 7729 | if (su == NULL) |
| 7730 | { |
| 7731 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 7732 | return CMD_WARNING; |
| 7733 | } |
| 7734 | |
| 7735 | peer = peer_lookup (NULL, su); |
| 7736 | if (! peer || ! peer->afc[afi][safi]) |
| 7737 | { |
| 7738 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 7739 | XFREE (MTYPE_SOCKUNION, su); |
| 7740 | return CMD_WARNING; |
| 7741 | } |
| 7742 | |
| 7743 | vty->output_arg = su; |
| 7744 | vty->output_clean = bgp_show_neighbor_route_clean; |
| 7745 | |
| 7746 | return bgp_show (vty, NULL, afi, safi, type); |
| 7747 | } |
| 7748 | |
| 7749 | DEFUN (show_ip_bgp_neighbor_routes, |
| 7750 | show_ip_bgp_neighbor_routes_cmd, |
| 7751 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 7752 | SHOW_STR |
| 7753 | IP_STR |
| 7754 | BGP_STR |
| 7755 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7756 | "Neighbor to display information about\n" |
| 7757 | "Neighbor to display information about\n" |
| 7758 | "Display routes learned from neighbor\n") |
| 7759 | { |
| 7760 | return bgp_show_neighbor_route (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7761 | bgp_show_type_neighbor); |
| 7762 | } |
| 7763 | |
| 7764 | DEFUN (show_ip_bgp_neighbor_flap, |
| 7765 | show_ip_bgp_neighbor_flap_cmd, |
| 7766 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 7767 | SHOW_STR |
| 7768 | IP_STR |
| 7769 | BGP_STR |
| 7770 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7771 | "Neighbor to display information about\n" |
| 7772 | "Neighbor to display information about\n" |
| 7773 | "Display flap statistics of the routes learned from neighbor\n") |
| 7774 | { |
| 7775 | return bgp_show_neighbor_route (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7776 | bgp_show_type_flap_neighbor); |
| 7777 | } |
| 7778 | |
| 7779 | DEFUN (show_ip_bgp_neighbor_damp, |
| 7780 | show_ip_bgp_neighbor_damp_cmd, |
| 7781 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 7782 | SHOW_STR |
| 7783 | IP_STR |
| 7784 | BGP_STR |
| 7785 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7786 | "Neighbor to display information about\n" |
| 7787 | "Neighbor to display information about\n" |
| 7788 | "Display the dampened routes received from neighbor\n") |
| 7789 | { |
| 7790 | return bgp_show_neighbor_route (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7791 | bgp_show_type_damp_neighbor); |
| 7792 | } |
| 7793 | |
| 7794 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 7795 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 7796 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 7797 | SHOW_STR |
| 7798 | IP_STR |
| 7799 | BGP_STR |
| 7800 | "Address family\n" |
| 7801 | "Address Family modifier\n" |
| 7802 | "Address Family modifier\n" |
| 7803 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7804 | "Neighbor to display information about\n" |
| 7805 | "Neighbor to display information about\n" |
| 7806 | "Display routes learned from neighbor\n") |
| 7807 | { |
| 7808 | if (strncmp (argv[0], "m", 1) == 0) |
| 7809 | return bgp_show_neighbor_route (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7810 | bgp_show_type_neighbor); |
| 7811 | |
| 7812 | return bgp_show_neighbor_route (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7813 | bgp_show_type_neighbor); |
| 7814 | } |
| 7815 | #ifdef HAVE_IPV6 |
| 7816 | DEFUN (show_bgp_neighbor_routes, |
| 7817 | show_bgp_neighbor_routes_cmd, |
| 7818 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 7819 | SHOW_STR |
| 7820 | BGP_STR |
| 7821 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7822 | "Neighbor to display information about\n" |
| 7823 | "Neighbor to display information about\n" |
| 7824 | "Display routes learned from neighbor\n") |
| 7825 | { |
| 7826 | return bgp_show_neighbor_route (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7827 | bgp_show_type_neighbor); |
| 7828 | } |
| 7829 | |
| 7830 | ALIAS (show_bgp_neighbor_routes, |
| 7831 | show_bgp_ipv6_neighbor_routes_cmd, |
| 7832 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 7833 | SHOW_STR |
| 7834 | BGP_STR |
| 7835 | "Address family\n" |
| 7836 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7837 | "Neighbor to display information about\n" |
| 7838 | "Neighbor to display information about\n" |
| 7839 | "Display routes learned from neighbor\n") |
| 7840 | |
| 7841 | /* old command */ |
| 7842 | DEFUN (ipv6_bgp_neighbor_routes, |
| 7843 | ipv6_bgp_neighbor_routes_cmd, |
| 7844 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 7845 | SHOW_STR |
| 7846 | IPV6_STR |
| 7847 | BGP_STR |
| 7848 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7849 | "Neighbor to display information about\n" |
| 7850 | "Neighbor to display information about\n" |
| 7851 | "Display routes learned from neighbor\n") |
| 7852 | { |
| 7853 | return bgp_show_neighbor_route (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7854 | bgp_show_type_neighbor); |
| 7855 | } |
| 7856 | |
| 7857 | /* old command */ |
| 7858 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 7859 | ipv6_mbgp_neighbor_routes_cmd, |
| 7860 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 7861 | SHOW_STR |
| 7862 | IPV6_STR |
| 7863 | MBGP_STR |
| 7864 | "Detailed information on TCP and BGP neighbor connections\n" |
| 7865 | "Neighbor to display information about\n" |
| 7866 | "Neighbor to display information about\n" |
| 7867 | "Display routes learned from neighbor\n") |
| 7868 | { |
| 7869 | return bgp_show_neighbor_route (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7870 | bgp_show_type_neighbor); |
| 7871 | } |
| 7872 | #endif /* HAVE_IPV6 */ |
| 7873 | |
| 7874 | struct bgp_table *bgp_distance_table; |
| 7875 | |
| 7876 | struct bgp_distance |
| 7877 | { |
| 7878 | /* Distance value for the IP source prefix. */ |
| 7879 | u_char distance; |
| 7880 | |
| 7881 | /* Name of the access-list to be matched. */ |
| 7882 | char *access_list; |
| 7883 | }; |
| 7884 | |
| 7885 | struct bgp_distance * |
| 7886 | bgp_distance_new () |
| 7887 | { |
| 7888 | struct bgp_distance *new; |
| 7889 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 7890 | memset (new, 0, sizeof (struct bgp_distance)); |
| 7891 | return new; |
| 7892 | } |
| 7893 | |
| 7894 | void |
| 7895 | bgp_distance_free (struct bgp_distance *bdistance) |
| 7896 | { |
| 7897 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 7898 | } |
| 7899 | |
| 7900 | int |
| 7901 | bgp_distance_set (struct vty *vty, char *distance_str, char *ip_str, |
| 7902 | char *access_list_str) |
| 7903 | { |
| 7904 | int ret; |
| 7905 | struct prefix_ipv4 p; |
| 7906 | u_char distance; |
| 7907 | struct bgp_node *rn; |
| 7908 | struct bgp_distance *bdistance; |
| 7909 | |
| 7910 | ret = str2prefix_ipv4 (ip_str, &p); |
| 7911 | if (ret == 0) |
| 7912 | { |
| 7913 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 7914 | return CMD_WARNING; |
| 7915 | } |
| 7916 | |
| 7917 | distance = atoi (distance_str); |
| 7918 | |
| 7919 | /* Get BGP distance node. */ |
| 7920 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 7921 | if (rn->info) |
| 7922 | { |
| 7923 | bdistance = rn->info; |
| 7924 | bgp_unlock_node (rn); |
| 7925 | } |
| 7926 | else |
| 7927 | { |
| 7928 | bdistance = bgp_distance_new (); |
| 7929 | rn->info = bdistance; |
| 7930 | } |
| 7931 | |
| 7932 | /* Set distance value. */ |
| 7933 | bdistance->distance = distance; |
| 7934 | |
| 7935 | /* Reset access-list configuration. */ |
| 7936 | if (bdistance->access_list) |
| 7937 | { |
| 7938 | free (bdistance->access_list); |
| 7939 | bdistance->access_list = NULL; |
| 7940 | } |
| 7941 | if (access_list_str) |
| 7942 | bdistance->access_list = strdup (access_list_str); |
| 7943 | |
| 7944 | return CMD_SUCCESS; |
| 7945 | } |
| 7946 | |
| 7947 | int |
| 7948 | bgp_distance_unset (struct vty *vty, char *distance_str, char *ip_str, |
| 7949 | char *access_list_str) |
| 7950 | { |
| 7951 | int ret; |
| 7952 | struct prefix_ipv4 p; |
| 7953 | u_char distance; |
| 7954 | struct bgp_node *rn; |
| 7955 | struct bgp_distance *bdistance; |
| 7956 | |
| 7957 | ret = str2prefix_ipv4 (ip_str, &p); |
| 7958 | if (ret == 0) |
| 7959 | { |
| 7960 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 7961 | return CMD_WARNING; |
| 7962 | } |
| 7963 | |
| 7964 | distance = atoi (distance_str); |
| 7965 | |
| 7966 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 7967 | if (! rn) |
| 7968 | { |
| 7969 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 7970 | return CMD_WARNING; |
| 7971 | } |
| 7972 | |
| 7973 | bdistance = rn->info; |
| 7974 | |
| 7975 | if (bdistance->access_list) |
| 7976 | free (bdistance->access_list); |
| 7977 | bgp_distance_free (bdistance); |
| 7978 | |
| 7979 | rn->info = NULL; |
| 7980 | bgp_unlock_node (rn); |
| 7981 | bgp_unlock_node (rn); |
| 7982 | |
| 7983 | return CMD_SUCCESS; |
| 7984 | } |
| 7985 | |
| 7986 | void |
| 7987 | bgp_distance_reset () |
| 7988 | { |
| 7989 | struct bgp_node *rn; |
| 7990 | struct bgp_distance *bdistance; |
| 7991 | |
| 7992 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 7993 | if ((bdistance = rn->info) != NULL) |
| 7994 | { |
| 7995 | if (bdistance->access_list) |
| 7996 | free (bdistance->access_list); |
| 7997 | bgp_distance_free (bdistance); |
| 7998 | rn->info = NULL; |
| 7999 | bgp_unlock_node (rn); |
| 8000 | } |
| 8001 | } |
| 8002 | |
| 8003 | /* Apply BGP information to distance method. */ |
| 8004 | u_char |
| 8005 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 8006 | { |
| 8007 | struct bgp_node *rn; |
| 8008 | struct prefix_ipv4 q; |
| 8009 | struct peer *peer; |
| 8010 | struct bgp_distance *bdistance; |
| 8011 | struct access_list *alist; |
| 8012 | struct bgp_static *bgp_static; |
| 8013 | |
| 8014 | if (! bgp) |
| 8015 | return 0; |
| 8016 | |
| 8017 | if (p->family != AF_INET) |
| 8018 | return 0; |
| 8019 | |
| 8020 | peer = rinfo->peer; |
| 8021 | |
| 8022 | if (peer->su.sa.sa_family != AF_INET) |
| 8023 | return 0; |
| 8024 | |
| 8025 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 8026 | q.family = AF_INET; |
| 8027 | q.prefix = peer->su.sin.sin_addr; |
| 8028 | q.prefixlen = IPV4_MAX_BITLEN; |
| 8029 | |
| 8030 | /* Check source address. */ |
| 8031 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 8032 | if (rn) |
| 8033 | { |
| 8034 | bdistance = rn->info; |
| 8035 | bgp_unlock_node (rn); |
| 8036 | |
| 8037 | if (bdistance->access_list) |
| 8038 | { |
| 8039 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 8040 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 8041 | return bdistance->distance; |
| 8042 | } |
| 8043 | else |
| 8044 | return bdistance->distance; |
| 8045 | } |
| 8046 | |
| 8047 | /* Backdoor check. */ |
| 8048 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 8049 | if (rn) |
| 8050 | { |
| 8051 | bgp_static = rn->info; |
| 8052 | bgp_unlock_node (rn); |
| 8053 | |
| 8054 | if (bgp_static->backdoor) |
| 8055 | { |
| 8056 | if (bgp->distance_local) |
| 8057 | return bgp->distance_local; |
| 8058 | else |
| 8059 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 8060 | } |
| 8061 | } |
| 8062 | |
| 8063 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 8064 | { |
| 8065 | if (bgp->distance_ebgp) |
| 8066 | return bgp->distance_ebgp; |
| 8067 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 8068 | } |
| 8069 | else |
| 8070 | { |
| 8071 | if (bgp->distance_ibgp) |
| 8072 | return bgp->distance_ibgp; |
| 8073 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 8074 | } |
| 8075 | } |
| 8076 | |
| 8077 | DEFUN (bgp_distance, |
| 8078 | bgp_distance_cmd, |
| 8079 | "distance bgp <1-255> <1-255> <1-255>", |
| 8080 | "Define an administrative distance\n" |
| 8081 | "BGP distance\n" |
| 8082 | "Distance for routes external to the AS\n" |
| 8083 | "Distance for routes internal to the AS\n" |
| 8084 | "Distance for local routes\n") |
| 8085 | { |
| 8086 | struct bgp *bgp; |
| 8087 | |
| 8088 | bgp = vty->index; |
| 8089 | |
| 8090 | bgp->distance_ebgp = atoi (argv[0]); |
| 8091 | bgp->distance_ibgp = atoi (argv[1]); |
| 8092 | bgp->distance_local = atoi (argv[2]); |
| 8093 | return CMD_SUCCESS; |
| 8094 | } |
| 8095 | |
| 8096 | DEFUN (no_bgp_distance, |
| 8097 | no_bgp_distance_cmd, |
| 8098 | "no distance bgp <1-255> <1-255> <1-255>", |
| 8099 | NO_STR |
| 8100 | "Define an administrative distance\n" |
| 8101 | "BGP distance\n" |
| 8102 | "Distance for routes external to the AS\n" |
| 8103 | "Distance for routes internal to the AS\n" |
| 8104 | "Distance for local routes\n") |
| 8105 | { |
| 8106 | struct bgp *bgp; |
| 8107 | |
| 8108 | bgp = vty->index; |
| 8109 | |
| 8110 | bgp->distance_ebgp= 0; |
| 8111 | bgp->distance_ibgp = 0; |
| 8112 | bgp->distance_local = 0; |
| 8113 | return CMD_SUCCESS; |
| 8114 | } |
| 8115 | |
| 8116 | ALIAS (no_bgp_distance, |
| 8117 | no_bgp_distance2_cmd, |
| 8118 | "no distance bgp", |
| 8119 | NO_STR |
| 8120 | "Define an administrative distance\n" |
| 8121 | "BGP distance\n") |
| 8122 | |
| 8123 | DEFUN (bgp_distance_source, |
| 8124 | bgp_distance_source_cmd, |
| 8125 | "distance <1-255> A.B.C.D/M", |
| 8126 | "Define an administrative distance\n" |
| 8127 | "Administrative distance\n" |
| 8128 | "IP source prefix\n") |
| 8129 | { |
| 8130 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 8131 | return CMD_SUCCESS; |
| 8132 | } |
| 8133 | |
| 8134 | DEFUN (no_bgp_distance_source, |
| 8135 | no_bgp_distance_source_cmd, |
| 8136 | "no distance <1-255> A.B.C.D/M", |
| 8137 | NO_STR |
| 8138 | "Define an administrative distance\n" |
| 8139 | "Administrative distance\n" |
| 8140 | "IP source prefix\n") |
| 8141 | { |
| 8142 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 8143 | return CMD_SUCCESS; |
| 8144 | } |
| 8145 | |
| 8146 | DEFUN (bgp_distance_source_access_list, |
| 8147 | bgp_distance_source_access_list_cmd, |
| 8148 | "distance <1-255> A.B.C.D/M WORD", |
| 8149 | "Define an administrative distance\n" |
| 8150 | "Administrative distance\n" |
| 8151 | "IP source prefix\n" |
| 8152 | "Access list name\n") |
| 8153 | { |
| 8154 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 8155 | return CMD_SUCCESS; |
| 8156 | } |
| 8157 | |
| 8158 | DEFUN (no_bgp_distance_source_access_list, |
| 8159 | no_bgp_distance_source_access_list_cmd, |
| 8160 | "no distance <1-255> A.B.C.D/M WORD", |
| 8161 | NO_STR |
| 8162 | "Define an administrative distance\n" |
| 8163 | "Administrative distance\n" |
| 8164 | "IP source prefix\n" |
| 8165 | "Access list name\n") |
| 8166 | { |
| 8167 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 8168 | return CMD_SUCCESS; |
| 8169 | } |
| 8170 | |
| 8171 | DEFUN (bgp_damp_set, |
| 8172 | bgp_damp_set_cmd, |
| 8173 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 8174 | "BGP Specific commands\n" |
| 8175 | "Enable route-flap dampening\n" |
| 8176 | "Half-life time for the penalty\n" |
| 8177 | "Value to start reusing a route\n" |
| 8178 | "Value to start suppressing a route\n" |
| 8179 | "Maximum duration to suppress a stable route\n") |
| 8180 | { |
| 8181 | struct bgp *bgp; |
| 8182 | int half = DEFAULT_HALF_LIFE * 60; |
| 8183 | int reuse = DEFAULT_REUSE; |
| 8184 | int suppress = DEFAULT_SUPPRESS; |
| 8185 | int max = 4 * half; |
| 8186 | |
| 8187 | if (argc == 4) |
| 8188 | { |
| 8189 | half = atoi (argv[0]) * 60; |
| 8190 | reuse = atoi (argv[1]); |
| 8191 | suppress = atoi (argv[2]); |
| 8192 | max = atoi (argv[3]) * 60; |
| 8193 | } |
| 8194 | else if (argc == 1) |
| 8195 | { |
| 8196 | half = atoi (argv[0]) * 60; |
| 8197 | max = 4 * half; |
| 8198 | } |
| 8199 | |
| 8200 | bgp = vty->index; |
| 8201 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 8202 | half, reuse, suppress, max); |
| 8203 | } |
| 8204 | |
| 8205 | ALIAS (bgp_damp_set, |
| 8206 | bgp_damp_set2_cmd, |
| 8207 | "bgp dampening <1-45>", |
| 8208 | "BGP Specific commands\n" |
| 8209 | "Enable route-flap dampening\n" |
| 8210 | "Half-life time for the penalty\n") |
| 8211 | |
| 8212 | ALIAS (bgp_damp_set, |
| 8213 | bgp_damp_set3_cmd, |
| 8214 | "bgp dampening", |
| 8215 | "BGP Specific commands\n" |
| 8216 | "Enable route-flap dampening\n") |
| 8217 | |
| 8218 | DEFUN (bgp_damp_unset, |
| 8219 | bgp_damp_unset_cmd, |
| 8220 | "no bgp dampening", |
| 8221 | NO_STR |
| 8222 | "BGP Specific commands\n" |
| 8223 | "Enable route-flap dampening\n") |
| 8224 | { |
| 8225 | struct bgp *bgp; |
| 8226 | |
| 8227 | bgp = vty->index; |
| 8228 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 8229 | } |
| 8230 | |
| 8231 | ALIAS (bgp_damp_unset, |
| 8232 | bgp_damp_unset2_cmd, |
| 8233 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 8234 | NO_STR |
| 8235 | "BGP Specific commands\n" |
| 8236 | "Enable route-flap dampening\n" |
| 8237 | "Half-life time for the penalty\n" |
| 8238 | "Value to start reusing a route\n" |
| 8239 | "Value to start suppressing a route\n" |
| 8240 | "Maximum duration to suppress a stable route\n") |
| 8241 | |
| 8242 | DEFUN (show_ip_bgp_dampened_paths, |
| 8243 | show_ip_bgp_dampened_paths_cmd, |
| 8244 | "show ip bgp dampened-paths", |
| 8245 | SHOW_STR |
| 8246 | IP_STR |
| 8247 | BGP_STR |
| 8248 | "Display paths suppressed due to dampening\n") |
| 8249 | { |
| 8250 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths); |
| 8251 | } |
| 8252 | |
| 8253 | DEFUN (show_ip_bgp_flap_statistics, |
| 8254 | show_ip_bgp_flap_statistics_cmd, |
| 8255 | "show ip bgp flap-statistics", |
| 8256 | SHOW_STR |
| 8257 | IP_STR |
| 8258 | BGP_STR |
| 8259 | "Display flap statistics of routes\n") |
| 8260 | { |
| 8261 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_statistics); |
| 8262 | } |
| 8263 | |
| 8264 | /* Display specified route of BGP table. */ |
| 8265 | int |
| 8266 | bgp_clear_damp_route (struct vty *vty, char *view_name, char *ip_str, |
| 8267 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 8268 | int prefix_check) |
| 8269 | { |
| 8270 | int ret; |
| 8271 | struct prefix match; |
| 8272 | struct bgp_node *rn; |
| 8273 | struct bgp_node *rm; |
| 8274 | struct bgp_info *ri; |
| 8275 | struct bgp_info *ri_temp; |
| 8276 | struct bgp *bgp; |
| 8277 | struct bgp_table *table; |
| 8278 | |
| 8279 | /* BGP structure lookup. */ |
| 8280 | if (view_name) |
| 8281 | { |
| 8282 | bgp = bgp_lookup_by_name (view_name); |
| 8283 | if (bgp == NULL) |
| 8284 | { |
| 8285 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8286 | return CMD_WARNING; |
| 8287 | } |
| 8288 | } |
| 8289 | else |
| 8290 | { |
| 8291 | bgp = bgp_get_default (); |
| 8292 | if (bgp == NULL) |
| 8293 | { |
| 8294 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 8295 | return CMD_WARNING; |
| 8296 | } |
| 8297 | } |
| 8298 | |
| 8299 | /* Check IP address argument. */ |
| 8300 | ret = str2prefix (ip_str, &match); |
| 8301 | if (! ret) |
| 8302 | { |
| 8303 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 8304 | return CMD_WARNING; |
| 8305 | } |
| 8306 | |
| 8307 | match.family = afi2family (afi); |
| 8308 | |
| 8309 | if (safi == SAFI_MPLS_VPN) |
| 8310 | { |
| 8311 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 8312 | { |
| 8313 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 8314 | continue; |
| 8315 | |
| 8316 | if ((table = rn->info) != NULL) |
| 8317 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 8318 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 8319 | { |
| 8320 | ri = rm->info; |
| 8321 | while (ri) |
| 8322 | { |
| 8323 | if (ri->damp_info) |
| 8324 | { |
| 8325 | ri_temp = ri->next; |
| 8326 | bgp_damp_info_free (ri->damp_info, 1); |
| 8327 | ri = ri_temp; |
| 8328 | } |
| 8329 | else |
| 8330 | ri = ri->next; |
| 8331 | } |
| 8332 | } |
| 8333 | } |
| 8334 | } |
| 8335 | else |
| 8336 | { |
| 8337 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 8338 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 8339 | { |
| 8340 | ri = rn->info; |
| 8341 | while (ri) |
| 8342 | { |
| 8343 | if (ri->damp_info) |
| 8344 | { |
| 8345 | ri_temp = ri->next; |
| 8346 | bgp_damp_info_free (ri->damp_info, 1); |
| 8347 | ri = ri_temp; |
| 8348 | } |
| 8349 | else |
| 8350 | ri = ri->next; |
| 8351 | } |
| 8352 | } |
| 8353 | } |
| 8354 | |
| 8355 | return CMD_SUCCESS; |
| 8356 | } |
| 8357 | |
| 8358 | DEFUN (clear_ip_bgp_dampening, |
| 8359 | clear_ip_bgp_dampening_cmd, |
| 8360 | "clear ip bgp dampening", |
| 8361 | CLEAR_STR |
| 8362 | IP_STR |
| 8363 | BGP_STR |
| 8364 | "Clear route flap dampening information\n") |
| 8365 | { |
| 8366 | bgp_damp_info_clean (); |
| 8367 | return CMD_SUCCESS; |
| 8368 | } |
| 8369 | |
| 8370 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 8371 | clear_ip_bgp_dampening_prefix_cmd, |
| 8372 | "clear ip bgp dampening A.B.C.D/M", |
| 8373 | CLEAR_STR |
| 8374 | IP_STR |
| 8375 | BGP_STR |
| 8376 | "Clear route flap dampening information\n" |
| 8377 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8378 | { |
| 8379 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 8380 | SAFI_UNICAST, NULL, 1); |
| 8381 | } |
| 8382 | |
| 8383 | DEFUN (clear_ip_bgp_dampening_address, |
| 8384 | clear_ip_bgp_dampening_address_cmd, |
| 8385 | "clear ip bgp dampening A.B.C.D", |
| 8386 | CLEAR_STR |
| 8387 | IP_STR |
| 8388 | BGP_STR |
| 8389 | "Clear route flap dampening information\n" |
| 8390 | "Network to clear damping information\n") |
| 8391 | { |
| 8392 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 8393 | SAFI_UNICAST, NULL, 0); |
| 8394 | } |
| 8395 | |
| 8396 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 8397 | clear_ip_bgp_dampening_address_mask_cmd, |
| 8398 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 8399 | CLEAR_STR |
| 8400 | IP_STR |
| 8401 | BGP_STR |
| 8402 | "Clear route flap dampening information\n" |
| 8403 | "Network to clear damping information\n" |
| 8404 | "Network mask\n") |
| 8405 | { |
| 8406 | int ret; |
| 8407 | char prefix_str[BUFSIZ]; |
| 8408 | |
| 8409 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 8410 | if (! ret) |
| 8411 | { |
| 8412 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 8413 | return CMD_WARNING; |
| 8414 | } |
| 8415 | |
| 8416 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 8417 | SAFI_UNICAST, NULL, 0); |
| 8418 | } |
| 8419 | |
| 8420 | int |
| 8421 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 8422 | afi_t afi, safi_t safi, int *write) |
| 8423 | { |
| 8424 | struct bgp_node *prn; |
| 8425 | struct bgp_node *rn; |
| 8426 | struct bgp_table *table; |
| 8427 | struct prefix *p; |
| 8428 | struct prefix_rd *prd; |
| 8429 | struct bgp_static *bgp_static; |
| 8430 | u_int32_t label; |
| 8431 | char buf[SU_ADDRSTRLEN]; |
| 8432 | char rdbuf[RD_ADDRSTRLEN]; |
| 8433 | |
| 8434 | /* Network configuration. */ |
| 8435 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 8436 | if ((table = prn->info) != NULL) |
| 8437 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 8438 | if ((bgp_static = rn->info) != NULL) |
| 8439 | { |
| 8440 | p = &rn->p; |
| 8441 | prd = (struct prefix_rd *) &prn->p; |
| 8442 | |
| 8443 | /* "address-family" display. */ |
| 8444 | bgp_config_write_family_header (vty, afi, safi, write); |
| 8445 | |
| 8446 | /* "network" configuration display. */ |
| 8447 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 8448 | label = decode_label (bgp_static->tag); |
| 8449 | |
| 8450 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 8451 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 8452 | p->prefixlen, |
| 8453 | rdbuf, label); |
| 8454 | vty_out (vty, "%s", VTY_NEWLINE); |
| 8455 | } |
| 8456 | return 0; |
| 8457 | } |
| 8458 | |
| 8459 | /* Configuration of static route announcement and aggregate |
| 8460 | information. */ |
| 8461 | int |
| 8462 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 8463 | afi_t afi, safi_t safi, int *write) |
| 8464 | { |
| 8465 | struct bgp_node *rn; |
| 8466 | struct prefix *p; |
| 8467 | struct bgp_static *bgp_static; |
| 8468 | struct bgp_aggregate *bgp_aggregate; |
| 8469 | char buf[SU_ADDRSTRLEN]; |
| 8470 | |
| 8471 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 8472 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 8473 | |
| 8474 | /* Network configuration. */ |
| 8475 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 8476 | if ((bgp_static = rn->info) != NULL) |
| 8477 | { |
| 8478 | p = &rn->p; |
| 8479 | |
| 8480 | /* "address-family" display. */ |
| 8481 | bgp_config_write_family_header (vty, afi, safi, write); |
| 8482 | |
| 8483 | /* "network" configuration display. */ |
| 8484 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 8485 | { |
| 8486 | u_int32_t destination; |
| 8487 | struct in_addr netmask; |
| 8488 | |
| 8489 | destination = ntohl (p->u.prefix4.s_addr); |
| 8490 | masklen2ip (p->prefixlen, &netmask); |
| 8491 | vty_out (vty, " network %s", |
| 8492 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 8493 | |
| 8494 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 8495 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 8496 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 8497 | || p->u.prefix4.s_addr == 0) |
| 8498 | { |
| 8499 | /* Natural mask is not display. */ |
| 8500 | } |
| 8501 | else |
| 8502 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 8503 | } |
| 8504 | else |
| 8505 | { |
| 8506 | vty_out (vty, " network %s/%d", |
| 8507 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 8508 | p->prefixlen); |
| 8509 | } |
| 8510 | |
| 8511 | if (bgp_static->rmap.name) |
| 8512 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 8513 | else if (bgp_static->backdoor) |
| 8514 | vty_out (vty, " backdoor"); |
| 8515 | |
| 8516 | vty_out (vty, "%s", VTY_NEWLINE); |
| 8517 | } |
| 8518 | |
| 8519 | /* Aggregate-address configuration. */ |
| 8520 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 8521 | if ((bgp_aggregate = rn->info) != NULL) |
| 8522 | { |
| 8523 | p = &rn->p; |
| 8524 | |
| 8525 | /* "address-family" display. */ |
| 8526 | bgp_config_write_family_header (vty, afi, safi, write); |
| 8527 | |
| 8528 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 8529 | { |
| 8530 | struct in_addr netmask; |
| 8531 | |
| 8532 | masklen2ip (p->prefixlen, &netmask); |
| 8533 | vty_out (vty, " aggregate-address %s %s", |
| 8534 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 8535 | inet_ntoa (netmask)); |
| 8536 | } |
| 8537 | else |
| 8538 | { |
| 8539 | vty_out (vty, " aggregate-address %s/%d", |
| 8540 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 8541 | p->prefixlen); |
| 8542 | } |
| 8543 | |
| 8544 | if (bgp_aggregate->as_set) |
| 8545 | vty_out (vty, " as-set"); |
| 8546 | |
| 8547 | if (bgp_aggregate->summary_only) |
| 8548 | vty_out (vty, " summary-only"); |
| 8549 | |
| 8550 | vty_out (vty, "%s", VTY_NEWLINE); |
| 8551 | } |
| 8552 | |
| 8553 | return 0; |
| 8554 | } |
| 8555 | |
| 8556 | int |
| 8557 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 8558 | { |
| 8559 | struct bgp_node *rn; |
| 8560 | struct bgp_distance *bdistance; |
| 8561 | |
| 8562 | /* Distance configuration. */ |
| 8563 | if (bgp->distance_ebgp |
| 8564 | && bgp->distance_ibgp |
| 8565 | && bgp->distance_local |
| 8566 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 8567 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 8568 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 8569 | vty_out (vty, " distance bgp %d %d %d%s", |
| 8570 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 8571 | VTY_NEWLINE); |
| 8572 | |
| 8573 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 8574 | if ((bdistance = rn->info) != NULL) |
| 8575 | { |
| 8576 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 8577 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 8578 | bdistance->access_list ? bdistance->access_list : "", |
| 8579 | VTY_NEWLINE); |
| 8580 | } |
| 8581 | |
| 8582 | return 0; |
| 8583 | } |
| 8584 | |
| 8585 | /* Allocate routing table structure and install commands. */ |
| 8586 | void |
| 8587 | bgp_route_init () |
| 8588 | { |
| 8589 | /* Init BGP distance table. */ |
| 8590 | bgp_distance_table = bgp_table_init (); |
| 8591 | |
| 8592 | /* IPv4 BGP commands. */ |
| 8593 | install_element (BGP_NODE, &bgp_network_cmd); |
| 8594 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 8595 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 8596 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 8597 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 8598 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 8599 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 8600 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 8601 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 8602 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 8603 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 8604 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 8605 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 8606 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 8607 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 8608 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 8609 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 8610 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 8611 | |
| 8612 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 8613 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 8614 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 8615 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 8616 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 8617 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 8618 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 8619 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 8620 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 8621 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 8622 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 8623 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 8624 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 8625 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 8626 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 8627 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 8628 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 8629 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 8630 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 8631 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 8632 | |
| 8633 | /* IPv4 unicast configuration. */ |
| 8634 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 8635 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 8636 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 8637 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 8638 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 8639 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 8640 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 8641 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 8642 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 8643 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 8644 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 8645 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 8646 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 8647 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 8648 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 8649 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 8650 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 8651 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 8652 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 8653 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 8654 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 8655 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 8656 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 8657 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 8658 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 8659 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 8660 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 8661 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 8662 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 8663 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 8664 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 8665 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 8666 | |
| 8667 | /* IPv4 multicast configuration. */ |
| 8668 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 8669 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 8670 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 8671 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 8672 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 8673 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 8674 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 8675 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 8676 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 8677 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 8678 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 8679 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 8680 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 8681 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 8682 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 8683 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 8684 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 8685 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 8686 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 8687 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 8688 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 8689 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 8690 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 8691 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 8692 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 8693 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 8694 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 8695 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 8696 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 8697 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 8698 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 8699 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 8700 | |
| 8701 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 8702 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 8703 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 8704 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 8705 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 8706 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 8707 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 8708 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 8709 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 8710 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 8711 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 8712 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 8713 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 8714 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 8715 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 8716 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 8717 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 8718 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 8719 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 8720 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 8721 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 8722 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 8723 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 8724 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 8725 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 8726 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 8727 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 8728 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 8729 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 8730 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 8731 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 8732 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 8733 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 8734 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 8735 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 8736 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 8737 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 8738 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 8739 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 8740 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 8741 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 8742 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 8743 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 8744 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 8745 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 8746 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 8747 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 8748 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 8749 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 8750 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 8751 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 8752 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 8753 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 8754 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 8755 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 8756 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 8757 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 8758 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 8759 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 8760 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 8761 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 8762 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 8763 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 8764 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 8765 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 8766 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 8767 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 8768 | |
| 8769 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 8770 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 8771 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 8772 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 8773 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 8774 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 8775 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 8776 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 8777 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 8778 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 8779 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 8780 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 8781 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 8782 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 8783 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 8784 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 8785 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 8786 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 8787 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 8788 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 8789 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 8790 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 8791 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 8792 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 8793 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 8794 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 8795 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 8796 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 8797 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 8798 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 8799 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 8800 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 8801 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 8802 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 8803 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 8804 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 8805 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 8806 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 8807 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 8808 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 8809 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 8810 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 8811 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 8812 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 8813 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 8814 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 8815 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 8816 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 8817 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 8818 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 8819 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 8820 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 8821 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 8822 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 8823 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 8824 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 8825 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 8826 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 8827 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 8828 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 8829 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 8830 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 8831 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 8832 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 8833 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 8834 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 8835 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 8836 | |
| 8837 | /* BGP dampening clear commands */ |
| 8838 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 8839 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 8840 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 8841 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 8842 | |
| 8843 | #ifdef HAVE_IPV6 |
| 8844 | /* New config IPv6 BGP commands. */ |
| 8845 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 8846 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 8847 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 8848 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 8849 | |
| 8850 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 8851 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 8852 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 8853 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 8854 | |
| 8855 | /* Old config IPv6 BGP commands. */ |
| 8856 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 8857 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 8858 | |
| 8859 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 8860 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 8861 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 8862 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 8863 | |
| 8864 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 8865 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 8866 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 8867 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 8868 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 8869 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 8870 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 8871 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 8872 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 8873 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 8874 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 8875 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 8876 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 8877 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 8878 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 8879 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 8880 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 8881 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 8882 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 8883 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 8884 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 8885 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 8886 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 8887 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 8888 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 8889 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 8890 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 8891 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 8892 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 8893 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 8894 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 8895 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 8896 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 8897 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 8898 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 8899 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 8900 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 8901 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 8902 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 8903 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 8904 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 8905 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 8906 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 8907 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 8908 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 8909 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
| 8910 | |
| 8911 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 8912 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 8913 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 8914 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 8915 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 8916 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 8917 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 8918 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 8919 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 8920 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 8921 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 8922 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 8923 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 8924 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 8925 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 8926 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 8927 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 8928 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 8929 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 8930 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 8931 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 8932 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 8933 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 8934 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 8935 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 8936 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 8937 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 8938 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 8939 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 8940 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 8941 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 8942 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 8943 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 8944 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 8945 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 8946 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 8947 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 8948 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 8949 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 8950 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 8951 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 8952 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 8953 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 8954 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 8955 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 8956 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
| 8957 | |
| 8958 | /* old command */ |
| 8959 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 8960 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 8961 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 8962 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 8963 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 8964 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 8965 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 8966 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 8967 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 8968 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 8969 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 8970 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 8971 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 8972 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 8973 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 8974 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 8975 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 8976 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 8977 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 8978 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 8979 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 8980 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 8981 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 8982 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 8983 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 8984 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 8985 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 8986 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 8987 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 8988 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 8989 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 8990 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 8991 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 8992 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 8993 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 8994 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 8995 | |
| 8996 | /* old command */ |
| 8997 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 8998 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 8999 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 9000 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 9001 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 9002 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 9003 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 9004 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 9005 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 9006 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 9007 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 9008 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 9009 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 9010 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 9011 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 9012 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 9013 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 9014 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 9015 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 9016 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 9017 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 9018 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 9019 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 9020 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 9021 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 9022 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 9023 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 9024 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 9025 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 9026 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 9027 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 9028 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 9029 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 9030 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 9031 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 9032 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 9033 | |
| 9034 | /* old command */ |
| 9035 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 9036 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 9037 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 9038 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 9039 | |
| 9040 | /* old command */ |
| 9041 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 9042 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 9043 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 9044 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 9045 | |
| 9046 | /* old command */ |
| 9047 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 9048 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 9049 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 9050 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 9051 | #endif /* HAVE_IPV6 */ |
| 9052 | |
| 9053 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 9054 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 9055 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 9056 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 9057 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 9058 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 9059 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 9060 | |
| 9061 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 9062 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 9063 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 9064 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 9065 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 9066 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 9067 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 9068 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 9069 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 9070 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 9071 | } |