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" |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 55 | #include "bgpd/bgp_vty.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 56 | |
| 57 | /* Extern from bgp_dump.c */ |
| 58 | extern char *bgp_origin_str[]; |
| 59 | extern char *bgp_origin_long_str[]; |
| 60 | |
| 61 | struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 62 | 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] | 63 | struct prefix_rd *prd) |
| 64 | { |
| 65 | struct bgp_node *rn; |
| 66 | struct bgp_node *prn = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 67 | |
| 68 | if (safi == SAFI_MPLS_VPN) |
| 69 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 70 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 71 | |
| 72 | if (prn->info == NULL) |
| 73 | prn->info = bgp_table_init (); |
| 74 | else |
| 75 | bgp_unlock_node (prn); |
| 76 | table = prn->info; |
| 77 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 78 | |
| 79 | rn = bgp_node_get (table, p); |
| 80 | |
| 81 | if (safi == SAFI_MPLS_VPN) |
| 82 | rn->prn = prn; |
| 83 | |
| 84 | return rn; |
| 85 | } |
| 86 | |
| 87 | /* Allocate new bgp info structure. */ |
| 88 | struct bgp_info * |
| 89 | bgp_info_new () |
| 90 | { |
| 91 | struct bgp_info *new; |
| 92 | |
| 93 | new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 94 | memset (new, 0, sizeof (struct bgp_info)); |
| 95 | |
| 96 | return new; |
| 97 | } |
| 98 | |
| 99 | /* Free bgp route information. */ |
| 100 | void |
| 101 | bgp_info_free (struct bgp_info *binfo) |
| 102 | { |
| 103 | if (binfo->attr) |
| 104 | bgp_attr_unintern (binfo->attr); |
| 105 | |
| 106 | if (binfo->damp_info) |
| 107 | bgp_damp_info_free (binfo->damp_info, 0); |
| 108 | |
| 109 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 110 | } |
| 111 | |
| 112 | void |
| 113 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 114 | { |
| 115 | struct bgp_info *top; |
| 116 | |
| 117 | top = rn->info; |
| 118 | |
| 119 | ri->next = rn->info; |
| 120 | ri->prev = NULL; |
| 121 | if (top) |
| 122 | top->prev = ri; |
| 123 | rn->info = ri; |
| 124 | } |
| 125 | |
| 126 | void |
| 127 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 128 | { |
| 129 | if (ri->next) |
| 130 | ri->next->prev = ri->prev; |
| 131 | if (ri->prev) |
| 132 | ri->prev->next = ri->next; |
| 133 | else |
| 134 | rn->info = ri->next; |
| 135 | } |
| 136 | |
| 137 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 138 | missing-as-worst" is specified, treat it as the worst value. */ |
| 139 | u_int32_t |
| 140 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 141 | { |
| 142 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 143 | return attr->med; |
| 144 | else |
| 145 | { |
| 146 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 147 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | else |
| 149 | return 0; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /* Compare two bgp route entity. br is preferable then return 1. */ |
| 154 | int |
| 155 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) |
| 156 | { |
| 157 | u_int32_t new_pref; |
| 158 | u_int32_t exist_pref; |
| 159 | u_int32_t new_med; |
| 160 | u_int32_t exist_med; |
| 161 | struct in_addr new_id; |
| 162 | struct in_addr exist_id; |
| 163 | int new_cluster; |
| 164 | int exist_cluster; |
| 165 | int internal_as_route = 0; |
| 166 | int confed_as_route = 0; |
| 167 | int ret; |
| 168 | |
| 169 | /* 0. Null check. */ |
| 170 | if (new == NULL) |
| 171 | return 0; |
| 172 | if (exist == NULL) |
| 173 | return 1; |
| 174 | |
| 175 | /* 1. Weight check. */ |
| 176 | if (new->attr->weight > exist->attr->weight) |
| 177 | return 1; |
| 178 | if (new->attr->weight < exist->attr->weight) |
| 179 | return 0; |
| 180 | |
| 181 | /* 2. Local preference check. */ |
| 182 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 183 | new_pref = new->attr->local_pref; |
| 184 | else |
| 185 | new_pref = bgp->default_local_pref; |
| 186 | |
| 187 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 188 | exist_pref = exist->attr->local_pref; |
| 189 | else |
| 190 | exist_pref = bgp->default_local_pref; |
| 191 | |
| 192 | if (new_pref > exist_pref) |
| 193 | return 1; |
| 194 | if (new_pref < exist_pref) |
| 195 | return 0; |
| 196 | |
| 197 | /* 3. Local route check. */ |
| 198 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 199 | return 1; |
| 200 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 201 | return 0; |
| 202 | |
| 203 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 204 | return 1; |
| 205 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 206 | return 0; |
| 207 | |
| 208 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 209 | return 1; |
| 210 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 211 | return 0; |
| 212 | |
| 213 | /* 4. AS path length check. */ |
| 214 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 215 | { |
| 216 | if (new->attr->aspath->count < exist->attr->aspath->count) |
| 217 | return 1; |
| 218 | if (new->attr->aspath->count > exist->attr->aspath->count) |
| 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | /* 5. Origin check. */ |
| 223 | if (new->attr->origin < exist->attr->origin) |
| 224 | return 1; |
| 225 | if (new->attr->origin > exist->attr->origin) |
| 226 | return 0; |
| 227 | |
| 228 | /* 6. MED check. */ |
| 229 | internal_as_route = (new->attr->aspath->length == 0 |
| 230 | && exist->attr->aspath->length == 0); |
| 231 | confed_as_route = (new->attr->aspath->length > 0 |
| 232 | && exist->attr->aspath->length > 0 |
| 233 | && new->attr->aspath->count == 0 |
| 234 | && exist->attr->aspath->count == 0); |
| 235 | |
| 236 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 237 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 238 | && confed_as_route) |
| 239 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 240 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 241 | || internal_as_route) |
| 242 | { |
| 243 | new_med = bgp_med_value (new->attr, bgp); |
| 244 | exist_med = bgp_med_value (exist->attr, bgp); |
| 245 | |
| 246 | if (new_med < exist_med) |
| 247 | return 1; |
| 248 | if (new_med > exist_med) |
| 249 | return 0; |
| 250 | } |
| 251 | |
| 252 | /* 7. Peer type check. */ |
| 253 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 254 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 255 | return 1; |
| 256 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 257 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 258 | return 1; |
| 259 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 260 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 261 | return 0; |
| 262 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 263 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 264 | return 0; |
| 265 | |
| 266 | /* 8. IGP metric check. */ |
| 267 | if (new->igpmetric < exist->igpmetric) |
| 268 | return 1; |
| 269 | if (new->igpmetric > exist->igpmetric) |
| 270 | return 0; |
| 271 | |
| 272 | /* 9. Maximum path check. */ |
| 273 | |
| 274 | /* 10. If both paths are external, prefer the path that was received |
| 275 | first (the oldest one). This step minimizes route-flap, since a |
| 276 | newer path won't displace an older one, even if it was the |
| 277 | preferred route based on the additional decision criteria below. */ |
| 278 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 279 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 280 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 281 | { |
| 282 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 283 | return 1; |
| 284 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | /* 11. Rourter-ID comparision. */ |
| 289 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 290 | new_id.s_addr = new->attr->originator_id.s_addr; |
| 291 | else |
| 292 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 293 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 294 | exist_id.s_addr = exist->attr->originator_id.s_addr; |
| 295 | else |
| 296 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 297 | |
| 298 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 299 | return 1; |
| 300 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 301 | return 0; |
| 302 | |
| 303 | /* 12. Cluster length comparision. */ |
| 304 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 305 | new_cluster = new->attr->cluster->length; |
| 306 | else |
| 307 | new_cluster = 0; |
| 308 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 309 | exist_cluster = exist->attr->cluster->length; |
| 310 | else |
| 311 | exist_cluster = 0; |
| 312 | |
| 313 | if (new_cluster < exist_cluster) |
| 314 | return 1; |
| 315 | if (new_cluster > exist_cluster) |
| 316 | return 0; |
| 317 | |
| 318 | /* 13. Neighbor address comparision. */ |
| 319 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 320 | |
| 321 | if (ret == 1) |
| 322 | return 0; |
| 323 | if (ret == -1) |
| 324 | return 1; |
| 325 | |
| 326 | return 1; |
| 327 | } |
| 328 | |
| 329 | enum filter_type |
| 330 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 331 | afi_t afi, safi_t safi) |
| 332 | { |
| 333 | struct bgp_filter *filter; |
| 334 | |
| 335 | filter = &peer->filter[afi][safi]; |
| 336 | |
| 337 | if (DISTRIBUTE_IN_NAME (filter)) |
| 338 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 339 | return FILTER_DENY; |
| 340 | |
| 341 | if (PREFIX_LIST_IN_NAME (filter)) |
| 342 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 343 | return FILTER_DENY; |
| 344 | |
| 345 | if (FILTER_LIST_IN_NAME (filter)) |
| 346 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 347 | return FILTER_DENY; |
| 348 | |
| 349 | return FILTER_PERMIT; |
| 350 | } |
| 351 | |
| 352 | enum filter_type |
| 353 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 354 | afi_t afi, safi_t safi) |
| 355 | { |
| 356 | struct bgp_filter *filter; |
| 357 | |
| 358 | filter = &peer->filter[afi][safi]; |
| 359 | |
| 360 | if (DISTRIBUTE_OUT_NAME (filter)) |
| 361 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 362 | return FILTER_DENY; |
| 363 | |
| 364 | if (PREFIX_LIST_OUT_NAME (filter)) |
| 365 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 366 | return FILTER_DENY; |
| 367 | |
| 368 | if (FILTER_LIST_OUT_NAME (filter)) |
| 369 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 370 | return FILTER_DENY; |
| 371 | |
| 372 | return FILTER_PERMIT; |
| 373 | } |
| 374 | |
| 375 | /* If community attribute includes no_export then return 1. */ |
| 376 | int |
| 377 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 378 | { |
| 379 | if (attr->community) |
| 380 | { |
| 381 | /* NO_ADVERTISE check. */ |
| 382 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 383 | return 1; |
| 384 | |
| 385 | /* NO_EXPORT check. */ |
| 386 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 387 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 388 | return 1; |
| 389 | |
| 390 | /* NO_EXPORT_SUBCONFED check. */ |
| 391 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 392 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 393 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 394 | return 1; |
| 395 | } |
| 396 | return 0; |
| 397 | } |
| 398 | |
| 399 | /* Route reflection loop check. */ |
| 400 | static int |
| 401 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 402 | { |
| 403 | struct in_addr cluster_id; |
| 404 | |
| 405 | if (attr->cluster) |
| 406 | { |
| 407 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 408 | cluster_id = peer->bgp->cluster_id; |
| 409 | else |
| 410 | cluster_id = peer->bgp->router_id; |
| 411 | |
| 412 | if (cluster_loop_check (attr->cluster, cluster_id)) |
| 413 | return 1; |
| 414 | } |
| 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | int |
| 419 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 420 | afi_t afi, safi_t safi) |
| 421 | { |
| 422 | struct bgp_filter *filter; |
| 423 | struct bgp_info info; |
| 424 | route_map_result_t ret; |
| 425 | |
| 426 | filter = &peer->filter[afi][safi]; |
| 427 | |
| 428 | /* Apply default weight value. */ |
| 429 | attr->weight = peer->weight; |
| 430 | |
| 431 | /* Route map apply. */ |
| 432 | if (ROUTE_MAP_IN_NAME (filter)) |
| 433 | { |
| 434 | /* Duplicate current value to new strucutre for modification. */ |
| 435 | info.peer = peer; |
| 436 | info.attr = attr; |
| 437 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 438 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 439 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 440 | /* Apply BGP route map to the attribute. */ |
| 441 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 442 | |
| 443 | peer->rmap_type = 0; |
| 444 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 445 | if (ret == RMAP_DENYMATCH) |
| 446 | { |
| 447 | /* Free newly generated AS path and community by route-map. */ |
| 448 | bgp_attr_flush (attr); |
| 449 | return RMAP_DENY; |
| 450 | } |
| 451 | } |
| 452 | return RMAP_PERMIT; |
| 453 | } |
| 454 | |
| 455 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 456 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 457 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 458 | { |
| 459 | struct bgp_filter *filter; |
| 460 | struct bgp_info info; |
| 461 | route_map_result_t ret; |
| 462 | |
| 463 | filter = &peer->filter[afi][safi]; |
| 464 | |
| 465 | /* Route map apply. */ |
| 466 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 467 | { |
| 468 | /* Duplicate current value to new strucutre for modification. */ |
| 469 | info.peer = rsclient; |
| 470 | info.attr = attr; |
| 471 | |
| 472 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 473 | |
| 474 | /* Apply BGP route map to the attribute. */ |
| 475 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 476 | |
| 477 | rsclient->rmap_type = 0; |
| 478 | |
| 479 | if (ret == RMAP_DENYMATCH) |
| 480 | { |
| 481 | /* Free newly generated AS path and community by route-map. */ |
| 482 | bgp_attr_flush (attr); |
| 483 | return RMAP_DENY; |
| 484 | } |
| 485 | } |
| 486 | return RMAP_PERMIT; |
| 487 | } |
| 488 | |
| 489 | int |
| 490 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 491 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 492 | { |
| 493 | struct bgp_filter *filter; |
| 494 | struct bgp_info info; |
| 495 | route_map_result_t ret; |
| 496 | |
| 497 | filter = &rsclient->filter[afi][safi]; |
| 498 | |
| 499 | /* Apply default weight value. */ |
| 500 | attr->weight = peer->weight; |
| 501 | |
| 502 | /* Route map apply. */ |
| 503 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 504 | { |
| 505 | /* Duplicate current value to new strucutre for modification. */ |
| 506 | info.peer = peer; |
| 507 | info.attr = attr; |
| 508 | |
| 509 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 510 | |
| 511 | /* Apply BGP route map to the attribute. */ |
| 512 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 513 | |
| 514 | peer->rmap_type = 0; |
| 515 | |
| 516 | if (ret == RMAP_DENYMATCH) |
| 517 | { |
| 518 | /* Free newly generated AS path and community by route-map. */ |
| 519 | bgp_attr_flush (attr); |
| 520 | return RMAP_DENY; |
| 521 | } |
| 522 | } |
| 523 | return RMAP_PERMIT; |
| 524 | } |
| 525 | |
| 526 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 527 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 528 | struct attr *attr, afi_t afi, safi_t safi) |
| 529 | { |
| 530 | int ret; |
| 531 | char buf[SU_ADDRSTRLEN]; |
| 532 | struct bgp_filter *filter; |
| 533 | struct bgp_info info; |
| 534 | struct peer *from; |
| 535 | struct bgp *bgp; |
| 536 | struct attr dummy_attr; |
| 537 | int transparent; |
| 538 | int reflect; |
| 539 | |
| 540 | from = ri->peer; |
| 541 | filter = &peer->filter[afi][safi]; |
| 542 | bgp = peer->bgp; |
| 543 | |
| 544 | #ifdef DISABLE_BGP_ANNOUNCE |
| 545 | return 0; |
| 546 | #endif |
| 547 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 548 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 549 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 550 | return 0; |
| 551 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 552 | /* Do not send back route to sender. */ |
| 553 | if (from == peer) |
| 554 | return 0; |
| 555 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 556 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 557 | if (p->family == AF_INET |
| 558 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 559 | return 0; |
| 560 | #ifdef HAVE_IPV6 |
| 561 | if (p->family == AF_INET6 |
| 562 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 563 | return 0; |
| 564 | #endif |
| 565 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 566 | /* Aggregate-address suppress check. */ |
| 567 | if (ri->suppress) |
| 568 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 569 | return 0; |
| 570 | |
| 571 | /* Default route check. */ |
| 572 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 573 | { |
| 574 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 575 | return 0; |
| 576 | #ifdef HAVE_IPV6 |
| 577 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 578 | return 0; |
| 579 | #endif /* HAVE_IPV6 */ |
| 580 | } |
| 581 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 582 | /* Transparency check. */ |
| 583 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 584 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 585 | transparent = 1; |
| 586 | else |
| 587 | transparent = 0; |
| 588 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 589 | /* If community is not disabled check the no-export and local. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 590 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 591 | return 0; |
| 592 | |
| 593 | /* If the attribute has originator-id and it is same as remote |
| 594 | peer's id. */ |
| 595 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 596 | { |
| 597 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id)) |
| 598 | { |
| 599 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 600 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 601 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 602 | peer->host, |
| 603 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 604 | p->prefixlen); |
| 605 | return 0; |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | /* ORF prefix-list filter check */ |
| 610 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 611 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 612 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 613 | if (peer->orf_plist[afi][safi]) |
| 614 | { |
| 615 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 616 | return 0; |
| 617 | } |
| 618 | |
| 619 | /* Output filter check. */ |
| 620 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) |
| 621 | { |
| 622 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 623 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 624 | "%s [Update:SEND] %s/%d is filtered", |
| 625 | peer->host, |
| 626 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 627 | p->prefixlen); |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | #ifdef BGP_SEND_ASPATH_CHECK |
| 632 | /* AS path loop check. */ |
| 633 | if (aspath_loop_check (ri->attr->aspath, peer->as)) |
| 634 | { |
| 635 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 636 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 637 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 638 | peer->host, peer->as); |
| 639 | return 0; |
| 640 | } |
| 641 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 642 | |
| 643 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 644 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 645 | { |
| 646 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) |
| 647 | { |
| 648 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 649 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 650 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 651 | peer->host, |
| 652 | bgp->confed_id); |
| 653 | return 0; |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | /* Route-Reflect check. */ |
| 658 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 659 | reflect = 1; |
| 660 | else |
| 661 | reflect = 0; |
| 662 | |
| 663 | /* IBGP reflection check. */ |
| 664 | if (reflect) |
| 665 | { |
| 666 | /* A route from a Client peer. */ |
| 667 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 668 | { |
| 669 | /* Reflect to all the Non-Client peers and also to the |
| 670 | Client peers other than the originator. Originator check |
| 671 | is already done. So there is noting to do. */ |
| 672 | /* no bgp client-to-client reflection check. */ |
| 673 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 674 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 675 | return 0; |
| 676 | } |
| 677 | else |
| 678 | { |
| 679 | /* A route from a Non-client peer. Reflect to all other |
| 680 | clients. */ |
| 681 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 682 | return 0; |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | /* For modify attribute, copy it to temporary structure. */ |
| 687 | *attr = *ri->attr; |
| 688 | |
| 689 | /* If local-preference is not set. */ |
| 690 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 691 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 692 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 693 | { |
| 694 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 695 | attr->local_pref = bgp->default_local_pref; |
| 696 | } |
| 697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 698 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 699 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 700 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 701 | { |
| 702 | if (ri->peer != bgp->peer_self && ! transparent |
| 703 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 704 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 705 | } |
| 706 | |
| 707 | /* next-hop-set */ |
| 708 | if (transparent || reflect |
| 709 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 710 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 711 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 712 | || (p->family == AF_INET6 && |
| 713 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 714 | #endif /* HAVE_IPV6 */ |
| 715 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 716 | { |
| 717 | /* NEXT-HOP Unchanged. */ |
| 718 | } |
| 719 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 720 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 721 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 722 | || (p->family == AF_INET6 && |
| 723 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 724 | #endif /* HAVE_IPV6 */ |
| 725 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 726 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 727 | { |
| 728 | /* Set IPv4 nexthop. */ |
| 729 | if (p->family == AF_INET) |
| 730 | { |
| 731 | if (safi == SAFI_MPLS_VPN) |
| 732 | memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 733 | else |
| 734 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 735 | } |
| 736 | #ifdef HAVE_IPV6 |
| 737 | /* Set IPv6 nexthop. */ |
| 738 | if (p->family == AF_INET6) |
| 739 | { |
| 740 | /* IPv6 global nexthop must be included. */ |
| 741 | memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global, |
| 742 | IPV6_MAX_BYTELEN); |
| 743 | attr->mp_nexthop_len = 16; |
| 744 | } |
| 745 | #endif /* HAVE_IPV6 */ |
| 746 | } |
| 747 | |
| 748 | #ifdef HAVE_IPV6 |
| 749 | if (p->family == AF_INET6) |
| 750 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 751 | /* Left nexthop_local unchanged if so configured. */ |
| 752 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 753 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 754 | { |
| 755 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 756 | attr->mp_nexthop_len=32; |
| 757 | else |
| 758 | attr->mp_nexthop_len=16; |
| 759 | } |
| 760 | |
| 761 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 762 | else |
| 763 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 764 | /* Link-local address should not be transit to different peer. */ |
| 765 | attr->mp_nexthop_len = 16; |
| 766 | |
| 767 | /* Set link-local address for shared network peer. */ |
| 768 | if (peer->shared_network |
| 769 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 770 | { |
| 771 | memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local, |
| 772 | IPV6_MAX_BYTELEN); |
| 773 | attr->mp_nexthop_len = 32; |
| 774 | } |
| 775 | |
| 776 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 777 | address.*/ |
| 778 | if (reflect) |
| 779 | attr->mp_nexthop_len = 16; |
| 780 | |
| 781 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 782 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
| 783 | attr->mp_nexthop_len = 16; |
| 784 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 785 | |
| 786 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | #endif /* HAVE_IPV6 */ |
| 788 | |
| 789 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 790 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 791 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 792 | && aspath_private_as_check (attr->aspath)) |
| 793 | attr->aspath = aspath_empty_get (); |
| 794 | |
| 795 | /* Route map & unsuppress-map apply. */ |
| 796 | if (ROUTE_MAP_OUT_NAME (filter) |
| 797 | || ri->suppress) |
| 798 | { |
| 799 | info.peer = peer; |
| 800 | info.attr = attr; |
| 801 | |
| 802 | /* The route reflector is not allowed to modify the attributes |
| 803 | of the reflected IBGP routes. */ |
| 804 | if (peer_sort (from) == BGP_PEER_IBGP |
| 805 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 806 | { |
| 807 | dummy_attr = *attr; |
| 808 | info.attr = &dummy_attr; |
| 809 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 810 | |
| 811 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 812 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 813 | if (ri->suppress) |
| 814 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 815 | else |
| 816 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 817 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 818 | peer->rmap_type = 0; |
| 819 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 820 | if (ret == RMAP_DENYMATCH) |
| 821 | { |
| 822 | bgp_attr_flush (attr); |
| 823 | return 0; |
| 824 | } |
| 825 | } |
| 826 | return 1; |
| 827 | } |
| 828 | |
| 829 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 830 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 831 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 832 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 833 | int ret; |
| 834 | char buf[SU_ADDRSTRLEN]; |
| 835 | struct bgp_filter *filter; |
| 836 | struct bgp_info info; |
| 837 | struct peer *from; |
| 838 | struct bgp *bgp; |
| 839 | |
| 840 | from = ri->peer; |
| 841 | filter = &rsclient->filter[afi][safi]; |
| 842 | bgp = rsclient->bgp; |
| 843 | |
| 844 | #ifdef DISABLE_BGP_ANNOUNCE |
| 845 | return 0; |
| 846 | #endif |
| 847 | |
| 848 | /* Do not send back route to sender. */ |
| 849 | if (from == rsclient) |
| 850 | return 0; |
| 851 | |
| 852 | /* Aggregate-address suppress check. */ |
| 853 | if (ri->suppress) |
| 854 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 855 | return 0; |
| 856 | |
| 857 | /* Default route check. */ |
| 858 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 859 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 860 | { |
| 861 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 862 | return 0; |
| 863 | #ifdef HAVE_IPV6 |
| 864 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 865 | return 0; |
| 866 | #endif /* HAVE_IPV6 */ |
| 867 | } |
| 868 | |
| 869 | /* If the attribute has originator-id and it is same as remote |
| 870 | peer's id. */ |
| 871 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 872 | { |
| 873 | if (IPV4_ADDR_SAME (&rsclient->remote_id, &ri->attr->originator_id)) |
| 874 | { |
| 875 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 876 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 877 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 878 | rsclient->host, |
| 879 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 880 | p->prefixlen); |
| 881 | return 0; |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | /* ORF prefix-list filter check */ |
| 886 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 887 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 888 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 889 | if (rsclient->orf_plist[afi][safi]) |
| 890 | { |
| 891 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 892 | return 0; |
| 893 | } |
| 894 | |
| 895 | /* Output filter check. */ |
| 896 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) |
| 897 | { |
| 898 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 899 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 900 | "%s [Update:SEND] %s/%d is filtered", |
| 901 | rsclient->host, |
| 902 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 903 | p->prefixlen); |
| 904 | return 0; |
| 905 | } |
| 906 | |
| 907 | #ifdef BGP_SEND_ASPATH_CHECK |
| 908 | /* AS path loop check. */ |
| 909 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) |
| 910 | { |
| 911 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 912 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 913 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 914 | rsclient->host, rsclient->as); |
| 915 | return 0; |
| 916 | } |
| 917 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 918 | |
| 919 | /* For modify attribute, copy it to temporary structure. */ |
| 920 | *attr = *ri->attr; |
| 921 | |
| 922 | /* next-hop-set */ |
| 923 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 924 | #ifdef HAVE_IPV6 |
| 925 | || (p->family == AF_INET6 && |
| 926 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
| 927 | #endif /* HAVE_IPV6 */ |
| 928 | ) |
| 929 | { |
| 930 | /* Set IPv4 nexthop. */ |
| 931 | if (p->family == AF_INET) |
| 932 | { |
| 933 | if (safi == SAFI_MPLS_VPN) |
| 934 | memcpy (&attr->mp_nexthop_global_in, &rsclient->nexthop.v4, |
| 935 | IPV4_MAX_BYTELEN); |
| 936 | else |
| 937 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 938 | } |
| 939 | #ifdef HAVE_IPV6 |
| 940 | /* Set IPv6 nexthop. */ |
| 941 | if (p->family == AF_INET6) |
| 942 | { |
| 943 | /* IPv6 global nexthop must be included. */ |
| 944 | memcpy (&attr->mp_nexthop_global, &rsclient->nexthop.v6_global, |
| 945 | |
| 946 | IPV6_MAX_BYTELEN); |
| 947 | attr->mp_nexthop_len = 16; |
| 948 | } |
| 949 | #endif /* HAVE_IPV6 */ |
| 950 | } |
| 951 | |
| 952 | #ifdef HAVE_IPV6 |
| 953 | if (p->family == AF_INET6) |
| 954 | { |
| 955 | /* Left nexthop_local unchanged if so configured. */ |
| 956 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 957 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 958 | { |
| 959 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 960 | attr->mp_nexthop_len=32; |
| 961 | else |
| 962 | attr->mp_nexthop_len=16; |
| 963 | } |
| 964 | |
| 965 | /* Default nexthop_local treatment for RS-Clients */ |
| 966 | else |
| 967 | { |
| 968 | /* Announcer and RS-Client are both in the same network */ |
| 969 | if (rsclient->shared_network && from->shared_network && |
| 970 | (rsclient->ifindex == from->ifindex)) |
| 971 | { |
| 972 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 973 | attr->mp_nexthop_len=32; |
| 974 | else |
| 975 | attr->mp_nexthop_len=16; |
| 976 | } |
| 977 | |
| 978 | /* Set link-local address for shared network peer. */ |
| 979 | else if (rsclient->shared_network |
| 980 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 981 | { |
| 982 | memcpy (&attr->mp_nexthop_local, &rsclient->nexthop.v6_local, |
| 983 | IPV6_MAX_BYTELEN); |
| 984 | attr->mp_nexthop_len = 32; |
| 985 | } |
| 986 | |
| 987 | else |
| 988 | attr->mp_nexthop_len = 16; |
| 989 | } |
| 990 | |
| 991 | } |
| 992 | #endif /* HAVE_IPV6 */ |
| 993 | |
| 994 | |
| 995 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 996 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 997 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 998 | && aspath_private_as_check (attr->aspath)) |
| 999 | attr->aspath = aspath_empty_get (); |
| 1000 | |
| 1001 | /* Route map & unsuppress-map apply. */ |
| 1002 | if (ROUTE_MAP_OUT_NAME (filter) || ri->suppress) |
| 1003 | { |
| 1004 | info.peer = rsclient; |
| 1005 | info.attr = attr; |
| 1006 | |
| 1007 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1008 | |
| 1009 | if (ri->suppress) |
| 1010 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1011 | else |
| 1012 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1013 | |
| 1014 | rsclient->rmap_type = 0; |
| 1015 | |
| 1016 | if (ret == RMAP_DENYMATCH) |
| 1017 | { |
| 1018 | bgp_attr_flush (attr); |
| 1019 | return 0; |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | return 1; |
| 1024 | } |
| 1025 | |
| 1026 | struct bgp_info_pair |
| 1027 | { |
| 1028 | struct bgp_info *old; |
| 1029 | struct bgp_info *new; |
| 1030 | }; |
| 1031 | |
| 1032 | void |
| 1033 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
| 1034 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1035 | struct bgp_info *new_select; |
| 1036 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1037 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1038 | struct bgp_info *ri1; |
| 1039 | struct bgp_info *ri2; |
| 1040 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1041 | /* bgp deterministic-med */ |
| 1042 | new_select = NULL; |
| 1043 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1044 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1045 | { |
| 1046 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1047 | continue; |
| 1048 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1049 | continue; |
| 1050 | |
| 1051 | new_select = ri1; |
| 1052 | if (ri1->next) |
| 1053 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1054 | { |
| 1055 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1056 | continue; |
| 1057 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1058 | continue; |
| 1059 | |
| 1060 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1061 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1062 | ri2->attr->aspath)) |
| 1063 | { |
| 1064 | if (bgp_info_cmp (bgp, ri2, new_select)) |
| 1065 | { |
| 1066 | UNSET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1067 | new_select = ri2; |
| 1068 | } |
| 1069 | |
| 1070 | SET_FLAG (ri2->flags, BGP_INFO_DMED_CHECK); |
| 1071 | } |
| 1072 | } |
| 1073 | SET_FLAG (new_select->flags, BGP_INFO_DMED_CHECK); |
| 1074 | SET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1075 | } |
| 1076 | |
| 1077 | /* Check old selected route and new selected route. */ |
| 1078 | old_select = NULL; |
| 1079 | new_select = NULL; |
| 1080 | for (ri = rn->info; ri; ri = ri->next) |
| 1081 | { |
| 1082 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1083 | old_select = ri; |
| 1084 | |
| 1085 | if (BGP_INFO_HOLDDOWN (ri)) |
| 1086 | continue; |
| 1087 | |
| 1088 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1089 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1090 | { |
| 1091 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1092 | continue; |
| 1093 | } |
| 1094 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1095 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_SELECTED); |
| 1096 | |
| 1097 | if (bgp_info_cmp (bgp, ri, new_select)) |
| 1098 | new_select = ri; |
| 1099 | } |
| 1100 | |
hasso | 6d69429 | 2005-01-24 09:29:42 +0000 | [diff] [blame] | 1101 | if ( (! old_select) || old_select != new_select |
| 1102 | || CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1103 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1104 | if (old_select) |
| 1105 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1106 | if (new_select) |
| 1107 | { |
| 1108 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1109 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1110 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1111 | } |
| 1112 | |
| 1113 | result->old = old_select; |
| 1114 | result->new = new_select; |
| 1115 | |
| 1116 | return; |
| 1117 | } |
| 1118 | |
| 1119 | int |
| 1120 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
| 1121 | struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi) |
| 1122 | { |
| 1123 | struct prefix *p; |
| 1124 | |
| 1125 | p = &rn->p; |
| 1126 | |
| 1127 | /* Announce route to Established peer. */ |
| 1128 | if (peer->status != Established) |
| 1129 | return 0; |
| 1130 | |
| 1131 | /* Address family configuration check. */ |
| 1132 | if (! peer->afc_nego[afi][safi]) |
| 1133 | return 0; |
| 1134 | |
| 1135 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 1136 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1137 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1138 | return 0; |
| 1139 | |
| 1140 | switch (rn->table->type) |
| 1141 | { |
| 1142 | case BGP_TABLE_MAIN: |
| 1143 | /* Announcement to peer->conf. If the route is filtered, |
| 1144 | withdraw it. */ |
| 1145 | if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi)) |
| 1146 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1147 | else |
| 1148 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1149 | break; |
| 1150 | case BGP_TABLE_RSCLIENT: |
| 1151 | /* Announcement to peer->conf. If the route is filtered, |
| 1152 | withdraw it. */ |
| 1153 | if (selected && bgp_announce_check_rsclient |
| 1154 | (selected, peer, p, attr, afi, safi)) |
| 1155 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1156 | else |
| 1157 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1158 | break; |
| 1159 | } |
| 1160 | return 0; |
| 1161 | } |
| 1162 | |
| 1163 | int |
| 1164 | bgp_process_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 1165 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1166 | { |
| 1167 | struct prefix *p; |
| 1168 | struct bgp_info *new_select; |
| 1169 | struct bgp_info *old_select; |
| 1170 | struct bgp_info_pair old_and_new; |
| 1171 | struct attr attr; |
| 1172 | struct peer_group *group; |
| 1173 | struct listnode *nn; |
| 1174 | |
| 1175 | p = &rn->p; |
| 1176 | |
| 1177 | /* Best path selection. */ |
| 1178 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1179 | new_select = old_and_new.new; |
| 1180 | old_select = old_and_new.old; |
| 1181 | |
| 1182 | if (CHECK_FLAG(rsclient->sflags, PEER_STATUS_GROUP)) |
| 1183 | { |
| 1184 | group = rsclient->group; |
| 1185 | LIST_LOOP(group->peer, rsclient, nn) |
| 1186 | { |
| 1187 | /* Nothing to do. */ |
| 1188 | if (old_select && old_select == new_select) |
| 1189 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1190 | continue; |
| 1191 | |
| 1192 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, |
| 1193 | afi, safi); |
| 1194 | } |
| 1195 | return 0; |
| 1196 | } |
| 1197 | |
| 1198 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, afi, safi); |
| 1199 | |
| 1200 | return 0; |
| 1201 | } |
| 1202 | |
| 1203 | int |
| 1204 | bgp_process_main (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1205 | { |
| 1206 | struct prefix *p; |
| 1207 | struct bgp_info *new_select; |
| 1208 | struct bgp_info *old_select; |
| 1209 | struct bgp_info_pair old_and_new; |
| 1210 | struct listnode *nn; |
| 1211 | struct peer *peer; |
| 1212 | struct attr attr; |
| 1213 | |
| 1214 | p = &rn->p; |
| 1215 | |
| 1216 | /* Best path selection. */ |
| 1217 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1218 | old_select = old_and_new.old; |
| 1219 | new_select = old_and_new.new; |
| 1220 | |
| 1221 | /* Nothing to do. */ |
| 1222 | if (old_select && old_select == new_select) |
| 1223 | { |
| 1224 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1225 | { |
| 1226 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) |
| 1227 | bgp_zebra_announce (p, old_select, bgp); |
| 1228 | return 0; |
| 1229 | } |
| 1230 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1231 | |
| 1232 | /* Check each BGP peer. */ |
| 1233 | LIST_LOOP (bgp->peer, peer, nn) |
| 1234 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1235 | bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1236 | } |
| 1237 | |
| 1238 | /* FIB update. */ |
| 1239 | if (safi == SAFI_UNICAST && ! bgp->name && |
| 1240 | ! bgp_option_check (BGP_OPT_NO_FIB)) |
| 1241 | { |
| 1242 | if (new_select |
| 1243 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1244 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
| 1245 | bgp_zebra_announce (p, new_select, bgp); |
| 1246 | else |
| 1247 | { |
| 1248 | /* Withdraw the route from the kernel. */ |
| 1249 | if (old_select |
| 1250 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1251 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
| 1252 | bgp_zebra_withdraw (p, old_select); |
| 1253 | } |
| 1254 | } |
| 1255 | return 0; |
| 1256 | } |
| 1257 | |
| 1258 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1259 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1260 | { |
| 1261 | switch (rn->table->type) |
| 1262 | { |
| 1263 | case BGP_TABLE_MAIN: |
| 1264 | return bgp_process_main (bgp, rn, afi, safi); |
| 1265 | case BGP_TABLE_RSCLIENT: |
| 1266 | return bgp_process_rsclient (bgp, (struct peer *) rn->table->owner, |
| 1267 | rn, afi, safi); |
| 1268 | } |
| 1269 | return 0; |
| 1270 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1271 | |
| 1272 | int |
| 1273 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1274 | { |
| 1275 | struct peer *peer; |
| 1276 | |
| 1277 | peer = THREAD_ARG (thread); |
| 1278 | peer->t_pmax_restart = NULL; |
| 1279 | |
| 1280 | if (BGP_DEBUG (events, EVENTS)) |
| 1281 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1282 | peer->host); |
| 1283 | |
| 1284 | peer_clear (peer); |
| 1285 | |
| 1286 | return 0; |
| 1287 | } |
| 1288 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1289 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1290 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1291 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1292 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1293 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1294 | return 0; |
| 1295 | |
| 1296 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1297 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1298 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1299 | && ! always) |
| 1300 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1301 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1302 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1303 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1304 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1305 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1306 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1307 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1308 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1309 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1310 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1311 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1312 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1313 | |
| 1314 | if (safi == SAFI_MPLS_VPN) |
| 1315 | safi = BGP_SAFI_VPNV4; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1316 | |
| 1317 | ndata[0] = (afi >> 8); |
| 1318 | ndata[1] = afi; |
| 1319 | ndata[2] = safi; |
| 1320 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1321 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1322 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1323 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1324 | |
| 1325 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1326 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1327 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1328 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1329 | |
| 1330 | /* restart timer start */ |
| 1331 | if (peer->pmax_restart[afi][safi]) |
| 1332 | { |
| 1333 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1334 | |
| 1335 | if (BGP_DEBUG (events, EVENTS)) |
| 1336 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1337 | peer->host, peer->v_pmax_restart); |
| 1338 | |
| 1339 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1340 | peer->v_pmax_restart); |
| 1341 | } |
| 1342 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1343 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1344 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1345 | else |
| 1346 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1347 | |
| 1348 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1349 | { |
| 1350 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1351 | && ! always) |
| 1352 | return 0; |
| 1353 | |
| 1354 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1355 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1356 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1357 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1358 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1359 | } |
| 1360 | else |
| 1361 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1362 | return 0; |
| 1363 | } |
| 1364 | |
| 1365 | void |
| 1366 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1367 | afi_t afi, safi_t safi) |
| 1368 | { |
| 1369 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1370 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1371 | /* Ignore 'pcount' for RS-client tables */ |
| 1372 | if ( rn->table->type == BGP_TABLE_MAIN) |
| 1373 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1374 | peer->pcount[afi][safi]--; |
| 1375 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1376 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1377 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1378 | bgp_process (peer->bgp, rn, afi, safi); |
| 1379 | } |
| 1380 | bgp_info_delete (rn, ri); |
| 1381 | bgp_info_free (ri); |
| 1382 | bgp_unlock_node (rn); |
| 1383 | } |
| 1384 | |
| 1385 | void |
| 1386 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1387 | afi_t afi, safi_t safi, int force) |
| 1388 | { |
| 1389 | int valid; |
| 1390 | int status = BGP_DAMP_NONE; |
| 1391 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1392 | /* Ignore 'pcount' for RS-client tables */ |
| 1393 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) && |
| 1394 | rn->table->type == BGP_TABLE_MAIN) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1395 | { |
| 1396 | peer->pcount[afi][safi]--; |
| 1397 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1398 | } |
| 1399 | |
| 1400 | if (! force) |
| 1401 | { |
| 1402 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1403 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1404 | status = bgp_damp_withdraw (ri, rn, afi, safi, 0); |
| 1405 | |
| 1406 | if (status == BGP_DAMP_SUPPRESSED) |
| 1407 | return; |
| 1408 | } |
| 1409 | |
| 1410 | valid = CHECK_FLAG (ri->flags, BGP_INFO_VALID); |
| 1411 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1412 | bgp_process (peer->bgp, rn, afi, safi); |
| 1413 | |
| 1414 | if (valid) |
| 1415 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1416 | |
| 1417 | if (status != BGP_DAMP_USED) |
| 1418 | { |
| 1419 | bgp_info_delete (rn, ri); |
| 1420 | bgp_info_free (ri); |
| 1421 | bgp_unlock_node (rn); |
| 1422 | } |
| 1423 | } |
| 1424 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1425 | void |
| 1426 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1427 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1428 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1429 | { |
| 1430 | struct bgp_node *rn; |
| 1431 | struct bgp *bgp; |
| 1432 | struct attr new_attr; |
| 1433 | struct attr *attr_new; |
| 1434 | struct attr *attr_new2; |
| 1435 | struct bgp_info *ri; |
| 1436 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1437 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1438 | char buf[SU_ADDRSTRLEN]; |
| 1439 | |
| 1440 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1441 | if (peer == rsclient) |
| 1442 | return; |
| 1443 | |
| 1444 | bgp = peer->bgp; |
| 1445 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1446 | |
| 1447 | /* Check previously received route. */ |
| 1448 | for (ri = rn->info; ri; ri = ri->next) |
| 1449 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1450 | break; |
| 1451 | |
| 1452 | /* AS path loop check. */ |
| 1453 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1454 | { |
| 1455 | reason = "as-path contains our own AS;"; |
| 1456 | goto filtered; |
| 1457 | } |
| 1458 | |
| 1459 | /* Route reflector originator ID check. */ |
| 1460 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1461 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->originator_id)) |
| 1462 | { |
| 1463 | reason = "originator is us;"; |
| 1464 | goto filtered; |
| 1465 | } |
| 1466 | |
| 1467 | new_attr = *attr; |
| 1468 | |
| 1469 | /* Apply export policy. */ |
| 1470 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1471 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1472 | { |
| 1473 | reason = "export-policy;"; |
| 1474 | goto filtered; |
| 1475 | } |
| 1476 | |
| 1477 | attr_new2 = bgp_attr_intern (&new_attr); |
| 1478 | |
| 1479 | /* Apply import policy. */ |
| 1480 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1481 | { |
| 1482 | bgp_attr_unintern (attr_new2); |
| 1483 | |
| 1484 | reason = "import-policy;"; |
| 1485 | goto filtered; |
| 1486 | } |
| 1487 | |
| 1488 | attr_new = bgp_attr_intern (&new_attr); |
| 1489 | bgp_attr_unintern (attr_new2); |
| 1490 | |
| 1491 | /* IPv4 unicast next hop check. */ |
| 1492 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1493 | { |
| 1494 | /* Next hop must not be 0.0.0.0 nor Class E address. */ |
| 1495 | if (new_attr.nexthop.s_addr == 0 |
| 1496 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1497 | { |
| 1498 | bgp_attr_unintern (attr_new); |
| 1499 | |
| 1500 | reason = "martian next-hop;"; |
| 1501 | goto filtered; |
| 1502 | } |
| 1503 | } |
| 1504 | |
| 1505 | /* If the update is implicit withdraw. */ |
| 1506 | if (ri) |
| 1507 | { |
| 1508 | ri->uptime = time (NULL); |
| 1509 | |
| 1510 | /* Same attribute comes in. */ |
| 1511 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1512 | { |
| 1513 | |
| 1514 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1515 | |
| 1516 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1517 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1518 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1519 | peer->host, |
| 1520 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1521 | p->prefixlen, rsclient->host); |
| 1522 | |
| 1523 | bgp_unlock_node (rn); |
| 1524 | bgp_attr_unintern (attr_new); |
| 1525 | |
| 1526 | return; |
| 1527 | } |
| 1528 | |
| 1529 | /* Received Logging. */ |
| 1530 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1531 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1532 | peer->host, |
| 1533 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1534 | p->prefixlen, rsclient->host); |
| 1535 | |
| 1536 | /* The attribute is changed. */ |
| 1537 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1538 | |
| 1539 | /* Update to new attribute. */ |
| 1540 | bgp_attr_unintern (ri->attr); |
| 1541 | ri->attr = attr_new; |
| 1542 | |
| 1543 | /* Update MPLS tag. */ |
| 1544 | if (safi == SAFI_MPLS_VPN) |
| 1545 | memcpy (ri->tag, tag, 3); |
| 1546 | |
| 1547 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1548 | |
| 1549 | /* Process change. */ |
| 1550 | bgp_process (bgp, rn, afi, safi); |
| 1551 | bgp_unlock_node (rn); |
| 1552 | |
| 1553 | return; |
| 1554 | } |
| 1555 | |
| 1556 | /* Received Logging. */ |
| 1557 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1558 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1559 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1560 | peer->host, |
| 1561 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1562 | p->prefixlen, rsclient->host); |
| 1563 | } |
| 1564 | |
| 1565 | /* Make new BGP info. */ |
| 1566 | new = bgp_info_new (); |
| 1567 | new->type = type; |
| 1568 | new->sub_type = sub_type; |
| 1569 | new->peer = peer; |
| 1570 | new->attr = attr_new; |
| 1571 | new->uptime = time (NULL); |
| 1572 | |
| 1573 | /* Update MPLS tag. */ |
| 1574 | if (safi == SAFI_MPLS_VPN) |
| 1575 | memcpy (new->tag, tag, 3); |
| 1576 | |
| 1577 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1578 | |
| 1579 | /* Register new BGP information. */ |
| 1580 | bgp_info_add (rn, new); |
| 1581 | |
| 1582 | /* Process change. */ |
| 1583 | bgp_process (bgp, rn, afi, safi); |
| 1584 | |
| 1585 | return; |
| 1586 | |
| 1587 | filtered: |
| 1588 | |
| 1589 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 1590 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1591 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1592 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 1593 | peer->host, |
| 1594 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1595 | p->prefixlen, rsclient->host, reason); |
| 1596 | |
| 1597 | if (ri) |
| 1598 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 1); |
| 1599 | |
| 1600 | bgp_unlock_node (rn); |
| 1601 | |
| 1602 | return; |
| 1603 | } |
| 1604 | |
| 1605 | void |
| 1606 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1607 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 1608 | struct prefix_rd *prd, u_char *tag) |
| 1609 | { |
| 1610 | struct bgp_node *rn; |
| 1611 | struct bgp_info *ri; |
| 1612 | char buf[SU_ADDRSTRLEN]; |
| 1613 | |
| 1614 | if (rsclient == peer) |
| 1615 | return; |
| 1616 | |
| 1617 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1618 | |
| 1619 | /* Lookup withdrawn route. */ |
| 1620 | for (ri = rn->info; ri; ri = ri->next) |
| 1621 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1622 | break; |
| 1623 | |
| 1624 | /* Withdraw specified route from routing table. */ |
| 1625 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1626 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 0); |
| 1627 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1628 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1629 | "%s Can't find the route %s/%d", peer->host, |
| 1630 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1631 | p->prefixlen); |
| 1632 | |
| 1633 | /* Unlock bgp_node_get() lock. */ |
| 1634 | bgp_unlock_node (rn); |
| 1635 | } |
| 1636 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1638 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1639 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1640 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1641 | { |
| 1642 | int ret; |
| 1643 | int aspath_loop_count = 0; |
| 1644 | struct bgp_node *rn; |
| 1645 | struct bgp *bgp; |
| 1646 | struct attr new_attr; |
| 1647 | struct attr *attr_new; |
| 1648 | struct bgp_info *ri; |
| 1649 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1650 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1651 | char buf[SU_ADDRSTRLEN]; |
| 1652 | |
| 1653 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1654 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1655 | |
| 1656 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 1657 | Adj-RIBs-In. */ |
| 1658 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1659 | && peer != bgp->peer_self && ! soft_reconfig) |
| 1660 | bgp_adj_in_set (rn, peer, attr); |
| 1661 | |
| 1662 | /* Check previously received route. */ |
| 1663 | for (ri = rn->info; ri; ri = ri->next) |
| 1664 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1665 | break; |
| 1666 | |
| 1667 | /* AS path local-as loop check. */ |
| 1668 | if (peer->change_local_as) |
| 1669 | { |
| 1670 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 1671 | aspath_loop_count = 1; |
| 1672 | |
| 1673 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 1674 | { |
| 1675 | reason = "as-path contains our own AS;"; |
| 1676 | goto filtered; |
| 1677 | } |
| 1678 | } |
| 1679 | |
| 1680 | /* AS path loop check. */ |
| 1681 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 1682 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 1683 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 1684 | > peer->allowas_in[afi][safi])) |
| 1685 | { |
| 1686 | reason = "as-path contains our own AS;"; |
| 1687 | goto filtered; |
| 1688 | } |
| 1689 | |
| 1690 | /* Route reflector originator ID check. */ |
| 1691 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1692 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id)) |
| 1693 | { |
| 1694 | reason = "originator is us;"; |
| 1695 | goto filtered; |
| 1696 | } |
| 1697 | |
| 1698 | /* Route reflector cluster ID check. */ |
| 1699 | if (bgp_cluster_filter (peer, attr)) |
| 1700 | { |
| 1701 | reason = "reflected from the same cluster;"; |
| 1702 | goto filtered; |
| 1703 | } |
| 1704 | |
| 1705 | /* Apply incoming filter. */ |
| 1706 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 1707 | { |
| 1708 | reason = "filter;"; |
| 1709 | goto filtered; |
| 1710 | } |
| 1711 | |
| 1712 | /* Apply incoming route-map. */ |
| 1713 | new_attr = *attr; |
| 1714 | |
| 1715 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1716 | { |
| 1717 | reason = "route-map;"; |
| 1718 | goto filtered; |
| 1719 | } |
| 1720 | |
| 1721 | /* IPv4 unicast next hop check. */ |
| 1722 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1723 | { |
| 1724 | /* If the peer is EBGP and nexthop is not on connected route, |
| 1725 | discard it. */ |
| 1726 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
| 1727 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) |
| 1728 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP)) |
| 1729 | { |
| 1730 | reason = "non-connected next-hop;"; |
| 1731 | goto filtered; |
| 1732 | } |
| 1733 | |
| 1734 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop |
| 1735 | must not be my own address. */ |
| 1736 | if (bgp_nexthop_self (afi, &new_attr) |
| 1737 | || new_attr.nexthop.s_addr == 0 |
| 1738 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1739 | { |
| 1740 | reason = "martian next-hop;"; |
| 1741 | goto filtered; |
| 1742 | } |
| 1743 | } |
| 1744 | |
| 1745 | attr_new = bgp_attr_intern (&new_attr); |
| 1746 | |
| 1747 | /* If the update is implicit withdraw. */ |
| 1748 | if (ri) |
| 1749 | { |
| 1750 | ri->uptime = time (NULL); |
| 1751 | |
| 1752 | /* Same attribute comes in. */ |
| 1753 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1754 | { |
| 1755 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1756 | |
| 1757 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1758 | && peer_sort (peer) == BGP_PEER_EBGP |
| 1759 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1760 | { |
| 1761 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1762 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1763 | peer->host, |
| 1764 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1765 | p->prefixlen); |
| 1766 | |
| 1767 | peer->pcount[afi][safi]++; |
| 1768 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1769 | if (ret != BGP_DAMP_SUPPRESSED) |
| 1770 | { |
| 1771 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1772 | bgp_process (bgp, rn, afi, safi); |
| 1773 | } |
| 1774 | } |
| 1775 | else |
| 1776 | { |
| 1777 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1778 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1779 | "%s rcvd %s/%d...duplicate ignored", |
| 1780 | peer->host, |
| 1781 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1782 | p->prefixlen); |
| 1783 | } |
| 1784 | |
| 1785 | bgp_unlock_node (rn); |
| 1786 | bgp_attr_unintern (attr_new); |
| 1787 | return 0; |
| 1788 | } |
| 1789 | |
| 1790 | /* Received Logging. */ |
| 1791 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1792 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1793 | peer->host, |
| 1794 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1795 | p->prefixlen); |
| 1796 | |
| 1797 | /* The attribute is changed. */ |
| 1798 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1799 | |
| 1800 | /* Update bgp route dampening information. */ |
| 1801 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1802 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1803 | { |
| 1804 | /* This is implicit withdraw so we should update dampening |
| 1805 | information. */ |
| 1806 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1807 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
| 1808 | else |
| 1809 | peer->pcount[afi][safi]++; |
| 1810 | } |
| 1811 | |
| 1812 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 1813 | |
| 1814 | /* Update to new attribute. */ |
| 1815 | bgp_attr_unintern (ri->attr); |
| 1816 | ri->attr = attr_new; |
| 1817 | |
| 1818 | /* Update MPLS tag. */ |
| 1819 | if (safi == SAFI_MPLS_VPN) |
| 1820 | memcpy (ri->tag, tag, 3); |
| 1821 | |
| 1822 | /* Update bgp route dampening information. */ |
| 1823 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1824 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1825 | { |
| 1826 | /* Now we do normal update dampening. */ |
| 1827 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1828 | if (ret == BGP_DAMP_SUPPRESSED) |
| 1829 | { |
| 1830 | bgp_unlock_node (rn); |
| 1831 | return 0; |
| 1832 | } |
| 1833 | } |
| 1834 | |
| 1835 | /* Nexthop reachability check. */ |
| 1836 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 1837 | && safi == SAFI_UNICAST |
| 1838 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 1839 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
| 1840 | || CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP))) |
| 1841 | { |
| 1842 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
| 1843 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1844 | else |
| 1845 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1846 | } |
| 1847 | else |
| 1848 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1849 | |
| 1850 | /* Process change. */ |
| 1851 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1852 | |
| 1853 | bgp_process (bgp, rn, afi, safi); |
| 1854 | bgp_unlock_node (rn); |
| 1855 | return 0; |
| 1856 | } |
| 1857 | |
| 1858 | /* Received Logging. */ |
| 1859 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1860 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1861 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1862 | peer->host, |
| 1863 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1864 | p->prefixlen); |
| 1865 | } |
| 1866 | |
| 1867 | /* Increment prefix counter */ |
| 1868 | peer->pcount[afi][safi]++; |
| 1869 | |
| 1870 | /* Make new BGP info. */ |
| 1871 | new = bgp_info_new (); |
| 1872 | new->type = type; |
| 1873 | new->sub_type = sub_type; |
| 1874 | new->peer = peer; |
| 1875 | new->attr = attr_new; |
| 1876 | new->uptime = time (NULL); |
| 1877 | |
| 1878 | /* Update MPLS tag. */ |
| 1879 | if (safi == SAFI_MPLS_VPN) |
| 1880 | memcpy (new->tag, tag, 3); |
| 1881 | |
| 1882 | /* Nexthop reachability check. */ |
| 1883 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 1884 | && safi == SAFI_UNICAST |
| 1885 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 1886 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
| 1887 | || CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP))) |
| 1888 | { |
| 1889 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
| 1890 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1891 | else |
| 1892 | UNSET_FLAG (new->flags, BGP_INFO_VALID); |
| 1893 | } |
| 1894 | else |
| 1895 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1896 | |
| 1897 | /* Aggregate address increment. */ |
| 1898 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 1899 | |
| 1900 | /* Register new BGP information. */ |
| 1901 | bgp_info_add (rn, new); |
| 1902 | |
| 1903 | /* If maximum prefix count is configured and current prefix |
| 1904 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1905 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 1906 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1907 | |
| 1908 | /* Process change. */ |
| 1909 | bgp_process (bgp, rn, afi, safi); |
| 1910 | |
| 1911 | return 0; |
| 1912 | |
| 1913 | /* This BGP update is filtered. Log the reason then update BGP |
| 1914 | entry. */ |
| 1915 | filtered: |
| 1916 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1917 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1918 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 1919 | peer->host, |
| 1920 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1921 | p->prefixlen, reason); |
| 1922 | |
| 1923 | if (ri) |
| 1924 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 1); |
| 1925 | |
| 1926 | bgp_unlock_node (rn); |
| 1927 | |
| 1928 | return 0; |
| 1929 | } |
| 1930 | |
| 1931 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1932 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 1933 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1934 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1935 | { |
| 1936 | struct peer *rsclient; |
| 1937 | struct listnode *nn; |
| 1938 | struct bgp *bgp; |
| 1939 | int ret; |
| 1940 | |
| 1941 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 1942 | soft_reconfig); |
| 1943 | |
| 1944 | bgp = peer->bgp; |
| 1945 | |
| 1946 | /* Process the update for each RS-client. */ |
| 1947 | LIST_LOOP(bgp->rsclient, rsclient, nn) |
| 1948 | { |
| 1949 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 1950 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 1951 | sub_type, prd, tag); |
| 1952 | } |
| 1953 | |
| 1954 | return ret; |
| 1955 | } |
| 1956 | |
| 1957 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1958 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
| 1959 | int afi, int safi, int type, int sub_type, struct prefix_rd *prd, |
| 1960 | u_char *tag) |
| 1961 | { |
| 1962 | struct bgp *bgp; |
| 1963 | char buf[SU_ADDRSTRLEN]; |
| 1964 | struct bgp_node *rn; |
| 1965 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1966 | struct peer *rsclient; |
| 1967 | struct listnode *nn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1968 | |
| 1969 | bgp = peer->bgp; |
| 1970 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1971 | /* Process the withdraw for each RS-client. */ |
| 1972 | LIST_LOOP (bgp->rsclient, rsclient, nn) |
| 1973 | { |
| 1974 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 1975 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 1976 | } |
| 1977 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1978 | /* Logging. */ |
| 1979 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1980 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1981 | peer->host, |
| 1982 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1983 | p->prefixlen); |
| 1984 | |
| 1985 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1986 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1987 | |
| 1988 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 1989 | further calculation. */ |
| 1990 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1991 | && peer != bgp->peer_self) |
| 1992 | bgp_adj_in_unset (rn, peer); |
| 1993 | |
| 1994 | /* Lookup withdrawn route. */ |
| 1995 | for (ri = rn->info; ri; ri = ri->next) |
| 1996 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1997 | break; |
| 1998 | |
| 1999 | /* Withdraw specified route from routing table. */ |
| 2000 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2001 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 0); |
| 2002 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2003 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2004 | "%s Can't find the route %s/%d", peer->host, |
| 2005 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2006 | p->prefixlen); |
| 2007 | |
| 2008 | /* Unlock bgp_node_get() lock. */ |
| 2009 | bgp_unlock_node (rn); |
| 2010 | |
| 2011 | return 0; |
| 2012 | } |
| 2013 | |
| 2014 | void |
| 2015 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2016 | { |
| 2017 | struct bgp *bgp; |
| 2018 | struct attr attr; |
| 2019 | struct aspath *aspath; |
| 2020 | struct prefix p; |
| 2021 | struct bgp_info binfo; |
| 2022 | struct peer *from; |
| 2023 | int ret = RMAP_DENYMATCH; |
| 2024 | |
| 2025 | bgp = peer->bgp; |
| 2026 | from = bgp->peer_self; |
| 2027 | |
| 2028 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2029 | aspath = attr.aspath; |
| 2030 | attr.local_pref = bgp->default_local_pref; |
| 2031 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2032 | |
| 2033 | if (afi == AFI_IP) |
| 2034 | str2prefix ("0.0.0.0/0", &p); |
| 2035 | #ifdef HAVE_IPV6 |
| 2036 | else if (afi == AFI_IP6) |
| 2037 | { |
| 2038 | str2prefix ("::/0", &p); |
| 2039 | |
| 2040 | /* IPv6 global nexthop must be included. */ |
| 2041 | memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global, |
| 2042 | IPV6_MAX_BYTELEN); |
| 2043 | attr.mp_nexthop_len = 16; |
| 2044 | |
| 2045 | /* If the peer is on shared nextwork and we have link-local |
| 2046 | nexthop set it. */ |
| 2047 | if (peer->shared_network |
| 2048 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2049 | { |
| 2050 | memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local, |
| 2051 | IPV6_MAX_BYTELEN); |
| 2052 | attr.mp_nexthop_len = 32; |
| 2053 | } |
| 2054 | } |
| 2055 | #endif /* HAVE_IPV6 */ |
| 2056 | else |
| 2057 | return; |
| 2058 | |
| 2059 | if (peer->default_rmap[afi][safi].name) |
| 2060 | { |
| 2061 | binfo.peer = bgp->peer_self; |
| 2062 | binfo.attr = &attr; |
| 2063 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2064 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2065 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2066 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2067 | RMAP_BGP, &binfo); |
| 2068 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2069 | bgp->peer_self->rmap_type = 0; |
| 2070 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2071 | if (ret == RMAP_DENYMATCH) |
| 2072 | { |
| 2073 | bgp_attr_flush (&attr); |
| 2074 | withdraw = 1; |
| 2075 | } |
| 2076 | } |
| 2077 | |
| 2078 | if (withdraw) |
| 2079 | { |
| 2080 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2081 | bgp_default_withdraw_send (peer, afi, safi); |
| 2082 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2083 | } |
| 2084 | else |
| 2085 | { |
| 2086 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2087 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2088 | } |
| 2089 | |
| 2090 | aspath_unintern (aspath); |
| 2091 | } |
| 2092 | |
| 2093 | static void |
| 2094 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2095 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2096 | { |
| 2097 | struct bgp_node *rn; |
| 2098 | struct bgp_info *ri; |
| 2099 | struct attr attr; |
| 2100 | |
| 2101 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2102 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2103 | |
| 2104 | if (safi != SAFI_MPLS_VPN |
| 2105 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2106 | bgp_default_originate (peer, afi, safi, 0); |
| 2107 | |
| 2108 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2109 | for (ri = rn->info; ri; ri = ri->next) |
| 2110 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2111 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2112 | if ( (rsclient) ? |
| 2113 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2114 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2115 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2116 | else |
| 2117 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2118 | } |
| 2119 | } |
| 2120 | |
| 2121 | void |
| 2122 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2123 | { |
| 2124 | struct bgp_node *rn; |
| 2125 | struct bgp_table *table; |
| 2126 | |
| 2127 | if (peer->status != Established) |
| 2128 | return; |
| 2129 | |
| 2130 | if (! peer->afc_nego[afi][safi]) |
| 2131 | return; |
| 2132 | |
| 2133 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2134 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2135 | return; |
| 2136 | |
| 2137 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2138 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2139 | else |
| 2140 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2141 | rn = bgp_route_next(rn)) |
| 2142 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2143 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2144 | |
| 2145 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2146 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2147 | } |
| 2148 | |
| 2149 | void |
| 2150 | bgp_announce_route_all (struct peer *peer) |
| 2151 | { |
| 2152 | afi_t afi; |
| 2153 | safi_t safi; |
| 2154 | |
| 2155 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2156 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2157 | bgp_announce_route (peer, afi, safi); |
| 2158 | } |
| 2159 | |
| 2160 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2161 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
| 2162 | safi_t safi, struct bgp_table *table) |
| 2163 | { |
| 2164 | struct bgp_node *rn; |
| 2165 | struct bgp_adj_in *ain; |
| 2166 | |
| 2167 | if (! table) |
| 2168 | table = rsclient->bgp->rib[afi][safi]; |
| 2169 | |
| 2170 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2171 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2172 | { |
| 2173 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
| 2174 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2175 | } |
| 2176 | } |
| 2177 | |
| 2178 | void |
| 2179 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2180 | { |
| 2181 | struct bgp_table *table; |
| 2182 | struct bgp_node *rn; |
| 2183 | |
| 2184 | if (safi != SAFI_MPLS_VPN) |
| 2185 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); |
| 2186 | |
| 2187 | else |
| 2188 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2189 | rn = bgp_route_next (rn)) |
| 2190 | if ((table = rn->info) != NULL) |
| 2191 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); |
| 2192 | } |
| 2193 | |
| 2194 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2195 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 2196 | struct bgp_table *table) |
| 2197 | { |
| 2198 | int ret; |
| 2199 | struct bgp_node *rn; |
| 2200 | struct bgp_adj_in *ain; |
| 2201 | |
| 2202 | if (! table) |
| 2203 | table = peer->bgp->rib[afi][safi]; |
| 2204 | |
| 2205 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2206 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2207 | { |
| 2208 | if (ain->peer == peer) |
| 2209 | { |
| 2210 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2211 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 2212 | NULL, NULL, 1); |
| 2213 | if (ret < 0) |
| 2214 | { |
| 2215 | bgp_unlock_node (rn); |
| 2216 | return; |
| 2217 | } |
| 2218 | continue; |
| 2219 | } |
| 2220 | } |
| 2221 | } |
| 2222 | |
| 2223 | void |
| 2224 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2225 | { |
| 2226 | struct bgp_node *rn; |
| 2227 | struct bgp_table *table; |
| 2228 | |
| 2229 | if (peer->status != Established) |
| 2230 | return; |
| 2231 | |
| 2232 | if (safi != SAFI_MPLS_VPN) |
| 2233 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 2234 | else |
| 2235 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2236 | rn = bgp_route_next (rn)) |
| 2237 | if ((table = rn->info) != NULL) |
| 2238 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 2239 | } |
| 2240 | |
| 2241 | static void |
| 2242 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2243 | struct bgp_table *table, struct peer *rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2244 | { |
| 2245 | struct bgp_node *rn; |
| 2246 | struct bgp_adj_in *ain; |
| 2247 | struct bgp_adj_out *aout; |
| 2248 | struct bgp_info *ri; |
| 2249 | |
| 2250 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2251 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | |
| 2253 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2254 | { |
| 2255 | for (ri = rn->info; ri; ri = ri->next) |
| 2256 | if (ri->peer == peer) |
| 2257 | { |
| 2258 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 2259 | break; |
| 2260 | } |
| 2261 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2262 | if (ain->peer == peer) |
| 2263 | { |
| 2264 | bgp_adj_in_remove (rn, ain); |
| 2265 | bgp_unlock_node (rn); |
| 2266 | break; |
| 2267 | } |
| 2268 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2269 | if (aout->peer == peer) |
| 2270 | { |
| 2271 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2272 | bgp_unlock_node (rn); |
| 2273 | break; |
| 2274 | } |
| 2275 | } |
| 2276 | } |
| 2277 | |
| 2278 | void |
| 2279 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2280 | { |
| 2281 | struct bgp_node *rn; |
| 2282 | struct bgp_table *table; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2283 | struct peer *rsclient; |
| 2284 | struct listnode *nn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2285 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2286 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2287 | bgp_clear_route_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2288 | else |
| 2289 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2290 | rn = bgp_route_next (rn)) |
| 2291 | if ((table = rn->info) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2292 | bgp_clear_route_table (peer, afi, safi, table, NULL); |
| 2293 | |
| 2294 | LIST_LOOP (peer->bgp->rsclient, rsclient, nn) |
| 2295 | { |
| 2296 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2297 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient); |
| 2298 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2299 | } |
| 2300 | |
| 2301 | void |
| 2302 | bgp_clear_route_all (struct peer *peer) |
| 2303 | { |
| 2304 | afi_t afi; |
| 2305 | safi_t safi; |
| 2306 | |
| 2307 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2308 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2309 | bgp_clear_route (peer, afi, safi); |
| 2310 | } |
| 2311 | |
| 2312 | void |
| 2313 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2314 | { |
| 2315 | struct bgp_table *table; |
| 2316 | struct bgp_node *rn; |
| 2317 | struct bgp_adj_in *ain; |
| 2318 | |
| 2319 | table = peer->bgp->rib[afi][safi]; |
| 2320 | |
| 2321 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2322 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2323 | if (ain->peer == peer) |
| 2324 | { |
| 2325 | bgp_adj_in_remove (rn, ain); |
| 2326 | bgp_unlock_node (rn); |
| 2327 | break; |
| 2328 | } |
| 2329 | } |
| 2330 | |
| 2331 | /* Delete all kernel routes. */ |
| 2332 | void |
paul | 545acaf | 2004-04-20 15:13:15 +0000 | [diff] [blame] | 2333 | bgp_cleanup_routes () |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2334 | { |
| 2335 | struct bgp *bgp; |
| 2336 | struct listnode *nn; |
| 2337 | struct bgp_node *rn; |
| 2338 | struct bgp_table *table; |
| 2339 | struct bgp_info *ri; |
| 2340 | |
| 2341 | LIST_LOOP (bm->bgp, bgp, nn) |
| 2342 | { |
| 2343 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 2344 | |
| 2345 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2346 | for (ri = rn->info; ri; ri = ri->next) |
| 2347 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2348 | && ri->type == ZEBRA_ROUTE_BGP |
| 2349 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2350 | bgp_zebra_withdraw (&rn->p, ri); |
| 2351 | |
| 2352 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 2353 | |
| 2354 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2355 | for (ri = rn->info; ri; ri = ri->next) |
| 2356 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2357 | && ri->type == ZEBRA_ROUTE_BGP |
| 2358 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2359 | bgp_zebra_withdraw (&rn->p, ri); |
| 2360 | } |
| 2361 | } |
| 2362 | |
| 2363 | void |
| 2364 | bgp_reset () |
| 2365 | { |
| 2366 | vty_reset (); |
| 2367 | bgp_zclient_reset (); |
| 2368 | access_list_reset (); |
| 2369 | prefix_list_reset (); |
| 2370 | } |
| 2371 | |
| 2372 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 2373 | value. */ |
| 2374 | int |
| 2375 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 2376 | { |
| 2377 | u_char *pnt; |
| 2378 | u_char *lim; |
| 2379 | struct prefix p; |
| 2380 | int psize; |
| 2381 | int ret; |
| 2382 | |
| 2383 | /* Check peer status. */ |
| 2384 | if (peer->status != Established) |
| 2385 | return 0; |
| 2386 | |
| 2387 | pnt = packet->nlri; |
| 2388 | lim = pnt + packet->length; |
| 2389 | |
| 2390 | for (; pnt < lim; pnt += psize) |
| 2391 | { |
| 2392 | /* Clear prefix structure. */ |
| 2393 | memset (&p, 0, sizeof (struct prefix)); |
| 2394 | |
| 2395 | /* Fetch prefix length. */ |
| 2396 | p.prefixlen = *pnt++; |
| 2397 | p.family = afi2family (packet->afi); |
| 2398 | |
| 2399 | /* Already checked in nlri_sanity_check(). We do double check |
| 2400 | here. */ |
| 2401 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 2402 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 2403 | return -1; |
| 2404 | |
| 2405 | /* Packet size overflow check. */ |
| 2406 | psize = PSIZE (p.prefixlen); |
| 2407 | |
| 2408 | /* When packet overflow occur return immediately. */ |
| 2409 | if (pnt + psize > lim) |
| 2410 | return -1; |
| 2411 | |
| 2412 | /* Fetch prefix from NLRI packet. */ |
| 2413 | memcpy (&p.u.prefix, pnt, psize); |
| 2414 | |
| 2415 | /* Check address. */ |
| 2416 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 2417 | { |
| 2418 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 2419 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2420 | /* |
| 2421 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 2422 | * If a BGP router receives an UPDATE message with a |
| 2423 | * semantically incorrect NLRI field, in which a prefix is |
| 2424 | * semantically incorrect (eg. an unexpected multicast IP |
| 2425 | * address), it should ignore the prefix. |
| 2426 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2427 | zlog (peer->log, LOG_ERR, |
| 2428 | "IPv4 unicast NLRI is multicast address %s", |
| 2429 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2430 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2431 | return -1; |
| 2432 | } |
| 2433 | } |
| 2434 | |
| 2435 | #ifdef HAVE_IPV6 |
| 2436 | /* Check address. */ |
| 2437 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 2438 | { |
| 2439 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2440 | { |
| 2441 | char buf[BUFSIZ]; |
| 2442 | |
| 2443 | zlog (peer->log, LOG_WARNING, |
| 2444 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 2445 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 2446 | |
| 2447 | continue; |
| 2448 | } |
| 2449 | } |
| 2450 | #endif /* HAVE_IPV6 */ |
| 2451 | |
| 2452 | /* Normal process. */ |
| 2453 | if (attr) |
| 2454 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 2455 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 2456 | else |
| 2457 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 2458 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2459 | |
| 2460 | /* Address family configuration mismatch or maximum-prefix count |
| 2461 | overflow. */ |
| 2462 | if (ret < 0) |
| 2463 | return -1; |
| 2464 | } |
| 2465 | |
| 2466 | /* Packet length consistency check. */ |
| 2467 | if (pnt != lim) |
| 2468 | return -1; |
| 2469 | |
| 2470 | return 0; |
| 2471 | } |
| 2472 | |
| 2473 | /* NLRI encode syntax check routine. */ |
| 2474 | int |
| 2475 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 2476 | bgp_size_t length) |
| 2477 | { |
| 2478 | u_char *end; |
| 2479 | u_char prefixlen; |
| 2480 | int psize; |
| 2481 | |
| 2482 | end = pnt + length; |
| 2483 | |
| 2484 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 2485 | syntactic validity. If the field is syntactically incorrect, |
| 2486 | then the Error Subcode is set to Invalid Network Field. */ |
| 2487 | |
| 2488 | while (pnt < end) |
| 2489 | { |
| 2490 | prefixlen = *pnt++; |
| 2491 | |
| 2492 | /* Prefix length check. */ |
| 2493 | if ((afi == AFI_IP && prefixlen > 32) |
| 2494 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 2495 | { |
| 2496 | plog_err (peer->log, |
| 2497 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 2498 | peer->host, prefixlen); |
| 2499 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2500 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2501 | return -1; |
| 2502 | } |
| 2503 | |
| 2504 | /* Packet size overflow check. */ |
| 2505 | psize = PSIZE (prefixlen); |
| 2506 | |
| 2507 | if (pnt + psize > end) |
| 2508 | { |
| 2509 | plog_err (peer->log, |
| 2510 | "%s [Error] Update packet error" |
| 2511 | " (prefix data overflow prefix size is %d)", |
| 2512 | peer->host, psize); |
| 2513 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2514 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2515 | return -1; |
| 2516 | } |
| 2517 | |
| 2518 | pnt += psize; |
| 2519 | } |
| 2520 | |
| 2521 | /* Packet length consistency check. */ |
| 2522 | if (pnt != end) |
| 2523 | { |
| 2524 | plog_err (peer->log, |
| 2525 | "%s [Error] Update packet error" |
| 2526 | " (prefix length mismatch with total length)", |
| 2527 | peer->host); |
| 2528 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2529 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2530 | return -1; |
| 2531 | } |
| 2532 | return 0; |
| 2533 | } |
| 2534 | |
| 2535 | struct bgp_static * |
| 2536 | bgp_static_new () |
| 2537 | { |
| 2538 | struct bgp_static *new; |
| 2539 | new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
| 2540 | memset (new, 0, sizeof (struct bgp_static)); |
| 2541 | return new; |
| 2542 | } |
| 2543 | |
| 2544 | void |
| 2545 | bgp_static_free (struct bgp_static *bgp_static) |
| 2546 | { |
| 2547 | if (bgp_static->rmap.name) |
| 2548 | free (bgp_static->rmap.name); |
| 2549 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 2550 | } |
| 2551 | |
| 2552 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2553 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 2554 | struct prefix *p, afi_t afi, safi_t safi) |
| 2555 | { |
| 2556 | struct bgp_node *rn; |
| 2557 | struct bgp_info *ri; |
| 2558 | |
| 2559 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2560 | |
| 2561 | /* Check selected route and self inserted route. */ |
| 2562 | for (ri = rn->info; ri; ri = ri->next) |
| 2563 | if (ri->peer == bgp->peer_self |
| 2564 | && ri->type == ZEBRA_ROUTE_BGP |
| 2565 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2566 | break; |
| 2567 | |
| 2568 | /* Withdraw static BGP route from routing table. */ |
| 2569 | if (ri) |
| 2570 | { |
| 2571 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2572 | bgp_process (bgp, rn, afi, safi); |
| 2573 | bgp_info_delete (rn, ri); |
| 2574 | bgp_info_free (ri); |
| 2575 | bgp_unlock_node (rn); |
| 2576 | } |
| 2577 | |
| 2578 | /* Unlock bgp_node_lookup. */ |
| 2579 | bgp_unlock_node (rn); |
| 2580 | } |
| 2581 | |
| 2582 | void |
| 2583 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
| 2584 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2585 | { |
| 2586 | struct bgp_node *rn; |
| 2587 | struct bgp_info *ri; |
| 2588 | struct bgp_info *new; |
| 2589 | struct bgp_info info; |
| 2590 | struct attr new_attr; |
| 2591 | struct attr *attr_new; |
| 2592 | struct attr attr; |
| 2593 | struct bgp *bgp; |
| 2594 | int ret; |
| 2595 | char buf[SU_ADDRSTRLEN]; |
| 2596 | |
| 2597 | bgp = rsclient->bgp; |
| 2598 | |
| 2599 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2600 | |
| 2601 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2602 | if (bgp_static) |
| 2603 | { |
| 2604 | attr.nexthop = bgp_static->igpnexthop; |
| 2605 | attr.med = bgp_static->igpmetric; |
| 2606 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 2607 | } |
| 2608 | |
| 2609 | new_attr = attr; |
| 2610 | |
| 2611 | /* Apply network route-map for export to this rsclient. */ |
| 2612 | if (bgp_static->rmap.name) |
| 2613 | { |
| 2614 | info.peer = rsclient; |
| 2615 | info.attr = &new_attr; |
| 2616 | |
| 2617 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 2618 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2619 | |
| 2620 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 2621 | |
| 2622 | rsclient->rmap_type = 0; |
| 2623 | |
| 2624 | if (ret == RMAP_DENYMATCH) |
| 2625 | { |
| 2626 | /* Free uninterned attribute. */ |
| 2627 | bgp_attr_flush (&new_attr); |
| 2628 | |
| 2629 | /* Unintern original. */ |
| 2630 | aspath_unintern (attr.aspath); |
| 2631 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2632 | |
| 2633 | return; |
| 2634 | } |
| 2635 | attr_new = bgp_attr_intern (&new_attr); |
| 2636 | } |
| 2637 | else |
| 2638 | attr_new = bgp_attr_intern (&attr); |
| 2639 | |
| 2640 | new_attr = *attr_new; |
| 2641 | |
| 2642 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2643 | |
| 2644 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2645 | { |
| 2646 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2647 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2648 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2649 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 2650 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2651 | p->prefixlen, rsclient->host); |
| 2652 | |
| 2653 | bgp->peer_self->rmap_type = 0; |
| 2654 | |
| 2655 | bgp_attr_unintern (attr_new); |
| 2656 | aspath_unintern (attr.aspath); |
| 2657 | |
| 2658 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2659 | |
| 2660 | return; |
| 2661 | } |
| 2662 | |
| 2663 | bgp->peer_self->rmap_type = 0; |
| 2664 | |
| 2665 | bgp_attr_unintern (attr_new); |
| 2666 | attr_new = bgp_attr_intern (&new_attr); |
| 2667 | |
| 2668 | for (ri = rn->info; ri; ri = ri->next) |
| 2669 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 2670 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2671 | break; |
| 2672 | |
| 2673 | if (ri) |
| 2674 | { |
| 2675 | if (attrhash_cmp (ri->attr, attr_new)) |
| 2676 | { |
| 2677 | bgp_unlock_node (rn); |
| 2678 | bgp_attr_unintern (attr_new); |
| 2679 | aspath_unintern (attr.aspath); |
| 2680 | return; |
| 2681 | } |
| 2682 | else |
| 2683 | { |
| 2684 | /* The attribute is changed. */ |
| 2685 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2686 | |
| 2687 | /* Rewrite BGP route information. */ |
| 2688 | bgp_attr_unintern (ri->attr); |
| 2689 | ri->attr = attr_new; |
| 2690 | ri->uptime = time (NULL); |
| 2691 | |
| 2692 | /* Process change. */ |
| 2693 | bgp_process (bgp, rn, afi, safi); |
| 2694 | bgp_unlock_node (rn); |
| 2695 | aspath_unintern (attr.aspath); |
| 2696 | return; |
| 2697 | } |
| 2698 | } |
| 2699 | |
| 2700 | /* Make new BGP info. */ |
| 2701 | new = bgp_info_new (); |
| 2702 | new->type = ZEBRA_ROUTE_BGP; |
| 2703 | new->sub_type = BGP_ROUTE_STATIC; |
| 2704 | new->peer = bgp->peer_self; |
| 2705 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2706 | new->attr = attr_new; |
| 2707 | new->uptime = time (NULL); |
| 2708 | |
| 2709 | /* Register new BGP information. */ |
| 2710 | bgp_info_add (rn, new); |
| 2711 | |
| 2712 | /* Process change. */ |
| 2713 | bgp_process (bgp, rn, afi, safi); |
| 2714 | |
| 2715 | /* Unintern original. */ |
| 2716 | aspath_unintern (attr.aspath); |
| 2717 | } |
| 2718 | |
| 2719 | void |
| 2720 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2721 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2722 | { |
| 2723 | struct bgp_node *rn; |
| 2724 | struct bgp_info *ri; |
| 2725 | struct bgp_info *new; |
| 2726 | struct bgp_info info; |
| 2727 | struct attr attr; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2728 | struct attr attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2729 | struct attr *attr_new; |
| 2730 | int ret; |
| 2731 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2732 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2733 | |
| 2734 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2735 | if (bgp_static) |
| 2736 | { |
| 2737 | attr.nexthop = bgp_static->igpnexthop; |
| 2738 | attr.med = bgp_static->igpmetric; |
| 2739 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 2740 | } |
| 2741 | |
| 2742 | /* Apply route-map. */ |
| 2743 | if (bgp_static->rmap.name) |
| 2744 | { |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2745 | attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2746 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2747 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2748 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2749 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2750 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2751 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2752 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2753 | bgp->peer_self->rmap_type = 0; |
| 2754 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2755 | if (ret == RMAP_DENYMATCH) |
| 2756 | { |
| 2757 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2758 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2759 | |
| 2760 | /* Unintern original. */ |
| 2761 | aspath_unintern (attr.aspath); |
| 2762 | bgp_static_withdraw (bgp, p, afi, safi); |
| 2763 | return; |
| 2764 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2765 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2766 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2767 | else |
| 2768 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2769 | |
| 2770 | for (ri = rn->info; ri; ri = ri->next) |
| 2771 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 2772 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2773 | break; |
| 2774 | |
| 2775 | if (ri) |
| 2776 | { |
| 2777 | if (attrhash_cmp (ri->attr, attr_new)) |
| 2778 | { |
| 2779 | bgp_unlock_node (rn); |
| 2780 | bgp_attr_unintern (attr_new); |
| 2781 | aspath_unintern (attr.aspath); |
| 2782 | return; |
| 2783 | } |
| 2784 | else |
| 2785 | { |
| 2786 | /* The attribute is changed. */ |
| 2787 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2788 | |
| 2789 | /* Rewrite BGP route information. */ |
| 2790 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2791 | bgp_attr_unintern (ri->attr); |
| 2792 | ri->attr = attr_new; |
| 2793 | ri->uptime = time (NULL); |
| 2794 | |
| 2795 | /* Process change. */ |
| 2796 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2797 | bgp_process (bgp, rn, afi, safi); |
| 2798 | bgp_unlock_node (rn); |
| 2799 | aspath_unintern (attr.aspath); |
| 2800 | return; |
| 2801 | } |
| 2802 | } |
| 2803 | |
| 2804 | /* Make new BGP info. */ |
| 2805 | new = bgp_info_new (); |
| 2806 | new->type = ZEBRA_ROUTE_BGP; |
| 2807 | new->sub_type = BGP_ROUTE_STATIC; |
| 2808 | new->peer = bgp->peer_self; |
| 2809 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2810 | new->attr = attr_new; |
| 2811 | new->uptime = time (NULL); |
| 2812 | |
| 2813 | /* Aggregate address increment. */ |
| 2814 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2815 | |
| 2816 | /* Register new BGP information. */ |
| 2817 | bgp_info_add (rn, new); |
| 2818 | |
| 2819 | /* Process change. */ |
| 2820 | bgp_process (bgp, rn, afi, safi); |
| 2821 | |
| 2822 | /* Unintern original. */ |
| 2823 | aspath_unintern (attr.aspath); |
| 2824 | } |
| 2825 | |
| 2826 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2827 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 2828 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2829 | { |
| 2830 | struct peer *rsclient; |
| 2831 | struct listnode *nn; |
| 2832 | |
| 2833 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 2834 | |
| 2835 | LIST_LOOP(bgp->rsclient, rsclient, nn) |
| 2836 | { |
| 2837 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
| 2838 | } |
| 2839 | } |
| 2840 | |
| 2841 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2842 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 2843 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 2844 | { |
| 2845 | struct bgp_node *rn; |
| 2846 | struct bgp_info *new; |
| 2847 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2848 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2849 | |
| 2850 | /* Make new BGP info. */ |
| 2851 | new = bgp_info_new (); |
| 2852 | new->type = ZEBRA_ROUTE_BGP; |
| 2853 | new->sub_type = BGP_ROUTE_STATIC; |
| 2854 | new->peer = bgp->peer_self; |
| 2855 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 2856 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2857 | new->uptime = time (NULL); |
| 2858 | memcpy (new->tag, tag, 3); |
| 2859 | |
| 2860 | /* Aggregate address increment. */ |
| 2861 | bgp_aggregate_increment (bgp, p, (struct bgp_info *) new, afi, safi); |
| 2862 | |
| 2863 | /* Register new BGP information. */ |
| 2864 | bgp_info_add (rn, (struct bgp_info *) new); |
| 2865 | |
| 2866 | /* Process change. */ |
| 2867 | bgp_process (bgp, rn, afi, safi); |
| 2868 | } |
| 2869 | |
| 2870 | void |
| 2871 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 2872 | safi_t safi) |
| 2873 | { |
| 2874 | struct bgp_node *rn; |
| 2875 | struct bgp_info *ri; |
| 2876 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2877 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2878 | |
| 2879 | /* Check selected route and self inserted route. */ |
| 2880 | for (ri = rn->info; ri; ri = ri->next) |
| 2881 | if (ri->peer == bgp->peer_self |
| 2882 | && ri->type == ZEBRA_ROUTE_BGP |
| 2883 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2884 | break; |
| 2885 | |
| 2886 | /* Withdraw static BGP route from routing table. */ |
| 2887 | if (ri) |
| 2888 | { |
| 2889 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2890 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2891 | bgp_process (bgp, rn, afi, safi); |
| 2892 | bgp_info_delete (rn, ri); |
| 2893 | bgp_info_free (ri); |
| 2894 | bgp_unlock_node (rn); |
| 2895 | } |
| 2896 | |
| 2897 | /* Unlock bgp_node_lookup. */ |
| 2898 | bgp_unlock_node (rn); |
| 2899 | } |
| 2900 | |
| 2901 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2902 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2903 | { |
| 2904 | struct bgp_static *bgp_static; |
| 2905 | struct bgp *bgp; |
| 2906 | struct bgp_node *rn; |
| 2907 | struct prefix *p; |
| 2908 | |
| 2909 | bgp = rsclient->bgp; |
| 2910 | |
| 2911 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 2912 | if ((bgp_static = rn->info) != NULL) |
| 2913 | { |
| 2914 | p = &rn->p; |
| 2915 | |
| 2916 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 2917 | afi, safi); |
| 2918 | } |
| 2919 | } |
| 2920 | |
| 2921 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2922 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 2923 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 2924 | { |
| 2925 | struct bgp_node *rn; |
| 2926 | struct bgp_info *ri; |
| 2927 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2928 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2929 | |
| 2930 | /* Check selected route and self inserted route. */ |
| 2931 | for (ri = rn->info; ri; ri = ri->next) |
| 2932 | if (ri->peer == bgp->peer_self |
| 2933 | && ri->type == ZEBRA_ROUTE_BGP |
| 2934 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2935 | break; |
| 2936 | |
| 2937 | /* Withdraw static BGP route from routing table. */ |
| 2938 | if (ri) |
| 2939 | { |
| 2940 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2941 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2942 | bgp_process (bgp, rn, afi, safi); |
| 2943 | bgp_info_delete (rn, ri); |
| 2944 | bgp_info_free (ri); |
| 2945 | bgp_unlock_node (rn); |
| 2946 | } |
| 2947 | |
| 2948 | /* Unlock bgp_node_lookup. */ |
| 2949 | bgp_unlock_node (rn); |
| 2950 | } |
| 2951 | |
| 2952 | /* Configure static BGP network. When user don't run zebra, static |
| 2953 | route should be installed as valid. */ |
| 2954 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2955 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
| 2956 | u_int16_t afi, u_char safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2957 | { |
| 2958 | int ret; |
| 2959 | struct prefix p; |
| 2960 | struct bgp_static *bgp_static; |
| 2961 | struct bgp_node *rn; |
| 2962 | int need_update = 0; |
| 2963 | |
| 2964 | /* Convert IP prefix string to struct prefix. */ |
| 2965 | ret = str2prefix (ip_str, &p); |
| 2966 | if (! ret) |
| 2967 | { |
| 2968 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 2969 | return CMD_WARNING; |
| 2970 | } |
| 2971 | #ifdef HAVE_IPV6 |
| 2972 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2973 | { |
| 2974 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 2975 | VTY_NEWLINE); |
| 2976 | return CMD_WARNING; |
| 2977 | } |
| 2978 | #endif /* HAVE_IPV6 */ |
| 2979 | |
| 2980 | apply_mask (&p); |
| 2981 | |
| 2982 | /* Set BGP static route configuration. */ |
| 2983 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 2984 | |
| 2985 | if (rn->info) |
| 2986 | { |
| 2987 | /* Configuration change. */ |
| 2988 | bgp_static = rn->info; |
| 2989 | |
| 2990 | /* Check previous routes are installed into BGP. */ |
| 2991 | if (! bgp_static->backdoor && bgp_static->valid) |
| 2992 | need_update = 1; |
| 2993 | |
| 2994 | bgp_static->backdoor = backdoor; |
| 2995 | if (rmap) |
| 2996 | { |
| 2997 | if (bgp_static->rmap.name) |
| 2998 | free (bgp_static->rmap.name); |
| 2999 | bgp_static->rmap.name = strdup (rmap); |
| 3000 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3001 | } |
| 3002 | else |
| 3003 | { |
| 3004 | if (bgp_static->rmap.name) |
| 3005 | free (bgp_static->rmap.name); |
| 3006 | bgp_static->rmap.name = NULL; |
| 3007 | bgp_static->rmap.map = NULL; |
| 3008 | bgp_static->valid = 0; |
| 3009 | } |
| 3010 | bgp_unlock_node (rn); |
| 3011 | } |
| 3012 | else |
| 3013 | { |
| 3014 | /* New configuration. */ |
| 3015 | bgp_static = bgp_static_new (); |
| 3016 | bgp_static->backdoor = backdoor; |
| 3017 | bgp_static->valid = 0; |
| 3018 | bgp_static->igpmetric = 0; |
| 3019 | bgp_static->igpnexthop.s_addr = 0; |
| 3020 | if (rmap) |
| 3021 | { |
| 3022 | if (bgp_static->rmap.name) |
| 3023 | free (bgp_static->rmap.name); |
| 3024 | bgp_static->rmap.name = strdup (rmap); |
| 3025 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3026 | } |
| 3027 | rn->info = bgp_static; |
| 3028 | } |
| 3029 | |
| 3030 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3031 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3032 | { |
| 3033 | bgp_static->valid = 1; |
| 3034 | |
| 3035 | if (need_update) |
| 3036 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3037 | |
| 3038 | if (! bgp_static->backdoor) |
| 3039 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3040 | } |
| 3041 | |
| 3042 | return CMD_SUCCESS; |
| 3043 | } |
| 3044 | |
| 3045 | /* Configure static BGP network. */ |
| 3046 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3047 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3048 | u_int16_t afi, u_char safi) |
| 3049 | { |
| 3050 | int ret; |
| 3051 | struct prefix p; |
| 3052 | struct bgp_static *bgp_static; |
| 3053 | struct bgp_node *rn; |
| 3054 | |
| 3055 | /* Convert IP prefix string to struct prefix. */ |
| 3056 | ret = str2prefix (ip_str, &p); |
| 3057 | if (! ret) |
| 3058 | { |
| 3059 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3060 | return CMD_WARNING; |
| 3061 | } |
| 3062 | #ifdef HAVE_IPV6 |
| 3063 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3064 | { |
| 3065 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3066 | VTY_NEWLINE); |
| 3067 | return CMD_WARNING; |
| 3068 | } |
| 3069 | #endif /* HAVE_IPV6 */ |
| 3070 | |
| 3071 | apply_mask (&p); |
| 3072 | |
| 3073 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3074 | if (! rn) |
| 3075 | { |
| 3076 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3077 | VTY_NEWLINE); |
| 3078 | return CMD_WARNING; |
| 3079 | } |
| 3080 | |
| 3081 | bgp_static = rn->info; |
| 3082 | |
| 3083 | /* Update BGP RIB. */ |
| 3084 | if (! bgp_static->backdoor) |
| 3085 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3086 | |
| 3087 | /* Clear configuration. */ |
| 3088 | bgp_static_free (bgp_static); |
| 3089 | rn->info = NULL; |
| 3090 | bgp_unlock_node (rn); |
| 3091 | bgp_unlock_node (rn); |
| 3092 | |
| 3093 | return CMD_SUCCESS; |
| 3094 | } |
| 3095 | |
| 3096 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3097 | instance. */ |
| 3098 | void |
| 3099 | bgp_static_delete (struct bgp *bgp) |
| 3100 | { |
| 3101 | afi_t afi; |
| 3102 | safi_t safi; |
| 3103 | struct bgp_node *rn; |
| 3104 | struct bgp_node *rm; |
| 3105 | struct bgp_table *table; |
| 3106 | struct bgp_static *bgp_static; |
| 3107 | |
| 3108 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3109 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3110 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3111 | if (rn->info != NULL) |
| 3112 | { |
| 3113 | if (safi == SAFI_MPLS_VPN) |
| 3114 | { |
| 3115 | table = rn->info; |
| 3116 | |
| 3117 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3118 | { |
| 3119 | bgp_static = rn->info; |
| 3120 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3121 | AFI_IP, SAFI_MPLS_VPN, |
| 3122 | (struct prefix_rd *)&rn->p, |
| 3123 | bgp_static->tag); |
| 3124 | bgp_static_free (bgp_static); |
| 3125 | rn->info = NULL; |
| 3126 | bgp_unlock_node (rn); |
| 3127 | } |
| 3128 | } |
| 3129 | else |
| 3130 | { |
| 3131 | bgp_static = rn->info; |
| 3132 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3133 | bgp_static_free (bgp_static); |
| 3134 | rn->info = NULL; |
| 3135 | bgp_unlock_node (rn); |
| 3136 | } |
| 3137 | } |
| 3138 | } |
| 3139 | |
| 3140 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3141 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3142 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3143 | { |
| 3144 | int ret; |
| 3145 | struct prefix p; |
| 3146 | struct prefix_rd prd; |
| 3147 | struct bgp *bgp; |
| 3148 | struct bgp_node *prn; |
| 3149 | struct bgp_node *rn; |
| 3150 | struct bgp_table *table; |
| 3151 | struct bgp_static *bgp_static; |
| 3152 | u_char tag[3]; |
| 3153 | |
| 3154 | bgp = vty->index; |
| 3155 | |
| 3156 | ret = str2prefix (ip_str, &p); |
| 3157 | if (! ret) |
| 3158 | { |
| 3159 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3160 | return CMD_WARNING; |
| 3161 | } |
| 3162 | apply_mask (&p); |
| 3163 | |
| 3164 | ret = str2prefix_rd (rd_str, &prd); |
| 3165 | if (! ret) |
| 3166 | { |
| 3167 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3168 | return CMD_WARNING; |
| 3169 | } |
| 3170 | |
| 3171 | ret = str2tag (tag_str, tag); |
| 3172 | if (! ret) |
| 3173 | { |
| 3174 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3175 | return CMD_WARNING; |
| 3176 | } |
| 3177 | |
| 3178 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3179 | (struct prefix *)&prd); |
| 3180 | if (prn->info == NULL) |
| 3181 | prn->info = bgp_table_init (); |
| 3182 | else |
| 3183 | bgp_unlock_node (prn); |
| 3184 | table = prn->info; |
| 3185 | |
| 3186 | rn = bgp_node_get (table, &p); |
| 3187 | |
| 3188 | if (rn->info) |
| 3189 | { |
| 3190 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3191 | bgp_unlock_node (rn); |
| 3192 | } |
| 3193 | else |
| 3194 | { |
| 3195 | /* New configuration. */ |
| 3196 | bgp_static = bgp_static_new (); |
| 3197 | bgp_static->valid = 1; |
| 3198 | memcpy (bgp_static->tag, tag, 3); |
| 3199 | rn->info = bgp_static; |
| 3200 | |
| 3201 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3202 | } |
| 3203 | |
| 3204 | return CMD_SUCCESS; |
| 3205 | } |
| 3206 | |
| 3207 | /* Configure static BGP network. */ |
| 3208 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3209 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3210 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3211 | { |
| 3212 | int ret; |
| 3213 | struct bgp *bgp; |
| 3214 | struct prefix p; |
| 3215 | struct prefix_rd prd; |
| 3216 | struct bgp_node *prn; |
| 3217 | struct bgp_node *rn; |
| 3218 | struct bgp_table *table; |
| 3219 | struct bgp_static *bgp_static; |
| 3220 | u_char tag[3]; |
| 3221 | |
| 3222 | bgp = vty->index; |
| 3223 | |
| 3224 | /* Convert IP prefix string to struct prefix. */ |
| 3225 | ret = str2prefix (ip_str, &p); |
| 3226 | if (! ret) |
| 3227 | { |
| 3228 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3229 | return CMD_WARNING; |
| 3230 | } |
| 3231 | apply_mask (&p); |
| 3232 | |
| 3233 | ret = str2prefix_rd (rd_str, &prd); |
| 3234 | if (! ret) |
| 3235 | { |
| 3236 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3237 | return CMD_WARNING; |
| 3238 | } |
| 3239 | |
| 3240 | ret = str2tag (tag_str, tag); |
| 3241 | if (! ret) |
| 3242 | { |
| 3243 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3244 | return CMD_WARNING; |
| 3245 | } |
| 3246 | |
| 3247 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3248 | (struct prefix *)&prd); |
| 3249 | if (prn->info == NULL) |
| 3250 | prn->info = bgp_table_init (); |
| 3251 | else |
| 3252 | bgp_unlock_node (prn); |
| 3253 | table = prn->info; |
| 3254 | |
| 3255 | rn = bgp_node_lookup (table, &p); |
| 3256 | |
| 3257 | if (rn) |
| 3258 | { |
| 3259 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3260 | |
| 3261 | bgp_static = rn->info; |
| 3262 | bgp_static_free (bgp_static); |
| 3263 | rn->info = NULL; |
| 3264 | bgp_unlock_node (rn); |
| 3265 | bgp_unlock_node (rn); |
| 3266 | } |
| 3267 | else |
| 3268 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3269 | |
| 3270 | return CMD_SUCCESS; |
| 3271 | } |
| 3272 | |
| 3273 | DEFUN (bgp_network, |
| 3274 | bgp_network_cmd, |
| 3275 | "network A.B.C.D/M", |
| 3276 | "Specify a network to announce via BGP\n" |
| 3277 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3278 | { |
| 3279 | return bgp_static_set (vty, vty->index, argv[0], |
| 3280 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3281 | } |
| 3282 | |
| 3283 | DEFUN (bgp_network_route_map, |
| 3284 | bgp_network_route_map_cmd, |
| 3285 | "network A.B.C.D/M route-map WORD", |
| 3286 | "Specify a network to announce via BGP\n" |
| 3287 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3288 | "Route-map to modify the attributes\n" |
| 3289 | "Name of the route map\n") |
| 3290 | { |
| 3291 | return bgp_static_set (vty, vty->index, argv[0], |
| 3292 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3293 | } |
| 3294 | |
| 3295 | DEFUN (bgp_network_backdoor, |
| 3296 | bgp_network_backdoor_cmd, |
| 3297 | "network A.B.C.D/M backdoor", |
| 3298 | "Specify a network to announce via BGP\n" |
| 3299 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3300 | "Specify a BGP backdoor route\n") |
| 3301 | { |
| 3302 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3303 | } |
| 3304 | |
| 3305 | DEFUN (bgp_network_mask, |
| 3306 | bgp_network_mask_cmd, |
| 3307 | "network A.B.C.D mask A.B.C.D", |
| 3308 | "Specify a network to announce via BGP\n" |
| 3309 | "Network number\n" |
| 3310 | "Network mask\n" |
| 3311 | "Network mask\n") |
| 3312 | { |
| 3313 | int ret; |
| 3314 | char prefix_str[BUFSIZ]; |
| 3315 | |
| 3316 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3317 | if (! ret) |
| 3318 | { |
| 3319 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3320 | return CMD_WARNING; |
| 3321 | } |
| 3322 | |
| 3323 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3324 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3325 | } |
| 3326 | |
| 3327 | DEFUN (bgp_network_mask_route_map, |
| 3328 | bgp_network_mask_route_map_cmd, |
| 3329 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 3330 | "Specify a network to announce via BGP\n" |
| 3331 | "Network number\n" |
| 3332 | "Network mask\n" |
| 3333 | "Network mask\n" |
| 3334 | "Route-map to modify the attributes\n" |
| 3335 | "Name of the route map\n") |
| 3336 | { |
| 3337 | int ret; |
| 3338 | char prefix_str[BUFSIZ]; |
| 3339 | |
| 3340 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3341 | if (! ret) |
| 3342 | { |
| 3343 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3344 | return CMD_WARNING; |
| 3345 | } |
| 3346 | |
| 3347 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3348 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
| 3349 | } |
| 3350 | |
| 3351 | DEFUN (bgp_network_mask_backdoor, |
| 3352 | bgp_network_mask_backdoor_cmd, |
| 3353 | "network A.B.C.D mask A.B.C.D backdoor", |
| 3354 | "Specify a network to announce via BGP\n" |
| 3355 | "Network number\n" |
| 3356 | "Network mask\n" |
| 3357 | "Network mask\n" |
| 3358 | "Specify a BGP backdoor route\n") |
| 3359 | { |
| 3360 | int ret; |
| 3361 | char prefix_str[BUFSIZ]; |
| 3362 | |
| 3363 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3364 | if (! ret) |
| 3365 | { |
| 3366 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3367 | return CMD_WARNING; |
| 3368 | } |
| 3369 | |
| 3370 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3371 | } |
| 3372 | |
| 3373 | DEFUN (bgp_network_mask_natural, |
| 3374 | bgp_network_mask_natural_cmd, |
| 3375 | "network A.B.C.D", |
| 3376 | "Specify a network to announce via BGP\n" |
| 3377 | "Network number\n") |
| 3378 | { |
| 3379 | int ret; |
| 3380 | char prefix_str[BUFSIZ]; |
| 3381 | |
| 3382 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3383 | if (! ret) |
| 3384 | { |
| 3385 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3386 | return CMD_WARNING; |
| 3387 | } |
| 3388 | |
| 3389 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3390 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3391 | } |
| 3392 | |
| 3393 | DEFUN (bgp_network_mask_natural_route_map, |
| 3394 | bgp_network_mask_natural_route_map_cmd, |
| 3395 | "network A.B.C.D route-map WORD", |
| 3396 | "Specify a network to announce via BGP\n" |
| 3397 | "Network number\n" |
| 3398 | "Route-map to modify the attributes\n" |
| 3399 | "Name of the route map\n") |
| 3400 | { |
| 3401 | int ret; |
| 3402 | char prefix_str[BUFSIZ]; |
| 3403 | |
| 3404 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3405 | if (! ret) |
| 3406 | { |
| 3407 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3408 | return CMD_WARNING; |
| 3409 | } |
| 3410 | |
| 3411 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3412 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3413 | } |
| 3414 | |
| 3415 | DEFUN (bgp_network_mask_natural_backdoor, |
| 3416 | bgp_network_mask_natural_backdoor_cmd, |
| 3417 | "network A.B.C.D backdoor", |
| 3418 | "Specify a network to announce via BGP\n" |
| 3419 | "Network number\n" |
| 3420 | "Specify a BGP backdoor route\n") |
| 3421 | { |
| 3422 | int ret; |
| 3423 | char prefix_str[BUFSIZ]; |
| 3424 | |
| 3425 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3426 | if (! ret) |
| 3427 | { |
| 3428 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3429 | return CMD_WARNING; |
| 3430 | } |
| 3431 | |
| 3432 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3433 | } |
| 3434 | |
| 3435 | DEFUN (no_bgp_network, |
| 3436 | no_bgp_network_cmd, |
| 3437 | "no network A.B.C.D/M", |
| 3438 | NO_STR |
| 3439 | "Specify a network to announce via BGP\n" |
| 3440 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3441 | { |
| 3442 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 3443 | bgp_node_safi (vty)); |
| 3444 | } |
| 3445 | |
| 3446 | ALIAS (no_bgp_network, |
| 3447 | no_bgp_network_route_map_cmd, |
| 3448 | "no network A.B.C.D/M route-map WORD", |
| 3449 | NO_STR |
| 3450 | "Specify a network to announce via BGP\n" |
| 3451 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3452 | "Route-map to modify the attributes\n" |
| 3453 | "Name of the route map\n") |
| 3454 | |
| 3455 | ALIAS (no_bgp_network, |
| 3456 | no_bgp_network_backdoor_cmd, |
| 3457 | "no network A.B.C.D/M backdoor", |
| 3458 | NO_STR |
| 3459 | "Specify a network to announce via BGP\n" |
| 3460 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3461 | "Specify a BGP backdoor route\n") |
| 3462 | |
| 3463 | DEFUN (no_bgp_network_mask, |
| 3464 | no_bgp_network_mask_cmd, |
| 3465 | "no network A.B.C.D mask A.B.C.D", |
| 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 | { |
| 3472 | int ret; |
| 3473 | char prefix_str[BUFSIZ]; |
| 3474 | |
| 3475 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3476 | if (! ret) |
| 3477 | { |
| 3478 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3479 | return CMD_WARNING; |
| 3480 | } |
| 3481 | |
| 3482 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3483 | bgp_node_safi (vty)); |
| 3484 | } |
| 3485 | |
| 3486 | ALIAS (no_bgp_network_mask, |
| 3487 | no_bgp_network_mask_route_map_cmd, |
| 3488 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 3489 | NO_STR |
| 3490 | "Specify a network to announce via BGP\n" |
| 3491 | "Network number\n" |
| 3492 | "Network mask\n" |
| 3493 | "Network mask\n" |
| 3494 | "Route-map to modify the attributes\n" |
| 3495 | "Name of the route map\n") |
| 3496 | |
| 3497 | ALIAS (no_bgp_network_mask, |
| 3498 | no_bgp_network_mask_backdoor_cmd, |
| 3499 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 3500 | NO_STR |
| 3501 | "Specify a network to announce via BGP\n" |
| 3502 | "Network number\n" |
| 3503 | "Network mask\n" |
| 3504 | "Network mask\n" |
| 3505 | "Specify a BGP backdoor route\n") |
| 3506 | |
| 3507 | DEFUN (no_bgp_network_mask_natural, |
| 3508 | no_bgp_network_mask_natural_cmd, |
| 3509 | "no network A.B.C.D", |
| 3510 | NO_STR |
| 3511 | "Specify a network to announce via BGP\n" |
| 3512 | "Network number\n") |
| 3513 | { |
| 3514 | int ret; |
| 3515 | char prefix_str[BUFSIZ]; |
| 3516 | |
| 3517 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3518 | if (! ret) |
| 3519 | { |
| 3520 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3521 | return CMD_WARNING; |
| 3522 | } |
| 3523 | |
| 3524 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3525 | bgp_node_safi (vty)); |
| 3526 | } |
| 3527 | |
| 3528 | ALIAS (no_bgp_network_mask_natural, |
| 3529 | no_bgp_network_mask_natural_route_map_cmd, |
| 3530 | "no network A.B.C.D route-map WORD", |
| 3531 | NO_STR |
| 3532 | "Specify a network to announce via BGP\n" |
| 3533 | "Network number\n" |
| 3534 | "Route-map to modify the attributes\n" |
| 3535 | "Name of the route map\n") |
| 3536 | |
| 3537 | ALIAS (no_bgp_network_mask_natural, |
| 3538 | no_bgp_network_mask_natural_backdoor_cmd, |
| 3539 | "no network A.B.C.D backdoor", |
| 3540 | NO_STR |
| 3541 | "Specify a network to announce via BGP\n" |
| 3542 | "Network number\n" |
| 3543 | "Specify a BGP backdoor route\n") |
| 3544 | |
| 3545 | #ifdef HAVE_IPV6 |
| 3546 | DEFUN (ipv6_bgp_network, |
| 3547 | ipv6_bgp_network_cmd, |
| 3548 | "network X:X::X:X/M", |
| 3549 | "Specify a network to announce via BGP\n" |
| 3550 | "IPv6 prefix <network>/<length>\n") |
| 3551 | { |
| 3552 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 3553 | } |
| 3554 | |
| 3555 | DEFUN (ipv6_bgp_network_route_map, |
| 3556 | ipv6_bgp_network_route_map_cmd, |
| 3557 | "network X:X::X:X/M route-map WORD", |
| 3558 | "Specify a network to announce via BGP\n" |
| 3559 | "IPv6 prefix <network>/<length>\n" |
| 3560 | "Route-map to modify the attributes\n" |
| 3561 | "Name of the route map\n") |
| 3562 | { |
| 3563 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
| 3564 | bgp_node_safi (vty), argv[1], 0); |
| 3565 | } |
| 3566 | |
| 3567 | DEFUN (no_ipv6_bgp_network, |
| 3568 | no_ipv6_bgp_network_cmd, |
| 3569 | "no network X:X::X:X/M", |
| 3570 | NO_STR |
| 3571 | "Specify a network to announce via BGP\n" |
| 3572 | "IPv6 prefix <network>/<length>\n") |
| 3573 | { |
| 3574 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); |
| 3575 | } |
| 3576 | |
| 3577 | ALIAS (no_ipv6_bgp_network, |
| 3578 | no_ipv6_bgp_network_route_map_cmd, |
| 3579 | "no network X:X::X:X/M route-map WORD", |
| 3580 | NO_STR |
| 3581 | "Specify a network to announce via BGP\n" |
| 3582 | "IPv6 prefix <network>/<length>\n" |
| 3583 | "Route-map to modify the attributes\n" |
| 3584 | "Name of the route map\n") |
| 3585 | |
| 3586 | ALIAS (ipv6_bgp_network, |
| 3587 | old_ipv6_bgp_network_cmd, |
| 3588 | "ipv6 bgp network X:X::X:X/M", |
| 3589 | IPV6_STR |
| 3590 | BGP_STR |
| 3591 | "Specify a network to announce via BGP\n" |
| 3592 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3593 | |
| 3594 | ALIAS (no_ipv6_bgp_network, |
| 3595 | old_no_ipv6_bgp_network_cmd, |
| 3596 | "no ipv6 bgp network X:X::X:X/M", |
| 3597 | NO_STR |
| 3598 | IPV6_STR |
| 3599 | BGP_STR |
| 3600 | "Specify a network to announce via BGP\n" |
| 3601 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3602 | #endif /* HAVE_IPV6 */ |
| 3603 | |
| 3604 | /* Aggreagete address: |
| 3605 | |
| 3606 | advertise-map Set condition to advertise attribute |
| 3607 | as-set Generate AS set path information |
| 3608 | attribute-map Set attributes of aggregate |
| 3609 | route-map Set parameters of aggregate |
| 3610 | summary-only Filter more specific routes from updates |
| 3611 | suppress-map Conditionally filter more specific routes from updates |
| 3612 | <cr> |
| 3613 | */ |
| 3614 | struct bgp_aggregate |
| 3615 | { |
| 3616 | /* Summary-only flag. */ |
| 3617 | u_char summary_only; |
| 3618 | |
| 3619 | /* AS set generation. */ |
| 3620 | u_char as_set; |
| 3621 | |
| 3622 | /* Route-map for aggregated route. */ |
| 3623 | struct route_map *map; |
| 3624 | |
| 3625 | /* Suppress-count. */ |
| 3626 | unsigned long count; |
| 3627 | |
| 3628 | /* SAFI configuration. */ |
| 3629 | safi_t safi; |
| 3630 | }; |
| 3631 | |
| 3632 | struct bgp_aggregate * |
| 3633 | bgp_aggregate_new () |
| 3634 | { |
| 3635 | struct bgp_aggregate *new; |
| 3636 | new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
| 3637 | memset (new, 0, sizeof (struct bgp_aggregate)); |
| 3638 | return new; |
| 3639 | } |
| 3640 | |
| 3641 | void |
| 3642 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 3643 | { |
| 3644 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 3645 | } |
| 3646 | |
| 3647 | void |
| 3648 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 3649 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 3650 | struct bgp_aggregate *aggregate) |
| 3651 | { |
| 3652 | struct bgp_table *table; |
| 3653 | struct bgp_node *top; |
| 3654 | struct bgp_node *rn; |
| 3655 | u_char origin; |
| 3656 | struct aspath *aspath = NULL; |
| 3657 | struct aspath *asmerge = NULL; |
| 3658 | struct community *community = NULL; |
| 3659 | struct community *commerge = NULL; |
| 3660 | struct in_addr nexthop; |
| 3661 | u_int32_t med = 0; |
| 3662 | struct bgp_info *ri; |
| 3663 | struct bgp_info *new; |
| 3664 | int first = 1; |
| 3665 | unsigned long match = 0; |
| 3666 | |
| 3667 | /* Record adding route's nexthop and med. */ |
| 3668 | if (rinew) |
| 3669 | { |
| 3670 | nexthop = rinew->attr->nexthop; |
| 3671 | med = rinew->attr->med; |
| 3672 | } |
| 3673 | |
| 3674 | /* ORIGIN attribute: If at least one route among routes that are |
| 3675 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 3676 | aggregated route must have the ORIGIN attribute with the value |
| 3677 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 3678 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 3679 | route must have the origin attribute with the value EGP. In all |
| 3680 | other case the value of the ORIGIN attribute of the aggregated |
| 3681 | route is INTERNAL. */ |
| 3682 | origin = BGP_ORIGIN_IGP; |
| 3683 | |
| 3684 | table = bgp->rib[afi][safi]; |
| 3685 | |
| 3686 | top = bgp_node_get (table, p); |
| 3687 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 3688 | if (rn->p.prefixlen > p->prefixlen) |
| 3689 | { |
| 3690 | match = 0; |
| 3691 | |
| 3692 | for (ri = rn->info; ri; ri = ri->next) |
| 3693 | { |
| 3694 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3695 | continue; |
| 3696 | |
| 3697 | if (del && ri == del) |
| 3698 | continue; |
| 3699 | |
| 3700 | if (! rinew && first) |
| 3701 | { |
| 3702 | nexthop = ri->attr->nexthop; |
| 3703 | med = ri->attr->med; |
| 3704 | first = 0; |
| 3705 | } |
| 3706 | |
| 3707 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 3708 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 3709 | || ri->attr->med != med) |
| 3710 | { |
| 3711 | if (aspath) |
| 3712 | aspath_free (aspath); |
| 3713 | if (community) |
| 3714 | community_free (community); |
| 3715 | bgp_unlock_node (rn); |
| 3716 | bgp_unlock_node (top); |
| 3717 | return; |
| 3718 | } |
| 3719 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 3720 | |
| 3721 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 3722 | { |
| 3723 | if (aggregate->summary_only) |
| 3724 | { |
| 3725 | ri->suppress++; |
| 3726 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3727 | match++; |
| 3728 | } |
| 3729 | |
| 3730 | aggregate->count++; |
| 3731 | |
| 3732 | if (aggregate->as_set) |
| 3733 | { |
| 3734 | if (origin < ri->attr->origin) |
| 3735 | origin = ri->attr->origin; |
| 3736 | |
| 3737 | if (aspath) |
| 3738 | { |
| 3739 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 3740 | aspath_free (aspath); |
| 3741 | aspath = asmerge; |
| 3742 | } |
| 3743 | else |
| 3744 | aspath = aspath_dup (ri->attr->aspath); |
| 3745 | |
| 3746 | if (ri->attr->community) |
| 3747 | { |
| 3748 | if (community) |
| 3749 | { |
| 3750 | commerge = community_merge (community, |
| 3751 | ri->attr->community); |
| 3752 | community = community_uniq_sort (commerge); |
| 3753 | community_free (commerge); |
| 3754 | } |
| 3755 | else |
| 3756 | community = community_dup (ri->attr->community); |
| 3757 | } |
| 3758 | } |
| 3759 | } |
| 3760 | } |
| 3761 | if (match) |
| 3762 | bgp_process (bgp, rn, afi, safi); |
| 3763 | } |
| 3764 | bgp_unlock_node (top); |
| 3765 | |
| 3766 | if (rinew) |
| 3767 | { |
| 3768 | aggregate->count++; |
| 3769 | |
| 3770 | if (aggregate->summary_only) |
| 3771 | rinew->suppress++; |
| 3772 | |
| 3773 | if (aggregate->as_set) |
| 3774 | { |
| 3775 | if (origin < rinew->attr->origin) |
| 3776 | origin = rinew->attr->origin; |
| 3777 | |
| 3778 | if (aspath) |
| 3779 | { |
| 3780 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 3781 | aspath_free (aspath); |
| 3782 | aspath = asmerge; |
| 3783 | } |
| 3784 | else |
| 3785 | aspath = aspath_dup (rinew->attr->aspath); |
| 3786 | |
| 3787 | if (rinew->attr->community) |
| 3788 | { |
| 3789 | if (community) |
| 3790 | { |
| 3791 | commerge = community_merge (community, |
| 3792 | rinew->attr->community); |
| 3793 | community = community_uniq_sort (commerge); |
| 3794 | community_free (commerge); |
| 3795 | } |
| 3796 | else |
| 3797 | community = community_dup (rinew->attr->community); |
| 3798 | } |
| 3799 | } |
| 3800 | } |
| 3801 | |
| 3802 | if (aggregate->count > 0) |
| 3803 | { |
| 3804 | rn = bgp_node_get (table, p); |
| 3805 | new = bgp_info_new (); |
| 3806 | new->type = ZEBRA_ROUTE_BGP; |
| 3807 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 3808 | new->peer = bgp->peer_self; |
| 3809 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3810 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 3811 | new->uptime = time (NULL); |
| 3812 | |
| 3813 | bgp_info_add (rn, new); |
| 3814 | bgp_process (bgp, rn, afi, safi); |
| 3815 | } |
| 3816 | else |
| 3817 | { |
| 3818 | if (aspath) |
| 3819 | aspath_free (aspath); |
| 3820 | if (community) |
| 3821 | community_free (community); |
| 3822 | } |
| 3823 | } |
| 3824 | |
| 3825 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 3826 | struct bgp_aggregate *); |
| 3827 | |
| 3828 | void |
| 3829 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 3830 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 3831 | { |
| 3832 | struct bgp_node *child; |
| 3833 | struct bgp_node *rn; |
| 3834 | struct bgp_aggregate *aggregate; |
| 3835 | |
| 3836 | /* MPLS-VPN aggregation is not yet supported. */ |
| 3837 | if (safi == SAFI_MPLS_VPN) |
| 3838 | return; |
| 3839 | |
| 3840 | if (p->prefixlen == 0) |
| 3841 | return; |
| 3842 | |
| 3843 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3844 | return; |
| 3845 | |
| 3846 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 3847 | |
| 3848 | /* Aggregate address configuration check. */ |
| 3849 | for (rn = child; rn; rn = rn->parent) |
| 3850 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 3851 | { |
| 3852 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3853 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3854 | } |
| 3855 | bgp_unlock_node (child); |
| 3856 | } |
| 3857 | |
| 3858 | void |
| 3859 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 3860 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 3861 | { |
| 3862 | struct bgp_node *child; |
| 3863 | struct bgp_node *rn; |
| 3864 | struct bgp_aggregate *aggregate; |
| 3865 | |
| 3866 | /* MPLS-VPN aggregation is not yet supported. */ |
| 3867 | if (safi == SAFI_MPLS_VPN) |
| 3868 | return; |
| 3869 | |
| 3870 | if (p->prefixlen == 0) |
| 3871 | return; |
| 3872 | |
| 3873 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 3874 | |
| 3875 | /* Aggregate address configuration check. */ |
| 3876 | for (rn = child; rn; rn = rn->parent) |
| 3877 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 3878 | { |
| 3879 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3880 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3881 | } |
| 3882 | bgp_unlock_node (child); |
| 3883 | } |
| 3884 | |
| 3885 | void |
| 3886 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 3887 | struct bgp_aggregate *aggregate) |
| 3888 | { |
| 3889 | struct bgp_table *table; |
| 3890 | struct bgp_node *top; |
| 3891 | struct bgp_node *rn; |
| 3892 | struct bgp_info *new; |
| 3893 | struct bgp_info *ri; |
| 3894 | unsigned long match; |
| 3895 | u_char origin = BGP_ORIGIN_IGP; |
| 3896 | struct aspath *aspath = NULL; |
| 3897 | struct aspath *asmerge = NULL; |
| 3898 | struct community *community = NULL; |
| 3899 | struct community *commerge = NULL; |
| 3900 | |
| 3901 | table = bgp->rib[afi][safi]; |
| 3902 | |
| 3903 | /* Sanity check. */ |
| 3904 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 3905 | return; |
| 3906 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 3907 | return; |
| 3908 | |
| 3909 | /* If routes exists below this node, generate aggregate routes. */ |
| 3910 | top = bgp_node_get (table, p); |
| 3911 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 3912 | if (rn->p.prefixlen > p->prefixlen) |
| 3913 | { |
| 3914 | match = 0; |
| 3915 | |
| 3916 | for (ri = rn->info; ri; ri = ri->next) |
| 3917 | { |
| 3918 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3919 | continue; |
| 3920 | |
| 3921 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 3922 | { |
| 3923 | /* summary-only aggregate route suppress aggregated |
| 3924 | route announcement. */ |
| 3925 | if (aggregate->summary_only) |
| 3926 | { |
| 3927 | ri->suppress++; |
| 3928 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3929 | match++; |
| 3930 | } |
| 3931 | /* as-set aggregate route generate origin, as path, |
| 3932 | community aggregation. */ |
| 3933 | if (aggregate->as_set) |
| 3934 | { |
| 3935 | if (origin < ri->attr->origin) |
| 3936 | origin = ri->attr->origin; |
| 3937 | |
| 3938 | if (aspath) |
| 3939 | { |
| 3940 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 3941 | aspath_free (aspath); |
| 3942 | aspath = asmerge; |
| 3943 | } |
| 3944 | else |
| 3945 | aspath = aspath_dup (ri->attr->aspath); |
| 3946 | |
| 3947 | if (ri->attr->community) |
| 3948 | { |
| 3949 | if (community) |
| 3950 | { |
| 3951 | commerge = community_merge (community, |
| 3952 | ri->attr->community); |
| 3953 | community = community_uniq_sort (commerge); |
| 3954 | community_free (commerge); |
| 3955 | } |
| 3956 | else |
| 3957 | community = community_dup (ri->attr->community); |
| 3958 | } |
| 3959 | } |
| 3960 | aggregate->count++; |
| 3961 | } |
| 3962 | } |
| 3963 | |
| 3964 | /* If this node is suppressed, process the change. */ |
| 3965 | if (match) |
| 3966 | bgp_process (bgp, rn, afi, safi); |
| 3967 | } |
| 3968 | bgp_unlock_node (top); |
| 3969 | |
| 3970 | /* Add aggregate route to BGP table. */ |
| 3971 | if (aggregate->count) |
| 3972 | { |
| 3973 | rn = bgp_node_get (table, p); |
| 3974 | |
| 3975 | new = bgp_info_new (); |
| 3976 | new->type = ZEBRA_ROUTE_BGP; |
| 3977 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 3978 | new->peer = bgp->peer_self; |
| 3979 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3980 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 3981 | new->uptime = time (NULL); |
| 3982 | |
| 3983 | bgp_info_add (rn, new); |
| 3984 | |
| 3985 | /* Process change. */ |
| 3986 | bgp_process (bgp, rn, afi, safi); |
| 3987 | } |
| 3988 | } |
| 3989 | |
| 3990 | void |
| 3991 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3992 | safi_t safi, struct bgp_aggregate *aggregate) |
| 3993 | { |
| 3994 | struct bgp_table *table; |
| 3995 | struct bgp_node *top; |
| 3996 | struct bgp_node *rn; |
| 3997 | struct bgp_info *ri; |
| 3998 | unsigned long match; |
| 3999 | |
| 4000 | table = bgp->rib[afi][safi]; |
| 4001 | |
| 4002 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4003 | return; |
| 4004 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4005 | return; |
| 4006 | |
| 4007 | /* If routes exists below this node, generate aggregate routes. */ |
| 4008 | top = bgp_node_get (table, p); |
| 4009 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4010 | if (rn->p.prefixlen > p->prefixlen) |
| 4011 | { |
| 4012 | match = 0; |
| 4013 | |
| 4014 | for (ri = rn->info; ri; ri = ri->next) |
| 4015 | { |
| 4016 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4017 | continue; |
| 4018 | |
| 4019 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4020 | { |
| 4021 | if (aggregate->summary_only) |
| 4022 | { |
| 4023 | ri->suppress--; |
| 4024 | |
| 4025 | if (ri->suppress == 0) |
| 4026 | { |
| 4027 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4028 | match++; |
| 4029 | } |
| 4030 | } |
| 4031 | aggregate->count--; |
| 4032 | } |
| 4033 | } |
| 4034 | |
| 4035 | /* If this node is suppressed, process the change. */ |
| 4036 | if (match) |
| 4037 | bgp_process (bgp, rn, afi, safi); |
| 4038 | } |
| 4039 | bgp_unlock_node (top); |
| 4040 | |
| 4041 | /* Delete aggregate route from BGP table. */ |
| 4042 | rn = bgp_node_get (table, p); |
| 4043 | |
| 4044 | for (ri = rn->info; ri; ri = ri->next) |
| 4045 | if (ri->peer == bgp->peer_self |
| 4046 | && ri->type == ZEBRA_ROUTE_BGP |
| 4047 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4048 | break; |
| 4049 | |
| 4050 | /* Withdraw static BGP route from routing table. */ |
| 4051 | if (ri) |
| 4052 | { |
| 4053 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4054 | bgp_process (bgp, rn, afi, safi); |
| 4055 | bgp_info_delete (rn, ri); |
| 4056 | bgp_info_free (ri); |
| 4057 | bgp_unlock_node (rn); |
| 4058 | } |
| 4059 | |
| 4060 | /* Unlock bgp_node_lookup. */ |
| 4061 | bgp_unlock_node (rn); |
| 4062 | } |
| 4063 | |
| 4064 | /* Aggregate route attribute. */ |
| 4065 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4066 | #define AGGREGATE_AS_SET 1 |
| 4067 | |
| 4068 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4069 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
| 4070 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4071 | u_char summary_only, u_char as_set) |
| 4072 | { |
| 4073 | int ret; |
| 4074 | struct prefix p; |
| 4075 | struct bgp_node *rn; |
| 4076 | struct bgp *bgp; |
| 4077 | struct bgp_aggregate *aggregate; |
| 4078 | |
| 4079 | /* Convert string to prefix structure. */ |
| 4080 | ret = str2prefix (prefix_str, &p); |
| 4081 | if (!ret) |
| 4082 | { |
| 4083 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4084 | return CMD_WARNING; |
| 4085 | } |
| 4086 | apply_mask (&p); |
| 4087 | |
| 4088 | /* Get BGP structure. */ |
| 4089 | bgp = vty->index; |
| 4090 | |
| 4091 | /* Old configuration check. */ |
| 4092 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4093 | |
| 4094 | if (rn->info) |
| 4095 | { |
| 4096 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
| 4097 | bgp_unlock_node (rn); |
| 4098 | return CMD_WARNING; |
| 4099 | } |
| 4100 | |
| 4101 | /* Make aggregate address structure. */ |
| 4102 | aggregate = bgp_aggregate_new (); |
| 4103 | aggregate->summary_only = summary_only; |
| 4104 | aggregate->as_set = as_set; |
| 4105 | aggregate->safi = safi; |
| 4106 | rn->info = aggregate; |
| 4107 | |
| 4108 | /* Aggregate address insert into BGP routing table. */ |
| 4109 | if (safi & SAFI_UNICAST) |
| 4110 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4111 | if (safi & SAFI_MULTICAST) |
| 4112 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4113 | |
| 4114 | return CMD_SUCCESS; |
| 4115 | } |
| 4116 | |
| 4117 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4118 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4119 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4120 | { |
| 4121 | int ret; |
| 4122 | struct prefix p; |
| 4123 | struct bgp_node *rn; |
| 4124 | struct bgp *bgp; |
| 4125 | struct bgp_aggregate *aggregate; |
| 4126 | |
| 4127 | /* Convert string to prefix structure. */ |
| 4128 | ret = str2prefix (prefix_str, &p); |
| 4129 | if (!ret) |
| 4130 | { |
| 4131 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4132 | return CMD_WARNING; |
| 4133 | } |
| 4134 | apply_mask (&p); |
| 4135 | |
| 4136 | /* Get BGP structure. */ |
| 4137 | bgp = vty->index; |
| 4138 | |
| 4139 | /* Old configuration check. */ |
| 4140 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4141 | if (! rn) |
| 4142 | { |
| 4143 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4144 | VTY_NEWLINE); |
| 4145 | return CMD_WARNING; |
| 4146 | } |
| 4147 | |
| 4148 | aggregate = rn->info; |
| 4149 | if (aggregate->safi & SAFI_UNICAST) |
| 4150 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4151 | if (aggregate->safi & SAFI_MULTICAST) |
| 4152 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4153 | |
| 4154 | /* Unlock aggregate address configuration. */ |
| 4155 | rn->info = NULL; |
| 4156 | bgp_aggregate_free (aggregate); |
| 4157 | bgp_unlock_node (rn); |
| 4158 | bgp_unlock_node (rn); |
| 4159 | |
| 4160 | return CMD_SUCCESS; |
| 4161 | } |
| 4162 | |
| 4163 | DEFUN (aggregate_address, |
| 4164 | aggregate_address_cmd, |
| 4165 | "aggregate-address A.B.C.D/M", |
| 4166 | "Configure BGP aggregate entries\n" |
| 4167 | "Aggregate prefix\n") |
| 4168 | { |
| 4169 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 4170 | } |
| 4171 | |
| 4172 | DEFUN (aggregate_address_mask, |
| 4173 | aggregate_address_mask_cmd, |
| 4174 | "aggregate-address A.B.C.D A.B.C.D", |
| 4175 | "Configure BGP aggregate entries\n" |
| 4176 | "Aggregate address\n" |
| 4177 | "Aggregate mask\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 | 0, 0); |
| 4192 | } |
| 4193 | |
| 4194 | DEFUN (aggregate_address_summary_only, |
| 4195 | aggregate_address_summary_only_cmd, |
| 4196 | "aggregate-address A.B.C.D/M summary-only", |
| 4197 | "Configure BGP aggregate entries\n" |
| 4198 | "Aggregate prefix\n" |
| 4199 | "Filter more specific routes from updates\n") |
| 4200 | { |
| 4201 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4202 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4203 | } |
| 4204 | |
| 4205 | DEFUN (aggregate_address_mask_summary_only, |
| 4206 | aggregate_address_mask_summary_only_cmd, |
| 4207 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4208 | "Configure BGP aggregate entries\n" |
| 4209 | "Aggregate address\n" |
| 4210 | "Aggregate mask\n" |
| 4211 | "Filter more specific routes from updates\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 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4226 | } |
| 4227 | |
| 4228 | DEFUN (aggregate_address_as_set, |
| 4229 | aggregate_address_as_set_cmd, |
| 4230 | "aggregate-address A.B.C.D/M as-set", |
| 4231 | "Configure BGP aggregate entries\n" |
| 4232 | "Aggregate prefix\n" |
| 4233 | "Generate AS set path information\n") |
| 4234 | { |
| 4235 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4236 | 0, AGGREGATE_AS_SET); |
| 4237 | } |
| 4238 | |
| 4239 | DEFUN (aggregate_address_mask_as_set, |
| 4240 | aggregate_address_mask_as_set_cmd, |
| 4241 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 4242 | "Configure BGP aggregate entries\n" |
| 4243 | "Aggregate address\n" |
| 4244 | "Aggregate mask\n" |
| 4245 | "Generate AS set path information\n") |
| 4246 | { |
| 4247 | int ret; |
| 4248 | char prefix_str[BUFSIZ]; |
| 4249 | |
| 4250 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4251 | |
| 4252 | if (! ret) |
| 4253 | { |
| 4254 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4255 | return CMD_WARNING; |
| 4256 | } |
| 4257 | |
| 4258 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4259 | 0, AGGREGATE_AS_SET); |
| 4260 | } |
| 4261 | |
| 4262 | |
| 4263 | DEFUN (aggregate_address_as_set_summary, |
| 4264 | aggregate_address_as_set_summary_cmd, |
| 4265 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 4266 | "Configure BGP aggregate entries\n" |
| 4267 | "Aggregate prefix\n" |
| 4268 | "Generate AS set path information\n" |
| 4269 | "Filter more specific routes from updates\n") |
| 4270 | { |
| 4271 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4272 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4273 | } |
| 4274 | |
| 4275 | ALIAS (aggregate_address_as_set_summary, |
| 4276 | aggregate_address_summary_as_set_cmd, |
| 4277 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 4278 | "Configure BGP aggregate entries\n" |
| 4279 | "Aggregate prefix\n" |
| 4280 | "Filter more specific routes from updates\n" |
| 4281 | "Generate AS set path information\n") |
| 4282 | |
| 4283 | DEFUN (aggregate_address_mask_as_set_summary, |
| 4284 | aggregate_address_mask_as_set_summary_cmd, |
| 4285 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4286 | "Configure BGP aggregate entries\n" |
| 4287 | "Aggregate address\n" |
| 4288 | "Aggregate mask\n" |
| 4289 | "Generate AS set path information\n" |
| 4290 | "Filter more specific routes from updates\n") |
| 4291 | { |
| 4292 | int ret; |
| 4293 | char prefix_str[BUFSIZ]; |
| 4294 | |
| 4295 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4296 | |
| 4297 | if (! ret) |
| 4298 | { |
| 4299 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4300 | return CMD_WARNING; |
| 4301 | } |
| 4302 | |
| 4303 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4304 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4305 | } |
| 4306 | |
| 4307 | ALIAS (aggregate_address_mask_as_set_summary, |
| 4308 | aggregate_address_mask_summary_as_set_cmd, |
| 4309 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4310 | "Configure BGP aggregate entries\n" |
| 4311 | "Aggregate address\n" |
| 4312 | "Aggregate mask\n" |
| 4313 | "Filter more specific routes from updates\n" |
| 4314 | "Generate AS set path information\n") |
| 4315 | |
| 4316 | DEFUN (no_aggregate_address, |
| 4317 | no_aggregate_address_cmd, |
| 4318 | "no aggregate-address A.B.C.D/M", |
| 4319 | NO_STR |
| 4320 | "Configure BGP aggregate entries\n" |
| 4321 | "Aggregate prefix\n") |
| 4322 | { |
| 4323 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 4324 | } |
| 4325 | |
| 4326 | ALIAS (no_aggregate_address, |
| 4327 | no_aggregate_address_summary_only_cmd, |
| 4328 | "no aggregate-address A.B.C.D/M summary-only", |
| 4329 | NO_STR |
| 4330 | "Configure BGP aggregate entries\n" |
| 4331 | "Aggregate prefix\n" |
| 4332 | "Filter more specific routes from updates\n") |
| 4333 | |
| 4334 | ALIAS (no_aggregate_address, |
| 4335 | no_aggregate_address_as_set_cmd, |
| 4336 | "no aggregate-address A.B.C.D/M as-set", |
| 4337 | NO_STR |
| 4338 | "Configure BGP aggregate entries\n" |
| 4339 | "Aggregate prefix\n" |
| 4340 | "Generate AS set path information\n") |
| 4341 | |
| 4342 | ALIAS (no_aggregate_address, |
| 4343 | no_aggregate_address_as_set_summary_cmd, |
| 4344 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 4345 | NO_STR |
| 4346 | "Configure BGP aggregate entries\n" |
| 4347 | "Aggregate prefix\n" |
| 4348 | "Generate AS set path information\n" |
| 4349 | "Filter more specific routes from updates\n") |
| 4350 | |
| 4351 | ALIAS (no_aggregate_address, |
| 4352 | no_aggregate_address_summary_as_set_cmd, |
| 4353 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 4354 | NO_STR |
| 4355 | "Configure BGP aggregate entries\n" |
| 4356 | "Aggregate prefix\n" |
| 4357 | "Filter more specific routes from updates\n" |
| 4358 | "Generate AS set path information\n") |
| 4359 | |
| 4360 | DEFUN (no_aggregate_address_mask, |
| 4361 | no_aggregate_address_mask_cmd, |
| 4362 | "no aggregate-address A.B.C.D A.B.C.D", |
| 4363 | NO_STR |
| 4364 | "Configure BGP aggregate entries\n" |
| 4365 | "Aggregate address\n" |
| 4366 | "Aggregate mask\n") |
| 4367 | { |
| 4368 | int ret; |
| 4369 | char prefix_str[BUFSIZ]; |
| 4370 | |
| 4371 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4372 | |
| 4373 | if (! ret) |
| 4374 | { |
| 4375 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4376 | return CMD_WARNING; |
| 4377 | } |
| 4378 | |
| 4379 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 4380 | } |
| 4381 | |
| 4382 | ALIAS (no_aggregate_address_mask, |
| 4383 | no_aggregate_address_mask_summary_only_cmd, |
| 4384 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4385 | NO_STR |
| 4386 | "Configure BGP aggregate entries\n" |
| 4387 | "Aggregate address\n" |
| 4388 | "Aggregate mask\n" |
| 4389 | "Filter more specific routes from updates\n") |
| 4390 | |
| 4391 | ALIAS (no_aggregate_address_mask, |
| 4392 | no_aggregate_address_mask_as_set_cmd, |
| 4393 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 4394 | NO_STR |
| 4395 | "Configure BGP aggregate entries\n" |
| 4396 | "Aggregate address\n" |
| 4397 | "Aggregate mask\n" |
| 4398 | "Generate AS set path information\n") |
| 4399 | |
| 4400 | ALIAS (no_aggregate_address_mask, |
| 4401 | no_aggregate_address_mask_as_set_summary_cmd, |
| 4402 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4403 | NO_STR |
| 4404 | "Configure BGP aggregate entries\n" |
| 4405 | "Aggregate address\n" |
| 4406 | "Aggregate mask\n" |
| 4407 | "Generate AS set path information\n" |
| 4408 | "Filter more specific routes from updates\n") |
| 4409 | |
| 4410 | ALIAS (no_aggregate_address_mask, |
| 4411 | no_aggregate_address_mask_summary_as_set_cmd, |
| 4412 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4413 | NO_STR |
| 4414 | "Configure BGP aggregate entries\n" |
| 4415 | "Aggregate address\n" |
| 4416 | "Aggregate mask\n" |
| 4417 | "Filter more specific routes from updates\n" |
| 4418 | "Generate AS set path information\n") |
| 4419 | |
| 4420 | #ifdef HAVE_IPV6 |
| 4421 | DEFUN (ipv6_aggregate_address, |
| 4422 | ipv6_aggregate_address_cmd, |
| 4423 | "aggregate-address X:X::X:X/M", |
| 4424 | "Configure BGP aggregate entries\n" |
| 4425 | "Aggregate prefix\n") |
| 4426 | { |
| 4427 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 4428 | } |
| 4429 | |
| 4430 | DEFUN (ipv6_aggregate_address_summary_only, |
| 4431 | ipv6_aggregate_address_summary_only_cmd, |
| 4432 | "aggregate-address X:X::X:X/M summary-only", |
| 4433 | "Configure BGP aggregate entries\n" |
| 4434 | "Aggregate prefix\n" |
| 4435 | "Filter more specific routes from updates\n") |
| 4436 | { |
| 4437 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 4438 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4439 | } |
| 4440 | |
| 4441 | DEFUN (no_ipv6_aggregate_address, |
| 4442 | no_ipv6_aggregate_address_cmd, |
| 4443 | "no aggregate-address X:X::X:X/M", |
| 4444 | NO_STR |
| 4445 | "Configure BGP aggregate entries\n" |
| 4446 | "Aggregate prefix\n") |
| 4447 | { |
| 4448 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4449 | } |
| 4450 | |
| 4451 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 4452 | no_ipv6_aggregate_address_summary_only_cmd, |
| 4453 | "no aggregate-address X:X::X:X/M summary-only", |
| 4454 | NO_STR |
| 4455 | "Configure BGP aggregate entries\n" |
| 4456 | "Aggregate prefix\n" |
| 4457 | "Filter more specific routes from updates\n") |
| 4458 | { |
| 4459 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4460 | } |
| 4461 | |
| 4462 | ALIAS (ipv6_aggregate_address, |
| 4463 | old_ipv6_aggregate_address_cmd, |
| 4464 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 4465 | IPV6_STR |
| 4466 | BGP_STR |
| 4467 | "Configure BGP aggregate entries\n" |
| 4468 | "Aggregate prefix\n") |
| 4469 | |
| 4470 | ALIAS (ipv6_aggregate_address_summary_only, |
| 4471 | old_ipv6_aggregate_address_summary_only_cmd, |
| 4472 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4473 | IPV6_STR |
| 4474 | BGP_STR |
| 4475 | "Configure BGP aggregate entries\n" |
| 4476 | "Aggregate prefix\n" |
| 4477 | "Filter more specific routes from updates\n") |
| 4478 | |
| 4479 | ALIAS (no_ipv6_aggregate_address, |
| 4480 | old_no_ipv6_aggregate_address_cmd, |
| 4481 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 4482 | NO_STR |
| 4483 | IPV6_STR |
| 4484 | BGP_STR |
| 4485 | "Configure BGP aggregate entries\n" |
| 4486 | "Aggregate prefix\n") |
| 4487 | |
| 4488 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 4489 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 4490 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4491 | NO_STR |
| 4492 | IPV6_STR |
| 4493 | BGP_STR |
| 4494 | "Configure BGP aggregate entries\n" |
| 4495 | "Aggregate prefix\n" |
| 4496 | "Filter more specific routes from updates\n") |
| 4497 | #endif /* HAVE_IPV6 */ |
| 4498 | |
| 4499 | /* Redistribute route treatment. */ |
| 4500 | void |
| 4501 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, |
| 4502 | u_int32_t metric, u_char type) |
| 4503 | { |
| 4504 | struct bgp *bgp; |
| 4505 | struct listnode *nn; |
| 4506 | struct bgp_info *new; |
| 4507 | struct bgp_info *bi; |
| 4508 | struct bgp_info info; |
| 4509 | struct bgp_node *bn; |
| 4510 | struct attr attr; |
| 4511 | struct attr attr_new; |
| 4512 | struct attr *new_attr; |
| 4513 | afi_t afi; |
| 4514 | int ret; |
| 4515 | |
| 4516 | /* Make default attribute. */ |
| 4517 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 4518 | if (nexthop) |
| 4519 | attr.nexthop = *nexthop; |
| 4520 | |
| 4521 | attr.med = metric; |
| 4522 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 4523 | |
| 4524 | LIST_LOOP (bm->bgp, bgp, nn) |
| 4525 | { |
| 4526 | afi = family2afi (p->family); |
| 4527 | |
| 4528 | if (bgp->redist[afi][type]) |
| 4529 | { |
| 4530 | /* Copy attribute for modification. */ |
| 4531 | attr_new = attr; |
| 4532 | |
| 4533 | if (bgp->redist_metric_flag[afi][type]) |
| 4534 | attr_new.med = bgp->redist_metric[afi][type]; |
| 4535 | |
| 4536 | /* Apply route-map. */ |
| 4537 | if (bgp->rmap[afi][type].map) |
| 4538 | { |
| 4539 | info.peer = bgp->peer_self; |
| 4540 | info.attr = &attr_new; |
| 4541 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4542 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 4543 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4544 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 4545 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4546 | |
| 4547 | bgp->peer_self->rmap_type = 0; |
| 4548 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4549 | if (ret == RMAP_DENYMATCH) |
| 4550 | { |
| 4551 | /* Free uninterned attribute. */ |
| 4552 | bgp_attr_flush (&attr_new); |
| 4553 | |
| 4554 | /* Unintern original. */ |
| 4555 | aspath_unintern (attr.aspath); |
| 4556 | bgp_redistribute_delete (p, type); |
| 4557 | return; |
| 4558 | } |
| 4559 | } |
| 4560 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4561 | 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] | 4562 | new_attr = bgp_attr_intern (&attr_new); |
| 4563 | |
| 4564 | for (bi = bn->info; bi; bi = bi->next) |
| 4565 | if (bi->peer == bgp->peer_self |
| 4566 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 4567 | break; |
| 4568 | |
| 4569 | if (bi) |
| 4570 | { |
| 4571 | if (attrhash_cmp (bi->attr, new_attr)) |
| 4572 | { |
| 4573 | bgp_attr_unintern (new_attr); |
| 4574 | aspath_unintern (attr.aspath); |
| 4575 | bgp_unlock_node (bn); |
| 4576 | return; |
| 4577 | } |
| 4578 | else |
| 4579 | { |
| 4580 | /* The attribute is changed. */ |
| 4581 | SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED); |
| 4582 | |
| 4583 | /* Rewrite BGP route information. */ |
| 4584 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
| 4585 | bgp_attr_unintern (bi->attr); |
| 4586 | bi->attr = new_attr; |
| 4587 | bi->uptime = time (NULL); |
| 4588 | |
| 4589 | /* Process change. */ |
| 4590 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 4591 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4592 | bgp_unlock_node (bn); |
| 4593 | aspath_unintern (attr.aspath); |
| 4594 | return; |
| 4595 | } |
| 4596 | } |
| 4597 | |
| 4598 | new = bgp_info_new (); |
| 4599 | new->type = type; |
| 4600 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 4601 | new->peer = bgp->peer_self; |
| 4602 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4603 | new->attr = new_attr; |
| 4604 | new->uptime = time (NULL); |
| 4605 | |
| 4606 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 4607 | bgp_info_add (bn, new); |
| 4608 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4609 | } |
| 4610 | } |
| 4611 | |
| 4612 | /* Unintern original. */ |
| 4613 | aspath_unintern (attr.aspath); |
| 4614 | } |
| 4615 | |
| 4616 | void |
| 4617 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 4618 | { |
| 4619 | struct bgp *bgp; |
| 4620 | struct listnode *nn; |
| 4621 | afi_t afi; |
| 4622 | struct bgp_node *rn; |
| 4623 | struct bgp_info *ri; |
| 4624 | |
| 4625 | LIST_LOOP (bm->bgp, bgp, nn) |
| 4626 | { |
| 4627 | afi = family2afi (p->family); |
| 4628 | |
| 4629 | if (bgp->redist[afi][type]) |
| 4630 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4631 | 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] | 4632 | |
| 4633 | for (ri = rn->info; ri; ri = ri->next) |
| 4634 | if (ri->peer == bgp->peer_self |
| 4635 | && ri->type == type) |
| 4636 | break; |
| 4637 | |
| 4638 | if (ri) |
| 4639 | { |
| 4640 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
| 4641 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4642 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4643 | bgp_info_delete (rn, ri); |
| 4644 | bgp_info_free (ri); |
| 4645 | bgp_unlock_node (rn); |
| 4646 | } |
| 4647 | bgp_unlock_node (rn); |
| 4648 | } |
| 4649 | } |
| 4650 | } |
| 4651 | |
| 4652 | /* Withdraw specified route type's route. */ |
| 4653 | void |
| 4654 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 4655 | { |
| 4656 | struct bgp_node *rn; |
| 4657 | struct bgp_info *ri; |
| 4658 | struct bgp_table *table; |
| 4659 | |
| 4660 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 4661 | |
| 4662 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 4663 | { |
| 4664 | for (ri = rn->info; ri; ri = ri->next) |
| 4665 | if (ri->peer == bgp->peer_self |
| 4666 | && ri->type == type) |
| 4667 | break; |
| 4668 | |
| 4669 | if (ri) |
| 4670 | { |
| 4671 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
| 4672 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4673 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4674 | bgp_info_delete (rn, ri); |
| 4675 | bgp_info_free (ri); |
| 4676 | bgp_unlock_node (rn); |
| 4677 | } |
| 4678 | } |
| 4679 | } |
| 4680 | |
| 4681 | /* Static function to display route. */ |
| 4682 | void |
| 4683 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 4684 | { |
| 4685 | int len; |
| 4686 | u_int32_t destination; |
| 4687 | char buf[BUFSIZ]; |
| 4688 | |
| 4689 | if (p->family == AF_INET) |
| 4690 | { |
| 4691 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 4692 | destination = ntohl (p->u.prefix4.s_addr); |
| 4693 | |
| 4694 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 4695 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 4696 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 4697 | || p->u.prefix4.s_addr == 0) |
| 4698 | { |
| 4699 | /* When mask is natural, mask is not displayed. */ |
| 4700 | } |
| 4701 | else |
| 4702 | len += vty_out (vty, "/%d", p->prefixlen); |
| 4703 | } |
| 4704 | else |
| 4705 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 4706 | p->prefixlen); |
| 4707 | |
| 4708 | len = 17 - len; |
| 4709 | if (len < 1) |
| 4710 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 4711 | else |
| 4712 | vty_out (vty, "%*s", len, " "); |
| 4713 | } |
| 4714 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4715 | enum bgp_display_type |
| 4716 | { |
| 4717 | normal_list, |
| 4718 | }; |
| 4719 | |
| 4720 | /* called from terminal list command */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4721 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4722 | route_vty_out (struct vty *vty, struct prefix *p, |
| 4723 | struct bgp_info *binfo, int display, safi_t safi) |
| 4724 | { |
| 4725 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4726 | |
| 4727 | /* Route status display. */ |
| 4728 | if (binfo->suppress) |
| 4729 | vty_out (vty, "s"); |
| 4730 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4731 | vty_out (vty, "*"); |
| 4732 | else |
| 4733 | vty_out (vty, " "); |
| 4734 | |
| 4735 | /* Selected */ |
| 4736 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4737 | vty_out (vty, "h"); |
| 4738 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4739 | vty_out (vty, "d"); |
| 4740 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4741 | vty_out (vty, ">"); |
| 4742 | else |
| 4743 | vty_out (vty, " "); |
| 4744 | |
| 4745 | /* Internal route. */ |
| 4746 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 4747 | vty_out (vty, "i"); |
| 4748 | else |
| 4749 | vty_out (vty, " "); |
| 4750 | |
| 4751 | /* print prefix and mask */ |
| 4752 | if (! display) |
| 4753 | route_vty_out_route (p, vty); |
| 4754 | else |
| 4755 | vty_out (vty, "%*s", 17, " "); |
| 4756 | |
| 4757 | /* Print attribute */ |
| 4758 | attr = binfo->attr; |
| 4759 | if (attr) |
| 4760 | { |
| 4761 | if (p->family == AF_INET) |
| 4762 | { |
| 4763 | if (safi == SAFI_MPLS_VPN) |
| 4764 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4765 | else |
| 4766 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4767 | } |
| 4768 | #ifdef HAVE_IPV6 |
| 4769 | else if (p->family == AF_INET6) |
| 4770 | { |
| 4771 | int len; |
| 4772 | char buf[BUFSIZ]; |
| 4773 | |
| 4774 | len = vty_out (vty, "%s", |
| 4775 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 4776 | len = 16 - len; |
| 4777 | if (len < 1) |
| 4778 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 4779 | else |
| 4780 | vty_out (vty, "%*s", len, " "); |
| 4781 | } |
| 4782 | #endif /* HAVE_IPV6 */ |
| 4783 | |
| 4784 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 4785 | vty_out (vty, "%10d", attr->med); |
| 4786 | else |
| 4787 | vty_out (vty, " "); |
| 4788 | |
| 4789 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 4790 | vty_out (vty, "%7d", attr->local_pref); |
| 4791 | else |
| 4792 | vty_out (vty, " "); |
| 4793 | |
| 4794 | vty_out (vty, "%7u ",attr->weight); |
| 4795 | |
| 4796 | /* Print aspath */ |
| 4797 | if (attr->aspath) |
| 4798 | aspath_print_vty (vty, attr->aspath); |
| 4799 | |
| 4800 | /* Print origin */ |
| 4801 | if (strlen (attr->aspath->str) == 0) |
| 4802 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4803 | else |
| 4804 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4805 | } |
| 4806 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4807 | } |
| 4808 | |
| 4809 | /* called from terminal list command */ |
| 4810 | void |
| 4811 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 4812 | struct attr *attr, safi_t safi) |
| 4813 | { |
| 4814 | /* Route status display. */ |
| 4815 | vty_out (vty, "*"); |
| 4816 | vty_out (vty, ">"); |
| 4817 | vty_out (vty, " "); |
| 4818 | |
| 4819 | /* print prefix and mask */ |
| 4820 | route_vty_out_route (p, vty); |
| 4821 | |
| 4822 | /* Print attribute */ |
| 4823 | if (attr) |
| 4824 | { |
| 4825 | if (p->family == AF_INET) |
| 4826 | { |
| 4827 | if (safi == SAFI_MPLS_VPN) |
| 4828 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4829 | else |
| 4830 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4831 | } |
| 4832 | #ifdef HAVE_IPV6 |
| 4833 | else if (p->family == AF_INET6) |
| 4834 | { |
| 4835 | int len; |
| 4836 | char buf[BUFSIZ]; |
| 4837 | |
| 4838 | len = vty_out (vty, "%s", |
| 4839 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 4840 | len = 16 - len; |
| 4841 | if (len < 1) |
| 4842 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 4843 | else |
| 4844 | vty_out (vty, "%*s", len, " "); |
| 4845 | } |
| 4846 | #endif /* HAVE_IPV6 */ |
| 4847 | |
| 4848 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 4849 | vty_out (vty, "%10d", attr->med); |
| 4850 | else |
| 4851 | vty_out (vty, " "); |
| 4852 | |
| 4853 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 4854 | vty_out (vty, "%7d", attr->local_pref); |
| 4855 | else |
| 4856 | vty_out (vty, " "); |
| 4857 | |
| 4858 | vty_out (vty, "%7d ",attr->weight); |
| 4859 | |
| 4860 | /* Print aspath */ |
| 4861 | if (attr->aspath) |
| 4862 | aspath_print_vty (vty, attr->aspath); |
| 4863 | |
| 4864 | /* Print origin */ |
| 4865 | if (strlen (attr->aspath->str) == 0) |
| 4866 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4867 | else |
| 4868 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4869 | } |
| 4870 | |
| 4871 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4872 | } |
| 4873 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4874 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4875 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 4876 | struct bgp_info *binfo, int display, safi_t safi) |
| 4877 | { |
| 4878 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4879 | u_int32_t label = 0; |
| 4880 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4881 | /* Route status display. */ |
| 4882 | if (binfo->suppress) |
| 4883 | vty_out (vty, "s"); |
| 4884 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4885 | vty_out (vty, "*"); |
| 4886 | else |
| 4887 | vty_out (vty, " "); |
| 4888 | |
| 4889 | /* Selected */ |
| 4890 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4891 | vty_out (vty, "h"); |
| 4892 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4893 | vty_out (vty, "d"); |
| 4894 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4895 | vty_out (vty, ">"); |
| 4896 | else |
| 4897 | vty_out (vty, " "); |
| 4898 | |
| 4899 | /* Internal route. */ |
| 4900 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 4901 | vty_out (vty, "i"); |
| 4902 | else |
| 4903 | vty_out (vty, " "); |
| 4904 | |
| 4905 | /* print prefix and mask */ |
| 4906 | if (! display) |
| 4907 | route_vty_out_route (p, vty); |
| 4908 | else |
| 4909 | vty_out (vty, "%*s", 17, " "); |
| 4910 | |
| 4911 | /* Print attribute */ |
| 4912 | attr = binfo->attr; |
| 4913 | if (attr) |
| 4914 | { |
| 4915 | if (p->family == AF_INET) |
| 4916 | { |
| 4917 | if (safi == SAFI_MPLS_VPN) |
| 4918 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4919 | else |
| 4920 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4921 | } |
| 4922 | #ifdef HAVE_IPV6 |
| 4923 | else if (p->family == AF_INET6) |
| 4924 | { |
| 4925 | char buf[BUFSIZ]; |
| 4926 | char buf1[BUFSIZ]; |
| 4927 | if (attr->mp_nexthop_len == 16) |
| 4928 | vty_out (vty, "%s", |
| 4929 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 4930 | else if (attr->mp_nexthop_len == 32) |
| 4931 | vty_out (vty, "%s(%s)", |
| 4932 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ), |
| 4933 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ)); |
| 4934 | |
| 4935 | } |
| 4936 | #endif /* HAVE_IPV6 */ |
| 4937 | } |
| 4938 | |
| 4939 | label = decode_label (binfo->tag); |
| 4940 | |
| 4941 | vty_out (vty, "notag/%d", label); |
| 4942 | |
| 4943 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4944 | } |
| 4945 | |
| 4946 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4947 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4948 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 4949 | struct bgp_info *binfo, int display, safi_t safi) |
| 4950 | { |
| 4951 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4952 | int len; |
| 4953 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4954 | /* Route status display. */ |
| 4955 | if (binfo->suppress) |
| 4956 | vty_out (vty, "s"); |
| 4957 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4958 | vty_out (vty, "*"); |
| 4959 | else |
| 4960 | vty_out (vty, " "); |
| 4961 | |
| 4962 | /* Selected */ |
| 4963 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4964 | vty_out (vty, "h"); |
| 4965 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4966 | vty_out (vty, "d"); |
| 4967 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4968 | vty_out (vty, ">"); |
| 4969 | else |
| 4970 | vty_out (vty, " "); |
| 4971 | |
| 4972 | vty_out (vty, " "); |
| 4973 | |
| 4974 | /* print prefix and mask */ |
| 4975 | if (! display) |
| 4976 | route_vty_out_route (p, vty); |
| 4977 | else |
| 4978 | vty_out (vty, "%*s", 17, " "); |
| 4979 | |
| 4980 | len = vty_out (vty, "%s", binfo->peer->host); |
| 4981 | len = 17 - len; |
| 4982 | if (len < 1) |
| 4983 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 4984 | else |
| 4985 | vty_out (vty, "%*s", len, " "); |
| 4986 | |
| 4987 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 4988 | |
| 4989 | /* Print attribute */ |
| 4990 | attr = binfo->attr; |
| 4991 | if (attr) |
| 4992 | { |
| 4993 | /* Print aspath */ |
| 4994 | if (attr->aspath) |
| 4995 | aspath_print_vty (vty, attr->aspath); |
| 4996 | |
| 4997 | /* Print origin */ |
| 4998 | if (strlen (attr->aspath->str) == 0) |
| 4999 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5000 | else |
| 5001 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5002 | } |
| 5003 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5004 | } |
| 5005 | |
| 5006 | #define BGP_UPTIME_LEN 25 |
| 5007 | |
| 5008 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5009 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5010 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5011 | struct bgp_info *binfo, int display, safi_t safi) |
| 5012 | { |
| 5013 | struct attr *attr; |
| 5014 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5015 | char timebuf[BGP_UPTIME_LEN]; |
| 5016 | int len; |
| 5017 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5018 | bdi = binfo->damp_info; |
| 5019 | |
| 5020 | /* Route status display. */ |
| 5021 | if (binfo->suppress) |
| 5022 | vty_out (vty, "s"); |
| 5023 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5024 | vty_out (vty, "*"); |
| 5025 | else |
| 5026 | vty_out (vty, " "); |
| 5027 | |
| 5028 | /* Selected */ |
| 5029 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5030 | vty_out (vty, "h"); |
| 5031 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5032 | vty_out (vty, "d"); |
| 5033 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5034 | vty_out (vty, ">"); |
| 5035 | else |
| 5036 | vty_out (vty, " "); |
| 5037 | |
| 5038 | vty_out (vty, " "); |
| 5039 | |
| 5040 | /* print prefix and mask */ |
| 5041 | if (! display) |
| 5042 | route_vty_out_route (p, vty); |
| 5043 | else |
| 5044 | vty_out (vty, "%*s", 17, " "); |
| 5045 | |
| 5046 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5047 | len = 16 - len; |
| 5048 | if (len < 1) |
| 5049 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5050 | else |
| 5051 | vty_out (vty, "%*s", len, " "); |
| 5052 | |
| 5053 | len = vty_out (vty, "%d", bdi->flap); |
| 5054 | len = 5 - len; |
| 5055 | if (len < 1) |
| 5056 | vty_out (vty, " "); |
| 5057 | else |
| 5058 | vty_out (vty, "%*s ", len, " "); |
| 5059 | |
| 5060 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5061 | timebuf, BGP_UPTIME_LEN)); |
| 5062 | |
| 5063 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5064 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5065 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5066 | else |
| 5067 | vty_out (vty, "%*s ", 8, " "); |
| 5068 | |
| 5069 | /* Print attribute */ |
| 5070 | attr = binfo->attr; |
| 5071 | if (attr) |
| 5072 | { |
| 5073 | /* Print aspath */ |
| 5074 | if (attr->aspath) |
| 5075 | aspath_print_vty (vty, attr->aspath); |
| 5076 | |
| 5077 | /* Print origin */ |
| 5078 | if (strlen (attr->aspath->str) == 0) |
| 5079 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5080 | else |
| 5081 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5082 | } |
| 5083 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5084 | } |
| 5085 | |
| 5086 | void |
| 5087 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5088 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5089 | { |
| 5090 | char buf[INET6_ADDRSTRLEN]; |
| 5091 | char buf1[BUFSIZ]; |
| 5092 | struct attr *attr; |
| 5093 | int sockunion_vty_out (struct vty *, union sockunion *); |
| 5094 | |
| 5095 | attr = binfo->attr; |
| 5096 | |
| 5097 | if (attr) |
| 5098 | { |
| 5099 | /* Line1 display AS-path, Aggregator */ |
| 5100 | if (attr->aspath) |
| 5101 | { |
| 5102 | vty_out (vty, " "); |
| 5103 | if (attr->aspath->length == 0) |
| 5104 | vty_out (vty, "Local"); |
| 5105 | else |
| 5106 | aspath_print_vty (vty, attr->aspath); |
| 5107 | } |
| 5108 | |
| 5109 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR) |
| 5110 | || CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT) |
| 5111 | || CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 5112 | || CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY) |
| 5113 | || CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5114 | { |
| 5115 | vty_out (vty, ","); |
| 5116 | |
| 5117 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)) |
| 5118 | vty_out (vty, " (aggregated by %d %s)", attr->aggregator_as, |
| 5119 | inet_ntoa (attr->aggregator_addr)); |
| 5120 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5121 | vty_out (vty, " (Received from a RR-client)"); |
| 5122 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5123 | vty_out (vty, " (Received from a RS-client)"); |
| 5124 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5125 | vty_out (vty, " (history entry)"); |
| 5126 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5127 | vty_out (vty, " (suppressed due to dampening)"); |
| 5128 | } |
| 5129 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5130 | |
| 5131 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5132 | if (p->family == AF_INET) |
| 5133 | { |
| 5134 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
| 5135 | inet_ntoa (attr->mp_nexthop_global_in) : |
| 5136 | inet_ntoa (attr->nexthop)); |
| 5137 | } |
| 5138 | #ifdef HAVE_IPV6 |
| 5139 | else |
| 5140 | { |
| 5141 | vty_out (vty, " %s", |
| 5142 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, |
| 5143 | buf, INET6_ADDRSTRLEN)); |
| 5144 | } |
| 5145 | #endif /* HAVE_IPV6 */ |
| 5146 | |
| 5147 | if (binfo->peer == bgp->peer_self) |
| 5148 | { |
| 5149 | vty_out (vty, " from %s ", |
| 5150 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5151 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5152 | } |
| 5153 | else |
| 5154 | { |
| 5155 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5156 | vty_out (vty, " (inaccessible)"); |
| 5157 | else if (binfo->igpmetric) |
| 5158 | vty_out (vty, " (metric %d)", binfo->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5159 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5160 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5161 | vty_out (vty, " (%s)", inet_ntoa (attr->originator_id)); |
| 5162 | else |
| 5163 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5164 | } |
| 5165 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5166 | |
| 5167 | #ifdef HAVE_IPV6 |
| 5168 | /* display nexthop local */ |
| 5169 | if (attr->mp_nexthop_len == 32) |
| 5170 | { |
| 5171 | vty_out (vty, " (%s)%s", |
| 5172 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, |
| 5173 | buf, INET6_ADDRSTRLEN), |
| 5174 | VTY_NEWLINE); |
| 5175 | } |
| 5176 | #endif /* HAVE_IPV6 */ |
| 5177 | |
| 5178 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5179 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5180 | |
| 5181 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
| 5182 | vty_out (vty, ", metric %d", attr->med); |
| 5183 | |
| 5184 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
| 5185 | vty_out (vty, ", localpref %d", attr->local_pref); |
| 5186 | else |
| 5187 | vty_out (vty, ", localpref %d", bgp->default_local_pref); |
| 5188 | |
| 5189 | if (attr->weight != 0) |
| 5190 | vty_out (vty, ", weight %d", attr->weight); |
| 5191 | |
| 5192 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5193 | vty_out (vty, ", valid"); |
| 5194 | |
| 5195 | if (binfo->peer != bgp->peer_self) |
| 5196 | { |
| 5197 | if (binfo->peer->as == binfo->peer->local_as) |
| 5198 | vty_out (vty, ", internal"); |
| 5199 | else |
| 5200 | vty_out (vty, ", %s", |
| 5201 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 5202 | } |
| 5203 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 5204 | vty_out (vty, ", aggregated, local"); |
| 5205 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 5206 | vty_out (vty, ", sourced"); |
| 5207 | else |
| 5208 | vty_out (vty, ", sourced, local"); |
| 5209 | |
| 5210 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5211 | vty_out (vty, ", atomic-aggregate"); |
| 5212 | |
| 5213 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5214 | vty_out (vty, ", best"); |
| 5215 | |
| 5216 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5217 | |
| 5218 | /* Line 4 display Community */ |
| 5219 | if (attr->community) |
| 5220 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 5221 | VTY_NEWLINE); |
| 5222 | |
| 5223 | /* Line 5 display Extended-community */ |
| 5224 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
| 5225 | vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str, |
| 5226 | VTY_NEWLINE); |
| 5227 | |
| 5228 | /* Line 6 display Originator, Cluster-id */ |
| 5229 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 5230 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 5231 | { |
| 5232 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5233 | vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id)); |
| 5234 | |
| 5235 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 5236 | { |
| 5237 | int i; |
| 5238 | vty_out (vty, ", Cluster list: "); |
| 5239 | for (i = 0; i < attr->cluster->length / 4; i++) |
| 5240 | vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i])); |
| 5241 | } |
| 5242 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5243 | } |
| 5244 | |
| 5245 | if (binfo->damp_info) |
| 5246 | bgp_damp_info_vty (vty, binfo); |
| 5247 | |
| 5248 | /* Line 7 display Uptime */ |
| 5249 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); |
| 5250 | } |
| 5251 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5252 | } |
| 5253 | |
| 5254 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 5255 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 5256 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 5257 | |
| 5258 | enum bgp_show_type |
| 5259 | { |
| 5260 | bgp_show_type_normal, |
| 5261 | bgp_show_type_regexp, |
| 5262 | bgp_show_type_prefix_list, |
| 5263 | bgp_show_type_filter_list, |
| 5264 | bgp_show_type_route_map, |
| 5265 | bgp_show_type_neighbor, |
| 5266 | bgp_show_type_cidr_only, |
| 5267 | bgp_show_type_prefix_longer, |
| 5268 | bgp_show_type_community_all, |
| 5269 | bgp_show_type_community, |
| 5270 | bgp_show_type_community_exact, |
| 5271 | bgp_show_type_community_list, |
| 5272 | bgp_show_type_community_list_exact, |
| 5273 | bgp_show_type_flap_statistics, |
| 5274 | bgp_show_type_flap_address, |
| 5275 | bgp_show_type_flap_prefix, |
| 5276 | bgp_show_type_flap_cidr_only, |
| 5277 | bgp_show_type_flap_regexp, |
| 5278 | bgp_show_type_flap_filter_list, |
| 5279 | bgp_show_type_flap_prefix_list, |
| 5280 | bgp_show_type_flap_prefix_longer, |
| 5281 | bgp_show_type_flap_route_map, |
| 5282 | bgp_show_type_flap_neighbor, |
| 5283 | bgp_show_type_dampend_paths, |
| 5284 | bgp_show_type_damp_neighbor |
| 5285 | }; |
| 5286 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5287 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5288 | 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] | 5289 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5290 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5291 | struct bgp_info *ri; |
| 5292 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5293 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5294 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5295 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5296 | |
| 5297 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5298 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5299 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5300 | /* Start processing of routes. */ |
| 5301 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5302 | if (rn->info != NULL) |
| 5303 | { |
| 5304 | display = 0; |
| 5305 | |
| 5306 | for (ri = rn->info; ri; ri = ri->next) |
| 5307 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5308 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5309 | || type == bgp_show_type_flap_address |
| 5310 | || type == bgp_show_type_flap_prefix |
| 5311 | || type == bgp_show_type_flap_cidr_only |
| 5312 | || type == bgp_show_type_flap_regexp |
| 5313 | || type == bgp_show_type_flap_filter_list |
| 5314 | || type == bgp_show_type_flap_prefix_list |
| 5315 | || type == bgp_show_type_flap_prefix_longer |
| 5316 | || type == bgp_show_type_flap_route_map |
| 5317 | || type == bgp_show_type_flap_neighbor |
| 5318 | || type == bgp_show_type_dampend_paths |
| 5319 | || type == bgp_show_type_damp_neighbor) |
| 5320 | { |
| 5321 | if (! ri->damp_info) |
| 5322 | continue; |
| 5323 | } |
| 5324 | if (type == bgp_show_type_regexp |
| 5325 | || type == bgp_show_type_flap_regexp) |
| 5326 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5327 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5328 | |
| 5329 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 5330 | continue; |
| 5331 | } |
| 5332 | if (type == bgp_show_type_prefix_list |
| 5333 | || type == bgp_show_type_flap_prefix_list) |
| 5334 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5335 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5336 | |
| 5337 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 5338 | continue; |
| 5339 | } |
| 5340 | if (type == bgp_show_type_filter_list |
| 5341 | || type == bgp_show_type_flap_filter_list) |
| 5342 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5343 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5344 | |
| 5345 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 5346 | continue; |
| 5347 | } |
| 5348 | if (type == bgp_show_type_route_map |
| 5349 | || type == bgp_show_type_flap_route_map) |
| 5350 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5351 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5352 | struct bgp_info binfo; |
| 5353 | struct attr dummy_attr; |
| 5354 | int ret; |
| 5355 | |
| 5356 | dummy_attr = *ri->attr; |
| 5357 | binfo.peer = ri->peer; |
| 5358 | binfo.attr = &dummy_attr; |
| 5359 | |
| 5360 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 5361 | |
| 5362 | if (ret == RMAP_DENYMATCH) |
| 5363 | continue; |
| 5364 | } |
| 5365 | if (type == bgp_show_type_neighbor |
| 5366 | || type == bgp_show_type_flap_neighbor |
| 5367 | || type == bgp_show_type_damp_neighbor) |
| 5368 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5369 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5370 | |
| 5371 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 5372 | continue; |
| 5373 | } |
| 5374 | if (type == bgp_show_type_cidr_only |
| 5375 | || type == bgp_show_type_flap_cidr_only) |
| 5376 | { |
| 5377 | u_int32_t destination; |
| 5378 | |
| 5379 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 5380 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 5381 | continue; |
| 5382 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 5383 | continue; |
| 5384 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 5385 | continue; |
| 5386 | } |
| 5387 | if (type == bgp_show_type_prefix_longer |
| 5388 | || type == bgp_show_type_flap_prefix_longer) |
| 5389 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5390 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5391 | |
| 5392 | if (! prefix_match (p, &rn->p)) |
| 5393 | continue; |
| 5394 | } |
| 5395 | if (type == bgp_show_type_community_all) |
| 5396 | { |
| 5397 | if (! ri->attr->community) |
| 5398 | continue; |
| 5399 | } |
| 5400 | if (type == bgp_show_type_community) |
| 5401 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5402 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5403 | |
| 5404 | if (! ri->attr->community || |
| 5405 | ! community_match (ri->attr->community, com)) |
| 5406 | continue; |
| 5407 | } |
| 5408 | if (type == bgp_show_type_community_exact) |
| 5409 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5410 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5411 | |
| 5412 | if (! ri->attr->community || |
| 5413 | ! community_cmp (ri->attr->community, com)) |
| 5414 | continue; |
| 5415 | } |
| 5416 | if (type == bgp_show_type_community_list) |
| 5417 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5418 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5419 | |
| 5420 | if (! community_list_match (ri->attr->community, list)) |
| 5421 | continue; |
| 5422 | } |
| 5423 | if (type == bgp_show_type_community_list_exact) |
| 5424 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5425 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5426 | |
| 5427 | if (! community_list_exact_match (ri->attr->community, list)) |
| 5428 | continue; |
| 5429 | } |
| 5430 | if (type == bgp_show_type_flap_address |
| 5431 | || type == bgp_show_type_flap_prefix) |
| 5432 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5433 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5434 | |
| 5435 | if (! prefix_match (&rn->p, p)) |
| 5436 | continue; |
| 5437 | |
| 5438 | if (type == bgp_show_type_flap_prefix) |
| 5439 | if (p->prefixlen != rn->p.prefixlen) |
| 5440 | continue; |
| 5441 | } |
| 5442 | if (type == bgp_show_type_dampend_paths |
| 5443 | || type == bgp_show_type_damp_neighbor) |
| 5444 | { |
| 5445 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 5446 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 5447 | continue; |
| 5448 | } |
| 5449 | |
| 5450 | if (header) |
| 5451 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5452 | 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] | 5453 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 5454 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 5455 | if (type == bgp_show_type_dampend_paths |
| 5456 | || type == bgp_show_type_damp_neighbor) |
| 5457 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 5458 | else if (type == bgp_show_type_flap_statistics |
| 5459 | || type == bgp_show_type_flap_address |
| 5460 | || type == bgp_show_type_flap_prefix |
| 5461 | || type == bgp_show_type_flap_cidr_only |
| 5462 | || type == bgp_show_type_flap_regexp |
| 5463 | || type == bgp_show_type_flap_filter_list |
| 5464 | || type == bgp_show_type_flap_prefix_list |
| 5465 | || type == bgp_show_type_flap_prefix_longer |
| 5466 | || type == bgp_show_type_flap_route_map |
| 5467 | || type == bgp_show_type_flap_neighbor) |
| 5468 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 5469 | else |
| 5470 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5471 | header = 0; |
| 5472 | } |
| 5473 | |
| 5474 | if (type == bgp_show_type_dampend_paths |
| 5475 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5476 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5477 | else if (type == bgp_show_type_flap_statistics |
| 5478 | || type == bgp_show_type_flap_address |
| 5479 | || type == bgp_show_type_flap_prefix |
| 5480 | || type == bgp_show_type_flap_cidr_only |
| 5481 | || type == bgp_show_type_flap_regexp |
| 5482 | || type == bgp_show_type_flap_filter_list |
| 5483 | || type == bgp_show_type_flap_prefix_list |
| 5484 | || type == bgp_show_type_flap_prefix_longer |
| 5485 | || type == bgp_show_type_flap_route_map |
| 5486 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5487 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5488 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5489 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5490 | display++; |
| 5491 | } |
| 5492 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5493 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5494 | } |
| 5495 | |
| 5496 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5497 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5498 | { |
| 5499 | if (type == bgp_show_type_normal) |
| 5500 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 5501 | } |
| 5502 | else |
| 5503 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5504 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5505 | |
| 5506 | return CMD_SUCCESS; |
| 5507 | } |
| 5508 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5509 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5510 | 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] | 5511 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5512 | { |
| 5513 | struct bgp_table *table; |
| 5514 | |
| 5515 | if (bgp == NULL) { |
| 5516 | bgp = bgp_get_default (); |
| 5517 | } |
| 5518 | |
| 5519 | if (bgp == NULL) |
| 5520 | { |
| 5521 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5522 | return CMD_WARNING; |
| 5523 | } |
| 5524 | |
| 5525 | |
| 5526 | table = bgp->rib[afi][safi]; |
| 5527 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5528 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5529 | } |
| 5530 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5531 | /* Header of detailed BGP route information */ |
| 5532 | void |
| 5533 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 5534 | struct bgp_node *rn, |
| 5535 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 5536 | { |
| 5537 | struct bgp_info *ri; |
| 5538 | struct prefix *p; |
| 5539 | struct peer *peer; |
| 5540 | struct listnode *nn; |
| 5541 | char buf1[INET6_ADDRSTRLEN]; |
| 5542 | char buf2[INET6_ADDRSTRLEN]; |
| 5543 | int count = 0; |
| 5544 | int best = 0; |
| 5545 | int suppress = 0; |
| 5546 | int no_export = 0; |
| 5547 | int no_advertise = 0; |
| 5548 | int local_as = 0; |
| 5549 | int first = 0; |
| 5550 | |
| 5551 | p = &rn->p; |
| 5552 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 5553 | (safi == SAFI_MPLS_VPN ? |
| 5554 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 5555 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 5556 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 5557 | p->prefixlen, VTY_NEWLINE); |
| 5558 | |
| 5559 | for (ri = rn->info; ri; ri = ri->next) |
| 5560 | { |
| 5561 | count++; |
| 5562 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 5563 | { |
| 5564 | best = count; |
| 5565 | if (ri->suppress) |
| 5566 | suppress = 1; |
| 5567 | if (ri->attr->community != NULL) |
| 5568 | { |
| 5569 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 5570 | no_advertise = 1; |
| 5571 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 5572 | no_export = 1; |
| 5573 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 5574 | local_as = 1; |
| 5575 | } |
| 5576 | } |
| 5577 | } |
| 5578 | |
| 5579 | vty_out (vty, "Paths: (%d available", count); |
| 5580 | if (best) |
| 5581 | { |
| 5582 | vty_out (vty, ", best #%d", best); |
| 5583 | if (safi == SAFI_UNICAST) |
| 5584 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 5585 | } |
| 5586 | else |
| 5587 | vty_out (vty, ", no best path"); |
| 5588 | if (no_advertise) |
| 5589 | vty_out (vty, ", not advertised to any peer"); |
| 5590 | else if (no_export) |
| 5591 | vty_out (vty, ", not advertised to EBGP peer"); |
| 5592 | else if (local_as) |
| 5593 | vty_out (vty, ", not advertised outside local AS"); |
| 5594 | if (suppress) |
| 5595 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 5596 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 5597 | |
| 5598 | /* advertised peer */ |
| 5599 | LIST_LOOP (bgp->peer, peer, nn) |
| 5600 | { |
| 5601 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 5602 | { |
| 5603 | if (! first) |
| 5604 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 5605 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 5606 | first = 1; |
| 5607 | } |
| 5608 | } |
| 5609 | if (! first) |
| 5610 | vty_out (vty, " Not advertised to any peer"); |
| 5611 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5612 | } |
| 5613 | |
| 5614 | /* Display specified route of BGP table. */ |
| 5615 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5616 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5617 | struct bgp_table *rib, const char *ip_str, |
| 5618 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5619 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5620 | { |
| 5621 | int ret; |
| 5622 | int header; |
| 5623 | int display = 0; |
| 5624 | struct prefix match; |
| 5625 | struct bgp_node *rn; |
| 5626 | struct bgp_node *rm; |
| 5627 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5628 | struct bgp_table *table; |
| 5629 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5630 | /* Check IP address argument. */ |
| 5631 | ret = str2prefix (ip_str, &match); |
| 5632 | if (! ret) |
| 5633 | { |
| 5634 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 5635 | return CMD_WARNING; |
| 5636 | } |
| 5637 | |
| 5638 | match.family = afi2family (afi); |
| 5639 | |
| 5640 | if (safi == SAFI_MPLS_VPN) |
| 5641 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5642 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5643 | { |
| 5644 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 5645 | continue; |
| 5646 | |
| 5647 | if ((table = rn->info) != NULL) |
| 5648 | { |
| 5649 | header = 1; |
| 5650 | |
| 5651 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 5652 | { |
| 5653 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 5654 | continue; |
| 5655 | |
| 5656 | for (ri = rm->info; ri; ri = ri->next) |
| 5657 | { |
| 5658 | if (header) |
| 5659 | { |
| 5660 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 5661 | AFI_IP, SAFI_MPLS_VPN); |
| 5662 | |
| 5663 | header = 0; |
| 5664 | } |
| 5665 | display++; |
| 5666 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 5667 | } |
| 5668 | } |
| 5669 | } |
| 5670 | } |
| 5671 | } |
| 5672 | else |
| 5673 | { |
| 5674 | header = 1; |
| 5675 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5676 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5677 | { |
| 5678 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 5679 | { |
| 5680 | for (ri = rn->info; ri; ri = ri->next) |
| 5681 | { |
| 5682 | if (header) |
| 5683 | { |
| 5684 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 5685 | header = 0; |
| 5686 | } |
| 5687 | display++; |
| 5688 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 5689 | } |
| 5690 | } |
| 5691 | } |
| 5692 | } |
| 5693 | |
| 5694 | if (! display) |
| 5695 | { |
| 5696 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 5697 | return CMD_WARNING; |
| 5698 | } |
| 5699 | |
| 5700 | return CMD_SUCCESS; |
| 5701 | } |
| 5702 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5703 | /* Display specified route of Main RIB */ |
| 5704 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5705 | 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] | 5706 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5707 | int prefix_check) |
| 5708 | { |
| 5709 | struct bgp *bgp; |
| 5710 | |
| 5711 | /* BGP structure lookup. */ |
| 5712 | if (view_name) |
| 5713 | { |
| 5714 | bgp = bgp_lookup_by_name (view_name); |
| 5715 | if (bgp == NULL) |
| 5716 | { |
| 5717 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 5718 | return CMD_WARNING; |
| 5719 | } |
| 5720 | } |
| 5721 | else |
| 5722 | { |
| 5723 | bgp = bgp_get_default (); |
| 5724 | if (bgp == NULL) |
| 5725 | { |
| 5726 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5727 | return CMD_WARNING; |
| 5728 | } |
| 5729 | } |
| 5730 | |
| 5731 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 5732 | afi, safi, prd, prefix_check); |
| 5733 | } |
| 5734 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5735 | /* BGP route print out function. */ |
| 5736 | DEFUN (show_ip_bgp, |
| 5737 | show_ip_bgp_cmd, |
| 5738 | "show ip bgp", |
| 5739 | SHOW_STR |
| 5740 | IP_STR |
| 5741 | BGP_STR) |
| 5742 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5743 | 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] | 5744 | } |
| 5745 | |
| 5746 | DEFUN (show_ip_bgp_ipv4, |
| 5747 | show_ip_bgp_ipv4_cmd, |
| 5748 | "show ip bgp ipv4 (unicast|multicast)", |
| 5749 | SHOW_STR |
| 5750 | IP_STR |
| 5751 | BGP_STR |
| 5752 | "Address family\n" |
| 5753 | "Address Family modifier\n" |
| 5754 | "Address Family modifier\n") |
| 5755 | { |
| 5756 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5757 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 5758 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5759 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5760 | 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] | 5761 | } |
| 5762 | |
| 5763 | DEFUN (show_ip_bgp_route, |
| 5764 | show_ip_bgp_route_cmd, |
| 5765 | "show ip bgp A.B.C.D", |
| 5766 | SHOW_STR |
| 5767 | IP_STR |
| 5768 | BGP_STR |
| 5769 | "Network in the BGP routing table to display\n") |
| 5770 | { |
| 5771 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5772 | } |
| 5773 | |
| 5774 | DEFUN (show_ip_bgp_ipv4_route, |
| 5775 | show_ip_bgp_ipv4_route_cmd, |
| 5776 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 5777 | SHOW_STR |
| 5778 | IP_STR |
| 5779 | BGP_STR |
| 5780 | "Address family\n" |
| 5781 | "Address Family modifier\n" |
| 5782 | "Address Family modifier\n" |
| 5783 | "Network in the BGP routing table to display\n") |
| 5784 | { |
| 5785 | if (strncmp (argv[0], "m", 1) == 0) |
| 5786 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 5787 | |
| 5788 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5789 | } |
| 5790 | |
| 5791 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 5792 | show_ip_bgp_vpnv4_all_route_cmd, |
| 5793 | "show ip bgp vpnv4 all A.B.C.D", |
| 5794 | SHOW_STR |
| 5795 | IP_STR |
| 5796 | BGP_STR |
| 5797 | "Display VPNv4 NLRI specific information\n" |
| 5798 | "Display information about all VPNv4 NLRIs\n" |
| 5799 | "Network in the BGP routing table to display\n") |
| 5800 | { |
| 5801 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 5802 | } |
| 5803 | |
| 5804 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 5805 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 5806 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 5807 | SHOW_STR |
| 5808 | IP_STR |
| 5809 | BGP_STR |
| 5810 | "Display VPNv4 NLRI specific information\n" |
| 5811 | "Display information for a route distinguisher\n" |
| 5812 | "VPN Route Distinguisher\n" |
| 5813 | "Network in the BGP routing table to display\n") |
| 5814 | { |
| 5815 | int ret; |
| 5816 | struct prefix_rd prd; |
| 5817 | |
| 5818 | ret = str2prefix_rd (argv[0], &prd); |
| 5819 | if (! ret) |
| 5820 | { |
| 5821 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5822 | return CMD_WARNING; |
| 5823 | } |
| 5824 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 5825 | } |
| 5826 | |
| 5827 | DEFUN (show_ip_bgp_prefix, |
| 5828 | show_ip_bgp_prefix_cmd, |
| 5829 | "show ip bgp A.B.C.D/M", |
| 5830 | SHOW_STR |
| 5831 | IP_STR |
| 5832 | BGP_STR |
| 5833 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5834 | { |
| 5835 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5836 | } |
| 5837 | |
| 5838 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 5839 | show_ip_bgp_ipv4_prefix_cmd, |
| 5840 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 5841 | SHOW_STR |
| 5842 | IP_STR |
| 5843 | BGP_STR |
| 5844 | "Address family\n" |
| 5845 | "Address Family modifier\n" |
| 5846 | "Address Family modifier\n" |
| 5847 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5848 | { |
| 5849 | if (strncmp (argv[0], "m", 1) == 0) |
| 5850 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 5851 | |
| 5852 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5853 | } |
| 5854 | |
| 5855 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 5856 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 5857 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 5858 | SHOW_STR |
| 5859 | IP_STR |
| 5860 | BGP_STR |
| 5861 | "Display VPNv4 NLRI specific information\n" |
| 5862 | "Display information about all VPNv4 NLRIs\n" |
| 5863 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5864 | { |
| 5865 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 5866 | } |
| 5867 | |
| 5868 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 5869 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 5870 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 5871 | SHOW_STR |
| 5872 | IP_STR |
| 5873 | BGP_STR |
| 5874 | "Display VPNv4 NLRI specific information\n" |
| 5875 | "Display information for a route distinguisher\n" |
| 5876 | "VPN Route Distinguisher\n" |
| 5877 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5878 | { |
| 5879 | int ret; |
| 5880 | struct prefix_rd prd; |
| 5881 | |
| 5882 | ret = str2prefix_rd (argv[0], &prd); |
| 5883 | if (! ret) |
| 5884 | { |
| 5885 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5886 | return CMD_WARNING; |
| 5887 | } |
| 5888 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 5889 | } |
| 5890 | |
| 5891 | DEFUN (show_ip_bgp_view, |
| 5892 | show_ip_bgp_view_cmd, |
| 5893 | "show ip bgp view WORD", |
| 5894 | SHOW_STR |
| 5895 | IP_STR |
| 5896 | BGP_STR |
| 5897 | "BGP view\n" |
| 5898 | "BGP view name\n") |
| 5899 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 5900 | struct bgp *bgp; |
| 5901 | |
| 5902 | /* BGP structure lookup. */ |
| 5903 | bgp = bgp_lookup_by_name (argv[0]); |
| 5904 | if (bgp == NULL) |
| 5905 | { |
| 5906 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 5907 | return CMD_WARNING; |
| 5908 | } |
| 5909 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5910 | 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] | 5911 | } |
| 5912 | |
| 5913 | DEFUN (show_ip_bgp_view_route, |
| 5914 | show_ip_bgp_view_route_cmd, |
| 5915 | "show ip bgp view WORD A.B.C.D", |
| 5916 | SHOW_STR |
| 5917 | IP_STR |
| 5918 | BGP_STR |
| 5919 | "BGP view\n" |
| 5920 | "BGP view name\n" |
| 5921 | "Network in the BGP routing table to display\n") |
| 5922 | { |
| 5923 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5924 | } |
| 5925 | |
| 5926 | DEFUN (show_ip_bgp_view_prefix, |
| 5927 | show_ip_bgp_view_prefix_cmd, |
| 5928 | "show ip bgp view WORD A.B.C.D/M", |
| 5929 | SHOW_STR |
| 5930 | IP_STR |
| 5931 | BGP_STR |
| 5932 | "BGP view\n" |
| 5933 | "BGP view name\n" |
| 5934 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5935 | { |
| 5936 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5937 | } |
| 5938 | |
| 5939 | #ifdef HAVE_IPV6 |
| 5940 | DEFUN (show_bgp, |
| 5941 | show_bgp_cmd, |
| 5942 | "show bgp", |
| 5943 | SHOW_STR |
| 5944 | BGP_STR) |
| 5945 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5946 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 5947 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5948 | } |
| 5949 | |
| 5950 | ALIAS (show_bgp, |
| 5951 | show_bgp_ipv6_cmd, |
| 5952 | "show bgp ipv6", |
| 5953 | SHOW_STR |
| 5954 | BGP_STR |
| 5955 | "Address family\n") |
| 5956 | |
| 5957 | /* old command */ |
| 5958 | DEFUN (show_ipv6_bgp, |
| 5959 | show_ipv6_bgp_cmd, |
| 5960 | "show ipv6 bgp", |
| 5961 | SHOW_STR |
| 5962 | IP_STR |
| 5963 | BGP_STR) |
| 5964 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5965 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 5966 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5967 | } |
| 5968 | |
| 5969 | DEFUN (show_bgp_route, |
| 5970 | show_bgp_route_cmd, |
| 5971 | "show bgp X:X::X:X", |
| 5972 | SHOW_STR |
| 5973 | BGP_STR |
| 5974 | "Network in the BGP routing table to display\n") |
| 5975 | { |
| 5976 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5977 | } |
| 5978 | |
| 5979 | ALIAS (show_bgp_route, |
| 5980 | show_bgp_ipv6_route_cmd, |
| 5981 | "show bgp ipv6 X:X::X:X", |
| 5982 | SHOW_STR |
| 5983 | BGP_STR |
| 5984 | "Address family\n" |
| 5985 | "Network in the BGP routing table to display\n") |
| 5986 | |
| 5987 | /* old command */ |
| 5988 | DEFUN (show_ipv6_bgp_route, |
| 5989 | show_ipv6_bgp_route_cmd, |
| 5990 | "show ipv6 bgp X:X::X:X", |
| 5991 | SHOW_STR |
| 5992 | IP_STR |
| 5993 | BGP_STR |
| 5994 | "Network in the BGP routing table to display\n") |
| 5995 | { |
| 5996 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 5997 | } |
| 5998 | |
| 5999 | DEFUN (show_bgp_prefix, |
| 6000 | show_bgp_prefix_cmd, |
| 6001 | "show bgp X:X::X:X/M", |
| 6002 | SHOW_STR |
| 6003 | BGP_STR |
| 6004 | "IPv6 prefix <network>/<length>\n") |
| 6005 | { |
| 6006 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6007 | } |
| 6008 | |
| 6009 | ALIAS (show_bgp_prefix, |
| 6010 | show_bgp_ipv6_prefix_cmd, |
| 6011 | "show bgp ipv6 X:X::X:X/M", |
| 6012 | SHOW_STR |
| 6013 | BGP_STR |
| 6014 | "Address family\n" |
| 6015 | "IPv6 prefix <network>/<length>\n") |
| 6016 | |
| 6017 | /* old command */ |
| 6018 | DEFUN (show_ipv6_bgp_prefix, |
| 6019 | show_ipv6_bgp_prefix_cmd, |
| 6020 | "show ipv6 bgp X:X::X:X/M", |
| 6021 | SHOW_STR |
| 6022 | IP_STR |
| 6023 | BGP_STR |
| 6024 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6025 | { |
| 6026 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6027 | } |
| 6028 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6029 | DEFUN (show_bgp_view, |
| 6030 | show_bgp_view_cmd, |
| 6031 | "show bgp view WORD", |
| 6032 | SHOW_STR |
| 6033 | BGP_STR |
| 6034 | "BGP view\n" |
| 6035 | "View name\n") |
| 6036 | { |
| 6037 | struct bgp *bgp; |
| 6038 | |
| 6039 | /* BGP structure lookup. */ |
| 6040 | bgp = bgp_lookup_by_name (argv[0]); |
| 6041 | if (bgp == NULL) |
| 6042 | { |
| 6043 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6044 | return CMD_WARNING; |
| 6045 | } |
| 6046 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6047 | 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] | 6048 | } |
| 6049 | |
| 6050 | ALIAS (show_bgp_view, |
| 6051 | show_bgp_view_ipv6_cmd, |
| 6052 | "show bgp view WORD ipv6", |
| 6053 | SHOW_STR |
| 6054 | BGP_STR |
| 6055 | "BGP view\n" |
| 6056 | "View name\n" |
| 6057 | "Address family\n") |
| 6058 | |
| 6059 | DEFUN (show_bgp_view_route, |
| 6060 | show_bgp_view_route_cmd, |
| 6061 | "show bgp view WORD X:X::X:X", |
| 6062 | SHOW_STR |
| 6063 | BGP_STR |
| 6064 | "BGP view\n" |
| 6065 | "View name\n" |
| 6066 | "Network in the BGP routing table to display\n") |
| 6067 | { |
| 6068 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6069 | } |
| 6070 | |
| 6071 | ALIAS (show_bgp_view_route, |
| 6072 | show_bgp_view_ipv6_route_cmd, |
| 6073 | "show bgp view WORD ipv6 X:X::X:X", |
| 6074 | SHOW_STR |
| 6075 | BGP_STR |
| 6076 | "BGP view\n" |
| 6077 | "View name\n" |
| 6078 | "Address family\n" |
| 6079 | "Network in the BGP routing table to display\n") |
| 6080 | |
| 6081 | DEFUN (show_bgp_view_prefix, |
| 6082 | show_bgp_view_prefix_cmd, |
| 6083 | "show bgp view WORD X:X::X:X/M", |
| 6084 | SHOW_STR |
| 6085 | BGP_STR |
| 6086 | "BGP view\n" |
| 6087 | "View name\n" |
| 6088 | "IPv6 prefix <network>/<length>\n") |
| 6089 | { |
| 6090 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6091 | } |
| 6092 | |
| 6093 | ALIAS (show_bgp_view_prefix, |
| 6094 | show_bgp_view_ipv6_prefix_cmd, |
| 6095 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 6096 | SHOW_STR |
| 6097 | BGP_STR |
| 6098 | "BGP view\n" |
| 6099 | "View name\n" |
| 6100 | "Address family\n" |
| 6101 | "IPv6 prefix <network>/<length>\n") |
| 6102 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6103 | /* old command */ |
| 6104 | DEFUN (show_ipv6_mbgp, |
| 6105 | show_ipv6_mbgp_cmd, |
| 6106 | "show ipv6 mbgp", |
| 6107 | SHOW_STR |
| 6108 | IP_STR |
| 6109 | MBGP_STR) |
| 6110 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6111 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6112 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6113 | } |
| 6114 | |
| 6115 | /* old command */ |
| 6116 | DEFUN (show_ipv6_mbgp_route, |
| 6117 | show_ipv6_mbgp_route_cmd, |
| 6118 | "show ipv6 mbgp X:X::X:X", |
| 6119 | SHOW_STR |
| 6120 | IP_STR |
| 6121 | MBGP_STR |
| 6122 | "Network in the MBGP routing table to display\n") |
| 6123 | { |
| 6124 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6125 | } |
| 6126 | |
| 6127 | /* old command */ |
| 6128 | DEFUN (show_ipv6_mbgp_prefix, |
| 6129 | show_ipv6_mbgp_prefix_cmd, |
| 6130 | "show ipv6 mbgp X:X::X:X/M", |
| 6131 | SHOW_STR |
| 6132 | IP_STR |
| 6133 | MBGP_STR |
| 6134 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6135 | { |
| 6136 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6137 | } |
| 6138 | #endif |
| 6139 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6140 | |
| 6141 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6142 | 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] | 6143 | safi_t safi, enum bgp_show_type type) |
| 6144 | { |
| 6145 | int i; |
| 6146 | struct buffer *b; |
| 6147 | char *regstr; |
| 6148 | int first; |
| 6149 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6150 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6151 | |
| 6152 | first = 0; |
| 6153 | b = buffer_new (1024); |
| 6154 | for (i = 0; i < argc; i++) |
| 6155 | { |
| 6156 | if (first) |
| 6157 | buffer_putc (b, ' '); |
| 6158 | else |
| 6159 | { |
| 6160 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6161 | continue; |
| 6162 | first = 1; |
| 6163 | } |
| 6164 | |
| 6165 | buffer_putstr (b, argv[i]); |
| 6166 | } |
| 6167 | buffer_putc (b, '\0'); |
| 6168 | |
| 6169 | regstr = buffer_getstr (b); |
| 6170 | buffer_free (b); |
| 6171 | |
| 6172 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6173 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6174 | if (! regex) |
| 6175 | { |
| 6176 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 6177 | VTY_NEWLINE); |
| 6178 | return CMD_WARNING; |
| 6179 | } |
| 6180 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6181 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 6182 | bgp_regex_free (regex); |
| 6183 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6184 | } |
| 6185 | |
| 6186 | DEFUN (show_ip_bgp_regexp, |
| 6187 | show_ip_bgp_regexp_cmd, |
| 6188 | "show ip bgp regexp .LINE", |
| 6189 | SHOW_STR |
| 6190 | IP_STR |
| 6191 | BGP_STR |
| 6192 | "Display routes matching the AS path regular expression\n" |
| 6193 | "A regular-expression to match the BGP AS paths\n") |
| 6194 | { |
| 6195 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6196 | bgp_show_type_regexp); |
| 6197 | } |
| 6198 | |
| 6199 | DEFUN (show_ip_bgp_flap_regexp, |
| 6200 | show_ip_bgp_flap_regexp_cmd, |
| 6201 | "show ip bgp flap-statistics regexp .LINE", |
| 6202 | SHOW_STR |
| 6203 | IP_STR |
| 6204 | BGP_STR |
| 6205 | "Display flap statistics of routes\n" |
| 6206 | "Display routes matching the AS path regular expression\n" |
| 6207 | "A regular-expression to match the BGP AS paths\n") |
| 6208 | { |
| 6209 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6210 | bgp_show_type_flap_regexp); |
| 6211 | } |
| 6212 | |
| 6213 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 6214 | show_ip_bgp_ipv4_regexp_cmd, |
| 6215 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 6216 | SHOW_STR |
| 6217 | IP_STR |
| 6218 | BGP_STR |
| 6219 | "Address family\n" |
| 6220 | "Address Family modifier\n" |
| 6221 | "Address Family modifier\n" |
| 6222 | "Display routes matching the AS path regular expression\n" |
| 6223 | "A regular-expression to match the BGP AS paths\n") |
| 6224 | { |
| 6225 | if (strncmp (argv[0], "m", 1) == 0) |
| 6226 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 6227 | bgp_show_type_regexp); |
| 6228 | |
| 6229 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6230 | bgp_show_type_regexp); |
| 6231 | } |
| 6232 | |
| 6233 | #ifdef HAVE_IPV6 |
| 6234 | DEFUN (show_bgp_regexp, |
| 6235 | show_bgp_regexp_cmd, |
| 6236 | "show bgp regexp .LINE", |
| 6237 | SHOW_STR |
| 6238 | BGP_STR |
| 6239 | "Display routes matching the AS path regular expression\n" |
| 6240 | "A regular-expression to match the BGP AS paths\n") |
| 6241 | { |
| 6242 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6243 | bgp_show_type_regexp); |
| 6244 | } |
| 6245 | |
| 6246 | ALIAS (show_bgp_regexp, |
| 6247 | show_bgp_ipv6_regexp_cmd, |
| 6248 | "show bgp ipv6 regexp .LINE", |
| 6249 | SHOW_STR |
| 6250 | BGP_STR |
| 6251 | "Address family\n" |
| 6252 | "Display routes matching the AS path regular expression\n" |
| 6253 | "A regular-expression to match the BGP AS paths\n") |
| 6254 | |
| 6255 | /* old command */ |
| 6256 | DEFUN (show_ipv6_bgp_regexp, |
| 6257 | show_ipv6_bgp_regexp_cmd, |
| 6258 | "show ipv6 bgp regexp .LINE", |
| 6259 | SHOW_STR |
| 6260 | IP_STR |
| 6261 | BGP_STR |
| 6262 | "Display routes matching the AS path regular expression\n" |
| 6263 | "A regular-expression to match the BGP AS paths\n") |
| 6264 | { |
| 6265 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6266 | bgp_show_type_regexp); |
| 6267 | } |
| 6268 | |
| 6269 | /* old command */ |
| 6270 | DEFUN (show_ipv6_mbgp_regexp, |
| 6271 | show_ipv6_mbgp_regexp_cmd, |
| 6272 | "show ipv6 mbgp regexp .LINE", |
| 6273 | SHOW_STR |
| 6274 | IP_STR |
| 6275 | BGP_STR |
| 6276 | "Display routes matching the AS path regular expression\n" |
| 6277 | "A regular-expression to match the MBGP AS paths\n") |
| 6278 | { |
| 6279 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 6280 | bgp_show_type_regexp); |
| 6281 | } |
| 6282 | #endif /* HAVE_IPV6 */ |
| 6283 | |
| 6284 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6285 | 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] | 6286 | safi_t safi, enum bgp_show_type type) |
| 6287 | { |
| 6288 | struct prefix_list *plist; |
| 6289 | |
| 6290 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 6291 | if (plist == NULL) |
| 6292 | { |
| 6293 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 6294 | prefix_list_str, VTY_NEWLINE); |
| 6295 | return CMD_WARNING; |
| 6296 | } |
| 6297 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6298 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6299 | } |
| 6300 | |
| 6301 | DEFUN (show_ip_bgp_prefix_list, |
| 6302 | show_ip_bgp_prefix_list_cmd, |
| 6303 | "show ip bgp prefix-list WORD", |
| 6304 | SHOW_STR |
| 6305 | IP_STR |
| 6306 | BGP_STR |
| 6307 | "Display routes conforming to the prefix-list\n" |
| 6308 | "IP prefix-list name\n") |
| 6309 | { |
| 6310 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6311 | bgp_show_type_prefix_list); |
| 6312 | } |
| 6313 | |
| 6314 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 6315 | show_ip_bgp_flap_prefix_list_cmd, |
| 6316 | "show ip bgp flap-statistics prefix-list WORD", |
| 6317 | SHOW_STR |
| 6318 | IP_STR |
| 6319 | BGP_STR |
| 6320 | "Display flap statistics of routes\n" |
| 6321 | "Display routes conforming to the prefix-list\n" |
| 6322 | "IP prefix-list name\n") |
| 6323 | { |
| 6324 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6325 | bgp_show_type_flap_prefix_list); |
| 6326 | } |
| 6327 | |
| 6328 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 6329 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 6330 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 6331 | SHOW_STR |
| 6332 | IP_STR |
| 6333 | BGP_STR |
| 6334 | "Address family\n" |
| 6335 | "Address Family modifier\n" |
| 6336 | "Address Family modifier\n" |
| 6337 | "Display routes conforming to the prefix-list\n" |
| 6338 | "IP prefix-list name\n") |
| 6339 | { |
| 6340 | if (strncmp (argv[0], "m", 1) == 0) |
| 6341 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6342 | bgp_show_type_prefix_list); |
| 6343 | |
| 6344 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6345 | bgp_show_type_prefix_list); |
| 6346 | } |
| 6347 | |
| 6348 | #ifdef HAVE_IPV6 |
| 6349 | DEFUN (show_bgp_prefix_list, |
| 6350 | show_bgp_prefix_list_cmd, |
| 6351 | "show bgp prefix-list WORD", |
| 6352 | SHOW_STR |
| 6353 | BGP_STR |
| 6354 | "Display routes conforming to the prefix-list\n" |
| 6355 | "IPv6 prefix-list name\n") |
| 6356 | { |
| 6357 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6358 | bgp_show_type_prefix_list); |
| 6359 | } |
| 6360 | |
| 6361 | ALIAS (show_bgp_prefix_list, |
| 6362 | show_bgp_ipv6_prefix_list_cmd, |
| 6363 | "show bgp ipv6 prefix-list WORD", |
| 6364 | SHOW_STR |
| 6365 | BGP_STR |
| 6366 | "Address family\n" |
| 6367 | "Display routes conforming to the prefix-list\n" |
| 6368 | "IPv6 prefix-list name\n") |
| 6369 | |
| 6370 | /* old command */ |
| 6371 | DEFUN (show_ipv6_bgp_prefix_list, |
| 6372 | show_ipv6_bgp_prefix_list_cmd, |
| 6373 | "show ipv6 bgp prefix-list WORD", |
| 6374 | SHOW_STR |
| 6375 | IPV6_STR |
| 6376 | BGP_STR |
| 6377 | "Display routes matching the prefix-list\n" |
| 6378 | "IPv6 prefix-list name\n") |
| 6379 | { |
| 6380 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6381 | bgp_show_type_prefix_list); |
| 6382 | } |
| 6383 | |
| 6384 | /* old command */ |
| 6385 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 6386 | show_ipv6_mbgp_prefix_list_cmd, |
| 6387 | "show ipv6 mbgp prefix-list WORD", |
| 6388 | SHOW_STR |
| 6389 | IPV6_STR |
| 6390 | MBGP_STR |
| 6391 | "Display routes matching the prefix-list\n" |
| 6392 | "IPv6 prefix-list name\n") |
| 6393 | { |
| 6394 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6395 | bgp_show_type_prefix_list); |
| 6396 | } |
| 6397 | #endif /* HAVE_IPV6 */ |
| 6398 | |
| 6399 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6400 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6401 | safi_t safi, enum bgp_show_type type) |
| 6402 | { |
| 6403 | struct as_list *as_list; |
| 6404 | |
| 6405 | as_list = as_list_lookup (filter); |
| 6406 | if (as_list == NULL) |
| 6407 | { |
| 6408 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 6409 | return CMD_WARNING; |
| 6410 | } |
| 6411 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6412 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6413 | } |
| 6414 | |
| 6415 | DEFUN (show_ip_bgp_filter_list, |
| 6416 | show_ip_bgp_filter_list_cmd, |
| 6417 | "show ip bgp filter-list WORD", |
| 6418 | SHOW_STR |
| 6419 | IP_STR |
| 6420 | BGP_STR |
| 6421 | "Display routes conforming to the filter-list\n" |
| 6422 | "Regular expression access list name\n") |
| 6423 | { |
| 6424 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6425 | bgp_show_type_filter_list); |
| 6426 | } |
| 6427 | |
| 6428 | DEFUN (show_ip_bgp_flap_filter_list, |
| 6429 | show_ip_bgp_flap_filter_list_cmd, |
| 6430 | "show ip bgp flap-statistics filter-list WORD", |
| 6431 | SHOW_STR |
| 6432 | IP_STR |
| 6433 | BGP_STR |
| 6434 | "Display flap statistics of routes\n" |
| 6435 | "Display routes conforming to the filter-list\n" |
| 6436 | "Regular expression access list name\n") |
| 6437 | { |
| 6438 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6439 | bgp_show_type_flap_filter_list); |
| 6440 | } |
| 6441 | |
| 6442 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 6443 | show_ip_bgp_ipv4_filter_list_cmd, |
| 6444 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 6445 | SHOW_STR |
| 6446 | IP_STR |
| 6447 | BGP_STR |
| 6448 | "Address family\n" |
| 6449 | "Address Family modifier\n" |
| 6450 | "Address Family modifier\n" |
| 6451 | "Display routes conforming to the filter-list\n" |
| 6452 | "Regular expression access list name\n") |
| 6453 | { |
| 6454 | if (strncmp (argv[0], "m", 1) == 0) |
| 6455 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6456 | bgp_show_type_filter_list); |
| 6457 | |
| 6458 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6459 | bgp_show_type_filter_list); |
| 6460 | } |
| 6461 | |
| 6462 | #ifdef HAVE_IPV6 |
| 6463 | DEFUN (show_bgp_filter_list, |
| 6464 | show_bgp_filter_list_cmd, |
| 6465 | "show bgp filter-list WORD", |
| 6466 | SHOW_STR |
| 6467 | BGP_STR |
| 6468 | "Display routes conforming to the filter-list\n" |
| 6469 | "Regular expression access list name\n") |
| 6470 | { |
| 6471 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6472 | bgp_show_type_filter_list); |
| 6473 | } |
| 6474 | |
| 6475 | ALIAS (show_bgp_filter_list, |
| 6476 | show_bgp_ipv6_filter_list_cmd, |
| 6477 | "show bgp ipv6 filter-list WORD", |
| 6478 | SHOW_STR |
| 6479 | BGP_STR |
| 6480 | "Address family\n" |
| 6481 | "Display routes conforming to the filter-list\n" |
| 6482 | "Regular expression access list name\n") |
| 6483 | |
| 6484 | /* old command */ |
| 6485 | DEFUN (show_ipv6_bgp_filter_list, |
| 6486 | show_ipv6_bgp_filter_list_cmd, |
| 6487 | "show ipv6 bgp filter-list WORD", |
| 6488 | SHOW_STR |
| 6489 | IPV6_STR |
| 6490 | BGP_STR |
| 6491 | "Display routes conforming to the filter-list\n" |
| 6492 | "Regular expression access list name\n") |
| 6493 | { |
| 6494 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6495 | bgp_show_type_filter_list); |
| 6496 | } |
| 6497 | |
| 6498 | /* old command */ |
| 6499 | DEFUN (show_ipv6_mbgp_filter_list, |
| 6500 | show_ipv6_mbgp_filter_list_cmd, |
| 6501 | "show ipv6 mbgp filter-list WORD", |
| 6502 | SHOW_STR |
| 6503 | IPV6_STR |
| 6504 | MBGP_STR |
| 6505 | "Display routes conforming to the filter-list\n" |
| 6506 | "Regular expression access list name\n") |
| 6507 | { |
| 6508 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6509 | bgp_show_type_filter_list); |
| 6510 | } |
| 6511 | #endif /* HAVE_IPV6 */ |
| 6512 | |
| 6513 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6514 | 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] | 6515 | safi_t safi, enum bgp_show_type type) |
| 6516 | { |
| 6517 | struct route_map *rmap; |
| 6518 | |
| 6519 | rmap = route_map_lookup_by_name (rmap_str); |
| 6520 | if (! rmap) |
| 6521 | { |
| 6522 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 6523 | rmap_str, VTY_NEWLINE); |
| 6524 | return CMD_WARNING; |
| 6525 | } |
| 6526 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6527 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6528 | } |
| 6529 | |
| 6530 | DEFUN (show_ip_bgp_route_map, |
| 6531 | show_ip_bgp_route_map_cmd, |
| 6532 | "show ip bgp route-map WORD", |
| 6533 | SHOW_STR |
| 6534 | IP_STR |
| 6535 | BGP_STR |
| 6536 | "Display routes matching the route-map\n" |
| 6537 | "A route-map to match on\n") |
| 6538 | { |
| 6539 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6540 | bgp_show_type_route_map); |
| 6541 | } |
| 6542 | |
| 6543 | DEFUN (show_ip_bgp_flap_route_map, |
| 6544 | show_ip_bgp_flap_route_map_cmd, |
| 6545 | "show ip bgp flap-statistics route-map WORD", |
| 6546 | SHOW_STR |
| 6547 | IP_STR |
| 6548 | BGP_STR |
| 6549 | "Display flap statistics of routes\n" |
| 6550 | "Display routes matching the route-map\n" |
| 6551 | "A route-map to match on\n") |
| 6552 | { |
| 6553 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6554 | bgp_show_type_flap_route_map); |
| 6555 | } |
| 6556 | |
| 6557 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 6558 | show_ip_bgp_ipv4_route_map_cmd, |
| 6559 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 6560 | SHOW_STR |
| 6561 | IP_STR |
| 6562 | BGP_STR |
| 6563 | "Address family\n" |
| 6564 | "Address Family modifier\n" |
| 6565 | "Address Family modifier\n" |
| 6566 | "Display routes matching the route-map\n" |
| 6567 | "A route-map to match on\n") |
| 6568 | { |
| 6569 | if (strncmp (argv[0], "m", 1) == 0) |
| 6570 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6571 | bgp_show_type_route_map); |
| 6572 | |
| 6573 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6574 | bgp_show_type_route_map); |
| 6575 | } |
| 6576 | |
| 6577 | DEFUN (show_bgp_route_map, |
| 6578 | show_bgp_route_map_cmd, |
| 6579 | "show bgp route-map WORD", |
| 6580 | SHOW_STR |
| 6581 | BGP_STR |
| 6582 | "Display routes matching the route-map\n" |
| 6583 | "A route-map to match on\n") |
| 6584 | { |
| 6585 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6586 | bgp_show_type_route_map); |
| 6587 | } |
| 6588 | |
| 6589 | ALIAS (show_bgp_route_map, |
| 6590 | show_bgp_ipv6_route_map_cmd, |
| 6591 | "show bgp ipv6 route-map WORD", |
| 6592 | SHOW_STR |
| 6593 | BGP_STR |
| 6594 | "Address family\n" |
| 6595 | "Display routes matching the route-map\n" |
| 6596 | "A route-map to match on\n") |
| 6597 | |
| 6598 | DEFUN (show_ip_bgp_cidr_only, |
| 6599 | show_ip_bgp_cidr_only_cmd, |
| 6600 | "show ip bgp cidr-only", |
| 6601 | SHOW_STR |
| 6602 | IP_STR |
| 6603 | BGP_STR |
| 6604 | "Display only routes with non-natural netmasks\n") |
| 6605 | { |
| 6606 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6607 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6608 | } |
| 6609 | |
| 6610 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 6611 | show_ip_bgp_flap_cidr_only_cmd, |
| 6612 | "show ip bgp flap-statistics cidr-only", |
| 6613 | SHOW_STR |
| 6614 | IP_STR |
| 6615 | BGP_STR |
| 6616 | "Display flap statistics of routes\n" |
| 6617 | "Display only routes with non-natural netmasks\n") |
| 6618 | { |
| 6619 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6620 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6621 | } |
| 6622 | |
| 6623 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 6624 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 6625 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 6626 | SHOW_STR |
| 6627 | IP_STR |
| 6628 | BGP_STR |
| 6629 | "Address family\n" |
| 6630 | "Address Family modifier\n" |
| 6631 | "Address Family modifier\n" |
| 6632 | "Display only routes with non-natural netmasks\n") |
| 6633 | { |
| 6634 | if (strncmp (argv[0], "m", 1) == 0) |
| 6635 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6636 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6637 | |
| 6638 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6639 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6640 | } |
| 6641 | |
| 6642 | DEFUN (show_ip_bgp_community_all, |
| 6643 | show_ip_bgp_community_all_cmd, |
| 6644 | "show ip bgp community", |
| 6645 | SHOW_STR |
| 6646 | IP_STR |
| 6647 | BGP_STR |
| 6648 | "Display routes matching the communities\n") |
| 6649 | { |
| 6650 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6651 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6652 | } |
| 6653 | |
| 6654 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 6655 | show_ip_bgp_ipv4_community_all_cmd, |
| 6656 | "show ip bgp ipv4 (unicast|multicast) community", |
| 6657 | SHOW_STR |
| 6658 | IP_STR |
| 6659 | BGP_STR |
| 6660 | "Address family\n" |
| 6661 | "Address Family modifier\n" |
| 6662 | "Address Family modifier\n" |
| 6663 | "Display routes matching the communities\n") |
| 6664 | { |
| 6665 | if (strncmp (argv[0], "m", 1) == 0) |
| 6666 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6667 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6668 | |
| 6669 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6670 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6671 | } |
| 6672 | |
| 6673 | #ifdef HAVE_IPV6 |
| 6674 | DEFUN (show_bgp_community_all, |
| 6675 | show_bgp_community_all_cmd, |
| 6676 | "show bgp community", |
| 6677 | SHOW_STR |
| 6678 | BGP_STR |
| 6679 | "Display routes matching the communities\n") |
| 6680 | { |
| 6681 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
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 | |
| 6685 | ALIAS (show_bgp_community_all, |
| 6686 | show_bgp_ipv6_community_all_cmd, |
| 6687 | "show bgp ipv6 community", |
| 6688 | SHOW_STR |
| 6689 | BGP_STR |
| 6690 | "Address family\n" |
| 6691 | "Display routes matching the communities\n") |
| 6692 | |
| 6693 | /* old command */ |
| 6694 | DEFUN (show_ipv6_bgp_community_all, |
| 6695 | show_ipv6_bgp_community_all_cmd, |
| 6696 | "show ipv6 bgp community", |
| 6697 | SHOW_STR |
| 6698 | IPV6_STR |
| 6699 | BGP_STR |
| 6700 | "Display routes matching the communities\n") |
| 6701 | { |
| 6702 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6703 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6704 | } |
| 6705 | |
| 6706 | /* old command */ |
| 6707 | DEFUN (show_ipv6_mbgp_community_all, |
| 6708 | show_ipv6_mbgp_community_all_cmd, |
| 6709 | "show ipv6 mbgp community", |
| 6710 | SHOW_STR |
| 6711 | IPV6_STR |
| 6712 | MBGP_STR |
| 6713 | "Display routes matching the communities\n") |
| 6714 | { |
| 6715 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6716 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6717 | } |
| 6718 | #endif /* HAVE_IPV6 */ |
| 6719 | |
| 6720 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6721 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
| 6722 | u_int16_t afi, u_char safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6723 | { |
| 6724 | struct community *com; |
| 6725 | struct buffer *b; |
| 6726 | int i; |
| 6727 | char *str; |
| 6728 | int first = 0; |
| 6729 | |
| 6730 | b = buffer_new (1024); |
| 6731 | for (i = 0; i < argc; i++) |
| 6732 | { |
| 6733 | if (first) |
| 6734 | buffer_putc (b, ' '); |
| 6735 | else |
| 6736 | { |
| 6737 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6738 | continue; |
| 6739 | first = 1; |
| 6740 | } |
| 6741 | |
| 6742 | buffer_putstr (b, argv[i]); |
| 6743 | } |
| 6744 | buffer_putc (b, '\0'); |
| 6745 | |
| 6746 | str = buffer_getstr (b); |
| 6747 | buffer_free (b); |
| 6748 | |
| 6749 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6750 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6751 | if (! com) |
| 6752 | { |
| 6753 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 6754 | return CMD_WARNING; |
| 6755 | } |
| 6756 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6757 | return bgp_show (vty, NULL, afi, safi, |
| 6758 | (exact ? bgp_show_type_community_exact : |
| 6759 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6760 | } |
| 6761 | |
| 6762 | DEFUN (show_ip_bgp_community, |
| 6763 | show_ip_bgp_community_cmd, |
| 6764 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6765 | SHOW_STR |
| 6766 | IP_STR |
| 6767 | BGP_STR |
| 6768 | "Display routes matching the communities\n" |
| 6769 | "community number\n" |
| 6770 | "Do not send outside local AS (well-known community)\n" |
| 6771 | "Do not advertise to any peer (well-known community)\n" |
| 6772 | "Do not export to next AS (well-known community)\n") |
| 6773 | { |
| 6774 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6775 | } |
| 6776 | |
| 6777 | ALIAS (show_ip_bgp_community, |
| 6778 | show_ip_bgp_community2_cmd, |
| 6779 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6780 | SHOW_STR |
| 6781 | IP_STR |
| 6782 | BGP_STR |
| 6783 | "Display routes matching the communities\n" |
| 6784 | "community number\n" |
| 6785 | "Do not send outside local AS (well-known community)\n" |
| 6786 | "Do not advertise to any peer (well-known community)\n" |
| 6787 | "Do not export to next AS (well-known community)\n" |
| 6788 | "community number\n" |
| 6789 | "Do not send outside local AS (well-known community)\n" |
| 6790 | "Do not advertise to any peer (well-known community)\n" |
| 6791 | "Do not export to next AS (well-known community)\n") |
| 6792 | |
| 6793 | ALIAS (show_ip_bgp_community, |
| 6794 | show_ip_bgp_community3_cmd, |
| 6795 | "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)", |
| 6796 | SHOW_STR |
| 6797 | IP_STR |
| 6798 | BGP_STR |
| 6799 | "Display routes matching the communities\n" |
| 6800 | "community number\n" |
| 6801 | "Do not send outside local AS (well-known community)\n" |
| 6802 | "Do not advertise to any peer (well-known community)\n" |
| 6803 | "Do not export to next AS (well-known community)\n" |
| 6804 | "community number\n" |
| 6805 | "Do not send outside local AS (well-known community)\n" |
| 6806 | "Do not advertise to any peer (well-known community)\n" |
| 6807 | "Do not export to next AS (well-known community)\n" |
| 6808 | "community number\n" |
| 6809 | "Do not send outside local AS (well-known community)\n" |
| 6810 | "Do not advertise to any peer (well-known community)\n" |
| 6811 | "Do not export to next AS (well-known community)\n") |
| 6812 | |
| 6813 | ALIAS (show_ip_bgp_community, |
| 6814 | show_ip_bgp_community4_cmd, |
| 6815 | "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)", |
| 6816 | SHOW_STR |
| 6817 | IP_STR |
| 6818 | BGP_STR |
| 6819 | "Display routes matching the communities\n" |
| 6820 | "community number\n" |
| 6821 | "Do not send outside local AS (well-known community)\n" |
| 6822 | "Do not advertise to any peer (well-known community)\n" |
| 6823 | "Do not export to next AS (well-known community)\n" |
| 6824 | "community number\n" |
| 6825 | "Do not send outside local AS (well-known community)\n" |
| 6826 | "Do not advertise to any peer (well-known community)\n" |
| 6827 | "Do not export to next AS (well-known community)\n" |
| 6828 | "community number\n" |
| 6829 | "Do not send outside local AS (well-known community)\n" |
| 6830 | "Do not advertise to any peer (well-known community)\n" |
| 6831 | "Do not export to next AS (well-known community)\n" |
| 6832 | "community number\n" |
| 6833 | "Do not send outside local AS (well-known community)\n" |
| 6834 | "Do not advertise to any peer (well-known community)\n" |
| 6835 | "Do not export to next AS (well-known community)\n") |
| 6836 | |
| 6837 | DEFUN (show_ip_bgp_ipv4_community, |
| 6838 | show_ip_bgp_ipv4_community_cmd, |
| 6839 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 6840 | SHOW_STR |
| 6841 | IP_STR |
| 6842 | BGP_STR |
| 6843 | "Address family\n" |
| 6844 | "Address Family modifier\n" |
| 6845 | "Address Family modifier\n" |
| 6846 | "Display routes matching the communities\n" |
| 6847 | "community number\n" |
| 6848 | "Do not send outside local AS (well-known community)\n" |
| 6849 | "Do not advertise to any peer (well-known community)\n" |
| 6850 | "Do not export to next AS (well-known community)\n") |
| 6851 | { |
| 6852 | if (strncmp (argv[0], "m", 1) == 0) |
| 6853 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 6854 | |
| 6855 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6856 | } |
| 6857 | |
| 6858 | ALIAS (show_ip_bgp_ipv4_community, |
| 6859 | show_ip_bgp_ipv4_community2_cmd, |
| 6860 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6861 | SHOW_STR |
| 6862 | IP_STR |
| 6863 | BGP_STR |
| 6864 | "Address family\n" |
| 6865 | "Address Family modifier\n" |
| 6866 | "Address Family modifier\n" |
| 6867 | "Display routes matching the communities\n" |
| 6868 | "community number\n" |
| 6869 | "Do not send outside local AS (well-known community)\n" |
| 6870 | "Do not advertise to any peer (well-known community)\n" |
| 6871 | "Do not export to next AS (well-known community)\n" |
| 6872 | "community number\n" |
| 6873 | "Do not send outside local AS (well-known community)\n" |
| 6874 | "Do not advertise to any peer (well-known community)\n" |
| 6875 | "Do not export to next AS (well-known community)\n") |
| 6876 | |
| 6877 | ALIAS (show_ip_bgp_ipv4_community, |
| 6878 | show_ip_bgp_ipv4_community3_cmd, |
| 6879 | "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)", |
| 6880 | SHOW_STR |
| 6881 | IP_STR |
| 6882 | BGP_STR |
| 6883 | "Address family\n" |
| 6884 | "Address Family modifier\n" |
| 6885 | "Address Family modifier\n" |
| 6886 | "Display routes matching the communities\n" |
| 6887 | "community number\n" |
| 6888 | "Do not send outside local AS (well-known community)\n" |
| 6889 | "Do not advertise to any peer (well-known community)\n" |
| 6890 | "Do not export to next AS (well-known community)\n" |
| 6891 | "community number\n" |
| 6892 | "Do not send outside local AS (well-known community)\n" |
| 6893 | "Do not advertise to any peer (well-known community)\n" |
| 6894 | "Do not export to next AS (well-known community)\n" |
| 6895 | "community number\n" |
| 6896 | "Do not send outside local AS (well-known community)\n" |
| 6897 | "Do not advertise to any peer (well-known community)\n" |
| 6898 | "Do not export to next AS (well-known community)\n") |
| 6899 | |
| 6900 | ALIAS (show_ip_bgp_ipv4_community, |
| 6901 | show_ip_bgp_ipv4_community4_cmd, |
| 6902 | "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)", |
| 6903 | SHOW_STR |
| 6904 | IP_STR |
| 6905 | BGP_STR |
| 6906 | "Address family\n" |
| 6907 | "Address Family modifier\n" |
| 6908 | "Address Family modifier\n" |
| 6909 | "Display routes matching the communities\n" |
| 6910 | "community number\n" |
| 6911 | "Do not send outside local AS (well-known community)\n" |
| 6912 | "Do not advertise to any peer (well-known community)\n" |
| 6913 | "Do not export to next AS (well-known community)\n" |
| 6914 | "community number\n" |
| 6915 | "Do not send outside local AS (well-known community)\n" |
| 6916 | "Do not advertise to any peer (well-known community)\n" |
| 6917 | "Do not export to next AS (well-known community)\n" |
| 6918 | "community number\n" |
| 6919 | "Do not send outside local AS (well-known community)\n" |
| 6920 | "Do not advertise to any peer (well-known community)\n" |
| 6921 | "Do not export to next AS (well-known community)\n" |
| 6922 | "community number\n" |
| 6923 | "Do not send outside local AS (well-known community)\n" |
| 6924 | "Do not advertise to any peer (well-known community)\n" |
| 6925 | "Do not export to next AS (well-known community)\n") |
| 6926 | |
| 6927 | DEFUN (show_ip_bgp_community_exact, |
| 6928 | show_ip_bgp_community_exact_cmd, |
| 6929 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6930 | SHOW_STR |
| 6931 | IP_STR |
| 6932 | BGP_STR |
| 6933 | "Display routes matching the communities\n" |
| 6934 | "community number\n" |
| 6935 | "Do not send outside local AS (well-known community)\n" |
| 6936 | "Do not advertise to any peer (well-known community)\n" |
| 6937 | "Do not export to next AS (well-known community)\n" |
| 6938 | "Exact match of the communities") |
| 6939 | { |
| 6940 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 6941 | } |
| 6942 | |
| 6943 | ALIAS (show_ip_bgp_community_exact, |
| 6944 | show_ip_bgp_community2_exact_cmd, |
| 6945 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6946 | SHOW_STR |
| 6947 | IP_STR |
| 6948 | BGP_STR |
| 6949 | "Display routes matching the communities\n" |
| 6950 | "community number\n" |
| 6951 | "Do not send outside local AS (well-known community)\n" |
| 6952 | "Do not advertise to any peer (well-known community)\n" |
| 6953 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 6959 | |
| 6960 | ALIAS (show_ip_bgp_community_exact, |
| 6961 | show_ip_bgp_community3_exact_cmd, |
| 6962 | "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", |
| 6963 | SHOW_STR |
| 6964 | IP_STR |
| 6965 | BGP_STR |
| 6966 | "Display routes matching the communities\n" |
| 6967 | "community number\n" |
| 6968 | "Do not send outside local AS (well-known community)\n" |
| 6969 | "Do not advertise to any peer (well-known community)\n" |
| 6970 | "Do not export to next AS (well-known community)\n" |
| 6971 | "community number\n" |
| 6972 | "Do not send outside local AS (well-known community)\n" |
| 6973 | "Do not advertise to any peer (well-known community)\n" |
| 6974 | "Do not export to next AS (well-known community)\n" |
| 6975 | "community number\n" |
| 6976 | "Do not send outside local AS (well-known community)\n" |
| 6977 | "Do not advertise to any peer (well-known community)\n" |
| 6978 | "Do not export to next AS (well-known community)\n" |
| 6979 | "Exact match of the communities") |
| 6980 | |
| 6981 | ALIAS (show_ip_bgp_community_exact, |
| 6982 | show_ip_bgp_community4_exact_cmd, |
| 6983 | "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", |
| 6984 | SHOW_STR |
| 6985 | IP_STR |
| 6986 | BGP_STR |
| 6987 | "Display routes matching the communities\n" |
| 6988 | "community number\n" |
| 6989 | "Do not send outside local AS (well-known community)\n" |
| 6990 | "Do not advertise to any peer (well-known community)\n" |
| 6991 | "Do not export to next AS (well-known community)\n" |
| 6992 | "community number\n" |
| 6993 | "Do not send outside local AS (well-known community)\n" |
| 6994 | "Do not advertise to any peer (well-known community)\n" |
| 6995 | "Do not export to next AS (well-known community)\n" |
| 6996 | "community number\n" |
| 6997 | "Do not send outside local AS (well-known community)\n" |
| 6998 | "Do not advertise to any peer (well-known community)\n" |
| 6999 | "Do not export to next AS (well-known community)\n" |
| 7000 | "community number\n" |
| 7001 | "Do not send outside local AS (well-known community)\n" |
| 7002 | "Do not advertise to any peer (well-known community)\n" |
| 7003 | "Do not export to next AS (well-known community)\n" |
| 7004 | "Exact match of the communities") |
| 7005 | |
| 7006 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 7007 | show_ip_bgp_ipv4_community_exact_cmd, |
| 7008 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7009 | SHOW_STR |
| 7010 | IP_STR |
| 7011 | BGP_STR |
| 7012 | "Address family\n" |
| 7013 | "Address Family modifier\n" |
| 7014 | "Address Family modifier\n" |
| 7015 | "Display routes matching the communities\n" |
| 7016 | "community number\n" |
| 7017 | "Do not send outside local AS (well-known community)\n" |
| 7018 | "Do not advertise to any peer (well-known community)\n" |
| 7019 | "Do not export to next AS (well-known community)\n" |
| 7020 | "Exact match of the communities") |
| 7021 | { |
| 7022 | if (strncmp (argv[0], "m", 1) == 0) |
| 7023 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 7024 | |
| 7025 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7026 | } |
| 7027 | |
| 7028 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7029 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 7030 | "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", |
| 7031 | SHOW_STR |
| 7032 | IP_STR |
| 7033 | BGP_STR |
| 7034 | "Address family\n" |
| 7035 | "Address Family modifier\n" |
| 7036 | "Address Family modifier\n" |
| 7037 | "Display routes matching the communities\n" |
| 7038 | "community number\n" |
| 7039 | "Do not send outside local AS (well-known community)\n" |
| 7040 | "Do not advertise to any peer (well-known community)\n" |
| 7041 | "Do not export to next AS (well-known community)\n" |
| 7042 | "community number\n" |
| 7043 | "Do not send outside local AS (well-known community)\n" |
| 7044 | "Do not advertise to any peer (well-known community)\n" |
| 7045 | "Do not export to next AS (well-known community)\n" |
| 7046 | "Exact match of the communities") |
| 7047 | |
| 7048 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7049 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 7050 | "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", |
| 7051 | SHOW_STR |
| 7052 | IP_STR |
| 7053 | BGP_STR |
| 7054 | "Address family\n" |
| 7055 | "Address Family modifier\n" |
| 7056 | "Address Family modifier\n" |
| 7057 | "Display routes matching the communities\n" |
| 7058 | "community number\n" |
| 7059 | "Do not send outside local AS (well-known community)\n" |
| 7060 | "Do not advertise to any peer (well-known community)\n" |
| 7061 | "Do not export to next AS (well-known community)\n" |
| 7062 | "community number\n" |
| 7063 | "Do not send outside local AS (well-known community)\n" |
| 7064 | "Do not advertise to any peer (well-known community)\n" |
| 7065 | "Do not export to next AS (well-known community)\n" |
| 7066 | "community number\n" |
| 7067 | "Do not send outside local AS (well-known community)\n" |
| 7068 | "Do not advertise to any peer (well-known community)\n" |
| 7069 | "Do not export to next AS (well-known community)\n" |
| 7070 | "Exact match of the communities") |
| 7071 | |
| 7072 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7073 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 7074 | "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", |
| 7075 | SHOW_STR |
| 7076 | IP_STR |
| 7077 | BGP_STR |
| 7078 | "Address family\n" |
| 7079 | "Address Family modifier\n" |
| 7080 | "Address Family modifier\n" |
| 7081 | "Display routes matching the communities\n" |
| 7082 | "community number\n" |
| 7083 | "Do not send outside local AS (well-known community)\n" |
| 7084 | "Do not advertise to any peer (well-known community)\n" |
| 7085 | "Do not export to next AS (well-known community)\n" |
| 7086 | "community number\n" |
| 7087 | "Do not send outside local AS (well-known community)\n" |
| 7088 | "Do not advertise to any peer (well-known community)\n" |
| 7089 | "Do not export to next AS (well-known community)\n" |
| 7090 | "community number\n" |
| 7091 | "Do not send outside local AS (well-known community)\n" |
| 7092 | "Do not advertise to any peer (well-known community)\n" |
| 7093 | "Do not export to next AS (well-known community)\n" |
| 7094 | "community number\n" |
| 7095 | "Do not send outside local AS (well-known community)\n" |
| 7096 | "Do not advertise to any peer (well-known community)\n" |
| 7097 | "Do not export to next AS (well-known community)\n" |
| 7098 | "Exact match of the communities") |
| 7099 | |
| 7100 | #ifdef HAVE_IPV6 |
| 7101 | DEFUN (show_bgp_community, |
| 7102 | show_bgp_community_cmd, |
| 7103 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7104 | SHOW_STR |
| 7105 | BGP_STR |
| 7106 | "Display routes matching the communities\n" |
| 7107 | "community number\n" |
| 7108 | "Do not send outside local AS (well-known community)\n" |
| 7109 | "Do not advertise to any peer (well-known community)\n" |
| 7110 | "Do not export to next AS (well-known community)\n") |
| 7111 | { |
| 7112 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7113 | } |
| 7114 | |
| 7115 | ALIAS (show_bgp_community, |
| 7116 | show_bgp_ipv6_community_cmd, |
| 7117 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 7118 | SHOW_STR |
| 7119 | BGP_STR |
| 7120 | "Address family\n" |
| 7121 | "Display routes matching the communities\n" |
| 7122 | "community number\n" |
| 7123 | "Do not send outside local AS (well-known community)\n" |
| 7124 | "Do not advertise to any peer (well-known community)\n" |
| 7125 | "Do not export to next AS (well-known community)\n") |
| 7126 | |
| 7127 | ALIAS (show_bgp_community, |
| 7128 | show_bgp_community2_cmd, |
| 7129 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7130 | SHOW_STR |
| 7131 | BGP_STR |
| 7132 | "Display routes matching the communities\n" |
| 7133 | "community number\n" |
| 7134 | "Do not send outside local AS (well-known community)\n" |
| 7135 | "Do not advertise to any peer (well-known community)\n" |
| 7136 | "Do not export to next AS (well-known community)\n" |
| 7137 | "community number\n" |
| 7138 | "Do not send outside local AS (well-known community)\n" |
| 7139 | "Do not advertise to any peer (well-known community)\n" |
| 7140 | "Do not export to next AS (well-known community)\n") |
| 7141 | |
| 7142 | ALIAS (show_bgp_community, |
| 7143 | show_bgp_ipv6_community2_cmd, |
| 7144 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7145 | SHOW_STR |
| 7146 | BGP_STR |
| 7147 | "Address family\n" |
| 7148 | "Display routes matching the communities\n" |
| 7149 | "community number\n" |
| 7150 | "Do not send outside local AS (well-known community)\n" |
| 7151 | "Do not advertise to any peer (well-known community)\n" |
| 7152 | "Do not export to next AS (well-known community)\n" |
| 7153 | "community number\n" |
| 7154 | "Do not send outside local AS (well-known community)\n" |
| 7155 | "Do not advertise to any peer (well-known community)\n" |
| 7156 | "Do not export to next AS (well-known community)\n") |
| 7157 | |
| 7158 | ALIAS (show_bgp_community, |
| 7159 | show_bgp_community3_cmd, |
| 7160 | "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)", |
| 7161 | SHOW_STR |
| 7162 | BGP_STR |
| 7163 | "Display routes matching the communities\n" |
| 7164 | "community number\n" |
| 7165 | "Do not send outside local AS (well-known community)\n" |
| 7166 | "Do not advertise to any peer (well-known community)\n" |
| 7167 | "Do not export to next AS (well-known community)\n" |
| 7168 | "community number\n" |
| 7169 | "Do not send outside local AS (well-known community)\n" |
| 7170 | "Do not advertise to any peer (well-known community)\n" |
| 7171 | "Do not export to next AS (well-known community)\n" |
| 7172 | "community number\n" |
| 7173 | "Do not send outside local AS (well-known community)\n" |
| 7174 | "Do not advertise to any peer (well-known community)\n" |
| 7175 | "Do not export to next AS (well-known community)\n") |
| 7176 | |
| 7177 | ALIAS (show_bgp_community, |
| 7178 | show_bgp_ipv6_community3_cmd, |
| 7179 | "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)", |
| 7180 | SHOW_STR |
| 7181 | BGP_STR |
| 7182 | "Address family\n" |
| 7183 | "Display routes matching the communities\n" |
| 7184 | "community number\n" |
| 7185 | "Do not send outside local AS (well-known community)\n" |
| 7186 | "Do not advertise to any peer (well-known community)\n" |
| 7187 | "Do not export to next AS (well-known community)\n" |
| 7188 | "community number\n" |
| 7189 | "Do not send outside local AS (well-known community)\n" |
| 7190 | "Do not advertise to any peer (well-known community)\n" |
| 7191 | "Do not export to next AS (well-known community)\n" |
| 7192 | "community number\n" |
| 7193 | "Do not send outside local AS (well-known community)\n" |
| 7194 | "Do not advertise to any peer (well-known community)\n" |
| 7195 | "Do not export to next AS (well-known community)\n") |
| 7196 | |
| 7197 | ALIAS (show_bgp_community, |
| 7198 | show_bgp_community4_cmd, |
| 7199 | "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)", |
| 7200 | SHOW_STR |
| 7201 | BGP_STR |
| 7202 | "Display routes matching the communities\n" |
| 7203 | "community number\n" |
| 7204 | "Do not send outside local AS (well-known community)\n" |
| 7205 | "Do not advertise to any peer (well-known community)\n" |
| 7206 | "Do not export to next AS (well-known community)\n" |
| 7207 | "community number\n" |
| 7208 | "Do not send outside local AS (well-known community)\n" |
| 7209 | "Do not advertise to any peer (well-known community)\n" |
| 7210 | "Do not export to next AS (well-known community)\n" |
| 7211 | "community number\n" |
| 7212 | "Do not send outside local AS (well-known community)\n" |
| 7213 | "Do not advertise to any peer (well-known community)\n" |
| 7214 | "Do not export to next AS (well-known community)\n" |
| 7215 | "community number\n" |
| 7216 | "Do not send outside local AS (well-known community)\n" |
| 7217 | "Do not advertise to any peer (well-known community)\n" |
| 7218 | "Do not export to next AS (well-known community)\n") |
| 7219 | |
| 7220 | ALIAS (show_bgp_community, |
| 7221 | show_bgp_ipv6_community4_cmd, |
| 7222 | "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)", |
| 7223 | SHOW_STR |
| 7224 | BGP_STR |
| 7225 | "Address family\n" |
| 7226 | "Display routes matching the communities\n" |
| 7227 | "community number\n" |
| 7228 | "Do not send outside local AS (well-known community)\n" |
| 7229 | "Do not advertise to any peer (well-known community)\n" |
| 7230 | "Do not export to next AS (well-known community)\n" |
| 7231 | "community number\n" |
| 7232 | "Do not send outside local AS (well-known community)\n" |
| 7233 | "Do not advertise to any peer (well-known community)\n" |
| 7234 | "Do not export to next AS (well-known community)\n" |
| 7235 | "community number\n" |
| 7236 | "Do not send outside local AS (well-known community)\n" |
| 7237 | "Do not advertise to any peer (well-known community)\n" |
| 7238 | "Do not export to next AS (well-known community)\n" |
| 7239 | "community number\n" |
| 7240 | "Do not send outside local AS (well-known community)\n" |
| 7241 | "Do not advertise to any peer (well-known community)\n" |
| 7242 | "Do not export to next AS (well-known community)\n") |
| 7243 | |
| 7244 | /* old command */ |
| 7245 | DEFUN (show_ipv6_bgp_community, |
| 7246 | show_ipv6_bgp_community_cmd, |
| 7247 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7248 | SHOW_STR |
| 7249 | IPV6_STR |
| 7250 | BGP_STR |
| 7251 | "Display routes matching the communities\n" |
| 7252 | "community number\n" |
| 7253 | "Do not send outside local AS (well-known community)\n" |
| 7254 | "Do not advertise to any peer (well-known community)\n" |
| 7255 | "Do not export to next AS (well-known community)\n") |
| 7256 | { |
| 7257 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7258 | } |
| 7259 | |
| 7260 | /* old command */ |
| 7261 | ALIAS (show_ipv6_bgp_community, |
| 7262 | show_ipv6_bgp_community2_cmd, |
| 7263 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7264 | SHOW_STR |
| 7265 | IPV6_STR |
| 7266 | BGP_STR |
| 7267 | "Display routes matching the communities\n" |
| 7268 | "community number\n" |
| 7269 | "Do not send outside local AS (well-known community)\n" |
| 7270 | "Do not advertise to any peer (well-known community)\n" |
| 7271 | "Do not export to next AS (well-known community)\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 | |
| 7277 | /* old command */ |
| 7278 | ALIAS (show_ipv6_bgp_community, |
| 7279 | show_ipv6_bgp_community3_cmd, |
| 7280 | "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)", |
| 7281 | SHOW_STR |
| 7282 | IPV6_STR |
| 7283 | BGP_STR |
| 7284 | "Display routes matching the communities\n" |
| 7285 | "community number\n" |
| 7286 | "Do not send outside local AS (well-known community)\n" |
| 7287 | "Do not advertise to any peer (well-known community)\n" |
| 7288 | "Do not export to next AS (well-known community)\n" |
| 7289 | "community number\n" |
| 7290 | "Do not send outside local AS (well-known community)\n" |
| 7291 | "Do not advertise to any peer (well-known community)\n" |
| 7292 | "Do not export to next AS (well-known community)\n" |
| 7293 | "community number\n" |
| 7294 | "Do not send outside local AS (well-known community)\n" |
| 7295 | "Do not advertise to any peer (well-known community)\n" |
| 7296 | "Do not export to next AS (well-known community)\n") |
| 7297 | |
| 7298 | /* old command */ |
| 7299 | ALIAS (show_ipv6_bgp_community, |
| 7300 | show_ipv6_bgp_community4_cmd, |
| 7301 | "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)", |
| 7302 | SHOW_STR |
| 7303 | IPV6_STR |
| 7304 | BGP_STR |
| 7305 | "Display routes matching the communities\n" |
| 7306 | "community number\n" |
| 7307 | "Do not send outside local AS (well-known community)\n" |
| 7308 | "Do not advertise to any peer (well-known community)\n" |
| 7309 | "Do not export to next AS (well-known community)\n" |
| 7310 | "community number\n" |
| 7311 | "Do not send outside local AS (well-known community)\n" |
| 7312 | "Do not advertise to any peer (well-known community)\n" |
| 7313 | "Do not export to next AS (well-known community)\n" |
| 7314 | "community number\n" |
| 7315 | "Do not send outside local AS (well-known community)\n" |
| 7316 | "Do not advertise to any peer (well-known community)\n" |
| 7317 | "Do not export to next AS (well-known community)\n" |
| 7318 | "community number\n" |
| 7319 | "Do not send outside local AS (well-known community)\n" |
| 7320 | "Do not advertise to any peer (well-known community)\n" |
| 7321 | "Do not export to next AS (well-known community)\n") |
| 7322 | |
| 7323 | DEFUN (show_bgp_community_exact, |
| 7324 | show_bgp_community_exact_cmd, |
| 7325 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7326 | SHOW_STR |
| 7327 | BGP_STR |
| 7328 | "Display routes matching the communities\n" |
| 7329 | "community number\n" |
| 7330 | "Do not send outside local AS (well-known community)\n" |
| 7331 | "Do not advertise to any peer (well-known community)\n" |
| 7332 | "Do not export to next AS (well-known community)\n" |
| 7333 | "Exact match of the communities") |
| 7334 | { |
| 7335 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7336 | } |
| 7337 | |
| 7338 | ALIAS (show_bgp_community_exact, |
| 7339 | show_bgp_ipv6_community_exact_cmd, |
| 7340 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7341 | SHOW_STR |
| 7342 | BGP_STR |
| 7343 | "Address family\n" |
| 7344 | "Display routes matching the communities\n" |
| 7345 | "community number\n" |
| 7346 | "Do not send outside local AS (well-known community)\n" |
| 7347 | "Do not advertise to any peer (well-known community)\n" |
| 7348 | "Do not export to next AS (well-known community)\n" |
| 7349 | "Exact match of the communities") |
| 7350 | |
| 7351 | ALIAS (show_bgp_community_exact, |
| 7352 | show_bgp_community2_exact_cmd, |
| 7353 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7354 | SHOW_STR |
| 7355 | BGP_STR |
| 7356 | "Display routes matching the communities\n" |
| 7357 | "community number\n" |
| 7358 | "Do not send outside local AS (well-known community)\n" |
| 7359 | "Do not advertise to any peer (well-known community)\n" |
| 7360 | "Do not export to next AS (well-known community)\n" |
| 7361 | "community number\n" |
| 7362 | "Do not send outside local AS (well-known community)\n" |
| 7363 | "Do not advertise to any peer (well-known community)\n" |
| 7364 | "Do not export to next AS (well-known community)\n" |
| 7365 | "Exact match of the communities") |
| 7366 | |
| 7367 | ALIAS (show_bgp_community_exact, |
| 7368 | show_bgp_ipv6_community2_exact_cmd, |
| 7369 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7370 | SHOW_STR |
| 7371 | BGP_STR |
| 7372 | "Address family\n" |
| 7373 | "Display routes matching the communities\n" |
| 7374 | "community number\n" |
| 7375 | "Do not send outside local AS (well-known community)\n" |
| 7376 | "Do not advertise to any peer (well-known community)\n" |
| 7377 | "Do not export to next AS (well-known community)\n" |
| 7378 | "community number\n" |
| 7379 | "Do not send outside local AS (well-known community)\n" |
| 7380 | "Do not advertise to any peer (well-known community)\n" |
| 7381 | "Do not export to next AS (well-known community)\n" |
| 7382 | "Exact match of the communities") |
| 7383 | |
| 7384 | ALIAS (show_bgp_community_exact, |
| 7385 | show_bgp_community3_exact_cmd, |
| 7386 | "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", |
| 7387 | SHOW_STR |
| 7388 | BGP_STR |
| 7389 | "Display routes matching the communities\n" |
| 7390 | "community number\n" |
| 7391 | "Do not send outside local AS (well-known community)\n" |
| 7392 | "Do not advertise to any peer (well-known community)\n" |
| 7393 | "Do not export to next AS (well-known community)\n" |
| 7394 | "community number\n" |
| 7395 | "Do not send outside local AS (well-known community)\n" |
| 7396 | "Do not advertise to any peer (well-known community)\n" |
| 7397 | "Do not export to next AS (well-known community)\n" |
| 7398 | "community number\n" |
| 7399 | "Do not send outside local AS (well-known community)\n" |
| 7400 | "Do not advertise to any peer (well-known community)\n" |
| 7401 | "Do not export to next AS (well-known community)\n" |
| 7402 | "Exact match of the communities") |
| 7403 | |
| 7404 | ALIAS (show_bgp_community_exact, |
| 7405 | show_bgp_ipv6_community3_exact_cmd, |
| 7406 | "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", |
| 7407 | SHOW_STR |
| 7408 | BGP_STR |
| 7409 | "Address family\n" |
| 7410 | "Display routes matching the communities\n" |
| 7411 | "community number\n" |
| 7412 | "Do not send outside local AS (well-known community)\n" |
| 7413 | "Do not advertise to any peer (well-known community)\n" |
| 7414 | "Do not export to next AS (well-known community)\n" |
| 7415 | "community number\n" |
| 7416 | "Do not send outside local AS (well-known community)\n" |
| 7417 | "Do not advertise to any peer (well-known community)\n" |
| 7418 | "Do not export to next AS (well-known community)\n" |
| 7419 | "community number\n" |
| 7420 | "Do not send outside local AS (well-known community)\n" |
| 7421 | "Do not advertise to any peer (well-known community)\n" |
| 7422 | "Do not export to next AS (well-known community)\n" |
| 7423 | "Exact match of the communities") |
| 7424 | |
| 7425 | ALIAS (show_bgp_community_exact, |
| 7426 | show_bgp_community4_exact_cmd, |
| 7427 | "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", |
| 7428 | SHOW_STR |
| 7429 | BGP_STR |
| 7430 | "Display routes matching the communities\n" |
| 7431 | "community number\n" |
| 7432 | "Do not send outside local AS (well-known community)\n" |
| 7433 | "Do not advertise to any peer (well-known community)\n" |
| 7434 | "Do not export to next AS (well-known community)\n" |
| 7435 | "community number\n" |
| 7436 | "Do not send outside local AS (well-known community)\n" |
| 7437 | "Do not advertise to any peer (well-known community)\n" |
| 7438 | "Do not export to next AS (well-known community)\n" |
| 7439 | "community number\n" |
| 7440 | "Do not send outside local AS (well-known community)\n" |
| 7441 | "Do not advertise to any peer (well-known community)\n" |
| 7442 | "Do not export to next AS (well-known community)\n" |
| 7443 | "community number\n" |
| 7444 | "Do not send outside local AS (well-known community)\n" |
| 7445 | "Do not advertise to any peer (well-known community)\n" |
| 7446 | "Do not export to next AS (well-known community)\n" |
| 7447 | "Exact match of the communities") |
| 7448 | |
| 7449 | ALIAS (show_bgp_community_exact, |
| 7450 | show_bgp_ipv6_community4_exact_cmd, |
| 7451 | "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", |
| 7452 | SHOW_STR |
| 7453 | BGP_STR |
| 7454 | "Address family\n" |
| 7455 | "Display routes matching the communities\n" |
| 7456 | "community number\n" |
| 7457 | "Do not send outside local AS (well-known community)\n" |
| 7458 | "Do not advertise to any peer (well-known community)\n" |
| 7459 | "Do not export to next AS (well-known community)\n" |
| 7460 | "community number\n" |
| 7461 | "Do not send outside local AS (well-known community)\n" |
| 7462 | "Do not advertise to any peer (well-known community)\n" |
| 7463 | "Do not export to next AS (well-known community)\n" |
| 7464 | "community number\n" |
| 7465 | "Do not send outside local AS (well-known community)\n" |
| 7466 | "Do not advertise to any peer (well-known community)\n" |
| 7467 | "Do not export to next AS (well-known community)\n" |
| 7468 | "community number\n" |
| 7469 | "Do not send outside local AS (well-known community)\n" |
| 7470 | "Do not advertise to any peer (well-known community)\n" |
| 7471 | "Do not export to next AS (well-known community)\n" |
| 7472 | "Exact match of the communities") |
| 7473 | |
| 7474 | /* old command */ |
| 7475 | DEFUN (show_ipv6_bgp_community_exact, |
| 7476 | show_ipv6_bgp_community_exact_cmd, |
| 7477 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7478 | SHOW_STR |
| 7479 | IPV6_STR |
| 7480 | BGP_STR |
| 7481 | "Display routes matching the communities\n" |
| 7482 | "community number\n" |
| 7483 | "Do not send outside local AS (well-known community)\n" |
| 7484 | "Do not advertise to any peer (well-known community)\n" |
| 7485 | "Do not export to next AS (well-known community)\n" |
| 7486 | "Exact match of the communities") |
| 7487 | { |
| 7488 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7489 | } |
| 7490 | |
| 7491 | /* old command */ |
| 7492 | ALIAS (show_ipv6_bgp_community_exact, |
| 7493 | show_ipv6_bgp_community2_exact_cmd, |
| 7494 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7495 | SHOW_STR |
| 7496 | IPV6_STR |
| 7497 | BGP_STR |
| 7498 | "Display routes matching the communities\n" |
| 7499 | "community number\n" |
| 7500 | "Do not send outside local AS (well-known community)\n" |
| 7501 | "Do not advertise to any peer (well-known community)\n" |
| 7502 | "Do not export to next AS (well-known community)\n" |
| 7503 | "community number\n" |
| 7504 | "Do not send outside local AS (well-known community)\n" |
| 7505 | "Do not advertise to any peer (well-known community)\n" |
| 7506 | "Do not export to next AS (well-known community)\n" |
| 7507 | "Exact match of the communities") |
| 7508 | |
| 7509 | /* old command */ |
| 7510 | ALIAS (show_ipv6_bgp_community_exact, |
| 7511 | show_ipv6_bgp_community3_exact_cmd, |
| 7512 | "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", |
| 7513 | SHOW_STR |
| 7514 | IPV6_STR |
| 7515 | BGP_STR |
| 7516 | "Display routes matching the communities\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 | "community number\n" |
| 7522 | "Do not send outside local AS (well-known community)\n" |
| 7523 | "Do not advertise to any peer (well-known community)\n" |
| 7524 | "Do not export to next AS (well-known community)\n" |
| 7525 | "community number\n" |
| 7526 | "Do not send outside local AS (well-known community)\n" |
| 7527 | "Do not advertise to any peer (well-known community)\n" |
| 7528 | "Do not export to next AS (well-known community)\n" |
| 7529 | "Exact match of the communities") |
| 7530 | |
| 7531 | /* old command */ |
| 7532 | ALIAS (show_ipv6_bgp_community_exact, |
| 7533 | show_ipv6_bgp_community4_exact_cmd, |
| 7534 | "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", |
| 7535 | SHOW_STR |
| 7536 | IPV6_STR |
| 7537 | BGP_STR |
| 7538 | "Display routes matching the communities\n" |
| 7539 | "community number\n" |
| 7540 | "Do not send outside local AS (well-known community)\n" |
| 7541 | "Do not advertise to any peer (well-known community)\n" |
| 7542 | "Do not export to next AS (well-known community)\n" |
| 7543 | "community number\n" |
| 7544 | "Do not send outside local AS (well-known community)\n" |
| 7545 | "Do not advertise to any peer (well-known community)\n" |
| 7546 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 7556 | |
| 7557 | /* old command */ |
| 7558 | DEFUN (show_ipv6_mbgp_community, |
| 7559 | show_ipv6_mbgp_community_cmd, |
| 7560 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7561 | SHOW_STR |
| 7562 | IPV6_STR |
| 7563 | MBGP_STR |
| 7564 | "Display routes matching the communities\n" |
| 7565 | "community number\n" |
| 7566 | "Do not send outside local AS (well-known community)\n" |
| 7567 | "Do not advertise to any peer (well-known community)\n" |
| 7568 | "Do not export to next AS (well-known community)\n") |
| 7569 | { |
| 7570 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 7571 | } |
| 7572 | |
| 7573 | /* old command */ |
| 7574 | ALIAS (show_ipv6_mbgp_community, |
| 7575 | show_ipv6_mbgp_community2_cmd, |
| 7576 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7577 | SHOW_STR |
| 7578 | IPV6_STR |
| 7579 | MBGP_STR |
| 7580 | "Display routes matching the communities\n" |
| 7581 | "community number\n" |
| 7582 | "Do not send outside local AS (well-known community)\n" |
| 7583 | "Do not advertise to any peer (well-known community)\n" |
| 7584 | "Do not export to next AS (well-known community)\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 | |
| 7590 | /* old command */ |
| 7591 | ALIAS (show_ipv6_mbgp_community, |
| 7592 | show_ipv6_mbgp_community3_cmd, |
| 7593 | "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)", |
| 7594 | SHOW_STR |
| 7595 | IPV6_STR |
| 7596 | MBGP_STR |
| 7597 | "Display routes matching the communities\n" |
| 7598 | "community number\n" |
| 7599 | "Do not send outside local AS (well-known community)\n" |
| 7600 | "Do not advertise to any peer (well-known community)\n" |
| 7601 | "Do not export to next AS (well-known community)\n" |
| 7602 | "community number\n" |
| 7603 | "Do not send outside local AS (well-known community)\n" |
| 7604 | "Do not advertise to any peer (well-known community)\n" |
| 7605 | "Do not export to next AS (well-known community)\n" |
| 7606 | "community number\n" |
| 7607 | "Do not send outside local AS (well-known community)\n" |
| 7608 | "Do not advertise to any peer (well-known community)\n" |
| 7609 | "Do not export to next AS (well-known community)\n") |
| 7610 | |
| 7611 | /* old command */ |
| 7612 | ALIAS (show_ipv6_mbgp_community, |
| 7613 | show_ipv6_mbgp_community4_cmd, |
| 7614 | "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)", |
| 7615 | SHOW_STR |
| 7616 | IPV6_STR |
| 7617 | MBGP_STR |
| 7618 | "Display routes matching the communities\n" |
| 7619 | "community number\n" |
| 7620 | "Do not send outside local AS (well-known community)\n" |
| 7621 | "Do not advertise to any peer (well-known community)\n" |
| 7622 | "Do not export to next AS (well-known community)\n" |
| 7623 | "community number\n" |
| 7624 | "Do not send outside local AS (well-known community)\n" |
| 7625 | "Do not advertise to any peer (well-known community)\n" |
| 7626 | "Do not export to next AS (well-known community)\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 | |
| 7636 | /* old command */ |
| 7637 | DEFUN (show_ipv6_mbgp_community_exact, |
| 7638 | show_ipv6_mbgp_community_exact_cmd, |
| 7639 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7640 | SHOW_STR |
| 7641 | IPV6_STR |
| 7642 | MBGP_STR |
| 7643 | "Display routes matching the communities\n" |
| 7644 | "community number\n" |
| 7645 | "Do not send outside local AS (well-known community)\n" |
| 7646 | "Do not advertise to any peer (well-known community)\n" |
| 7647 | "Do not export to next AS (well-known community)\n" |
| 7648 | "Exact match of the communities") |
| 7649 | { |
| 7650 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 7651 | } |
| 7652 | |
| 7653 | /* old command */ |
| 7654 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7655 | show_ipv6_mbgp_community2_exact_cmd, |
| 7656 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7657 | SHOW_STR |
| 7658 | IPV6_STR |
| 7659 | MBGP_STR |
| 7660 | "Display routes matching the communities\n" |
| 7661 | "community number\n" |
| 7662 | "Do not send outside local AS (well-known community)\n" |
| 7663 | "Do not advertise to any peer (well-known community)\n" |
| 7664 | "Do not export to next AS (well-known community)\n" |
| 7665 | "community number\n" |
| 7666 | "Do not send outside local AS (well-known community)\n" |
| 7667 | "Do not advertise to any peer (well-known community)\n" |
| 7668 | "Do not export to next AS (well-known community)\n" |
| 7669 | "Exact match of the communities") |
| 7670 | |
| 7671 | /* old command */ |
| 7672 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7673 | show_ipv6_mbgp_community3_exact_cmd, |
| 7674 | "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", |
| 7675 | SHOW_STR |
| 7676 | IPV6_STR |
| 7677 | MBGP_STR |
| 7678 | "Display routes matching the communities\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 | "community number\n" |
| 7684 | "Do not send outside local AS (well-known community)\n" |
| 7685 | "Do not advertise to any peer (well-known community)\n" |
| 7686 | "Do not export to next AS (well-known community)\n" |
| 7687 | "community number\n" |
| 7688 | "Do not send outside local AS (well-known community)\n" |
| 7689 | "Do not advertise to any peer (well-known community)\n" |
| 7690 | "Do not export to next AS (well-known community)\n" |
| 7691 | "Exact match of the communities") |
| 7692 | |
| 7693 | /* old command */ |
| 7694 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7695 | show_ipv6_mbgp_community4_exact_cmd, |
| 7696 | "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", |
| 7697 | SHOW_STR |
| 7698 | IPV6_STR |
| 7699 | MBGP_STR |
| 7700 | "Display routes matching the communities\n" |
| 7701 | "community number\n" |
| 7702 | "Do not send outside local AS (well-known community)\n" |
| 7703 | "Do not advertise to any peer (well-known community)\n" |
| 7704 | "Do not export to next AS (well-known community)\n" |
| 7705 | "community number\n" |
| 7706 | "Do not send outside local AS (well-known community)\n" |
| 7707 | "Do not advertise to any peer (well-known community)\n" |
| 7708 | "Do not export to next AS (well-known community)\n" |
| 7709 | "community number\n" |
| 7710 | "Do not send outside local AS (well-known community)\n" |
| 7711 | "Do not advertise to any peer (well-known community)\n" |
| 7712 | "Do not export to next AS (well-known community)\n" |
| 7713 | "community number\n" |
| 7714 | "Do not send outside local AS (well-known community)\n" |
| 7715 | "Do not advertise to any peer (well-known community)\n" |
| 7716 | "Do not export to next AS (well-known community)\n" |
| 7717 | "Exact match of the communities") |
| 7718 | #endif /* HAVE_IPV6 */ |
| 7719 | |
| 7720 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7721 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7722 | u_int16_t afi, u_char safi) |
| 7723 | { |
| 7724 | struct community_list *list; |
| 7725 | |
| 7726 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_AUTO); |
| 7727 | if (list == NULL) |
| 7728 | { |
| 7729 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 7730 | VTY_NEWLINE); |
| 7731 | return CMD_WARNING; |
| 7732 | } |
| 7733 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7734 | return bgp_show (vty, NULL, afi, safi, |
| 7735 | (exact ? bgp_show_type_community_list_exact : |
| 7736 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7737 | } |
| 7738 | |
| 7739 | DEFUN (show_ip_bgp_community_list, |
| 7740 | show_ip_bgp_community_list_cmd, |
| 7741 | "show ip bgp community-list WORD", |
| 7742 | SHOW_STR |
| 7743 | IP_STR |
| 7744 | BGP_STR |
| 7745 | "Display routes matching the community-list\n" |
| 7746 | "community-list name\n") |
| 7747 | { |
| 7748 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 7749 | } |
| 7750 | |
| 7751 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 7752 | show_ip_bgp_ipv4_community_list_cmd, |
| 7753 | "show ip bgp ipv4 (unicast|multicast) community-list WORD", |
| 7754 | SHOW_STR |
| 7755 | IP_STR |
| 7756 | BGP_STR |
| 7757 | "Address family\n" |
| 7758 | "Address Family modifier\n" |
| 7759 | "Address Family modifier\n" |
| 7760 | "Display routes matching the community-list\n" |
| 7761 | "community-list name\n") |
| 7762 | { |
| 7763 | if (strncmp (argv[0], "m", 1) == 0) |
| 7764 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 7765 | |
| 7766 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 7767 | } |
| 7768 | |
| 7769 | DEFUN (show_ip_bgp_community_list_exact, |
| 7770 | show_ip_bgp_community_list_exact_cmd, |
| 7771 | "show ip bgp community-list WORD exact-match", |
| 7772 | SHOW_STR |
| 7773 | IP_STR |
| 7774 | BGP_STR |
| 7775 | "Display routes matching the community-list\n" |
| 7776 | "community-list name\n" |
| 7777 | "Exact match of the communities\n") |
| 7778 | { |
| 7779 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 7780 | } |
| 7781 | |
| 7782 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 7783 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 7784 | "show ip bgp ipv4 (unicast|multicast) community-list WORD exact-match", |
| 7785 | SHOW_STR |
| 7786 | IP_STR |
| 7787 | BGP_STR |
| 7788 | "Address family\n" |
| 7789 | "Address Family modifier\n" |
| 7790 | "Address Family modifier\n" |
| 7791 | "Display routes matching the community-list\n" |
| 7792 | "community-list name\n" |
| 7793 | "Exact match of the communities\n") |
| 7794 | { |
| 7795 | if (strncmp (argv[0], "m", 1) == 0) |
| 7796 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 7797 | |
| 7798 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 7799 | } |
| 7800 | |
| 7801 | #ifdef HAVE_IPV6 |
| 7802 | DEFUN (show_bgp_community_list, |
| 7803 | show_bgp_community_list_cmd, |
| 7804 | "show bgp community-list WORD", |
| 7805 | SHOW_STR |
| 7806 | BGP_STR |
| 7807 | "Display routes matching the community-list\n" |
| 7808 | "community-list name\n") |
| 7809 | { |
| 7810 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7811 | } |
| 7812 | |
| 7813 | ALIAS (show_bgp_community_list, |
| 7814 | show_bgp_ipv6_community_list_cmd, |
| 7815 | "show bgp ipv6 community-list WORD", |
| 7816 | SHOW_STR |
| 7817 | BGP_STR |
| 7818 | "Address family\n" |
| 7819 | "Display routes matching the community-list\n" |
| 7820 | "community-list name\n") |
| 7821 | |
| 7822 | /* old command */ |
| 7823 | DEFUN (show_ipv6_bgp_community_list, |
| 7824 | show_ipv6_bgp_community_list_cmd, |
| 7825 | "show ipv6 bgp community-list WORD", |
| 7826 | SHOW_STR |
| 7827 | IPV6_STR |
| 7828 | BGP_STR |
| 7829 | "Display routes matching the community-list\n" |
| 7830 | "community-list name\n") |
| 7831 | { |
| 7832 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7833 | } |
| 7834 | |
| 7835 | /* old command */ |
| 7836 | DEFUN (show_ipv6_mbgp_community_list, |
| 7837 | show_ipv6_mbgp_community_list_cmd, |
| 7838 | "show ipv6 mbgp community-list WORD", |
| 7839 | SHOW_STR |
| 7840 | IPV6_STR |
| 7841 | MBGP_STR |
| 7842 | "Display routes matching the community-list\n" |
| 7843 | "community-list name\n") |
| 7844 | { |
| 7845 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 7846 | } |
| 7847 | |
| 7848 | DEFUN (show_bgp_community_list_exact, |
| 7849 | show_bgp_community_list_exact_cmd, |
| 7850 | "show bgp community-list WORD exact-match", |
| 7851 | SHOW_STR |
| 7852 | BGP_STR |
| 7853 | "Display routes matching the community-list\n" |
| 7854 | "community-list name\n" |
| 7855 | "Exact match of the communities\n") |
| 7856 | { |
| 7857 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7858 | } |
| 7859 | |
| 7860 | ALIAS (show_bgp_community_list_exact, |
| 7861 | show_bgp_ipv6_community_list_exact_cmd, |
| 7862 | "show bgp ipv6 community-list WORD exact-match", |
| 7863 | SHOW_STR |
| 7864 | BGP_STR |
| 7865 | "Address family\n" |
| 7866 | "Display routes matching the community-list\n" |
| 7867 | "community-list name\n" |
| 7868 | "Exact match of the communities\n") |
| 7869 | |
| 7870 | /* old command */ |
| 7871 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 7872 | show_ipv6_bgp_community_list_exact_cmd, |
| 7873 | "show ipv6 bgp community-list WORD exact-match", |
| 7874 | SHOW_STR |
| 7875 | IPV6_STR |
| 7876 | BGP_STR |
| 7877 | "Display routes matching the community-list\n" |
| 7878 | "community-list name\n" |
| 7879 | "Exact match of the communities\n") |
| 7880 | { |
| 7881 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7882 | } |
| 7883 | |
| 7884 | /* old command */ |
| 7885 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 7886 | show_ipv6_mbgp_community_list_exact_cmd, |
| 7887 | "show ipv6 mbgp community-list WORD exact-match", |
| 7888 | SHOW_STR |
| 7889 | IPV6_STR |
| 7890 | MBGP_STR |
| 7891 | "Display routes matching the community-list\n" |
| 7892 | "community-list name\n" |
| 7893 | "Exact match of the communities\n") |
| 7894 | { |
| 7895 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 7896 | } |
| 7897 | #endif /* HAVE_IPV6 */ |
| 7898 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7899 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7900 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7901 | safi_t safi, enum bgp_show_type type) |
| 7902 | { |
| 7903 | int ret; |
| 7904 | struct prefix *p; |
| 7905 | |
| 7906 | p = prefix_new(); |
| 7907 | |
| 7908 | ret = str2prefix (prefix, p); |
| 7909 | if (! ret) |
| 7910 | { |
| 7911 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 7912 | return CMD_WARNING; |
| 7913 | } |
| 7914 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7915 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 7916 | prefix_free(p); |
| 7917 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7918 | } |
| 7919 | |
| 7920 | DEFUN (show_ip_bgp_prefix_longer, |
| 7921 | show_ip_bgp_prefix_longer_cmd, |
| 7922 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 7923 | SHOW_STR |
| 7924 | IP_STR |
| 7925 | BGP_STR |
| 7926 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7927 | "Display route and more specific routes\n") |
| 7928 | { |
| 7929 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7930 | bgp_show_type_prefix_longer); |
| 7931 | } |
| 7932 | |
| 7933 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 7934 | show_ip_bgp_flap_prefix_longer_cmd, |
| 7935 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 7936 | SHOW_STR |
| 7937 | IP_STR |
| 7938 | BGP_STR |
| 7939 | "Display flap statistics of routes\n" |
| 7940 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7941 | "Display route and more specific routes\n") |
| 7942 | { |
| 7943 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7944 | bgp_show_type_flap_prefix_longer); |
| 7945 | } |
| 7946 | |
| 7947 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 7948 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 7949 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 7950 | SHOW_STR |
| 7951 | IP_STR |
| 7952 | BGP_STR |
| 7953 | "Address family\n" |
| 7954 | "Address Family modifier\n" |
| 7955 | "Address Family modifier\n" |
| 7956 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7957 | "Display route and more specific routes\n") |
| 7958 | { |
| 7959 | if (strncmp (argv[0], "m", 1) == 0) |
| 7960 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7961 | bgp_show_type_prefix_longer); |
| 7962 | |
| 7963 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7964 | bgp_show_type_prefix_longer); |
| 7965 | } |
| 7966 | |
| 7967 | DEFUN (show_ip_bgp_flap_address, |
| 7968 | show_ip_bgp_flap_address_cmd, |
| 7969 | "show ip bgp flap-statistics A.B.C.D", |
| 7970 | SHOW_STR |
| 7971 | IP_STR |
| 7972 | BGP_STR |
| 7973 | "Display flap statistics of routes\n" |
| 7974 | "Network in the BGP routing table to display\n") |
| 7975 | { |
| 7976 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7977 | bgp_show_type_flap_address); |
| 7978 | } |
| 7979 | |
| 7980 | DEFUN (show_ip_bgp_flap_prefix, |
| 7981 | show_ip_bgp_flap_prefix_cmd, |
| 7982 | "show ip bgp flap-statistics A.B.C.D/M", |
| 7983 | SHOW_STR |
| 7984 | IP_STR |
| 7985 | BGP_STR |
| 7986 | "Display flap statistics of routes\n" |
| 7987 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7988 | { |
| 7989 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7990 | bgp_show_type_flap_prefix); |
| 7991 | } |
| 7992 | #ifdef HAVE_IPV6 |
| 7993 | DEFUN (show_bgp_prefix_longer, |
| 7994 | show_bgp_prefix_longer_cmd, |
| 7995 | "show bgp X:X::X:X/M longer-prefixes", |
| 7996 | SHOW_STR |
| 7997 | BGP_STR |
| 7998 | "IPv6 prefix <network>/<length>\n" |
| 7999 | "Display route and more specific routes\n") |
| 8000 | { |
| 8001 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8002 | bgp_show_type_prefix_longer); |
| 8003 | } |
| 8004 | |
| 8005 | ALIAS (show_bgp_prefix_longer, |
| 8006 | show_bgp_ipv6_prefix_longer_cmd, |
| 8007 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 8008 | SHOW_STR |
| 8009 | BGP_STR |
| 8010 | "Address family\n" |
| 8011 | "IPv6 prefix <network>/<length>\n" |
| 8012 | "Display route and more specific routes\n") |
| 8013 | |
| 8014 | /* old command */ |
| 8015 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 8016 | show_ipv6_bgp_prefix_longer_cmd, |
| 8017 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 8018 | SHOW_STR |
| 8019 | IPV6_STR |
| 8020 | BGP_STR |
| 8021 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8022 | "Display route and more specific routes\n") |
| 8023 | { |
| 8024 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8025 | bgp_show_type_prefix_longer); |
| 8026 | } |
| 8027 | |
| 8028 | /* old command */ |
| 8029 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 8030 | show_ipv6_mbgp_prefix_longer_cmd, |
| 8031 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 8032 | SHOW_STR |
| 8033 | IPV6_STR |
| 8034 | MBGP_STR |
| 8035 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8036 | "Display route and more specific routes\n") |
| 8037 | { |
| 8038 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8039 | bgp_show_type_prefix_longer); |
| 8040 | } |
| 8041 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8042 | |
| 8043 | struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8044 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 8045 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8046 | { |
| 8047 | int ret; |
| 8048 | struct bgp *bgp; |
| 8049 | struct peer *peer; |
| 8050 | union sockunion su; |
| 8051 | |
| 8052 | /* BGP structure lookup. */ |
| 8053 | if (view_name) |
| 8054 | { |
| 8055 | bgp = bgp_lookup_by_name (view_name); |
| 8056 | if (! bgp) |
| 8057 | { |
| 8058 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8059 | return NULL; |
| 8060 | } |
| 8061 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 8062 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8063 | { |
| 8064 | bgp = bgp_get_default (); |
| 8065 | if (! bgp) |
| 8066 | { |
| 8067 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8068 | return NULL; |
| 8069 | } |
| 8070 | } |
| 8071 | |
| 8072 | /* Get peer sockunion. */ |
| 8073 | ret = str2sockunion (ip_str, &su); |
| 8074 | if (ret < 0) |
| 8075 | { |
| 8076 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 8077 | return NULL; |
| 8078 | } |
| 8079 | |
| 8080 | /* Peer structure lookup. */ |
| 8081 | peer = peer_lookup (bgp, &su); |
| 8082 | if (! peer) |
| 8083 | { |
| 8084 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 8085 | return NULL; |
| 8086 | } |
| 8087 | |
| 8088 | return peer; |
| 8089 | } |
| 8090 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8091 | void |
| 8092 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 8093 | int in) |
| 8094 | { |
| 8095 | struct bgp_table *table; |
| 8096 | struct bgp_adj_in *ain; |
| 8097 | struct bgp_adj_out *adj; |
| 8098 | unsigned long output_count; |
| 8099 | struct bgp_node *rn; |
| 8100 | int header1 = 1; |
| 8101 | struct bgp *bgp; |
| 8102 | int header2 = 1; |
| 8103 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8104 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8105 | |
| 8106 | if (! bgp) |
| 8107 | return; |
| 8108 | |
| 8109 | table = bgp->rib[afi][safi]; |
| 8110 | |
| 8111 | output_count = 0; |
| 8112 | |
| 8113 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 8114 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 8115 | { |
| 8116 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 8117 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 8118 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 8119 | |
| 8120 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 8121 | VTY_NEWLINE, VTY_NEWLINE); |
| 8122 | header1 = 0; |
| 8123 | } |
| 8124 | |
| 8125 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 8126 | if (in) |
| 8127 | { |
| 8128 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 8129 | if (ain->peer == peer) |
| 8130 | { |
| 8131 | if (header1) |
| 8132 | { |
| 8133 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 8134 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 8135 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 8136 | header1 = 0; |
| 8137 | } |
| 8138 | if (header2) |
| 8139 | { |
| 8140 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8141 | header2 = 0; |
| 8142 | } |
| 8143 | if (ain->attr) |
| 8144 | { |
| 8145 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 8146 | output_count++; |
| 8147 | } |
| 8148 | } |
| 8149 | } |
| 8150 | else |
| 8151 | { |
| 8152 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 8153 | if (adj->peer == peer) |
| 8154 | { |
| 8155 | if (header1) |
| 8156 | { |
| 8157 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
| 8158 | vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE); |
| 8159 | vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE); |
| 8160 | header1 = 0; |
| 8161 | } |
| 8162 | if (header2) |
| 8163 | { |
| 8164 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8165 | header2 = 0; |
| 8166 | } |
| 8167 | if (adj->attr) |
| 8168 | { |
| 8169 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 8170 | output_count++; |
| 8171 | } |
| 8172 | } |
| 8173 | } |
| 8174 | |
| 8175 | if (output_count != 0) |
| 8176 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 8177 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 8178 | } |
| 8179 | |
| 8180 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8181 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 8182 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8183 | if (! peer || ! peer->afc[afi][safi]) |
| 8184 | { |
| 8185 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 8186 | return CMD_WARNING; |
| 8187 | } |
| 8188 | |
| 8189 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 8190 | { |
| 8191 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 8192 | VTY_NEWLINE); |
| 8193 | return CMD_WARNING; |
| 8194 | } |
| 8195 | |
| 8196 | show_adj_route (vty, peer, afi, safi, in); |
| 8197 | |
| 8198 | return CMD_SUCCESS; |
| 8199 | } |
| 8200 | |
| 8201 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 8202 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 8203 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8204 | SHOW_STR |
| 8205 | IP_STR |
| 8206 | BGP_STR |
| 8207 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8208 | "Neighbor to display information about\n" |
| 8209 | "Neighbor to display information about\n" |
| 8210 | "Display the routes advertised to a BGP neighbor\n") |
| 8211 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8212 | struct peer *peer; |
| 8213 | |
| 8214 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8215 | if (! peer) |
| 8216 | return CMD_WARNING; |
| 8217 | |
| 8218 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8219 | } |
| 8220 | |
| 8221 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 8222 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 8223 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8224 | SHOW_STR |
| 8225 | IP_STR |
| 8226 | BGP_STR |
| 8227 | "Address family\n" |
| 8228 | "Address Family modifier\n" |
| 8229 | "Address Family modifier\n" |
| 8230 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8231 | "Neighbor to display information about\n" |
| 8232 | "Neighbor to display information about\n" |
| 8233 | "Display the routes advertised to a BGP neighbor\n") |
| 8234 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8235 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8236 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8237 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8238 | if (! peer) |
| 8239 | return CMD_WARNING; |
| 8240 | |
| 8241 | if (strncmp (argv[0], "m", 1) == 0) |
| 8242 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 8243 | |
| 8244 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8245 | } |
| 8246 | |
| 8247 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8248 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 8249 | show_bgp_view_neighbor_advertised_route_cmd, |
| 8250 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8251 | SHOW_STR |
| 8252 | BGP_STR |
| 8253 | "BGP view\n" |
| 8254 | "View name\n" |
| 8255 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8256 | "Neighbor to display information about\n" |
| 8257 | "Neighbor to display information about\n" |
| 8258 | "Display the routes advertised to a BGP neighbor\n") |
| 8259 | { |
| 8260 | struct peer *peer; |
| 8261 | |
| 8262 | if (argc == 2) |
| 8263 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8264 | else |
| 8265 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8266 | |
| 8267 | if (! peer) |
| 8268 | return CMD_WARNING; |
| 8269 | |
| 8270 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 8271 | } |
| 8272 | |
| 8273 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 8274 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 8275 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8276 | SHOW_STR |
| 8277 | BGP_STR |
| 8278 | "BGP view\n" |
| 8279 | "View name\n" |
| 8280 | "Address family\n" |
| 8281 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8282 | "Neighbor to display information about\n" |
| 8283 | "Neighbor to display information about\n" |
| 8284 | "Display the routes advertised to a BGP neighbor\n") |
| 8285 | |
| 8286 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 8287 | show_bgp_view_neighbor_received_routes_cmd, |
| 8288 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8289 | SHOW_STR |
| 8290 | BGP_STR |
| 8291 | "BGP view\n" |
| 8292 | "View name\n" |
| 8293 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8294 | "Neighbor to display information about\n" |
| 8295 | "Neighbor to display information about\n" |
| 8296 | "Display the received routes from neighbor\n") |
| 8297 | { |
| 8298 | struct peer *peer; |
| 8299 | |
| 8300 | if (argc == 2) |
| 8301 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8302 | else |
| 8303 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8304 | |
| 8305 | if (! peer) |
| 8306 | return CMD_WARNING; |
| 8307 | |
| 8308 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 8309 | } |
| 8310 | |
| 8311 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 8312 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 8313 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8314 | SHOW_STR |
| 8315 | BGP_STR |
| 8316 | "BGP view\n" |
| 8317 | "View name\n" |
| 8318 | "Address family\n" |
| 8319 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8320 | "Neighbor to display information about\n" |
| 8321 | "Neighbor to display information about\n" |
| 8322 | "Display the received routes from neighbor\n") |
| 8323 | |
| 8324 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8325 | show_bgp_neighbor_advertised_route_cmd, |
| 8326 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8327 | SHOW_STR |
| 8328 | BGP_STR |
| 8329 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8330 | "Neighbor to display information about\n" |
| 8331 | "Neighbor to display information about\n" |
| 8332 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8333 | |
| 8334 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8335 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 8336 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8337 | SHOW_STR |
| 8338 | BGP_STR |
| 8339 | "Address family\n" |
| 8340 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8341 | "Neighbor to display information about\n" |
| 8342 | "Neighbor to display information about\n" |
| 8343 | "Display the routes advertised to a BGP neighbor\n") |
| 8344 | |
| 8345 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8346 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8347 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 8348 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8349 | SHOW_STR |
| 8350 | IPV6_STR |
| 8351 | BGP_STR |
| 8352 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8353 | "Neighbor to display information about\n" |
| 8354 | "Neighbor to display information about\n" |
| 8355 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8356 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8357 | /* old command */ |
| 8358 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 8359 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 8360 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8361 | SHOW_STR |
| 8362 | IPV6_STR |
| 8363 | MBGP_STR |
| 8364 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8365 | "Neighbor to display information about\n" |
| 8366 | "Neighbor to display information about\n" |
| 8367 | "Display the routes advertised to a BGP neighbor\n") |
| 8368 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8369 | struct peer *peer; |
| 8370 | |
| 8371 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8372 | if (! peer) |
| 8373 | return CMD_WARNING; |
| 8374 | |
| 8375 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8376 | } |
| 8377 | #endif /* HAVE_IPV6 */ |
| 8378 | |
| 8379 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 8380 | show_ip_bgp_neighbor_received_routes_cmd, |
| 8381 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8382 | SHOW_STR |
| 8383 | IP_STR |
| 8384 | BGP_STR |
| 8385 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8386 | "Neighbor to display information about\n" |
| 8387 | "Neighbor to display information about\n" |
| 8388 | "Display the received routes from neighbor\n") |
| 8389 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8390 | struct peer *peer; |
| 8391 | |
| 8392 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8393 | if (! peer) |
| 8394 | return CMD_WARNING; |
| 8395 | |
| 8396 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8397 | } |
| 8398 | |
| 8399 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 8400 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 8401 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8402 | SHOW_STR |
| 8403 | IP_STR |
| 8404 | BGP_STR |
| 8405 | "Address family\n" |
| 8406 | "Address Family modifier\n" |
| 8407 | "Address Family modifier\n" |
| 8408 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8409 | "Neighbor to display information about\n" |
| 8410 | "Neighbor to display information about\n" |
| 8411 | "Display the received routes from neighbor\n") |
| 8412 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8413 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8414 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8415 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8416 | if (! peer) |
| 8417 | return CMD_WARNING; |
| 8418 | |
| 8419 | if (strncmp (argv[0], "m", 1) == 0) |
| 8420 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 8421 | |
| 8422 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8423 | } |
| 8424 | |
| 8425 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 8426 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 8427 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8428 | SHOW_STR |
| 8429 | IP_STR |
| 8430 | BGP_STR |
| 8431 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8432 | "Neighbor to display information about\n" |
| 8433 | "Neighbor to display information about\n" |
| 8434 | "Display information received from a BGP neighbor\n" |
| 8435 | "Display the prefixlist filter\n") |
| 8436 | { |
| 8437 | char name[BUFSIZ]; |
| 8438 | union sockunion *su; |
| 8439 | struct peer *peer; |
| 8440 | int count; |
| 8441 | |
| 8442 | su = sockunion_str2su (argv[0]); |
| 8443 | if (su == NULL) |
| 8444 | return CMD_WARNING; |
| 8445 | |
| 8446 | peer = peer_lookup (NULL, su); |
| 8447 | if (! peer) |
| 8448 | return CMD_WARNING; |
| 8449 | |
| 8450 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8451 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8452 | if (count) |
| 8453 | { |
| 8454 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8455 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8456 | } |
| 8457 | |
| 8458 | return CMD_SUCCESS; |
| 8459 | } |
| 8460 | |
| 8461 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 8462 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 8463 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8464 | SHOW_STR |
| 8465 | IP_STR |
| 8466 | BGP_STR |
| 8467 | "Address family\n" |
| 8468 | "Address Family modifier\n" |
| 8469 | "Address Family modifier\n" |
| 8470 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8471 | "Neighbor to display information about\n" |
| 8472 | "Neighbor to display information about\n" |
| 8473 | "Display information received from a BGP neighbor\n" |
| 8474 | "Display the prefixlist filter\n") |
| 8475 | { |
| 8476 | char name[BUFSIZ]; |
| 8477 | union sockunion *su; |
| 8478 | struct peer *peer; |
| 8479 | int count; |
| 8480 | |
| 8481 | su = sockunion_str2su (argv[1]); |
| 8482 | if (su == NULL) |
| 8483 | return CMD_WARNING; |
| 8484 | |
| 8485 | peer = peer_lookup (NULL, su); |
| 8486 | if (! peer) |
| 8487 | return CMD_WARNING; |
| 8488 | |
| 8489 | if (strncmp (argv[0], "m", 1) == 0) |
| 8490 | { |
| 8491 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 8492 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8493 | if (count) |
| 8494 | { |
| 8495 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 8496 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8497 | } |
| 8498 | } |
| 8499 | else |
| 8500 | { |
| 8501 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8502 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8503 | if (count) |
| 8504 | { |
| 8505 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8506 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8507 | } |
| 8508 | } |
| 8509 | |
| 8510 | return CMD_SUCCESS; |
| 8511 | } |
| 8512 | |
| 8513 | |
| 8514 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8515 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8516 | show_bgp_neighbor_received_routes_cmd, |
| 8517 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8518 | SHOW_STR |
| 8519 | BGP_STR |
| 8520 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8521 | "Neighbor to display information about\n" |
| 8522 | "Neighbor to display information about\n" |
| 8523 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8524 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8525 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8526 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 8527 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8528 | SHOW_STR |
| 8529 | BGP_STR |
| 8530 | "Address family\n" |
| 8531 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8532 | "Neighbor to display information about\n" |
| 8533 | "Neighbor to display information about\n" |
| 8534 | "Display the received routes from neighbor\n") |
| 8535 | |
| 8536 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 8537 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 8538 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8539 | SHOW_STR |
| 8540 | BGP_STR |
| 8541 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8542 | "Neighbor to display information about\n" |
| 8543 | "Neighbor to display information about\n" |
| 8544 | "Display information received from a BGP neighbor\n" |
| 8545 | "Display the prefixlist filter\n") |
| 8546 | { |
| 8547 | char name[BUFSIZ]; |
| 8548 | union sockunion *su; |
| 8549 | struct peer *peer; |
| 8550 | int count; |
| 8551 | |
| 8552 | su = sockunion_str2su (argv[0]); |
| 8553 | if (su == NULL) |
| 8554 | return CMD_WARNING; |
| 8555 | |
| 8556 | peer = peer_lookup (NULL, su); |
| 8557 | if (! peer) |
| 8558 | return CMD_WARNING; |
| 8559 | |
| 8560 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8561 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8562 | if (count) |
| 8563 | { |
| 8564 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8565 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8566 | } |
| 8567 | |
| 8568 | return CMD_SUCCESS; |
| 8569 | } |
| 8570 | |
| 8571 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 8572 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 8573 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8574 | SHOW_STR |
| 8575 | BGP_STR |
| 8576 | "Address family\n" |
| 8577 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8578 | "Neighbor to display information about\n" |
| 8579 | "Neighbor to display information about\n" |
| 8580 | "Display information received from a BGP neighbor\n" |
| 8581 | "Display the prefixlist filter\n") |
| 8582 | |
| 8583 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8584 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8585 | ipv6_bgp_neighbor_received_routes_cmd, |
| 8586 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8587 | SHOW_STR |
| 8588 | IPV6_STR |
| 8589 | BGP_STR |
| 8590 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8591 | "Neighbor to display information about\n" |
| 8592 | "Neighbor to display information about\n" |
| 8593 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8594 | |
| 8595 | /* old command */ |
| 8596 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 8597 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 8598 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8599 | SHOW_STR |
| 8600 | IPV6_STR |
| 8601 | MBGP_STR |
| 8602 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8603 | "Neighbor to display information about\n" |
| 8604 | "Neighbor to display information about\n" |
| 8605 | "Display the received routes from neighbor\n") |
| 8606 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8607 | struct peer *peer; |
| 8608 | |
| 8609 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8610 | if (! peer) |
| 8611 | return CMD_WARNING; |
| 8612 | |
| 8613 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8614 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8615 | |
| 8616 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 8617 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 8618 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8619 | SHOW_STR |
| 8620 | BGP_STR |
| 8621 | "BGP view\n" |
| 8622 | "View name\n" |
| 8623 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8624 | "Neighbor to display information about\n" |
| 8625 | "Neighbor to display information about\n" |
| 8626 | "Display information received from a BGP neighbor\n" |
| 8627 | "Display the prefixlist filter\n") |
| 8628 | { |
| 8629 | char name[BUFSIZ]; |
| 8630 | union sockunion *su; |
| 8631 | struct peer *peer; |
| 8632 | struct bgp *bgp; |
| 8633 | int count; |
| 8634 | |
| 8635 | /* BGP structure lookup. */ |
| 8636 | bgp = bgp_lookup_by_name (argv[0]); |
| 8637 | if (bgp == NULL) |
| 8638 | { |
| 8639 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8640 | return CMD_WARNING; |
| 8641 | } |
| 8642 | |
| 8643 | su = sockunion_str2su (argv[1]); |
| 8644 | if (su == NULL) |
| 8645 | return CMD_WARNING; |
| 8646 | |
| 8647 | peer = peer_lookup (bgp, su); |
| 8648 | if (! peer) |
| 8649 | return CMD_WARNING; |
| 8650 | |
| 8651 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8652 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8653 | if (count) |
| 8654 | { |
| 8655 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8656 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8657 | } |
| 8658 | |
| 8659 | return CMD_SUCCESS; |
| 8660 | } |
| 8661 | |
| 8662 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 8663 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 8664 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8665 | SHOW_STR |
| 8666 | BGP_STR |
| 8667 | "BGP view\n" |
| 8668 | "View name\n" |
| 8669 | "Address family\n" |
| 8670 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8671 | "Neighbor to display information about\n" |
| 8672 | "Neighbor to display information about\n" |
| 8673 | "Display information received from a BGP neighbor\n" |
| 8674 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8675 | #endif /* HAVE_IPV6 */ |
| 8676 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8677 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8678 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8679 | safi_t safi, enum bgp_show_type type) |
| 8680 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8681 | if (! peer || ! peer->afc[afi][safi]) |
| 8682 | { |
| 8683 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8684 | return CMD_WARNING; |
| 8685 | } |
| 8686 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8687 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8688 | } |
| 8689 | |
| 8690 | DEFUN (show_ip_bgp_neighbor_routes, |
| 8691 | show_ip_bgp_neighbor_routes_cmd, |
| 8692 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8693 | SHOW_STR |
| 8694 | IP_STR |
| 8695 | BGP_STR |
| 8696 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8697 | "Neighbor to display information about\n" |
| 8698 | "Neighbor to display information about\n" |
| 8699 | "Display routes learned from neighbor\n") |
| 8700 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8701 | struct peer *peer; |
| 8702 | |
| 8703 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8704 | if (! peer) |
| 8705 | return CMD_WARNING; |
| 8706 | |
| 8707 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8708 | bgp_show_type_neighbor); |
| 8709 | } |
| 8710 | |
| 8711 | DEFUN (show_ip_bgp_neighbor_flap, |
| 8712 | show_ip_bgp_neighbor_flap_cmd, |
| 8713 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8714 | SHOW_STR |
| 8715 | IP_STR |
| 8716 | BGP_STR |
| 8717 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8718 | "Neighbor to display information about\n" |
| 8719 | "Neighbor to display information about\n" |
| 8720 | "Display flap statistics of the routes learned from neighbor\n") |
| 8721 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8722 | struct peer *peer; |
| 8723 | |
| 8724 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8725 | if (! peer) |
| 8726 | return CMD_WARNING; |
| 8727 | |
| 8728 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8729 | bgp_show_type_flap_neighbor); |
| 8730 | } |
| 8731 | |
| 8732 | DEFUN (show_ip_bgp_neighbor_damp, |
| 8733 | show_ip_bgp_neighbor_damp_cmd, |
| 8734 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8735 | SHOW_STR |
| 8736 | IP_STR |
| 8737 | BGP_STR |
| 8738 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8739 | "Neighbor to display information about\n" |
| 8740 | "Neighbor to display information about\n" |
| 8741 | "Display the dampened routes received from neighbor\n") |
| 8742 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8743 | struct peer *peer; |
| 8744 | |
| 8745 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8746 | if (! peer) |
| 8747 | return CMD_WARNING; |
| 8748 | |
| 8749 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8750 | bgp_show_type_damp_neighbor); |
| 8751 | } |
| 8752 | |
| 8753 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 8754 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 8755 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 8756 | SHOW_STR |
| 8757 | IP_STR |
| 8758 | BGP_STR |
| 8759 | "Address family\n" |
| 8760 | "Address Family modifier\n" |
| 8761 | "Address Family modifier\n" |
| 8762 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8763 | "Neighbor to display information about\n" |
| 8764 | "Neighbor to display information about\n" |
| 8765 | "Display routes learned from neighbor\n") |
| 8766 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8767 | struct peer *peer; |
| 8768 | |
| 8769 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8770 | if (! peer) |
| 8771 | return CMD_WARNING; |
| 8772 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8773 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8774 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8775 | bgp_show_type_neighbor); |
| 8776 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8777 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8778 | bgp_show_type_neighbor); |
| 8779 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8780 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 8781 | DEFUN (show_ip_bgp_view_rsclient, |
| 8782 | show_ip_bgp_view_rsclient_cmd, |
| 8783 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 8784 | SHOW_STR |
| 8785 | IP_STR |
| 8786 | BGP_STR |
| 8787 | "BGP view\n" |
| 8788 | "BGP view name\n" |
| 8789 | "Information about Route Server Client\n" |
| 8790 | NEIGHBOR_ADDR_STR) |
| 8791 | { |
| 8792 | struct bgp_table *table; |
| 8793 | struct peer *peer; |
| 8794 | |
| 8795 | if (argc == 2) |
| 8796 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8797 | else |
| 8798 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8799 | |
| 8800 | if (! peer) |
| 8801 | return CMD_WARNING; |
| 8802 | |
| 8803 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 8804 | { |
| 8805 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 8806 | VTY_NEWLINE); |
| 8807 | return CMD_WARNING; |
| 8808 | } |
| 8809 | |
| 8810 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 8811 | PEER_FLAG_RSERVER_CLIENT)) |
| 8812 | { |
| 8813 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 8814 | VTY_NEWLINE); |
| 8815 | return CMD_WARNING; |
| 8816 | } |
| 8817 | |
| 8818 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 8819 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8820 | 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] | 8821 | } |
| 8822 | |
| 8823 | ALIAS (show_ip_bgp_view_rsclient, |
| 8824 | show_ip_bgp_rsclient_cmd, |
| 8825 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 8826 | SHOW_STR |
| 8827 | IP_STR |
| 8828 | BGP_STR |
| 8829 | "Information about Route Server Client\n" |
| 8830 | NEIGHBOR_ADDR_STR) |
| 8831 | |
| 8832 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 8833 | show_ip_bgp_view_rsclient_route_cmd, |
| 8834 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 8835 | SHOW_STR |
| 8836 | IP_STR |
| 8837 | BGP_STR |
| 8838 | "BGP view\n" |
| 8839 | "BGP view name\n" |
| 8840 | "Information about Route Server Client\n" |
| 8841 | NEIGHBOR_ADDR_STR |
| 8842 | "Network in the BGP routing table to display\n") |
| 8843 | { |
| 8844 | struct bgp *bgp; |
| 8845 | struct peer *peer; |
| 8846 | |
| 8847 | /* BGP structure lookup. */ |
| 8848 | if (argc == 3) |
| 8849 | { |
| 8850 | bgp = bgp_lookup_by_name (argv[0]); |
| 8851 | if (bgp == NULL) |
| 8852 | { |
| 8853 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8854 | return CMD_WARNING; |
| 8855 | } |
| 8856 | } |
| 8857 | else |
| 8858 | { |
| 8859 | bgp = bgp_get_default (); |
| 8860 | if (bgp == NULL) |
| 8861 | { |
| 8862 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8863 | return CMD_WARNING; |
| 8864 | } |
| 8865 | } |
| 8866 | |
| 8867 | if (argc == 3) |
| 8868 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8869 | else |
| 8870 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8871 | |
| 8872 | if (! peer) |
| 8873 | return CMD_WARNING; |
| 8874 | |
| 8875 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 8876 | { |
| 8877 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 8878 | VTY_NEWLINE); |
| 8879 | return CMD_WARNING; |
| 8880 | } |
| 8881 | |
| 8882 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 8883 | PEER_FLAG_RSERVER_CLIENT)) |
| 8884 | { |
| 8885 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 8886 | VTY_NEWLINE); |
| 8887 | return CMD_WARNING; |
| 8888 | } |
| 8889 | |
| 8890 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 8891 | (argc == 3) ? argv[2] : argv[1], |
| 8892 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 8893 | } |
| 8894 | |
| 8895 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 8896 | show_ip_bgp_rsclient_route_cmd, |
| 8897 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 8898 | SHOW_STR |
| 8899 | IP_STR |
| 8900 | BGP_STR |
| 8901 | "Information about Route Server Client\n" |
| 8902 | NEIGHBOR_ADDR_STR |
| 8903 | "Network in the BGP routing table to display\n") |
| 8904 | |
| 8905 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 8906 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 8907 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 8908 | SHOW_STR |
| 8909 | IP_STR |
| 8910 | BGP_STR |
| 8911 | "BGP view\n" |
| 8912 | "BGP view name\n" |
| 8913 | "Information about Route Server Client\n" |
| 8914 | NEIGHBOR_ADDR_STR |
| 8915 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8916 | { |
| 8917 | struct bgp *bgp; |
| 8918 | struct peer *peer; |
| 8919 | |
| 8920 | /* BGP structure lookup. */ |
| 8921 | if (argc == 3) |
| 8922 | { |
| 8923 | bgp = bgp_lookup_by_name (argv[0]); |
| 8924 | if (bgp == NULL) |
| 8925 | { |
| 8926 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8927 | return CMD_WARNING; |
| 8928 | } |
| 8929 | } |
| 8930 | else |
| 8931 | { |
| 8932 | bgp = bgp_get_default (); |
| 8933 | if (bgp == NULL) |
| 8934 | { |
| 8935 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8936 | return CMD_WARNING; |
| 8937 | } |
| 8938 | } |
| 8939 | |
| 8940 | if (argc == 3) |
| 8941 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8942 | else |
| 8943 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8944 | |
| 8945 | if (! peer) |
| 8946 | return CMD_WARNING; |
| 8947 | |
| 8948 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 8949 | { |
| 8950 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 8951 | VTY_NEWLINE); |
| 8952 | return CMD_WARNING; |
| 8953 | } |
| 8954 | |
| 8955 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 8956 | PEER_FLAG_RSERVER_CLIENT)) |
| 8957 | { |
| 8958 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 8959 | VTY_NEWLINE); |
| 8960 | return CMD_WARNING; |
| 8961 | } |
| 8962 | |
| 8963 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 8964 | (argc == 3) ? argv[2] : argv[1], |
| 8965 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 8966 | } |
| 8967 | |
| 8968 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 8969 | show_ip_bgp_rsclient_prefix_cmd, |
| 8970 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 8971 | SHOW_STR |
| 8972 | IP_STR |
| 8973 | BGP_STR |
| 8974 | "Information about Route Server Client\n" |
| 8975 | NEIGHBOR_ADDR_STR |
| 8976 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8977 | |
| 8978 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8979 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8980 | DEFUN (show_bgp_view_neighbor_routes, |
| 8981 | show_bgp_view_neighbor_routes_cmd, |
| 8982 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 8983 | SHOW_STR |
| 8984 | BGP_STR |
| 8985 | "BGP view\n" |
| 8986 | "BGP view name\n" |
| 8987 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8988 | "Neighbor to display information about\n" |
| 8989 | "Neighbor to display information about\n" |
| 8990 | "Display routes learned from neighbor\n") |
| 8991 | { |
| 8992 | struct peer *peer; |
| 8993 | |
| 8994 | if (argc == 2) |
| 8995 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8996 | else |
| 8997 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8998 | |
| 8999 | if (! peer) |
| 9000 | return CMD_WARNING; |
| 9001 | |
| 9002 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9003 | bgp_show_type_neighbor); |
| 9004 | } |
| 9005 | |
| 9006 | ALIAS (show_bgp_view_neighbor_routes, |
| 9007 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 9008 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9009 | SHOW_STR |
| 9010 | BGP_STR |
| 9011 | "BGP view\n" |
| 9012 | "BGP view name\n" |
| 9013 | "Address family\n" |
| 9014 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9015 | "Neighbor to display information about\n" |
| 9016 | "Neighbor to display information about\n" |
| 9017 | "Display routes learned from neighbor\n") |
| 9018 | |
| 9019 | DEFUN (show_bgp_view_neighbor_damp, |
| 9020 | show_bgp_view_neighbor_damp_cmd, |
| 9021 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9022 | SHOW_STR |
| 9023 | BGP_STR |
| 9024 | "BGP view\n" |
| 9025 | "BGP view name\n" |
| 9026 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9027 | "Neighbor to display information about\n" |
| 9028 | "Neighbor to display information about\n" |
| 9029 | "Display the dampened routes received from neighbor\n") |
| 9030 | { |
| 9031 | struct peer *peer; |
| 9032 | |
| 9033 | if (argc == 2) |
| 9034 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9035 | else |
| 9036 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9037 | |
| 9038 | if (! peer) |
| 9039 | return CMD_WARNING; |
| 9040 | |
| 9041 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9042 | bgp_show_type_damp_neighbor); |
| 9043 | } |
| 9044 | |
| 9045 | ALIAS (show_bgp_view_neighbor_damp, |
| 9046 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 9047 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9048 | SHOW_STR |
| 9049 | BGP_STR |
| 9050 | "BGP view\n" |
| 9051 | "BGP view name\n" |
| 9052 | "Address family\n" |
| 9053 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9054 | "Neighbor to display information about\n" |
| 9055 | "Neighbor to display information about\n" |
| 9056 | "Display the dampened routes received from neighbor\n") |
| 9057 | |
| 9058 | DEFUN (show_bgp_view_neighbor_flap, |
| 9059 | show_bgp_view_neighbor_flap_cmd, |
| 9060 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9061 | SHOW_STR |
| 9062 | BGP_STR |
| 9063 | "BGP view\n" |
| 9064 | "BGP view name\n" |
| 9065 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9066 | "Neighbor to display information about\n" |
| 9067 | "Neighbor to display information about\n" |
| 9068 | "Display flap statistics of the routes learned from neighbor\n") |
| 9069 | { |
| 9070 | struct peer *peer; |
| 9071 | |
| 9072 | if (argc == 2) |
| 9073 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9074 | else |
| 9075 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9076 | |
| 9077 | if (! peer) |
| 9078 | return CMD_WARNING; |
| 9079 | |
| 9080 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9081 | bgp_show_type_flap_neighbor); |
| 9082 | } |
| 9083 | |
| 9084 | ALIAS (show_bgp_view_neighbor_flap, |
| 9085 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 9086 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9087 | SHOW_STR |
| 9088 | BGP_STR |
| 9089 | "BGP view\n" |
| 9090 | "BGP view name\n" |
| 9091 | "Address family\n" |
| 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 flap statistics of the routes learned from neighbor\n") |
| 9096 | |
| 9097 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9098 | show_bgp_neighbor_routes_cmd, |
| 9099 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9100 | SHOW_STR |
| 9101 | BGP_STR |
| 9102 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9103 | "Neighbor to display information about\n" |
| 9104 | "Neighbor to display information about\n" |
| 9105 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9106 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9107 | |
| 9108 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9109 | show_bgp_ipv6_neighbor_routes_cmd, |
| 9110 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9111 | SHOW_STR |
| 9112 | BGP_STR |
| 9113 | "Address family\n" |
| 9114 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9115 | "Neighbor to display information about\n" |
| 9116 | "Neighbor to display information about\n" |
| 9117 | "Display routes learned from neighbor\n") |
| 9118 | |
| 9119 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9120 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9121 | ipv6_bgp_neighbor_routes_cmd, |
| 9122 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9123 | SHOW_STR |
| 9124 | IPV6_STR |
| 9125 | BGP_STR |
| 9126 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9127 | "Neighbor to display information about\n" |
| 9128 | "Neighbor to display information about\n" |
| 9129 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9130 | |
| 9131 | /* old command */ |
| 9132 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 9133 | ipv6_mbgp_neighbor_routes_cmd, |
| 9134 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9135 | SHOW_STR |
| 9136 | IPV6_STR |
| 9137 | MBGP_STR |
| 9138 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9139 | "Neighbor to display information about\n" |
| 9140 | "Neighbor to display information about\n" |
| 9141 | "Display routes learned from neighbor\n") |
| 9142 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9143 | struct peer *peer; |
| 9144 | |
| 9145 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9146 | if (! peer) |
| 9147 | return CMD_WARNING; |
| 9148 | |
| 9149 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9150 | bgp_show_type_neighbor); |
| 9151 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9152 | |
| 9153 | ALIAS (show_bgp_view_neighbor_flap, |
| 9154 | show_bgp_neighbor_flap_cmd, |
| 9155 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9156 | SHOW_STR |
| 9157 | BGP_STR |
| 9158 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9159 | "Neighbor to display information about\n" |
| 9160 | "Neighbor to display information about\n" |
| 9161 | "Display flap statistics of the routes learned from neighbor\n") |
| 9162 | |
| 9163 | ALIAS (show_bgp_view_neighbor_flap, |
| 9164 | show_bgp_ipv6_neighbor_flap_cmd, |
| 9165 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9166 | SHOW_STR |
| 9167 | BGP_STR |
| 9168 | "Address family\n" |
| 9169 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9170 | "Neighbor to display information about\n" |
| 9171 | "Neighbor to display information about\n" |
| 9172 | "Display flap statistics of the routes learned from neighbor\n") |
| 9173 | |
| 9174 | ALIAS (show_bgp_view_neighbor_damp, |
| 9175 | show_bgp_neighbor_damp_cmd, |
| 9176 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9177 | SHOW_STR |
| 9178 | BGP_STR |
| 9179 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9180 | "Neighbor to display information about\n" |
| 9181 | "Neighbor to display information about\n" |
| 9182 | "Display the dampened routes received from neighbor\n") |
| 9183 | |
| 9184 | ALIAS (show_bgp_view_neighbor_damp, |
| 9185 | show_bgp_ipv6_neighbor_damp_cmd, |
| 9186 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9187 | SHOW_STR |
| 9188 | BGP_STR |
| 9189 | "Address family\n" |
| 9190 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9191 | "Neighbor to display information about\n" |
| 9192 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 9193 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9194 | |
| 9195 | DEFUN (show_bgp_view_rsclient, |
| 9196 | show_bgp_view_rsclient_cmd, |
| 9197 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9198 | SHOW_STR |
| 9199 | BGP_STR |
| 9200 | "BGP view\n" |
| 9201 | "BGP view name\n" |
| 9202 | "Information about Route Server Client\n" |
| 9203 | NEIGHBOR_ADDR_STR) |
| 9204 | { |
| 9205 | struct bgp_table *table; |
| 9206 | struct peer *peer; |
| 9207 | |
| 9208 | if (argc == 2) |
| 9209 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9210 | else |
| 9211 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9212 | |
| 9213 | if (! peer) |
| 9214 | return CMD_WARNING; |
| 9215 | |
| 9216 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9217 | { |
| 9218 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9219 | VTY_NEWLINE); |
| 9220 | return CMD_WARNING; |
| 9221 | } |
| 9222 | |
| 9223 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9224 | PEER_FLAG_RSERVER_CLIENT)) |
| 9225 | { |
| 9226 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9227 | VTY_NEWLINE); |
| 9228 | return CMD_WARNING; |
| 9229 | } |
| 9230 | |
| 9231 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 9232 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9233 | 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] | 9234 | } |
| 9235 | |
| 9236 | ALIAS (show_bgp_view_rsclient, |
| 9237 | show_bgp_rsclient_cmd, |
| 9238 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9239 | SHOW_STR |
| 9240 | BGP_STR |
| 9241 | "Information about Route Server Client\n" |
| 9242 | NEIGHBOR_ADDR_STR) |
| 9243 | |
| 9244 | DEFUN (show_bgp_view_rsclient_route, |
| 9245 | show_bgp_view_rsclient_route_cmd, |
| 9246 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9247 | SHOW_STR |
| 9248 | BGP_STR |
| 9249 | "BGP view\n" |
| 9250 | "BGP view name\n" |
| 9251 | "Information about Route Server Client\n" |
| 9252 | NEIGHBOR_ADDR_STR |
| 9253 | "Network in the BGP routing table to display\n") |
| 9254 | { |
| 9255 | struct bgp *bgp; |
| 9256 | struct peer *peer; |
| 9257 | |
| 9258 | /* BGP structure lookup. */ |
| 9259 | if (argc == 3) |
| 9260 | { |
| 9261 | bgp = bgp_lookup_by_name (argv[0]); |
| 9262 | if (bgp == NULL) |
| 9263 | { |
| 9264 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9265 | return CMD_WARNING; |
| 9266 | } |
| 9267 | } |
| 9268 | else |
| 9269 | { |
| 9270 | bgp = bgp_get_default (); |
| 9271 | if (bgp == NULL) |
| 9272 | { |
| 9273 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9274 | return CMD_WARNING; |
| 9275 | } |
| 9276 | } |
| 9277 | |
| 9278 | if (argc == 3) |
| 9279 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9280 | else |
| 9281 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9282 | |
| 9283 | if (! peer) |
| 9284 | return CMD_WARNING; |
| 9285 | |
| 9286 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9287 | { |
| 9288 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9289 | VTY_NEWLINE); |
| 9290 | return CMD_WARNING; |
| 9291 | } |
| 9292 | |
| 9293 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9294 | PEER_FLAG_RSERVER_CLIENT)) |
| 9295 | { |
| 9296 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9297 | VTY_NEWLINE); |
| 9298 | return CMD_WARNING; |
| 9299 | } |
| 9300 | |
| 9301 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9302 | (argc == 3) ? argv[2] : argv[1], |
| 9303 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 9304 | } |
| 9305 | |
| 9306 | ALIAS (show_bgp_view_rsclient_route, |
| 9307 | show_bgp_rsclient_route_cmd, |
| 9308 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9309 | SHOW_STR |
| 9310 | BGP_STR |
| 9311 | "Information about Route Server Client\n" |
| 9312 | NEIGHBOR_ADDR_STR |
| 9313 | "Network in the BGP routing table to display\n") |
| 9314 | |
| 9315 | DEFUN (show_bgp_view_rsclient_prefix, |
| 9316 | show_bgp_view_rsclient_prefix_cmd, |
| 9317 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9318 | SHOW_STR |
| 9319 | BGP_STR |
| 9320 | "BGP view\n" |
| 9321 | "BGP view name\n" |
| 9322 | "Information about Route Server Client\n" |
| 9323 | NEIGHBOR_ADDR_STR |
| 9324 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9325 | { |
| 9326 | struct bgp *bgp; |
| 9327 | struct peer *peer; |
| 9328 | |
| 9329 | /* BGP structure lookup. */ |
| 9330 | if (argc == 3) |
| 9331 | { |
| 9332 | bgp = bgp_lookup_by_name (argv[0]); |
| 9333 | if (bgp == NULL) |
| 9334 | { |
| 9335 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9336 | return CMD_WARNING; |
| 9337 | } |
| 9338 | } |
| 9339 | else |
| 9340 | { |
| 9341 | bgp = bgp_get_default (); |
| 9342 | if (bgp == NULL) |
| 9343 | { |
| 9344 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9345 | return CMD_WARNING; |
| 9346 | } |
| 9347 | } |
| 9348 | |
| 9349 | if (argc == 3) |
| 9350 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9351 | else |
| 9352 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9353 | |
| 9354 | if (! peer) |
| 9355 | return CMD_WARNING; |
| 9356 | |
| 9357 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9358 | { |
| 9359 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9360 | VTY_NEWLINE); |
| 9361 | return CMD_WARNING; |
| 9362 | } |
| 9363 | |
| 9364 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9365 | PEER_FLAG_RSERVER_CLIENT)) |
| 9366 | { |
| 9367 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9368 | VTY_NEWLINE); |
| 9369 | return CMD_WARNING; |
| 9370 | } |
| 9371 | |
| 9372 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9373 | (argc == 3) ? argv[2] : argv[1], |
| 9374 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 9375 | } |
| 9376 | |
| 9377 | ALIAS (show_bgp_view_rsclient_prefix, |
| 9378 | show_bgp_rsclient_prefix_cmd, |
| 9379 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9380 | SHOW_STR |
| 9381 | BGP_STR |
| 9382 | "Information about Route Server Client\n" |
| 9383 | NEIGHBOR_ADDR_STR |
| 9384 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9385 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9386 | #endif /* HAVE_IPV6 */ |
| 9387 | |
| 9388 | struct bgp_table *bgp_distance_table; |
| 9389 | |
| 9390 | struct bgp_distance |
| 9391 | { |
| 9392 | /* Distance value for the IP source prefix. */ |
| 9393 | u_char distance; |
| 9394 | |
| 9395 | /* Name of the access-list to be matched. */ |
| 9396 | char *access_list; |
| 9397 | }; |
| 9398 | |
| 9399 | struct bgp_distance * |
| 9400 | bgp_distance_new () |
| 9401 | { |
| 9402 | struct bgp_distance *new; |
| 9403 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 9404 | memset (new, 0, sizeof (struct bgp_distance)); |
| 9405 | return new; |
| 9406 | } |
| 9407 | |
| 9408 | void |
| 9409 | bgp_distance_free (struct bgp_distance *bdistance) |
| 9410 | { |
| 9411 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 9412 | } |
| 9413 | |
| 9414 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9415 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 9416 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9417 | { |
| 9418 | int ret; |
| 9419 | struct prefix_ipv4 p; |
| 9420 | u_char distance; |
| 9421 | struct bgp_node *rn; |
| 9422 | struct bgp_distance *bdistance; |
| 9423 | |
| 9424 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9425 | if (ret == 0) |
| 9426 | { |
| 9427 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9428 | return CMD_WARNING; |
| 9429 | } |
| 9430 | |
| 9431 | distance = atoi (distance_str); |
| 9432 | |
| 9433 | /* Get BGP distance node. */ |
| 9434 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 9435 | if (rn->info) |
| 9436 | { |
| 9437 | bdistance = rn->info; |
| 9438 | bgp_unlock_node (rn); |
| 9439 | } |
| 9440 | else |
| 9441 | { |
| 9442 | bdistance = bgp_distance_new (); |
| 9443 | rn->info = bdistance; |
| 9444 | } |
| 9445 | |
| 9446 | /* Set distance value. */ |
| 9447 | bdistance->distance = distance; |
| 9448 | |
| 9449 | /* Reset access-list configuration. */ |
| 9450 | if (bdistance->access_list) |
| 9451 | { |
| 9452 | free (bdistance->access_list); |
| 9453 | bdistance->access_list = NULL; |
| 9454 | } |
| 9455 | if (access_list_str) |
| 9456 | bdistance->access_list = strdup (access_list_str); |
| 9457 | |
| 9458 | return CMD_SUCCESS; |
| 9459 | } |
| 9460 | |
| 9461 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9462 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 9463 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9464 | { |
| 9465 | int ret; |
| 9466 | struct prefix_ipv4 p; |
| 9467 | u_char distance; |
| 9468 | struct bgp_node *rn; |
| 9469 | struct bgp_distance *bdistance; |
| 9470 | |
| 9471 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9472 | if (ret == 0) |
| 9473 | { |
| 9474 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9475 | return CMD_WARNING; |
| 9476 | } |
| 9477 | |
| 9478 | distance = atoi (distance_str); |
| 9479 | |
| 9480 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 9481 | if (! rn) |
| 9482 | { |
| 9483 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 9484 | return CMD_WARNING; |
| 9485 | } |
| 9486 | |
| 9487 | bdistance = rn->info; |
| 9488 | |
| 9489 | if (bdistance->access_list) |
| 9490 | free (bdistance->access_list); |
| 9491 | bgp_distance_free (bdistance); |
| 9492 | |
| 9493 | rn->info = NULL; |
| 9494 | bgp_unlock_node (rn); |
| 9495 | bgp_unlock_node (rn); |
| 9496 | |
| 9497 | return CMD_SUCCESS; |
| 9498 | } |
| 9499 | |
| 9500 | void |
| 9501 | bgp_distance_reset () |
| 9502 | { |
| 9503 | struct bgp_node *rn; |
| 9504 | struct bgp_distance *bdistance; |
| 9505 | |
| 9506 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 9507 | if ((bdistance = rn->info) != NULL) |
| 9508 | { |
| 9509 | if (bdistance->access_list) |
| 9510 | free (bdistance->access_list); |
| 9511 | bgp_distance_free (bdistance); |
| 9512 | rn->info = NULL; |
| 9513 | bgp_unlock_node (rn); |
| 9514 | } |
| 9515 | } |
| 9516 | |
| 9517 | /* Apply BGP information to distance method. */ |
| 9518 | u_char |
| 9519 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 9520 | { |
| 9521 | struct bgp_node *rn; |
| 9522 | struct prefix_ipv4 q; |
| 9523 | struct peer *peer; |
| 9524 | struct bgp_distance *bdistance; |
| 9525 | struct access_list *alist; |
| 9526 | struct bgp_static *bgp_static; |
| 9527 | |
| 9528 | if (! bgp) |
| 9529 | return 0; |
| 9530 | |
| 9531 | if (p->family != AF_INET) |
| 9532 | return 0; |
| 9533 | |
| 9534 | peer = rinfo->peer; |
| 9535 | |
| 9536 | if (peer->su.sa.sa_family != AF_INET) |
| 9537 | return 0; |
| 9538 | |
| 9539 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 9540 | q.family = AF_INET; |
| 9541 | q.prefix = peer->su.sin.sin_addr; |
| 9542 | q.prefixlen = IPV4_MAX_BITLEN; |
| 9543 | |
| 9544 | /* Check source address. */ |
| 9545 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 9546 | if (rn) |
| 9547 | { |
| 9548 | bdistance = rn->info; |
| 9549 | bgp_unlock_node (rn); |
| 9550 | |
| 9551 | if (bdistance->access_list) |
| 9552 | { |
| 9553 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 9554 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 9555 | return bdistance->distance; |
| 9556 | } |
| 9557 | else |
| 9558 | return bdistance->distance; |
| 9559 | } |
| 9560 | |
| 9561 | /* Backdoor check. */ |
| 9562 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 9563 | if (rn) |
| 9564 | { |
| 9565 | bgp_static = rn->info; |
| 9566 | bgp_unlock_node (rn); |
| 9567 | |
| 9568 | if (bgp_static->backdoor) |
| 9569 | { |
| 9570 | if (bgp->distance_local) |
| 9571 | return bgp->distance_local; |
| 9572 | else |
| 9573 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9574 | } |
| 9575 | } |
| 9576 | |
| 9577 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 9578 | { |
| 9579 | if (bgp->distance_ebgp) |
| 9580 | return bgp->distance_ebgp; |
| 9581 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 9582 | } |
| 9583 | else |
| 9584 | { |
| 9585 | if (bgp->distance_ibgp) |
| 9586 | return bgp->distance_ibgp; |
| 9587 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9588 | } |
| 9589 | } |
| 9590 | |
| 9591 | DEFUN (bgp_distance, |
| 9592 | bgp_distance_cmd, |
| 9593 | "distance bgp <1-255> <1-255> <1-255>", |
| 9594 | "Define an administrative distance\n" |
| 9595 | "BGP distance\n" |
| 9596 | "Distance for routes external to the AS\n" |
| 9597 | "Distance for routes internal to the AS\n" |
| 9598 | "Distance for local routes\n") |
| 9599 | { |
| 9600 | struct bgp *bgp; |
| 9601 | |
| 9602 | bgp = vty->index; |
| 9603 | |
| 9604 | bgp->distance_ebgp = atoi (argv[0]); |
| 9605 | bgp->distance_ibgp = atoi (argv[1]); |
| 9606 | bgp->distance_local = atoi (argv[2]); |
| 9607 | return CMD_SUCCESS; |
| 9608 | } |
| 9609 | |
| 9610 | DEFUN (no_bgp_distance, |
| 9611 | no_bgp_distance_cmd, |
| 9612 | "no distance bgp <1-255> <1-255> <1-255>", |
| 9613 | NO_STR |
| 9614 | "Define an administrative distance\n" |
| 9615 | "BGP distance\n" |
| 9616 | "Distance for routes external to the AS\n" |
| 9617 | "Distance for routes internal to the AS\n" |
| 9618 | "Distance for local routes\n") |
| 9619 | { |
| 9620 | struct bgp *bgp; |
| 9621 | |
| 9622 | bgp = vty->index; |
| 9623 | |
| 9624 | bgp->distance_ebgp= 0; |
| 9625 | bgp->distance_ibgp = 0; |
| 9626 | bgp->distance_local = 0; |
| 9627 | return CMD_SUCCESS; |
| 9628 | } |
| 9629 | |
| 9630 | ALIAS (no_bgp_distance, |
| 9631 | no_bgp_distance2_cmd, |
| 9632 | "no distance bgp", |
| 9633 | NO_STR |
| 9634 | "Define an administrative distance\n" |
| 9635 | "BGP distance\n") |
| 9636 | |
| 9637 | DEFUN (bgp_distance_source, |
| 9638 | bgp_distance_source_cmd, |
| 9639 | "distance <1-255> A.B.C.D/M", |
| 9640 | "Define an administrative distance\n" |
| 9641 | "Administrative distance\n" |
| 9642 | "IP source prefix\n") |
| 9643 | { |
| 9644 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 9645 | return CMD_SUCCESS; |
| 9646 | } |
| 9647 | |
| 9648 | DEFUN (no_bgp_distance_source, |
| 9649 | no_bgp_distance_source_cmd, |
| 9650 | "no distance <1-255> A.B.C.D/M", |
| 9651 | NO_STR |
| 9652 | "Define an administrative distance\n" |
| 9653 | "Administrative distance\n" |
| 9654 | "IP source prefix\n") |
| 9655 | { |
| 9656 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 9657 | return CMD_SUCCESS; |
| 9658 | } |
| 9659 | |
| 9660 | DEFUN (bgp_distance_source_access_list, |
| 9661 | bgp_distance_source_access_list_cmd, |
| 9662 | "distance <1-255> A.B.C.D/M WORD", |
| 9663 | "Define an administrative distance\n" |
| 9664 | "Administrative distance\n" |
| 9665 | "IP source prefix\n" |
| 9666 | "Access list name\n") |
| 9667 | { |
| 9668 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 9669 | return CMD_SUCCESS; |
| 9670 | } |
| 9671 | |
| 9672 | DEFUN (no_bgp_distance_source_access_list, |
| 9673 | no_bgp_distance_source_access_list_cmd, |
| 9674 | "no distance <1-255> A.B.C.D/M WORD", |
| 9675 | NO_STR |
| 9676 | "Define an administrative distance\n" |
| 9677 | "Administrative distance\n" |
| 9678 | "IP source prefix\n" |
| 9679 | "Access list name\n") |
| 9680 | { |
| 9681 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 9682 | return CMD_SUCCESS; |
| 9683 | } |
| 9684 | |
| 9685 | DEFUN (bgp_damp_set, |
| 9686 | bgp_damp_set_cmd, |
| 9687 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 9688 | "BGP Specific commands\n" |
| 9689 | "Enable route-flap dampening\n" |
| 9690 | "Half-life time for the penalty\n" |
| 9691 | "Value to start reusing a route\n" |
| 9692 | "Value to start suppressing a route\n" |
| 9693 | "Maximum duration to suppress a stable route\n") |
| 9694 | { |
| 9695 | struct bgp *bgp; |
| 9696 | int half = DEFAULT_HALF_LIFE * 60; |
| 9697 | int reuse = DEFAULT_REUSE; |
| 9698 | int suppress = DEFAULT_SUPPRESS; |
| 9699 | int max = 4 * half; |
| 9700 | |
| 9701 | if (argc == 4) |
| 9702 | { |
| 9703 | half = atoi (argv[0]) * 60; |
| 9704 | reuse = atoi (argv[1]); |
| 9705 | suppress = atoi (argv[2]); |
| 9706 | max = atoi (argv[3]) * 60; |
| 9707 | } |
| 9708 | else if (argc == 1) |
| 9709 | { |
| 9710 | half = atoi (argv[0]) * 60; |
| 9711 | max = 4 * half; |
| 9712 | } |
| 9713 | |
| 9714 | bgp = vty->index; |
| 9715 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 9716 | half, reuse, suppress, max); |
| 9717 | } |
| 9718 | |
| 9719 | ALIAS (bgp_damp_set, |
| 9720 | bgp_damp_set2_cmd, |
| 9721 | "bgp dampening <1-45>", |
| 9722 | "BGP Specific commands\n" |
| 9723 | "Enable route-flap dampening\n" |
| 9724 | "Half-life time for the penalty\n") |
| 9725 | |
| 9726 | ALIAS (bgp_damp_set, |
| 9727 | bgp_damp_set3_cmd, |
| 9728 | "bgp dampening", |
| 9729 | "BGP Specific commands\n" |
| 9730 | "Enable route-flap dampening\n") |
| 9731 | |
| 9732 | DEFUN (bgp_damp_unset, |
| 9733 | bgp_damp_unset_cmd, |
| 9734 | "no bgp dampening", |
| 9735 | NO_STR |
| 9736 | "BGP Specific commands\n" |
| 9737 | "Enable route-flap dampening\n") |
| 9738 | { |
| 9739 | struct bgp *bgp; |
| 9740 | |
| 9741 | bgp = vty->index; |
| 9742 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 9743 | } |
| 9744 | |
| 9745 | ALIAS (bgp_damp_unset, |
| 9746 | bgp_damp_unset2_cmd, |
| 9747 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 9748 | NO_STR |
| 9749 | "BGP Specific commands\n" |
| 9750 | "Enable route-flap dampening\n" |
| 9751 | "Half-life time for the penalty\n" |
| 9752 | "Value to start reusing a route\n" |
| 9753 | "Value to start suppressing a route\n" |
| 9754 | "Maximum duration to suppress a stable route\n") |
| 9755 | |
| 9756 | DEFUN (show_ip_bgp_dampened_paths, |
| 9757 | show_ip_bgp_dampened_paths_cmd, |
| 9758 | "show ip bgp dampened-paths", |
| 9759 | SHOW_STR |
| 9760 | IP_STR |
| 9761 | BGP_STR |
| 9762 | "Display paths suppressed due to dampening\n") |
| 9763 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9764 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 9765 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9766 | } |
| 9767 | |
| 9768 | DEFUN (show_ip_bgp_flap_statistics, |
| 9769 | show_ip_bgp_flap_statistics_cmd, |
| 9770 | "show ip bgp flap-statistics", |
| 9771 | SHOW_STR |
| 9772 | IP_STR |
| 9773 | BGP_STR |
| 9774 | "Display flap statistics of routes\n") |
| 9775 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9776 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9777 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9778 | } |
| 9779 | |
| 9780 | /* Display specified route of BGP table. */ |
| 9781 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9782 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 9783 | const char *ip_str, afi_t afi, safi_t safi, |
| 9784 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9785 | { |
| 9786 | int ret; |
| 9787 | struct prefix match; |
| 9788 | struct bgp_node *rn; |
| 9789 | struct bgp_node *rm; |
| 9790 | struct bgp_info *ri; |
| 9791 | struct bgp_info *ri_temp; |
| 9792 | struct bgp *bgp; |
| 9793 | struct bgp_table *table; |
| 9794 | |
| 9795 | /* BGP structure lookup. */ |
| 9796 | if (view_name) |
| 9797 | { |
| 9798 | bgp = bgp_lookup_by_name (view_name); |
| 9799 | if (bgp == NULL) |
| 9800 | { |
| 9801 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9802 | return CMD_WARNING; |
| 9803 | } |
| 9804 | } |
| 9805 | else |
| 9806 | { |
| 9807 | bgp = bgp_get_default (); |
| 9808 | if (bgp == NULL) |
| 9809 | { |
| 9810 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 9811 | return CMD_WARNING; |
| 9812 | } |
| 9813 | } |
| 9814 | |
| 9815 | /* Check IP address argument. */ |
| 9816 | ret = str2prefix (ip_str, &match); |
| 9817 | if (! ret) |
| 9818 | { |
| 9819 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 9820 | return CMD_WARNING; |
| 9821 | } |
| 9822 | |
| 9823 | match.family = afi2family (afi); |
| 9824 | |
| 9825 | if (safi == SAFI_MPLS_VPN) |
| 9826 | { |
| 9827 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 9828 | { |
| 9829 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 9830 | continue; |
| 9831 | |
| 9832 | if ((table = rn->info) != NULL) |
| 9833 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 9834 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 9835 | { |
| 9836 | ri = rm->info; |
| 9837 | while (ri) |
| 9838 | { |
| 9839 | if (ri->damp_info) |
| 9840 | { |
| 9841 | ri_temp = ri->next; |
| 9842 | bgp_damp_info_free (ri->damp_info, 1); |
| 9843 | ri = ri_temp; |
| 9844 | } |
| 9845 | else |
| 9846 | ri = ri->next; |
| 9847 | } |
| 9848 | } |
| 9849 | } |
| 9850 | } |
| 9851 | else |
| 9852 | { |
| 9853 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 9854 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 9855 | { |
| 9856 | ri = rn->info; |
| 9857 | while (ri) |
| 9858 | { |
| 9859 | if (ri->damp_info) |
| 9860 | { |
| 9861 | ri_temp = ri->next; |
| 9862 | bgp_damp_info_free (ri->damp_info, 1); |
| 9863 | ri = ri_temp; |
| 9864 | } |
| 9865 | else |
| 9866 | ri = ri->next; |
| 9867 | } |
| 9868 | } |
| 9869 | } |
| 9870 | |
| 9871 | return CMD_SUCCESS; |
| 9872 | } |
| 9873 | |
| 9874 | DEFUN (clear_ip_bgp_dampening, |
| 9875 | clear_ip_bgp_dampening_cmd, |
| 9876 | "clear ip bgp dampening", |
| 9877 | CLEAR_STR |
| 9878 | IP_STR |
| 9879 | BGP_STR |
| 9880 | "Clear route flap dampening information\n") |
| 9881 | { |
| 9882 | bgp_damp_info_clean (); |
| 9883 | return CMD_SUCCESS; |
| 9884 | } |
| 9885 | |
| 9886 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 9887 | clear_ip_bgp_dampening_prefix_cmd, |
| 9888 | "clear ip bgp dampening A.B.C.D/M", |
| 9889 | CLEAR_STR |
| 9890 | IP_STR |
| 9891 | BGP_STR |
| 9892 | "Clear route flap dampening information\n" |
| 9893 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9894 | { |
| 9895 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 9896 | SAFI_UNICAST, NULL, 1); |
| 9897 | } |
| 9898 | |
| 9899 | DEFUN (clear_ip_bgp_dampening_address, |
| 9900 | clear_ip_bgp_dampening_address_cmd, |
| 9901 | "clear ip bgp dampening A.B.C.D", |
| 9902 | CLEAR_STR |
| 9903 | IP_STR |
| 9904 | BGP_STR |
| 9905 | "Clear route flap dampening information\n" |
| 9906 | "Network to clear damping information\n") |
| 9907 | { |
| 9908 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 9909 | SAFI_UNICAST, NULL, 0); |
| 9910 | } |
| 9911 | |
| 9912 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 9913 | clear_ip_bgp_dampening_address_mask_cmd, |
| 9914 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 9915 | CLEAR_STR |
| 9916 | IP_STR |
| 9917 | BGP_STR |
| 9918 | "Clear route flap dampening information\n" |
| 9919 | "Network to clear damping information\n" |
| 9920 | "Network mask\n") |
| 9921 | { |
| 9922 | int ret; |
| 9923 | char prefix_str[BUFSIZ]; |
| 9924 | |
| 9925 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 9926 | if (! ret) |
| 9927 | { |
| 9928 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 9929 | return CMD_WARNING; |
| 9930 | } |
| 9931 | |
| 9932 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 9933 | SAFI_UNICAST, NULL, 0); |
| 9934 | } |
| 9935 | |
| 9936 | int |
| 9937 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 9938 | afi_t afi, safi_t safi, int *write) |
| 9939 | { |
| 9940 | struct bgp_node *prn; |
| 9941 | struct bgp_node *rn; |
| 9942 | struct bgp_table *table; |
| 9943 | struct prefix *p; |
| 9944 | struct prefix_rd *prd; |
| 9945 | struct bgp_static *bgp_static; |
| 9946 | u_int32_t label; |
| 9947 | char buf[SU_ADDRSTRLEN]; |
| 9948 | char rdbuf[RD_ADDRSTRLEN]; |
| 9949 | |
| 9950 | /* Network configuration. */ |
| 9951 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 9952 | if ((table = prn->info) != NULL) |
| 9953 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9954 | if ((bgp_static = rn->info) != NULL) |
| 9955 | { |
| 9956 | p = &rn->p; |
| 9957 | prd = (struct prefix_rd *) &prn->p; |
| 9958 | |
| 9959 | /* "address-family" display. */ |
| 9960 | bgp_config_write_family_header (vty, afi, safi, write); |
| 9961 | |
| 9962 | /* "network" configuration display. */ |
| 9963 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 9964 | label = decode_label (bgp_static->tag); |
| 9965 | |
| 9966 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 9967 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 9968 | p->prefixlen, |
| 9969 | rdbuf, label); |
| 9970 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9971 | } |
| 9972 | return 0; |
| 9973 | } |
| 9974 | |
| 9975 | /* Configuration of static route announcement and aggregate |
| 9976 | information. */ |
| 9977 | int |
| 9978 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 9979 | afi_t afi, safi_t safi, int *write) |
| 9980 | { |
| 9981 | struct bgp_node *rn; |
| 9982 | struct prefix *p; |
| 9983 | struct bgp_static *bgp_static; |
| 9984 | struct bgp_aggregate *bgp_aggregate; |
| 9985 | char buf[SU_ADDRSTRLEN]; |
| 9986 | |
| 9987 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 9988 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 9989 | |
| 9990 | /* Network configuration. */ |
| 9991 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 9992 | if ((bgp_static = rn->info) != NULL) |
| 9993 | { |
| 9994 | p = &rn->p; |
| 9995 | |
| 9996 | /* "address-family" display. */ |
| 9997 | bgp_config_write_family_header (vty, afi, safi, write); |
| 9998 | |
| 9999 | /* "network" configuration display. */ |
| 10000 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10001 | { |
| 10002 | u_int32_t destination; |
| 10003 | struct in_addr netmask; |
| 10004 | |
| 10005 | destination = ntohl (p->u.prefix4.s_addr); |
| 10006 | masklen2ip (p->prefixlen, &netmask); |
| 10007 | vty_out (vty, " network %s", |
| 10008 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 10009 | |
| 10010 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 10011 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 10012 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 10013 | || p->u.prefix4.s_addr == 0) |
| 10014 | { |
| 10015 | /* Natural mask is not display. */ |
| 10016 | } |
| 10017 | else |
| 10018 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 10019 | } |
| 10020 | else |
| 10021 | { |
| 10022 | vty_out (vty, " network %s/%d", |
| 10023 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10024 | p->prefixlen); |
| 10025 | } |
| 10026 | |
| 10027 | if (bgp_static->rmap.name) |
| 10028 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 10029 | else if (bgp_static->backdoor) |
| 10030 | vty_out (vty, " backdoor"); |
| 10031 | |
| 10032 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10033 | } |
| 10034 | |
| 10035 | /* Aggregate-address configuration. */ |
| 10036 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10037 | if ((bgp_aggregate = rn->info) != NULL) |
| 10038 | { |
| 10039 | p = &rn->p; |
| 10040 | |
| 10041 | /* "address-family" display. */ |
| 10042 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10043 | |
| 10044 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10045 | { |
| 10046 | struct in_addr netmask; |
| 10047 | |
| 10048 | masklen2ip (p->prefixlen, &netmask); |
| 10049 | vty_out (vty, " aggregate-address %s %s", |
| 10050 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10051 | inet_ntoa (netmask)); |
| 10052 | } |
| 10053 | else |
| 10054 | { |
| 10055 | vty_out (vty, " aggregate-address %s/%d", |
| 10056 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10057 | p->prefixlen); |
| 10058 | } |
| 10059 | |
| 10060 | if (bgp_aggregate->as_set) |
| 10061 | vty_out (vty, " as-set"); |
| 10062 | |
| 10063 | if (bgp_aggregate->summary_only) |
| 10064 | vty_out (vty, " summary-only"); |
| 10065 | |
| 10066 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10067 | } |
| 10068 | |
| 10069 | return 0; |
| 10070 | } |
| 10071 | |
| 10072 | int |
| 10073 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 10074 | { |
| 10075 | struct bgp_node *rn; |
| 10076 | struct bgp_distance *bdistance; |
| 10077 | |
| 10078 | /* Distance configuration. */ |
| 10079 | if (bgp->distance_ebgp |
| 10080 | && bgp->distance_ibgp |
| 10081 | && bgp->distance_local |
| 10082 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 10083 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 10084 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 10085 | vty_out (vty, " distance bgp %d %d %d%s", |
| 10086 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 10087 | VTY_NEWLINE); |
| 10088 | |
| 10089 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 10090 | if ((bdistance = rn->info) != NULL) |
| 10091 | { |
| 10092 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 10093 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 10094 | bdistance->access_list ? bdistance->access_list : "", |
| 10095 | VTY_NEWLINE); |
| 10096 | } |
| 10097 | |
| 10098 | return 0; |
| 10099 | } |
| 10100 | |
| 10101 | /* Allocate routing table structure and install commands. */ |
| 10102 | void |
| 10103 | bgp_route_init () |
| 10104 | { |
| 10105 | /* Init BGP distance table. */ |
| 10106 | bgp_distance_table = bgp_table_init (); |
| 10107 | |
| 10108 | /* IPv4 BGP commands. */ |
| 10109 | install_element (BGP_NODE, &bgp_network_cmd); |
| 10110 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 10111 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 10112 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 10113 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 10114 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10115 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 10116 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 10117 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 10118 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 10119 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 10120 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 10121 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 10122 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10123 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10124 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 10125 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 10126 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 10127 | |
| 10128 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 10129 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 10130 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 10131 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10132 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 10133 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 10134 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 10135 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10136 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 10137 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10138 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 10139 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 10140 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 10141 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10142 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10143 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 10144 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10145 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10146 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10147 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10148 | |
| 10149 | /* IPv4 unicast configuration. */ |
| 10150 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 10151 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 10152 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 10153 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 10154 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 10155 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10156 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 10157 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 10158 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 10159 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 10160 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10161 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10162 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 10163 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 10164 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 10165 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10166 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 10167 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 10168 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 10169 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10170 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 10171 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10172 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 10173 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 10174 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 10175 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10176 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10177 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 10178 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10179 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10180 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10181 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10182 | |
| 10183 | /* IPv4 multicast configuration. */ |
| 10184 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 10185 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 10186 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 10187 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 10188 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 10189 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10190 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 10191 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 10192 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 10193 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 10194 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10195 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10196 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 10197 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 10198 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 10199 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10200 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 10201 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 10202 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 10203 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10204 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 10205 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10206 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 10207 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 10208 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 10209 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10210 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10211 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 10212 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10213 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10214 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10215 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10216 | |
| 10217 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 10218 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 10219 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 10220 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10221 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10222 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10223 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 10224 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10225 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10226 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10227 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 10228 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 10229 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10230 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 10231 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10232 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10233 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10234 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 10235 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10236 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 10237 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10238 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10239 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10240 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 10241 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10242 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 10243 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 10244 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 10245 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 10246 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10247 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10248 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10249 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10250 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 10251 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10252 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10253 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10254 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10255 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10256 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10257 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10258 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 10259 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10260 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10261 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10262 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10263 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10264 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10265 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10266 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10267 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10268 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10269 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10270 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10271 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10272 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10273 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10274 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 10275 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10276 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10277 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10278 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10279 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10280 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10281 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10282 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10283 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10284 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 10285 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10286 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10287 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10288 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10289 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10290 | |
| 10291 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 10292 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 10293 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 10294 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10295 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10296 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10297 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 10298 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10299 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10300 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10301 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 10302 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 10303 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10304 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 10305 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10306 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10307 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10308 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 10309 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10310 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 10311 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10312 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10313 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10314 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 10315 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10316 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 10317 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 10318 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 10319 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 10320 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10321 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10322 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10323 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10324 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 10325 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10326 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10327 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10328 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10329 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10330 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10331 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10332 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 10333 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10334 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10335 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10336 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10337 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10338 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10339 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10340 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10341 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10342 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10343 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10344 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10345 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10346 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10347 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10348 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 10349 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10350 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10351 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10352 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10353 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10354 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10355 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10356 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10357 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10358 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 10359 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10360 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10361 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10362 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10363 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10364 | |
| 10365 | /* BGP dampening clear commands */ |
| 10366 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 10367 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 10368 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 10369 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 10370 | |
| 10371 | #ifdef HAVE_IPV6 |
| 10372 | /* New config IPv6 BGP commands. */ |
| 10373 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 10374 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 10375 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 10376 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 10377 | |
| 10378 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 10379 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 10380 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 10381 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 10382 | |
| 10383 | /* Old config IPv6 BGP commands. */ |
| 10384 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 10385 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 10386 | |
| 10387 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 10388 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 10389 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 10390 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 10391 | |
| 10392 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 10393 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 10394 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 10395 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 10396 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 10397 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10398 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 10399 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10400 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 10401 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10402 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 10403 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10404 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 10405 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10406 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 10407 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10408 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 10409 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 10410 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 10411 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 10412 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 10413 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 10414 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 10415 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 10416 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 10417 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10418 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 10419 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10420 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 10421 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10422 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 10423 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10424 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 10425 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10426 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 10427 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10428 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 10429 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10430 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10431 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10432 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10433 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10434 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 10435 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10436 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10437 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10438 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 10439 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10440 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 10441 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10442 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 10443 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 10444 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10445 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 10446 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 10447 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 10448 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10449 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 10450 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10451 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10452 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10453 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10454 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10455 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10456 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10457 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10458 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10459 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10460 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10461 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10462 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10463 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 10464 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10465 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10466 | |
| 10467 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 10468 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 10469 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 10470 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 10471 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 10472 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10473 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 10474 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10475 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 10476 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10477 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 10478 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10479 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 10480 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10481 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 10482 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10483 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 10484 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 10485 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 10486 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 10487 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 10488 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 10489 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 10490 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 10491 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 10492 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10493 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 10494 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10495 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 10496 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10497 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 10498 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10499 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 10500 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10501 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 10502 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10503 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 10504 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10505 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10506 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10507 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10508 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10509 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 10510 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10511 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10512 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10513 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 10514 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10515 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 10516 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10517 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 10518 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 10519 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10520 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 10521 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 10522 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 10523 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10524 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 10525 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10526 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10527 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10528 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10529 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10530 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10531 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10532 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10533 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10534 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10535 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10536 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10537 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10538 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 10539 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10540 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10541 | |
| 10542 | /* old command */ |
| 10543 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 10544 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 10545 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10546 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10547 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10548 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10549 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10550 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 10551 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 10552 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 10553 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 10554 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10555 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10556 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10557 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10558 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10559 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10560 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10561 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 10562 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 10563 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10564 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10565 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10566 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10567 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10568 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 10569 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10570 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10571 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10572 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10573 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10574 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10575 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10576 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10577 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10578 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10579 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10580 | /* old command */ |
| 10581 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 10582 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 10583 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10584 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10585 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10586 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10587 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10588 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 10589 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 10590 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 10591 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 10592 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10593 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10594 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10595 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10596 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10597 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10598 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10599 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 10600 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 10601 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10602 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10603 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10604 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10605 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10606 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 10607 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10608 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10609 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10610 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10611 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10612 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10613 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10614 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10615 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10616 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 10617 | |
| 10618 | /* old command */ |
| 10619 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10620 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10621 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10622 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10623 | |
| 10624 | /* old command */ |
| 10625 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10626 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10627 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10628 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10629 | |
| 10630 | /* old command */ |
| 10631 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10632 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10633 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10634 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10635 | #endif /* HAVE_IPV6 */ |
| 10636 | |
| 10637 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 10638 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 10639 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 10640 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 10641 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 10642 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 10643 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 10644 | |
| 10645 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 10646 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 10647 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 10648 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 10649 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 10650 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 10651 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 10652 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 10653 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 10654 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 10655 | } |