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 * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 61 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 62 | struct prefix_rd *prd) |
| 63 | { |
| 64 | struct bgp_node *rn; |
| 65 | struct bgp_node *prn = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 66 | |
| 67 | if (safi == SAFI_MPLS_VPN) |
| 68 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 69 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 70 | |
| 71 | if (prn->info == NULL) |
| 72 | prn->info = bgp_table_init (); |
| 73 | else |
| 74 | bgp_unlock_node (prn); |
| 75 | table = prn->info; |
| 76 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 77 | |
| 78 | rn = bgp_node_get (table, p); |
| 79 | |
| 80 | if (safi == SAFI_MPLS_VPN) |
| 81 | rn->prn = prn; |
| 82 | |
| 83 | return rn; |
| 84 | } |
| 85 | |
| 86 | /* Allocate new bgp info structure. */ |
| 87 | struct bgp_info * |
| 88 | bgp_info_new () |
| 89 | { |
| 90 | struct bgp_info *new; |
| 91 | |
| 92 | new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 93 | memset (new, 0, sizeof (struct bgp_info)); |
| 94 | |
| 95 | return new; |
| 96 | } |
| 97 | |
| 98 | /* Free bgp route information. */ |
| 99 | void |
| 100 | bgp_info_free (struct bgp_info *binfo) |
| 101 | { |
| 102 | if (binfo->attr) |
| 103 | bgp_attr_unintern (binfo->attr); |
| 104 | |
| 105 | if (binfo->damp_info) |
| 106 | bgp_damp_info_free (binfo->damp_info, 0); |
| 107 | |
| 108 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 109 | } |
| 110 | |
| 111 | void |
| 112 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 113 | { |
| 114 | struct bgp_info *top; |
| 115 | |
| 116 | top = rn->info; |
| 117 | |
| 118 | ri->next = rn->info; |
| 119 | ri->prev = NULL; |
| 120 | if (top) |
| 121 | top->prev = ri; |
| 122 | rn->info = ri; |
| 123 | } |
| 124 | |
| 125 | void |
| 126 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 127 | { |
| 128 | if (ri->next) |
| 129 | ri->next->prev = ri->prev; |
| 130 | if (ri->prev) |
| 131 | ri->prev->next = ri->next; |
| 132 | else |
| 133 | rn->info = ri->next; |
| 134 | } |
| 135 | |
| 136 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 137 | missing-as-worst" is specified, treat it as the worst value. */ |
| 138 | u_int32_t |
| 139 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 140 | { |
| 141 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 142 | return attr->med; |
| 143 | else |
| 144 | { |
| 145 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 146 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 147 | else |
| 148 | return 0; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /* Compare two bgp route entity. br is preferable then return 1. */ |
| 153 | int |
| 154 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) |
| 155 | { |
| 156 | u_int32_t new_pref; |
| 157 | u_int32_t exist_pref; |
| 158 | u_int32_t new_med; |
| 159 | u_int32_t exist_med; |
| 160 | struct in_addr new_id; |
| 161 | struct in_addr exist_id; |
| 162 | int new_cluster; |
| 163 | int exist_cluster; |
| 164 | int internal_as_route = 0; |
| 165 | int confed_as_route = 0; |
| 166 | int ret; |
| 167 | |
| 168 | /* 0. Null check. */ |
| 169 | if (new == NULL) |
| 170 | return 0; |
| 171 | if (exist == NULL) |
| 172 | return 1; |
| 173 | |
| 174 | /* 1. Weight check. */ |
| 175 | if (new->attr->weight > exist->attr->weight) |
| 176 | return 1; |
| 177 | if (new->attr->weight < exist->attr->weight) |
| 178 | return 0; |
| 179 | |
| 180 | /* 2. Local preference check. */ |
| 181 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 182 | new_pref = new->attr->local_pref; |
| 183 | else |
| 184 | new_pref = bgp->default_local_pref; |
| 185 | |
| 186 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 187 | exist_pref = exist->attr->local_pref; |
| 188 | else |
| 189 | exist_pref = bgp->default_local_pref; |
| 190 | |
| 191 | if (new_pref > exist_pref) |
| 192 | return 1; |
| 193 | if (new_pref < exist_pref) |
| 194 | return 0; |
| 195 | |
| 196 | /* 3. Local route check. */ |
| 197 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 198 | return 1; |
| 199 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 200 | return 0; |
| 201 | |
| 202 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 203 | return 1; |
| 204 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 205 | return 0; |
| 206 | |
| 207 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 208 | return 1; |
| 209 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 210 | return 0; |
| 211 | |
| 212 | /* 4. AS path length check. */ |
| 213 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 214 | { |
| 215 | if (new->attr->aspath->count < exist->attr->aspath->count) |
| 216 | return 1; |
| 217 | if (new->attr->aspath->count > exist->attr->aspath->count) |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | /* 5. Origin check. */ |
| 222 | if (new->attr->origin < exist->attr->origin) |
| 223 | return 1; |
| 224 | if (new->attr->origin > exist->attr->origin) |
| 225 | return 0; |
| 226 | |
| 227 | /* 6. MED check. */ |
| 228 | internal_as_route = (new->attr->aspath->length == 0 |
| 229 | && exist->attr->aspath->length == 0); |
| 230 | confed_as_route = (new->attr->aspath->length > 0 |
| 231 | && exist->attr->aspath->length > 0 |
| 232 | && new->attr->aspath->count == 0 |
| 233 | && exist->attr->aspath->count == 0); |
| 234 | |
| 235 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 236 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 237 | && confed_as_route) |
| 238 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 239 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 240 | || internal_as_route) |
| 241 | { |
| 242 | new_med = bgp_med_value (new->attr, bgp); |
| 243 | exist_med = bgp_med_value (exist->attr, bgp); |
| 244 | |
| 245 | if (new_med < exist_med) |
| 246 | return 1; |
| 247 | if (new_med > exist_med) |
| 248 | return 0; |
| 249 | } |
| 250 | |
| 251 | /* 7. Peer type check. */ |
| 252 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 253 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 254 | return 1; |
| 255 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 256 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 257 | return 1; |
| 258 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 259 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 260 | return 0; |
| 261 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 262 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 263 | return 0; |
| 264 | |
| 265 | /* 8. IGP metric check. */ |
| 266 | if (new->igpmetric < exist->igpmetric) |
| 267 | return 1; |
| 268 | if (new->igpmetric > exist->igpmetric) |
| 269 | return 0; |
| 270 | |
| 271 | /* 9. Maximum path check. */ |
| 272 | |
| 273 | /* 10. If both paths are external, prefer the path that was received |
| 274 | first (the oldest one). This step minimizes route-flap, since a |
| 275 | newer path won't displace an older one, even if it was the |
| 276 | preferred route based on the additional decision criteria below. */ |
| 277 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 278 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 279 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 280 | { |
| 281 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 282 | return 1; |
| 283 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 284 | return 0; |
| 285 | } |
| 286 | |
| 287 | /* 11. Rourter-ID comparision. */ |
| 288 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 289 | new_id.s_addr = new->attr->originator_id.s_addr; |
| 290 | else |
| 291 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 292 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 293 | exist_id.s_addr = exist->attr->originator_id.s_addr; |
| 294 | else |
| 295 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 296 | |
| 297 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 298 | return 1; |
| 299 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 300 | return 0; |
| 301 | |
| 302 | /* 12. Cluster length comparision. */ |
| 303 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 304 | new_cluster = new->attr->cluster->length; |
| 305 | else |
| 306 | new_cluster = 0; |
| 307 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 308 | exist_cluster = exist->attr->cluster->length; |
| 309 | else |
| 310 | exist_cluster = 0; |
| 311 | |
| 312 | if (new_cluster < exist_cluster) |
| 313 | return 1; |
| 314 | if (new_cluster > exist_cluster) |
| 315 | return 0; |
| 316 | |
| 317 | /* 13. Neighbor address comparision. */ |
| 318 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 319 | |
| 320 | if (ret == 1) |
| 321 | return 0; |
| 322 | if (ret == -1) |
| 323 | return 1; |
| 324 | |
| 325 | return 1; |
| 326 | } |
| 327 | |
| 328 | enum filter_type |
| 329 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 330 | afi_t afi, safi_t safi) |
| 331 | { |
| 332 | struct bgp_filter *filter; |
| 333 | |
| 334 | filter = &peer->filter[afi][safi]; |
| 335 | |
| 336 | if (DISTRIBUTE_IN_NAME (filter)) |
| 337 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 338 | return FILTER_DENY; |
| 339 | |
| 340 | if (PREFIX_LIST_IN_NAME (filter)) |
| 341 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 342 | return FILTER_DENY; |
| 343 | |
| 344 | if (FILTER_LIST_IN_NAME (filter)) |
| 345 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 346 | return FILTER_DENY; |
| 347 | |
| 348 | return FILTER_PERMIT; |
| 349 | } |
| 350 | |
| 351 | enum filter_type |
| 352 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 353 | afi_t afi, safi_t safi) |
| 354 | { |
| 355 | struct bgp_filter *filter; |
| 356 | |
| 357 | filter = &peer->filter[afi][safi]; |
| 358 | |
| 359 | if (DISTRIBUTE_OUT_NAME (filter)) |
| 360 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 361 | return FILTER_DENY; |
| 362 | |
| 363 | if (PREFIX_LIST_OUT_NAME (filter)) |
| 364 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 365 | return FILTER_DENY; |
| 366 | |
| 367 | if (FILTER_LIST_OUT_NAME (filter)) |
| 368 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 369 | return FILTER_DENY; |
| 370 | |
| 371 | return FILTER_PERMIT; |
| 372 | } |
| 373 | |
| 374 | /* If community attribute includes no_export then return 1. */ |
| 375 | int |
| 376 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 377 | { |
| 378 | if (attr->community) |
| 379 | { |
| 380 | /* NO_ADVERTISE check. */ |
| 381 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 382 | return 1; |
| 383 | |
| 384 | /* NO_EXPORT check. */ |
| 385 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 386 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 387 | return 1; |
| 388 | |
| 389 | /* NO_EXPORT_SUBCONFED check. */ |
| 390 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 391 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 392 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 393 | return 1; |
| 394 | } |
| 395 | return 0; |
| 396 | } |
| 397 | |
| 398 | /* Route reflection loop check. */ |
| 399 | static int |
| 400 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 401 | { |
| 402 | struct in_addr cluster_id; |
| 403 | |
| 404 | if (attr->cluster) |
| 405 | { |
| 406 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 407 | cluster_id = peer->bgp->cluster_id; |
| 408 | else |
| 409 | cluster_id = peer->bgp->router_id; |
| 410 | |
| 411 | if (cluster_loop_check (attr->cluster, cluster_id)) |
| 412 | return 1; |
| 413 | } |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | int |
| 418 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 419 | afi_t afi, safi_t safi) |
| 420 | { |
| 421 | struct bgp_filter *filter; |
| 422 | struct bgp_info info; |
| 423 | route_map_result_t ret; |
| 424 | |
| 425 | filter = &peer->filter[afi][safi]; |
| 426 | |
| 427 | /* Apply default weight value. */ |
| 428 | attr->weight = peer->weight; |
| 429 | |
| 430 | /* Route map apply. */ |
| 431 | if (ROUTE_MAP_IN_NAME (filter)) |
| 432 | { |
| 433 | /* Duplicate current value to new strucutre for modification. */ |
| 434 | info.peer = peer; |
| 435 | info.attr = attr; |
| 436 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 437 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 438 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 439 | /* Apply BGP route map to the attribute. */ |
| 440 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 441 | |
| 442 | peer->rmap_type = 0; |
| 443 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 444 | if (ret == RMAP_DENYMATCH) |
| 445 | { |
| 446 | /* Free newly generated AS path and community by route-map. */ |
| 447 | bgp_attr_flush (attr); |
| 448 | return RMAP_DENY; |
| 449 | } |
| 450 | } |
| 451 | return RMAP_PERMIT; |
| 452 | } |
| 453 | |
| 454 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 455 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 456 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 457 | { |
| 458 | struct bgp_filter *filter; |
| 459 | struct bgp_info info; |
| 460 | route_map_result_t ret; |
| 461 | |
| 462 | filter = &peer->filter[afi][safi]; |
| 463 | |
| 464 | /* Route map apply. */ |
| 465 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 466 | { |
| 467 | /* Duplicate current value to new strucutre for modification. */ |
| 468 | info.peer = rsclient; |
| 469 | info.attr = attr; |
| 470 | |
| 471 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 472 | |
| 473 | /* Apply BGP route map to the attribute. */ |
| 474 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 475 | |
| 476 | rsclient->rmap_type = 0; |
| 477 | |
| 478 | if (ret == RMAP_DENYMATCH) |
| 479 | { |
| 480 | /* Free newly generated AS path and community by route-map. */ |
| 481 | bgp_attr_flush (attr); |
| 482 | return RMAP_DENY; |
| 483 | } |
| 484 | } |
| 485 | return RMAP_PERMIT; |
| 486 | } |
| 487 | |
| 488 | int |
| 489 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 490 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 491 | { |
| 492 | struct bgp_filter *filter; |
| 493 | struct bgp_info info; |
| 494 | route_map_result_t ret; |
| 495 | |
| 496 | filter = &rsclient->filter[afi][safi]; |
| 497 | |
| 498 | /* Apply default weight value. */ |
| 499 | attr->weight = peer->weight; |
| 500 | |
| 501 | /* Route map apply. */ |
| 502 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 503 | { |
| 504 | /* Duplicate current value to new strucutre for modification. */ |
| 505 | info.peer = peer; |
| 506 | info.attr = attr; |
| 507 | |
| 508 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 509 | |
| 510 | /* Apply BGP route map to the attribute. */ |
| 511 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 512 | |
| 513 | peer->rmap_type = 0; |
| 514 | |
| 515 | if (ret == RMAP_DENYMATCH) |
| 516 | { |
| 517 | /* Free newly generated AS path and community by route-map. */ |
| 518 | bgp_attr_flush (attr); |
| 519 | return RMAP_DENY; |
| 520 | } |
| 521 | } |
| 522 | return RMAP_PERMIT; |
| 523 | } |
| 524 | |
| 525 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 526 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 527 | struct attr *attr, afi_t afi, safi_t safi) |
| 528 | { |
| 529 | int ret; |
| 530 | char buf[SU_ADDRSTRLEN]; |
| 531 | struct bgp_filter *filter; |
| 532 | struct bgp_info info; |
| 533 | struct peer *from; |
| 534 | struct bgp *bgp; |
| 535 | struct attr dummy_attr; |
| 536 | int transparent; |
| 537 | int reflect; |
| 538 | |
| 539 | from = ri->peer; |
| 540 | filter = &peer->filter[afi][safi]; |
| 541 | bgp = peer->bgp; |
| 542 | |
| 543 | #ifdef DISABLE_BGP_ANNOUNCE |
| 544 | return 0; |
| 545 | #endif |
| 546 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 547 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 548 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 549 | return 0; |
| 550 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 551 | /* Do not send back route to sender. */ |
| 552 | if (from == peer) |
| 553 | return 0; |
| 554 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 555 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 556 | if (p->family == AF_INET |
| 557 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 558 | return 0; |
| 559 | #ifdef HAVE_IPV6 |
| 560 | if (p->family == AF_INET6 |
| 561 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 562 | return 0; |
| 563 | #endif |
| 564 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 565 | /* Aggregate-address suppress check. */ |
| 566 | if (ri->suppress) |
| 567 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 568 | return 0; |
| 569 | |
| 570 | /* Default route check. */ |
| 571 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 572 | { |
| 573 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 574 | return 0; |
| 575 | #ifdef HAVE_IPV6 |
| 576 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 577 | return 0; |
| 578 | #endif /* HAVE_IPV6 */ |
| 579 | } |
| 580 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 581 | /* Transparency check. */ |
| 582 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 583 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 584 | transparent = 1; |
| 585 | else |
| 586 | transparent = 0; |
| 587 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 588 | /* If community is not disabled check the no-export and local. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 589 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 590 | return 0; |
| 591 | |
| 592 | /* If the attribute has originator-id and it is same as remote |
| 593 | peer's id. */ |
| 594 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 595 | { |
| 596 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id)) |
| 597 | { |
| 598 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 599 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 600 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 601 | peer->host, |
| 602 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 603 | p->prefixlen); |
| 604 | return 0; |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | /* ORF prefix-list filter check */ |
| 609 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 610 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 611 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 612 | if (peer->orf_plist[afi][safi]) |
| 613 | { |
| 614 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | /* Output filter check. */ |
| 619 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) |
| 620 | { |
| 621 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 622 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | "%s [Update:SEND] %s/%d is filtered", |
| 624 | peer->host, |
| 625 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 626 | p->prefixlen); |
| 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | #ifdef BGP_SEND_ASPATH_CHECK |
| 631 | /* AS path loop check. */ |
| 632 | if (aspath_loop_check (ri->attr->aspath, peer->as)) |
| 633 | { |
| 634 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 635 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 636 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 637 | peer->host, peer->as); |
| 638 | return 0; |
| 639 | } |
| 640 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 641 | |
| 642 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 643 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 644 | { |
| 645 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) |
| 646 | { |
| 647 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 648 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 649 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 650 | peer->host, |
| 651 | bgp->confed_id); |
| 652 | return 0; |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | /* Route-Reflect check. */ |
| 657 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 658 | reflect = 1; |
| 659 | else |
| 660 | reflect = 0; |
| 661 | |
| 662 | /* IBGP reflection check. */ |
| 663 | if (reflect) |
| 664 | { |
| 665 | /* A route from a Client peer. */ |
| 666 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 667 | { |
| 668 | /* Reflect to all the Non-Client peers and also to the |
| 669 | Client peers other than the originator. Originator check |
| 670 | is already done. So there is noting to do. */ |
| 671 | /* no bgp client-to-client reflection check. */ |
| 672 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 673 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 674 | return 0; |
| 675 | } |
| 676 | else |
| 677 | { |
| 678 | /* A route from a Non-client peer. Reflect to all other |
| 679 | clients. */ |
| 680 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 681 | return 0; |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | /* For modify attribute, copy it to temporary structure. */ |
| 686 | *attr = *ri->attr; |
| 687 | |
| 688 | /* If local-preference is not set. */ |
| 689 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 690 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 691 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 692 | { |
| 693 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 694 | attr->local_pref = bgp->default_local_pref; |
| 695 | } |
| 696 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 697 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 698 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 699 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 700 | { |
| 701 | if (ri->peer != bgp->peer_self && ! transparent |
| 702 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 703 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 704 | } |
| 705 | |
| 706 | /* next-hop-set */ |
| 707 | if (transparent || reflect |
| 708 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 709 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 710 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 711 | || (p->family == AF_INET6 && |
| 712 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 713 | #endif /* HAVE_IPV6 */ |
| 714 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 715 | { |
| 716 | /* NEXT-HOP Unchanged. */ |
| 717 | } |
| 718 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 719 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 720 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 721 | || (p->family == AF_INET6 && |
| 722 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | #endif /* HAVE_IPV6 */ |
| 724 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 725 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 726 | { |
| 727 | /* Set IPv4 nexthop. */ |
| 728 | if (p->family == AF_INET) |
| 729 | { |
| 730 | if (safi == SAFI_MPLS_VPN) |
| 731 | memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 732 | else |
| 733 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 734 | } |
| 735 | #ifdef HAVE_IPV6 |
| 736 | /* Set IPv6 nexthop. */ |
| 737 | if (p->family == AF_INET6) |
| 738 | { |
| 739 | /* IPv6 global nexthop must be included. */ |
| 740 | memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global, |
| 741 | IPV6_MAX_BYTELEN); |
| 742 | attr->mp_nexthop_len = 16; |
| 743 | } |
| 744 | #endif /* HAVE_IPV6 */ |
| 745 | } |
| 746 | |
| 747 | #ifdef HAVE_IPV6 |
| 748 | if (p->family == AF_INET6) |
| 749 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 750 | /* Left nexthop_local unchanged if so configured. */ |
| 751 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 752 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 753 | { |
| 754 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 755 | attr->mp_nexthop_len=32; |
| 756 | else |
| 757 | attr->mp_nexthop_len=16; |
| 758 | } |
| 759 | |
| 760 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 761 | else |
| 762 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 763 | /* Link-local address should not be transit to different peer. */ |
| 764 | attr->mp_nexthop_len = 16; |
| 765 | |
| 766 | /* Set link-local address for shared network peer. */ |
| 767 | if (peer->shared_network |
| 768 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 769 | { |
| 770 | memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local, |
| 771 | IPV6_MAX_BYTELEN); |
| 772 | attr->mp_nexthop_len = 32; |
| 773 | } |
| 774 | |
| 775 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 776 | address.*/ |
| 777 | if (reflect) |
| 778 | attr->mp_nexthop_len = 16; |
| 779 | |
| 780 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 781 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
| 782 | attr->mp_nexthop_len = 16; |
| 783 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 784 | |
| 785 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 786 | #endif /* HAVE_IPV6 */ |
| 787 | |
| 788 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 789 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 790 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 791 | && aspath_private_as_check (attr->aspath)) |
| 792 | attr->aspath = aspath_empty_get (); |
| 793 | |
| 794 | /* Route map & unsuppress-map apply. */ |
| 795 | if (ROUTE_MAP_OUT_NAME (filter) |
| 796 | || ri->suppress) |
| 797 | { |
| 798 | info.peer = peer; |
| 799 | info.attr = attr; |
| 800 | |
| 801 | /* The route reflector is not allowed to modify the attributes |
| 802 | of the reflected IBGP routes. */ |
| 803 | if (peer_sort (from) == BGP_PEER_IBGP |
| 804 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 805 | { |
| 806 | dummy_attr = *attr; |
| 807 | info.attr = &dummy_attr; |
| 808 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 809 | |
| 810 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 811 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 812 | if (ri->suppress) |
| 813 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 814 | else |
| 815 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 816 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 817 | peer->rmap_type = 0; |
| 818 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 819 | if (ret == RMAP_DENYMATCH) |
| 820 | { |
| 821 | bgp_attr_flush (attr); |
| 822 | return 0; |
| 823 | } |
| 824 | } |
| 825 | return 1; |
| 826 | } |
| 827 | |
| 828 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 829 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 830 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 831 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 832 | int ret; |
| 833 | char buf[SU_ADDRSTRLEN]; |
| 834 | struct bgp_filter *filter; |
| 835 | struct bgp_info info; |
| 836 | struct peer *from; |
| 837 | struct bgp *bgp; |
| 838 | |
| 839 | from = ri->peer; |
| 840 | filter = &rsclient->filter[afi][safi]; |
| 841 | bgp = rsclient->bgp; |
| 842 | |
| 843 | #ifdef DISABLE_BGP_ANNOUNCE |
| 844 | return 0; |
| 845 | #endif |
| 846 | |
| 847 | /* Do not send back route to sender. */ |
| 848 | if (from == rsclient) |
| 849 | return 0; |
| 850 | |
| 851 | /* Aggregate-address suppress check. */ |
| 852 | if (ri->suppress) |
| 853 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 854 | return 0; |
| 855 | |
| 856 | /* Default route check. */ |
| 857 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 858 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 859 | { |
| 860 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 861 | return 0; |
| 862 | #ifdef HAVE_IPV6 |
| 863 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 864 | return 0; |
| 865 | #endif /* HAVE_IPV6 */ |
| 866 | } |
| 867 | |
| 868 | /* If the attribute has originator-id and it is same as remote |
| 869 | peer's id. */ |
| 870 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 871 | { |
| 872 | if (IPV4_ADDR_SAME (&rsclient->remote_id, &ri->attr->originator_id)) |
| 873 | { |
| 874 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 875 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 876 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 877 | rsclient->host, |
| 878 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 879 | p->prefixlen); |
| 880 | return 0; |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | /* ORF prefix-list filter check */ |
| 885 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 886 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 887 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 888 | if (rsclient->orf_plist[afi][safi]) |
| 889 | { |
| 890 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 891 | return 0; |
| 892 | } |
| 893 | |
| 894 | /* Output filter check. */ |
| 895 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) |
| 896 | { |
| 897 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 898 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 899 | "%s [Update:SEND] %s/%d is filtered", |
| 900 | rsclient->host, |
| 901 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 902 | p->prefixlen); |
| 903 | return 0; |
| 904 | } |
| 905 | |
| 906 | #ifdef BGP_SEND_ASPATH_CHECK |
| 907 | /* AS path loop check. */ |
| 908 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) |
| 909 | { |
| 910 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 911 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 912 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 913 | rsclient->host, rsclient->as); |
| 914 | return 0; |
| 915 | } |
| 916 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 917 | |
| 918 | /* For modify attribute, copy it to temporary structure. */ |
| 919 | *attr = *ri->attr; |
| 920 | |
| 921 | /* next-hop-set */ |
| 922 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 923 | #ifdef HAVE_IPV6 |
| 924 | || (p->family == AF_INET6 && |
| 925 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
| 926 | #endif /* HAVE_IPV6 */ |
| 927 | ) |
| 928 | { |
| 929 | /* Set IPv4 nexthop. */ |
| 930 | if (p->family == AF_INET) |
| 931 | { |
| 932 | if (safi == SAFI_MPLS_VPN) |
| 933 | memcpy (&attr->mp_nexthop_global_in, &rsclient->nexthop.v4, |
| 934 | IPV4_MAX_BYTELEN); |
| 935 | else |
| 936 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 937 | } |
| 938 | #ifdef HAVE_IPV6 |
| 939 | /* Set IPv6 nexthop. */ |
| 940 | if (p->family == AF_INET6) |
| 941 | { |
| 942 | /* IPv6 global nexthop must be included. */ |
| 943 | memcpy (&attr->mp_nexthop_global, &rsclient->nexthop.v6_global, |
| 944 | |
| 945 | IPV6_MAX_BYTELEN); |
| 946 | attr->mp_nexthop_len = 16; |
| 947 | } |
| 948 | #endif /* HAVE_IPV6 */ |
| 949 | } |
| 950 | |
| 951 | #ifdef HAVE_IPV6 |
| 952 | if (p->family == AF_INET6) |
| 953 | { |
| 954 | /* Left nexthop_local unchanged if so configured. */ |
| 955 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 956 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 957 | { |
| 958 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 959 | attr->mp_nexthop_len=32; |
| 960 | else |
| 961 | attr->mp_nexthop_len=16; |
| 962 | } |
| 963 | |
| 964 | /* Default nexthop_local treatment for RS-Clients */ |
| 965 | else |
| 966 | { |
| 967 | /* Announcer and RS-Client are both in the same network */ |
| 968 | if (rsclient->shared_network && from->shared_network && |
| 969 | (rsclient->ifindex == from->ifindex)) |
| 970 | { |
| 971 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 972 | attr->mp_nexthop_len=32; |
| 973 | else |
| 974 | attr->mp_nexthop_len=16; |
| 975 | } |
| 976 | |
| 977 | /* Set link-local address for shared network peer. */ |
| 978 | else if (rsclient->shared_network |
| 979 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 980 | { |
| 981 | memcpy (&attr->mp_nexthop_local, &rsclient->nexthop.v6_local, |
| 982 | IPV6_MAX_BYTELEN); |
| 983 | attr->mp_nexthop_len = 32; |
| 984 | } |
| 985 | |
| 986 | else |
| 987 | attr->mp_nexthop_len = 16; |
| 988 | } |
| 989 | |
| 990 | } |
| 991 | #endif /* HAVE_IPV6 */ |
| 992 | |
| 993 | |
| 994 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 995 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 996 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 997 | && aspath_private_as_check (attr->aspath)) |
| 998 | attr->aspath = aspath_empty_get (); |
| 999 | |
| 1000 | /* Route map & unsuppress-map apply. */ |
| 1001 | if (ROUTE_MAP_OUT_NAME (filter) || ri->suppress) |
| 1002 | { |
| 1003 | info.peer = rsclient; |
| 1004 | info.attr = attr; |
| 1005 | |
| 1006 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1007 | |
| 1008 | if (ri->suppress) |
| 1009 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1010 | else |
| 1011 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1012 | |
| 1013 | rsclient->rmap_type = 0; |
| 1014 | |
| 1015 | if (ret == RMAP_DENYMATCH) |
| 1016 | { |
| 1017 | bgp_attr_flush (attr); |
| 1018 | return 0; |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | return 1; |
| 1023 | } |
| 1024 | |
| 1025 | struct bgp_info_pair |
| 1026 | { |
| 1027 | struct bgp_info *old; |
| 1028 | struct bgp_info *new; |
| 1029 | }; |
| 1030 | |
| 1031 | void |
| 1032 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
| 1033 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1034 | struct bgp_info *new_select; |
| 1035 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1036 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1037 | struct bgp_info *ri1; |
| 1038 | struct bgp_info *ri2; |
| 1039 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1040 | /* bgp deterministic-med */ |
| 1041 | new_select = NULL; |
| 1042 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1043 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1044 | { |
| 1045 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1046 | continue; |
| 1047 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1048 | continue; |
| 1049 | |
| 1050 | new_select = ri1; |
| 1051 | if (ri1->next) |
| 1052 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1053 | { |
| 1054 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1055 | continue; |
| 1056 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1057 | continue; |
| 1058 | |
| 1059 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1060 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1061 | ri2->attr->aspath)) |
| 1062 | { |
| 1063 | if (bgp_info_cmp (bgp, ri2, new_select)) |
| 1064 | { |
| 1065 | UNSET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1066 | new_select = ri2; |
| 1067 | } |
| 1068 | |
| 1069 | SET_FLAG (ri2->flags, BGP_INFO_DMED_CHECK); |
| 1070 | } |
| 1071 | } |
| 1072 | SET_FLAG (new_select->flags, BGP_INFO_DMED_CHECK); |
| 1073 | SET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1074 | } |
| 1075 | |
| 1076 | /* Check old selected route and new selected route. */ |
| 1077 | old_select = NULL; |
| 1078 | new_select = NULL; |
| 1079 | for (ri = rn->info; ri; ri = ri->next) |
| 1080 | { |
| 1081 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1082 | old_select = ri; |
| 1083 | |
| 1084 | if (BGP_INFO_HOLDDOWN (ri)) |
| 1085 | continue; |
| 1086 | |
| 1087 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1088 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1089 | { |
| 1090 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1091 | continue; |
| 1092 | } |
| 1093 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1094 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_SELECTED); |
| 1095 | |
| 1096 | if (bgp_info_cmp (bgp, ri, new_select)) |
| 1097 | new_select = ri; |
| 1098 | } |
| 1099 | |
hasso | 6d69429 | 2005-01-24 09:29:42 +0000 | [diff] [blame] | 1100 | if ( (! old_select) || old_select != new_select |
| 1101 | || CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1102 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1103 | if (old_select) |
| 1104 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1105 | if (new_select) |
| 1106 | { |
| 1107 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1108 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1109 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1110 | } |
| 1111 | |
| 1112 | result->old = old_select; |
| 1113 | result->new = new_select; |
| 1114 | |
| 1115 | return; |
| 1116 | } |
| 1117 | |
| 1118 | int |
| 1119 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
| 1120 | struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi) |
| 1121 | { |
| 1122 | struct prefix *p; |
| 1123 | |
| 1124 | p = &rn->p; |
| 1125 | |
| 1126 | /* Announce route to Established peer. */ |
| 1127 | if (peer->status != Established) |
| 1128 | return 0; |
| 1129 | |
| 1130 | /* Address family configuration check. */ |
| 1131 | if (! peer->afc_nego[afi][safi]) |
| 1132 | return 0; |
| 1133 | |
| 1134 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 1135 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1136 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1137 | return 0; |
| 1138 | |
| 1139 | switch (rn->table->type) |
| 1140 | { |
| 1141 | case BGP_TABLE_MAIN: |
| 1142 | /* Announcement to peer->conf. If the route is filtered, |
| 1143 | withdraw it. */ |
| 1144 | if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi)) |
| 1145 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1146 | else |
| 1147 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1148 | break; |
| 1149 | case BGP_TABLE_RSCLIENT: |
| 1150 | /* Announcement to peer->conf. If the route is filtered, |
| 1151 | withdraw it. */ |
| 1152 | if (selected && bgp_announce_check_rsclient |
| 1153 | (selected, peer, p, attr, afi, safi)) |
| 1154 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1155 | else |
| 1156 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1157 | break; |
| 1158 | } |
| 1159 | return 0; |
| 1160 | } |
| 1161 | |
| 1162 | int |
| 1163 | bgp_process_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 1164 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1165 | { |
| 1166 | struct prefix *p; |
| 1167 | struct bgp_info *new_select; |
| 1168 | struct bgp_info *old_select; |
| 1169 | struct bgp_info_pair old_and_new; |
| 1170 | struct attr attr; |
| 1171 | struct peer_group *group; |
| 1172 | struct listnode *nn; |
| 1173 | |
| 1174 | p = &rn->p; |
| 1175 | |
| 1176 | /* Best path selection. */ |
| 1177 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1178 | new_select = old_and_new.new; |
| 1179 | old_select = old_and_new.old; |
| 1180 | |
| 1181 | if (CHECK_FLAG(rsclient->sflags, PEER_STATUS_GROUP)) |
| 1182 | { |
| 1183 | group = rsclient->group; |
| 1184 | LIST_LOOP(group->peer, rsclient, nn) |
| 1185 | { |
| 1186 | /* Nothing to do. */ |
| 1187 | if (old_select && old_select == new_select) |
| 1188 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1189 | continue; |
| 1190 | |
| 1191 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, |
| 1192 | afi, safi); |
| 1193 | } |
| 1194 | return 0; |
| 1195 | } |
| 1196 | |
| 1197 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, afi, safi); |
| 1198 | |
| 1199 | return 0; |
| 1200 | } |
| 1201 | |
| 1202 | int |
| 1203 | bgp_process_main (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1204 | { |
| 1205 | struct prefix *p; |
| 1206 | struct bgp_info *new_select; |
| 1207 | struct bgp_info *old_select; |
| 1208 | struct bgp_info_pair old_and_new; |
| 1209 | struct listnode *nn; |
| 1210 | struct peer *peer; |
| 1211 | struct attr attr; |
| 1212 | |
| 1213 | p = &rn->p; |
| 1214 | |
| 1215 | /* Best path selection. */ |
| 1216 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1217 | old_select = old_and_new.old; |
| 1218 | new_select = old_and_new.new; |
| 1219 | |
| 1220 | /* Nothing to do. */ |
| 1221 | if (old_select && old_select == new_select) |
| 1222 | { |
| 1223 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1224 | { |
| 1225 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) |
| 1226 | bgp_zebra_announce (p, old_select, bgp); |
| 1227 | return 0; |
| 1228 | } |
| 1229 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1230 | |
| 1231 | /* Check each BGP peer. */ |
| 1232 | LIST_LOOP (bgp->peer, peer, nn) |
| 1233 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1234 | bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | /* FIB update. */ |
| 1238 | if (safi == SAFI_UNICAST && ! bgp->name && |
| 1239 | ! bgp_option_check (BGP_OPT_NO_FIB)) |
| 1240 | { |
| 1241 | if (new_select |
| 1242 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1243 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
| 1244 | bgp_zebra_announce (p, new_select, bgp); |
| 1245 | else |
| 1246 | { |
| 1247 | /* Withdraw the route from the kernel. */ |
| 1248 | if (old_select |
| 1249 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1250 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
| 1251 | bgp_zebra_withdraw (p, old_select); |
| 1252 | } |
| 1253 | } |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
| 1257 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1258 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1259 | { |
| 1260 | switch (rn->table->type) |
| 1261 | { |
| 1262 | case BGP_TABLE_MAIN: |
| 1263 | return bgp_process_main (bgp, rn, afi, safi); |
| 1264 | case BGP_TABLE_RSCLIENT: |
| 1265 | return bgp_process_rsclient (bgp, (struct peer *) rn->table->owner, |
| 1266 | rn, afi, safi); |
| 1267 | } |
| 1268 | return 0; |
| 1269 | } |
| 1270 | |
| 1271 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1272 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1273 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1274 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1275 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1276 | return 0; |
| 1277 | |
| 1278 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1279 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1280 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1281 | && ! always) |
| 1282 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1283 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1284 | zlog (peer->log, LOG_INFO, |
| 1285 | "%%MAXPFXEXCEED: No. of prefix received from %s (afi %d): %ld exceed limit %ld", |
| 1286 | peer->host, afi, peer->pcount[afi][safi], peer->pmax[afi][safi]); |
| 1287 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1288 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1289 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1290 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1291 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1292 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1293 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1294 | |
| 1295 | if (safi == SAFI_MPLS_VPN) |
| 1296 | safi = BGP_SAFI_VPNV4; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1297 | |
| 1298 | ndata[0] = (afi >> 8); |
| 1299 | ndata[1] = afi; |
| 1300 | ndata[2] = safi; |
| 1301 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1302 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1303 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1304 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1305 | |
| 1306 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1307 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1308 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1309 | } |
| 1310 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1311 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1312 | else |
| 1313 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1314 | |
| 1315 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1316 | { |
| 1317 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1318 | && ! always) |
| 1319 | return 0; |
| 1320 | |
| 1321 | zlog (peer->log, LOG_INFO, |
| 1322 | "%%MAXPFX: No. of prefix received from %s (afi %d) reaches %ld, max %ld", |
| 1323 | peer->host, afi, peer->pcount[afi][safi], peer->pmax[afi][safi]); |
| 1324 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1325 | } |
| 1326 | else |
| 1327 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1328 | return 0; |
| 1329 | } |
| 1330 | |
| 1331 | void |
| 1332 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1333 | afi_t afi, safi_t safi) |
| 1334 | { |
| 1335 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1336 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1337 | /* Ignore 'pcount' for RS-client tables */ |
| 1338 | if ( rn->table->type == BGP_TABLE_MAIN) |
| 1339 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1340 | peer->pcount[afi][safi]--; |
| 1341 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1342 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1343 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1344 | bgp_process (peer->bgp, rn, afi, safi); |
| 1345 | } |
| 1346 | bgp_info_delete (rn, ri); |
| 1347 | bgp_info_free (ri); |
| 1348 | bgp_unlock_node (rn); |
| 1349 | } |
| 1350 | |
| 1351 | void |
| 1352 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1353 | afi_t afi, safi_t safi, int force) |
| 1354 | { |
| 1355 | int valid; |
| 1356 | int status = BGP_DAMP_NONE; |
| 1357 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1358 | /* Ignore 'pcount' for RS-client tables */ |
| 1359 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) && |
| 1360 | rn->table->type == BGP_TABLE_MAIN) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | { |
| 1362 | peer->pcount[afi][safi]--; |
| 1363 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1364 | } |
| 1365 | |
| 1366 | if (! force) |
| 1367 | { |
| 1368 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1369 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1370 | status = bgp_damp_withdraw (ri, rn, afi, safi, 0); |
| 1371 | |
| 1372 | if (status == BGP_DAMP_SUPPRESSED) |
| 1373 | return; |
| 1374 | } |
| 1375 | |
| 1376 | valid = CHECK_FLAG (ri->flags, BGP_INFO_VALID); |
| 1377 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1378 | bgp_process (peer->bgp, rn, afi, safi); |
| 1379 | |
| 1380 | if (valid) |
| 1381 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1382 | |
| 1383 | if (status != BGP_DAMP_USED) |
| 1384 | { |
| 1385 | bgp_info_delete (rn, ri); |
| 1386 | bgp_info_free (ri); |
| 1387 | bgp_unlock_node (rn); |
| 1388 | } |
| 1389 | } |
| 1390 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1391 | void |
| 1392 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1393 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1394 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1395 | { |
| 1396 | struct bgp_node *rn; |
| 1397 | struct bgp *bgp; |
| 1398 | struct attr new_attr; |
| 1399 | struct attr *attr_new; |
| 1400 | struct attr *attr_new2; |
| 1401 | struct bgp_info *ri; |
| 1402 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1403 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1404 | char buf[SU_ADDRSTRLEN]; |
| 1405 | |
| 1406 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1407 | if (peer == rsclient) |
| 1408 | return; |
| 1409 | |
| 1410 | bgp = peer->bgp; |
| 1411 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1412 | |
| 1413 | /* Check previously received route. */ |
| 1414 | for (ri = rn->info; ri; ri = ri->next) |
| 1415 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1416 | break; |
| 1417 | |
| 1418 | /* AS path loop check. */ |
| 1419 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1420 | { |
| 1421 | reason = "as-path contains our own AS;"; |
| 1422 | goto filtered; |
| 1423 | } |
| 1424 | |
| 1425 | /* Route reflector originator ID check. */ |
| 1426 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1427 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->originator_id)) |
| 1428 | { |
| 1429 | reason = "originator is us;"; |
| 1430 | goto filtered; |
| 1431 | } |
| 1432 | |
| 1433 | new_attr = *attr; |
| 1434 | |
| 1435 | /* Apply export policy. */ |
| 1436 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1437 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1438 | { |
| 1439 | reason = "export-policy;"; |
| 1440 | goto filtered; |
| 1441 | } |
| 1442 | |
| 1443 | attr_new2 = bgp_attr_intern (&new_attr); |
| 1444 | |
| 1445 | /* Apply import policy. */ |
| 1446 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1447 | { |
| 1448 | bgp_attr_unintern (attr_new2); |
| 1449 | |
| 1450 | reason = "import-policy;"; |
| 1451 | goto filtered; |
| 1452 | } |
| 1453 | |
| 1454 | attr_new = bgp_attr_intern (&new_attr); |
| 1455 | bgp_attr_unintern (attr_new2); |
| 1456 | |
| 1457 | /* IPv4 unicast next hop check. */ |
| 1458 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1459 | { |
| 1460 | /* Next hop must not be 0.0.0.0 nor Class E address. */ |
| 1461 | if (new_attr.nexthop.s_addr == 0 |
| 1462 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1463 | { |
| 1464 | bgp_attr_unintern (attr_new); |
| 1465 | |
| 1466 | reason = "martian next-hop;"; |
| 1467 | goto filtered; |
| 1468 | } |
| 1469 | } |
| 1470 | |
| 1471 | /* If the update is implicit withdraw. */ |
| 1472 | if (ri) |
| 1473 | { |
| 1474 | ri->uptime = time (NULL); |
| 1475 | |
| 1476 | /* Same attribute comes in. */ |
| 1477 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1478 | { |
| 1479 | |
| 1480 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1481 | |
| 1482 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1483 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1484 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1485 | peer->host, |
| 1486 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1487 | p->prefixlen, rsclient->host); |
| 1488 | |
| 1489 | bgp_unlock_node (rn); |
| 1490 | bgp_attr_unintern (attr_new); |
| 1491 | |
| 1492 | return; |
| 1493 | } |
| 1494 | |
| 1495 | /* Received Logging. */ |
| 1496 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1497 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1498 | peer->host, |
| 1499 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1500 | p->prefixlen, rsclient->host); |
| 1501 | |
| 1502 | /* The attribute is changed. */ |
| 1503 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1504 | |
| 1505 | /* Update to new attribute. */ |
| 1506 | bgp_attr_unintern (ri->attr); |
| 1507 | ri->attr = attr_new; |
| 1508 | |
| 1509 | /* Update MPLS tag. */ |
| 1510 | if (safi == SAFI_MPLS_VPN) |
| 1511 | memcpy (ri->tag, tag, 3); |
| 1512 | |
| 1513 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1514 | |
| 1515 | /* Process change. */ |
| 1516 | bgp_process (bgp, rn, afi, safi); |
| 1517 | bgp_unlock_node (rn); |
| 1518 | |
| 1519 | return; |
| 1520 | } |
| 1521 | |
| 1522 | /* Received Logging. */ |
| 1523 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1524 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1525 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1526 | peer->host, |
| 1527 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1528 | p->prefixlen, rsclient->host); |
| 1529 | } |
| 1530 | |
| 1531 | /* Make new BGP info. */ |
| 1532 | new = bgp_info_new (); |
| 1533 | new->type = type; |
| 1534 | new->sub_type = sub_type; |
| 1535 | new->peer = peer; |
| 1536 | new->attr = attr_new; |
| 1537 | new->uptime = time (NULL); |
| 1538 | |
| 1539 | /* Update MPLS tag. */ |
| 1540 | if (safi == SAFI_MPLS_VPN) |
| 1541 | memcpy (new->tag, tag, 3); |
| 1542 | |
| 1543 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1544 | |
| 1545 | /* Register new BGP information. */ |
| 1546 | bgp_info_add (rn, new); |
| 1547 | |
| 1548 | /* Process change. */ |
| 1549 | bgp_process (bgp, rn, afi, safi); |
| 1550 | |
| 1551 | return; |
| 1552 | |
| 1553 | filtered: |
| 1554 | |
| 1555 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 1556 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1557 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1558 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 1559 | peer->host, |
| 1560 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1561 | p->prefixlen, rsclient->host, reason); |
| 1562 | |
| 1563 | if (ri) |
| 1564 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 1); |
| 1565 | |
| 1566 | bgp_unlock_node (rn); |
| 1567 | |
| 1568 | return; |
| 1569 | } |
| 1570 | |
| 1571 | void |
| 1572 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1573 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 1574 | struct prefix_rd *prd, u_char *tag) |
| 1575 | { |
| 1576 | struct bgp_node *rn; |
| 1577 | struct bgp_info *ri; |
| 1578 | char buf[SU_ADDRSTRLEN]; |
| 1579 | |
| 1580 | if (rsclient == peer) |
| 1581 | return; |
| 1582 | |
| 1583 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1584 | |
| 1585 | /* Lookup withdrawn route. */ |
| 1586 | for (ri = rn->info; ri; ri = ri->next) |
| 1587 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1588 | break; |
| 1589 | |
| 1590 | /* Withdraw specified route from routing table. */ |
| 1591 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1592 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 0); |
| 1593 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1594 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1595 | "%s Can't find the route %s/%d", peer->host, |
| 1596 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1597 | p->prefixlen); |
| 1598 | |
| 1599 | /* Unlock bgp_node_get() lock. */ |
| 1600 | bgp_unlock_node (rn); |
| 1601 | } |
| 1602 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1603 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1604 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1605 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1606 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1607 | { |
| 1608 | int ret; |
| 1609 | int aspath_loop_count = 0; |
| 1610 | struct bgp_node *rn; |
| 1611 | struct bgp *bgp; |
| 1612 | struct attr new_attr; |
| 1613 | struct attr *attr_new; |
| 1614 | struct bgp_info *ri; |
| 1615 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1616 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1617 | char buf[SU_ADDRSTRLEN]; |
| 1618 | |
| 1619 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1620 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1621 | |
| 1622 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 1623 | Adj-RIBs-In. */ |
| 1624 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1625 | && peer != bgp->peer_self && ! soft_reconfig) |
| 1626 | bgp_adj_in_set (rn, peer, attr); |
| 1627 | |
| 1628 | /* Check previously received route. */ |
| 1629 | for (ri = rn->info; ri; ri = ri->next) |
| 1630 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1631 | break; |
| 1632 | |
| 1633 | /* AS path local-as loop check. */ |
| 1634 | if (peer->change_local_as) |
| 1635 | { |
| 1636 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 1637 | aspath_loop_count = 1; |
| 1638 | |
| 1639 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 1640 | { |
| 1641 | reason = "as-path contains our own AS;"; |
| 1642 | goto filtered; |
| 1643 | } |
| 1644 | } |
| 1645 | |
| 1646 | /* AS path loop check. */ |
| 1647 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 1648 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 1649 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 1650 | > peer->allowas_in[afi][safi])) |
| 1651 | { |
| 1652 | reason = "as-path contains our own AS;"; |
| 1653 | goto filtered; |
| 1654 | } |
| 1655 | |
| 1656 | /* Route reflector originator ID check. */ |
| 1657 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1658 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id)) |
| 1659 | { |
| 1660 | reason = "originator is us;"; |
| 1661 | goto filtered; |
| 1662 | } |
| 1663 | |
| 1664 | /* Route reflector cluster ID check. */ |
| 1665 | if (bgp_cluster_filter (peer, attr)) |
| 1666 | { |
| 1667 | reason = "reflected from the same cluster;"; |
| 1668 | goto filtered; |
| 1669 | } |
| 1670 | |
| 1671 | /* Apply incoming filter. */ |
| 1672 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 1673 | { |
| 1674 | reason = "filter;"; |
| 1675 | goto filtered; |
| 1676 | } |
| 1677 | |
| 1678 | /* Apply incoming route-map. */ |
| 1679 | new_attr = *attr; |
| 1680 | |
| 1681 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1682 | { |
| 1683 | reason = "route-map;"; |
| 1684 | goto filtered; |
| 1685 | } |
| 1686 | |
| 1687 | /* IPv4 unicast next hop check. */ |
| 1688 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1689 | { |
| 1690 | /* If the peer is EBGP and nexthop is not on connected route, |
| 1691 | discard it. */ |
| 1692 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
| 1693 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) |
| 1694 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP)) |
| 1695 | { |
| 1696 | reason = "non-connected next-hop;"; |
| 1697 | goto filtered; |
| 1698 | } |
| 1699 | |
| 1700 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop |
| 1701 | must not be my own address. */ |
| 1702 | if (bgp_nexthop_self (afi, &new_attr) |
| 1703 | || new_attr.nexthop.s_addr == 0 |
| 1704 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1705 | { |
| 1706 | reason = "martian next-hop;"; |
| 1707 | goto filtered; |
| 1708 | } |
| 1709 | } |
| 1710 | |
| 1711 | attr_new = bgp_attr_intern (&new_attr); |
| 1712 | |
| 1713 | /* If the update is implicit withdraw. */ |
| 1714 | if (ri) |
| 1715 | { |
| 1716 | ri->uptime = time (NULL); |
| 1717 | |
| 1718 | /* Same attribute comes in. */ |
| 1719 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1720 | { |
| 1721 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1722 | |
| 1723 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1724 | && peer_sort (peer) == BGP_PEER_EBGP |
| 1725 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1726 | { |
| 1727 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1728 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1729 | peer->host, |
| 1730 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1731 | p->prefixlen); |
| 1732 | |
| 1733 | peer->pcount[afi][safi]++; |
| 1734 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1735 | if (ret != BGP_DAMP_SUPPRESSED) |
| 1736 | { |
| 1737 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1738 | bgp_process (bgp, rn, afi, safi); |
| 1739 | } |
| 1740 | } |
| 1741 | else |
| 1742 | { |
| 1743 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1744 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1745 | "%s rcvd %s/%d...duplicate ignored", |
| 1746 | peer->host, |
| 1747 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1748 | p->prefixlen); |
| 1749 | } |
| 1750 | |
| 1751 | bgp_unlock_node (rn); |
| 1752 | bgp_attr_unintern (attr_new); |
| 1753 | return 0; |
| 1754 | } |
| 1755 | |
| 1756 | /* Received Logging. */ |
| 1757 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1758 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1759 | peer->host, |
| 1760 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1761 | p->prefixlen); |
| 1762 | |
| 1763 | /* The attribute is changed. */ |
| 1764 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1765 | |
| 1766 | /* Update bgp route dampening information. */ |
| 1767 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1768 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1769 | { |
| 1770 | /* This is implicit withdraw so we should update dampening |
| 1771 | information. */ |
| 1772 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1773 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
| 1774 | else |
| 1775 | peer->pcount[afi][safi]++; |
| 1776 | } |
| 1777 | |
| 1778 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 1779 | |
| 1780 | /* Update to new attribute. */ |
| 1781 | bgp_attr_unintern (ri->attr); |
| 1782 | ri->attr = attr_new; |
| 1783 | |
| 1784 | /* Update MPLS tag. */ |
| 1785 | if (safi == SAFI_MPLS_VPN) |
| 1786 | memcpy (ri->tag, tag, 3); |
| 1787 | |
| 1788 | /* Update bgp route dampening information. */ |
| 1789 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1790 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1791 | { |
| 1792 | /* Now we do normal update dampening. */ |
| 1793 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1794 | if (ret == BGP_DAMP_SUPPRESSED) |
| 1795 | { |
| 1796 | bgp_unlock_node (rn); |
| 1797 | return 0; |
| 1798 | } |
| 1799 | } |
| 1800 | |
| 1801 | /* Nexthop reachability check. */ |
| 1802 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 1803 | && safi == SAFI_UNICAST |
| 1804 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 1805 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
| 1806 | || CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP))) |
| 1807 | { |
| 1808 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
| 1809 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1810 | else |
| 1811 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1812 | } |
| 1813 | else |
| 1814 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1815 | |
| 1816 | /* Process change. */ |
| 1817 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1818 | |
| 1819 | bgp_process (bgp, rn, afi, safi); |
| 1820 | bgp_unlock_node (rn); |
| 1821 | return 0; |
| 1822 | } |
| 1823 | |
| 1824 | /* Received Logging. */ |
| 1825 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1826 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1827 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1828 | peer->host, |
| 1829 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1830 | p->prefixlen); |
| 1831 | } |
| 1832 | |
| 1833 | /* Increment prefix counter */ |
| 1834 | peer->pcount[afi][safi]++; |
| 1835 | |
| 1836 | /* Make new BGP info. */ |
| 1837 | new = bgp_info_new (); |
| 1838 | new->type = type; |
| 1839 | new->sub_type = sub_type; |
| 1840 | new->peer = peer; |
| 1841 | new->attr = attr_new; |
| 1842 | new->uptime = time (NULL); |
| 1843 | |
| 1844 | /* Update MPLS tag. */ |
| 1845 | if (safi == SAFI_MPLS_VPN) |
| 1846 | memcpy (new->tag, tag, 3); |
| 1847 | |
| 1848 | /* Nexthop reachability check. */ |
| 1849 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 1850 | && safi == SAFI_UNICAST |
| 1851 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 1852 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
| 1853 | || CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP))) |
| 1854 | { |
| 1855 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
| 1856 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1857 | else |
| 1858 | UNSET_FLAG (new->flags, BGP_INFO_VALID); |
| 1859 | } |
| 1860 | else |
| 1861 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1862 | |
| 1863 | /* Aggregate address increment. */ |
| 1864 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 1865 | |
| 1866 | /* Register new BGP information. */ |
| 1867 | bgp_info_add (rn, new); |
| 1868 | |
| 1869 | /* If maximum prefix count is configured and current prefix |
| 1870 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1871 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 1872 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1873 | |
| 1874 | /* Process change. */ |
| 1875 | bgp_process (bgp, rn, afi, safi); |
| 1876 | |
| 1877 | return 0; |
| 1878 | |
| 1879 | /* This BGP update is filtered. Log the reason then update BGP |
| 1880 | entry. */ |
| 1881 | filtered: |
| 1882 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1883 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1884 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 1885 | peer->host, |
| 1886 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1887 | p->prefixlen, reason); |
| 1888 | |
| 1889 | if (ri) |
| 1890 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 1); |
| 1891 | |
| 1892 | bgp_unlock_node (rn); |
| 1893 | |
| 1894 | return 0; |
| 1895 | } |
| 1896 | |
| 1897 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1898 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 1899 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1900 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1901 | { |
| 1902 | struct peer *rsclient; |
| 1903 | struct listnode *nn; |
| 1904 | struct bgp *bgp; |
| 1905 | int ret; |
| 1906 | |
| 1907 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 1908 | soft_reconfig); |
| 1909 | |
| 1910 | bgp = peer->bgp; |
| 1911 | |
| 1912 | /* Process the update for each RS-client. */ |
| 1913 | LIST_LOOP(bgp->rsclient, rsclient, nn) |
| 1914 | { |
| 1915 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 1916 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 1917 | sub_type, prd, tag); |
| 1918 | } |
| 1919 | |
| 1920 | return ret; |
| 1921 | } |
| 1922 | |
| 1923 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1924 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
| 1925 | int afi, int safi, int type, int sub_type, struct prefix_rd *prd, |
| 1926 | u_char *tag) |
| 1927 | { |
| 1928 | struct bgp *bgp; |
| 1929 | char buf[SU_ADDRSTRLEN]; |
| 1930 | struct bgp_node *rn; |
| 1931 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1932 | struct peer *rsclient; |
| 1933 | struct listnode *nn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1934 | |
| 1935 | bgp = peer->bgp; |
| 1936 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1937 | /* Process the withdraw for each RS-client. */ |
| 1938 | LIST_LOOP (bgp->rsclient, rsclient, nn) |
| 1939 | { |
| 1940 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 1941 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 1942 | } |
| 1943 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1944 | /* Logging. */ |
| 1945 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1946 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1947 | peer->host, |
| 1948 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1949 | p->prefixlen); |
| 1950 | |
| 1951 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1952 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1953 | |
| 1954 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 1955 | further calculation. */ |
| 1956 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1957 | && peer != bgp->peer_self) |
| 1958 | bgp_adj_in_unset (rn, peer); |
| 1959 | |
| 1960 | /* Lookup withdrawn route. */ |
| 1961 | for (ri = rn->info; ri; ri = ri->next) |
| 1962 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1963 | break; |
| 1964 | |
| 1965 | /* Withdraw specified route from routing table. */ |
| 1966 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1967 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 0); |
| 1968 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1969 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1970 | "%s Can't find the route %s/%d", peer->host, |
| 1971 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1972 | p->prefixlen); |
| 1973 | |
| 1974 | /* Unlock bgp_node_get() lock. */ |
| 1975 | bgp_unlock_node (rn); |
| 1976 | |
| 1977 | return 0; |
| 1978 | } |
| 1979 | |
| 1980 | void |
| 1981 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 1982 | { |
| 1983 | struct bgp *bgp; |
| 1984 | struct attr attr; |
| 1985 | struct aspath *aspath; |
| 1986 | struct prefix p; |
| 1987 | struct bgp_info binfo; |
| 1988 | struct peer *from; |
| 1989 | int ret = RMAP_DENYMATCH; |
| 1990 | |
| 1991 | bgp = peer->bgp; |
| 1992 | from = bgp->peer_self; |
| 1993 | |
| 1994 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 1995 | aspath = attr.aspath; |
| 1996 | attr.local_pref = bgp->default_local_pref; |
| 1997 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1998 | |
| 1999 | if (afi == AFI_IP) |
| 2000 | str2prefix ("0.0.0.0/0", &p); |
| 2001 | #ifdef HAVE_IPV6 |
| 2002 | else if (afi == AFI_IP6) |
| 2003 | { |
| 2004 | str2prefix ("::/0", &p); |
| 2005 | |
| 2006 | /* IPv6 global nexthop must be included. */ |
| 2007 | memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global, |
| 2008 | IPV6_MAX_BYTELEN); |
| 2009 | attr.mp_nexthop_len = 16; |
| 2010 | |
| 2011 | /* If the peer is on shared nextwork and we have link-local |
| 2012 | nexthop set it. */ |
| 2013 | if (peer->shared_network |
| 2014 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2015 | { |
| 2016 | memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local, |
| 2017 | IPV6_MAX_BYTELEN); |
| 2018 | attr.mp_nexthop_len = 32; |
| 2019 | } |
| 2020 | } |
| 2021 | #endif /* HAVE_IPV6 */ |
| 2022 | else |
| 2023 | return; |
| 2024 | |
| 2025 | if (peer->default_rmap[afi][safi].name) |
| 2026 | { |
| 2027 | binfo.peer = bgp->peer_self; |
| 2028 | binfo.attr = &attr; |
| 2029 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2030 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2031 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2032 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2033 | RMAP_BGP, &binfo); |
| 2034 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2035 | bgp->peer_self->rmap_type = 0; |
| 2036 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2037 | if (ret == RMAP_DENYMATCH) |
| 2038 | { |
| 2039 | bgp_attr_flush (&attr); |
| 2040 | withdraw = 1; |
| 2041 | } |
| 2042 | } |
| 2043 | |
| 2044 | if (withdraw) |
| 2045 | { |
| 2046 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2047 | bgp_default_withdraw_send (peer, afi, safi); |
| 2048 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2049 | } |
| 2050 | else |
| 2051 | { |
| 2052 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2053 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2054 | } |
| 2055 | |
| 2056 | aspath_unintern (aspath); |
| 2057 | } |
| 2058 | |
| 2059 | static void |
| 2060 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2061 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2062 | { |
| 2063 | struct bgp_node *rn; |
| 2064 | struct bgp_info *ri; |
| 2065 | struct attr attr; |
| 2066 | |
| 2067 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2068 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2069 | |
| 2070 | if (safi != SAFI_MPLS_VPN |
| 2071 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2072 | bgp_default_originate (peer, afi, safi, 0); |
| 2073 | |
| 2074 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2075 | for (ri = rn->info; ri; ri = ri->next) |
| 2076 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2077 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2078 | if ( (rsclient) ? |
| 2079 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2080 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2081 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2082 | else |
| 2083 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2084 | } |
| 2085 | } |
| 2086 | |
| 2087 | void |
| 2088 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2089 | { |
| 2090 | struct bgp_node *rn; |
| 2091 | struct bgp_table *table; |
| 2092 | |
| 2093 | if (peer->status != Established) |
| 2094 | return; |
| 2095 | |
| 2096 | if (! peer->afc_nego[afi][safi]) |
| 2097 | return; |
| 2098 | |
| 2099 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2100 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2101 | return; |
| 2102 | |
| 2103 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2104 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2105 | else |
| 2106 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2107 | rn = bgp_route_next(rn)) |
| 2108 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2109 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2110 | |
| 2111 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2112 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2113 | } |
| 2114 | |
| 2115 | void |
| 2116 | bgp_announce_route_all (struct peer *peer) |
| 2117 | { |
| 2118 | afi_t afi; |
| 2119 | safi_t safi; |
| 2120 | |
| 2121 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2122 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2123 | bgp_announce_route (peer, afi, safi); |
| 2124 | } |
| 2125 | |
| 2126 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2127 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
| 2128 | safi_t safi, struct bgp_table *table) |
| 2129 | { |
| 2130 | struct bgp_node *rn; |
| 2131 | struct bgp_adj_in *ain; |
| 2132 | |
| 2133 | if (! table) |
| 2134 | table = rsclient->bgp->rib[afi][safi]; |
| 2135 | |
| 2136 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2137 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2138 | { |
| 2139 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
| 2140 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2141 | } |
| 2142 | } |
| 2143 | |
| 2144 | void |
| 2145 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2146 | { |
| 2147 | struct bgp_table *table; |
| 2148 | struct bgp_node *rn; |
| 2149 | |
| 2150 | if (safi != SAFI_MPLS_VPN) |
| 2151 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); |
| 2152 | |
| 2153 | else |
| 2154 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2155 | rn = bgp_route_next (rn)) |
| 2156 | if ((table = rn->info) != NULL) |
| 2157 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); |
| 2158 | } |
| 2159 | |
| 2160 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2161 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 2162 | struct bgp_table *table) |
| 2163 | { |
| 2164 | int ret; |
| 2165 | struct bgp_node *rn; |
| 2166 | struct bgp_adj_in *ain; |
| 2167 | |
| 2168 | if (! table) |
| 2169 | table = peer->bgp->rib[afi][safi]; |
| 2170 | |
| 2171 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2172 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2173 | { |
| 2174 | if (ain->peer == peer) |
| 2175 | { |
| 2176 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2177 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 2178 | NULL, NULL, 1); |
| 2179 | if (ret < 0) |
| 2180 | { |
| 2181 | bgp_unlock_node (rn); |
| 2182 | return; |
| 2183 | } |
| 2184 | continue; |
| 2185 | } |
| 2186 | } |
| 2187 | } |
| 2188 | |
| 2189 | void |
| 2190 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2191 | { |
| 2192 | struct bgp_node *rn; |
| 2193 | struct bgp_table *table; |
| 2194 | |
| 2195 | if (peer->status != Established) |
| 2196 | return; |
| 2197 | |
| 2198 | if (safi != SAFI_MPLS_VPN) |
| 2199 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 2200 | else |
| 2201 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2202 | rn = bgp_route_next (rn)) |
| 2203 | if ((table = rn->info) != NULL) |
| 2204 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 2205 | } |
| 2206 | |
| 2207 | static void |
| 2208 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2209 | struct bgp_table *table, struct peer *rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2210 | { |
| 2211 | struct bgp_node *rn; |
| 2212 | struct bgp_adj_in *ain; |
| 2213 | struct bgp_adj_out *aout; |
| 2214 | struct bgp_info *ri; |
| 2215 | |
| 2216 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2217 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2218 | |
| 2219 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2220 | { |
| 2221 | for (ri = rn->info; ri; ri = ri->next) |
| 2222 | if (ri->peer == peer) |
| 2223 | { |
| 2224 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 2225 | break; |
| 2226 | } |
| 2227 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2228 | if (ain->peer == peer) |
| 2229 | { |
| 2230 | bgp_adj_in_remove (rn, ain); |
| 2231 | bgp_unlock_node (rn); |
| 2232 | break; |
| 2233 | } |
| 2234 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2235 | if (aout->peer == peer) |
| 2236 | { |
| 2237 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2238 | bgp_unlock_node (rn); |
| 2239 | break; |
| 2240 | } |
| 2241 | } |
| 2242 | } |
| 2243 | |
| 2244 | void |
| 2245 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2246 | { |
| 2247 | struct bgp_node *rn; |
| 2248 | struct bgp_table *table; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2249 | struct peer *rsclient; |
| 2250 | struct listnode *nn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2251 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2253 | bgp_clear_route_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | else |
| 2255 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2256 | rn = bgp_route_next (rn)) |
| 2257 | if ((table = rn->info) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2258 | bgp_clear_route_table (peer, afi, safi, table, NULL); |
| 2259 | |
| 2260 | LIST_LOOP (peer->bgp->rsclient, rsclient, nn) |
| 2261 | { |
| 2262 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2263 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient); |
| 2264 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2265 | } |
| 2266 | |
| 2267 | void |
| 2268 | bgp_clear_route_all (struct peer *peer) |
| 2269 | { |
| 2270 | afi_t afi; |
| 2271 | safi_t safi; |
| 2272 | |
| 2273 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2274 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2275 | bgp_clear_route (peer, afi, safi); |
| 2276 | } |
| 2277 | |
| 2278 | void |
| 2279 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2280 | { |
| 2281 | struct bgp_table *table; |
| 2282 | struct bgp_node *rn; |
| 2283 | struct bgp_adj_in *ain; |
| 2284 | |
| 2285 | table = peer->bgp->rib[afi][safi]; |
| 2286 | |
| 2287 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2288 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2289 | if (ain->peer == peer) |
| 2290 | { |
| 2291 | bgp_adj_in_remove (rn, ain); |
| 2292 | bgp_unlock_node (rn); |
| 2293 | break; |
| 2294 | } |
| 2295 | } |
| 2296 | |
| 2297 | /* Delete all kernel routes. */ |
| 2298 | void |
paul | 545acaf | 2004-04-20 15:13:15 +0000 | [diff] [blame] | 2299 | bgp_cleanup_routes () |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | { |
| 2301 | struct bgp *bgp; |
| 2302 | struct listnode *nn; |
| 2303 | struct bgp_node *rn; |
| 2304 | struct bgp_table *table; |
| 2305 | struct bgp_info *ri; |
| 2306 | |
| 2307 | LIST_LOOP (bm->bgp, bgp, nn) |
| 2308 | { |
| 2309 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 2310 | |
| 2311 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2312 | for (ri = rn->info; ri; ri = ri->next) |
| 2313 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2314 | && ri->type == ZEBRA_ROUTE_BGP |
| 2315 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2316 | bgp_zebra_withdraw (&rn->p, ri); |
| 2317 | |
| 2318 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 2319 | |
| 2320 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2321 | for (ri = rn->info; ri; ri = ri->next) |
| 2322 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2323 | && ri->type == ZEBRA_ROUTE_BGP |
| 2324 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2325 | bgp_zebra_withdraw (&rn->p, ri); |
| 2326 | } |
| 2327 | } |
| 2328 | |
| 2329 | void |
| 2330 | bgp_reset () |
| 2331 | { |
| 2332 | vty_reset (); |
| 2333 | bgp_zclient_reset (); |
| 2334 | access_list_reset (); |
| 2335 | prefix_list_reset (); |
| 2336 | } |
| 2337 | |
| 2338 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 2339 | value. */ |
| 2340 | int |
| 2341 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 2342 | { |
| 2343 | u_char *pnt; |
| 2344 | u_char *lim; |
| 2345 | struct prefix p; |
| 2346 | int psize; |
| 2347 | int ret; |
| 2348 | |
| 2349 | /* Check peer status. */ |
| 2350 | if (peer->status != Established) |
| 2351 | return 0; |
| 2352 | |
| 2353 | pnt = packet->nlri; |
| 2354 | lim = pnt + packet->length; |
| 2355 | |
| 2356 | for (; pnt < lim; pnt += psize) |
| 2357 | { |
| 2358 | /* Clear prefix structure. */ |
| 2359 | memset (&p, 0, sizeof (struct prefix)); |
| 2360 | |
| 2361 | /* Fetch prefix length. */ |
| 2362 | p.prefixlen = *pnt++; |
| 2363 | p.family = afi2family (packet->afi); |
| 2364 | |
| 2365 | /* Already checked in nlri_sanity_check(). We do double check |
| 2366 | here. */ |
| 2367 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 2368 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 2369 | return -1; |
| 2370 | |
| 2371 | /* Packet size overflow check. */ |
| 2372 | psize = PSIZE (p.prefixlen); |
| 2373 | |
| 2374 | /* When packet overflow occur return immediately. */ |
| 2375 | if (pnt + psize > lim) |
| 2376 | return -1; |
| 2377 | |
| 2378 | /* Fetch prefix from NLRI packet. */ |
| 2379 | memcpy (&p.u.prefix, pnt, psize); |
| 2380 | |
| 2381 | /* Check address. */ |
| 2382 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 2383 | { |
| 2384 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 2385 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2386 | /* |
| 2387 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 2388 | * If a BGP router receives an UPDATE message with a |
| 2389 | * semantically incorrect NLRI field, in which a prefix is |
| 2390 | * semantically incorrect (eg. an unexpected multicast IP |
| 2391 | * address), it should ignore the prefix. |
| 2392 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2393 | zlog (peer->log, LOG_ERR, |
| 2394 | "IPv4 unicast NLRI is multicast address %s", |
| 2395 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2396 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2397 | return -1; |
| 2398 | } |
| 2399 | } |
| 2400 | |
| 2401 | #ifdef HAVE_IPV6 |
| 2402 | /* Check address. */ |
| 2403 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 2404 | { |
| 2405 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2406 | { |
| 2407 | char buf[BUFSIZ]; |
| 2408 | |
| 2409 | zlog (peer->log, LOG_WARNING, |
| 2410 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 2411 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 2412 | |
| 2413 | continue; |
| 2414 | } |
| 2415 | } |
| 2416 | #endif /* HAVE_IPV6 */ |
| 2417 | |
| 2418 | /* Normal process. */ |
| 2419 | if (attr) |
| 2420 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 2421 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 2422 | else |
| 2423 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 2424 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2425 | |
| 2426 | /* Address family configuration mismatch or maximum-prefix count |
| 2427 | overflow. */ |
| 2428 | if (ret < 0) |
| 2429 | return -1; |
| 2430 | } |
| 2431 | |
| 2432 | /* Packet length consistency check. */ |
| 2433 | if (pnt != lim) |
| 2434 | return -1; |
| 2435 | |
| 2436 | return 0; |
| 2437 | } |
| 2438 | |
| 2439 | /* NLRI encode syntax check routine. */ |
| 2440 | int |
| 2441 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 2442 | bgp_size_t length) |
| 2443 | { |
| 2444 | u_char *end; |
| 2445 | u_char prefixlen; |
| 2446 | int psize; |
| 2447 | |
| 2448 | end = pnt + length; |
| 2449 | |
| 2450 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 2451 | syntactic validity. If the field is syntactically incorrect, |
| 2452 | then the Error Subcode is set to Invalid Network Field. */ |
| 2453 | |
| 2454 | while (pnt < end) |
| 2455 | { |
| 2456 | prefixlen = *pnt++; |
| 2457 | |
| 2458 | /* Prefix length check. */ |
| 2459 | if ((afi == AFI_IP && prefixlen > 32) |
| 2460 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 2461 | { |
| 2462 | plog_err (peer->log, |
| 2463 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 2464 | peer->host, prefixlen); |
| 2465 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2466 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2467 | return -1; |
| 2468 | } |
| 2469 | |
| 2470 | /* Packet size overflow check. */ |
| 2471 | psize = PSIZE (prefixlen); |
| 2472 | |
| 2473 | if (pnt + psize > end) |
| 2474 | { |
| 2475 | plog_err (peer->log, |
| 2476 | "%s [Error] Update packet error" |
| 2477 | " (prefix data overflow prefix size is %d)", |
| 2478 | peer->host, psize); |
| 2479 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2480 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2481 | return -1; |
| 2482 | } |
| 2483 | |
| 2484 | pnt += psize; |
| 2485 | } |
| 2486 | |
| 2487 | /* Packet length consistency check. */ |
| 2488 | if (pnt != end) |
| 2489 | { |
| 2490 | plog_err (peer->log, |
| 2491 | "%s [Error] Update packet error" |
| 2492 | " (prefix length mismatch with total length)", |
| 2493 | peer->host); |
| 2494 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2495 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2496 | return -1; |
| 2497 | } |
| 2498 | return 0; |
| 2499 | } |
| 2500 | |
| 2501 | struct bgp_static * |
| 2502 | bgp_static_new () |
| 2503 | { |
| 2504 | struct bgp_static *new; |
| 2505 | new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
| 2506 | memset (new, 0, sizeof (struct bgp_static)); |
| 2507 | return new; |
| 2508 | } |
| 2509 | |
| 2510 | void |
| 2511 | bgp_static_free (struct bgp_static *bgp_static) |
| 2512 | { |
| 2513 | if (bgp_static->rmap.name) |
| 2514 | free (bgp_static->rmap.name); |
| 2515 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 2516 | } |
| 2517 | |
| 2518 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2519 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 2520 | struct prefix *p, afi_t afi, safi_t safi) |
| 2521 | { |
| 2522 | struct bgp_node *rn; |
| 2523 | struct bgp_info *ri; |
| 2524 | |
| 2525 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2526 | |
| 2527 | /* Check selected route and self inserted route. */ |
| 2528 | for (ri = rn->info; ri; ri = ri->next) |
| 2529 | if (ri->peer == bgp->peer_self |
| 2530 | && ri->type == ZEBRA_ROUTE_BGP |
| 2531 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2532 | break; |
| 2533 | |
| 2534 | /* Withdraw static BGP route from routing table. */ |
| 2535 | if (ri) |
| 2536 | { |
| 2537 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2538 | bgp_process (bgp, rn, afi, safi); |
| 2539 | bgp_info_delete (rn, ri); |
| 2540 | bgp_info_free (ri); |
| 2541 | bgp_unlock_node (rn); |
| 2542 | } |
| 2543 | |
| 2544 | /* Unlock bgp_node_lookup. */ |
| 2545 | bgp_unlock_node (rn); |
| 2546 | } |
| 2547 | |
| 2548 | void |
| 2549 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
| 2550 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2551 | { |
| 2552 | struct bgp_node *rn; |
| 2553 | struct bgp_info *ri; |
| 2554 | struct bgp_info *new; |
| 2555 | struct bgp_info info; |
| 2556 | struct attr new_attr; |
| 2557 | struct attr *attr_new; |
| 2558 | struct attr attr; |
| 2559 | struct bgp *bgp; |
| 2560 | int ret; |
| 2561 | char buf[SU_ADDRSTRLEN]; |
| 2562 | |
| 2563 | bgp = rsclient->bgp; |
| 2564 | |
| 2565 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2566 | |
| 2567 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2568 | if (bgp_static) |
| 2569 | { |
| 2570 | attr.nexthop = bgp_static->igpnexthop; |
| 2571 | attr.med = bgp_static->igpmetric; |
| 2572 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 2573 | } |
| 2574 | |
| 2575 | new_attr = attr; |
| 2576 | |
| 2577 | /* Apply network route-map for export to this rsclient. */ |
| 2578 | if (bgp_static->rmap.name) |
| 2579 | { |
| 2580 | info.peer = rsclient; |
| 2581 | info.attr = &new_attr; |
| 2582 | |
| 2583 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 2584 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2585 | |
| 2586 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 2587 | |
| 2588 | rsclient->rmap_type = 0; |
| 2589 | |
| 2590 | if (ret == RMAP_DENYMATCH) |
| 2591 | { |
| 2592 | /* Free uninterned attribute. */ |
| 2593 | bgp_attr_flush (&new_attr); |
| 2594 | |
| 2595 | /* Unintern original. */ |
| 2596 | aspath_unintern (attr.aspath); |
| 2597 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2598 | |
| 2599 | return; |
| 2600 | } |
| 2601 | attr_new = bgp_attr_intern (&new_attr); |
| 2602 | } |
| 2603 | else |
| 2604 | attr_new = bgp_attr_intern (&attr); |
| 2605 | |
| 2606 | new_attr = *attr_new; |
| 2607 | |
| 2608 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2609 | |
| 2610 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2611 | { |
| 2612 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2613 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2614 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2615 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 2616 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2617 | p->prefixlen, rsclient->host); |
| 2618 | |
| 2619 | bgp->peer_self->rmap_type = 0; |
| 2620 | |
| 2621 | bgp_attr_unintern (attr_new); |
| 2622 | aspath_unintern (attr.aspath); |
| 2623 | |
| 2624 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2625 | |
| 2626 | return; |
| 2627 | } |
| 2628 | |
| 2629 | bgp->peer_self->rmap_type = 0; |
| 2630 | |
| 2631 | bgp_attr_unintern (attr_new); |
| 2632 | attr_new = bgp_attr_intern (&new_attr); |
| 2633 | |
| 2634 | for (ri = rn->info; ri; ri = ri->next) |
| 2635 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 2636 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2637 | break; |
| 2638 | |
| 2639 | if (ri) |
| 2640 | { |
| 2641 | if (attrhash_cmp (ri->attr, attr_new)) |
| 2642 | { |
| 2643 | bgp_unlock_node (rn); |
| 2644 | bgp_attr_unintern (attr_new); |
| 2645 | aspath_unintern (attr.aspath); |
| 2646 | return; |
| 2647 | } |
| 2648 | else |
| 2649 | { |
| 2650 | /* The attribute is changed. */ |
| 2651 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2652 | |
| 2653 | /* Rewrite BGP route information. */ |
| 2654 | bgp_attr_unintern (ri->attr); |
| 2655 | ri->attr = attr_new; |
| 2656 | ri->uptime = time (NULL); |
| 2657 | |
| 2658 | /* Process change. */ |
| 2659 | bgp_process (bgp, rn, afi, safi); |
| 2660 | bgp_unlock_node (rn); |
| 2661 | aspath_unintern (attr.aspath); |
| 2662 | return; |
| 2663 | } |
| 2664 | } |
| 2665 | |
| 2666 | /* Make new BGP info. */ |
| 2667 | new = bgp_info_new (); |
| 2668 | new->type = ZEBRA_ROUTE_BGP; |
| 2669 | new->sub_type = BGP_ROUTE_STATIC; |
| 2670 | new->peer = bgp->peer_self; |
| 2671 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2672 | new->attr = attr_new; |
| 2673 | new->uptime = time (NULL); |
| 2674 | |
| 2675 | /* Register new BGP information. */ |
| 2676 | bgp_info_add (rn, new); |
| 2677 | |
| 2678 | /* Process change. */ |
| 2679 | bgp_process (bgp, rn, afi, safi); |
| 2680 | |
| 2681 | /* Unintern original. */ |
| 2682 | aspath_unintern (attr.aspath); |
| 2683 | } |
| 2684 | |
| 2685 | void |
| 2686 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2687 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2688 | { |
| 2689 | struct bgp_node *rn; |
| 2690 | struct bgp_info *ri; |
| 2691 | struct bgp_info *new; |
| 2692 | struct bgp_info info; |
| 2693 | struct attr attr; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2694 | struct attr attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2695 | struct attr *attr_new; |
| 2696 | int ret; |
| 2697 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2698 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2699 | |
| 2700 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2701 | if (bgp_static) |
| 2702 | { |
| 2703 | attr.nexthop = bgp_static->igpnexthop; |
| 2704 | attr.med = bgp_static->igpmetric; |
| 2705 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 2706 | } |
| 2707 | |
| 2708 | /* Apply route-map. */ |
| 2709 | if (bgp_static->rmap.name) |
| 2710 | { |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2711 | attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2712 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2713 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2714 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2715 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2716 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2717 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2718 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2719 | bgp->peer_self->rmap_type = 0; |
| 2720 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2721 | if (ret == RMAP_DENYMATCH) |
| 2722 | { |
| 2723 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2724 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2725 | |
| 2726 | /* Unintern original. */ |
| 2727 | aspath_unintern (attr.aspath); |
| 2728 | bgp_static_withdraw (bgp, p, afi, safi); |
| 2729 | return; |
| 2730 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2731 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2732 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2733 | else |
| 2734 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2735 | |
| 2736 | for (ri = rn->info; ri; ri = ri->next) |
| 2737 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 2738 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2739 | break; |
| 2740 | |
| 2741 | if (ri) |
| 2742 | { |
| 2743 | if (attrhash_cmp (ri->attr, attr_new)) |
| 2744 | { |
| 2745 | bgp_unlock_node (rn); |
| 2746 | bgp_attr_unintern (attr_new); |
| 2747 | aspath_unintern (attr.aspath); |
| 2748 | return; |
| 2749 | } |
| 2750 | else |
| 2751 | { |
| 2752 | /* The attribute is changed. */ |
| 2753 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2754 | |
| 2755 | /* Rewrite BGP route information. */ |
| 2756 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2757 | bgp_attr_unintern (ri->attr); |
| 2758 | ri->attr = attr_new; |
| 2759 | ri->uptime = time (NULL); |
| 2760 | |
| 2761 | /* Process change. */ |
| 2762 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2763 | bgp_process (bgp, rn, afi, safi); |
| 2764 | bgp_unlock_node (rn); |
| 2765 | aspath_unintern (attr.aspath); |
| 2766 | return; |
| 2767 | } |
| 2768 | } |
| 2769 | |
| 2770 | /* Make new BGP info. */ |
| 2771 | new = bgp_info_new (); |
| 2772 | new->type = ZEBRA_ROUTE_BGP; |
| 2773 | new->sub_type = BGP_ROUTE_STATIC; |
| 2774 | new->peer = bgp->peer_self; |
| 2775 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2776 | new->attr = attr_new; |
| 2777 | new->uptime = time (NULL); |
| 2778 | |
| 2779 | /* Aggregate address increment. */ |
| 2780 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2781 | |
| 2782 | /* Register new BGP information. */ |
| 2783 | bgp_info_add (rn, new); |
| 2784 | |
| 2785 | /* Process change. */ |
| 2786 | bgp_process (bgp, rn, afi, safi); |
| 2787 | |
| 2788 | /* Unintern original. */ |
| 2789 | aspath_unintern (attr.aspath); |
| 2790 | } |
| 2791 | |
| 2792 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2793 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 2794 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2795 | { |
| 2796 | struct peer *rsclient; |
| 2797 | struct listnode *nn; |
| 2798 | |
| 2799 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 2800 | |
| 2801 | LIST_LOOP(bgp->rsclient, rsclient, nn) |
| 2802 | { |
| 2803 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
| 2804 | } |
| 2805 | } |
| 2806 | |
| 2807 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2808 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 2809 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 2810 | { |
| 2811 | struct bgp_node *rn; |
| 2812 | struct bgp_info *new; |
| 2813 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2814 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2815 | |
| 2816 | /* Make new BGP info. */ |
| 2817 | new = bgp_info_new (); |
| 2818 | new->type = ZEBRA_ROUTE_BGP; |
| 2819 | new->sub_type = BGP_ROUTE_STATIC; |
| 2820 | new->peer = bgp->peer_self; |
| 2821 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 2822 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2823 | new->uptime = time (NULL); |
| 2824 | memcpy (new->tag, tag, 3); |
| 2825 | |
| 2826 | /* Aggregate address increment. */ |
| 2827 | bgp_aggregate_increment (bgp, p, (struct bgp_info *) new, afi, safi); |
| 2828 | |
| 2829 | /* Register new BGP information. */ |
| 2830 | bgp_info_add (rn, (struct bgp_info *) new); |
| 2831 | |
| 2832 | /* Process change. */ |
| 2833 | bgp_process (bgp, rn, afi, safi); |
| 2834 | } |
| 2835 | |
| 2836 | void |
| 2837 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 2838 | safi_t safi) |
| 2839 | { |
| 2840 | struct bgp_node *rn; |
| 2841 | struct bgp_info *ri; |
| 2842 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2843 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2844 | |
| 2845 | /* Check selected route and self inserted route. */ |
| 2846 | for (ri = rn->info; ri; ri = ri->next) |
| 2847 | if (ri->peer == bgp->peer_self |
| 2848 | && ri->type == ZEBRA_ROUTE_BGP |
| 2849 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2850 | break; |
| 2851 | |
| 2852 | /* Withdraw static BGP route from routing table. */ |
| 2853 | if (ri) |
| 2854 | { |
| 2855 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2856 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2857 | bgp_process (bgp, rn, afi, safi); |
| 2858 | bgp_info_delete (rn, ri); |
| 2859 | bgp_info_free (ri); |
| 2860 | bgp_unlock_node (rn); |
| 2861 | } |
| 2862 | |
| 2863 | /* Unlock bgp_node_lookup. */ |
| 2864 | bgp_unlock_node (rn); |
| 2865 | } |
| 2866 | |
| 2867 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2868 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2869 | { |
| 2870 | struct bgp_static *bgp_static; |
| 2871 | struct bgp *bgp; |
| 2872 | struct bgp_node *rn; |
| 2873 | struct prefix *p; |
| 2874 | |
| 2875 | bgp = rsclient->bgp; |
| 2876 | |
| 2877 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 2878 | if ((bgp_static = rn->info) != NULL) |
| 2879 | { |
| 2880 | p = &rn->p; |
| 2881 | |
| 2882 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 2883 | afi, safi); |
| 2884 | } |
| 2885 | } |
| 2886 | |
| 2887 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2888 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 2889 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 2890 | { |
| 2891 | struct bgp_node *rn; |
| 2892 | struct bgp_info *ri; |
| 2893 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2894 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2895 | |
| 2896 | /* Check selected route and self inserted route. */ |
| 2897 | for (ri = rn->info; ri; ri = ri->next) |
| 2898 | if (ri->peer == bgp->peer_self |
| 2899 | && ri->type == ZEBRA_ROUTE_BGP |
| 2900 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2901 | break; |
| 2902 | |
| 2903 | /* Withdraw static BGP route from routing table. */ |
| 2904 | if (ri) |
| 2905 | { |
| 2906 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2907 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2908 | bgp_process (bgp, rn, afi, safi); |
| 2909 | bgp_info_delete (rn, ri); |
| 2910 | bgp_info_free (ri); |
| 2911 | bgp_unlock_node (rn); |
| 2912 | } |
| 2913 | |
| 2914 | /* Unlock bgp_node_lookup. */ |
| 2915 | bgp_unlock_node (rn); |
| 2916 | } |
| 2917 | |
| 2918 | /* Configure static BGP network. When user don't run zebra, static |
| 2919 | route should be installed as valid. */ |
| 2920 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2921 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
| 2922 | u_int16_t afi, u_char safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2923 | { |
| 2924 | int ret; |
| 2925 | struct prefix p; |
| 2926 | struct bgp_static *bgp_static; |
| 2927 | struct bgp_node *rn; |
| 2928 | int need_update = 0; |
| 2929 | |
| 2930 | /* Convert IP prefix string to struct prefix. */ |
| 2931 | ret = str2prefix (ip_str, &p); |
| 2932 | if (! ret) |
| 2933 | { |
| 2934 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 2935 | return CMD_WARNING; |
| 2936 | } |
| 2937 | #ifdef HAVE_IPV6 |
| 2938 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2939 | { |
| 2940 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 2941 | VTY_NEWLINE); |
| 2942 | return CMD_WARNING; |
| 2943 | } |
| 2944 | #endif /* HAVE_IPV6 */ |
| 2945 | |
| 2946 | apply_mask (&p); |
| 2947 | |
| 2948 | /* Set BGP static route configuration. */ |
| 2949 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 2950 | |
| 2951 | if (rn->info) |
| 2952 | { |
| 2953 | /* Configuration change. */ |
| 2954 | bgp_static = rn->info; |
| 2955 | |
| 2956 | /* Check previous routes are installed into BGP. */ |
| 2957 | if (! bgp_static->backdoor && bgp_static->valid) |
| 2958 | need_update = 1; |
| 2959 | |
| 2960 | bgp_static->backdoor = backdoor; |
| 2961 | if (rmap) |
| 2962 | { |
| 2963 | if (bgp_static->rmap.name) |
| 2964 | free (bgp_static->rmap.name); |
| 2965 | bgp_static->rmap.name = strdup (rmap); |
| 2966 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 2967 | } |
| 2968 | else |
| 2969 | { |
| 2970 | if (bgp_static->rmap.name) |
| 2971 | free (bgp_static->rmap.name); |
| 2972 | bgp_static->rmap.name = NULL; |
| 2973 | bgp_static->rmap.map = NULL; |
| 2974 | bgp_static->valid = 0; |
| 2975 | } |
| 2976 | bgp_unlock_node (rn); |
| 2977 | } |
| 2978 | else |
| 2979 | { |
| 2980 | /* New configuration. */ |
| 2981 | bgp_static = bgp_static_new (); |
| 2982 | bgp_static->backdoor = backdoor; |
| 2983 | bgp_static->valid = 0; |
| 2984 | bgp_static->igpmetric = 0; |
| 2985 | bgp_static->igpnexthop.s_addr = 0; |
| 2986 | if (rmap) |
| 2987 | { |
| 2988 | if (bgp_static->rmap.name) |
| 2989 | free (bgp_static->rmap.name); |
| 2990 | bgp_static->rmap.name = strdup (rmap); |
| 2991 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 2992 | } |
| 2993 | rn->info = bgp_static; |
| 2994 | } |
| 2995 | |
| 2996 | /* If BGP scan is not enabled, we should install this route here. */ |
| 2997 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 2998 | { |
| 2999 | bgp_static->valid = 1; |
| 3000 | |
| 3001 | if (need_update) |
| 3002 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3003 | |
| 3004 | if (! bgp_static->backdoor) |
| 3005 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3006 | } |
| 3007 | |
| 3008 | return CMD_SUCCESS; |
| 3009 | } |
| 3010 | |
| 3011 | /* Configure static BGP network. */ |
| 3012 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3013 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3014 | u_int16_t afi, u_char safi) |
| 3015 | { |
| 3016 | int ret; |
| 3017 | struct prefix p; |
| 3018 | struct bgp_static *bgp_static; |
| 3019 | struct bgp_node *rn; |
| 3020 | |
| 3021 | /* Convert IP prefix string to struct prefix. */ |
| 3022 | ret = str2prefix (ip_str, &p); |
| 3023 | if (! ret) |
| 3024 | { |
| 3025 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3026 | return CMD_WARNING; |
| 3027 | } |
| 3028 | #ifdef HAVE_IPV6 |
| 3029 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3030 | { |
| 3031 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3032 | VTY_NEWLINE); |
| 3033 | return CMD_WARNING; |
| 3034 | } |
| 3035 | #endif /* HAVE_IPV6 */ |
| 3036 | |
| 3037 | apply_mask (&p); |
| 3038 | |
| 3039 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3040 | if (! rn) |
| 3041 | { |
| 3042 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3043 | VTY_NEWLINE); |
| 3044 | return CMD_WARNING; |
| 3045 | } |
| 3046 | |
| 3047 | bgp_static = rn->info; |
| 3048 | |
| 3049 | /* Update BGP RIB. */ |
| 3050 | if (! bgp_static->backdoor) |
| 3051 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3052 | |
| 3053 | /* Clear configuration. */ |
| 3054 | bgp_static_free (bgp_static); |
| 3055 | rn->info = NULL; |
| 3056 | bgp_unlock_node (rn); |
| 3057 | bgp_unlock_node (rn); |
| 3058 | |
| 3059 | return CMD_SUCCESS; |
| 3060 | } |
| 3061 | |
| 3062 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3063 | instance. */ |
| 3064 | void |
| 3065 | bgp_static_delete (struct bgp *bgp) |
| 3066 | { |
| 3067 | afi_t afi; |
| 3068 | safi_t safi; |
| 3069 | struct bgp_node *rn; |
| 3070 | struct bgp_node *rm; |
| 3071 | struct bgp_table *table; |
| 3072 | struct bgp_static *bgp_static; |
| 3073 | |
| 3074 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3075 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3076 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3077 | if (rn->info != NULL) |
| 3078 | { |
| 3079 | if (safi == SAFI_MPLS_VPN) |
| 3080 | { |
| 3081 | table = rn->info; |
| 3082 | |
| 3083 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3084 | { |
| 3085 | bgp_static = rn->info; |
| 3086 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3087 | AFI_IP, SAFI_MPLS_VPN, |
| 3088 | (struct prefix_rd *)&rn->p, |
| 3089 | bgp_static->tag); |
| 3090 | bgp_static_free (bgp_static); |
| 3091 | rn->info = NULL; |
| 3092 | bgp_unlock_node (rn); |
| 3093 | } |
| 3094 | } |
| 3095 | else |
| 3096 | { |
| 3097 | bgp_static = rn->info; |
| 3098 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3099 | bgp_static_free (bgp_static); |
| 3100 | rn->info = NULL; |
| 3101 | bgp_unlock_node (rn); |
| 3102 | } |
| 3103 | } |
| 3104 | } |
| 3105 | |
| 3106 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3107 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3108 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3109 | { |
| 3110 | int ret; |
| 3111 | struct prefix p; |
| 3112 | struct prefix_rd prd; |
| 3113 | struct bgp *bgp; |
| 3114 | struct bgp_node *prn; |
| 3115 | struct bgp_node *rn; |
| 3116 | struct bgp_table *table; |
| 3117 | struct bgp_static *bgp_static; |
| 3118 | u_char tag[3]; |
| 3119 | |
| 3120 | bgp = vty->index; |
| 3121 | |
| 3122 | ret = str2prefix (ip_str, &p); |
| 3123 | if (! ret) |
| 3124 | { |
| 3125 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3126 | return CMD_WARNING; |
| 3127 | } |
| 3128 | apply_mask (&p); |
| 3129 | |
| 3130 | ret = str2prefix_rd (rd_str, &prd); |
| 3131 | if (! ret) |
| 3132 | { |
| 3133 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3134 | return CMD_WARNING; |
| 3135 | } |
| 3136 | |
| 3137 | ret = str2tag (tag_str, tag); |
| 3138 | if (! ret) |
| 3139 | { |
| 3140 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3141 | return CMD_WARNING; |
| 3142 | } |
| 3143 | |
| 3144 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3145 | (struct prefix *)&prd); |
| 3146 | if (prn->info == NULL) |
| 3147 | prn->info = bgp_table_init (); |
| 3148 | else |
| 3149 | bgp_unlock_node (prn); |
| 3150 | table = prn->info; |
| 3151 | |
| 3152 | rn = bgp_node_get (table, &p); |
| 3153 | |
| 3154 | if (rn->info) |
| 3155 | { |
| 3156 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3157 | bgp_unlock_node (rn); |
| 3158 | } |
| 3159 | else |
| 3160 | { |
| 3161 | /* New configuration. */ |
| 3162 | bgp_static = bgp_static_new (); |
| 3163 | bgp_static->valid = 1; |
| 3164 | memcpy (bgp_static->tag, tag, 3); |
| 3165 | rn->info = bgp_static; |
| 3166 | |
| 3167 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3168 | } |
| 3169 | |
| 3170 | return CMD_SUCCESS; |
| 3171 | } |
| 3172 | |
| 3173 | /* Configure static BGP network. */ |
| 3174 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3175 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3176 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3177 | { |
| 3178 | int ret; |
| 3179 | struct bgp *bgp; |
| 3180 | struct prefix p; |
| 3181 | struct prefix_rd prd; |
| 3182 | struct bgp_node *prn; |
| 3183 | struct bgp_node *rn; |
| 3184 | struct bgp_table *table; |
| 3185 | struct bgp_static *bgp_static; |
| 3186 | u_char tag[3]; |
| 3187 | |
| 3188 | bgp = vty->index; |
| 3189 | |
| 3190 | /* Convert IP prefix string to struct prefix. */ |
| 3191 | ret = str2prefix (ip_str, &p); |
| 3192 | if (! ret) |
| 3193 | { |
| 3194 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3195 | return CMD_WARNING; |
| 3196 | } |
| 3197 | apply_mask (&p); |
| 3198 | |
| 3199 | ret = str2prefix_rd (rd_str, &prd); |
| 3200 | if (! ret) |
| 3201 | { |
| 3202 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3203 | return CMD_WARNING; |
| 3204 | } |
| 3205 | |
| 3206 | ret = str2tag (tag_str, tag); |
| 3207 | if (! ret) |
| 3208 | { |
| 3209 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3210 | return CMD_WARNING; |
| 3211 | } |
| 3212 | |
| 3213 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3214 | (struct prefix *)&prd); |
| 3215 | if (prn->info == NULL) |
| 3216 | prn->info = bgp_table_init (); |
| 3217 | else |
| 3218 | bgp_unlock_node (prn); |
| 3219 | table = prn->info; |
| 3220 | |
| 3221 | rn = bgp_node_lookup (table, &p); |
| 3222 | |
| 3223 | if (rn) |
| 3224 | { |
| 3225 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3226 | |
| 3227 | bgp_static = rn->info; |
| 3228 | bgp_static_free (bgp_static); |
| 3229 | rn->info = NULL; |
| 3230 | bgp_unlock_node (rn); |
| 3231 | bgp_unlock_node (rn); |
| 3232 | } |
| 3233 | else |
| 3234 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3235 | |
| 3236 | return CMD_SUCCESS; |
| 3237 | } |
| 3238 | |
| 3239 | DEFUN (bgp_network, |
| 3240 | bgp_network_cmd, |
| 3241 | "network A.B.C.D/M", |
| 3242 | "Specify a network to announce via BGP\n" |
| 3243 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3244 | { |
| 3245 | return bgp_static_set (vty, vty->index, argv[0], |
| 3246 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3247 | } |
| 3248 | |
| 3249 | DEFUN (bgp_network_route_map, |
| 3250 | bgp_network_route_map_cmd, |
| 3251 | "network A.B.C.D/M route-map WORD", |
| 3252 | "Specify a network to announce via BGP\n" |
| 3253 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3254 | "Route-map to modify the attributes\n" |
| 3255 | "Name of the route map\n") |
| 3256 | { |
| 3257 | return bgp_static_set (vty, vty->index, argv[0], |
| 3258 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3259 | } |
| 3260 | |
| 3261 | DEFUN (bgp_network_backdoor, |
| 3262 | bgp_network_backdoor_cmd, |
| 3263 | "network A.B.C.D/M backdoor", |
| 3264 | "Specify a network to announce via BGP\n" |
| 3265 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3266 | "Specify a BGP backdoor route\n") |
| 3267 | { |
| 3268 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3269 | } |
| 3270 | |
| 3271 | DEFUN (bgp_network_mask, |
| 3272 | bgp_network_mask_cmd, |
| 3273 | "network A.B.C.D mask A.B.C.D", |
| 3274 | "Specify a network to announce via BGP\n" |
| 3275 | "Network number\n" |
| 3276 | "Network mask\n" |
| 3277 | "Network mask\n") |
| 3278 | { |
| 3279 | int ret; |
| 3280 | char prefix_str[BUFSIZ]; |
| 3281 | |
| 3282 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3283 | if (! ret) |
| 3284 | { |
| 3285 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3286 | return CMD_WARNING; |
| 3287 | } |
| 3288 | |
| 3289 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3290 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3291 | } |
| 3292 | |
| 3293 | DEFUN (bgp_network_mask_route_map, |
| 3294 | bgp_network_mask_route_map_cmd, |
| 3295 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 3296 | "Specify a network to announce via BGP\n" |
| 3297 | "Network number\n" |
| 3298 | "Network mask\n" |
| 3299 | "Network mask\n" |
| 3300 | "Route-map to modify the attributes\n" |
| 3301 | "Name of the route map\n") |
| 3302 | { |
| 3303 | int ret; |
| 3304 | char prefix_str[BUFSIZ]; |
| 3305 | |
| 3306 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3307 | if (! ret) |
| 3308 | { |
| 3309 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3310 | return CMD_WARNING; |
| 3311 | } |
| 3312 | |
| 3313 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3314 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
| 3315 | } |
| 3316 | |
| 3317 | DEFUN (bgp_network_mask_backdoor, |
| 3318 | bgp_network_mask_backdoor_cmd, |
| 3319 | "network A.B.C.D mask A.B.C.D backdoor", |
| 3320 | "Specify a network to announce via BGP\n" |
| 3321 | "Network number\n" |
| 3322 | "Network mask\n" |
| 3323 | "Network mask\n" |
| 3324 | "Specify a BGP backdoor route\n") |
| 3325 | { |
| 3326 | int ret; |
| 3327 | char prefix_str[BUFSIZ]; |
| 3328 | |
| 3329 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3330 | if (! ret) |
| 3331 | { |
| 3332 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3333 | return CMD_WARNING; |
| 3334 | } |
| 3335 | |
| 3336 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3337 | } |
| 3338 | |
| 3339 | DEFUN (bgp_network_mask_natural, |
| 3340 | bgp_network_mask_natural_cmd, |
| 3341 | "network A.B.C.D", |
| 3342 | "Specify a network to announce via BGP\n" |
| 3343 | "Network number\n") |
| 3344 | { |
| 3345 | int ret; |
| 3346 | char prefix_str[BUFSIZ]; |
| 3347 | |
| 3348 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3349 | if (! ret) |
| 3350 | { |
| 3351 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3352 | return CMD_WARNING; |
| 3353 | } |
| 3354 | |
| 3355 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3356 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3357 | } |
| 3358 | |
| 3359 | DEFUN (bgp_network_mask_natural_route_map, |
| 3360 | bgp_network_mask_natural_route_map_cmd, |
| 3361 | "network A.B.C.D route-map WORD", |
| 3362 | "Specify a network to announce via BGP\n" |
| 3363 | "Network number\n" |
| 3364 | "Route-map to modify the attributes\n" |
| 3365 | "Name of the route map\n") |
| 3366 | { |
| 3367 | int ret; |
| 3368 | char prefix_str[BUFSIZ]; |
| 3369 | |
| 3370 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3371 | if (! ret) |
| 3372 | { |
| 3373 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3374 | return CMD_WARNING; |
| 3375 | } |
| 3376 | |
| 3377 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3378 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3379 | } |
| 3380 | |
| 3381 | DEFUN (bgp_network_mask_natural_backdoor, |
| 3382 | bgp_network_mask_natural_backdoor_cmd, |
| 3383 | "network A.B.C.D backdoor", |
| 3384 | "Specify a network to announce via BGP\n" |
| 3385 | "Network number\n" |
| 3386 | "Specify a BGP backdoor route\n") |
| 3387 | { |
| 3388 | int ret; |
| 3389 | char prefix_str[BUFSIZ]; |
| 3390 | |
| 3391 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3392 | if (! ret) |
| 3393 | { |
| 3394 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3395 | return CMD_WARNING; |
| 3396 | } |
| 3397 | |
| 3398 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3399 | } |
| 3400 | |
| 3401 | DEFUN (no_bgp_network, |
| 3402 | no_bgp_network_cmd, |
| 3403 | "no network A.B.C.D/M", |
| 3404 | NO_STR |
| 3405 | "Specify a network to announce via BGP\n" |
| 3406 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3407 | { |
| 3408 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 3409 | bgp_node_safi (vty)); |
| 3410 | } |
| 3411 | |
| 3412 | ALIAS (no_bgp_network, |
| 3413 | no_bgp_network_route_map_cmd, |
| 3414 | "no network A.B.C.D/M route-map WORD", |
| 3415 | NO_STR |
| 3416 | "Specify a network to announce via BGP\n" |
| 3417 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3418 | "Route-map to modify the attributes\n" |
| 3419 | "Name of the route map\n") |
| 3420 | |
| 3421 | ALIAS (no_bgp_network, |
| 3422 | no_bgp_network_backdoor_cmd, |
| 3423 | "no network A.B.C.D/M backdoor", |
| 3424 | NO_STR |
| 3425 | "Specify a network to announce via BGP\n" |
| 3426 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3427 | "Specify a BGP backdoor route\n") |
| 3428 | |
| 3429 | DEFUN (no_bgp_network_mask, |
| 3430 | no_bgp_network_mask_cmd, |
| 3431 | "no network A.B.C.D mask A.B.C.D", |
| 3432 | NO_STR |
| 3433 | "Specify a network to announce via BGP\n" |
| 3434 | "Network number\n" |
| 3435 | "Network mask\n" |
| 3436 | "Network mask\n") |
| 3437 | { |
| 3438 | int ret; |
| 3439 | char prefix_str[BUFSIZ]; |
| 3440 | |
| 3441 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3442 | if (! ret) |
| 3443 | { |
| 3444 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3445 | return CMD_WARNING; |
| 3446 | } |
| 3447 | |
| 3448 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3449 | bgp_node_safi (vty)); |
| 3450 | } |
| 3451 | |
| 3452 | ALIAS (no_bgp_network_mask, |
| 3453 | no_bgp_network_mask_route_map_cmd, |
| 3454 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 3455 | NO_STR |
| 3456 | "Specify a network to announce via BGP\n" |
| 3457 | "Network number\n" |
| 3458 | "Network mask\n" |
| 3459 | "Network mask\n" |
| 3460 | "Route-map to modify the attributes\n" |
| 3461 | "Name of the route map\n") |
| 3462 | |
| 3463 | ALIAS (no_bgp_network_mask, |
| 3464 | no_bgp_network_mask_backdoor_cmd, |
| 3465 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 3466 | NO_STR |
| 3467 | "Specify a network to announce via BGP\n" |
| 3468 | "Network number\n" |
| 3469 | "Network mask\n" |
| 3470 | "Network mask\n" |
| 3471 | "Specify a BGP backdoor route\n") |
| 3472 | |
| 3473 | DEFUN (no_bgp_network_mask_natural, |
| 3474 | no_bgp_network_mask_natural_cmd, |
| 3475 | "no network A.B.C.D", |
| 3476 | NO_STR |
| 3477 | "Specify a network to announce via BGP\n" |
| 3478 | "Network number\n") |
| 3479 | { |
| 3480 | int ret; |
| 3481 | char prefix_str[BUFSIZ]; |
| 3482 | |
| 3483 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3484 | if (! ret) |
| 3485 | { |
| 3486 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3487 | return CMD_WARNING; |
| 3488 | } |
| 3489 | |
| 3490 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3491 | bgp_node_safi (vty)); |
| 3492 | } |
| 3493 | |
| 3494 | ALIAS (no_bgp_network_mask_natural, |
| 3495 | no_bgp_network_mask_natural_route_map_cmd, |
| 3496 | "no network A.B.C.D route-map WORD", |
| 3497 | NO_STR |
| 3498 | "Specify a network to announce via BGP\n" |
| 3499 | "Network number\n" |
| 3500 | "Route-map to modify the attributes\n" |
| 3501 | "Name of the route map\n") |
| 3502 | |
| 3503 | ALIAS (no_bgp_network_mask_natural, |
| 3504 | no_bgp_network_mask_natural_backdoor_cmd, |
| 3505 | "no network A.B.C.D backdoor", |
| 3506 | NO_STR |
| 3507 | "Specify a network to announce via BGP\n" |
| 3508 | "Network number\n" |
| 3509 | "Specify a BGP backdoor route\n") |
| 3510 | |
| 3511 | #ifdef HAVE_IPV6 |
| 3512 | DEFUN (ipv6_bgp_network, |
| 3513 | ipv6_bgp_network_cmd, |
| 3514 | "network X:X::X:X/M", |
| 3515 | "Specify a network to announce via BGP\n" |
| 3516 | "IPv6 prefix <network>/<length>\n") |
| 3517 | { |
| 3518 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 3519 | } |
| 3520 | |
| 3521 | DEFUN (ipv6_bgp_network_route_map, |
| 3522 | ipv6_bgp_network_route_map_cmd, |
| 3523 | "network X:X::X:X/M route-map WORD", |
| 3524 | "Specify a network to announce via BGP\n" |
| 3525 | "IPv6 prefix <network>/<length>\n" |
| 3526 | "Route-map to modify the attributes\n" |
| 3527 | "Name of the route map\n") |
| 3528 | { |
| 3529 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
| 3530 | bgp_node_safi (vty), argv[1], 0); |
| 3531 | } |
| 3532 | |
| 3533 | DEFUN (no_ipv6_bgp_network, |
| 3534 | no_ipv6_bgp_network_cmd, |
| 3535 | "no network X:X::X:X/M", |
| 3536 | NO_STR |
| 3537 | "Specify a network to announce via BGP\n" |
| 3538 | "IPv6 prefix <network>/<length>\n") |
| 3539 | { |
| 3540 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); |
| 3541 | } |
| 3542 | |
| 3543 | ALIAS (no_ipv6_bgp_network, |
| 3544 | no_ipv6_bgp_network_route_map_cmd, |
| 3545 | "no network X:X::X:X/M route-map WORD", |
| 3546 | NO_STR |
| 3547 | "Specify a network to announce via BGP\n" |
| 3548 | "IPv6 prefix <network>/<length>\n" |
| 3549 | "Route-map to modify the attributes\n" |
| 3550 | "Name of the route map\n") |
| 3551 | |
| 3552 | ALIAS (ipv6_bgp_network, |
| 3553 | old_ipv6_bgp_network_cmd, |
| 3554 | "ipv6 bgp network X:X::X:X/M", |
| 3555 | IPV6_STR |
| 3556 | BGP_STR |
| 3557 | "Specify a network to announce via BGP\n" |
| 3558 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3559 | |
| 3560 | ALIAS (no_ipv6_bgp_network, |
| 3561 | old_no_ipv6_bgp_network_cmd, |
| 3562 | "no ipv6 bgp network X:X::X:X/M", |
| 3563 | NO_STR |
| 3564 | IPV6_STR |
| 3565 | BGP_STR |
| 3566 | "Specify a network to announce via BGP\n" |
| 3567 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3568 | #endif /* HAVE_IPV6 */ |
| 3569 | |
| 3570 | /* Aggreagete address: |
| 3571 | |
| 3572 | advertise-map Set condition to advertise attribute |
| 3573 | as-set Generate AS set path information |
| 3574 | attribute-map Set attributes of aggregate |
| 3575 | route-map Set parameters of aggregate |
| 3576 | summary-only Filter more specific routes from updates |
| 3577 | suppress-map Conditionally filter more specific routes from updates |
| 3578 | <cr> |
| 3579 | */ |
| 3580 | struct bgp_aggregate |
| 3581 | { |
| 3582 | /* Summary-only flag. */ |
| 3583 | u_char summary_only; |
| 3584 | |
| 3585 | /* AS set generation. */ |
| 3586 | u_char as_set; |
| 3587 | |
| 3588 | /* Route-map for aggregated route. */ |
| 3589 | struct route_map *map; |
| 3590 | |
| 3591 | /* Suppress-count. */ |
| 3592 | unsigned long count; |
| 3593 | |
| 3594 | /* SAFI configuration. */ |
| 3595 | safi_t safi; |
| 3596 | }; |
| 3597 | |
| 3598 | struct bgp_aggregate * |
| 3599 | bgp_aggregate_new () |
| 3600 | { |
| 3601 | struct bgp_aggregate *new; |
| 3602 | new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
| 3603 | memset (new, 0, sizeof (struct bgp_aggregate)); |
| 3604 | return new; |
| 3605 | } |
| 3606 | |
| 3607 | void |
| 3608 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 3609 | { |
| 3610 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 3611 | } |
| 3612 | |
| 3613 | void |
| 3614 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 3615 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 3616 | struct bgp_aggregate *aggregate) |
| 3617 | { |
| 3618 | struct bgp_table *table; |
| 3619 | struct bgp_node *top; |
| 3620 | struct bgp_node *rn; |
| 3621 | u_char origin; |
| 3622 | struct aspath *aspath = NULL; |
| 3623 | struct aspath *asmerge = NULL; |
| 3624 | struct community *community = NULL; |
| 3625 | struct community *commerge = NULL; |
| 3626 | struct in_addr nexthop; |
| 3627 | u_int32_t med = 0; |
| 3628 | struct bgp_info *ri; |
| 3629 | struct bgp_info *new; |
| 3630 | int first = 1; |
| 3631 | unsigned long match = 0; |
| 3632 | |
| 3633 | /* Record adding route's nexthop and med. */ |
| 3634 | if (rinew) |
| 3635 | { |
| 3636 | nexthop = rinew->attr->nexthop; |
| 3637 | med = rinew->attr->med; |
| 3638 | } |
| 3639 | |
| 3640 | /* ORIGIN attribute: If at least one route among routes that are |
| 3641 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 3642 | aggregated route must have the ORIGIN attribute with the value |
| 3643 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 3644 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 3645 | route must have the origin attribute with the value EGP. In all |
| 3646 | other case the value of the ORIGIN attribute of the aggregated |
| 3647 | route is INTERNAL. */ |
| 3648 | origin = BGP_ORIGIN_IGP; |
| 3649 | |
| 3650 | table = bgp->rib[afi][safi]; |
| 3651 | |
| 3652 | top = bgp_node_get (table, p); |
| 3653 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 3654 | if (rn->p.prefixlen > p->prefixlen) |
| 3655 | { |
| 3656 | match = 0; |
| 3657 | |
| 3658 | for (ri = rn->info; ri; ri = ri->next) |
| 3659 | { |
| 3660 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3661 | continue; |
| 3662 | |
| 3663 | if (del && ri == del) |
| 3664 | continue; |
| 3665 | |
| 3666 | if (! rinew && first) |
| 3667 | { |
| 3668 | nexthop = ri->attr->nexthop; |
| 3669 | med = ri->attr->med; |
| 3670 | first = 0; |
| 3671 | } |
| 3672 | |
| 3673 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 3674 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 3675 | || ri->attr->med != med) |
| 3676 | { |
| 3677 | if (aspath) |
| 3678 | aspath_free (aspath); |
| 3679 | if (community) |
| 3680 | community_free (community); |
| 3681 | bgp_unlock_node (rn); |
| 3682 | bgp_unlock_node (top); |
| 3683 | return; |
| 3684 | } |
| 3685 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 3686 | |
| 3687 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 3688 | { |
| 3689 | if (aggregate->summary_only) |
| 3690 | { |
| 3691 | ri->suppress++; |
| 3692 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3693 | match++; |
| 3694 | } |
| 3695 | |
| 3696 | aggregate->count++; |
| 3697 | |
| 3698 | if (aggregate->as_set) |
| 3699 | { |
| 3700 | if (origin < ri->attr->origin) |
| 3701 | origin = ri->attr->origin; |
| 3702 | |
| 3703 | if (aspath) |
| 3704 | { |
| 3705 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 3706 | aspath_free (aspath); |
| 3707 | aspath = asmerge; |
| 3708 | } |
| 3709 | else |
| 3710 | aspath = aspath_dup (ri->attr->aspath); |
| 3711 | |
| 3712 | if (ri->attr->community) |
| 3713 | { |
| 3714 | if (community) |
| 3715 | { |
| 3716 | commerge = community_merge (community, |
| 3717 | ri->attr->community); |
| 3718 | community = community_uniq_sort (commerge); |
| 3719 | community_free (commerge); |
| 3720 | } |
| 3721 | else |
| 3722 | community = community_dup (ri->attr->community); |
| 3723 | } |
| 3724 | } |
| 3725 | } |
| 3726 | } |
| 3727 | if (match) |
| 3728 | bgp_process (bgp, rn, afi, safi); |
| 3729 | } |
| 3730 | bgp_unlock_node (top); |
| 3731 | |
| 3732 | if (rinew) |
| 3733 | { |
| 3734 | aggregate->count++; |
| 3735 | |
| 3736 | if (aggregate->summary_only) |
| 3737 | rinew->suppress++; |
| 3738 | |
| 3739 | if (aggregate->as_set) |
| 3740 | { |
| 3741 | if (origin < rinew->attr->origin) |
| 3742 | origin = rinew->attr->origin; |
| 3743 | |
| 3744 | if (aspath) |
| 3745 | { |
| 3746 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 3747 | aspath_free (aspath); |
| 3748 | aspath = asmerge; |
| 3749 | } |
| 3750 | else |
| 3751 | aspath = aspath_dup (rinew->attr->aspath); |
| 3752 | |
| 3753 | if (rinew->attr->community) |
| 3754 | { |
| 3755 | if (community) |
| 3756 | { |
| 3757 | commerge = community_merge (community, |
| 3758 | rinew->attr->community); |
| 3759 | community = community_uniq_sort (commerge); |
| 3760 | community_free (commerge); |
| 3761 | } |
| 3762 | else |
| 3763 | community = community_dup (rinew->attr->community); |
| 3764 | } |
| 3765 | } |
| 3766 | } |
| 3767 | |
| 3768 | if (aggregate->count > 0) |
| 3769 | { |
| 3770 | rn = bgp_node_get (table, p); |
| 3771 | new = bgp_info_new (); |
| 3772 | new->type = ZEBRA_ROUTE_BGP; |
| 3773 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 3774 | new->peer = bgp->peer_self; |
| 3775 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3776 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 3777 | new->uptime = time (NULL); |
| 3778 | |
| 3779 | bgp_info_add (rn, new); |
| 3780 | bgp_process (bgp, rn, afi, safi); |
| 3781 | } |
| 3782 | else |
| 3783 | { |
| 3784 | if (aspath) |
| 3785 | aspath_free (aspath); |
| 3786 | if (community) |
| 3787 | community_free (community); |
| 3788 | } |
| 3789 | } |
| 3790 | |
| 3791 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 3792 | struct bgp_aggregate *); |
| 3793 | |
| 3794 | void |
| 3795 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 3796 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 3797 | { |
| 3798 | struct bgp_node *child; |
| 3799 | struct bgp_node *rn; |
| 3800 | struct bgp_aggregate *aggregate; |
| 3801 | |
| 3802 | /* MPLS-VPN aggregation is not yet supported. */ |
| 3803 | if (safi == SAFI_MPLS_VPN) |
| 3804 | return; |
| 3805 | |
| 3806 | if (p->prefixlen == 0) |
| 3807 | return; |
| 3808 | |
| 3809 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3810 | return; |
| 3811 | |
| 3812 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 3813 | |
| 3814 | /* Aggregate address configuration check. */ |
| 3815 | for (rn = child; rn; rn = rn->parent) |
| 3816 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 3817 | { |
| 3818 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3819 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3820 | } |
| 3821 | bgp_unlock_node (child); |
| 3822 | } |
| 3823 | |
| 3824 | void |
| 3825 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 3826 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 3827 | { |
| 3828 | struct bgp_node *child; |
| 3829 | struct bgp_node *rn; |
| 3830 | struct bgp_aggregate *aggregate; |
| 3831 | |
| 3832 | /* MPLS-VPN aggregation is not yet supported. */ |
| 3833 | if (safi == SAFI_MPLS_VPN) |
| 3834 | return; |
| 3835 | |
| 3836 | if (p->prefixlen == 0) |
| 3837 | return; |
| 3838 | |
| 3839 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 3840 | |
| 3841 | /* Aggregate address configuration check. */ |
| 3842 | for (rn = child; rn; rn = rn->parent) |
| 3843 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 3844 | { |
| 3845 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3846 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3847 | } |
| 3848 | bgp_unlock_node (child); |
| 3849 | } |
| 3850 | |
| 3851 | void |
| 3852 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 3853 | struct bgp_aggregate *aggregate) |
| 3854 | { |
| 3855 | struct bgp_table *table; |
| 3856 | struct bgp_node *top; |
| 3857 | struct bgp_node *rn; |
| 3858 | struct bgp_info *new; |
| 3859 | struct bgp_info *ri; |
| 3860 | unsigned long match; |
| 3861 | u_char origin = BGP_ORIGIN_IGP; |
| 3862 | struct aspath *aspath = NULL; |
| 3863 | struct aspath *asmerge = NULL; |
| 3864 | struct community *community = NULL; |
| 3865 | struct community *commerge = NULL; |
| 3866 | |
| 3867 | table = bgp->rib[afi][safi]; |
| 3868 | |
| 3869 | /* Sanity check. */ |
| 3870 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 3871 | return; |
| 3872 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 3873 | return; |
| 3874 | |
| 3875 | /* If routes exists below this node, generate aggregate routes. */ |
| 3876 | top = bgp_node_get (table, p); |
| 3877 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 3878 | if (rn->p.prefixlen > p->prefixlen) |
| 3879 | { |
| 3880 | match = 0; |
| 3881 | |
| 3882 | for (ri = rn->info; ri; ri = ri->next) |
| 3883 | { |
| 3884 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3885 | continue; |
| 3886 | |
| 3887 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 3888 | { |
| 3889 | /* summary-only aggregate route suppress aggregated |
| 3890 | route announcement. */ |
| 3891 | if (aggregate->summary_only) |
| 3892 | { |
| 3893 | ri->suppress++; |
| 3894 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3895 | match++; |
| 3896 | } |
| 3897 | /* as-set aggregate route generate origin, as path, |
| 3898 | community aggregation. */ |
| 3899 | if (aggregate->as_set) |
| 3900 | { |
| 3901 | if (origin < ri->attr->origin) |
| 3902 | origin = ri->attr->origin; |
| 3903 | |
| 3904 | if (aspath) |
| 3905 | { |
| 3906 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 3907 | aspath_free (aspath); |
| 3908 | aspath = asmerge; |
| 3909 | } |
| 3910 | else |
| 3911 | aspath = aspath_dup (ri->attr->aspath); |
| 3912 | |
| 3913 | if (ri->attr->community) |
| 3914 | { |
| 3915 | if (community) |
| 3916 | { |
| 3917 | commerge = community_merge (community, |
| 3918 | ri->attr->community); |
| 3919 | community = community_uniq_sort (commerge); |
| 3920 | community_free (commerge); |
| 3921 | } |
| 3922 | else |
| 3923 | community = community_dup (ri->attr->community); |
| 3924 | } |
| 3925 | } |
| 3926 | aggregate->count++; |
| 3927 | } |
| 3928 | } |
| 3929 | |
| 3930 | /* If this node is suppressed, process the change. */ |
| 3931 | if (match) |
| 3932 | bgp_process (bgp, rn, afi, safi); |
| 3933 | } |
| 3934 | bgp_unlock_node (top); |
| 3935 | |
| 3936 | /* Add aggregate route to BGP table. */ |
| 3937 | if (aggregate->count) |
| 3938 | { |
| 3939 | rn = bgp_node_get (table, p); |
| 3940 | |
| 3941 | new = bgp_info_new (); |
| 3942 | new->type = ZEBRA_ROUTE_BGP; |
| 3943 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 3944 | new->peer = bgp->peer_self; |
| 3945 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3946 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 3947 | new->uptime = time (NULL); |
| 3948 | |
| 3949 | bgp_info_add (rn, new); |
| 3950 | |
| 3951 | /* Process change. */ |
| 3952 | bgp_process (bgp, rn, afi, safi); |
| 3953 | } |
| 3954 | } |
| 3955 | |
| 3956 | void |
| 3957 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3958 | safi_t safi, struct bgp_aggregate *aggregate) |
| 3959 | { |
| 3960 | struct bgp_table *table; |
| 3961 | struct bgp_node *top; |
| 3962 | struct bgp_node *rn; |
| 3963 | struct bgp_info *ri; |
| 3964 | unsigned long match; |
| 3965 | |
| 3966 | table = bgp->rib[afi][safi]; |
| 3967 | |
| 3968 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 3969 | return; |
| 3970 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 3971 | return; |
| 3972 | |
| 3973 | /* If routes exists below this node, generate aggregate routes. */ |
| 3974 | top = bgp_node_get (table, p); |
| 3975 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 3976 | if (rn->p.prefixlen > p->prefixlen) |
| 3977 | { |
| 3978 | match = 0; |
| 3979 | |
| 3980 | for (ri = rn->info; ri; ri = ri->next) |
| 3981 | { |
| 3982 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3983 | continue; |
| 3984 | |
| 3985 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 3986 | { |
| 3987 | if (aggregate->summary_only) |
| 3988 | { |
| 3989 | ri->suppress--; |
| 3990 | |
| 3991 | if (ri->suppress == 0) |
| 3992 | { |
| 3993 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3994 | match++; |
| 3995 | } |
| 3996 | } |
| 3997 | aggregate->count--; |
| 3998 | } |
| 3999 | } |
| 4000 | |
| 4001 | /* If this node is suppressed, process the change. */ |
| 4002 | if (match) |
| 4003 | bgp_process (bgp, rn, afi, safi); |
| 4004 | } |
| 4005 | bgp_unlock_node (top); |
| 4006 | |
| 4007 | /* Delete aggregate route from BGP table. */ |
| 4008 | rn = bgp_node_get (table, p); |
| 4009 | |
| 4010 | for (ri = rn->info; ri; ri = ri->next) |
| 4011 | if (ri->peer == bgp->peer_self |
| 4012 | && ri->type == ZEBRA_ROUTE_BGP |
| 4013 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4014 | break; |
| 4015 | |
| 4016 | /* Withdraw static BGP route from routing table. */ |
| 4017 | if (ri) |
| 4018 | { |
| 4019 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4020 | bgp_process (bgp, rn, afi, safi); |
| 4021 | bgp_info_delete (rn, ri); |
| 4022 | bgp_info_free (ri); |
| 4023 | bgp_unlock_node (rn); |
| 4024 | } |
| 4025 | |
| 4026 | /* Unlock bgp_node_lookup. */ |
| 4027 | bgp_unlock_node (rn); |
| 4028 | } |
| 4029 | |
| 4030 | /* Aggregate route attribute. */ |
| 4031 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4032 | #define AGGREGATE_AS_SET 1 |
| 4033 | |
| 4034 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4035 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
| 4036 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4037 | u_char summary_only, u_char as_set) |
| 4038 | { |
| 4039 | int ret; |
| 4040 | struct prefix p; |
| 4041 | struct bgp_node *rn; |
| 4042 | struct bgp *bgp; |
| 4043 | struct bgp_aggregate *aggregate; |
| 4044 | |
| 4045 | /* Convert string to prefix structure. */ |
| 4046 | ret = str2prefix (prefix_str, &p); |
| 4047 | if (!ret) |
| 4048 | { |
| 4049 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4050 | return CMD_WARNING; |
| 4051 | } |
| 4052 | apply_mask (&p); |
| 4053 | |
| 4054 | /* Get BGP structure. */ |
| 4055 | bgp = vty->index; |
| 4056 | |
| 4057 | /* Old configuration check. */ |
| 4058 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4059 | |
| 4060 | if (rn->info) |
| 4061 | { |
| 4062 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
| 4063 | bgp_unlock_node (rn); |
| 4064 | return CMD_WARNING; |
| 4065 | } |
| 4066 | |
| 4067 | /* Make aggregate address structure. */ |
| 4068 | aggregate = bgp_aggregate_new (); |
| 4069 | aggregate->summary_only = summary_only; |
| 4070 | aggregate->as_set = as_set; |
| 4071 | aggregate->safi = safi; |
| 4072 | rn->info = aggregate; |
| 4073 | |
| 4074 | /* Aggregate address insert into BGP routing table. */ |
| 4075 | if (safi & SAFI_UNICAST) |
| 4076 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4077 | if (safi & SAFI_MULTICAST) |
| 4078 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4079 | |
| 4080 | return CMD_SUCCESS; |
| 4081 | } |
| 4082 | |
| 4083 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4084 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4085 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4086 | { |
| 4087 | int ret; |
| 4088 | struct prefix p; |
| 4089 | struct bgp_node *rn; |
| 4090 | struct bgp *bgp; |
| 4091 | struct bgp_aggregate *aggregate; |
| 4092 | |
| 4093 | /* Convert string to prefix structure. */ |
| 4094 | ret = str2prefix (prefix_str, &p); |
| 4095 | if (!ret) |
| 4096 | { |
| 4097 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4098 | return CMD_WARNING; |
| 4099 | } |
| 4100 | apply_mask (&p); |
| 4101 | |
| 4102 | /* Get BGP structure. */ |
| 4103 | bgp = vty->index; |
| 4104 | |
| 4105 | /* Old configuration check. */ |
| 4106 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4107 | if (! rn) |
| 4108 | { |
| 4109 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4110 | VTY_NEWLINE); |
| 4111 | return CMD_WARNING; |
| 4112 | } |
| 4113 | |
| 4114 | aggregate = rn->info; |
| 4115 | if (aggregate->safi & SAFI_UNICAST) |
| 4116 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4117 | if (aggregate->safi & SAFI_MULTICAST) |
| 4118 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4119 | |
| 4120 | /* Unlock aggregate address configuration. */ |
| 4121 | rn->info = NULL; |
| 4122 | bgp_aggregate_free (aggregate); |
| 4123 | bgp_unlock_node (rn); |
| 4124 | bgp_unlock_node (rn); |
| 4125 | |
| 4126 | return CMD_SUCCESS; |
| 4127 | } |
| 4128 | |
| 4129 | DEFUN (aggregate_address, |
| 4130 | aggregate_address_cmd, |
| 4131 | "aggregate-address A.B.C.D/M", |
| 4132 | "Configure BGP aggregate entries\n" |
| 4133 | "Aggregate prefix\n") |
| 4134 | { |
| 4135 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 4136 | } |
| 4137 | |
| 4138 | DEFUN (aggregate_address_mask, |
| 4139 | aggregate_address_mask_cmd, |
| 4140 | "aggregate-address A.B.C.D A.B.C.D", |
| 4141 | "Configure BGP aggregate entries\n" |
| 4142 | "Aggregate address\n" |
| 4143 | "Aggregate mask\n") |
| 4144 | { |
| 4145 | int ret; |
| 4146 | char prefix_str[BUFSIZ]; |
| 4147 | |
| 4148 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4149 | |
| 4150 | if (! ret) |
| 4151 | { |
| 4152 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4153 | return CMD_WARNING; |
| 4154 | } |
| 4155 | |
| 4156 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4157 | 0, 0); |
| 4158 | } |
| 4159 | |
| 4160 | DEFUN (aggregate_address_summary_only, |
| 4161 | aggregate_address_summary_only_cmd, |
| 4162 | "aggregate-address A.B.C.D/M summary-only", |
| 4163 | "Configure BGP aggregate entries\n" |
| 4164 | "Aggregate prefix\n" |
| 4165 | "Filter more specific routes from updates\n") |
| 4166 | { |
| 4167 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4168 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4169 | } |
| 4170 | |
| 4171 | DEFUN (aggregate_address_mask_summary_only, |
| 4172 | aggregate_address_mask_summary_only_cmd, |
| 4173 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4174 | "Configure BGP aggregate entries\n" |
| 4175 | "Aggregate address\n" |
| 4176 | "Aggregate mask\n" |
| 4177 | "Filter more specific routes from updates\n") |
| 4178 | { |
| 4179 | int ret; |
| 4180 | char prefix_str[BUFSIZ]; |
| 4181 | |
| 4182 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4183 | |
| 4184 | if (! ret) |
| 4185 | { |
| 4186 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4187 | return CMD_WARNING; |
| 4188 | } |
| 4189 | |
| 4190 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4191 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4192 | } |
| 4193 | |
| 4194 | DEFUN (aggregate_address_as_set, |
| 4195 | aggregate_address_as_set_cmd, |
| 4196 | "aggregate-address A.B.C.D/M as-set", |
| 4197 | "Configure BGP aggregate entries\n" |
| 4198 | "Aggregate prefix\n" |
| 4199 | "Generate AS set path information\n") |
| 4200 | { |
| 4201 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4202 | 0, AGGREGATE_AS_SET); |
| 4203 | } |
| 4204 | |
| 4205 | DEFUN (aggregate_address_mask_as_set, |
| 4206 | aggregate_address_mask_as_set_cmd, |
| 4207 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 4208 | "Configure BGP aggregate entries\n" |
| 4209 | "Aggregate address\n" |
| 4210 | "Aggregate mask\n" |
| 4211 | "Generate AS set path information\n") |
| 4212 | { |
| 4213 | int ret; |
| 4214 | char prefix_str[BUFSIZ]; |
| 4215 | |
| 4216 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4217 | |
| 4218 | if (! ret) |
| 4219 | { |
| 4220 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4221 | return CMD_WARNING; |
| 4222 | } |
| 4223 | |
| 4224 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4225 | 0, AGGREGATE_AS_SET); |
| 4226 | } |
| 4227 | |
| 4228 | |
| 4229 | DEFUN (aggregate_address_as_set_summary, |
| 4230 | aggregate_address_as_set_summary_cmd, |
| 4231 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 4232 | "Configure BGP aggregate entries\n" |
| 4233 | "Aggregate prefix\n" |
| 4234 | "Generate AS set path information\n" |
| 4235 | "Filter more specific routes from updates\n") |
| 4236 | { |
| 4237 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4238 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4239 | } |
| 4240 | |
| 4241 | ALIAS (aggregate_address_as_set_summary, |
| 4242 | aggregate_address_summary_as_set_cmd, |
| 4243 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 4244 | "Configure BGP aggregate entries\n" |
| 4245 | "Aggregate prefix\n" |
| 4246 | "Filter more specific routes from updates\n" |
| 4247 | "Generate AS set path information\n") |
| 4248 | |
| 4249 | DEFUN (aggregate_address_mask_as_set_summary, |
| 4250 | aggregate_address_mask_as_set_summary_cmd, |
| 4251 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4252 | "Configure BGP aggregate entries\n" |
| 4253 | "Aggregate address\n" |
| 4254 | "Aggregate mask\n" |
| 4255 | "Generate AS set path information\n" |
| 4256 | "Filter more specific routes from updates\n") |
| 4257 | { |
| 4258 | int ret; |
| 4259 | char prefix_str[BUFSIZ]; |
| 4260 | |
| 4261 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4262 | |
| 4263 | if (! ret) |
| 4264 | { |
| 4265 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4266 | return CMD_WARNING; |
| 4267 | } |
| 4268 | |
| 4269 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4270 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4271 | } |
| 4272 | |
| 4273 | ALIAS (aggregate_address_mask_as_set_summary, |
| 4274 | aggregate_address_mask_summary_as_set_cmd, |
| 4275 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4276 | "Configure BGP aggregate entries\n" |
| 4277 | "Aggregate address\n" |
| 4278 | "Aggregate mask\n" |
| 4279 | "Filter more specific routes from updates\n" |
| 4280 | "Generate AS set path information\n") |
| 4281 | |
| 4282 | DEFUN (no_aggregate_address, |
| 4283 | no_aggregate_address_cmd, |
| 4284 | "no aggregate-address A.B.C.D/M", |
| 4285 | NO_STR |
| 4286 | "Configure BGP aggregate entries\n" |
| 4287 | "Aggregate prefix\n") |
| 4288 | { |
| 4289 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 4290 | } |
| 4291 | |
| 4292 | ALIAS (no_aggregate_address, |
| 4293 | no_aggregate_address_summary_only_cmd, |
| 4294 | "no aggregate-address A.B.C.D/M summary-only", |
| 4295 | NO_STR |
| 4296 | "Configure BGP aggregate entries\n" |
| 4297 | "Aggregate prefix\n" |
| 4298 | "Filter more specific routes from updates\n") |
| 4299 | |
| 4300 | ALIAS (no_aggregate_address, |
| 4301 | no_aggregate_address_as_set_cmd, |
| 4302 | "no aggregate-address A.B.C.D/M as-set", |
| 4303 | NO_STR |
| 4304 | "Configure BGP aggregate entries\n" |
| 4305 | "Aggregate prefix\n" |
| 4306 | "Generate AS set path information\n") |
| 4307 | |
| 4308 | ALIAS (no_aggregate_address, |
| 4309 | no_aggregate_address_as_set_summary_cmd, |
| 4310 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 4311 | NO_STR |
| 4312 | "Configure BGP aggregate entries\n" |
| 4313 | "Aggregate prefix\n" |
| 4314 | "Generate AS set path information\n" |
| 4315 | "Filter more specific routes from updates\n") |
| 4316 | |
| 4317 | ALIAS (no_aggregate_address, |
| 4318 | no_aggregate_address_summary_as_set_cmd, |
| 4319 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 4320 | NO_STR |
| 4321 | "Configure BGP aggregate entries\n" |
| 4322 | "Aggregate prefix\n" |
| 4323 | "Filter more specific routes from updates\n" |
| 4324 | "Generate AS set path information\n") |
| 4325 | |
| 4326 | DEFUN (no_aggregate_address_mask, |
| 4327 | no_aggregate_address_mask_cmd, |
| 4328 | "no aggregate-address A.B.C.D A.B.C.D", |
| 4329 | NO_STR |
| 4330 | "Configure BGP aggregate entries\n" |
| 4331 | "Aggregate address\n" |
| 4332 | "Aggregate mask\n") |
| 4333 | { |
| 4334 | int ret; |
| 4335 | char prefix_str[BUFSIZ]; |
| 4336 | |
| 4337 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4338 | |
| 4339 | if (! ret) |
| 4340 | { |
| 4341 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4342 | return CMD_WARNING; |
| 4343 | } |
| 4344 | |
| 4345 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 4346 | } |
| 4347 | |
| 4348 | ALIAS (no_aggregate_address_mask, |
| 4349 | no_aggregate_address_mask_summary_only_cmd, |
| 4350 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4351 | NO_STR |
| 4352 | "Configure BGP aggregate entries\n" |
| 4353 | "Aggregate address\n" |
| 4354 | "Aggregate mask\n" |
| 4355 | "Filter more specific routes from updates\n") |
| 4356 | |
| 4357 | ALIAS (no_aggregate_address_mask, |
| 4358 | no_aggregate_address_mask_as_set_cmd, |
| 4359 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 4360 | NO_STR |
| 4361 | "Configure BGP aggregate entries\n" |
| 4362 | "Aggregate address\n" |
| 4363 | "Aggregate mask\n" |
| 4364 | "Generate AS set path information\n") |
| 4365 | |
| 4366 | ALIAS (no_aggregate_address_mask, |
| 4367 | no_aggregate_address_mask_as_set_summary_cmd, |
| 4368 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4369 | NO_STR |
| 4370 | "Configure BGP aggregate entries\n" |
| 4371 | "Aggregate address\n" |
| 4372 | "Aggregate mask\n" |
| 4373 | "Generate AS set path information\n" |
| 4374 | "Filter more specific routes from updates\n") |
| 4375 | |
| 4376 | ALIAS (no_aggregate_address_mask, |
| 4377 | no_aggregate_address_mask_summary_as_set_cmd, |
| 4378 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4379 | NO_STR |
| 4380 | "Configure BGP aggregate entries\n" |
| 4381 | "Aggregate address\n" |
| 4382 | "Aggregate mask\n" |
| 4383 | "Filter more specific routes from updates\n" |
| 4384 | "Generate AS set path information\n") |
| 4385 | |
| 4386 | #ifdef HAVE_IPV6 |
| 4387 | DEFUN (ipv6_aggregate_address, |
| 4388 | ipv6_aggregate_address_cmd, |
| 4389 | "aggregate-address X:X::X:X/M", |
| 4390 | "Configure BGP aggregate entries\n" |
| 4391 | "Aggregate prefix\n") |
| 4392 | { |
| 4393 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 4394 | } |
| 4395 | |
| 4396 | DEFUN (ipv6_aggregate_address_summary_only, |
| 4397 | ipv6_aggregate_address_summary_only_cmd, |
| 4398 | "aggregate-address X:X::X:X/M summary-only", |
| 4399 | "Configure BGP aggregate entries\n" |
| 4400 | "Aggregate prefix\n" |
| 4401 | "Filter more specific routes from updates\n") |
| 4402 | { |
| 4403 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 4404 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4405 | } |
| 4406 | |
| 4407 | DEFUN (no_ipv6_aggregate_address, |
| 4408 | no_ipv6_aggregate_address_cmd, |
| 4409 | "no aggregate-address X:X::X:X/M", |
| 4410 | NO_STR |
| 4411 | "Configure BGP aggregate entries\n" |
| 4412 | "Aggregate prefix\n") |
| 4413 | { |
| 4414 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4415 | } |
| 4416 | |
| 4417 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 4418 | no_ipv6_aggregate_address_summary_only_cmd, |
| 4419 | "no aggregate-address X:X::X:X/M summary-only", |
| 4420 | NO_STR |
| 4421 | "Configure BGP aggregate entries\n" |
| 4422 | "Aggregate prefix\n" |
| 4423 | "Filter more specific routes from updates\n") |
| 4424 | { |
| 4425 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4426 | } |
| 4427 | |
| 4428 | ALIAS (ipv6_aggregate_address, |
| 4429 | old_ipv6_aggregate_address_cmd, |
| 4430 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 4431 | IPV6_STR |
| 4432 | BGP_STR |
| 4433 | "Configure BGP aggregate entries\n" |
| 4434 | "Aggregate prefix\n") |
| 4435 | |
| 4436 | ALIAS (ipv6_aggregate_address_summary_only, |
| 4437 | old_ipv6_aggregate_address_summary_only_cmd, |
| 4438 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4439 | IPV6_STR |
| 4440 | BGP_STR |
| 4441 | "Configure BGP aggregate entries\n" |
| 4442 | "Aggregate prefix\n" |
| 4443 | "Filter more specific routes from updates\n") |
| 4444 | |
| 4445 | ALIAS (no_ipv6_aggregate_address, |
| 4446 | old_no_ipv6_aggregate_address_cmd, |
| 4447 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 4448 | NO_STR |
| 4449 | IPV6_STR |
| 4450 | BGP_STR |
| 4451 | "Configure BGP aggregate entries\n" |
| 4452 | "Aggregate prefix\n") |
| 4453 | |
| 4454 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 4455 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 4456 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4457 | NO_STR |
| 4458 | IPV6_STR |
| 4459 | BGP_STR |
| 4460 | "Configure BGP aggregate entries\n" |
| 4461 | "Aggregate prefix\n" |
| 4462 | "Filter more specific routes from updates\n") |
| 4463 | #endif /* HAVE_IPV6 */ |
| 4464 | |
| 4465 | /* Redistribute route treatment. */ |
| 4466 | void |
| 4467 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, |
| 4468 | u_int32_t metric, u_char type) |
| 4469 | { |
| 4470 | struct bgp *bgp; |
| 4471 | struct listnode *nn; |
| 4472 | struct bgp_info *new; |
| 4473 | struct bgp_info *bi; |
| 4474 | struct bgp_info info; |
| 4475 | struct bgp_node *bn; |
| 4476 | struct attr attr; |
| 4477 | struct attr attr_new; |
| 4478 | struct attr *new_attr; |
| 4479 | afi_t afi; |
| 4480 | int ret; |
| 4481 | |
| 4482 | /* Make default attribute. */ |
| 4483 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 4484 | if (nexthop) |
| 4485 | attr.nexthop = *nexthop; |
| 4486 | |
| 4487 | attr.med = metric; |
| 4488 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 4489 | |
| 4490 | LIST_LOOP (bm->bgp, bgp, nn) |
| 4491 | { |
| 4492 | afi = family2afi (p->family); |
| 4493 | |
| 4494 | if (bgp->redist[afi][type]) |
| 4495 | { |
| 4496 | /* Copy attribute for modification. */ |
| 4497 | attr_new = attr; |
| 4498 | |
| 4499 | if (bgp->redist_metric_flag[afi][type]) |
| 4500 | attr_new.med = bgp->redist_metric[afi][type]; |
| 4501 | |
| 4502 | /* Apply route-map. */ |
| 4503 | if (bgp->rmap[afi][type].map) |
| 4504 | { |
| 4505 | info.peer = bgp->peer_self; |
| 4506 | info.attr = &attr_new; |
| 4507 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4508 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 4509 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4510 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 4511 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4512 | |
| 4513 | bgp->peer_self->rmap_type = 0; |
| 4514 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4515 | if (ret == RMAP_DENYMATCH) |
| 4516 | { |
| 4517 | /* Free uninterned attribute. */ |
| 4518 | bgp_attr_flush (&attr_new); |
| 4519 | |
| 4520 | /* Unintern original. */ |
| 4521 | aspath_unintern (attr.aspath); |
| 4522 | bgp_redistribute_delete (p, type); |
| 4523 | return; |
| 4524 | } |
| 4525 | } |
| 4526 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4527 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4528 | new_attr = bgp_attr_intern (&attr_new); |
| 4529 | |
| 4530 | for (bi = bn->info; bi; bi = bi->next) |
| 4531 | if (bi->peer == bgp->peer_self |
| 4532 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 4533 | break; |
| 4534 | |
| 4535 | if (bi) |
| 4536 | { |
| 4537 | if (attrhash_cmp (bi->attr, new_attr)) |
| 4538 | { |
| 4539 | bgp_attr_unintern (new_attr); |
| 4540 | aspath_unintern (attr.aspath); |
| 4541 | bgp_unlock_node (bn); |
| 4542 | return; |
| 4543 | } |
| 4544 | else |
| 4545 | { |
| 4546 | /* The attribute is changed. */ |
| 4547 | SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED); |
| 4548 | |
| 4549 | /* Rewrite BGP route information. */ |
| 4550 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
| 4551 | bgp_attr_unintern (bi->attr); |
| 4552 | bi->attr = new_attr; |
| 4553 | bi->uptime = time (NULL); |
| 4554 | |
| 4555 | /* Process change. */ |
| 4556 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 4557 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4558 | bgp_unlock_node (bn); |
| 4559 | aspath_unintern (attr.aspath); |
| 4560 | return; |
| 4561 | } |
| 4562 | } |
| 4563 | |
| 4564 | new = bgp_info_new (); |
| 4565 | new->type = type; |
| 4566 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 4567 | new->peer = bgp->peer_self; |
| 4568 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4569 | new->attr = new_attr; |
| 4570 | new->uptime = time (NULL); |
| 4571 | |
| 4572 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 4573 | bgp_info_add (bn, new); |
| 4574 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4575 | } |
| 4576 | } |
| 4577 | |
| 4578 | /* Unintern original. */ |
| 4579 | aspath_unintern (attr.aspath); |
| 4580 | } |
| 4581 | |
| 4582 | void |
| 4583 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 4584 | { |
| 4585 | struct bgp *bgp; |
| 4586 | struct listnode *nn; |
| 4587 | afi_t afi; |
| 4588 | struct bgp_node *rn; |
| 4589 | struct bgp_info *ri; |
| 4590 | |
| 4591 | LIST_LOOP (bm->bgp, bgp, nn) |
| 4592 | { |
| 4593 | afi = family2afi (p->family); |
| 4594 | |
| 4595 | if (bgp->redist[afi][type]) |
| 4596 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4597 | rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4598 | |
| 4599 | for (ri = rn->info; ri; ri = ri->next) |
| 4600 | if (ri->peer == bgp->peer_self |
| 4601 | && ri->type == type) |
| 4602 | break; |
| 4603 | |
| 4604 | if (ri) |
| 4605 | { |
| 4606 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
| 4607 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4608 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4609 | bgp_info_delete (rn, ri); |
| 4610 | bgp_info_free (ri); |
| 4611 | bgp_unlock_node (rn); |
| 4612 | } |
| 4613 | bgp_unlock_node (rn); |
| 4614 | } |
| 4615 | } |
| 4616 | } |
| 4617 | |
| 4618 | /* Withdraw specified route type's route. */ |
| 4619 | void |
| 4620 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 4621 | { |
| 4622 | struct bgp_node *rn; |
| 4623 | struct bgp_info *ri; |
| 4624 | struct bgp_table *table; |
| 4625 | |
| 4626 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 4627 | |
| 4628 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 4629 | { |
| 4630 | for (ri = rn->info; ri; ri = ri->next) |
| 4631 | if (ri->peer == bgp->peer_self |
| 4632 | && ri->type == type) |
| 4633 | break; |
| 4634 | |
| 4635 | if (ri) |
| 4636 | { |
| 4637 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
| 4638 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4639 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4640 | bgp_info_delete (rn, ri); |
| 4641 | bgp_info_free (ri); |
| 4642 | bgp_unlock_node (rn); |
| 4643 | } |
| 4644 | } |
| 4645 | } |
| 4646 | |
| 4647 | /* Static function to display route. */ |
| 4648 | void |
| 4649 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 4650 | { |
| 4651 | int len; |
| 4652 | u_int32_t destination; |
| 4653 | char buf[BUFSIZ]; |
| 4654 | |
| 4655 | if (p->family == AF_INET) |
| 4656 | { |
| 4657 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 4658 | destination = ntohl (p->u.prefix4.s_addr); |
| 4659 | |
| 4660 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 4661 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 4662 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 4663 | || p->u.prefix4.s_addr == 0) |
| 4664 | { |
| 4665 | /* When mask is natural, mask is not displayed. */ |
| 4666 | } |
| 4667 | else |
| 4668 | len += vty_out (vty, "/%d", p->prefixlen); |
| 4669 | } |
| 4670 | else |
| 4671 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 4672 | p->prefixlen); |
| 4673 | |
| 4674 | len = 17 - len; |
| 4675 | if (len < 1) |
| 4676 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 4677 | else |
| 4678 | vty_out (vty, "%*s", len, " "); |
| 4679 | } |
| 4680 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4681 | enum bgp_display_type |
| 4682 | { |
| 4683 | normal_list, |
| 4684 | }; |
| 4685 | |
| 4686 | /* called from terminal list command */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4687 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4688 | route_vty_out (struct vty *vty, struct prefix *p, |
| 4689 | struct bgp_info *binfo, int display, safi_t safi) |
| 4690 | { |
| 4691 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4692 | |
| 4693 | /* Route status display. */ |
| 4694 | if (binfo->suppress) |
| 4695 | vty_out (vty, "s"); |
| 4696 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4697 | vty_out (vty, "*"); |
| 4698 | else |
| 4699 | vty_out (vty, " "); |
| 4700 | |
| 4701 | /* Selected */ |
| 4702 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4703 | vty_out (vty, "h"); |
| 4704 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4705 | vty_out (vty, "d"); |
| 4706 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4707 | vty_out (vty, ">"); |
| 4708 | else |
| 4709 | vty_out (vty, " "); |
| 4710 | |
| 4711 | /* Internal route. */ |
| 4712 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 4713 | vty_out (vty, "i"); |
| 4714 | else |
| 4715 | vty_out (vty, " "); |
| 4716 | |
| 4717 | /* print prefix and mask */ |
| 4718 | if (! display) |
| 4719 | route_vty_out_route (p, vty); |
| 4720 | else |
| 4721 | vty_out (vty, "%*s", 17, " "); |
| 4722 | |
| 4723 | /* Print attribute */ |
| 4724 | attr = binfo->attr; |
| 4725 | if (attr) |
| 4726 | { |
| 4727 | if (p->family == AF_INET) |
| 4728 | { |
| 4729 | if (safi == SAFI_MPLS_VPN) |
| 4730 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4731 | else |
| 4732 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4733 | } |
| 4734 | #ifdef HAVE_IPV6 |
| 4735 | else if (p->family == AF_INET6) |
| 4736 | { |
| 4737 | int len; |
| 4738 | char buf[BUFSIZ]; |
| 4739 | |
| 4740 | len = vty_out (vty, "%s", |
| 4741 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 4742 | len = 16 - len; |
| 4743 | if (len < 1) |
| 4744 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 4745 | else |
| 4746 | vty_out (vty, "%*s", len, " "); |
| 4747 | } |
| 4748 | #endif /* HAVE_IPV6 */ |
| 4749 | |
| 4750 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 4751 | vty_out (vty, "%10d", attr->med); |
| 4752 | else |
| 4753 | vty_out (vty, " "); |
| 4754 | |
| 4755 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 4756 | vty_out (vty, "%7d", attr->local_pref); |
| 4757 | else |
| 4758 | vty_out (vty, " "); |
| 4759 | |
| 4760 | vty_out (vty, "%7u ",attr->weight); |
| 4761 | |
| 4762 | /* Print aspath */ |
| 4763 | if (attr->aspath) |
| 4764 | aspath_print_vty (vty, attr->aspath); |
| 4765 | |
| 4766 | /* Print origin */ |
| 4767 | if (strlen (attr->aspath->str) == 0) |
| 4768 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4769 | else |
| 4770 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4771 | } |
| 4772 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4773 | } |
| 4774 | |
| 4775 | /* called from terminal list command */ |
| 4776 | void |
| 4777 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 4778 | struct attr *attr, safi_t safi) |
| 4779 | { |
| 4780 | /* Route status display. */ |
| 4781 | vty_out (vty, "*"); |
| 4782 | vty_out (vty, ">"); |
| 4783 | vty_out (vty, " "); |
| 4784 | |
| 4785 | /* print prefix and mask */ |
| 4786 | route_vty_out_route (p, vty); |
| 4787 | |
| 4788 | /* Print attribute */ |
| 4789 | if (attr) |
| 4790 | { |
| 4791 | if (p->family == AF_INET) |
| 4792 | { |
| 4793 | if (safi == SAFI_MPLS_VPN) |
| 4794 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4795 | else |
| 4796 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4797 | } |
| 4798 | #ifdef HAVE_IPV6 |
| 4799 | else if (p->family == AF_INET6) |
| 4800 | { |
| 4801 | int len; |
| 4802 | char buf[BUFSIZ]; |
| 4803 | |
| 4804 | len = vty_out (vty, "%s", |
| 4805 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 4806 | len = 16 - len; |
| 4807 | if (len < 1) |
| 4808 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 4809 | else |
| 4810 | vty_out (vty, "%*s", len, " "); |
| 4811 | } |
| 4812 | #endif /* HAVE_IPV6 */ |
| 4813 | |
| 4814 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 4815 | vty_out (vty, "%10d", attr->med); |
| 4816 | else |
| 4817 | vty_out (vty, " "); |
| 4818 | |
| 4819 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 4820 | vty_out (vty, "%7d", attr->local_pref); |
| 4821 | else |
| 4822 | vty_out (vty, " "); |
| 4823 | |
| 4824 | vty_out (vty, "%7d ",attr->weight); |
| 4825 | |
| 4826 | /* Print aspath */ |
| 4827 | if (attr->aspath) |
| 4828 | aspath_print_vty (vty, attr->aspath); |
| 4829 | |
| 4830 | /* Print origin */ |
| 4831 | if (strlen (attr->aspath->str) == 0) |
| 4832 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4833 | else |
| 4834 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4835 | } |
| 4836 | |
| 4837 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4838 | } |
| 4839 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4840 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4841 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 4842 | struct bgp_info *binfo, int display, safi_t safi) |
| 4843 | { |
| 4844 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4845 | u_int32_t label = 0; |
| 4846 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4847 | /* Route status display. */ |
| 4848 | if (binfo->suppress) |
| 4849 | vty_out (vty, "s"); |
| 4850 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4851 | vty_out (vty, "*"); |
| 4852 | else |
| 4853 | vty_out (vty, " "); |
| 4854 | |
| 4855 | /* Selected */ |
| 4856 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4857 | vty_out (vty, "h"); |
| 4858 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4859 | vty_out (vty, "d"); |
| 4860 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4861 | vty_out (vty, ">"); |
| 4862 | else |
| 4863 | vty_out (vty, " "); |
| 4864 | |
| 4865 | /* Internal route. */ |
| 4866 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 4867 | vty_out (vty, "i"); |
| 4868 | else |
| 4869 | vty_out (vty, " "); |
| 4870 | |
| 4871 | /* print prefix and mask */ |
| 4872 | if (! display) |
| 4873 | route_vty_out_route (p, vty); |
| 4874 | else |
| 4875 | vty_out (vty, "%*s", 17, " "); |
| 4876 | |
| 4877 | /* Print attribute */ |
| 4878 | attr = binfo->attr; |
| 4879 | if (attr) |
| 4880 | { |
| 4881 | if (p->family == AF_INET) |
| 4882 | { |
| 4883 | if (safi == SAFI_MPLS_VPN) |
| 4884 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4885 | else |
| 4886 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4887 | } |
| 4888 | #ifdef HAVE_IPV6 |
| 4889 | else if (p->family == AF_INET6) |
| 4890 | { |
| 4891 | char buf[BUFSIZ]; |
| 4892 | char buf1[BUFSIZ]; |
| 4893 | if (attr->mp_nexthop_len == 16) |
| 4894 | vty_out (vty, "%s", |
| 4895 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 4896 | else if (attr->mp_nexthop_len == 32) |
| 4897 | vty_out (vty, "%s(%s)", |
| 4898 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ), |
| 4899 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ)); |
| 4900 | |
| 4901 | } |
| 4902 | #endif /* HAVE_IPV6 */ |
| 4903 | } |
| 4904 | |
| 4905 | label = decode_label (binfo->tag); |
| 4906 | |
| 4907 | vty_out (vty, "notag/%d", label); |
| 4908 | |
| 4909 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4910 | } |
| 4911 | |
| 4912 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4913 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4914 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 4915 | struct bgp_info *binfo, int display, safi_t safi) |
| 4916 | { |
| 4917 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4918 | int len; |
| 4919 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4920 | /* Route status display. */ |
| 4921 | if (binfo->suppress) |
| 4922 | vty_out (vty, "s"); |
| 4923 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4924 | vty_out (vty, "*"); |
| 4925 | else |
| 4926 | vty_out (vty, " "); |
| 4927 | |
| 4928 | /* Selected */ |
| 4929 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4930 | vty_out (vty, "h"); |
| 4931 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4932 | vty_out (vty, "d"); |
| 4933 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4934 | vty_out (vty, ">"); |
| 4935 | else |
| 4936 | vty_out (vty, " "); |
| 4937 | |
| 4938 | vty_out (vty, " "); |
| 4939 | |
| 4940 | /* print prefix and mask */ |
| 4941 | if (! display) |
| 4942 | route_vty_out_route (p, vty); |
| 4943 | else |
| 4944 | vty_out (vty, "%*s", 17, " "); |
| 4945 | |
| 4946 | len = vty_out (vty, "%s", binfo->peer->host); |
| 4947 | len = 17 - len; |
| 4948 | if (len < 1) |
| 4949 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 4950 | else |
| 4951 | vty_out (vty, "%*s", len, " "); |
| 4952 | |
| 4953 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 4954 | |
| 4955 | /* Print attribute */ |
| 4956 | attr = binfo->attr; |
| 4957 | if (attr) |
| 4958 | { |
| 4959 | /* Print aspath */ |
| 4960 | if (attr->aspath) |
| 4961 | aspath_print_vty (vty, attr->aspath); |
| 4962 | |
| 4963 | /* Print origin */ |
| 4964 | if (strlen (attr->aspath->str) == 0) |
| 4965 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4966 | else |
| 4967 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4968 | } |
| 4969 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4970 | } |
| 4971 | |
| 4972 | #define BGP_UPTIME_LEN 25 |
| 4973 | |
| 4974 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4975 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4976 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 4977 | struct bgp_info *binfo, int display, safi_t safi) |
| 4978 | { |
| 4979 | struct attr *attr; |
| 4980 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4981 | char timebuf[BGP_UPTIME_LEN]; |
| 4982 | int len; |
| 4983 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4984 | bdi = binfo->damp_info; |
| 4985 | |
| 4986 | /* Route status display. */ |
| 4987 | if (binfo->suppress) |
| 4988 | vty_out (vty, "s"); |
| 4989 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4990 | vty_out (vty, "*"); |
| 4991 | else |
| 4992 | vty_out (vty, " "); |
| 4993 | |
| 4994 | /* Selected */ |
| 4995 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4996 | vty_out (vty, "h"); |
| 4997 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4998 | vty_out (vty, "d"); |
| 4999 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5000 | vty_out (vty, ">"); |
| 5001 | else |
| 5002 | vty_out (vty, " "); |
| 5003 | |
| 5004 | vty_out (vty, " "); |
| 5005 | |
| 5006 | /* print prefix and mask */ |
| 5007 | if (! display) |
| 5008 | route_vty_out_route (p, vty); |
| 5009 | else |
| 5010 | vty_out (vty, "%*s", 17, " "); |
| 5011 | |
| 5012 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5013 | len = 16 - len; |
| 5014 | if (len < 1) |
| 5015 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5016 | else |
| 5017 | vty_out (vty, "%*s", len, " "); |
| 5018 | |
| 5019 | len = vty_out (vty, "%d", bdi->flap); |
| 5020 | len = 5 - len; |
| 5021 | if (len < 1) |
| 5022 | vty_out (vty, " "); |
| 5023 | else |
| 5024 | vty_out (vty, "%*s ", len, " "); |
| 5025 | |
| 5026 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5027 | timebuf, BGP_UPTIME_LEN)); |
| 5028 | |
| 5029 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5030 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5031 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5032 | else |
| 5033 | vty_out (vty, "%*s ", 8, " "); |
| 5034 | |
| 5035 | /* Print attribute */ |
| 5036 | attr = binfo->attr; |
| 5037 | if (attr) |
| 5038 | { |
| 5039 | /* Print aspath */ |
| 5040 | if (attr->aspath) |
| 5041 | aspath_print_vty (vty, attr->aspath); |
| 5042 | |
| 5043 | /* Print origin */ |
| 5044 | if (strlen (attr->aspath->str) == 0) |
| 5045 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5046 | else |
| 5047 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5048 | } |
| 5049 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5050 | } |
| 5051 | |
| 5052 | void |
| 5053 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5054 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5055 | { |
| 5056 | char buf[INET6_ADDRSTRLEN]; |
| 5057 | char buf1[BUFSIZ]; |
| 5058 | struct attr *attr; |
| 5059 | int sockunion_vty_out (struct vty *, union sockunion *); |
| 5060 | |
| 5061 | attr = binfo->attr; |
| 5062 | |
| 5063 | if (attr) |
| 5064 | { |
| 5065 | /* Line1 display AS-path, Aggregator */ |
| 5066 | if (attr->aspath) |
| 5067 | { |
| 5068 | vty_out (vty, " "); |
| 5069 | if (attr->aspath->length == 0) |
| 5070 | vty_out (vty, "Local"); |
| 5071 | else |
| 5072 | aspath_print_vty (vty, attr->aspath); |
| 5073 | } |
| 5074 | |
| 5075 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR) |
| 5076 | || CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT) |
| 5077 | || CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 5078 | || CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY) |
| 5079 | || CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5080 | { |
| 5081 | vty_out (vty, ","); |
| 5082 | |
| 5083 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)) |
| 5084 | vty_out (vty, " (aggregated by %d %s)", attr->aggregator_as, |
| 5085 | inet_ntoa (attr->aggregator_addr)); |
| 5086 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5087 | vty_out (vty, " (Received from a RR-client)"); |
| 5088 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5089 | vty_out (vty, " (Received from a RS-client)"); |
| 5090 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5091 | vty_out (vty, " (history entry)"); |
| 5092 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5093 | vty_out (vty, " (suppressed due to dampening)"); |
| 5094 | } |
| 5095 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5096 | |
| 5097 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5098 | if (p->family == AF_INET) |
| 5099 | { |
| 5100 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
| 5101 | inet_ntoa (attr->mp_nexthop_global_in) : |
| 5102 | inet_ntoa (attr->nexthop)); |
| 5103 | } |
| 5104 | #ifdef HAVE_IPV6 |
| 5105 | else |
| 5106 | { |
| 5107 | vty_out (vty, " %s", |
| 5108 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, |
| 5109 | buf, INET6_ADDRSTRLEN)); |
| 5110 | } |
| 5111 | #endif /* HAVE_IPV6 */ |
| 5112 | |
| 5113 | if (binfo->peer == bgp->peer_self) |
| 5114 | { |
| 5115 | vty_out (vty, " from %s ", |
| 5116 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5117 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5118 | } |
| 5119 | else |
| 5120 | { |
| 5121 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5122 | vty_out (vty, " (inaccessible)"); |
| 5123 | else if (binfo->igpmetric) |
| 5124 | vty_out (vty, " (metric %d)", binfo->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5125 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5126 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5127 | vty_out (vty, " (%s)", inet_ntoa (attr->originator_id)); |
| 5128 | else |
| 5129 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5130 | } |
| 5131 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5132 | |
| 5133 | #ifdef HAVE_IPV6 |
| 5134 | /* display nexthop local */ |
| 5135 | if (attr->mp_nexthop_len == 32) |
| 5136 | { |
| 5137 | vty_out (vty, " (%s)%s", |
| 5138 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, |
| 5139 | buf, INET6_ADDRSTRLEN), |
| 5140 | VTY_NEWLINE); |
| 5141 | } |
| 5142 | #endif /* HAVE_IPV6 */ |
| 5143 | |
| 5144 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5145 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5146 | |
| 5147 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
| 5148 | vty_out (vty, ", metric %d", attr->med); |
| 5149 | |
| 5150 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
| 5151 | vty_out (vty, ", localpref %d", attr->local_pref); |
| 5152 | else |
| 5153 | vty_out (vty, ", localpref %d", bgp->default_local_pref); |
| 5154 | |
| 5155 | if (attr->weight != 0) |
| 5156 | vty_out (vty, ", weight %d", attr->weight); |
| 5157 | |
| 5158 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5159 | vty_out (vty, ", valid"); |
| 5160 | |
| 5161 | if (binfo->peer != bgp->peer_self) |
| 5162 | { |
| 5163 | if (binfo->peer->as == binfo->peer->local_as) |
| 5164 | vty_out (vty, ", internal"); |
| 5165 | else |
| 5166 | vty_out (vty, ", %s", |
| 5167 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 5168 | } |
| 5169 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 5170 | vty_out (vty, ", aggregated, local"); |
| 5171 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 5172 | vty_out (vty, ", sourced"); |
| 5173 | else |
| 5174 | vty_out (vty, ", sourced, local"); |
| 5175 | |
| 5176 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5177 | vty_out (vty, ", atomic-aggregate"); |
| 5178 | |
| 5179 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5180 | vty_out (vty, ", best"); |
| 5181 | |
| 5182 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5183 | |
| 5184 | /* Line 4 display Community */ |
| 5185 | if (attr->community) |
| 5186 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 5187 | VTY_NEWLINE); |
| 5188 | |
| 5189 | /* Line 5 display Extended-community */ |
| 5190 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
| 5191 | vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str, |
| 5192 | VTY_NEWLINE); |
| 5193 | |
| 5194 | /* Line 6 display Originator, Cluster-id */ |
| 5195 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 5196 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 5197 | { |
| 5198 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5199 | vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id)); |
| 5200 | |
| 5201 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 5202 | { |
| 5203 | int i; |
| 5204 | vty_out (vty, ", Cluster list: "); |
| 5205 | for (i = 0; i < attr->cluster->length / 4; i++) |
| 5206 | vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i])); |
| 5207 | } |
| 5208 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5209 | } |
| 5210 | |
| 5211 | if (binfo->damp_info) |
| 5212 | bgp_damp_info_vty (vty, binfo); |
| 5213 | |
| 5214 | /* Line 7 display Uptime */ |
| 5215 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); |
| 5216 | } |
| 5217 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5218 | } |
| 5219 | |
| 5220 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 5221 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 5222 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 5223 | |
| 5224 | enum bgp_show_type |
| 5225 | { |
| 5226 | bgp_show_type_normal, |
| 5227 | bgp_show_type_regexp, |
| 5228 | bgp_show_type_prefix_list, |
| 5229 | bgp_show_type_filter_list, |
| 5230 | bgp_show_type_route_map, |
| 5231 | bgp_show_type_neighbor, |
| 5232 | bgp_show_type_cidr_only, |
| 5233 | bgp_show_type_prefix_longer, |
| 5234 | bgp_show_type_community_all, |
| 5235 | bgp_show_type_community, |
| 5236 | bgp_show_type_community_exact, |
| 5237 | bgp_show_type_community_list, |
| 5238 | bgp_show_type_community_list_exact, |
| 5239 | bgp_show_type_flap_statistics, |
| 5240 | bgp_show_type_flap_address, |
| 5241 | bgp_show_type_flap_prefix, |
| 5242 | bgp_show_type_flap_cidr_only, |
| 5243 | bgp_show_type_flap_regexp, |
| 5244 | bgp_show_type_flap_filter_list, |
| 5245 | bgp_show_type_flap_prefix_list, |
| 5246 | bgp_show_type_flap_prefix_longer, |
| 5247 | bgp_show_type_flap_route_map, |
| 5248 | bgp_show_type_flap_neighbor, |
| 5249 | bgp_show_type_dampend_paths, |
| 5250 | bgp_show_type_damp_neighbor |
| 5251 | }; |
| 5252 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5253 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5254 | bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5255 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5256 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5257 | struct bgp_info *ri; |
| 5258 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5259 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5260 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5261 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5262 | |
| 5263 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5264 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5265 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5266 | /* Start processing of routes. */ |
| 5267 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5268 | if (rn->info != NULL) |
| 5269 | { |
| 5270 | display = 0; |
| 5271 | |
| 5272 | for (ri = rn->info; ri; ri = ri->next) |
| 5273 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5274 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5275 | || type == bgp_show_type_flap_address |
| 5276 | || type == bgp_show_type_flap_prefix |
| 5277 | || type == bgp_show_type_flap_cidr_only |
| 5278 | || type == bgp_show_type_flap_regexp |
| 5279 | || type == bgp_show_type_flap_filter_list |
| 5280 | || type == bgp_show_type_flap_prefix_list |
| 5281 | || type == bgp_show_type_flap_prefix_longer |
| 5282 | || type == bgp_show_type_flap_route_map |
| 5283 | || type == bgp_show_type_flap_neighbor |
| 5284 | || type == bgp_show_type_dampend_paths |
| 5285 | || type == bgp_show_type_damp_neighbor) |
| 5286 | { |
| 5287 | if (! ri->damp_info) |
| 5288 | continue; |
| 5289 | } |
| 5290 | if (type == bgp_show_type_regexp |
| 5291 | || type == bgp_show_type_flap_regexp) |
| 5292 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5293 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5294 | |
| 5295 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 5296 | continue; |
| 5297 | } |
| 5298 | if (type == bgp_show_type_prefix_list |
| 5299 | || type == bgp_show_type_flap_prefix_list) |
| 5300 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5301 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5302 | |
| 5303 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 5304 | continue; |
| 5305 | } |
| 5306 | if (type == bgp_show_type_filter_list |
| 5307 | || type == bgp_show_type_flap_filter_list) |
| 5308 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5309 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5310 | |
| 5311 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 5312 | continue; |
| 5313 | } |
| 5314 | if (type == bgp_show_type_route_map |
| 5315 | || type == bgp_show_type_flap_route_map) |
| 5316 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5317 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5318 | struct bgp_info binfo; |
| 5319 | struct attr dummy_attr; |
| 5320 | int ret; |
| 5321 | |
| 5322 | dummy_attr = *ri->attr; |
| 5323 | binfo.peer = ri->peer; |
| 5324 | binfo.attr = &dummy_attr; |
| 5325 | |
| 5326 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 5327 | |
| 5328 | if (ret == RMAP_DENYMATCH) |
| 5329 | continue; |
| 5330 | } |
| 5331 | if (type == bgp_show_type_neighbor |
| 5332 | || type == bgp_show_type_flap_neighbor |
| 5333 | || type == bgp_show_type_damp_neighbor) |
| 5334 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5335 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5336 | |
| 5337 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 5338 | continue; |
| 5339 | } |
| 5340 | if (type == bgp_show_type_cidr_only |
| 5341 | || type == bgp_show_type_flap_cidr_only) |
| 5342 | { |
| 5343 | u_int32_t destination; |
| 5344 | |
| 5345 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 5346 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 5347 | continue; |
| 5348 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 5349 | continue; |
| 5350 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 5351 | continue; |
| 5352 | } |
| 5353 | if (type == bgp_show_type_prefix_longer |
| 5354 | || type == bgp_show_type_flap_prefix_longer) |
| 5355 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5356 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5357 | |
| 5358 | if (! prefix_match (p, &rn->p)) |
| 5359 | continue; |
| 5360 | } |
| 5361 | if (type == bgp_show_type_community_all) |
| 5362 | { |
| 5363 | if (! ri->attr->community) |
| 5364 | continue; |
| 5365 | } |
| 5366 | if (type == bgp_show_type_community) |
| 5367 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5368 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5369 | |
| 5370 | if (! ri->attr->community || |
| 5371 | ! community_match (ri->attr->community, com)) |
| 5372 | continue; |
| 5373 | } |
| 5374 | if (type == bgp_show_type_community_exact) |
| 5375 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5376 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5377 | |
| 5378 | if (! ri->attr->community || |
| 5379 | ! community_cmp (ri->attr->community, com)) |
| 5380 | continue; |
| 5381 | } |
| 5382 | if (type == bgp_show_type_community_list) |
| 5383 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5384 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5385 | |
| 5386 | if (! community_list_match (ri->attr->community, list)) |
| 5387 | continue; |
| 5388 | } |
| 5389 | if (type == bgp_show_type_community_list_exact) |
| 5390 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5391 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5392 | |
| 5393 | if (! community_list_exact_match (ri->attr->community, list)) |
| 5394 | continue; |
| 5395 | } |
| 5396 | if (type == bgp_show_type_flap_address |
| 5397 | || type == bgp_show_type_flap_prefix) |
| 5398 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5399 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5400 | |
| 5401 | if (! prefix_match (&rn->p, p)) |
| 5402 | continue; |
| 5403 | |
| 5404 | if (type == bgp_show_type_flap_prefix) |
| 5405 | if (p->prefixlen != rn->p.prefixlen) |
| 5406 | continue; |
| 5407 | } |
| 5408 | if (type == bgp_show_type_dampend_paths |
| 5409 | || type == bgp_show_type_damp_neighbor) |
| 5410 | { |
| 5411 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 5412 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 5413 | continue; |
| 5414 | } |
| 5415 | |
| 5416 | if (header) |
| 5417 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5418 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5419 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 5420 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 5421 | if (type == bgp_show_type_dampend_paths |
| 5422 | || type == bgp_show_type_damp_neighbor) |
| 5423 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 5424 | else if (type == bgp_show_type_flap_statistics |
| 5425 | || type == bgp_show_type_flap_address |
| 5426 | || type == bgp_show_type_flap_prefix |
| 5427 | || type == bgp_show_type_flap_cidr_only |
| 5428 | || type == bgp_show_type_flap_regexp |
| 5429 | || type == bgp_show_type_flap_filter_list |
| 5430 | || type == bgp_show_type_flap_prefix_list |
| 5431 | || type == bgp_show_type_flap_prefix_longer |
| 5432 | || type == bgp_show_type_flap_route_map |
| 5433 | || type == bgp_show_type_flap_neighbor) |
| 5434 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 5435 | else |
| 5436 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5437 | header = 0; |
| 5438 | } |
| 5439 | |
| 5440 | if (type == bgp_show_type_dampend_paths |
| 5441 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5442 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5443 | else if (type == bgp_show_type_flap_statistics |
| 5444 | || type == bgp_show_type_flap_address |
| 5445 | || type == bgp_show_type_flap_prefix |
| 5446 | || type == bgp_show_type_flap_cidr_only |
| 5447 | || type == bgp_show_type_flap_regexp |
| 5448 | || type == bgp_show_type_flap_filter_list |
| 5449 | || type == bgp_show_type_flap_prefix_list |
| 5450 | || type == bgp_show_type_flap_prefix_longer |
| 5451 | || type == bgp_show_type_flap_route_map |
| 5452 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5453 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5454 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5455 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5456 | display++; |
| 5457 | } |
| 5458 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5459 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5460 | } |
| 5461 | |
| 5462 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5463 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5464 | { |
| 5465 | if (type == bgp_show_type_normal) |
| 5466 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 5467 | } |
| 5468 | else |
| 5469 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5470 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5471 | |
| 5472 | return CMD_SUCCESS; |
| 5473 | } |
| 5474 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5475 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5476 | bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5477 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5478 | { |
| 5479 | struct bgp_table *table; |
| 5480 | |
| 5481 | if (bgp == NULL) { |
| 5482 | bgp = bgp_get_default (); |
| 5483 | } |
| 5484 | |
| 5485 | if (bgp == NULL) |
| 5486 | { |
| 5487 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5488 | return CMD_WARNING; |
| 5489 | } |
| 5490 | |
| 5491 | |
| 5492 | table = bgp->rib[afi][safi]; |
| 5493 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5494 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5495 | } |
| 5496 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5497 | /* Header of detailed BGP route information */ |
| 5498 | void |
| 5499 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 5500 | struct bgp_node *rn, |
| 5501 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 5502 | { |
| 5503 | struct bgp_info *ri; |
| 5504 | struct prefix *p; |
| 5505 | struct peer *peer; |
| 5506 | struct listnode *nn; |
| 5507 | char buf1[INET6_ADDRSTRLEN]; |
| 5508 | char buf2[INET6_ADDRSTRLEN]; |
| 5509 | int count = 0; |
| 5510 | int best = 0; |
| 5511 | int suppress = 0; |
| 5512 | int no_export = 0; |
| 5513 | int no_advertise = 0; |
| 5514 | int local_as = 0; |
| 5515 | int first = 0; |
| 5516 | |
| 5517 | p = &rn->p; |
| 5518 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 5519 | (safi == SAFI_MPLS_VPN ? |
| 5520 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 5521 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 5522 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 5523 | p->prefixlen, VTY_NEWLINE); |
| 5524 | |
| 5525 | for (ri = rn->info; ri; ri = ri->next) |
| 5526 | { |
| 5527 | count++; |
| 5528 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 5529 | { |
| 5530 | best = count; |
| 5531 | if (ri->suppress) |
| 5532 | suppress = 1; |
| 5533 | if (ri->attr->community != NULL) |
| 5534 | { |
| 5535 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 5536 | no_advertise = 1; |
| 5537 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 5538 | no_export = 1; |
| 5539 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 5540 | local_as = 1; |
| 5541 | } |
| 5542 | } |
| 5543 | } |
| 5544 | |
| 5545 | vty_out (vty, "Paths: (%d available", count); |
| 5546 | if (best) |
| 5547 | { |
| 5548 | vty_out (vty, ", best #%d", best); |
| 5549 | if (safi == SAFI_UNICAST) |
| 5550 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 5551 | } |
| 5552 | else |
| 5553 | vty_out (vty, ", no best path"); |
| 5554 | if (no_advertise) |
| 5555 | vty_out (vty, ", not advertised to any peer"); |
| 5556 | else if (no_export) |
| 5557 | vty_out (vty, ", not advertised to EBGP peer"); |
| 5558 | else if (local_as) |
| 5559 | vty_out (vty, ", not advertised outside local AS"); |
| 5560 | if (suppress) |
| 5561 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 5562 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 5563 | |
| 5564 | /* advertised peer */ |
| 5565 | LIST_LOOP (bgp->peer, peer, nn) |
| 5566 | { |
| 5567 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 5568 | { |
| 5569 | if (! first) |
| 5570 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 5571 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 5572 | first = 1; |
| 5573 | } |
| 5574 | } |
| 5575 | if (! first) |
| 5576 | vty_out (vty, " Not advertised to any peer"); |
| 5577 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5578 | } |
| 5579 | |
| 5580 | /* Display specified route of BGP table. */ |
| 5581 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5582 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5583 | struct bgp_table *rib, const char *ip_str, |
| 5584 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5585 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5586 | { |
| 5587 | int ret; |
| 5588 | int header; |
| 5589 | int display = 0; |
| 5590 | struct prefix match; |
| 5591 | struct bgp_node *rn; |
| 5592 | struct bgp_node *rm; |
| 5593 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5594 | struct bgp_table *table; |
| 5595 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5596 | /* Check IP address argument. */ |
| 5597 | ret = str2prefix (ip_str, &match); |
| 5598 | if (! ret) |
| 5599 | { |
| 5600 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 5601 | return CMD_WARNING; |
| 5602 | } |
| 5603 | |
| 5604 | match.family = afi2family (afi); |
| 5605 | |
| 5606 | if (safi == SAFI_MPLS_VPN) |
| 5607 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5608 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5609 | { |
| 5610 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 5611 | continue; |
| 5612 | |
| 5613 | if ((table = rn->info) != NULL) |
| 5614 | { |
| 5615 | header = 1; |
| 5616 | |
| 5617 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 5618 | { |
| 5619 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 5620 | continue; |
| 5621 | |
| 5622 | for (ri = rm->info; ri; ri = ri->next) |
| 5623 | { |
| 5624 | if (header) |
| 5625 | { |
| 5626 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 5627 | AFI_IP, SAFI_MPLS_VPN); |
| 5628 | |
| 5629 | header = 0; |
| 5630 | } |
| 5631 | display++; |
| 5632 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 5633 | } |
| 5634 | } |
| 5635 | } |
| 5636 | } |
| 5637 | } |
| 5638 | else |
| 5639 | { |
| 5640 | header = 1; |
| 5641 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5642 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5643 | { |
| 5644 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 5645 | { |
| 5646 | for (ri = rn->info; ri; ri = ri->next) |
| 5647 | { |
| 5648 | if (header) |
| 5649 | { |
| 5650 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 5651 | header = 0; |
| 5652 | } |
| 5653 | display++; |
| 5654 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 5655 | } |
| 5656 | } |
| 5657 | } |
| 5658 | } |
| 5659 | |
| 5660 | if (! display) |
| 5661 | { |
| 5662 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 5663 | return CMD_WARNING; |
| 5664 | } |
| 5665 | |
| 5666 | return CMD_SUCCESS; |
| 5667 | } |
| 5668 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5669 | /* Display specified route of Main RIB */ |
| 5670 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5671 | bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5672 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5673 | int prefix_check) |
| 5674 | { |
| 5675 | struct bgp *bgp; |
| 5676 | |
| 5677 | /* BGP structure lookup. */ |
| 5678 | if (view_name) |
| 5679 | { |
| 5680 | bgp = bgp_lookup_by_name (view_name); |
| 5681 | if (bgp == NULL) |
| 5682 | { |
| 5683 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 5684 | return CMD_WARNING; |
| 5685 | } |
| 5686 | } |
| 5687 | else |
| 5688 | { |
| 5689 | bgp = bgp_get_default (); |
| 5690 | if (bgp == NULL) |
| 5691 | { |
| 5692 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5693 | return CMD_WARNING; |
| 5694 | } |
| 5695 | } |
| 5696 | |
| 5697 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 5698 | afi, safi, prd, prefix_check); |
| 5699 | } |
| 5700 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5701 | /* BGP route print out function. */ |
| 5702 | DEFUN (show_ip_bgp, |
| 5703 | show_ip_bgp_cmd, |
| 5704 | "show ip bgp", |
| 5705 | SHOW_STR |
| 5706 | IP_STR |
| 5707 | BGP_STR) |
| 5708 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5709 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5710 | } |
| 5711 | |
| 5712 | DEFUN (show_ip_bgp_ipv4, |
| 5713 | show_ip_bgp_ipv4_cmd, |
| 5714 | "show ip bgp ipv4 (unicast|multicast)", |
| 5715 | SHOW_STR |
| 5716 | IP_STR |
| 5717 | BGP_STR |
| 5718 | "Address family\n" |
| 5719 | "Address Family modifier\n" |
| 5720 | "Address Family modifier\n") |
| 5721 | { |
| 5722 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5723 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 5724 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5725 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5726 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5727 | } |
| 5728 | |
| 5729 | DEFUN (show_ip_bgp_route, |
| 5730 | show_ip_bgp_route_cmd, |
| 5731 | "show ip bgp A.B.C.D", |
| 5732 | SHOW_STR |
| 5733 | IP_STR |
| 5734 | BGP_STR |
| 5735 | "Network in the BGP routing table to display\n") |
| 5736 | { |
| 5737 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5738 | } |
| 5739 | |
| 5740 | DEFUN (show_ip_bgp_ipv4_route, |
| 5741 | show_ip_bgp_ipv4_route_cmd, |
| 5742 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 5743 | SHOW_STR |
| 5744 | IP_STR |
| 5745 | BGP_STR |
| 5746 | "Address family\n" |
| 5747 | "Address Family modifier\n" |
| 5748 | "Address Family modifier\n" |
| 5749 | "Network in the BGP routing table to display\n") |
| 5750 | { |
| 5751 | if (strncmp (argv[0], "m", 1) == 0) |
| 5752 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 5753 | |
| 5754 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5755 | } |
| 5756 | |
| 5757 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 5758 | show_ip_bgp_vpnv4_all_route_cmd, |
| 5759 | "show ip bgp vpnv4 all A.B.C.D", |
| 5760 | SHOW_STR |
| 5761 | IP_STR |
| 5762 | BGP_STR |
| 5763 | "Display VPNv4 NLRI specific information\n" |
| 5764 | "Display information about all VPNv4 NLRIs\n" |
| 5765 | "Network in the BGP routing table to display\n") |
| 5766 | { |
| 5767 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 5768 | } |
| 5769 | |
| 5770 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 5771 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 5772 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 5773 | SHOW_STR |
| 5774 | IP_STR |
| 5775 | BGP_STR |
| 5776 | "Display VPNv4 NLRI specific information\n" |
| 5777 | "Display information for a route distinguisher\n" |
| 5778 | "VPN Route Distinguisher\n" |
| 5779 | "Network in the BGP routing table to display\n") |
| 5780 | { |
| 5781 | int ret; |
| 5782 | struct prefix_rd prd; |
| 5783 | |
| 5784 | ret = str2prefix_rd (argv[0], &prd); |
| 5785 | if (! ret) |
| 5786 | { |
| 5787 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5788 | return CMD_WARNING; |
| 5789 | } |
| 5790 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 5791 | } |
| 5792 | |
| 5793 | DEFUN (show_ip_bgp_prefix, |
| 5794 | show_ip_bgp_prefix_cmd, |
| 5795 | "show ip bgp A.B.C.D/M", |
| 5796 | SHOW_STR |
| 5797 | IP_STR |
| 5798 | BGP_STR |
| 5799 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5800 | { |
| 5801 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5802 | } |
| 5803 | |
| 5804 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 5805 | show_ip_bgp_ipv4_prefix_cmd, |
| 5806 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 5807 | SHOW_STR |
| 5808 | IP_STR |
| 5809 | BGP_STR |
| 5810 | "Address family\n" |
| 5811 | "Address Family modifier\n" |
| 5812 | "Address Family modifier\n" |
| 5813 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5814 | { |
| 5815 | if (strncmp (argv[0], "m", 1) == 0) |
| 5816 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 5817 | |
| 5818 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5819 | } |
| 5820 | |
| 5821 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 5822 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 5823 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 5824 | SHOW_STR |
| 5825 | IP_STR |
| 5826 | BGP_STR |
| 5827 | "Display VPNv4 NLRI specific information\n" |
| 5828 | "Display information about all VPNv4 NLRIs\n" |
| 5829 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5830 | { |
| 5831 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 5832 | } |
| 5833 | |
| 5834 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 5835 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 5836 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 5837 | SHOW_STR |
| 5838 | IP_STR |
| 5839 | BGP_STR |
| 5840 | "Display VPNv4 NLRI specific information\n" |
| 5841 | "Display information for a route distinguisher\n" |
| 5842 | "VPN Route Distinguisher\n" |
| 5843 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5844 | { |
| 5845 | int ret; |
| 5846 | struct prefix_rd prd; |
| 5847 | |
| 5848 | ret = str2prefix_rd (argv[0], &prd); |
| 5849 | if (! ret) |
| 5850 | { |
| 5851 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5852 | return CMD_WARNING; |
| 5853 | } |
| 5854 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 5855 | } |
| 5856 | |
| 5857 | DEFUN (show_ip_bgp_view, |
| 5858 | show_ip_bgp_view_cmd, |
| 5859 | "show ip bgp view WORD", |
| 5860 | SHOW_STR |
| 5861 | IP_STR |
| 5862 | BGP_STR |
| 5863 | "BGP view\n" |
| 5864 | "BGP view name\n") |
| 5865 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 5866 | struct bgp *bgp; |
| 5867 | |
| 5868 | /* BGP structure lookup. */ |
| 5869 | bgp = bgp_lookup_by_name (argv[0]); |
| 5870 | if (bgp == NULL) |
| 5871 | { |
| 5872 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 5873 | return CMD_WARNING; |
| 5874 | } |
| 5875 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5876 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5877 | } |
| 5878 | |
| 5879 | DEFUN (show_ip_bgp_view_route, |
| 5880 | show_ip_bgp_view_route_cmd, |
| 5881 | "show ip bgp view WORD A.B.C.D", |
| 5882 | SHOW_STR |
| 5883 | IP_STR |
| 5884 | BGP_STR |
| 5885 | "BGP view\n" |
| 5886 | "BGP view name\n" |
| 5887 | "Network in the BGP routing table to display\n") |
| 5888 | { |
| 5889 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5890 | } |
| 5891 | |
| 5892 | DEFUN (show_ip_bgp_view_prefix, |
| 5893 | show_ip_bgp_view_prefix_cmd, |
| 5894 | "show ip bgp view WORD A.B.C.D/M", |
| 5895 | SHOW_STR |
| 5896 | IP_STR |
| 5897 | BGP_STR |
| 5898 | "BGP view\n" |
| 5899 | "BGP view name\n" |
| 5900 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5901 | { |
| 5902 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5903 | } |
| 5904 | |
| 5905 | #ifdef HAVE_IPV6 |
| 5906 | DEFUN (show_bgp, |
| 5907 | show_bgp_cmd, |
| 5908 | "show bgp", |
| 5909 | SHOW_STR |
| 5910 | BGP_STR) |
| 5911 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5912 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 5913 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5914 | } |
| 5915 | |
| 5916 | ALIAS (show_bgp, |
| 5917 | show_bgp_ipv6_cmd, |
| 5918 | "show bgp ipv6", |
| 5919 | SHOW_STR |
| 5920 | BGP_STR |
| 5921 | "Address family\n") |
| 5922 | |
| 5923 | /* old command */ |
| 5924 | DEFUN (show_ipv6_bgp, |
| 5925 | show_ipv6_bgp_cmd, |
| 5926 | "show ipv6 bgp", |
| 5927 | SHOW_STR |
| 5928 | IP_STR |
| 5929 | BGP_STR) |
| 5930 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5931 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 5932 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5933 | } |
| 5934 | |
| 5935 | DEFUN (show_bgp_route, |
| 5936 | show_bgp_route_cmd, |
| 5937 | "show bgp X:X::X:X", |
| 5938 | SHOW_STR |
| 5939 | BGP_STR |
| 5940 | "Network in the BGP routing table to display\n") |
| 5941 | { |
| 5942 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5943 | } |
| 5944 | |
| 5945 | ALIAS (show_bgp_route, |
| 5946 | show_bgp_ipv6_route_cmd, |
| 5947 | "show bgp ipv6 X:X::X:X", |
| 5948 | SHOW_STR |
| 5949 | BGP_STR |
| 5950 | "Address family\n" |
| 5951 | "Network in the BGP routing table to display\n") |
| 5952 | |
| 5953 | /* old command */ |
| 5954 | DEFUN (show_ipv6_bgp_route, |
| 5955 | show_ipv6_bgp_route_cmd, |
| 5956 | "show ipv6 bgp X:X::X:X", |
| 5957 | SHOW_STR |
| 5958 | IP_STR |
| 5959 | BGP_STR |
| 5960 | "Network in the BGP routing table to display\n") |
| 5961 | { |
| 5962 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5963 | } |
| 5964 | |
| 5965 | DEFUN (show_bgp_prefix, |
| 5966 | show_bgp_prefix_cmd, |
| 5967 | "show bgp X:X::X:X/M", |
| 5968 | SHOW_STR |
| 5969 | BGP_STR |
| 5970 | "IPv6 prefix <network>/<length>\n") |
| 5971 | { |
| 5972 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 5973 | } |
| 5974 | |
| 5975 | ALIAS (show_bgp_prefix, |
| 5976 | show_bgp_ipv6_prefix_cmd, |
| 5977 | "show bgp ipv6 X:X::X:X/M", |
| 5978 | SHOW_STR |
| 5979 | BGP_STR |
| 5980 | "Address family\n" |
| 5981 | "IPv6 prefix <network>/<length>\n") |
| 5982 | |
| 5983 | /* old command */ |
| 5984 | DEFUN (show_ipv6_bgp_prefix, |
| 5985 | show_ipv6_bgp_prefix_cmd, |
| 5986 | "show ipv6 bgp X:X::X:X/M", |
| 5987 | SHOW_STR |
| 5988 | IP_STR |
| 5989 | BGP_STR |
| 5990 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 5991 | { |
| 5992 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 5993 | } |
| 5994 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 5995 | DEFUN (show_bgp_view, |
| 5996 | show_bgp_view_cmd, |
| 5997 | "show bgp view WORD", |
| 5998 | SHOW_STR |
| 5999 | BGP_STR |
| 6000 | "BGP view\n" |
| 6001 | "View name\n") |
| 6002 | { |
| 6003 | struct bgp *bgp; |
| 6004 | |
| 6005 | /* BGP structure lookup. */ |
| 6006 | bgp = bgp_lookup_by_name (argv[0]); |
| 6007 | if (bgp == NULL) |
| 6008 | { |
| 6009 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6010 | return CMD_WARNING; |
| 6011 | } |
| 6012 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6013 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6014 | } |
| 6015 | |
| 6016 | ALIAS (show_bgp_view, |
| 6017 | show_bgp_view_ipv6_cmd, |
| 6018 | "show bgp view WORD ipv6", |
| 6019 | SHOW_STR |
| 6020 | BGP_STR |
| 6021 | "BGP view\n" |
| 6022 | "View name\n" |
| 6023 | "Address family\n") |
| 6024 | |
| 6025 | DEFUN (show_bgp_view_route, |
| 6026 | show_bgp_view_route_cmd, |
| 6027 | "show bgp view WORD X:X::X:X", |
| 6028 | SHOW_STR |
| 6029 | BGP_STR |
| 6030 | "BGP view\n" |
| 6031 | "View name\n" |
| 6032 | "Network in the BGP routing table to display\n") |
| 6033 | { |
| 6034 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6035 | } |
| 6036 | |
| 6037 | ALIAS (show_bgp_view_route, |
| 6038 | show_bgp_view_ipv6_route_cmd, |
| 6039 | "show bgp view WORD ipv6 X:X::X:X", |
| 6040 | SHOW_STR |
| 6041 | BGP_STR |
| 6042 | "BGP view\n" |
| 6043 | "View name\n" |
| 6044 | "Address family\n" |
| 6045 | "Network in the BGP routing table to display\n") |
| 6046 | |
| 6047 | DEFUN (show_bgp_view_prefix, |
| 6048 | show_bgp_view_prefix_cmd, |
| 6049 | "show bgp view WORD X:X::X:X/M", |
| 6050 | SHOW_STR |
| 6051 | BGP_STR |
| 6052 | "BGP view\n" |
| 6053 | "View name\n" |
| 6054 | "IPv6 prefix <network>/<length>\n") |
| 6055 | { |
| 6056 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6057 | } |
| 6058 | |
| 6059 | ALIAS (show_bgp_view_prefix, |
| 6060 | show_bgp_view_ipv6_prefix_cmd, |
| 6061 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 6062 | SHOW_STR |
| 6063 | BGP_STR |
| 6064 | "BGP view\n" |
| 6065 | "View name\n" |
| 6066 | "Address family\n" |
| 6067 | "IPv6 prefix <network>/<length>\n") |
| 6068 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6069 | /* old command */ |
| 6070 | DEFUN (show_ipv6_mbgp, |
| 6071 | show_ipv6_mbgp_cmd, |
| 6072 | "show ipv6 mbgp", |
| 6073 | SHOW_STR |
| 6074 | IP_STR |
| 6075 | MBGP_STR) |
| 6076 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6077 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6078 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6079 | } |
| 6080 | |
| 6081 | /* old command */ |
| 6082 | DEFUN (show_ipv6_mbgp_route, |
| 6083 | show_ipv6_mbgp_route_cmd, |
| 6084 | "show ipv6 mbgp X:X::X:X", |
| 6085 | SHOW_STR |
| 6086 | IP_STR |
| 6087 | MBGP_STR |
| 6088 | "Network in the MBGP routing table to display\n") |
| 6089 | { |
| 6090 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6091 | } |
| 6092 | |
| 6093 | /* old command */ |
| 6094 | DEFUN (show_ipv6_mbgp_prefix, |
| 6095 | show_ipv6_mbgp_prefix_cmd, |
| 6096 | "show ipv6 mbgp X:X::X:X/M", |
| 6097 | SHOW_STR |
| 6098 | IP_STR |
| 6099 | MBGP_STR |
| 6100 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6101 | { |
| 6102 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6103 | } |
| 6104 | #endif |
| 6105 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6106 | |
| 6107 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6108 | bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6109 | safi_t safi, enum bgp_show_type type) |
| 6110 | { |
| 6111 | int i; |
| 6112 | struct buffer *b; |
| 6113 | char *regstr; |
| 6114 | int first; |
| 6115 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6116 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6117 | |
| 6118 | first = 0; |
| 6119 | b = buffer_new (1024); |
| 6120 | for (i = 0; i < argc; i++) |
| 6121 | { |
| 6122 | if (first) |
| 6123 | buffer_putc (b, ' '); |
| 6124 | else |
| 6125 | { |
| 6126 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6127 | continue; |
| 6128 | first = 1; |
| 6129 | } |
| 6130 | |
| 6131 | buffer_putstr (b, argv[i]); |
| 6132 | } |
| 6133 | buffer_putc (b, '\0'); |
| 6134 | |
| 6135 | regstr = buffer_getstr (b); |
| 6136 | buffer_free (b); |
| 6137 | |
| 6138 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6139 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6140 | if (! regex) |
| 6141 | { |
| 6142 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 6143 | VTY_NEWLINE); |
| 6144 | return CMD_WARNING; |
| 6145 | } |
| 6146 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6147 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 6148 | bgp_regex_free (regex); |
| 6149 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6150 | } |
| 6151 | |
| 6152 | DEFUN (show_ip_bgp_regexp, |
| 6153 | show_ip_bgp_regexp_cmd, |
| 6154 | "show ip bgp regexp .LINE", |
| 6155 | SHOW_STR |
| 6156 | IP_STR |
| 6157 | BGP_STR |
| 6158 | "Display routes matching the AS path regular expression\n" |
| 6159 | "A regular-expression to match the BGP AS paths\n") |
| 6160 | { |
| 6161 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6162 | bgp_show_type_regexp); |
| 6163 | } |
| 6164 | |
| 6165 | DEFUN (show_ip_bgp_flap_regexp, |
| 6166 | show_ip_bgp_flap_regexp_cmd, |
| 6167 | "show ip bgp flap-statistics regexp .LINE", |
| 6168 | SHOW_STR |
| 6169 | IP_STR |
| 6170 | BGP_STR |
| 6171 | "Display flap statistics of routes\n" |
| 6172 | "Display routes matching the AS path regular expression\n" |
| 6173 | "A regular-expression to match the BGP AS paths\n") |
| 6174 | { |
| 6175 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6176 | bgp_show_type_flap_regexp); |
| 6177 | } |
| 6178 | |
| 6179 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 6180 | show_ip_bgp_ipv4_regexp_cmd, |
| 6181 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 6182 | SHOW_STR |
| 6183 | IP_STR |
| 6184 | BGP_STR |
| 6185 | "Address family\n" |
| 6186 | "Address Family modifier\n" |
| 6187 | "Address Family modifier\n" |
| 6188 | "Display routes matching the AS path regular expression\n" |
| 6189 | "A regular-expression to match the BGP AS paths\n") |
| 6190 | { |
| 6191 | if (strncmp (argv[0], "m", 1) == 0) |
| 6192 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 6193 | bgp_show_type_regexp); |
| 6194 | |
| 6195 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6196 | bgp_show_type_regexp); |
| 6197 | } |
| 6198 | |
| 6199 | #ifdef HAVE_IPV6 |
| 6200 | DEFUN (show_bgp_regexp, |
| 6201 | show_bgp_regexp_cmd, |
| 6202 | "show bgp regexp .LINE", |
| 6203 | SHOW_STR |
| 6204 | BGP_STR |
| 6205 | "Display routes matching the AS path regular expression\n" |
| 6206 | "A regular-expression to match the BGP AS paths\n") |
| 6207 | { |
| 6208 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6209 | bgp_show_type_regexp); |
| 6210 | } |
| 6211 | |
| 6212 | ALIAS (show_bgp_regexp, |
| 6213 | show_bgp_ipv6_regexp_cmd, |
| 6214 | "show bgp ipv6 regexp .LINE", |
| 6215 | SHOW_STR |
| 6216 | BGP_STR |
| 6217 | "Address family\n" |
| 6218 | "Display routes matching the AS path regular expression\n" |
| 6219 | "A regular-expression to match the BGP AS paths\n") |
| 6220 | |
| 6221 | /* old command */ |
| 6222 | DEFUN (show_ipv6_bgp_regexp, |
| 6223 | show_ipv6_bgp_regexp_cmd, |
| 6224 | "show ipv6 bgp regexp .LINE", |
| 6225 | SHOW_STR |
| 6226 | IP_STR |
| 6227 | BGP_STR |
| 6228 | "Display routes matching the AS path regular expression\n" |
| 6229 | "A regular-expression to match the BGP AS paths\n") |
| 6230 | { |
| 6231 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6232 | bgp_show_type_regexp); |
| 6233 | } |
| 6234 | |
| 6235 | /* old command */ |
| 6236 | DEFUN (show_ipv6_mbgp_regexp, |
| 6237 | show_ipv6_mbgp_regexp_cmd, |
| 6238 | "show ipv6 mbgp regexp .LINE", |
| 6239 | SHOW_STR |
| 6240 | IP_STR |
| 6241 | BGP_STR |
| 6242 | "Display routes matching the AS path regular expression\n" |
| 6243 | "A regular-expression to match the MBGP AS paths\n") |
| 6244 | { |
| 6245 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 6246 | bgp_show_type_regexp); |
| 6247 | } |
| 6248 | #endif /* HAVE_IPV6 */ |
| 6249 | |
| 6250 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6251 | bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6252 | safi_t safi, enum bgp_show_type type) |
| 6253 | { |
| 6254 | struct prefix_list *plist; |
| 6255 | |
| 6256 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 6257 | if (plist == NULL) |
| 6258 | { |
| 6259 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 6260 | prefix_list_str, VTY_NEWLINE); |
| 6261 | return CMD_WARNING; |
| 6262 | } |
| 6263 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6264 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6265 | } |
| 6266 | |
| 6267 | DEFUN (show_ip_bgp_prefix_list, |
| 6268 | show_ip_bgp_prefix_list_cmd, |
| 6269 | "show ip bgp prefix-list WORD", |
| 6270 | SHOW_STR |
| 6271 | IP_STR |
| 6272 | BGP_STR |
| 6273 | "Display routes conforming to the prefix-list\n" |
| 6274 | "IP prefix-list name\n") |
| 6275 | { |
| 6276 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6277 | bgp_show_type_prefix_list); |
| 6278 | } |
| 6279 | |
| 6280 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 6281 | show_ip_bgp_flap_prefix_list_cmd, |
| 6282 | "show ip bgp flap-statistics prefix-list WORD", |
| 6283 | SHOW_STR |
| 6284 | IP_STR |
| 6285 | BGP_STR |
| 6286 | "Display flap statistics of routes\n" |
| 6287 | "Display routes conforming to the prefix-list\n" |
| 6288 | "IP prefix-list name\n") |
| 6289 | { |
| 6290 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6291 | bgp_show_type_flap_prefix_list); |
| 6292 | } |
| 6293 | |
| 6294 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 6295 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 6296 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 6297 | SHOW_STR |
| 6298 | IP_STR |
| 6299 | BGP_STR |
| 6300 | "Address family\n" |
| 6301 | "Address Family modifier\n" |
| 6302 | "Address Family modifier\n" |
| 6303 | "Display routes conforming to the prefix-list\n" |
| 6304 | "IP prefix-list name\n") |
| 6305 | { |
| 6306 | if (strncmp (argv[0], "m", 1) == 0) |
| 6307 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6308 | bgp_show_type_prefix_list); |
| 6309 | |
| 6310 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6311 | bgp_show_type_prefix_list); |
| 6312 | } |
| 6313 | |
| 6314 | #ifdef HAVE_IPV6 |
| 6315 | DEFUN (show_bgp_prefix_list, |
| 6316 | show_bgp_prefix_list_cmd, |
| 6317 | "show bgp prefix-list WORD", |
| 6318 | SHOW_STR |
| 6319 | BGP_STR |
| 6320 | "Display routes conforming to the prefix-list\n" |
| 6321 | "IPv6 prefix-list name\n") |
| 6322 | { |
| 6323 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6324 | bgp_show_type_prefix_list); |
| 6325 | } |
| 6326 | |
| 6327 | ALIAS (show_bgp_prefix_list, |
| 6328 | show_bgp_ipv6_prefix_list_cmd, |
| 6329 | "show bgp ipv6 prefix-list WORD", |
| 6330 | SHOW_STR |
| 6331 | BGP_STR |
| 6332 | "Address family\n" |
| 6333 | "Display routes conforming to the prefix-list\n" |
| 6334 | "IPv6 prefix-list name\n") |
| 6335 | |
| 6336 | /* old command */ |
| 6337 | DEFUN (show_ipv6_bgp_prefix_list, |
| 6338 | show_ipv6_bgp_prefix_list_cmd, |
| 6339 | "show ipv6 bgp prefix-list WORD", |
| 6340 | SHOW_STR |
| 6341 | IPV6_STR |
| 6342 | BGP_STR |
| 6343 | "Display routes matching the prefix-list\n" |
| 6344 | "IPv6 prefix-list name\n") |
| 6345 | { |
| 6346 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6347 | bgp_show_type_prefix_list); |
| 6348 | } |
| 6349 | |
| 6350 | /* old command */ |
| 6351 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 6352 | show_ipv6_mbgp_prefix_list_cmd, |
| 6353 | "show ipv6 mbgp prefix-list WORD", |
| 6354 | SHOW_STR |
| 6355 | IPV6_STR |
| 6356 | MBGP_STR |
| 6357 | "Display routes matching the prefix-list\n" |
| 6358 | "IPv6 prefix-list name\n") |
| 6359 | { |
| 6360 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6361 | bgp_show_type_prefix_list); |
| 6362 | } |
| 6363 | #endif /* HAVE_IPV6 */ |
| 6364 | |
| 6365 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6366 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6367 | safi_t safi, enum bgp_show_type type) |
| 6368 | { |
| 6369 | struct as_list *as_list; |
| 6370 | |
| 6371 | as_list = as_list_lookup (filter); |
| 6372 | if (as_list == NULL) |
| 6373 | { |
| 6374 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 6375 | return CMD_WARNING; |
| 6376 | } |
| 6377 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6378 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6379 | } |
| 6380 | |
| 6381 | DEFUN (show_ip_bgp_filter_list, |
| 6382 | show_ip_bgp_filter_list_cmd, |
| 6383 | "show ip bgp filter-list WORD", |
| 6384 | SHOW_STR |
| 6385 | IP_STR |
| 6386 | BGP_STR |
| 6387 | "Display routes conforming to the filter-list\n" |
| 6388 | "Regular expression access list name\n") |
| 6389 | { |
| 6390 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6391 | bgp_show_type_filter_list); |
| 6392 | } |
| 6393 | |
| 6394 | DEFUN (show_ip_bgp_flap_filter_list, |
| 6395 | show_ip_bgp_flap_filter_list_cmd, |
| 6396 | "show ip bgp flap-statistics filter-list WORD", |
| 6397 | SHOW_STR |
| 6398 | IP_STR |
| 6399 | BGP_STR |
| 6400 | "Display flap statistics of routes\n" |
| 6401 | "Display routes conforming to the filter-list\n" |
| 6402 | "Regular expression access list name\n") |
| 6403 | { |
| 6404 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6405 | bgp_show_type_flap_filter_list); |
| 6406 | } |
| 6407 | |
| 6408 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 6409 | show_ip_bgp_ipv4_filter_list_cmd, |
| 6410 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 6411 | SHOW_STR |
| 6412 | IP_STR |
| 6413 | BGP_STR |
| 6414 | "Address family\n" |
| 6415 | "Address Family modifier\n" |
| 6416 | "Address Family modifier\n" |
| 6417 | "Display routes conforming to the filter-list\n" |
| 6418 | "Regular expression access list name\n") |
| 6419 | { |
| 6420 | if (strncmp (argv[0], "m", 1) == 0) |
| 6421 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6422 | bgp_show_type_filter_list); |
| 6423 | |
| 6424 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6425 | bgp_show_type_filter_list); |
| 6426 | } |
| 6427 | |
| 6428 | #ifdef HAVE_IPV6 |
| 6429 | DEFUN (show_bgp_filter_list, |
| 6430 | show_bgp_filter_list_cmd, |
| 6431 | "show bgp filter-list WORD", |
| 6432 | SHOW_STR |
| 6433 | BGP_STR |
| 6434 | "Display routes conforming to the filter-list\n" |
| 6435 | "Regular expression access list name\n") |
| 6436 | { |
| 6437 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6438 | bgp_show_type_filter_list); |
| 6439 | } |
| 6440 | |
| 6441 | ALIAS (show_bgp_filter_list, |
| 6442 | show_bgp_ipv6_filter_list_cmd, |
| 6443 | "show bgp ipv6 filter-list WORD", |
| 6444 | SHOW_STR |
| 6445 | BGP_STR |
| 6446 | "Address family\n" |
| 6447 | "Display routes conforming to the filter-list\n" |
| 6448 | "Regular expression access list name\n") |
| 6449 | |
| 6450 | /* old command */ |
| 6451 | DEFUN (show_ipv6_bgp_filter_list, |
| 6452 | show_ipv6_bgp_filter_list_cmd, |
| 6453 | "show ipv6 bgp filter-list WORD", |
| 6454 | SHOW_STR |
| 6455 | IPV6_STR |
| 6456 | BGP_STR |
| 6457 | "Display routes conforming to the filter-list\n" |
| 6458 | "Regular expression access list name\n") |
| 6459 | { |
| 6460 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6461 | bgp_show_type_filter_list); |
| 6462 | } |
| 6463 | |
| 6464 | /* old command */ |
| 6465 | DEFUN (show_ipv6_mbgp_filter_list, |
| 6466 | show_ipv6_mbgp_filter_list_cmd, |
| 6467 | "show ipv6 mbgp filter-list WORD", |
| 6468 | SHOW_STR |
| 6469 | IPV6_STR |
| 6470 | MBGP_STR |
| 6471 | "Display routes conforming to the filter-list\n" |
| 6472 | "Regular expression access list name\n") |
| 6473 | { |
| 6474 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6475 | bgp_show_type_filter_list); |
| 6476 | } |
| 6477 | #endif /* HAVE_IPV6 */ |
| 6478 | |
| 6479 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6480 | bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6481 | safi_t safi, enum bgp_show_type type) |
| 6482 | { |
| 6483 | struct route_map *rmap; |
| 6484 | |
| 6485 | rmap = route_map_lookup_by_name (rmap_str); |
| 6486 | if (! rmap) |
| 6487 | { |
| 6488 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 6489 | rmap_str, VTY_NEWLINE); |
| 6490 | return CMD_WARNING; |
| 6491 | } |
| 6492 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6493 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6494 | } |
| 6495 | |
| 6496 | DEFUN (show_ip_bgp_route_map, |
| 6497 | show_ip_bgp_route_map_cmd, |
| 6498 | "show ip bgp route-map WORD", |
| 6499 | SHOW_STR |
| 6500 | IP_STR |
| 6501 | BGP_STR |
| 6502 | "Display routes matching the route-map\n" |
| 6503 | "A route-map to match on\n") |
| 6504 | { |
| 6505 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6506 | bgp_show_type_route_map); |
| 6507 | } |
| 6508 | |
| 6509 | DEFUN (show_ip_bgp_flap_route_map, |
| 6510 | show_ip_bgp_flap_route_map_cmd, |
| 6511 | "show ip bgp flap-statistics route-map WORD", |
| 6512 | SHOW_STR |
| 6513 | IP_STR |
| 6514 | BGP_STR |
| 6515 | "Display flap statistics of routes\n" |
| 6516 | "Display routes matching the route-map\n" |
| 6517 | "A route-map to match on\n") |
| 6518 | { |
| 6519 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6520 | bgp_show_type_flap_route_map); |
| 6521 | } |
| 6522 | |
| 6523 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 6524 | show_ip_bgp_ipv4_route_map_cmd, |
| 6525 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 6526 | SHOW_STR |
| 6527 | IP_STR |
| 6528 | BGP_STR |
| 6529 | "Address family\n" |
| 6530 | "Address Family modifier\n" |
| 6531 | "Address Family modifier\n" |
| 6532 | "Display routes matching the route-map\n" |
| 6533 | "A route-map to match on\n") |
| 6534 | { |
| 6535 | if (strncmp (argv[0], "m", 1) == 0) |
| 6536 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6537 | bgp_show_type_route_map); |
| 6538 | |
| 6539 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6540 | bgp_show_type_route_map); |
| 6541 | } |
| 6542 | |
| 6543 | DEFUN (show_bgp_route_map, |
| 6544 | show_bgp_route_map_cmd, |
| 6545 | "show bgp route-map WORD", |
| 6546 | SHOW_STR |
| 6547 | BGP_STR |
| 6548 | "Display routes matching the route-map\n" |
| 6549 | "A route-map to match on\n") |
| 6550 | { |
| 6551 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6552 | bgp_show_type_route_map); |
| 6553 | } |
| 6554 | |
| 6555 | ALIAS (show_bgp_route_map, |
| 6556 | show_bgp_ipv6_route_map_cmd, |
| 6557 | "show bgp ipv6 route-map WORD", |
| 6558 | SHOW_STR |
| 6559 | BGP_STR |
| 6560 | "Address family\n" |
| 6561 | "Display routes matching the route-map\n" |
| 6562 | "A route-map to match on\n") |
| 6563 | |
| 6564 | DEFUN (show_ip_bgp_cidr_only, |
| 6565 | show_ip_bgp_cidr_only_cmd, |
| 6566 | "show ip bgp cidr-only", |
| 6567 | SHOW_STR |
| 6568 | IP_STR |
| 6569 | BGP_STR |
| 6570 | "Display only routes with non-natural netmasks\n") |
| 6571 | { |
| 6572 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6573 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6574 | } |
| 6575 | |
| 6576 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 6577 | show_ip_bgp_flap_cidr_only_cmd, |
| 6578 | "show ip bgp flap-statistics cidr-only", |
| 6579 | SHOW_STR |
| 6580 | IP_STR |
| 6581 | BGP_STR |
| 6582 | "Display flap statistics of routes\n" |
| 6583 | "Display only routes with non-natural netmasks\n") |
| 6584 | { |
| 6585 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6586 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6587 | } |
| 6588 | |
| 6589 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 6590 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 6591 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 6592 | SHOW_STR |
| 6593 | IP_STR |
| 6594 | BGP_STR |
| 6595 | "Address family\n" |
| 6596 | "Address Family modifier\n" |
| 6597 | "Address Family modifier\n" |
| 6598 | "Display only routes with non-natural netmasks\n") |
| 6599 | { |
| 6600 | if (strncmp (argv[0], "m", 1) == 0) |
| 6601 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6602 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6603 | |
| 6604 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6605 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6606 | } |
| 6607 | |
| 6608 | DEFUN (show_ip_bgp_community_all, |
| 6609 | show_ip_bgp_community_all_cmd, |
| 6610 | "show ip bgp community", |
| 6611 | SHOW_STR |
| 6612 | IP_STR |
| 6613 | BGP_STR |
| 6614 | "Display routes matching the communities\n") |
| 6615 | { |
| 6616 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6617 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6618 | } |
| 6619 | |
| 6620 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 6621 | show_ip_bgp_ipv4_community_all_cmd, |
| 6622 | "show ip bgp ipv4 (unicast|multicast) community", |
| 6623 | SHOW_STR |
| 6624 | IP_STR |
| 6625 | BGP_STR |
| 6626 | "Address family\n" |
| 6627 | "Address Family modifier\n" |
| 6628 | "Address Family modifier\n" |
| 6629 | "Display routes matching the communities\n") |
| 6630 | { |
| 6631 | if (strncmp (argv[0], "m", 1) == 0) |
| 6632 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6633 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6634 | |
| 6635 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6636 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6637 | } |
| 6638 | |
| 6639 | #ifdef HAVE_IPV6 |
| 6640 | DEFUN (show_bgp_community_all, |
| 6641 | show_bgp_community_all_cmd, |
| 6642 | "show bgp community", |
| 6643 | SHOW_STR |
| 6644 | BGP_STR |
| 6645 | "Display routes matching the communities\n") |
| 6646 | { |
| 6647 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6648 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6649 | } |
| 6650 | |
| 6651 | ALIAS (show_bgp_community_all, |
| 6652 | show_bgp_ipv6_community_all_cmd, |
| 6653 | "show bgp ipv6 community", |
| 6654 | SHOW_STR |
| 6655 | BGP_STR |
| 6656 | "Address family\n" |
| 6657 | "Display routes matching the communities\n") |
| 6658 | |
| 6659 | /* old command */ |
| 6660 | DEFUN (show_ipv6_bgp_community_all, |
| 6661 | show_ipv6_bgp_community_all_cmd, |
| 6662 | "show ipv6 bgp community", |
| 6663 | SHOW_STR |
| 6664 | IPV6_STR |
| 6665 | BGP_STR |
| 6666 | "Display routes matching the communities\n") |
| 6667 | { |
| 6668 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6669 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6670 | } |
| 6671 | |
| 6672 | /* old command */ |
| 6673 | DEFUN (show_ipv6_mbgp_community_all, |
| 6674 | show_ipv6_mbgp_community_all_cmd, |
| 6675 | "show ipv6 mbgp community", |
| 6676 | SHOW_STR |
| 6677 | IPV6_STR |
| 6678 | MBGP_STR |
| 6679 | "Display routes matching the communities\n") |
| 6680 | { |
| 6681 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6682 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6683 | } |
| 6684 | #endif /* HAVE_IPV6 */ |
| 6685 | |
| 6686 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6687 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
| 6688 | u_int16_t afi, u_char safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6689 | { |
| 6690 | struct community *com; |
| 6691 | struct buffer *b; |
| 6692 | int i; |
| 6693 | char *str; |
| 6694 | int first = 0; |
| 6695 | |
| 6696 | b = buffer_new (1024); |
| 6697 | for (i = 0; i < argc; i++) |
| 6698 | { |
| 6699 | if (first) |
| 6700 | buffer_putc (b, ' '); |
| 6701 | else |
| 6702 | { |
| 6703 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6704 | continue; |
| 6705 | first = 1; |
| 6706 | } |
| 6707 | |
| 6708 | buffer_putstr (b, argv[i]); |
| 6709 | } |
| 6710 | buffer_putc (b, '\0'); |
| 6711 | |
| 6712 | str = buffer_getstr (b); |
| 6713 | buffer_free (b); |
| 6714 | |
| 6715 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6716 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6717 | if (! com) |
| 6718 | { |
| 6719 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 6720 | return CMD_WARNING; |
| 6721 | } |
| 6722 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6723 | return bgp_show (vty, NULL, afi, safi, |
| 6724 | (exact ? bgp_show_type_community_exact : |
| 6725 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6726 | } |
| 6727 | |
| 6728 | DEFUN (show_ip_bgp_community, |
| 6729 | show_ip_bgp_community_cmd, |
| 6730 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6731 | SHOW_STR |
| 6732 | IP_STR |
| 6733 | BGP_STR |
| 6734 | "Display routes matching the communities\n" |
| 6735 | "community number\n" |
| 6736 | "Do not send outside local AS (well-known community)\n" |
| 6737 | "Do not advertise to any peer (well-known community)\n" |
| 6738 | "Do not export to next AS (well-known community)\n") |
| 6739 | { |
| 6740 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6741 | } |
| 6742 | |
| 6743 | ALIAS (show_ip_bgp_community, |
| 6744 | show_ip_bgp_community2_cmd, |
| 6745 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6746 | SHOW_STR |
| 6747 | IP_STR |
| 6748 | BGP_STR |
| 6749 | "Display routes matching the communities\n" |
| 6750 | "community number\n" |
| 6751 | "Do not send outside local AS (well-known community)\n" |
| 6752 | "Do not advertise to any peer (well-known community)\n" |
| 6753 | "Do not export to next AS (well-known community)\n" |
| 6754 | "community number\n" |
| 6755 | "Do not send outside local AS (well-known community)\n" |
| 6756 | "Do not advertise to any peer (well-known community)\n" |
| 6757 | "Do not export to next AS (well-known community)\n") |
| 6758 | |
| 6759 | ALIAS (show_ip_bgp_community, |
| 6760 | show_ip_bgp_community3_cmd, |
| 6761 | "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)", |
| 6762 | SHOW_STR |
| 6763 | IP_STR |
| 6764 | BGP_STR |
| 6765 | "Display routes matching the communities\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 | "community number\n" |
| 6775 | "Do not send outside local AS (well-known community)\n" |
| 6776 | "Do not advertise to any peer (well-known community)\n" |
| 6777 | "Do not export to next AS (well-known community)\n") |
| 6778 | |
| 6779 | ALIAS (show_ip_bgp_community, |
| 6780 | show_ip_bgp_community4_cmd, |
| 6781 | "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)", |
| 6782 | SHOW_STR |
| 6783 | IP_STR |
| 6784 | BGP_STR |
| 6785 | "Display routes matching the communities\n" |
| 6786 | "community number\n" |
| 6787 | "Do not send outside local AS (well-known community)\n" |
| 6788 | "Do not advertise to any peer (well-known community)\n" |
| 6789 | "Do not export to next AS (well-known community)\n" |
| 6790 | "community number\n" |
| 6791 | "Do not send outside local AS (well-known community)\n" |
| 6792 | "Do not advertise to any peer (well-known community)\n" |
| 6793 | "Do not export to next AS (well-known community)\n" |
| 6794 | "community number\n" |
| 6795 | "Do not send outside local AS (well-known community)\n" |
| 6796 | "Do not advertise to any peer (well-known community)\n" |
| 6797 | "Do not export to next AS (well-known community)\n" |
| 6798 | "community number\n" |
| 6799 | "Do not send outside local AS (well-known community)\n" |
| 6800 | "Do not advertise to any peer (well-known community)\n" |
| 6801 | "Do not export to next AS (well-known community)\n") |
| 6802 | |
| 6803 | DEFUN (show_ip_bgp_ipv4_community, |
| 6804 | show_ip_bgp_ipv4_community_cmd, |
| 6805 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 6806 | SHOW_STR |
| 6807 | IP_STR |
| 6808 | BGP_STR |
| 6809 | "Address family\n" |
| 6810 | "Address Family modifier\n" |
| 6811 | "Address Family modifier\n" |
| 6812 | "Display routes matching the communities\n" |
| 6813 | "community number\n" |
| 6814 | "Do not send outside local AS (well-known community)\n" |
| 6815 | "Do not advertise to any peer (well-known community)\n" |
| 6816 | "Do not export to next AS (well-known community)\n") |
| 6817 | { |
| 6818 | if (strncmp (argv[0], "m", 1) == 0) |
| 6819 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 6820 | |
| 6821 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6822 | } |
| 6823 | |
| 6824 | ALIAS (show_ip_bgp_ipv4_community, |
| 6825 | show_ip_bgp_ipv4_community2_cmd, |
| 6826 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6827 | SHOW_STR |
| 6828 | IP_STR |
| 6829 | BGP_STR |
| 6830 | "Address family\n" |
| 6831 | "Address Family modifier\n" |
| 6832 | "Address Family modifier\n" |
| 6833 | "Display routes matching the communities\n" |
| 6834 | "community number\n" |
| 6835 | "Do not send outside local AS (well-known community)\n" |
| 6836 | "Do not advertise to any peer (well-known community)\n" |
| 6837 | "Do not export to next AS (well-known community)\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 | |
| 6843 | ALIAS (show_ip_bgp_ipv4_community, |
| 6844 | show_ip_bgp_ipv4_community3_cmd, |
| 6845 | "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)", |
| 6846 | SHOW_STR |
| 6847 | IP_STR |
| 6848 | BGP_STR |
| 6849 | "Address family\n" |
| 6850 | "Address Family modifier\n" |
| 6851 | "Address Family modifier\n" |
| 6852 | "Display routes matching the communities\n" |
| 6853 | "community number\n" |
| 6854 | "Do not send outside local AS (well-known community)\n" |
| 6855 | "Do not advertise to any peer (well-known community)\n" |
| 6856 | "Do not export to next AS (well-known community)\n" |
| 6857 | "community number\n" |
| 6858 | "Do not send outside local AS (well-known community)\n" |
| 6859 | "Do not advertise to any peer (well-known community)\n" |
| 6860 | "Do not export to next AS (well-known community)\n" |
| 6861 | "community number\n" |
| 6862 | "Do not send outside local AS (well-known community)\n" |
| 6863 | "Do not advertise to any peer (well-known community)\n" |
| 6864 | "Do not export to next AS (well-known community)\n") |
| 6865 | |
| 6866 | ALIAS (show_ip_bgp_ipv4_community, |
| 6867 | show_ip_bgp_ipv4_community4_cmd, |
| 6868 | "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)", |
| 6869 | SHOW_STR |
| 6870 | IP_STR |
| 6871 | BGP_STR |
| 6872 | "Address family\n" |
| 6873 | "Address Family modifier\n" |
| 6874 | "Address Family modifier\n" |
| 6875 | "Display routes matching the communities\n" |
| 6876 | "community number\n" |
| 6877 | "Do not send outside local AS (well-known community)\n" |
| 6878 | "Do not advertise to any peer (well-known community)\n" |
| 6879 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 6889 | "Do not send outside local AS (well-known community)\n" |
| 6890 | "Do not advertise to any peer (well-known community)\n" |
| 6891 | "Do not export to next AS (well-known community)\n") |
| 6892 | |
| 6893 | DEFUN (show_ip_bgp_community_exact, |
| 6894 | show_ip_bgp_community_exact_cmd, |
| 6895 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6896 | SHOW_STR |
| 6897 | IP_STR |
| 6898 | BGP_STR |
| 6899 | "Display routes matching the communities\n" |
| 6900 | "community number\n" |
| 6901 | "Do not send outside local AS (well-known community)\n" |
| 6902 | "Do not advertise to any peer (well-known community)\n" |
| 6903 | "Do not export to next AS (well-known community)\n" |
| 6904 | "Exact match of the communities") |
| 6905 | { |
| 6906 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 6907 | } |
| 6908 | |
| 6909 | ALIAS (show_ip_bgp_community_exact, |
| 6910 | show_ip_bgp_community2_exact_cmd, |
| 6911 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6912 | SHOW_STR |
| 6913 | IP_STR |
| 6914 | BGP_STR |
| 6915 | "Display routes matching the communities\n" |
| 6916 | "community number\n" |
| 6917 | "Do not send outside local AS (well-known community)\n" |
| 6918 | "Do not advertise to any peer (well-known community)\n" |
| 6919 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 6925 | |
| 6926 | ALIAS (show_ip_bgp_community_exact, |
| 6927 | show_ip_bgp_community3_exact_cmd, |
| 6928 | "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", |
| 6929 | SHOW_STR |
| 6930 | IP_STR |
| 6931 | BGP_STR |
| 6932 | "Display routes matching the communities\n" |
| 6933 | "community number\n" |
| 6934 | "Do not send outside local AS (well-known community)\n" |
| 6935 | "Do not advertise to any peer (well-known community)\n" |
| 6936 | "Do not export to next AS (well-known community)\n" |
| 6937 | "community number\n" |
| 6938 | "Do not send outside local AS (well-known community)\n" |
| 6939 | "Do not advertise to any peer (well-known community)\n" |
| 6940 | "Do not export to next AS (well-known community)\n" |
| 6941 | "community number\n" |
| 6942 | "Do not send outside local AS (well-known community)\n" |
| 6943 | "Do not advertise to any peer (well-known community)\n" |
| 6944 | "Do not export to next AS (well-known community)\n" |
| 6945 | "Exact match of the communities") |
| 6946 | |
| 6947 | ALIAS (show_ip_bgp_community_exact, |
| 6948 | show_ip_bgp_community4_exact_cmd, |
| 6949 | "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", |
| 6950 | SHOW_STR |
| 6951 | IP_STR |
| 6952 | BGP_STR |
| 6953 | "Display routes matching the communities\n" |
| 6954 | "community number\n" |
| 6955 | "Do not send outside local AS (well-known community)\n" |
| 6956 | "Do not advertise to any peer (well-known community)\n" |
| 6957 | "Do not export to next AS (well-known community)\n" |
| 6958 | "community number\n" |
| 6959 | "Do not send outside local AS (well-known community)\n" |
| 6960 | "Do not advertise to any peer (well-known community)\n" |
| 6961 | "Do not export to next AS (well-known community)\n" |
| 6962 | "community number\n" |
| 6963 | "Do not send outside local AS (well-known community)\n" |
| 6964 | "Do not advertise to any peer (well-known community)\n" |
| 6965 | "Do not export to next AS (well-known community)\n" |
| 6966 | "community number\n" |
| 6967 | "Do not send outside local AS (well-known community)\n" |
| 6968 | "Do not advertise to any peer (well-known community)\n" |
| 6969 | "Do not export to next AS (well-known community)\n" |
| 6970 | "Exact match of the communities") |
| 6971 | |
| 6972 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 6973 | show_ip_bgp_ipv4_community_exact_cmd, |
| 6974 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6975 | SHOW_STR |
| 6976 | IP_STR |
| 6977 | BGP_STR |
| 6978 | "Address family\n" |
| 6979 | "Address Family modifier\n" |
| 6980 | "Address Family modifier\n" |
| 6981 | "Display routes matching the communities\n" |
| 6982 | "community number\n" |
| 6983 | "Do not send outside local AS (well-known community)\n" |
| 6984 | "Do not advertise to any peer (well-known community)\n" |
| 6985 | "Do not export to next AS (well-known community)\n" |
| 6986 | "Exact match of the communities") |
| 6987 | { |
| 6988 | if (strncmp (argv[0], "m", 1) == 0) |
| 6989 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 6990 | |
| 6991 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 6992 | } |
| 6993 | |
| 6994 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 6995 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 6996 | "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", |
| 6997 | SHOW_STR |
| 6998 | IP_STR |
| 6999 | BGP_STR |
| 7000 | "Address family\n" |
| 7001 | "Address Family modifier\n" |
| 7002 | "Address Family modifier\n" |
| 7003 | "Display routes matching the communities\n" |
| 7004 | "community number\n" |
| 7005 | "Do not send outside local AS (well-known community)\n" |
| 7006 | "Do not advertise to any peer (well-known community)\n" |
| 7007 | "Do not export to next AS (well-known community)\n" |
| 7008 | "community number\n" |
| 7009 | "Do not send outside local AS (well-known community)\n" |
| 7010 | "Do not advertise to any peer (well-known community)\n" |
| 7011 | "Do not export to next AS (well-known community)\n" |
| 7012 | "Exact match of the communities") |
| 7013 | |
| 7014 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7015 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 7016 | "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", |
| 7017 | SHOW_STR |
| 7018 | IP_STR |
| 7019 | BGP_STR |
| 7020 | "Address family\n" |
| 7021 | "Address Family modifier\n" |
| 7022 | "Address Family modifier\n" |
| 7023 | "Display routes matching the communities\n" |
| 7024 | "community number\n" |
| 7025 | "Do not send outside local AS (well-known community)\n" |
| 7026 | "Do not advertise to any peer (well-known community)\n" |
| 7027 | "Do not export to next AS (well-known community)\n" |
| 7028 | "community number\n" |
| 7029 | "Do not send outside local AS (well-known community)\n" |
| 7030 | "Do not advertise to any peer (well-known community)\n" |
| 7031 | "Do not export to next AS (well-known community)\n" |
| 7032 | "community number\n" |
| 7033 | "Do not send outside local AS (well-known community)\n" |
| 7034 | "Do not advertise to any peer (well-known community)\n" |
| 7035 | "Do not export to next AS (well-known community)\n" |
| 7036 | "Exact match of the communities") |
| 7037 | |
| 7038 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7039 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 7040 | "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", |
| 7041 | SHOW_STR |
| 7042 | IP_STR |
| 7043 | BGP_STR |
| 7044 | "Address family\n" |
| 7045 | "Address Family modifier\n" |
| 7046 | "Address Family modifier\n" |
| 7047 | "Display routes matching the communities\n" |
| 7048 | "community number\n" |
| 7049 | "Do not send outside local AS (well-known community)\n" |
| 7050 | "Do not advertise to any peer (well-known community)\n" |
| 7051 | "Do not export to next AS (well-known community)\n" |
| 7052 | "community number\n" |
| 7053 | "Do not send outside local AS (well-known community)\n" |
| 7054 | "Do not advertise to any peer (well-known community)\n" |
| 7055 | "Do not export to next AS (well-known community)\n" |
| 7056 | "community number\n" |
| 7057 | "Do not send outside local AS (well-known community)\n" |
| 7058 | "Do not advertise to any peer (well-known community)\n" |
| 7059 | "Do not export to next AS (well-known community)\n" |
| 7060 | "community number\n" |
| 7061 | "Do not send outside local AS (well-known community)\n" |
| 7062 | "Do not advertise to any peer (well-known community)\n" |
| 7063 | "Do not export to next AS (well-known community)\n" |
| 7064 | "Exact match of the communities") |
| 7065 | |
| 7066 | #ifdef HAVE_IPV6 |
| 7067 | DEFUN (show_bgp_community, |
| 7068 | show_bgp_community_cmd, |
| 7069 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7070 | SHOW_STR |
| 7071 | BGP_STR |
| 7072 | "Display routes matching the communities\n" |
| 7073 | "community number\n" |
| 7074 | "Do not send outside local AS (well-known community)\n" |
| 7075 | "Do not advertise to any peer (well-known community)\n" |
| 7076 | "Do not export to next AS (well-known community)\n") |
| 7077 | { |
| 7078 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7079 | } |
| 7080 | |
| 7081 | ALIAS (show_bgp_community, |
| 7082 | show_bgp_ipv6_community_cmd, |
| 7083 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 7084 | SHOW_STR |
| 7085 | BGP_STR |
| 7086 | "Address family\n" |
| 7087 | "Display routes matching the communities\n" |
| 7088 | "community number\n" |
| 7089 | "Do not send outside local AS (well-known community)\n" |
| 7090 | "Do not advertise to any peer (well-known community)\n" |
| 7091 | "Do not export to next AS (well-known community)\n") |
| 7092 | |
| 7093 | ALIAS (show_bgp_community, |
| 7094 | show_bgp_community2_cmd, |
| 7095 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7096 | SHOW_STR |
| 7097 | BGP_STR |
| 7098 | "Display routes matching the communities\n" |
| 7099 | "community number\n" |
| 7100 | "Do not send outside local AS (well-known community)\n" |
| 7101 | "Do not advertise to any peer (well-known community)\n" |
| 7102 | "Do not export to next AS (well-known community)\n" |
| 7103 | "community number\n" |
| 7104 | "Do not send outside local AS (well-known community)\n" |
| 7105 | "Do not advertise to any peer (well-known community)\n" |
| 7106 | "Do not export to next AS (well-known community)\n") |
| 7107 | |
| 7108 | ALIAS (show_bgp_community, |
| 7109 | show_bgp_ipv6_community2_cmd, |
| 7110 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7111 | SHOW_STR |
| 7112 | BGP_STR |
| 7113 | "Address family\n" |
| 7114 | "Display routes matching the communities\n" |
| 7115 | "community number\n" |
| 7116 | "Do not send outside local AS (well-known community)\n" |
| 7117 | "Do not advertise to any peer (well-known community)\n" |
| 7118 | "Do not export to next AS (well-known community)\n" |
| 7119 | "community number\n" |
| 7120 | "Do not send outside local AS (well-known community)\n" |
| 7121 | "Do not advertise to any peer (well-known community)\n" |
| 7122 | "Do not export to next AS (well-known community)\n") |
| 7123 | |
| 7124 | ALIAS (show_bgp_community, |
| 7125 | show_bgp_community3_cmd, |
| 7126 | "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)", |
| 7127 | SHOW_STR |
| 7128 | BGP_STR |
| 7129 | "Display routes matching the communities\n" |
| 7130 | "community number\n" |
| 7131 | "Do not send outside local AS (well-known community)\n" |
| 7132 | "Do not advertise to any peer (well-known community)\n" |
| 7133 | "Do not export to next AS (well-known community)\n" |
| 7134 | "community number\n" |
| 7135 | "Do not send outside local AS (well-known community)\n" |
| 7136 | "Do not advertise to any peer (well-known community)\n" |
| 7137 | "Do not export to next AS (well-known community)\n" |
| 7138 | "community number\n" |
| 7139 | "Do not send outside local AS (well-known community)\n" |
| 7140 | "Do not advertise to any peer (well-known community)\n" |
| 7141 | "Do not export to next AS (well-known community)\n") |
| 7142 | |
| 7143 | ALIAS (show_bgp_community, |
| 7144 | show_bgp_ipv6_community3_cmd, |
| 7145 | "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)", |
| 7146 | SHOW_STR |
| 7147 | BGP_STR |
| 7148 | "Address family\n" |
| 7149 | "Display routes matching the communities\n" |
| 7150 | "community number\n" |
| 7151 | "Do not send outside local AS (well-known community)\n" |
| 7152 | "Do not advertise to any peer (well-known community)\n" |
| 7153 | "Do not export to next AS (well-known community)\n" |
| 7154 | "community number\n" |
| 7155 | "Do not send outside local AS (well-known community)\n" |
| 7156 | "Do not advertise to any peer (well-known community)\n" |
| 7157 | "Do not export to next AS (well-known community)\n" |
| 7158 | "community number\n" |
| 7159 | "Do not send outside local AS (well-known community)\n" |
| 7160 | "Do not advertise to any peer (well-known community)\n" |
| 7161 | "Do not export to next AS (well-known community)\n") |
| 7162 | |
| 7163 | ALIAS (show_bgp_community, |
| 7164 | show_bgp_community4_cmd, |
| 7165 | "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)", |
| 7166 | SHOW_STR |
| 7167 | BGP_STR |
| 7168 | "Display routes matching the communities\n" |
| 7169 | "community number\n" |
| 7170 | "Do not send outside local AS (well-known community)\n" |
| 7171 | "Do not advertise to any peer (well-known community)\n" |
| 7172 | "Do not export to next AS (well-known community)\n" |
| 7173 | "community number\n" |
| 7174 | "Do not send outside local AS (well-known community)\n" |
| 7175 | "Do not advertise to any peer (well-known community)\n" |
| 7176 | "Do not export to next AS (well-known community)\n" |
| 7177 | "community number\n" |
| 7178 | "Do not send outside local AS (well-known community)\n" |
| 7179 | "Do not advertise to any peer (well-known community)\n" |
| 7180 | "Do not export to next AS (well-known community)\n" |
| 7181 | "community number\n" |
| 7182 | "Do not send outside local AS (well-known community)\n" |
| 7183 | "Do not advertise to any peer (well-known community)\n" |
| 7184 | "Do not export to next AS (well-known community)\n") |
| 7185 | |
| 7186 | ALIAS (show_bgp_community, |
| 7187 | show_bgp_ipv6_community4_cmd, |
| 7188 | "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)", |
| 7189 | SHOW_STR |
| 7190 | BGP_STR |
| 7191 | "Address family\n" |
| 7192 | "Display routes matching the communities\n" |
| 7193 | "community number\n" |
| 7194 | "Do not send outside local AS (well-known community)\n" |
| 7195 | "Do not advertise to any peer (well-known community)\n" |
| 7196 | "Do not export to next AS (well-known community)\n" |
| 7197 | "community number\n" |
| 7198 | "Do not send outside local AS (well-known community)\n" |
| 7199 | "Do not advertise to any peer (well-known community)\n" |
| 7200 | "Do not export to next AS (well-known community)\n" |
| 7201 | "community number\n" |
| 7202 | "Do not send outside local AS (well-known community)\n" |
| 7203 | "Do not advertise to any peer (well-known community)\n" |
| 7204 | "Do not export to next AS (well-known community)\n" |
| 7205 | "community number\n" |
| 7206 | "Do not send outside local AS (well-known community)\n" |
| 7207 | "Do not advertise to any peer (well-known community)\n" |
| 7208 | "Do not export to next AS (well-known community)\n") |
| 7209 | |
| 7210 | /* old command */ |
| 7211 | DEFUN (show_ipv6_bgp_community, |
| 7212 | show_ipv6_bgp_community_cmd, |
| 7213 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7214 | SHOW_STR |
| 7215 | IPV6_STR |
| 7216 | BGP_STR |
| 7217 | "Display routes matching the communities\n" |
| 7218 | "community number\n" |
| 7219 | "Do not send outside local AS (well-known community)\n" |
| 7220 | "Do not advertise to any peer (well-known community)\n" |
| 7221 | "Do not export to next AS (well-known community)\n") |
| 7222 | { |
| 7223 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7224 | } |
| 7225 | |
| 7226 | /* old command */ |
| 7227 | ALIAS (show_ipv6_bgp_community, |
| 7228 | show_ipv6_bgp_community2_cmd, |
| 7229 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7230 | SHOW_STR |
| 7231 | IPV6_STR |
| 7232 | BGP_STR |
| 7233 | "Display routes matching the communities\n" |
| 7234 | "community number\n" |
| 7235 | "Do not send outside local AS (well-known community)\n" |
| 7236 | "Do not advertise to any peer (well-known community)\n" |
| 7237 | "Do not export to next AS (well-known community)\n" |
| 7238 | "community number\n" |
| 7239 | "Do not send outside local AS (well-known community)\n" |
| 7240 | "Do not advertise to any peer (well-known community)\n" |
| 7241 | "Do not export to next AS (well-known community)\n") |
| 7242 | |
| 7243 | /* old command */ |
| 7244 | ALIAS (show_ipv6_bgp_community, |
| 7245 | show_ipv6_bgp_community3_cmd, |
| 7246 | "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)", |
| 7247 | SHOW_STR |
| 7248 | IPV6_STR |
| 7249 | BGP_STR |
| 7250 | "Display routes matching the communities\n" |
| 7251 | "community number\n" |
| 7252 | "Do not send outside local AS (well-known community)\n" |
| 7253 | "Do not advertise to any peer (well-known community)\n" |
| 7254 | "Do not export to next AS (well-known community)\n" |
| 7255 | "community number\n" |
| 7256 | "Do not send outside local AS (well-known community)\n" |
| 7257 | "Do not advertise to any peer (well-known community)\n" |
| 7258 | "Do not export to next AS (well-known community)\n" |
| 7259 | "community number\n" |
| 7260 | "Do not send outside local AS (well-known community)\n" |
| 7261 | "Do not advertise to any peer (well-known community)\n" |
| 7262 | "Do not export to next AS (well-known community)\n") |
| 7263 | |
| 7264 | /* old command */ |
| 7265 | ALIAS (show_ipv6_bgp_community, |
| 7266 | show_ipv6_bgp_community4_cmd, |
| 7267 | "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)", |
| 7268 | SHOW_STR |
| 7269 | IPV6_STR |
| 7270 | BGP_STR |
| 7271 | "Display routes matching the communities\n" |
| 7272 | "community number\n" |
| 7273 | "Do not send outside local AS (well-known community)\n" |
| 7274 | "Do not advertise to any peer (well-known community)\n" |
| 7275 | "Do not export to next AS (well-known community)\n" |
| 7276 | "community number\n" |
| 7277 | "Do not send outside local AS (well-known community)\n" |
| 7278 | "Do not advertise to any peer (well-known community)\n" |
| 7279 | "Do not export to next AS (well-known community)\n" |
| 7280 | "community number\n" |
| 7281 | "Do not send outside local AS (well-known community)\n" |
| 7282 | "Do not advertise to any peer (well-known community)\n" |
| 7283 | "Do not export to next AS (well-known community)\n" |
| 7284 | "community number\n" |
| 7285 | "Do not send outside local AS (well-known community)\n" |
| 7286 | "Do not advertise to any peer (well-known community)\n" |
| 7287 | "Do not export to next AS (well-known community)\n") |
| 7288 | |
| 7289 | DEFUN (show_bgp_community_exact, |
| 7290 | show_bgp_community_exact_cmd, |
| 7291 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7292 | SHOW_STR |
| 7293 | BGP_STR |
| 7294 | "Display routes matching the communities\n" |
| 7295 | "community number\n" |
| 7296 | "Do not send outside local AS (well-known community)\n" |
| 7297 | "Do not advertise to any peer (well-known community)\n" |
| 7298 | "Do not export to next AS (well-known community)\n" |
| 7299 | "Exact match of the communities") |
| 7300 | { |
| 7301 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7302 | } |
| 7303 | |
| 7304 | ALIAS (show_bgp_community_exact, |
| 7305 | show_bgp_ipv6_community_exact_cmd, |
| 7306 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7307 | SHOW_STR |
| 7308 | BGP_STR |
| 7309 | "Address family\n" |
| 7310 | "Display routes matching the communities\n" |
| 7311 | "community number\n" |
| 7312 | "Do not send outside local AS (well-known community)\n" |
| 7313 | "Do not advertise to any peer (well-known community)\n" |
| 7314 | "Do not export to next AS (well-known community)\n" |
| 7315 | "Exact match of the communities") |
| 7316 | |
| 7317 | ALIAS (show_bgp_community_exact, |
| 7318 | show_bgp_community2_exact_cmd, |
| 7319 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7320 | SHOW_STR |
| 7321 | BGP_STR |
| 7322 | "Display routes matching the communities\n" |
| 7323 | "community number\n" |
| 7324 | "Do not send outside local AS (well-known community)\n" |
| 7325 | "Do not advertise to any peer (well-known community)\n" |
| 7326 | "Do not export to next AS (well-known community)\n" |
| 7327 | "community number\n" |
| 7328 | "Do not send outside local AS (well-known community)\n" |
| 7329 | "Do not advertise to any peer (well-known community)\n" |
| 7330 | "Do not export to next AS (well-known community)\n" |
| 7331 | "Exact match of the communities") |
| 7332 | |
| 7333 | ALIAS (show_bgp_community_exact, |
| 7334 | show_bgp_ipv6_community2_exact_cmd, |
| 7335 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7336 | SHOW_STR |
| 7337 | BGP_STR |
| 7338 | "Address family\n" |
| 7339 | "Display routes matching the communities\n" |
| 7340 | "community number\n" |
| 7341 | "Do not send outside local AS (well-known community)\n" |
| 7342 | "Do not advertise to any peer (well-known community)\n" |
| 7343 | "Do not export to next AS (well-known community)\n" |
| 7344 | "community number\n" |
| 7345 | "Do not send outside local AS (well-known community)\n" |
| 7346 | "Do not advertise to any peer (well-known community)\n" |
| 7347 | "Do not export to next AS (well-known community)\n" |
| 7348 | "Exact match of the communities") |
| 7349 | |
| 7350 | ALIAS (show_bgp_community_exact, |
| 7351 | show_bgp_community3_exact_cmd, |
| 7352 | "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", |
| 7353 | SHOW_STR |
| 7354 | BGP_STR |
| 7355 | "Display routes matching the communities\n" |
| 7356 | "community number\n" |
| 7357 | "Do not send outside local AS (well-known community)\n" |
| 7358 | "Do not advertise to any peer (well-known community)\n" |
| 7359 | "Do not export to next AS (well-known community)\n" |
| 7360 | "community number\n" |
| 7361 | "Do not send outside local AS (well-known community)\n" |
| 7362 | "Do not advertise to any peer (well-known community)\n" |
| 7363 | "Do not export to next AS (well-known community)\n" |
| 7364 | "community number\n" |
| 7365 | "Do not send outside local AS (well-known community)\n" |
| 7366 | "Do not advertise to any peer (well-known community)\n" |
| 7367 | "Do not export to next AS (well-known community)\n" |
| 7368 | "Exact match of the communities") |
| 7369 | |
| 7370 | ALIAS (show_bgp_community_exact, |
| 7371 | show_bgp_ipv6_community3_exact_cmd, |
| 7372 | "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", |
| 7373 | SHOW_STR |
| 7374 | BGP_STR |
| 7375 | "Address family\n" |
| 7376 | "Display routes matching the communities\n" |
| 7377 | "community number\n" |
| 7378 | "Do not send outside local AS (well-known community)\n" |
| 7379 | "Do not advertise to any peer (well-known community)\n" |
| 7380 | "Do not export to next AS (well-known community)\n" |
| 7381 | "community number\n" |
| 7382 | "Do not send outside local AS (well-known community)\n" |
| 7383 | "Do not advertise to any peer (well-known community)\n" |
| 7384 | "Do not export to next AS (well-known community)\n" |
| 7385 | "community number\n" |
| 7386 | "Do not send outside local AS (well-known community)\n" |
| 7387 | "Do not advertise to any peer (well-known community)\n" |
| 7388 | "Do not export to next AS (well-known community)\n" |
| 7389 | "Exact match of the communities") |
| 7390 | |
| 7391 | ALIAS (show_bgp_community_exact, |
| 7392 | show_bgp_community4_exact_cmd, |
| 7393 | "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", |
| 7394 | SHOW_STR |
| 7395 | BGP_STR |
| 7396 | "Display routes matching the communities\n" |
| 7397 | "community number\n" |
| 7398 | "Do not send outside local AS (well-known community)\n" |
| 7399 | "Do not advertise to any peer (well-known community)\n" |
| 7400 | "Do not export to next AS (well-known community)\n" |
| 7401 | "community number\n" |
| 7402 | "Do not send outside local AS (well-known community)\n" |
| 7403 | "Do not advertise to any peer (well-known community)\n" |
| 7404 | "Do not export to next AS (well-known community)\n" |
| 7405 | "community number\n" |
| 7406 | "Do not send outside local AS (well-known community)\n" |
| 7407 | "Do not advertise to any peer (well-known community)\n" |
| 7408 | "Do not export to next AS (well-known community)\n" |
| 7409 | "community number\n" |
| 7410 | "Do not send outside local AS (well-known community)\n" |
| 7411 | "Do not advertise to any peer (well-known community)\n" |
| 7412 | "Do not export to next AS (well-known community)\n" |
| 7413 | "Exact match of the communities") |
| 7414 | |
| 7415 | ALIAS (show_bgp_community_exact, |
| 7416 | show_bgp_ipv6_community4_exact_cmd, |
| 7417 | "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", |
| 7418 | SHOW_STR |
| 7419 | BGP_STR |
| 7420 | "Address family\n" |
| 7421 | "Display routes matching the communities\n" |
| 7422 | "community number\n" |
| 7423 | "Do not send outside local AS (well-known community)\n" |
| 7424 | "Do not advertise to any peer (well-known community)\n" |
| 7425 | "Do not export to next AS (well-known community)\n" |
| 7426 | "community number\n" |
| 7427 | "Do not send outside local AS (well-known community)\n" |
| 7428 | "Do not advertise to any peer (well-known community)\n" |
| 7429 | "Do not export to next AS (well-known community)\n" |
| 7430 | "community number\n" |
| 7431 | "Do not send outside local AS (well-known community)\n" |
| 7432 | "Do not advertise to any peer (well-known community)\n" |
| 7433 | "Do not export to next AS (well-known community)\n" |
| 7434 | "community number\n" |
| 7435 | "Do not send outside local AS (well-known community)\n" |
| 7436 | "Do not advertise to any peer (well-known community)\n" |
| 7437 | "Do not export to next AS (well-known community)\n" |
| 7438 | "Exact match of the communities") |
| 7439 | |
| 7440 | /* old command */ |
| 7441 | DEFUN (show_ipv6_bgp_community_exact, |
| 7442 | show_ipv6_bgp_community_exact_cmd, |
| 7443 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7444 | SHOW_STR |
| 7445 | IPV6_STR |
| 7446 | BGP_STR |
| 7447 | "Display routes matching the communities\n" |
| 7448 | "community number\n" |
| 7449 | "Do not send outside local AS (well-known community)\n" |
| 7450 | "Do not advertise to any peer (well-known community)\n" |
| 7451 | "Do not export to next AS (well-known community)\n" |
| 7452 | "Exact match of the communities") |
| 7453 | { |
| 7454 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7455 | } |
| 7456 | |
| 7457 | /* old command */ |
| 7458 | ALIAS (show_ipv6_bgp_community_exact, |
| 7459 | show_ipv6_bgp_community2_exact_cmd, |
| 7460 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7461 | SHOW_STR |
| 7462 | IPV6_STR |
| 7463 | BGP_STR |
| 7464 | "Display routes matching the communities\n" |
| 7465 | "community number\n" |
| 7466 | "Do not send outside local AS (well-known community)\n" |
| 7467 | "Do not advertise to any peer (well-known community)\n" |
| 7468 | "Do not export to next AS (well-known community)\n" |
| 7469 | "community number\n" |
| 7470 | "Do not send outside local AS (well-known community)\n" |
| 7471 | "Do not advertise to any peer (well-known community)\n" |
| 7472 | "Do not export to next AS (well-known community)\n" |
| 7473 | "Exact match of the communities") |
| 7474 | |
| 7475 | /* old command */ |
| 7476 | ALIAS (show_ipv6_bgp_community_exact, |
| 7477 | show_ipv6_bgp_community3_exact_cmd, |
| 7478 | "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", |
| 7479 | SHOW_STR |
| 7480 | IPV6_STR |
| 7481 | BGP_STR |
| 7482 | "Display routes matching the communities\n" |
| 7483 | "community number\n" |
| 7484 | "Do not send outside local AS (well-known community)\n" |
| 7485 | "Do not advertise to any peer (well-known community)\n" |
| 7486 | "Do not export to next AS (well-known community)\n" |
| 7487 | "community number\n" |
| 7488 | "Do not send outside local AS (well-known community)\n" |
| 7489 | "Do not advertise to any peer (well-known community)\n" |
| 7490 | "Do not export to next AS (well-known community)\n" |
| 7491 | "community number\n" |
| 7492 | "Do not send outside local AS (well-known community)\n" |
| 7493 | "Do not advertise to any peer (well-known community)\n" |
| 7494 | "Do not export to next AS (well-known community)\n" |
| 7495 | "Exact match of the communities") |
| 7496 | |
| 7497 | /* old command */ |
| 7498 | ALIAS (show_ipv6_bgp_community_exact, |
| 7499 | show_ipv6_bgp_community4_exact_cmd, |
| 7500 | "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", |
| 7501 | SHOW_STR |
| 7502 | IPV6_STR |
| 7503 | BGP_STR |
| 7504 | "Display routes matching the communities\n" |
| 7505 | "community number\n" |
| 7506 | "Do not send outside local AS (well-known community)\n" |
| 7507 | "Do not advertise to any peer (well-known community)\n" |
| 7508 | "Do not export to next AS (well-known community)\n" |
| 7509 | "community number\n" |
| 7510 | "Do not send outside local AS (well-known community)\n" |
| 7511 | "Do not advertise to any peer (well-known community)\n" |
| 7512 | "Do not export to next AS (well-known community)\n" |
| 7513 | "community number\n" |
| 7514 | "Do not send outside local AS (well-known community)\n" |
| 7515 | "Do not advertise to any peer (well-known community)\n" |
| 7516 | "Do not export to next AS (well-known community)\n" |
| 7517 | "community number\n" |
| 7518 | "Do not send outside local AS (well-known community)\n" |
| 7519 | "Do not advertise to any peer (well-known community)\n" |
| 7520 | "Do not export to next AS (well-known community)\n" |
| 7521 | "Exact match of the communities") |
| 7522 | |
| 7523 | /* old command */ |
| 7524 | DEFUN (show_ipv6_mbgp_community, |
| 7525 | show_ipv6_mbgp_community_cmd, |
| 7526 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7527 | SHOW_STR |
| 7528 | IPV6_STR |
| 7529 | MBGP_STR |
| 7530 | "Display routes matching the communities\n" |
| 7531 | "community number\n" |
| 7532 | "Do not send outside local AS (well-known community)\n" |
| 7533 | "Do not advertise to any peer (well-known community)\n" |
| 7534 | "Do not export to next AS (well-known community)\n") |
| 7535 | { |
| 7536 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 7537 | } |
| 7538 | |
| 7539 | /* old command */ |
| 7540 | ALIAS (show_ipv6_mbgp_community, |
| 7541 | show_ipv6_mbgp_community2_cmd, |
| 7542 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7543 | SHOW_STR |
| 7544 | IPV6_STR |
| 7545 | MBGP_STR |
| 7546 | "Display routes matching the communities\n" |
| 7547 | "community number\n" |
| 7548 | "Do not send outside local AS (well-known community)\n" |
| 7549 | "Do not advertise to any peer (well-known community)\n" |
| 7550 | "Do not export to next AS (well-known community)\n" |
| 7551 | "community number\n" |
| 7552 | "Do not send outside local AS (well-known community)\n" |
| 7553 | "Do not advertise to any peer (well-known community)\n" |
| 7554 | "Do not export to next AS (well-known community)\n") |
| 7555 | |
| 7556 | /* old command */ |
| 7557 | ALIAS (show_ipv6_mbgp_community, |
| 7558 | show_ipv6_mbgp_community3_cmd, |
| 7559 | "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)", |
| 7560 | SHOW_STR |
| 7561 | IPV6_STR |
| 7562 | MBGP_STR |
| 7563 | "Display routes matching the communities\n" |
| 7564 | "community number\n" |
| 7565 | "Do not send outside local AS (well-known community)\n" |
| 7566 | "Do not advertise to any peer (well-known community)\n" |
| 7567 | "Do not export to next AS (well-known community)\n" |
| 7568 | "community number\n" |
| 7569 | "Do not send outside local AS (well-known community)\n" |
| 7570 | "Do not advertise to any peer (well-known community)\n" |
| 7571 | "Do not export to next AS (well-known community)\n" |
| 7572 | "community number\n" |
| 7573 | "Do not send outside local AS (well-known community)\n" |
| 7574 | "Do not advertise to any peer (well-known community)\n" |
| 7575 | "Do not export to next AS (well-known community)\n") |
| 7576 | |
| 7577 | /* old command */ |
| 7578 | ALIAS (show_ipv6_mbgp_community, |
| 7579 | show_ipv6_mbgp_community4_cmd, |
| 7580 | "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)", |
| 7581 | SHOW_STR |
| 7582 | IPV6_STR |
| 7583 | MBGP_STR |
| 7584 | "Display routes matching the communities\n" |
| 7585 | "community number\n" |
| 7586 | "Do not send outside local AS (well-known community)\n" |
| 7587 | "Do not advertise to any peer (well-known community)\n" |
| 7588 | "Do not export to next AS (well-known community)\n" |
| 7589 | "community number\n" |
| 7590 | "Do not send outside local AS (well-known community)\n" |
| 7591 | "Do not advertise to any peer (well-known community)\n" |
| 7592 | "Do not export to next AS (well-known community)\n" |
| 7593 | "community number\n" |
| 7594 | "Do not send outside local AS (well-known community)\n" |
| 7595 | "Do not advertise to any peer (well-known community)\n" |
| 7596 | "Do not export to next AS (well-known community)\n" |
| 7597 | "community number\n" |
| 7598 | "Do not send outside local AS (well-known community)\n" |
| 7599 | "Do not advertise to any peer (well-known community)\n" |
| 7600 | "Do not export to next AS (well-known community)\n") |
| 7601 | |
| 7602 | /* old command */ |
| 7603 | DEFUN (show_ipv6_mbgp_community_exact, |
| 7604 | show_ipv6_mbgp_community_exact_cmd, |
| 7605 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7606 | SHOW_STR |
| 7607 | IPV6_STR |
| 7608 | MBGP_STR |
| 7609 | "Display routes matching the communities\n" |
| 7610 | "community number\n" |
| 7611 | "Do not send outside local AS (well-known community)\n" |
| 7612 | "Do not advertise to any peer (well-known community)\n" |
| 7613 | "Do not export to next AS (well-known community)\n" |
| 7614 | "Exact match of the communities") |
| 7615 | { |
| 7616 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 7617 | } |
| 7618 | |
| 7619 | /* old command */ |
| 7620 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7621 | show_ipv6_mbgp_community2_exact_cmd, |
| 7622 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7623 | SHOW_STR |
| 7624 | IPV6_STR |
| 7625 | MBGP_STR |
| 7626 | "Display routes matching the communities\n" |
| 7627 | "community number\n" |
| 7628 | "Do not send outside local AS (well-known community)\n" |
| 7629 | "Do not advertise to any peer (well-known community)\n" |
| 7630 | "Do not export to next AS (well-known community)\n" |
| 7631 | "community number\n" |
| 7632 | "Do not send outside local AS (well-known community)\n" |
| 7633 | "Do not advertise to any peer (well-known community)\n" |
| 7634 | "Do not export to next AS (well-known community)\n" |
| 7635 | "Exact match of the communities") |
| 7636 | |
| 7637 | /* old command */ |
| 7638 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7639 | show_ipv6_mbgp_community3_exact_cmd, |
| 7640 | "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", |
| 7641 | SHOW_STR |
| 7642 | IPV6_STR |
| 7643 | MBGP_STR |
| 7644 | "Display routes matching the communities\n" |
| 7645 | "community number\n" |
| 7646 | "Do not send outside local AS (well-known community)\n" |
| 7647 | "Do not advertise to any peer (well-known community)\n" |
| 7648 | "Do not export to next AS (well-known community)\n" |
| 7649 | "community number\n" |
| 7650 | "Do not send outside local AS (well-known community)\n" |
| 7651 | "Do not advertise to any peer (well-known community)\n" |
| 7652 | "Do not export to next AS (well-known community)\n" |
| 7653 | "community number\n" |
| 7654 | "Do not send outside local AS (well-known community)\n" |
| 7655 | "Do not advertise to any peer (well-known community)\n" |
| 7656 | "Do not export to next AS (well-known community)\n" |
| 7657 | "Exact match of the communities") |
| 7658 | |
| 7659 | /* old command */ |
| 7660 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7661 | show_ipv6_mbgp_community4_exact_cmd, |
| 7662 | "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", |
| 7663 | SHOW_STR |
| 7664 | IPV6_STR |
| 7665 | MBGP_STR |
| 7666 | "Display routes matching the communities\n" |
| 7667 | "community number\n" |
| 7668 | "Do not send outside local AS (well-known community)\n" |
| 7669 | "Do not advertise to any peer (well-known community)\n" |
| 7670 | "Do not export to next AS (well-known community)\n" |
| 7671 | "community number\n" |
| 7672 | "Do not send outside local AS (well-known community)\n" |
| 7673 | "Do not advertise to any peer (well-known community)\n" |
| 7674 | "Do not export to next AS (well-known community)\n" |
| 7675 | "community number\n" |
| 7676 | "Do not send outside local AS (well-known community)\n" |
| 7677 | "Do not advertise to any peer (well-known community)\n" |
| 7678 | "Do not export to next AS (well-known community)\n" |
| 7679 | "community number\n" |
| 7680 | "Do not send outside local AS (well-known community)\n" |
| 7681 | "Do not advertise to any peer (well-known community)\n" |
| 7682 | "Do not export to next AS (well-known community)\n" |
| 7683 | "Exact match of the communities") |
| 7684 | #endif /* HAVE_IPV6 */ |
| 7685 | |
| 7686 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7687 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7688 | u_int16_t afi, u_char safi) |
| 7689 | { |
| 7690 | struct community_list *list; |
| 7691 | |
| 7692 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_AUTO); |
| 7693 | if (list == NULL) |
| 7694 | { |
| 7695 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 7696 | VTY_NEWLINE); |
| 7697 | return CMD_WARNING; |
| 7698 | } |
| 7699 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7700 | return bgp_show (vty, NULL, afi, safi, |
| 7701 | (exact ? bgp_show_type_community_list_exact : |
| 7702 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7703 | } |
| 7704 | |
| 7705 | DEFUN (show_ip_bgp_community_list, |
| 7706 | show_ip_bgp_community_list_cmd, |
| 7707 | "show ip bgp community-list WORD", |
| 7708 | SHOW_STR |
| 7709 | IP_STR |
| 7710 | BGP_STR |
| 7711 | "Display routes matching the community-list\n" |
| 7712 | "community-list name\n") |
| 7713 | { |
| 7714 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 7715 | } |
| 7716 | |
| 7717 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 7718 | show_ip_bgp_ipv4_community_list_cmd, |
| 7719 | "show ip bgp ipv4 (unicast|multicast) community-list WORD", |
| 7720 | SHOW_STR |
| 7721 | IP_STR |
| 7722 | BGP_STR |
| 7723 | "Address family\n" |
| 7724 | "Address Family modifier\n" |
| 7725 | "Address Family modifier\n" |
| 7726 | "Display routes matching the community-list\n" |
| 7727 | "community-list name\n") |
| 7728 | { |
| 7729 | if (strncmp (argv[0], "m", 1) == 0) |
| 7730 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 7731 | |
| 7732 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 7733 | } |
| 7734 | |
| 7735 | DEFUN (show_ip_bgp_community_list_exact, |
| 7736 | show_ip_bgp_community_list_exact_cmd, |
| 7737 | "show ip bgp community-list WORD exact-match", |
| 7738 | SHOW_STR |
| 7739 | IP_STR |
| 7740 | BGP_STR |
| 7741 | "Display routes matching the community-list\n" |
| 7742 | "community-list name\n" |
| 7743 | "Exact match of the communities\n") |
| 7744 | { |
| 7745 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 7746 | } |
| 7747 | |
| 7748 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 7749 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 7750 | "show ip bgp ipv4 (unicast|multicast) community-list WORD exact-match", |
| 7751 | SHOW_STR |
| 7752 | IP_STR |
| 7753 | BGP_STR |
| 7754 | "Address family\n" |
| 7755 | "Address Family modifier\n" |
| 7756 | "Address Family modifier\n" |
| 7757 | "Display routes matching the community-list\n" |
| 7758 | "community-list name\n" |
| 7759 | "Exact match of the communities\n") |
| 7760 | { |
| 7761 | if (strncmp (argv[0], "m", 1) == 0) |
| 7762 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 7763 | |
| 7764 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 7765 | } |
| 7766 | |
| 7767 | #ifdef HAVE_IPV6 |
| 7768 | DEFUN (show_bgp_community_list, |
| 7769 | show_bgp_community_list_cmd, |
| 7770 | "show bgp community-list WORD", |
| 7771 | SHOW_STR |
| 7772 | BGP_STR |
| 7773 | "Display routes matching the community-list\n" |
| 7774 | "community-list name\n") |
| 7775 | { |
| 7776 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7777 | } |
| 7778 | |
| 7779 | ALIAS (show_bgp_community_list, |
| 7780 | show_bgp_ipv6_community_list_cmd, |
| 7781 | "show bgp ipv6 community-list WORD", |
| 7782 | SHOW_STR |
| 7783 | BGP_STR |
| 7784 | "Address family\n" |
| 7785 | "Display routes matching the community-list\n" |
| 7786 | "community-list name\n") |
| 7787 | |
| 7788 | /* old command */ |
| 7789 | DEFUN (show_ipv6_bgp_community_list, |
| 7790 | show_ipv6_bgp_community_list_cmd, |
| 7791 | "show ipv6 bgp community-list WORD", |
| 7792 | SHOW_STR |
| 7793 | IPV6_STR |
| 7794 | BGP_STR |
| 7795 | "Display routes matching the community-list\n" |
| 7796 | "community-list name\n") |
| 7797 | { |
| 7798 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7799 | } |
| 7800 | |
| 7801 | /* old command */ |
| 7802 | DEFUN (show_ipv6_mbgp_community_list, |
| 7803 | show_ipv6_mbgp_community_list_cmd, |
| 7804 | "show ipv6 mbgp community-list WORD", |
| 7805 | SHOW_STR |
| 7806 | IPV6_STR |
| 7807 | MBGP_STR |
| 7808 | "Display routes matching the community-list\n" |
| 7809 | "community-list name\n") |
| 7810 | { |
| 7811 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 7812 | } |
| 7813 | |
| 7814 | DEFUN (show_bgp_community_list_exact, |
| 7815 | show_bgp_community_list_exact_cmd, |
| 7816 | "show bgp community-list WORD exact-match", |
| 7817 | SHOW_STR |
| 7818 | BGP_STR |
| 7819 | "Display routes matching the community-list\n" |
| 7820 | "community-list name\n" |
| 7821 | "Exact match of the communities\n") |
| 7822 | { |
| 7823 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7824 | } |
| 7825 | |
| 7826 | ALIAS (show_bgp_community_list_exact, |
| 7827 | show_bgp_ipv6_community_list_exact_cmd, |
| 7828 | "show bgp ipv6 community-list WORD exact-match", |
| 7829 | SHOW_STR |
| 7830 | BGP_STR |
| 7831 | "Address family\n" |
| 7832 | "Display routes matching the community-list\n" |
| 7833 | "community-list name\n" |
| 7834 | "Exact match of the communities\n") |
| 7835 | |
| 7836 | /* old command */ |
| 7837 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 7838 | show_ipv6_bgp_community_list_exact_cmd, |
| 7839 | "show ipv6 bgp community-list WORD exact-match", |
| 7840 | SHOW_STR |
| 7841 | IPV6_STR |
| 7842 | BGP_STR |
| 7843 | "Display routes matching the community-list\n" |
| 7844 | "community-list name\n" |
| 7845 | "Exact match of the communities\n") |
| 7846 | { |
| 7847 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7848 | } |
| 7849 | |
| 7850 | /* old command */ |
| 7851 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 7852 | show_ipv6_mbgp_community_list_exact_cmd, |
| 7853 | "show ipv6 mbgp community-list WORD exact-match", |
| 7854 | SHOW_STR |
| 7855 | IPV6_STR |
| 7856 | MBGP_STR |
| 7857 | "Display routes matching the community-list\n" |
| 7858 | "community-list name\n" |
| 7859 | "Exact match of the communities\n") |
| 7860 | { |
| 7861 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 7862 | } |
| 7863 | #endif /* HAVE_IPV6 */ |
| 7864 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7865 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7866 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7867 | safi_t safi, enum bgp_show_type type) |
| 7868 | { |
| 7869 | int ret; |
| 7870 | struct prefix *p; |
| 7871 | |
| 7872 | p = prefix_new(); |
| 7873 | |
| 7874 | ret = str2prefix (prefix, p); |
| 7875 | if (! ret) |
| 7876 | { |
| 7877 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 7878 | return CMD_WARNING; |
| 7879 | } |
| 7880 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7881 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 7882 | prefix_free(p); |
| 7883 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7884 | } |
| 7885 | |
| 7886 | DEFUN (show_ip_bgp_prefix_longer, |
| 7887 | show_ip_bgp_prefix_longer_cmd, |
| 7888 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 7889 | SHOW_STR |
| 7890 | IP_STR |
| 7891 | BGP_STR |
| 7892 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7893 | "Display route and more specific routes\n") |
| 7894 | { |
| 7895 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7896 | bgp_show_type_prefix_longer); |
| 7897 | } |
| 7898 | |
| 7899 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 7900 | show_ip_bgp_flap_prefix_longer_cmd, |
| 7901 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 7902 | SHOW_STR |
| 7903 | IP_STR |
| 7904 | BGP_STR |
| 7905 | "Display flap statistics of routes\n" |
| 7906 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7907 | "Display route and more specific routes\n") |
| 7908 | { |
| 7909 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7910 | bgp_show_type_flap_prefix_longer); |
| 7911 | } |
| 7912 | |
| 7913 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 7914 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 7915 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 7916 | SHOW_STR |
| 7917 | IP_STR |
| 7918 | BGP_STR |
| 7919 | "Address family\n" |
| 7920 | "Address Family modifier\n" |
| 7921 | "Address Family modifier\n" |
| 7922 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7923 | "Display route and more specific routes\n") |
| 7924 | { |
| 7925 | if (strncmp (argv[0], "m", 1) == 0) |
| 7926 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7927 | bgp_show_type_prefix_longer); |
| 7928 | |
| 7929 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7930 | bgp_show_type_prefix_longer); |
| 7931 | } |
| 7932 | |
| 7933 | DEFUN (show_ip_bgp_flap_address, |
| 7934 | show_ip_bgp_flap_address_cmd, |
| 7935 | "show ip bgp flap-statistics A.B.C.D", |
| 7936 | SHOW_STR |
| 7937 | IP_STR |
| 7938 | BGP_STR |
| 7939 | "Display flap statistics of routes\n" |
| 7940 | "Network in the BGP routing table to display\n") |
| 7941 | { |
| 7942 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7943 | bgp_show_type_flap_address); |
| 7944 | } |
| 7945 | |
| 7946 | DEFUN (show_ip_bgp_flap_prefix, |
| 7947 | show_ip_bgp_flap_prefix_cmd, |
| 7948 | "show ip bgp flap-statistics A.B.C.D/M", |
| 7949 | SHOW_STR |
| 7950 | IP_STR |
| 7951 | BGP_STR |
| 7952 | "Display flap statistics of routes\n" |
| 7953 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7954 | { |
| 7955 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7956 | bgp_show_type_flap_prefix); |
| 7957 | } |
| 7958 | #ifdef HAVE_IPV6 |
| 7959 | DEFUN (show_bgp_prefix_longer, |
| 7960 | show_bgp_prefix_longer_cmd, |
| 7961 | "show bgp X:X::X:X/M longer-prefixes", |
| 7962 | SHOW_STR |
| 7963 | BGP_STR |
| 7964 | "IPv6 prefix <network>/<length>\n" |
| 7965 | "Display route and more specific routes\n") |
| 7966 | { |
| 7967 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7968 | bgp_show_type_prefix_longer); |
| 7969 | } |
| 7970 | |
| 7971 | ALIAS (show_bgp_prefix_longer, |
| 7972 | show_bgp_ipv6_prefix_longer_cmd, |
| 7973 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 7974 | SHOW_STR |
| 7975 | BGP_STR |
| 7976 | "Address family\n" |
| 7977 | "IPv6 prefix <network>/<length>\n" |
| 7978 | "Display route and more specific routes\n") |
| 7979 | |
| 7980 | /* old command */ |
| 7981 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 7982 | show_ipv6_bgp_prefix_longer_cmd, |
| 7983 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 7984 | SHOW_STR |
| 7985 | IPV6_STR |
| 7986 | BGP_STR |
| 7987 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 7988 | "Display route and more specific routes\n") |
| 7989 | { |
| 7990 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7991 | bgp_show_type_prefix_longer); |
| 7992 | } |
| 7993 | |
| 7994 | /* old command */ |
| 7995 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 7996 | show_ipv6_mbgp_prefix_longer_cmd, |
| 7997 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 7998 | SHOW_STR |
| 7999 | IPV6_STR |
| 8000 | MBGP_STR |
| 8001 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8002 | "Display route and more specific routes\n") |
| 8003 | { |
| 8004 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8005 | bgp_show_type_prefix_longer); |
| 8006 | } |
| 8007 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8008 | |
| 8009 | struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8010 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 8011 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8012 | { |
| 8013 | int ret; |
| 8014 | struct bgp *bgp; |
| 8015 | struct peer *peer; |
| 8016 | union sockunion su; |
| 8017 | |
| 8018 | /* BGP structure lookup. */ |
| 8019 | if (view_name) |
| 8020 | { |
| 8021 | bgp = bgp_lookup_by_name (view_name); |
| 8022 | if (! bgp) |
| 8023 | { |
| 8024 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8025 | return NULL; |
| 8026 | } |
| 8027 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 8028 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8029 | { |
| 8030 | bgp = bgp_get_default (); |
| 8031 | if (! bgp) |
| 8032 | { |
| 8033 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8034 | return NULL; |
| 8035 | } |
| 8036 | } |
| 8037 | |
| 8038 | /* Get peer sockunion. */ |
| 8039 | ret = str2sockunion (ip_str, &su); |
| 8040 | if (ret < 0) |
| 8041 | { |
| 8042 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 8043 | return NULL; |
| 8044 | } |
| 8045 | |
| 8046 | /* Peer structure lookup. */ |
| 8047 | peer = peer_lookup (bgp, &su); |
| 8048 | if (! peer) |
| 8049 | { |
| 8050 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 8051 | return NULL; |
| 8052 | } |
| 8053 | |
| 8054 | return peer; |
| 8055 | } |
| 8056 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8057 | void |
| 8058 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 8059 | int in) |
| 8060 | { |
| 8061 | struct bgp_table *table; |
| 8062 | struct bgp_adj_in *ain; |
| 8063 | struct bgp_adj_out *adj; |
| 8064 | unsigned long output_count; |
| 8065 | struct bgp_node *rn; |
| 8066 | int header1 = 1; |
| 8067 | struct bgp *bgp; |
| 8068 | int header2 = 1; |
| 8069 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8070 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8071 | |
| 8072 | if (! bgp) |
| 8073 | return; |
| 8074 | |
| 8075 | table = bgp->rib[afi][safi]; |
| 8076 | |
| 8077 | output_count = 0; |
| 8078 | |
| 8079 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 8080 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 8081 | { |
| 8082 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 8083 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 8084 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 8085 | |
| 8086 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 8087 | VTY_NEWLINE, VTY_NEWLINE); |
| 8088 | header1 = 0; |
| 8089 | } |
| 8090 | |
| 8091 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 8092 | if (in) |
| 8093 | { |
| 8094 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 8095 | if (ain->peer == peer) |
| 8096 | { |
| 8097 | if (header1) |
| 8098 | { |
| 8099 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 8100 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 8101 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 8102 | header1 = 0; |
| 8103 | } |
| 8104 | if (header2) |
| 8105 | { |
| 8106 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8107 | header2 = 0; |
| 8108 | } |
| 8109 | if (ain->attr) |
| 8110 | { |
| 8111 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 8112 | output_count++; |
| 8113 | } |
| 8114 | } |
| 8115 | } |
| 8116 | else |
| 8117 | { |
| 8118 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 8119 | if (adj->peer == peer) |
| 8120 | { |
| 8121 | if (header1) |
| 8122 | { |
| 8123 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 8124 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 8125 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 8126 | header1 = 0; |
| 8127 | } |
| 8128 | if (header2) |
| 8129 | { |
| 8130 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8131 | header2 = 0; |
| 8132 | } |
| 8133 | if (adj->attr) |
| 8134 | { |
| 8135 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 8136 | output_count++; |
| 8137 | } |
| 8138 | } |
| 8139 | } |
| 8140 | |
| 8141 | if (output_count != 0) |
| 8142 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 8143 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 8144 | } |
| 8145 | |
| 8146 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8147 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 8148 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8149 | if (! peer || ! peer->afc[afi][safi]) |
| 8150 | { |
| 8151 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 8152 | return CMD_WARNING; |
| 8153 | } |
| 8154 | |
| 8155 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 8156 | { |
| 8157 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 8158 | VTY_NEWLINE); |
| 8159 | return CMD_WARNING; |
| 8160 | } |
| 8161 | |
| 8162 | show_adj_route (vty, peer, afi, safi, in); |
| 8163 | |
| 8164 | return CMD_SUCCESS; |
| 8165 | } |
| 8166 | |
| 8167 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 8168 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 8169 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8170 | SHOW_STR |
| 8171 | IP_STR |
| 8172 | BGP_STR |
| 8173 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8174 | "Neighbor to display information about\n" |
| 8175 | "Neighbor to display information about\n" |
| 8176 | "Display the routes advertised to a BGP neighbor\n") |
| 8177 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8178 | struct peer *peer; |
| 8179 | |
| 8180 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8181 | if (! peer) |
| 8182 | return CMD_WARNING; |
| 8183 | |
| 8184 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8185 | } |
| 8186 | |
| 8187 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 8188 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 8189 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8190 | SHOW_STR |
| 8191 | IP_STR |
| 8192 | BGP_STR |
| 8193 | "Address family\n" |
| 8194 | "Address Family modifier\n" |
| 8195 | "Address Family modifier\n" |
| 8196 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8197 | "Neighbor to display information about\n" |
| 8198 | "Neighbor to display information about\n" |
| 8199 | "Display the routes advertised to a BGP neighbor\n") |
| 8200 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8201 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8202 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8203 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8204 | if (! peer) |
| 8205 | return CMD_WARNING; |
| 8206 | |
| 8207 | if (strncmp (argv[0], "m", 1) == 0) |
| 8208 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 8209 | |
| 8210 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8211 | } |
| 8212 | |
| 8213 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8214 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 8215 | show_bgp_view_neighbor_advertised_route_cmd, |
| 8216 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8217 | SHOW_STR |
| 8218 | BGP_STR |
| 8219 | "BGP view\n" |
| 8220 | "View name\n" |
| 8221 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8222 | "Neighbor to display information about\n" |
| 8223 | "Neighbor to display information about\n" |
| 8224 | "Display the routes advertised to a BGP neighbor\n") |
| 8225 | { |
| 8226 | struct peer *peer; |
| 8227 | |
| 8228 | if (argc == 2) |
| 8229 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8230 | else |
| 8231 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8232 | |
| 8233 | if (! peer) |
| 8234 | return CMD_WARNING; |
| 8235 | |
| 8236 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 8237 | } |
| 8238 | |
| 8239 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 8240 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 8241 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8242 | SHOW_STR |
| 8243 | BGP_STR |
| 8244 | "BGP view\n" |
| 8245 | "View name\n" |
| 8246 | "Address family\n" |
| 8247 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8248 | "Neighbor to display information about\n" |
| 8249 | "Neighbor to display information about\n" |
| 8250 | "Display the routes advertised to a BGP neighbor\n") |
| 8251 | |
| 8252 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 8253 | show_bgp_view_neighbor_received_routes_cmd, |
| 8254 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8255 | SHOW_STR |
| 8256 | BGP_STR |
| 8257 | "BGP view\n" |
| 8258 | "View name\n" |
| 8259 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8260 | "Neighbor to display information about\n" |
| 8261 | "Neighbor to display information about\n" |
| 8262 | "Display the received routes from neighbor\n") |
| 8263 | { |
| 8264 | struct peer *peer; |
| 8265 | |
| 8266 | if (argc == 2) |
| 8267 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8268 | else |
| 8269 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8270 | |
| 8271 | if (! peer) |
| 8272 | return CMD_WARNING; |
| 8273 | |
| 8274 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 8275 | } |
| 8276 | |
| 8277 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 8278 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 8279 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8280 | SHOW_STR |
| 8281 | BGP_STR |
| 8282 | "BGP view\n" |
| 8283 | "View name\n" |
| 8284 | "Address family\n" |
| 8285 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8286 | "Neighbor to display information about\n" |
| 8287 | "Neighbor to display information about\n" |
| 8288 | "Display the received routes from neighbor\n") |
| 8289 | |
| 8290 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8291 | show_bgp_neighbor_advertised_route_cmd, |
| 8292 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8293 | SHOW_STR |
| 8294 | BGP_STR |
| 8295 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8296 | "Neighbor to display information about\n" |
| 8297 | "Neighbor to display information about\n" |
| 8298 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8299 | |
| 8300 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8301 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 8302 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8303 | SHOW_STR |
| 8304 | BGP_STR |
| 8305 | "Address family\n" |
| 8306 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8307 | "Neighbor to display information about\n" |
| 8308 | "Neighbor to display information about\n" |
| 8309 | "Display the routes advertised to a BGP neighbor\n") |
| 8310 | |
| 8311 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8312 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8313 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 8314 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8315 | SHOW_STR |
| 8316 | IPV6_STR |
| 8317 | BGP_STR |
| 8318 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8319 | "Neighbor to display information about\n" |
| 8320 | "Neighbor to display information about\n" |
| 8321 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8322 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8323 | /* old command */ |
| 8324 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 8325 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 8326 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8327 | SHOW_STR |
| 8328 | IPV6_STR |
| 8329 | MBGP_STR |
| 8330 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8331 | "Neighbor to display information about\n" |
| 8332 | "Neighbor to display information about\n" |
| 8333 | "Display the routes advertised to a BGP neighbor\n") |
| 8334 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8335 | struct peer *peer; |
| 8336 | |
| 8337 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8338 | if (! peer) |
| 8339 | return CMD_WARNING; |
| 8340 | |
| 8341 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8342 | } |
| 8343 | #endif /* HAVE_IPV6 */ |
| 8344 | |
| 8345 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 8346 | show_ip_bgp_neighbor_received_routes_cmd, |
| 8347 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8348 | SHOW_STR |
| 8349 | IP_STR |
| 8350 | BGP_STR |
| 8351 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8352 | "Neighbor to display information about\n" |
| 8353 | "Neighbor to display information about\n" |
| 8354 | "Display the received routes from neighbor\n") |
| 8355 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8356 | struct peer *peer; |
| 8357 | |
| 8358 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8359 | if (! peer) |
| 8360 | return CMD_WARNING; |
| 8361 | |
| 8362 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8363 | } |
| 8364 | |
| 8365 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 8366 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 8367 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8368 | SHOW_STR |
| 8369 | IP_STR |
| 8370 | BGP_STR |
| 8371 | "Address family\n" |
| 8372 | "Address Family modifier\n" |
| 8373 | "Address Family modifier\n" |
| 8374 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8375 | "Neighbor to display information about\n" |
| 8376 | "Neighbor to display information about\n" |
| 8377 | "Display the received routes from neighbor\n") |
| 8378 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8379 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8380 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8381 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8382 | if (! peer) |
| 8383 | return CMD_WARNING; |
| 8384 | |
| 8385 | if (strncmp (argv[0], "m", 1) == 0) |
| 8386 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 8387 | |
| 8388 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8389 | } |
| 8390 | |
| 8391 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 8392 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 8393 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8394 | SHOW_STR |
| 8395 | IP_STR |
| 8396 | BGP_STR |
| 8397 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8398 | "Neighbor to display information about\n" |
| 8399 | "Neighbor to display information about\n" |
| 8400 | "Display information received from a BGP neighbor\n" |
| 8401 | "Display the prefixlist filter\n") |
| 8402 | { |
| 8403 | char name[BUFSIZ]; |
| 8404 | union sockunion *su; |
| 8405 | struct peer *peer; |
| 8406 | int count; |
| 8407 | |
| 8408 | su = sockunion_str2su (argv[0]); |
| 8409 | if (su == NULL) |
| 8410 | return CMD_WARNING; |
| 8411 | |
| 8412 | peer = peer_lookup (NULL, su); |
| 8413 | if (! peer) |
| 8414 | return CMD_WARNING; |
| 8415 | |
| 8416 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8417 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8418 | if (count) |
| 8419 | { |
| 8420 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8421 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8422 | } |
| 8423 | |
| 8424 | return CMD_SUCCESS; |
| 8425 | } |
| 8426 | |
| 8427 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 8428 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 8429 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8430 | SHOW_STR |
| 8431 | IP_STR |
| 8432 | BGP_STR |
| 8433 | "Address family\n" |
| 8434 | "Address Family modifier\n" |
| 8435 | "Address Family modifier\n" |
| 8436 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8437 | "Neighbor to display information about\n" |
| 8438 | "Neighbor to display information about\n" |
| 8439 | "Display information received from a BGP neighbor\n" |
| 8440 | "Display the prefixlist filter\n") |
| 8441 | { |
| 8442 | char name[BUFSIZ]; |
| 8443 | union sockunion *su; |
| 8444 | struct peer *peer; |
| 8445 | int count; |
| 8446 | |
| 8447 | su = sockunion_str2su (argv[1]); |
| 8448 | if (su == NULL) |
| 8449 | return CMD_WARNING; |
| 8450 | |
| 8451 | peer = peer_lookup (NULL, su); |
| 8452 | if (! peer) |
| 8453 | return CMD_WARNING; |
| 8454 | |
| 8455 | if (strncmp (argv[0], "m", 1) == 0) |
| 8456 | { |
| 8457 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 8458 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8459 | if (count) |
| 8460 | { |
| 8461 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 8462 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8463 | } |
| 8464 | } |
| 8465 | else |
| 8466 | { |
| 8467 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8468 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8469 | if (count) |
| 8470 | { |
| 8471 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8472 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8473 | } |
| 8474 | } |
| 8475 | |
| 8476 | return CMD_SUCCESS; |
| 8477 | } |
| 8478 | |
| 8479 | |
| 8480 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8481 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8482 | show_bgp_neighbor_received_routes_cmd, |
| 8483 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8484 | SHOW_STR |
| 8485 | BGP_STR |
| 8486 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8487 | "Neighbor to display information about\n" |
| 8488 | "Neighbor to display information about\n" |
| 8489 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8490 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8491 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8492 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 8493 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8494 | SHOW_STR |
| 8495 | BGP_STR |
| 8496 | "Address family\n" |
| 8497 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8498 | "Neighbor to display information about\n" |
| 8499 | "Neighbor to display information about\n" |
| 8500 | "Display the received routes from neighbor\n") |
| 8501 | |
| 8502 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 8503 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 8504 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8505 | SHOW_STR |
| 8506 | BGP_STR |
| 8507 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8508 | "Neighbor to display information about\n" |
| 8509 | "Neighbor to display information about\n" |
| 8510 | "Display information received from a BGP neighbor\n" |
| 8511 | "Display the prefixlist filter\n") |
| 8512 | { |
| 8513 | char name[BUFSIZ]; |
| 8514 | union sockunion *su; |
| 8515 | struct peer *peer; |
| 8516 | int count; |
| 8517 | |
| 8518 | su = sockunion_str2su (argv[0]); |
| 8519 | if (su == NULL) |
| 8520 | return CMD_WARNING; |
| 8521 | |
| 8522 | peer = peer_lookup (NULL, su); |
| 8523 | if (! peer) |
| 8524 | return CMD_WARNING; |
| 8525 | |
| 8526 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8527 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8528 | if (count) |
| 8529 | { |
| 8530 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8531 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8532 | } |
| 8533 | |
| 8534 | return CMD_SUCCESS; |
| 8535 | } |
| 8536 | |
| 8537 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 8538 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 8539 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8540 | SHOW_STR |
| 8541 | BGP_STR |
| 8542 | "Address family\n" |
| 8543 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8544 | "Neighbor to display information about\n" |
| 8545 | "Neighbor to display information about\n" |
| 8546 | "Display information received from a BGP neighbor\n" |
| 8547 | "Display the prefixlist filter\n") |
| 8548 | |
| 8549 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8550 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8551 | ipv6_bgp_neighbor_received_routes_cmd, |
| 8552 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8553 | SHOW_STR |
| 8554 | IPV6_STR |
| 8555 | BGP_STR |
| 8556 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8557 | "Neighbor to display information about\n" |
| 8558 | "Neighbor to display information about\n" |
| 8559 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8560 | |
| 8561 | /* old command */ |
| 8562 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 8563 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 8564 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8565 | SHOW_STR |
| 8566 | IPV6_STR |
| 8567 | MBGP_STR |
| 8568 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8569 | "Neighbor to display information about\n" |
| 8570 | "Neighbor to display information about\n" |
| 8571 | "Display the received routes from neighbor\n") |
| 8572 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8573 | struct peer *peer; |
| 8574 | |
| 8575 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8576 | if (! peer) |
| 8577 | return CMD_WARNING; |
| 8578 | |
| 8579 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8580 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8581 | |
| 8582 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 8583 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 8584 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8585 | SHOW_STR |
| 8586 | BGP_STR |
| 8587 | "BGP view\n" |
| 8588 | "View name\n" |
| 8589 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8590 | "Neighbor to display information about\n" |
| 8591 | "Neighbor to display information about\n" |
| 8592 | "Display information received from a BGP neighbor\n" |
| 8593 | "Display the prefixlist filter\n") |
| 8594 | { |
| 8595 | char name[BUFSIZ]; |
| 8596 | union sockunion *su; |
| 8597 | struct peer *peer; |
| 8598 | struct bgp *bgp; |
| 8599 | int count; |
| 8600 | |
| 8601 | /* BGP structure lookup. */ |
| 8602 | bgp = bgp_lookup_by_name (argv[0]); |
| 8603 | if (bgp == NULL) |
| 8604 | { |
| 8605 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8606 | return CMD_WARNING; |
| 8607 | } |
| 8608 | |
| 8609 | su = sockunion_str2su (argv[1]); |
| 8610 | if (su == NULL) |
| 8611 | return CMD_WARNING; |
| 8612 | |
| 8613 | peer = peer_lookup (bgp, su); |
| 8614 | if (! peer) |
| 8615 | return CMD_WARNING; |
| 8616 | |
| 8617 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8618 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8619 | if (count) |
| 8620 | { |
| 8621 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8622 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8623 | } |
| 8624 | |
| 8625 | return CMD_SUCCESS; |
| 8626 | } |
| 8627 | |
| 8628 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 8629 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 8630 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8631 | SHOW_STR |
| 8632 | BGP_STR |
| 8633 | "BGP view\n" |
| 8634 | "View name\n" |
| 8635 | "Address family\n" |
| 8636 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8637 | "Neighbor to display information about\n" |
| 8638 | "Neighbor to display information about\n" |
| 8639 | "Display information received from a BGP neighbor\n" |
| 8640 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8641 | #endif /* HAVE_IPV6 */ |
| 8642 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8643 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8644 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8645 | safi_t safi, enum bgp_show_type type) |
| 8646 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8647 | if (! peer || ! peer->afc[afi][safi]) |
| 8648 | { |
| 8649 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8650 | return CMD_WARNING; |
| 8651 | } |
| 8652 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8653 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8654 | } |
| 8655 | |
| 8656 | DEFUN (show_ip_bgp_neighbor_routes, |
| 8657 | show_ip_bgp_neighbor_routes_cmd, |
| 8658 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8659 | SHOW_STR |
| 8660 | IP_STR |
| 8661 | BGP_STR |
| 8662 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8663 | "Neighbor to display information about\n" |
| 8664 | "Neighbor to display information about\n" |
| 8665 | "Display routes learned from neighbor\n") |
| 8666 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8667 | struct peer *peer; |
| 8668 | |
| 8669 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8670 | if (! peer) |
| 8671 | return CMD_WARNING; |
| 8672 | |
| 8673 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8674 | bgp_show_type_neighbor); |
| 8675 | } |
| 8676 | |
| 8677 | DEFUN (show_ip_bgp_neighbor_flap, |
| 8678 | show_ip_bgp_neighbor_flap_cmd, |
| 8679 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8680 | SHOW_STR |
| 8681 | IP_STR |
| 8682 | BGP_STR |
| 8683 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8684 | "Neighbor to display information about\n" |
| 8685 | "Neighbor to display information about\n" |
| 8686 | "Display flap statistics of the routes learned from neighbor\n") |
| 8687 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8688 | struct peer *peer; |
| 8689 | |
| 8690 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8691 | if (! peer) |
| 8692 | return CMD_WARNING; |
| 8693 | |
| 8694 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8695 | bgp_show_type_flap_neighbor); |
| 8696 | } |
| 8697 | |
| 8698 | DEFUN (show_ip_bgp_neighbor_damp, |
| 8699 | show_ip_bgp_neighbor_damp_cmd, |
| 8700 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8701 | SHOW_STR |
| 8702 | IP_STR |
| 8703 | BGP_STR |
| 8704 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8705 | "Neighbor to display information about\n" |
| 8706 | "Neighbor to display information about\n" |
| 8707 | "Display the dampened routes received from neighbor\n") |
| 8708 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8709 | struct peer *peer; |
| 8710 | |
| 8711 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8712 | if (! peer) |
| 8713 | return CMD_WARNING; |
| 8714 | |
| 8715 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8716 | bgp_show_type_damp_neighbor); |
| 8717 | } |
| 8718 | |
| 8719 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 8720 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 8721 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 8722 | SHOW_STR |
| 8723 | IP_STR |
| 8724 | BGP_STR |
| 8725 | "Address family\n" |
| 8726 | "Address Family modifier\n" |
| 8727 | "Address Family modifier\n" |
| 8728 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8729 | "Neighbor to display information about\n" |
| 8730 | "Neighbor to display information about\n" |
| 8731 | "Display routes learned from neighbor\n") |
| 8732 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8733 | struct peer *peer; |
| 8734 | |
| 8735 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8736 | if (! peer) |
| 8737 | return CMD_WARNING; |
| 8738 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8739 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8740 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8741 | bgp_show_type_neighbor); |
| 8742 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8743 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8744 | bgp_show_type_neighbor); |
| 8745 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8746 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 8747 | DEFUN (show_ip_bgp_view_rsclient, |
| 8748 | show_ip_bgp_view_rsclient_cmd, |
| 8749 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 8750 | SHOW_STR |
| 8751 | IP_STR |
| 8752 | BGP_STR |
| 8753 | "BGP view\n" |
| 8754 | "BGP view name\n" |
| 8755 | "Information about Route Server Client\n" |
| 8756 | NEIGHBOR_ADDR_STR) |
| 8757 | { |
| 8758 | struct bgp_table *table; |
| 8759 | struct peer *peer; |
| 8760 | |
| 8761 | if (argc == 2) |
| 8762 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8763 | else |
| 8764 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8765 | |
| 8766 | if (! peer) |
| 8767 | return CMD_WARNING; |
| 8768 | |
| 8769 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 8770 | { |
| 8771 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 8772 | VTY_NEWLINE); |
| 8773 | return CMD_WARNING; |
| 8774 | } |
| 8775 | |
| 8776 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 8777 | PEER_FLAG_RSERVER_CLIENT)) |
| 8778 | { |
| 8779 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 8780 | VTY_NEWLINE); |
| 8781 | return CMD_WARNING; |
| 8782 | } |
| 8783 | |
| 8784 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 8785 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8786 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 8787 | } |
| 8788 | |
| 8789 | ALIAS (show_ip_bgp_view_rsclient, |
| 8790 | show_ip_bgp_rsclient_cmd, |
| 8791 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 8792 | SHOW_STR |
| 8793 | IP_STR |
| 8794 | BGP_STR |
| 8795 | "Information about Route Server Client\n" |
| 8796 | NEIGHBOR_ADDR_STR) |
| 8797 | |
| 8798 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 8799 | show_ip_bgp_view_rsclient_route_cmd, |
| 8800 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 8801 | SHOW_STR |
| 8802 | IP_STR |
| 8803 | BGP_STR |
| 8804 | "BGP view\n" |
| 8805 | "BGP view name\n" |
| 8806 | "Information about Route Server Client\n" |
| 8807 | NEIGHBOR_ADDR_STR |
| 8808 | "Network in the BGP routing table to display\n") |
| 8809 | { |
| 8810 | struct bgp *bgp; |
| 8811 | struct peer *peer; |
| 8812 | |
| 8813 | /* BGP structure lookup. */ |
| 8814 | if (argc == 3) |
| 8815 | { |
| 8816 | bgp = bgp_lookup_by_name (argv[0]); |
| 8817 | if (bgp == NULL) |
| 8818 | { |
| 8819 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8820 | return CMD_WARNING; |
| 8821 | } |
| 8822 | } |
| 8823 | else |
| 8824 | { |
| 8825 | bgp = bgp_get_default (); |
| 8826 | if (bgp == NULL) |
| 8827 | { |
| 8828 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8829 | return CMD_WARNING; |
| 8830 | } |
| 8831 | } |
| 8832 | |
| 8833 | if (argc == 3) |
| 8834 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8835 | else |
| 8836 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8837 | |
| 8838 | if (! peer) |
| 8839 | return CMD_WARNING; |
| 8840 | |
| 8841 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 8842 | { |
| 8843 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 8844 | VTY_NEWLINE); |
| 8845 | return CMD_WARNING; |
| 8846 | } |
| 8847 | |
| 8848 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 8849 | PEER_FLAG_RSERVER_CLIENT)) |
| 8850 | { |
| 8851 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 8852 | VTY_NEWLINE); |
| 8853 | return CMD_WARNING; |
| 8854 | } |
| 8855 | |
| 8856 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 8857 | (argc == 3) ? argv[2] : argv[1], |
| 8858 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 8859 | } |
| 8860 | |
| 8861 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 8862 | show_ip_bgp_rsclient_route_cmd, |
| 8863 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 8864 | SHOW_STR |
| 8865 | IP_STR |
| 8866 | BGP_STR |
| 8867 | "Information about Route Server Client\n" |
| 8868 | NEIGHBOR_ADDR_STR |
| 8869 | "Network in the BGP routing table to display\n") |
| 8870 | |
| 8871 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 8872 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 8873 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 8874 | SHOW_STR |
| 8875 | IP_STR |
| 8876 | BGP_STR |
| 8877 | "BGP view\n" |
| 8878 | "BGP view name\n" |
| 8879 | "Information about Route Server Client\n" |
| 8880 | NEIGHBOR_ADDR_STR |
| 8881 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8882 | { |
| 8883 | struct bgp *bgp; |
| 8884 | struct peer *peer; |
| 8885 | |
| 8886 | /* BGP structure lookup. */ |
| 8887 | if (argc == 3) |
| 8888 | { |
| 8889 | bgp = bgp_lookup_by_name (argv[0]); |
| 8890 | if (bgp == NULL) |
| 8891 | { |
| 8892 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8893 | return CMD_WARNING; |
| 8894 | } |
| 8895 | } |
| 8896 | else |
| 8897 | { |
| 8898 | bgp = bgp_get_default (); |
| 8899 | if (bgp == NULL) |
| 8900 | { |
| 8901 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8902 | return CMD_WARNING; |
| 8903 | } |
| 8904 | } |
| 8905 | |
| 8906 | if (argc == 3) |
| 8907 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8908 | else |
| 8909 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8910 | |
| 8911 | if (! peer) |
| 8912 | return CMD_WARNING; |
| 8913 | |
| 8914 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 8915 | { |
| 8916 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 8917 | VTY_NEWLINE); |
| 8918 | return CMD_WARNING; |
| 8919 | } |
| 8920 | |
| 8921 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 8922 | PEER_FLAG_RSERVER_CLIENT)) |
| 8923 | { |
| 8924 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 8925 | VTY_NEWLINE); |
| 8926 | return CMD_WARNING; |
| 8927 | } |
| 8928 | |
| 8929 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 8930 | (argc == 3) ? argv[2] : argv[1], |
| 8931 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 8932 | } |
| 8933 | |
| 8934 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 8935 | show_ip_bgp_rsclient_prefix_cmd, |
| 8936 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 8937 | SHOW_STR |
| 8938 | IP_STR |
| 8939 | BGP_STR |
| 8940 | "Information about Route Server Client\n" |
| 8941 | NEIGHBOR_ADDR_STR |
| 8942 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8943 | |
| 8944 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8945 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8946 | DEFUN (show_bgp_view_neighbor_routes, |
| 8947 | show_bgp_view_neighbor_routes_cmd, |
| 8948 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 8949 | SHOW_STR |
| 8950 | BGP_STR |
| 8951 | "BGP view\n" |
| 8952 | "BGP view name\n" |
| 8953 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8954 | "Neighbor to display information about\n" |
| 8955 | "Neighbor to display information about\n" |
| 8956 | "Display routes learned from neighbor\n") |
| 8957 | { |
| 8958 | struct peer *peer; |
| 8959 | |
| 8960 | if (argc == 2) |
| 8961 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8962 | else |
| 8963 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8964 | |
| 8965 | if (! peer) |
| 8966 | return CMD_WARNING; |
| 8967 | |
| 8968 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 8969 | bgp_show_type_neighbor); |
| 8970 | } |
| 8971 | |
| 8972 | ALIAS (show_bgp_view_neighbor_routes, |
| 8973 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 8974 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 8975 | SHOW_STR |
| 8976 | BGP_STR |
| 8977 | "BGP view\n" |
| 8978 | "BGP view name\n" |
| 8979 | "Address family\n" |
| 8980 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8981 | "Neighbor to display information about\n" |
| 8982 | "Neighbor to display information about\n" |
| 8983 | "Display routes learned from neighbor\n") |
| 8984 | |
| 8985 | DEFUN (show_bgp_view_neighbor_damp, |
| 8986 | show_bgp_view_neighbor_damp_cmd, |
| 8987 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8988 | SHOW_STR |
| 8989 | BGP_STR |
| 8990 | "BGP view\n" |
| 8991 | "BGP view name\n" |
| 8992 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8993 | "Neighbor to display information about\n" |
| 8994 | "Neighbor to display information about\n" |
| 8995 | "Display the dampened routes received from neighbor\n") |
| 8996 | { |
| 8997 | struct peer *peer; |
| 8998 | |
| 8999 | if (argc == 2) |
| 9000 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9001 | else |
| 9002 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9003 | |
| 9004 | if (! peer) |
| 9005 | return CMD_WARNING; |
| 9006 | |
| 9007 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9008 | bgp_show_type_damp_neighbor); |
| 9009 | } |
| 9010 | |
| 9011 | ALIAS (show_bgp_view_neighbor_damp, |
| 9012 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 9013 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9014 | SHOW_STR |
| 9015 | BGP_STR |
| 9016 | "BGP view\n" |
| 9017 | "BGP view name\n" |
| 9018 | "Address family\n" |
| 9019 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9020 | "Neighbor to display information about\n" |
| 9021 | "Neighbor to display information about\n" |
| 9022 | "Display the dampened routes received from neighbor\n") |
| 9023 | |
| 9024 | DEFUN (show_bgp_view_neighbor_flap, |
| 9025 | show_bgp_view_neighbor_flap_cmd, |
| 9026 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9027 | SHOW_STR |
| 9028 | BGP_STR |
| 9029 | "BGP view\n" |
| 9030 | "BGP view name\n" |
| 9031 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9032 | "Neighbor to display information about\n" |
| 9033 | "Neighbor to display information about\n" |
| 9034 | "Display flap statistics of the routes learned from neighbor\n") |
| 9035 | { |
| 9036 | struct peer *peer; |
| 9037 | |
| 9038 | if (argc == 2) |
| 9039 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9040 | else |
| 9041 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9042 | |
| 9043 | if (! peer) |
| 9044 | return CMD_WARNING; |
| 9045 | |
| 9046 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9047 | bgp_show_type_flap_neighbor); |
| 9048 | } |
| 9049 | |
| 9050 | ALIAS (show_bgp_view_neighbor_flap, |
| 9051 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 9052 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9053 | SHOW_STR |
| 9054 | BGP_STR |
| 9055 | "BGP view\n" |
| 9056 | "BGP view name\n" |
| 9057 | "Address family\n" |
| 9058 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9059 | "Neighbor to display information about\n" |
| 9060 | "Neighbor to display information about\n" |
| 9061 | "Display flap statistics of the routes learned from neighbor\n") |
| 9062 | |
| 9063 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9064 | show_bgp_neighbor_routes_cmd, |
| 9065 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9066 | SHOW_STR |
| 9067 | BGP_STR |
| 9068 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9069 | "Neighbor to display information about\n" |
| 9070 | "Neighbor to display information about\n" |
| 9071 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9072 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9073 | |
| 9074 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9075 | show_bgp_ipv6_neighbor_routes_cmd, |
| 9076 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9077 | SHOW_STR |
| 9078 | BGP_STR |
| 9079 | "Address family\n" |
| 9080 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9081 | "Neighbor to display information about\n" |
| 9082 | "Neighbor to display information about\n" |
| 9083 | "Display routes learned from neighbor\n") |
| 9084 | |
| 9085 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9086 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9087 | ipv6_bgp_neighbor_routes_cmd, |
| 9088 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9089 | SHOW_STR |
| 9090 | IPV6_STR |
| 9091 | BGP_STR |
| 9092 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9093 | "Neighbor to display information about\n" |
| 9094 | "Neighbor to display information about\n" |
| 9095 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9096 | |
| 9097 | /* old command */ |
| 9098 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 9099 | ipv6_mbgp_neighbor_routes_cmd, |
| 9100 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9101 | SHOW_STR |
| 9102 | IPV6_STR |
| 9103 | MBGP_STR |
| 9104 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9105 | "Neighbor to display information about\n" |
| 9106 | "Neighbor to display information about\n" |
| 9107 | "Display routes learned from neighbor\n") |
| 9108 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9109 | struct peer *peer; |
| 9110 | |
| 9111 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9112 | if (! peer) |
| 9113 | return CMD_WARNING; |
| 9114 | |
| 9115 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9116 | bgp_show_type_neighbor); |
| 9117 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9118 | |
| 9119 | ALIAS (show_bgp_view_neighbor_flap, |
| 9120 | show_bgp_neighbor_flap_cmd, |
| 9121 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9122 | SHOW_STR |
| 9123 | BGP_STR |
| 9124 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9125 | "Neighbor to display information about\n" |
| 9126 | "Neighbor to display information about\n" |
| 9127 | "Display flap statistics of the routes learned from neighbor\n") |
| 9128 | |
| 9129 | ALIAS (show_bgp_view_neighbor_flap, |
| 9130 | show_bgp_ipv6_neighbor_flap_cmd, |
| 9131 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9132 | SHOW_STR |
| 9133 | BGP_STR |
| 9134 | "Address family\n" |
| 9135 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9136 | "Neighbor to display information about\n" |
| 9137 | "Neighbor to display information about\n" |
| 9138 | "Display flap statistics of the routes learned from neighbor\n") |
| 9139 | |
| 9140 | ALIAS (show_bgp_view_neighbor_damp, |
| 9141 | show_bgp_neighbor_damp_cmd, |
| 9142 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9143 | SHOW_STR |
| 9144 | BGP_STR |
| 9145 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9146 | "Neighbor to display information about\n" |
| 9147 | "Neighbor to display information about\n" |
| 9148 | "Display the dampened routes received from neighbor\n") |
| 9149 | |
| 9150 | ALIAS (show_bgp_view_neighbor_damp, |
| 9151 | show_bgp_ipv6_neighbor_damp_cmd, |
| 9152 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9153 | SHOW_STR |
| 9154 | BGP_STR |
| 9155 | "Address family\n" |
| 9156 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9157 | "Neighbor to display information about\n" |
| 9158 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 9159 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9160 | |
| 9161 | DEFUN (show_bgp_view_rsclient, |
| 9162 | show_bgp_view_rsclient_cmd, |
| 9163 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9164 | SHOW_STR |
| 9165 | BGP_STR |
| 9166 | "BGP view\n" |
| 9167 | "BGP view name\n" |
| 9168 | "Information about Route Server Client\n" |
| 9169 | NEIGHBOR_ADDR_STR) |
| 9170 | { |
| 9171 | struct bgp_table *table; |
| 9172 | struct peer *peer; |
| 9173 | |
| 9174 | if (argc == 2) |
| 9175 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9176 | else |
| 9177 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9178 | |
| 9179 | if (! peer) |
| 9180 | return CMD_WARNING; |
| 9181 | |
| 9182 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9183 | { |
| 9184 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9185 | VTY_NEWLINE); |
| 9186 | return CMD_WARNING; |
| 9187 | } |
| 9188 | |
| 9189 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9190 | PEER_FLAG_RSERVER_CLIENT)) |
| 9191 | { |
| 9192 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9193 | VTY_NEWLINE); |
| 9194 | return CMD_WARNING; |
| 9195 | } |
| 9196 | |
| 9197 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 9198 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9199 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9200 | } |
| 9201 | |
| 9202 | ALIAS (show_bgp_view_rsclient, |
| 9203 | show_bgp_rsclient_cmd, |
| 9204 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9205 | SHOW_STR |
| 9206 | BGP_STR |
| 9207 | "Information about Route Server Client\n" |
| 9208 | NEIGHBOR_ADDR_STR) |
| 9209 | |
| 9210 | DEFUN (show_bgp_view_rsclient_route, |
| 9211 | show_bgp_view_rsclient_route_cmd, |
| 9212 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9213 | SHOW_STR |
| 9214 | BGP_STR |
| 9215 | "BGP view\n" |
| 9216 | "BGP view name\n" |
| 9217 | "Information about Route Server Client\n" |
| 9218 | NEIGHBOR_ADDR_STR |
| 9219 | "Network in the BGP routing table to display\n") |
| 9220 | { |
| 9221 | struct bgp *bgp; |
| 9222 | struct peer *peer; |
| 9223 | |
| 9224 | /* BGP structure lookup. */ |
| 9225 | if (argc == 3) |
| 9226 | { |
| 9227 | bgp = bgp_lookup_by_name (argv[0]); |
| 9228 | if (bgp == NULL) |
| 9229 | { |
| 9230 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9231 | return CMD_WARNING; |
| 9232 | } |
| 9233 | } |
| 9234 | else |
| 9235 | { |
| 9236 | bgp = bgp_get_default (); |
| 9237 | if (bgp == NULL) |
| 9238 | { |
| 9239 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9240 | return CMD_WARNING; |
| 9241 | } |
| 9242 | } |
| 9243 | |
| 9244 | if (argc == 3) |
| 9245 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9246 | else |
| 9247 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9248 | |
| 9249 | if (! peer) |
| 9250 | return CMD_WARNING; |
| 9251 | |
| 9252 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9253 | { |
| 9254 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9255 | VTY_NEWLINE); |
| 9256 | return CMD_WARNING; |
| 9257 | } |
| 9258 | |
| 9259 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9260 | PEER_FLAG_RSERVER_CLIENT)) |
| 9261 | { |
| 9262 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9263 | VTY_NEWLINE); |
| 9264 | return CMD_WARNING; |
| 9265 | } |
| 9266 | |
| 9267 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9268 | (argc == 3) ? argv[2] : argv[1], |
| 9269 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 9270 | } |
| 9271 | |
| 9272 | ALIAS (show_bgp_view_rsclient_route, |
| 9273 | show_bgp_rsclient_route_cmd, |
| 9274 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9275 | SHOW_STR |
| 9276 | BGP_STR |
| 9277 | "Information about Route Server Client\n" |
| 9278 | NEIGHBOR_ADDR_STR |
| 9279 | "Network in the BGP routing table to display\n") |
| 9280 | |
| 9281 | DEFUN (show_bgp_view_rsclient_prefix, |
| 9282 | show_bgp_view_rsclient_prefix_cmd, |
| 9283 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9284 | SHOW_STR |
| 9285 | BGP_STR |
| 9286 | "BGP view\n" |
| 9287 | "BGP view name\n" |
| 9288 | "Information about Route Server Client\n" |
| 9289 | NEIGHBOR_ADDR_STR |
| 9290 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9291 | { |
| 9292 | struct bgp *bgp; |
| 9293 | struct peer *peer; |
| 9294 | |
| 9295 | /* BGP structure lookup. */ |
| 9296 | if (argc == 3) |
| 9297 | { |
| 9298 | bgp = bgp_lookup_by_name (argv[0]); |
| 9299 | if (bgp == NULL) |
| 9300 | { |
| 9301 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9302 | return CMD_WARNING; |
| 9303 | } |
| 9304 | } |
| 9305 | else |
| 9306 | { |
| 9307 | bgp = bgp_get_default (); |
| 9308 | if (bgp == NULL) |
| 9309 | { |
| 9310 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9311 | return CMD_WARNING; |
| 9312 | } |
| 9313 | } |
| 9314 | |
| 9315 | if (argc == 3) |
| 9316 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9317 | else |
| 9318 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9319 | |
| 9320 | if (! peer) |
| 9321 | return CMD_WARNING; |
| 9322 | |
| 9323 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9324 | { |
| 9325 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9326 | VTY_NEWLINE); |
| 9327 | return CMD_WARNING; |
| 9328 | } |
| 9329 | |
| 9330 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9331 | PEER_FLAG_RSERVER_CLIENT)) |
| 9332 | { |
| 9333 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9334 | VTY_NEWLINE); |
| 9335 | return CMD_WARNING; |
| 9336 | } |
| 9337 | |
| 9338 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9339 | (argc == 3) ? argv[2] : argv[1], |
| 9340 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 9341 | } |
| 9342 | |
| 9343 | ALIAS (show_bgp_view_rsclient_prefix, |
| 9344 | show_bgp_rsclient_prefix_cmd, |
| 9345 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9346 | SHOW_STR |
| 9347 | BGP_STR |
| 9348 | "Information about Route Server Client\n" |
| 9349 | NEIGHBOR_ADDR_STR |
| 9350 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9351 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9352 | #endif /* HAVE_IPV6 */ |
| 9353 | |
| 9354 | struct bgp_table *bgp_distance_table; |
| 9355 | |
| 9356 | struct bgp_distance |
| 9357 | { |
| 9358 | /* Distance value for the IP source prefix. */ |
| 9359 | u_char distance; |
| 9360 | |
| 9361 | /* Name of the access-list to be matched. */ |
| 9362 | char *access_list; |
| 9363 | }; |
| 9364 | |
| 9365 | struct bgp_distance * |
| 9366 | bgp_distance_new () |
| 9367 | { |
| 9368 | struct bgp_distance *new; |
| 9369 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 9370 | memset (new, 0, sizeof (struct bgp_distance)); |
| 9371 | return new; |
| 9372 | } |
| 9373 | |
| 9374 | void |
| 9375 | bgp_distance_free (struct bgp_distance *bdistance) |
| 9376 | { |
| 9377 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 9378 | } |
| 9379 | |
| 9380 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9381 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 9382 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9383 | { |
| 9384 | int ret; |
| 9385 | struct prefix_ipv4 p; |
| 9386 | u_char distance; |
| 9387 | struct bgp_node *rn; |
| 9388 | struct bgp_distance *bdistance; |
| 9389 | |
| 9390 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9391 | if (ret == 0) |
| 9392 | { |
| 9393 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9394 | return CMD_WARNING; |
| 9395 | } |
| 9396 | |
| 9397 | distance = atoi (distance_str); |
| 9398 | |
| 9399 | /* Get BGP distance node. */ |
| 9400 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 9401 | if (rn->info) |
| 9402 | { |
| 9403 | bdistance = rn->info; |
| 9404 | bgp_unlock_node (rn); |
| 9405 | } |
| 9406 | else |
| 9407 | { |
| 9408 | bdistance = bgp_distance_new (); |
| 9409 | rn->info = bdistance; |
| 9410 | } |
| 9411 | |
| 9412 | /* Set distance value. */ |
| 9413 | bdistance->distance = distance; |
| 9414 | |
| 9415 | /* Reset access-list configuration. */ |
| 9416 | if (bdistance->access_list) |
| 9417 | { |
| 9418 | free (bdistance->access_list); |
| 9419 | bdistance->access_list = NULL; |
| 9420 | } |
| 9421 | if (access_list_str) |
| 9422 | bdistance->access_list = strdup (access_list_str); |
| 9423 | |
| 9424 | return CMD_SUCCESS; |
| 9425 | } |
| 9426 | |
| 9427 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9428 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 9429 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9430 | { |
| 9431 | int ret; |
| 9432 | struct prefix_ipv4 p; |
| 9433 | u_char distance; |
| 9434 | struct bgp_node *rn; |
| 9435 | struct bgp_distance *bdistance; |
| 9436 | |
| 9437 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9438 | if (ret == 0) |
| 9439 | { |
| 9440 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9441 | return CMD_WARNING; |
| 9442 | } |
| 9443 | |
| 9444 | distance = atoi (distance_str); |
| 9445 | |
| 9446 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 9447 | if (! rn) |
| 9448 | { |
| 9449 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 9450 | return CMD_WARNING; |
| 9451 | } |
| 9452 | |
| 9453 | bdistance = rn->info; |
| 9454 | |
| 9455 | if (bdistance->access_list) |
| 9456 | free (bdistance->access_list); |
| 9457 | bgp_distance_free (bdistance); |
| 9458 | |
| 9459 | rn->info = NULL; |
| 9460 | bgp_unlock_node (rn); |
| 9461 | bgp_unlock_node (rn); |
| 9462 | |
| 9463 | return CMD_SUCCESS; |
| 9464 | } |
| 9465 | |
| 9466 | void |
| 9467 | bgp_distance_reset () |
| 9468 | { |
| 9469 | struct bgp_node *rn; |
| 9470 | struct bgp_distance *bdistance; |
| 9471 | |
| 9472 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 9473 | if ((bdistance = rn->info) != NULL) |
| 9474 | { |
| 9475 | if (bdistance->access_list) |
| 9476 | free (bdistance->access_list); |
| 9477 | bgp_distance_free (bdistance); |
| 9478 | rn->info = NULL; |
| 9479 | bgp_unlock_node (rn); |
| 9480 | } |
| 9481 | } |
| 9482 | |
| 9483 | /* Apply BGP information to distance method. */ |
| 9484 | u_char |
| 9485 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 9486 | { |
| 9487 | struct bgp_node *rn; |
| 9488 | struct prefix_ipv4 q; |
| 9489 | struct peer *peer; |
| 9490 | struct bgp_distance *bdistance; |
| 9491 | struct access_list *alist; |
| 9492 | struct bgp_static *bgp_static; |
| 9493 | |
| 9494 | if (! bgp) |
| 9495 | return 0; |
| 9496 | |
| 9497 | if (p->family != AF_INET) |
| 9498 | return 0; |
| 9499 | |
| 9500 | peer = rinfo->peer; |
| 9501 | |
| 9502 | if (peer->su.sa.sa_family != AF_INET) |
| 9503 | return 0; |
| 9504 | |
| 9505 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 9506 | q.family = AF_INET; |
| 9507 | q.prefix = peer->su.sin.sin_addr; |
| 9508 | q.prefixlen = IPV4_MAX_BITLEN; |
| 9509 | |
| 9510 | /* Check source address. */ |
| 9511 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 9512 | if (rn) |
| 9513 | { |
| 9514 | bdistance = rn->info; |
| 9515 | bgp_unlock_node (rn); |
| 9516 | |
| 9517 | if (bdistance->access_list) |
| 9518 | { |
| 9519 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 9520 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 9521 | return bdistance->distance; |
| 9522 | } |
| 9523 | else |
| 9524 | return bdistance->distance; |
| 9525 | } |
| 9526 | |
| 9527 | /* Backdoor check. */ |
| 9528 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 9529 | if (rn) |
| 9530 | { |
| 9531 | bgp_static = rn->info; |
| 9532 | bgp_unlock_node (rn); |
| 9533 | |
| 9534 | if (bgp_static->backdoor) |
| 9535 | { |
| 9536 | if (bgp->distance_local) |
| 9537 | return bgp->distance_local; |
| 9538 | else |
| 9539 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9540 | } |
| 9541 | } |
| 9542 | |
| 9543 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 9544 | { |
| 9545 | if (bgp->distance_ebgp) |
| 9546 | return bgp->distance_ebgp; |
| 9547 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 9548 | } |
| 9549 | else |
| 9550 | { |
| 9551 | if (bgp->distance_ibgp) |
| 9552 | return bgp->distance_ibgp; |
| 9553 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9554 | } |
| 9555 | } |
| 9556 | |
| 9557 | DEFUN (bgp_distance, |
| 9558 | bgp_distance_cmd, |
| 9559 | "distance bgp <1-255> <1-255> <1-255>", |
| 9560 | "Define an administrative distance\n" |
| 9561 | "BGP distance\n" |
| 9562 | "Distance for routes external to the AS\n" |
| 9563 | "Distance for routes internal to the AS\n" |
| 9564 | "Distance for local routes\n") |
| 9565 | { |
| 9566 | struct bgp *bgp; |
| 9567 | |
| 9568 | bgp = vty->index; |
| 9569 | |
| 9570 | bgp->distance_ebgp = atoi (argv[0]); |
| 9571 | bgp->distance_ibgp = atoi (argv[1]); |
| 9572 | bgp->distance_local = atoi (argv[2]); |
| 9573 | return CMD_SUCCESS; |
| 9574 | } |
| 9575 | |
| 9576 | DEFUN (no_bgp_distance, |
| 9577 | no_bgp_distance_cmd, |
| 9578 | "no distance bgp <1-255> <1-255> <1-255>", |
| 9579 | NO_STR |
| 9580 | "Define an administrative distance\n" |
| 9581 | "BGP distance\n" |
| 9582 | "Distance for routes external to the AS\n" |
| 9583 | "Distance for routes internal to the AS\n" |
| 9584 | "Distance for local routes\n") |
| 9585 | { |
| 9586 | struct bgp *bgp; |
| 9587 | |
| 9588 | bgp = vty->index; |
| 9589 | |
| 9590 | bgp->distance_ebgp= 0; |
| 9591 | bgp->distance_ibgp = 0; |
| 9592 | bgp->distance_local = 0; |
| 9593 | return CMD_SUCCESS; |
| 9594 | } |
| 9595 | |
| 9596 | ALIAS (no_bgp_distance, |
| 9597 | no_bgp_distance2_cmd, |
| 9598 | "no distance bgp", |
| 9599 | NO_STR |
| 9600 | "Define an administrative distance\n" |
| 9601 | "BGP distance\n") |
| 9602 | |
| 9603 | DEFUN (bgp_distance_source, |
| 9604 | bgp_distance_source_cmd, |
| 9605 | "distance <1-255> A.B.C.D/M", |
| 9606 | "Define an administrative distance\n" |
| 9607 | "Administrative distance\n" |
| 9608 | "IP source prefix\n") |
| 9609 | { |
| 9610 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 9611 | return CMD_SUCCESS; |
| 9612 | } |
| 9613 | |
| 9614 | DEFUN (no_bgp_distance_source, |
| 9615 | no_bgp_distance_source_cmd, |
| 9616 | "no distance <1-255> A.B.C.D/M", |
| 9617 | NO_STR |
| 9618 | "Define an administrative distance\n" |
| 9619 | "Administrative distance\n" |
| 9620 | "IP source prefix\n") |
| 9621 | { |
| 9622 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 9623 | return CMD_SUCCESS; |
| 9624 | } |
| 9625 | |
| 9626 | DEFUN (bgp_distance_source_access_list, |
| 9627 | bgp_distance_source_access_list_cmd, |
| 9628 | "distance <1-255> A.B.C.D/M WORD", |
| 9629 | "Define an administrative distance\n" |
| 9630 | "Administrative distance\n" |
| 9631 | "IP source prefix\n" |
| 9632 | "Access list name\n") |
| 9633 | { |
| 9634 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 9635 | return CMD_SUCCESS; |
| 9636 | } |
| 9637 | |
| 9638 | DEFUN (no_bgp_distance_source_access_list, |
| 9639 | no_bgp_distance_source_access_list_cmd, |
| 9640 | "no distance <1-255> A.B.C.D/M WORD", |
| 9641 | NO_STR |
| 9642 | "Define an administrative distance\n" |
| 9643 | "Administrative distance\n" |
| 9644 | "IP source prefix\n" |
| 9645 | "Access list name\n") |
| 9646 | { |
| 9647 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 9648 | return CMD_SUCCESS; |
| 9649 | } |
| 9650 | |
| 9651 | DEFUN (bgp_damp_set, |
| 9652 | bgp_damp_set_cmd, |
| 9653 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 9654 | "BGP Specific commands\n" |
| 9655 | "Enable route-flap dampening\n" |
| 9656 | "Half-life time for the penalty\n" |
| 9657 | "Value to start reusing a route\n" |
| 9658 | "Value to start suppressing a route\n" |
| 9659 | "Maximum duration to suppress a stable route\n") |
| 9660 | { |
| 9661 | struct bgp *bgp; |
| 9662 | int half = DEFAULT_HALF_LIFE * 60; |
| 9663 | int reuse = DEFAULT_REUSE; |
| 9664 | int suppress = DEFAULT_SUPPRESS; |
| 9665 | int max = 4 * half; |
| 9666 | |
| 9667 | if (argc == 4) |
| 9668 | { |
| 9669 | half = atoi (argv[0]) * 60; |
| 9670 | reuse = atoi (argv[1]); |
| 9671 | suppress = atoi (argv[2]); |
| 9672 | max = atoi (argv[3]) * 60; |
| 9673 | } |
| 9674 | else if (argc == 1) |
| 9675 | { |
| 9676 | half = atoi (argv[0]) * 60; |
| 9677 | max = 4 * half; |
| 9678 | } |
| 9679 | |
| 9680 | bgp = vty->index; |
| 9681 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 9682 | half, reuse, suppress, max); |
| 9683 | } |
| 9684 | |
| 9685 | ALIAS (bgp_damp_set, |
| 9686 | bgp_damp_set2_cmd, |
| 9687 | "bgp dampening <1-45>", |
| 9688 | "BGP Specific commands\n" |
| 9689 | "Enable route-flap dampening\n" |
| 9690 | "Half-life time for the penalty\n") |
| 9691 | |
| 9692 | ALIAS (bgp_damp_set, |
| 9693 | bgp_damp_set3_cmd, |
| 9694 | "bgp dampening", |
| 9695 | "BGP Specific commands\n" |
| 9696 | "Enable route-flap dampening\n") |
| 9697 | |
| 9698 | DEFUN (bgp_damp_unset, |
| 9699 | bgp_damp_unset_cmd, |
| 9700 | "no bgp dampening", |
| 9701 | NO_STR |
| 9702 | "BGP Specific commands\n" |
| 9703 | "Enable route-flap dampening\n") |
| 9704 | { |
| 9705 | struct bgp *bgp; |
| 9706 | |
| 9707 | bgp = vty->index; |
| 9708 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 9709 | } |
| 9710 | |
| 9711 | ALIAS (bgp_damp_unset, |
| 9712 | bgp_damp_unset2_cmd, |
| 9713 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 9714 | NO_STR |
| 9715 | "BGP Specific commands\n" |
| 9716 | "Enable route-flap dampening\n" |
| 9717 | "Half-life time for the penalty\n" |
| 9718 | "Value to start reusing a route\n" |
| 9719 | "Value to start suppressing a route\n" |
| 9720 | "Maximum duration to suppress a stable route\n") |
| 9721 | |
| 9722 | DEFUN (show_ip_bgp_dampened_paths, |
| 9723 | show_ip_bgp_dampened_paths_cmd, |
| 9724 | "show ip bgp dampened-paths", |
| 9725 | SHOW_STR |
| 9726 | IP_STR |
| 9727 | BGP_STR |
| 9728 | "Display paths suppressed due to dampening\n") |
| 9729 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9730 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 9731 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9732 | } |
| 9733 | |
| 9734 | DEFUN (show_ip_bgp_flap_statistics, |
| 9735 | show_ip_bgp_flap_statistics_cmd, |
| 9736 | "show ip bgp flap-statistics", |
| 9737 | SHOW_STR |
| 9738 | IP_STR |
| 9739 | BGP_STR |
| 9740 | "Display flap statistics of routes\n") |
| 9741 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9742 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9743 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9744 | } |
| 9745 | |
| 9746 | /* Display specified route of BGP table. */ |
| 9747 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9748 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 9749 | const char *ip_str, afi_t afi, safi_t safi, |
| 9750 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9751 | { |
| 9752 | int ret; |
| 9753 | struct prefix match; |
| 9754 | struct bgp_node *rn; |
| 9755 | struct bgp_node *rm; |
| 9756 | struct bgp_info *ri; |
| 9757 | struct bgp_info *ri_temp; |
| 9758 | struct bgp *bgp; |
| 9759 | struct bgp_table *table; |
| 9760 | |
| 9761 | /* BGP structure lookup. */ |
| 9762 | if (view_name) |
| 9763 | { |
| 9764 | bgp = bgp_lookup_by_name (view_name); |
| 9765 | if (bgp == NULL) |
| 9766 | { |
| 9767 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9768 | return CMD_WARNING; |
| 9769 | } |
| 9770 | } |
| 9771 | else |
| 9772 | { |
| 9773 | bgp = bgp_get_default (); |
| 9774 | if (bgp == NULL) |
| 9775 | { |
| 9776 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 9777 | return CMD_WARNING; |
| 9778 | } |
| 9779 | } |
| 9780 | |
| 9781 | /* Check IP address argument. */ |
| 9782 | ret = str2prefix (ip_str, &match); |
| 9783 | if (! ret) |
| 9784 | { |
| 9785 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 9786 | return CMD_WARNING; |
| 9787 | } |
| 9788 | |
| 9789 | match.family = afi2family (afi); |
| 9790 | |
| 9791 | if (safi == SAFI_MPLS_VPN) |
| 9792 | { |
| 9793 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 9794 | { |
| 9795 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 9796 | continue; |
| 9797 | |
| 9798 | if ((table = rn->info) != NULL) |
| 9799 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 9800 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 9801 | { |
| 9802 | ri = rm->info; |
| 9803 | while (ri) |
| 9804 | { |
| 9805 | if (ri->damp_info) |
| 9806 | { |
| 9807 | ri_temp = ri->next; |
| 9808 | bgp_damp_info_free (ri->damp_info, 1); |
| 9809 | ri = ri_temp; |
| 9810 | } |
| 9811 | else |
| 9812 | ri = ri->next; |
| 9813 | } |
| 9814 | } |
| 9815 | } |
| 9816 | } |
| 9817 | else |
| 9818 | { |
| 9819 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 9820 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 9821 | { |
| 9822 | ri = rn->info; |
| 9823 | while (ri) |
| 9824 | { |
| 9825 | if (ri->damp_info) |
| 9826 | { |
| 9827 | ri_temp = ri->next; |
| 9828 | bgp_damp_info_free (ri->damp_info, 1); |
| 9829 | ri = ri_temp; |
| 9830 | } |
| 9831 | else |
| 9832 | ri = ri->next; |
| 9833 | } |
| 9834 | } |
| 9835 | } |
| 9836 | |
| 9837 | return CMD_SUCCESS; |
| 9838 | } |
| 9839 | |
| 9840 | DEFUN (clear_ip_bgp_dampening, |
| 9841 | clear_ip_bgp_dampening_cmd, |
| 9842 | "clear ip bgp dampening", |
| 9843 | CLEAR_STR |
| 9844 | IP_STR |
| 9845 | BGP_STR |
| 9846 | "Clear route flap dampening information\n") |
| 9847 | { |
| 9848 | bgp_damp_info_clean (); |
| 9849 | return CMD_SUCCESS; |
| 9850 | } |
| 9851 | |
| 9852 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 9853 | clear_ip_bgp_dampening_prefix_cmd, |
| 9854 | "clear ip bgp dampening A.B.C.D/M", |
| 9855 | CLEAR_STR |
| 9856 | IP_STR |
| 9857 | BGP_STR |
| 9858 | "Clear route flap dampening information\n" |
| 9859 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9860 | { |
| 9861 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 9862 | SAFI_UNICAST, NULL, 1); |
| 9863 | } |
| 9864 | |
| 9865 | DEFUN (clear_ip_bgp_dampening_address, |
| 9866 | clear_ip_bgp_dampening_address_cmd, |
| 9867 | "clear ip bgp dampening A.B.C.D", |
| 9868 | CLEAR_STR |
| 9869 | IP_STR |
| 9870 | BGP_STR |
| 9871 | "Clear route flap dampening information\n" |
| 9872 | "Network to clear damping information\n") |
| 9873 | { |
| 9874 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 9875 | SAFI_UNICAST, NULL, 0); |
| 9876 | } |
| 9877 | |
| 9878 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 9879 | clear_ip_bgp_dampening_address_mask_cmd, |
| 9880 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 9881 | CLEAR_STR |
| 9882 | IP_STR |
| 9883 | BGP_STR |
| 9884 | "Clear route flap dampening information\n" |
| 9885 | "Network to clear damping information\n" |
| 9886 | "Network mask\n") |
| 9887 | { |
| 9888 | int ret; |
| 9889 | char prefix_str[BUFSIZ]; |
| 9890 | |
| 9891 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 9892 | if (! ret) |
| 9893 | { |
| 9894 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 9895 | return CMD_WARNING; |
| 9896 | } |
| 9897 | |
| 9898 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 9899 | SAFI_UNICAST, NULL, 0); |
| 9900 | } |
| 9901 | |
| 9902 | int |
| 9903 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 9904 | afi_t afi, safi_t safi, int *write) |
| 9905 | { |
| 9906 | struct bgp_node *prn; |
| 9907 | struct bgp_node *rn; |
| 9908 | struct bgp_table *table; |
| 9909 | struct prefix *p; |
| 9910 | struct prefix_rd *prd; |
| 9911 | struct bgp_static *bgp_static; |
| 9912 | u_int32_t label; |
| 9913 | char buf[SU_ADDRSTRLEN]; |
| 9914 | char rdbuf[RD_ADDRSTRLEN]; |
| 9915 | |
| 9916 | /* Network configuration. */ |
| 9917 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 9918 | if ((table = prn->info) != NULL) |
| 9919 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9920 | if ((bgp_static = rn->info) != NULL) |
| 9921 | { |
| 9922 | p = &rn->p; |
| 9923 | prd = (struct prefix_rd *) &prn->p; |
| 9924 | |
| 9925 | /* "address-family" display. */ |
| 9926 | bgp_config_write_family_header (vty, afi, safi, write); |
| 9927 | |
| 9928 | /* "network" configuration display. */ |
| 9929 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 9930 | label = decode_label (bgp_static->tag); |
| 9931 | |
| 9932 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 9933 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 9934 | p->prefixlen, |
| 9935 | rdbuf, label); |
| 9936 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9937 | } |
| 9938 | return 0; |
| 9939 | } |
| 9940 | |
| 9941 | /* Configuration of static route announcement and aggregate |
| 9942 | information. */ |
| 9943 | int |
| 9944 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 9945 | afi_t afi, safi_t safi, int *write) |
| 9946 | { |
| 9947 | struct bgp_node *rn; |
| 9948 | struct prefix *p; |
| 9949 | struct bgp_static *bgp_static; |
| 9950 | struct bgp_aggregate *bgp_aggregate; |
| 9951 | char buf[SU_ADDRSTRLEN]; |
| 9952 | |
| 9953 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 9954 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 9955 | |
| 9956 | /* Network configuration. */ |
| 9957 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 9958 | if ((bgp_static = rn->info) != NULL) |
| 9959 | { |
| 9960 | p = &rn->p; |
| 9961 | |
| 9962 | /* "address-family" display. */ |
| 9963 | bgp_config_write_family_header (vty, afi, safi, write); |
| 9964 | |
| 9965 | /* "network" configuration display. */ |
| 9966 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 9967 | { |
| 9968 | u_int32_t destination; |
| 9969 | struct in_addr netmask; |
| 9970 | |
| 9971 | destination = ntohl (p->u.prefix4.s_addr); |
| 9972 | masklen2ip (p->prefixlen, &netmask); |
| 9973 | vty_out (vty, " network %s", |
| 9974 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 9975 | |
| 9976 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 9977 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 9978 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 9979 | || p->u.prefix4.s_addr == 0) |
| 9980 | { |
| 9981 | /* Natural mask is not display. */ |
| 9982 | } |
| 9983 | else |
| 9984 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 9985 | } |
| 9986 | else |
| 9987 | { |
| 9988 | vty_out (vty, " network %s/%d", |
| 9989 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 9990 | p->prefixlen); |
| 9991 | } |
| 9992 | |
| 9993 | if (bgp_static->rmap.name) |
| 9994 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 9995 | else if (bgp_static->backdoor) |
| 9996 | vty_out (vty, " backdoor"); |
| 9997 | |
| 9998 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9999 | } |
| 10000 | |
| 10001 | /* Aggregate-address configuration. */ |
| 10002 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10003 | if ((bgp_aggregate = rn->info) != NULL) |
| 10004 | { |
| 10005 | p = &rn->p; |
| 10006 | |
| 10007 | /* "address-family" display. */ |
| 10008 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10009 | |
| 10010 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10011 | { |
| 10012 | struct in_addr netmask; |
| 10013 | |
| 10014 | masklen2ip (p->prefixlen, &netmask); |
| 10015 | vty_out (vty, " aggregate-address %s %s", |
| 10016 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10017 | inet_ntoa (netmask)); |
| 10018 | } |
| 10019 | else |
| 10020 | { |
| 10021 | vty_out (vty, " aggregate-address %s/%d", |
| 10022 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10023 | p->prefixlen); |
| 10024 | } |
| 10025 | |
| 10026 | if (bgp_aggregate->as_set) |
| 10027 | vty_out (vty, " as-set"); |
| 10028 | |
| 10029 | if (bgp_aggregate->summary_only) |
| 10030 | vty_out (vty, " summary-only"); |
| 10031 | |
| 10032 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10033 | } |
| 10034 | |
| 10035 | return 0; |
| 10036 | } |
| 10037 | |
| 10038 | int |
| 10039 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 10040 | { |
| 10041 | struct bgp_node *rn; |
| 10042 | struct bgp_distance *bdistance; |
| 10043 | |
| 10044 | /* Distance configuration. */ |
| 10045 | if (bgp->distance_ebgp |
| 10046 | && bgp->distance_ibgp |
| 10047 | && bgp->distance_local |
| 10048 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 10049 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 10050 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 10051 | vty_out (vty, " distance bgp %d %d %d%s", |
| 10052 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 10053 | VTY_NEWLINE); |
| 10054 | |
| 10055 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 10056 | if ((bdistance = rn->info) != NULL) |
| 10057 | { |
| 10058 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 10059 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 10060 | bdistance->access_list ? bdistance->access_list : "", |
| 10061 | VTY_NEWLINE); |
| 10062 | } |
| 10063 | |
| 10064 | return 0; |
| 10065 | } |
| 10066 | |
| 10067 | /* Allocate routing table structure and install commands. */ |
| 10068 | void |
| 10069 | bgp_route_init () |
| 10070 | { |
| 10071 | /* Init BGP distance table. */ |
| 10072 | bgp_distance_table = bgp_table_init (); |
| 10073 | |
| 10074 | /* IPv4 BGP commands. */ |
| 10075 | install_element (BGP_NODE, &bgp_network_cmd); |
| 10076 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 10077 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 10078 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 10079 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 10080 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10081 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 10082 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 10083 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 10084 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 10085 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 10086 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 10087 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 10088 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10089 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10090 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 10091 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 10092 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 10093 | |
| 10094 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 10095 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 10096 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 10097 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10098 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 10099 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 10100 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 10101 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10102 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 10103 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10104 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 10105 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 10106 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 10107 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10108 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10109 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 10110 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10111 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10112 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10113 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10114 | |
| 10115 | /* IPv4 unicast configuration. */ |
| 10116 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 10117 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 10118 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 10119 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 10120 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 10121 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10122 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 10123 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 10124 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 10125 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 10126 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10127 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10128 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 10129 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 10130 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 10131 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10132 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 10133 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 10134 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 10135 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10136 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 10137 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10138 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 10139 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 10140 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 10141 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10142 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10143 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 10144 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10145 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10146 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10147 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10148 | |
| 10149 | /* IPv4 multicast configuration. */ |
| 10150 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 10151 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 10152 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 10153 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 10154 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 10155 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10156 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 10157 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 10158 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 10159 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 10160 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10161 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10162 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 10163 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 10164 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 10165 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10166 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 10167 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 10168 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 10169 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10170 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 10171 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10172 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 10173 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 10174 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 10175 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10176 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10177 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 10178 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10179 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10180 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10181 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10182 | |
| 10183 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 10184 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 10185 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 10186 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10187 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10188 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10189 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 10190 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10191 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10192 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10193 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 10194 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 10195 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10196 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 10197 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10198 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10199 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10200 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 10201 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10202 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 10203 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10204 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10205 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10206 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 10207 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10208 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 10209 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 10210 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 10211 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 10212 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10213 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10214 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10215 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10216 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 10217 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10218 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10219 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10220 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10221 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10222 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10223 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10224 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 10225 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10226 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10227 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10228 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10229 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10230 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10231 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10232 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10233 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10234 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10235 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10236 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10237 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10238 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10239 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10240 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 10241 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10242 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10243 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10244 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10245 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10246 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10247 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10248 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10249 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10250 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 10251 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10252 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10253 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10254 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10255 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10256 | |
| 10257 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 10258 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 10259 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 10260 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10261 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10262 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10263 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 10264 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10265 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10266 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10267 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 10268 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 10269 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10270 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 10271 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10272 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10273 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10274 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 10275 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10276 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 10277 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10278 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10279 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10280 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 10281 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10282 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 10283 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 10284 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 10285 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 10286 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10287 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10288 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10289 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10290 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 10291 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10292 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10293 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10294 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10295 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10296 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10297 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10298 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 10299 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10300 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10301 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10302 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10303 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10304 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10305 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10306 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10307 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10308 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10309 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10310 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10311 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10312 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10313 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10314 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 10315 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10316 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10317 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10318 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10319 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10320 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10321 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10322 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10323 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10324 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 10325 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10326 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10327 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10328 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10329 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10330 | |
| 10331 | /* BGP dampening clear commands */ |
| 10332 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 10333 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 10334 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 10335 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 10336 | |
| 10337 | #ifdef HAVE_IPV6 |
| 10338 | /* New config IPv6 BGP commands. */ |
| 10339 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 10340 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 10341 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 10342 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 10343 | |
| 10344 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 10345 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 10346 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 10347 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 10348 | |
| 10349 | /* Old config IPv6 BGP commands. */ |
| 10350 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 10351 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 10352 | |
| 10353 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 10354 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 10355 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 10356 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 10357 | |
| 10358 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 10359 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 10360 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 10361 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 10362 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 10363 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10364 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 10365 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10366 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 10367 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10368 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 10369 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10370 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 10371 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10372 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 10373 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10374 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 10375 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 10376 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 10377 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 10378 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 10379 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 10380 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 10381 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 10382 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 10383 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10384 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 10385 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10386 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 10387 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10388 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 10389 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10390 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 10391 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10392 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 10393 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10394 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 10395 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10396 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10397 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10398 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10399 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10400 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 10401 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10402 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10403 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10404 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 10405 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10406 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 10407 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10408 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 10409 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 10410 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10411 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 10412 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 10413 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 10414 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10415 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 10416 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10417 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10418 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10419 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10420 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10421 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10422 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10423 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10424 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10425 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10426 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10427 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10428 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10429 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 10430 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10431 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10432 | |
| 10433 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 10434 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 10435 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 10436 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 10437 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 10438 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10439 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 10440 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10441 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 10442 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10443 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 10444 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10445 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 10446 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10447 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 10448 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10449 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 10450 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 10451 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 10452 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 10453 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 10454 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 10455 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 10456 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 10457 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 10458 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10459 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 10460 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10461 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 10462 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10463 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 10464 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10465 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 10466 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10467 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 10468 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10469 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 10470 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10471 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10472 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10473 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10474 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10475 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 10476 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10477 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10478 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10479 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 10480 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10481 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 10482 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10483 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 10484 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 10485 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10486 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 10487 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 10488 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 10489 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10490 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 10491 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10492 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10493 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10494 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10495 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10496 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10497 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10498 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10499 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10500 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10501 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10502 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10503 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10504 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 10505 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10506 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10507 | |
| 10508 | /* old command */ |
| 10509 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 10510 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 10511 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10512 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10513 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10514 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10515 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10516 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 10517 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 10518 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 10519 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 10520 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10521 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10522 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10523 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10524 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10525 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10526 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10527 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 10528 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 10529 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10530 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10531 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10532 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10533 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10534 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 10535 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10536 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10537 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10538 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10539 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10540 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10541 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10542 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10543 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10544 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10545 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10546 | /* old command */ |
| 10547 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 10548 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 10549 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10550 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10551 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10552 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10553 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10554 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 10555 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 10556 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 10557 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 10558 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10559 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10560 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10561 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10562 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10563 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10564 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10565 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 10566 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 10567 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10568 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10569 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10570 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10571 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10572 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 10573 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10574 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10575 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10576 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10577 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10578 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10579 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10580 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10581 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10582 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 10583 | |
| 10584 | /* old command */ |
| 10585 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10586 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10587 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10588 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10589 | |
| 10590 | /* old command */ |
| 10591 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10592 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10593 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10594 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10595 | |
| 10596 | /* old command */ |
| 10597 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10598 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10599 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10600 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10601 | #endif /* HAVE_IPV6 */ |
| 10602 | |
| 10603 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 10604 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 10605 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 10606 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 10607 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 10608 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 10609 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 10610 | |
| 10611 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 10612 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 10613 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 10614 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 10615 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 10616 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 10617 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 10618 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 10619 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 10620 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 10621 | } |