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 | { |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 216 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 217 | { |
| 218 | if ((new->attr->aspath->count + |
| 219 | new->attr->aspath->confed_count) |
| 220 | < (exist->attr->aspath->count + |
| 221 | exist->attr->aspath->confed_count)) |
| 222 | return 1; |
| 223 | if ((new->attr->aspath->count + |
| 224 | new->attr->aspath->confed_count) |
| 225 | > (exist->attr->aspath->count + |
| 226 | exist->attr->aspath->confed_count)) |
| 227 | return 0; |
| 228 | } |
| 229 | else |
| 230 | { |
| 231 | if (new->attr->aspath->count < exist->attr->aspath->count) |
| 232 | return 1; |
| 233 | if (new->attr->aspath->count > exist->attr->aspath->count) |
| 234 | return 0; |
| 235 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /* 5. Origin check. */ |
| 239 | if (new->attr->origin < exist->attr->origin) |
| 240 | return 1; |
| 241 | if (new->attr->origin > exist->attr->origin) |
| 242 | return 0; |
| 243 | |
| 244 | /* 6. MED check. */ |
| 245 | internal_as_route = (new->attr->aspath->length == 0 |
| 246 | && exist->attr->aspath->length == 0); |
| 247 | confed_as_route = (new->attr->aspath->length > 0 |
| 248 | && exist->attr->aspath->length > 0 |
| 249 | && new->attr->aspath->count == 0 |
| 250 | && exist->attr->aspath->count == 0); |
| 251 | |
| 252 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 253 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 254 | && confed_as_route) |
| 255 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 256 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 257 | || internal_as_route) |
| 258 | { |
| 259 | new_med = bgp_med_value (new->attr, bgp); |
| 260 | exist_med = bgp_med_value (exist->attr, bgp); |
| 261 | |
| 262 | if (new_med < exist_med) |
| 263 | return 1; |
| 264 | if (new_med > exist_med) |
| 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | /* 7. Peer type check. */ |
| 269 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 270 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 271 | return 1; |
| 272 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 273 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 274 | return 1; |
| 275 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 276 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 277 | return 0; |
| 278 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 279 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 280 | return 0; |
| 281 | |
| 282 | /* 8. IGP metric check. */ |
| 283 | if (new->igpmetric < exist->igpmetric) |
| 284 | return 1; |
| 285 | if (new->igpmetric > exist->igpmetric) |
| 286 | return 0; |
| 287 | |
| 288 | /* 9. Maximum path check. */ |
| 289 | |
| 290 | /* 10. If both paths are external, prefer the path that was received |
| 291 | first (the oldest one). This step minimizes route-flap, since a |
| 292 | newer path won't displace an older one, even if it was the |
| 293 | preferred route based on the additional decision criteria below. */ |
| 294 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 295 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 296 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 297 | { |
| 298 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 299 | return 1; |
| 300 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | /* 11. Rourter-ID comparision. */ |
| 305 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 306 | new_id.s_addr = new->attr->originator_id.s_addr; |
| 307 | else |
| 308 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 309 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 310 | exist_id.s_addr = exist->attr->originator_id.s_addr; |
| 311 | else |
| 312 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 313 | |
| 314 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 315 | return 1; |
| 316 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 317 | return 0; |
| 318 | |
| 319 | /* 12. Cluster length comparision. */ |
| 320 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 321 | new_cluster = new->attr->cluster->length; |
| 322 | else |
| 323 | new_cluster = 0; |
| 324 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 325 | exist_cluster = exist->attr->cluster->length; |
| 326 | else |
| 327 | exist_cluster = 0; |
| 328 | |
| 329 | if (new_cluster < exist_cluster) |
| 330 | return 1; |
| 331 | if (new_cluster > exist_cluster) |
| 332 | return 0; |
| 333 | |
| 334 | /* 13. Neighbor address comparision. */ |
| 335 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 336 | |
| 337 | if (ret == 1) |
| 338 | return 0; |
| 339 | if (ret == -1) |
| 340 | return 1; |
| 341 | |
| 342 | return 1; |
| 343 | } |
| 344 | |
| 345 | enum filter_type |
| 346 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 347 | afi_t afi, safi_t safi) |
| 348 | { |
| 349 | struct bgp_filter *filter; |
| 350 | |
| 351 | filter = &peer->filter[afi][safi]; |
| 352 | |
| 353 | if (DISTRIBUTE_IN_NAME (filter)) |
| 354 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 355 | return FILTER_DENY; |
| 356 | |
| 357 | if (PREFIX_LIST_IN_NAME (filter)) |
| 358 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 359 | return FILTER_DENY; |
| 360 | |
| 361 | if (FILTER_LIST_IN_NAME (filter)) |
| 362 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 363 | return FILTER_DENY; |
| 364 | |
| 365 | return FILTER_PERMIT; |
| 366 | } |
| 367 | |
| 368 | enum filter_type |
| 369 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 370 | afi_t afi, safi_t safi) |
| 371 | { |
| 372 | struct bgp_filter *filter; |
| 373 | |
| 374 | filter = &peer->filter[afi][safi]; |
| 375 | |
| 376 | if (DISTRIBUTE_OUT_NAME (filter)) |
| 377 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 378 | return FILTER_DENY; |
| 379 | |
| 380 | if (PREFIX_LIST_OUT_NAME (filter)) |
| 381 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 382 | return FILTER_DENY; |
| 383 | |
| 384 | if (FILTER_LIST_OUT_NAME (filter)) |
| 385 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 386 | return FILTER_DENY; |
| 387 | |
| 388 | return FILTER_PERMIT; |
| 389 | } |
| 390 | |
| 391 | /* If community attribute includes no_export then return 1. */ |
| 392 | int |
| 393 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 394 | { |
| 395 | if (attr->community) |
| 396 | { |
| 397 | /* NO_ADVERTISE check. */ |
| 398 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 399 | return 1; |
| 400 | |
| 401 | /* NO_EXPORT check. */ |
| 402 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 403 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 404 | return 1; |
| 405 | |
| 406 | /* NO_EXPORT_SUBCONFED check. */ |
| 407 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 408 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 409 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 410 | return 1; |
| 411 | } |
| 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | /* Route reflection loop check. */ |
| 416 | static int |
| 417 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 418 | { |
| 419 | struct in_addr cluster_id; |
| 420 | |
| 421 | if (attr->cluster) |
| 422 | { |
| 423 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 424 | cluster_id = peer->bgp->cluster_id; |
| 425 | else |
| 426 | cluster_id = peer->bgp->router_id; |
| 427 | |
| 428 | if (cluster_loop_check (attr->cluster, cluster_id)) |
| 429 | return 1; |
| 430 | } |
| 431 | return 0; |
| 432 | } |
| 433 | |
| 434 | int |
| 435 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 436 | afi_t afi, safi_t safi) |
| 437 | { |
| 438 | struct bgp_filter *filter; |
| 439 | struct bgp_info info; |
| 440 | route_map_result_t ret; |
| 441 | |
| 442 | filter = &peer->filter[afi][safi]; |
| 443 | |
| 444 | /* Apply default weight value. */ |
| 445 | attr->weight = peer->weight; |
| 446 | |
| 447 | /* Route map apply. */ |
| 448 | if (ROUTE_MAP_IN_NAME (filter)) |
| 449 | { |
| 450 | /* Duplicate current value to new strucutre for modification. */ |
| 451 | info.peer = peer; |
| 452 | info.attr = attr; |
| 453 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 454 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 455 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 456 | /* Apply BGP route map to the attribute. */ |
| 457 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 458 | |
| 459 | peer->rmap_type = 0; |
| 460 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 461 | if (ret == RMAP_DENYMATCH) |
| 462 | { |
| 463 | /* Free newly generated AS path and community by route-map. */ |
| 464 | bgp_attr_flush (attr); |
| 465 | return RMAP_DENY; |
| 466 | } |
| 467 | } |
| 468 | return RMAP_PERMIT; |
| 469 | } |
| 470 | |
| 471 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 472 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 473 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 474 | { |
| 475 | struct bgp_filter *filter; |
| 476 | struct bgp_info info; |
| 477 | route_map_result_t ret; |
| 478 | |
| 479 | filter = &peer->filter[afi][safi]; |
| 480 | |
| 481 | /* Route map apply. */ |
| 482 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 483 | { |
| 484 | /* Duplicate current value to new strucutre for modification. */ |
| 485 | info.peer = rsclient; |
| 486 | info.attr = attr; |
| 487 | |
| 488 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 489 | |
| 490 | /* Apply BGP route map to the attribute. */ |
| 491 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 492 | |
| 493 | rsclient->rmap_type = 0; |
| 494 | |
| 495 | if (ret == RMAP_DENYMATCH) |
| 496 | { |
| 497 | /* Free newly generated AS path and community by route-map. */ |
| 498 | bgp_attr_flush (attr); |
| 499 | return RMAP_DENY; |
| 500 | } |
| 501 | } |
| 502 | return RMAP_PERMIT; |
| 503 | } |
| 504 | |
| 505 | int |
| 506 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 507 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 508 | { |
| 509 | struct bgp_filter *filter; |
| 510 | struct bgp_info info; |
| 511 | route_map_result_t ret; |
| 512 | |
| 513 | filter = &rsclient->filter[afi][safi]; |
| 514 | |
| 515 | /* Apply default weight value. */ |
| 516 | attr->weight = peer->weight; |
| 517 | |
| 518 | /* Route map apply. */ |
| 519 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 520 | { |
| 521 | /* Duplicate current value to new strucutre for modification. */ |
| 522 | info.peer = peer; |
| 523 | info.attr = attr; |
| 524 | |
| 525 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 526 | |
| 527 | /* Apply BGP route map to the attribute. */ |
| 528 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 529 | |
| 530 | peer->rmap_type = 0; |
| 531 | |
| 532 | if (ret == RMAP_DENYMATCH) |
| 533 | { |
| 534 | /* Free newly generated AS path and community by route-map. */ |
| 535 | bgp_attr_flush (attr); |
| 536 | return RMAP_DENY; |
| 537 | } |
| 538 | } |
| 539 | return RMAP_PERMIT; |
| 540 | } |
| 541 | |
| 542 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 543 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 544 | struct attr *attr, afi_t afi, safi_t safi) |
| 545 | { |
| 546 | int ret; |
| 547 | char buf[SU_ADDRSTRLEN]; |
| 548 | struct bgp_filter *filter; |
| 549 | struct bgp_info info; |
| 550 | struct peer *from; |
| 551 | struct bgp *bgp; |
| 552 | struct attr dummy_attr; |
| 553 | int transparent; |
| 554 | int reflect; |
| 555 | |
| 556 | from = ri->peer; |
| 557 | filter = &peer->filter[afi][safi]; |
| 558 | bgp = peer->bgp; |
| 559 | |
| 560 | #ifdef DISABLE_BGP_ANNOUNCE |
| 561 | return 0; |
| 562 | #endif |
| 563 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 564 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 565 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 566 | return 0; |
| 567 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 568 | /* Do not send back route to sender. */ |
| 569 | if (from == peer) |
| 570 | return 0; |
| 571 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 572 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 573 | if (p->family == AF_INET |
| 574 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 575 | return 0; |
| 576 | #ifdef HAVE_IPV6 |
| 577 | if (p->family == AF_INET6 |
| 578 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 579 | return 0; |
| 580 | #endif |
| 581 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 582 | /* Aggregate-address suppress check. */ |
| 583 | if (ri->suppress) |
| 584 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 585 | return 0; |
| 586 | |
| 587 | /* Default route check. */ |
| 588 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 589 | { |
| 590 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 591 | return 0; |
| 592 | #ifdef HAVE_IPV6 |
| 593 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 594 | return 0; |
| 595 | #endif /* HAVE_IPV6 */ |
| 596 | } |
| 597 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 598 | /* Transparency check. */ |
| 599 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 600 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 601 | transparent = 1; |
| 602 | else |
| 603 | transparent = 0; |
| 604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | /* If community is not disabled check the no-export and local. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 606 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 607 | return 0; |
| 608 | |
| 609 | /* If the attribute has originator-id and it is same as remote |
| 610 | peer's id. */ |
| 611 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 612 | { |
| 613 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id)) |
| 614 | { |
| 615 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 616 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 617 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 618 | peer->host, |
| 619 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 620 | p->prefixlen); |
| 621 | return 0; |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | /* ORF prefix-list filter check */ |
| 626 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 627 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 628 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 629 | if (peer->orf_plist[afi][safi]) |
| 630 | { |
| 631 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | /* Output filter check. */ |
| 636 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) |
| 637 | { |
| 638 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 639 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 640 | "%s [Update:SEND] %s/%d is filtered", |
| 641 | peer->host, |
| 642 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 643 | p->prefixlen); |
| 644 | return 0; |
| 645 | } |
| 646 | |
| 647 | #ifdef BGP_SEND_ASPATH_CHECK |
| 648 | /* AS path loop check. */ |
| 649 | if (aspath_loop_check (ri->attr->aspath, peer->as)) |
| 650 | { |
| 651 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 652 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 653 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 654 | peer->host, peer->as); |
| 655 | return 0; |
| 656 | } |
| 657 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 658 | |
| 659 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 660 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 661 | { |
| 662 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) |
| 663 | { |
| 664 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 665 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 666 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 667 | peer->host, |
| 668 | bgp->confed_id); |
| 669 | return 0; |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | /* Route-Reflect check. */ |
| 674 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 675 | reflect = 1; |
| 676 | else |
| 677 | reflect = 0; |
| 678 | |
| 679 | /* IBGP reflection check. */ |
| 680 | if (reflect) |
| 681 | { |
| 682 | /* A route from a Client peer. */ |
| 683 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 684 | { |
| 685 | /* Reflect to all the Non-Client peers and also to the |
| 686 | Client peers other than the originator. Originator check |
| 687 | is already done. So there is noting to do. */ |
| 688 | /* no bgp client-to-client reflection check. */ |
| 689 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 690 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 691 | return 0; |
| 692 | } |
| 693 | else |
| 694 | { |
| 695 | /* A route from a Non-client peer. Reflect to all other |
| 696 | clients. */ |
| 697 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 698 | return 0; |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | /* For modify attribute, copy it to temporary structure. */ |
| 703 | *attr = *ri->attr; |
| 704 | |
| 705 | /* If local-preference is not set. */ |
| 706 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 707 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 708 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 709 | { |
| 710 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 711 | attr->local_pref = bgp->default_local_pref; |
| 712 | } |
| 713 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 714 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 715 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 716 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 717 | { |
| 718 | if (ri->peer != bgp->peer_self && ! transparent |
| 719 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 720 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 721 | } |
| 722 | |
| 723 | /* next-hop-set */ |
| 724 | if (transparent || reflect |
| 725 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 726 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 727 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 728 | || (p->family == AF_INET6 && |
| 729 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 730 | #endif /* HAVE_IPV6 */ |
| 731 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 732 | { |
| 733 | /* NEXT-HOP Unchanged. */ |
| 734 | } |
| 735 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 736 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 737 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 738 | || (p->family == AF_INET6 && |
| 739 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 740 | #endif /* HAVE_IPV6 */ |
| 741 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 742 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 743 | { |
| 744 | /* Set IPv4 nexthop. */ |
| 745 | if (p->family == AF_INET) |
| 746 | { |
| 747 | if (safi == SAFI_MPLS_VPN) |
| 748 | memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 749 | else |
| 750 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 751 | } |
| 752 | #ifdef HAVE_IPV6 |
| 753 | /* Set IPv6 nexthop. */ |
| 754 | if (p->family == AF_INET6) |
| 755 | { |
| 756 | /* IPv6 global nexthop must be included. */ |
| 757 | memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global, |
| 758 | IPV6_MAX_BYTELEN); |
| 759 | attr->mp_nexthop_len = 16; |
| 760 | } |
| 761 | #endif /* HAVE_IPV6 */ |
| 762 | } |
| 763 | |
| 764 | #ifdef HAVE_IPV6 |
| 765 | if (p->family == AF_INET6) |
| 766 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 767 | /* Left nexthop_local unchanged if so configured. */ |
| 768 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 769 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 770 | { |
| 771 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 772 | attr->mp_nexthop_len=32; |
| 773 | else |
| 774 | attr->mp_nexthop_len=16; |
| 775 | } |
| 776 | |
| 777 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 778 | else |
| 779 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 780 | /* Link-local address should not be transit to different peer. */ |
| 781 | attr->mp_nexthop_len = 16; |
| 782 | |
| 783 | /* Set link-local address for shared network peer. */ |
| 784 | if (peer->shared_network |
| 785 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 786 | { |
| 787 | memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local, |
| 788 | IPV6_MAX_BYTELEN); |
| 789 | attr->mp_nexthop_len = 32; |
| 790 | } |
| 791 | |
| 792 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 793 | address.*/ |
| 794 | if (reflect) |
| 795 | attr->mp_nexthop_len = 16; |
| 796 | |
| 797 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 798 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
| 799 | attr->mp_nexthop_len = 16; |
| 800 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 801 | |
| 802 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 803 | #endif /* HAVE_IPV6 */ |
| 804 | |
| 805 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 806 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 807 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 808 | && aspath_private_as_check (attr->aspath)) |
| 809 | attr->aspath = aspath_empty_get (); |
| 810 | |
| 811 | /* Route map & unsuppress-map apply. */ |
| 812 | if (ROUTE_MAP_OUT_NAME (filter) |
| 813 | || ri->suppress) |
| 814 | { |
| 815 | info.peer = peer; |
| 816 | info.attr = attr; |
| 817 | |
| 818 | /* The route reflector is not allowed to modify the attributes |
| 819 | of the reflected IBGP routes. */ |
| 820 | if (peer_sort (from) == BGP_PEER_IBGP |
| 821 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 822 | { |
| 823 | dummy_attr = *attr; |
| 824 | info.attr = &dummy_attr; |
| 825 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 826 | |
| 827 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 828 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 829 | if (ri->suppress) |
| 830 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 831 | else |
| 832 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 833 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 834 | peer->rmap_type = 0; |
| 835 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | if (ret == RMAP_DENYMATCH) |
| 837 | { |
| 838 | bgp_attr_flush (attr); |
| 839 | return 0; |
| 840 | } |
| 841 | } |
| 842 | return 1; |
| 843 | } |
| 844 | |
| 845 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 846 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 847 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 849 | int ret; |
| 850 | char buf[SU_ADDRSTRLEN]; |
| 851 | struct bgp_filter *filter; |
| 852 | struct bgp_info info; |
| 853 | struct peer *from; |
| 854 | struct bgp *bgp; |
| 855 | |
| 856 | from = ri->peer; |
| 857 | filter = &rsclient->filter[afi][safi]; |
| 858 | bgp = rsclient->bgp; |
| 859 | |
| 860 | #ifdef DISABLE_BGP_ANNOUNCE |
| 861 | return 0; |
| 862 | #endif |
| 863 | |
| 864 | /* Do not send back route to sender. */ |
| 865 | if (from == rsclient) |
| 866 | return 0; |
| 867 | |
| 868 | /* Aggregate-address suppress check. */ |
| 869 | if (ri->suppress) |
| 870 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 871 | return 0; |
| 872 | |
| 873 | /* Default route check. */ |
| 874 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 875 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 876 | { |
| 877 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 878 | return 0; |
| 879 | #ifdef HAVE_IPV6 |
| 880 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 881 | return 0; |
| 882 | #endif /* HAVE_IPV6 */ |
| 883 | } |
| 884 | |
| 885 | /* If the attribute has originator-id and it is same as remote |
| 886 | peer's id. */ |
| 887 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 888 | { |
| 889 | if (IPV4_ADDR_SAME (&rsclient->remote_id, &ri->attr->originator_id)) |
| 890 | { |
| 891 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 892 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 893 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 894 | rsclient->host, |
| 895 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 896 | p->prefixlen); |
| 897 | return 0; |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | /* ORF prefix-list filter check */ |
| 902 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 903 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 904 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 905 | if (rsclient->orf_plist[afi][safi]) |
| 906 | { |
| 907 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | /* Output filter check. */ |
| 912 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) |
| 913 | { |
| 914 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 915 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 916 | "%s [Update:SEND] %s/%d is filtered", |
| 917 | rsclient->host, |
| 918 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 919 | p->prefixlen); |
| 920 | return 0; |
| 921 | } |
| 922 | |
| 923 | #ifdef BGP_SEND_ASPATH_CHECK |
| 924 | /* AS path loop check. */ |
| 925 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) |
| 926 | { |
| 927 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 928 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 929 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 930 | rsclient->host, rsclient->as); |
| 931 | return 0; |
| 932 | } |
| 933 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 934 | |
| 935 | /* For modify attribute, copy it to temporary structure. */ |
| 936 | *attr = *ri->attr; |
| 937 | |
| 938 | /* next-hop-set */ |
| 939 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 940 | #ifdef HAVE_IPV6 |
| 941 | || (p->family == AF_INET6 && |
| 942 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
| 943 | #endif /* HAVE_IPV6 */ |
| 944 | ) |
| 945 | { |
| 946 | /* Set IPv4 nexthop. */ |
| 947 | if (p->family == AF_INET) |
| 948 | { |
| 949 | if (safi == SAFI_MPLS_VPN) |
| 950 | memcpy (&attr->mp_nexthop_global_in, &rsclient->nexthop.v4, |
| 951 | IPV4_MAX_BYTELEN); |
| 952 | else |
| 953 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 954 | } |
| 955 | #ifdef HAVE_IPV6 |
| 956 | /* Set IPv6 nexthop. */ |
| 957 | if (p->family == AF_INET6) |
| 958 | { |
| 959 | /* IPv6 global nexthop must be included. */ |
| 960 | memcpy (&attr->mp_nexthop_global, &rsclient->nexthop.v6_global, |
| 961 | |
| 962 | IPV6_MAX_BYTELEN); |
| 963 | attr->mp_nexthop_len = 16; |
| 964 | } |
| 965 | #endif /* HAVE_IPV6 */ |
| 966 | } |
| 967 | |
| 968 | #ifdef HAVE_IPV6 |
| 969 | if (p->family == AF_INET6) |
| 970 | { |
| 971 | /* Left nexthop_local unchanged if so configured. */ |
| 972 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 973 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 974 | { |
| 975 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 976 | attr->mp_nexthop_len=32; |
| 977 | else |
| 978 | attr->mp_nexthop_len=16; |
| 979 | } |
| 980 | |
| 981 | /* Default nexthop_local treatment for RS-Clients */ |
| 982 | else |
| 983 | { |
| 984 | /* Announcer and RS-Client are both in the same network */ |
| 985 | if (rsclient->shared_network && from->shared_network && |
| 986 | (rsclient->ifindex == from->ifindex)) |
| 987 | { |
| 988 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 989 | attr->mp_nexthop_len=32; |
| 990 | else |
| 991 | attr->mp_nexthop_len=16; |
| 992 | } |
| 993 | |
| 994 | /* Set link-local address for shared network peer. */ |
| 995 | else if (rsclient->shared_network |
| 996 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 997 | { |
| 998 | memcpy (&attr->mp_nexthop_local, &rsclient->nexthop.v6_local, |
| 999 | IPV6_MAX_BYTELEN); |
| 1000 | attr->mp_nexthop_len = 32; |
| 1001 | } |
| 1002 | |
| 1003 | else |
| 1004 | attr->mp_nexthop_len = 16; |
| 1005 | } |
| 1006 | |
| 1007 | } |
| 1008 | #endif /* HAVE_IPV6 */ |
| 1009 | |
| 1010 | |
| 1011 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1012 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 1013 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1014 | && aspath_private_as_check (attr->aspath)) |
| 1015 | attr->aspath = aspath_empty_get (); |
| 1016 | |
| 1017 | /* Route map & unsuppress-map apply. */ |
| 1018 | if (ROUTE_MAP_OUT_NAME (filter) || ri->suppress) |
| 1019 | { |
| 1020 | info.peer = rsclient; |
| 1021 | info.attr = attr; |
| 1022 | |
| 1023 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1024 | |
| 1025 | if (ri->suppress) |
| 1026 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1027 | else |
| 1028 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1029 | |
| 1030 | rsclient->rmap_type = 0; |
| 1031 | |
| 1032 | if (ret == RMAP_DENYMATCH) |
| 1033 | { |
| 1034 | bgp_attr_flush (attr); |
| 1035 | return 0; |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | return 1; |
| 1040 | } |
| 1041 | |
| 1042 | struct bgp_info_pair |
| 1043 | { |
| 1044 | struct bgp_info *old; |
| 1045 | struct bgp_info *new; |
| 1046 | }; |
| 1047 | |
| 1048 | void |
| 1049 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
| 1050 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1051 | struct bgp_info *new_select; |
| 1052 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1053 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1054 | struct bgp_info *ri1; |
| 1055 | struct bgp_info *ri2; |
| 1056 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1057 | /* bgp deterministic-med */ |
| 1058 | new_select = NULL; |
| 1059 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1060 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1061 | { |
| 1062 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1063 | continue; |
| 1064 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1065 | continue; |
| 1066 | |
| 1067 | new_select = ri1; |
| 1068 | if (ri1->next) |
| 1069 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1070 | { |
| 1071 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1072 | continue; |
| 1073 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1074 | continue; |
| 1075 | |
| 1076 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1077 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1078 | ri2->attr->aspath)) |
| 1079 | { |
| 1080 | if (bgp_info_cmp (bgp, ri2, new_select)) |
| 1081 | { |
| 1082 | UNSET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1083 | new_select = ri2; |
| 1084 | } |
| 1085 | |
| 1086 | SET_FLAG (ri2->flags, BGP_INFO_DMED_CHECK); |
| 1087 | } |
| 1088 | } |
| 1089 | SET_FLAG (new_select->flags, BGP_INFO_DMED_CHECK); |
| 1090 | SET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1091 | } |
| 1092 | |
| 1093 | /* Check old selected route and new selected route. */ |
| 1094 | old_select = NULL; |
| 1095 | new_select = NULL; |
| 1096 | for (ri = rn->info; ri; ri = ri->next) |
| 1097 | { |
| 1098 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1099 | old_select = ri; |
| 1100 | |
| 1101 | if (BGP_INFO_HOLDDOWN (ri)) |
| 1102 | continue; |
| 1103 | |
| 1104 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1105 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1106 | { |
| 1107 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1108 | continue; |
| 1109 | } |
| 1110 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1111 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_SELECTED); |
| 1112 | |
| 1113 | if (bgp_info_cmp (bgp, ri, new_select)) |
| 1114 | new_select = ri; |
| 1115 | } |
| 1116 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1117 | result->old = old_select; |
| 1118 | result->new = new_select; |
| 1119 | |
| 1120 | return; |
| 1121 | } |
| 1122 | |
| 1123 | int |
| 1124 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
| 1125 | struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi) |
| 1126 | { |
| 1127 | struct prefix *p; |
| 1128 | |
| 1129 | p = &rn->p; |
| 1130 | |
| 1131 | /* Announce route to Established peer. */ |
| 1132 | if (peer->status != Established) |
| 1133 | return 0; |
| 1134 | |
| 1135 | /* Address family configuration check. */ |
| 1136 | if (! peer->afc_nego[afi][safi]) |
| 1137 | return 0; |
| 1138 | |
| 1139 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 1140 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1141 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1142 | return 0; |
| 1143 | |
| 1144 | switch (rn->table->type) |
| 1145 | { |
| 1146 | case BGP_TABLE_MAIN: |
| 1147 | /* Announcement to peer->conf. If the route is filtered, |
| 1148 | withdraw it. */ |
| 1149 | if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi)) |
| 1150 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1151 | else |
| 1152 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1153 | break; |
| 1154 | case BGP_TABLE_RSCLIENT: |
| 1155 | /* Announcement to peer->conf. If the route is filtered, |
| 1156 | withdraw it. */ |
| 1157 | if (selected && bgp_announce_check_rsclient |
| 1158 | (selected, peer, p, attr, afi, safi)) |
| 1159 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1160 | else |
| 1161 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1162 | break; |
| 1163 | } |
| 1164 | return 0; |
| 1165 | } |
| 1166 | |
| 1167 | int |
| 1168 | bgp_process_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 1169 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1170 | { |
| 1171 | struct prefix *p; |
| 1172 | struct bgp_info *new_select; |
| 1173 | struct bgp_info *old_select; |
| 1174 | struct bgp_info_pair old_and_new; |
| 1175 | struct attr attr; |
| 1176 | struct peer_group *group; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1177 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1178 | |
| 1179 | p = &rn->p; |
| 1180 | |
| 1181 | /* Best path selection. */ |
| 1182 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1183 | new_select = old_and_new.new; |
| 1184 | old_select = old_and_new.old; |
| 1185 | |
| 1186 | if (CHECK_FLAG(rsclient->sflags, PEER_STATUS_GROUP)) |
| 1187 | { |
| 1188 | group = rsclient->group; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1189 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1190 | { |
| 1191 | /* Nothing to do. */ |
| 1192 | if (old_select && old_select == new_select) |
| 1193 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1194 | continue; |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1195 | |
| 1196 | if (old_select) |
| 1197 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1198 | if (new_select) |
| 1199 | { |
| 1200 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1201 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1202 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1203 | |
| 1204 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, |
| 1205 | afi, safi); |
| 1206 | } |
| 1207 | return 0; |
| 1208 | } |
| 1209 | |
| 1210 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, afi, safi); |
| 1211 | |
| 1212 | return 0; |
| 1213 | } |
| 1214 | |
| 1215 | int |
| 1216 | bgp_process_main (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1217 | { |
| 1218 | struct prefix *p; |
| 1219 | struct bgp_info *new_select; |
| 1220 | struct bgp_info *old_select; |
| 1221 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1222 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | struct peer *peer; |
| 1224 | struct attr attr; |
| 1225 | |
| 1226 | p = &rn->p; |
| 1227 | |
| 1228 | /* Best path selection. */ |
| 1229 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1230 | old_select = old_and_new.old; |
| 1231 | new_select = old_and_new.new; |
| 1232 | |
| 1233 | /* Nothing to do. */ |
| 1234 | if (old_select && old_select == new_select) |
| 1235 | { |
| 1236 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1237 | { |
| 1238 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) |
| 1239 | bgp_zebra_announce (p, old_select, bgp); |
| 1240 | return 0; |
| 1241 | } |
| 1242 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1243 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1244 | if (old_select) |
| 1245 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1246 | if (new_select) |
| 1247 | { |
| 1248 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1249 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1250 | } |
| 1251 | |
| 1252 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1253 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1254 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1255 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1256 | bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
| 1259 | /* FIB update. */ |
| 1260 | if (safi == SAFI_UNICAST && ! bgp->name && |
| 1261 | ! bgp_option_check (BGP_OPT_NO_FIB)) |
| 1262 | { |
| 1263 | if (new_select |
| 1264 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1265 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
| 1266 | bgp_zebra_announce (p, new_select, bgp); |
| 1267 | else |
| 1268 | { |
| 1269 | /* Withdraw the route from the kernel. */ |
| 1270 | if (old_select |
| 1271 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1272 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
| 1273 | bgp_zebra_withdraw (p, old_select); |
| 1274 | } |
| 1275 | } |
| 1276 | return 0; |
| 1277 | } |
| 1278 | |
| 1279 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1280 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1281 | { |
| 1282 | switch (rn->table->type) |
| 1283 | { |
| 1284 | case BGP_TABLE_MAIN: |
| 1285 | return bgp_process_main (bgp, rn, afi, safi); |
| 1286 | case BGP_TABLE_RSCLIENT: |
| 1287 | return bgp_process_rsclient (bgp, (struct peer *) rn->table->owner, |
| 1288 | rn, afi, safi); |
| 1289 | } |
| 1290 | return 0; |
| 1291 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1292 | |
| 1293 | int |
| 1294 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1295 | { |
| 1296 | struct peer *peer; |
| 1297 | |
| 1298 | peer = THREAD_ARG (thread); |
| 1299 | peer->t_pmax_restart = NULL; |
| 1300 | |
| 1301 | if (BGP_DEBUG (events, EVENTS)) |
| 1302 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1303 | peer->host); |
| 1304 | |
| 1305 | peer_clear (peer); |
| 1306 | |
| 1307 | return 0; |
| 1308 | } |
| 1309 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1310 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1311 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1312 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1313 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1314 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1315 | return 0; |
| 1316 | |
| 1317 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1318 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1319 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1320 | && ! always) |
| 1321 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1322 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1323 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1324 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1325 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1326 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1327 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1328 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1329 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1330 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1331 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1332 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1333 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1334 | |
| 1335 | if (safi == SAFI_MPLS_VPN) |
| 1336 | safi = BGP_SAFI_VPNV4; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1337 | |
| 1338 | ndata[0] = (afi >> 8); |
| 1339 | ndata[1] = afi; |
| 1340 | ndata[2] = safi; |
| 1341 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1342 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1343 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1344 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1345 | |
| 1346 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1347 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1348 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1349 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1350 | |
| 1351 | /* restart timer start */ |
| 1352 | if (peer->pmax_restart[afi][safi]) |
| 1353 | { |
| 1354 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1355 | |
| 1356 | if (BGP_DEBUG (events, EVENTS)) |
| 1357 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1358 | peer->host, peer->v_pmax_restart); |
| 1359 | |
| 1360 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1361 | peer->v_pmax_restart); |
| 1362 | } |
| 1363 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1364 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1365 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1366 | else |
| 1367 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1368 | |
| 1369 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1370 | { |
| 1371 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1372 | && ! always) |
| 1373 | return 0; |
| 1374 | |
| 1375 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1376 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1377 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1378 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1379 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1380 | } |
| 1381 | else |
| 1382 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1383 | return 0; |
| 1384 | } |
| 1385 | |
| 1386 | void |
| 1387 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1388 | afi_t afi, safi_t safi) |
| 1389 | { |
| 1390 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1391 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1392 | /* Ignore 'pcount' for RS-client tables */ |
| 1393 | if ( rn->table->type == BGP_TABLE_MAIN) |
| 1394 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1395 | peer->pcount[afi][safi]--; |
| 1396 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1397 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1398 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1399 | bgp_process (peer->bgp, rn, afi, safi); |
| 1400 | } |
| 1401 | bgp_info_delete (rn, ri); |
| 1402 | bgp_info_free (ri); |
| 1403 | bgp_unlock_node (rn); |
| 1404 | } |
| 1405 | |
| 1406 | void |
| 1407 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1408 | afi_t afi, safi_t safi, int force) |
| 1409 | { |
| 1410 | int valid; |
| 1411 | int status = BGP_DAMP_NONE; |
| 1412 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1413 | /* Ignore 'pcount' for RS-client tables */ |
| 1414 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) && |
| 1415 | rn->table->type == BGP_TABLE_MAIN) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1416 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 1417 | if (! CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 1418 | peer->pcount[afi][safi]--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1419 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1420 | } |
| 1421 | |
| 1422 | if (! force) |
| 1423 | { |
| 1424 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1425 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1426 | status = bgp_damp_withdraw (ri, rn, afi, safi, 0); |
| 1427 | |
| 1428 | if (status == BGP_DAMP_SUPPRESSED) |
| 1429 | return; |
| 1430 | } |
| 1431 | |
| 1432 | valid = CHECK_FLAG (ri->flags, BGP_INFO_VALID); |
| 1433 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1434 | bgp_process (peer->bgp, rn, afi, safi); |
| 1435 | |
| 1436 | if (valid) |
| 1437 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1438 | |
| 1439 | if (status != BGP_DAMP_USED) |
| 1440 | { |
| 1441 | bgp_info_delete (rn, ri); |
| 1442 | bgp_info_free (ri); |
| 1443 | bgp_unlock_node (rn); |
| 1444 | } |
| 1445 | } |
| 1446 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1447 | void |
| 1448 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1449 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1450 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1451 | { |
| 1452 | struct bgp_node *rn; |
| 1453 | struct bgp *bgp; |
| 1454 | struct attr new_attr; |
| 1455 | struct attr *attr_new; |
| 1456 | struct attr *attr_new2; |
| 1457 | struct bgp_info *ri; |
| 1458 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1459 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1460 | char buf[SU_ADDRSTRLEN]; |
| 1461 | |
| 1462 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1463 | if (peer == rsclient) |
| 1464 | return; |
| 1465 | |
| 1466 | bgp = peer->bgp; |
| 1467 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1468 | |
| 1469 | /* Check previously received route. */ |
| 1470 | for (ri = rn->info; ri; ri = ri->next) |
| 1471 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1472 | break; |
| 1473 | |
| 1474 | /* AS path loop check. */ |
| 1475 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1476 | { |
| 1477 | reason = "as-path contains our own AS;"; |
| 1478 | goto filtered; |
| 1479 | } |
| 1480 | |
| 1481 | /* Route reflector originator ID check. */ |
| 1482 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1483 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->originator_id)) |
| 1484 | { |
| 1485 | reason = "originator is us;"; |
| 1486 | goto filtered; |
| 1487 | } |
| 1488 | |
| 1489 | new_attr = *attr; |
| 1490 | |
| 1491 | /* Apply export policy. */ |
| 1492 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1493 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1494 | { |
| 1495 | reason = "export-policy;"; |
| 1496 | goto filtered; |
| 1497 | } |
| 1498 | |
| 1499 | attr_new2 = bgp_attr_intern (&new_attr); |
| 1500 | |
| 1501 | /* Apply import policy. */ |
| 1502 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1503 | { |
| 1504 | bgp_attr_unintern (attr_new2); |
| 1505 | |
| 1506 | reason = "import-policy;"; |
| 1507 | goto filtered; |
| 1508 | } |
| 1509 | |
| 1510 | attr_new = bgp_attr_intern (&new_attr); |
| 1511 | bgp_attr_unintern (attr_new2); |
| 1512 | |
| 1513 | /* IPv4 unicast next hop check. */ |
| 1514 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1515 | { |
| 1516 | /* Next hop must not be 0.0.0.0 nor Class E address. */ |
| 1517 | if (new_attr.nexthop.s_addr == 0 |
| 1518 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1519 | { |
| 1520 | bgp_attr_unintern (attr_new); |
| 1521 | |
| 1522 | reason = "martian next-hop;"; |
| 1523 | goto filtered; |
| 1524 | } |
| 1525 | } |
| 1526 | |
| 1527 | /* If the update is implicit withdraw. */ |
| 1528 | if (ri) |
| 1529 | { |
| 1530 | ri->uptime = time (NULL); |
| 1531 | |
| 1532 | /* Same attribute comes in. */ |
| 1533 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1534 | { |
| 1535 | |
| 1536 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1537 | |
| 1538 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1539 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1540 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1541 | peer->host, |
| 1542 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1543 | p->prefixlen, rsclient->host); |
| 1544 | |
| 1545 | bgp_unlock_node (rn); |
| 1546 | bgp_attr_unintern (attr_new); |
| 1547 | |
| 1548 | return; |
| 1549 | } |
| 1550 | |
| 1551 | /* Received Logging. */ |
| 1552 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1553 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1554 | peer->host, |
| 1555 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1556 | p->prefixlen, rsclient->host); |
| 1557 | |
| 1558 | /* The attribute is changed. */ |
| 1559 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1560 | |
| 1561 | /* Update to new attribute. */ |
| 1562 | bgp_attr_unintern (ri->attr); |
| 1563 | ri->attr = attr_new; |
| 1564 | |
| 1565 | /* Update MPLS tag. */ |
| 1566 | if (safi == SAFI_MPLS_VPN) |
| 1567 | memcpy (ri->tag, tag, 3); |
| 1568 | |
| 1569 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1570 | |
| 1571 | /* Process change. */ |
| 1572 | bgp_process (bgp, rn, afi, safi); |
| 1573 | bgp_unlock_node (rn); |
| 1574 | |
| 1575 | return; |
| 1576 | } |
| 1577 | |
| 1578 | /* Received Logging. */ |
| 1579 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1580 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1581 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1582 | peer->host, |
| 1583 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1584 | p->prefixlen, rsclient->host); |
| 1585 | } |
| 1586 | |
| 1587 | /* Make new BGP info. */ |
| 1588 | new = bgp_info_new (); |
| 1589 | new->type = type; |
| 1590 | new->sub_type = sub_type; |
| 1591 | new->peer = peer; |
| 1592 | new->attr = attr_new; |
| 1593 | new->uptime = time (NULL); |
| 1594 | |
| 1595 | /* Update MPLS tag. */ |
| 1596 | if (safi == SAFI_MPLS_VPN) |
| 1597 | memcpy (new->tag, tag, 3); |
| 1598 | |
| 1599 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1600 | |
| 1601 | /* Register new BGP information. */ |
| 1602 | bgp_info_add (rn, new); |
| 1603 | |
| 1604 | /* Process change. */ |
| 1605 | bgp_process (bgp, rn, afi, safi); |
| 1606 | |
| 1607 | return; |
| 1608 | |
| 1609 | filtered: |
| 1610 | |
| 1611 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 1612 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1613 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1614 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 1615 | peer->host, |
| 1616 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1617 | p->prefixlen, rsclient->host, reason); |
| 1618 | |
| 1619 | if (ri) |
| 1620 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 1); |
| 1621 | |
| 1622 | bgp_unlock_node (rn); |
| 1623 | |
| 1624 | return; |
| 1625 | } |
| 1626 | |
| 1627 | void |
| 1628 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1629 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 1630 | struct prefix_rd *prd, u_char *tag) |
| 1631 | { |
| 1632 | struct bgp_node *rn; |
| 1633 | struct bgp_info *ri; |
| 1634 | char buf[SU_ADDRSTRLEN]; |
| 1635 | |
| 1636 | if (rsclient == peer) |
| 1637 | return; |
| 1638 | |
| 1639 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1640 | |
| 1641 | /* Lookup withdrawn route. */ |
| 1642 | for (ri = rn->info; ri; ri = ri->next) |
| 1643 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1644 | break; |
| 1645 | |
| 1646 | /* Withdraw specified route from routing table. */ |
| 1647 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1648 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 0); |
| 1649 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1650 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1651 | "%s Can't find the route %s/%d", peer->host, |
| 1652 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1653 | p->prefixlen); |
| 1654 | |
| 1655 | /* Unlock bgp_node_get() lock. */ |
| 1656 | bgp_unlock_node (rn); |
| 1657 | } |
| 1658 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1659 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1660 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1661 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1662 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1663 | { |
| 1664 | int ret; |
| 1665 | int aspath_loop_count = 0; |
| 1666 | struct bgp_node *rn; |
| 1667 | struct bgp *bgp; |
| 1668 | struct attr new_attr; |
| 1669 | struct attr *attr_new; |
| 1670 | struct bgp_info *ri; |
| 1671 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1672 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1673 | char buf[SU_ADDRSTRLEN]; |
| 1674 | |
| 1675 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1676 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1677 | |
| 1678 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 1679 | Adj-RIBs-In. */ |
| 1680 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1681 | && peer != bgp->peer_self && ! soft_reconfig) |
| 1682 | bgp_adj_in_set (rn, peer, attr); |
| 1683 | |
| 1684 | /* Check previously received route. */ |
| 1685 | for (ri = rn->info; ri; ri = ri->next) |
| 1686 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1687 | break; |
| 1688 | |
| 1689 | /* AS path local-as loop check. */ |
| 1690 | if (peer->change_local_as) |
| 1691 | { |
| 1692 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 1693 | aspath_loop_count = 1; |
| 1694 | |
| 1695 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 1696 | { |
| 1697 | reason = "as-path contains our own AS;"; |
| 1698 | goto filtered; |
| 1699 | } |
| 1700 | } |
| 1701 | |
| 1702 | /* AS path loop check. */ |
| 1703 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 1704 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 1705 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 1706 | > peer->allowas_in[afi][safi])) |
| 1707 | { |
| 1708 | reason = "as-path contains our own AS;"; |
| 1709 | goto filtered; |
| 1710 | } |
| 1711 | |
| 1712 | /* Route reflector originator ID check. */ |
| 1713 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1714 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id)) |
| 1715 | { |
| 1716 | reason = "originator is us;"; |
| 1717 | goto filtered; |
| 1718 | } |
| 1719 | |
| 1720 | /* Route reflector cluster ID check. */ |
| 1721 | if (bgp_cluster_filter (peer, attr)) |
| 1722 | { |
| 1723 | reason = "reflected from the same cluster;"; |
| 1724 | goto filtered; |
| 1725 | } |
| 1726 | |
| 1727 | /* Apply incoming filter. */ |
| 1728 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 1729 | { |
| 1730 | reason = "filter;"; |
| 1731 | goto filtered; |
| 1732 | } |
| 1733 | |
| 1734 | /* Apply incoming route-map. */ |
| 1735 | new_attr = *attr; |
| 1736 | |
| 1737 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1738 | { |
| 1739 | reason = "route-map;"; |
| 1740 | goto filtered; |
| 1741 | } |
| 1742 | |
| 1743 | /* IPv4 unicast next hop check. */ |
| 1744 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1745 | { |
| 1746 | /* If the peer is EBGP and nexthop is not on connected route, |
| 1747 | discard it. */ |
| 1748 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
| 1749 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 1750 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1751 | { |
| 1752 | reason = "non-connected next-hop;"; |
| 1753 | goto filtered; |
| 1754 | } |
| 1755 | |
| 1756 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop |
| 1757 | must not be my own address. */ |
| 1758 | if (bgp_nexthop_self (afi, &new_attr) |
| 1759 | || new_attr.nexthop.s_addr == 0 |
| 1760 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1761 | { |
| 1762 | reason = "martian next-hop;"; |
| 1763 | goto filtered; |
| 1764 | } |
| 1765 | } |
| 1766 | |
| 1767 | attr_new = bgp_attr_intern (&new_attr); |
| 1768 | |
| 1769 | /* If the update is implicit withdraw. */ |
| 1770 | if (ri) |
| 1771 | { |
| 1772 | ri->uptime = time (NULL); |
| 1773 | |
| 1774 | /* Same attribute comes in. */ |
| 1775 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1776 | { |
| 1777 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1778 | |
| 1779 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1780 | && peer_sort (peer) == BGP_PEER_EBGP |
| 1781 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1782 | { |
| 1783 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1784 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1785 | peer->host, |
| 1786 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1787 | p->prefixlen); |
| 1788 | |
| 1789 | peer->pcount[afi][safi]++; |
| 1790 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1791 | if (ret != BGP_DAMP_SUPPRESSED) |
| 1792 | { |
| 1793 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1794 | bgp_process (bgp, rn, afi, safi); |
| 1795 | } |
| 1796 | } |
| 1797 | else |
| 1798 | { |
| 1799 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1800 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1801 | "%s rcvd %s/%d...duplicate ignored", |
| 1802 | peer->host, |
| 1803 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1804 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 1805 | |
| 1806 | /* graceful restart STALE flag unset. */ |
| 1807 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 1808 | { |
| 1809 | UNSET_FLAG (ri->flags, BGP_INFO_STALE); |
| 1810 | peer->pcount[afi][safi]++; |
| 1811 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1812 | } |
| 1813 | |
| 1814 | bgp_unlock_node (rn); |
| 1815 | bgp_attr_unintern (attr_new); |
| 1816 | return 0; |
| 1817 | } |
| 1818 | |
| 1819 | /* Received Logging. */ |
| 1820 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1821 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1822 | peer->host, |
| 1823 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1824 | p->prefixlen); |
| 1825 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 1826 | /* graceful restart STALE flag unset. */ |
| 1827 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 1828 | { |
| 1829 | UNSET_FLAG (ri->flags, BGP_INFO_STALE); |
| 1830 | peer->pcount[afi][safi]++; |
| 1831 | } |
| 1832 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1833 | /* The attribute is changed. */ |
| 1834 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1835 | |
| 1836 | /* Update bgp route dampening information. */ |
| 1837 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1838 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1839 | { |
| 1840 | /* This is implicit withdraw so we should update dampening |
| 1841 | information. */ |
| 1842 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1843 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
| 1844 | else |
| 1845 | peer->pcount[afi][safi]++; |
| 1846 | } |
| 1847 | |
| 1848 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 1849 | |
| 1850 | /* Update to new attribute. */ |
| 1851 | bgp_attr_unintern (ri->attr); |
| 1852 | ri->attr = attr_new; |
| 1853 | |
| 1854 | /* Update MPLS tag. */ |
| 1855 | if (safi == SAFI_MPLS_VPN) |
| 1856 | memcpy (ri->tag, tag, 3); |
| 1857 | |
| 1858 | /* Update bgp route dampening information. */ |
| 1859 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1860 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1861 | { |
| 1862 | /* Now we do normal update dampening. */ |
| 1863 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1864 | if (ret == BGP_DAMP_SUPPRESSED) |
| 1865 | { |
| 1866 | bgp_unlock_node (rn); |
| 1867 | return 0; |
| 1868 | } |
| 1869 | } |
| 1870 | |
| 1871 | /* Nexthop reachability check. */ |
| 1872 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 1873 | && safi == SAFI_UNICAST |
| 1874 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 1875 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 1876 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1877 | { |
| 1878 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
| 1879 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1880 | else |
| 1881 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1882 | } |
| 1883 | else |
| 1884 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1885 | |
| 1886 | /* Process change. */ |
| 1887 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1888 | |
| 1889 | bgp_process (bgp, rn, afi, safi); |
| 1890 | bgp_unlock_node (rn); |
| 1891 | return 0; |
| 1892 | } |
| 1893 | |
| 1894 | /* Received Logging. */ |
| 1895 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1896 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1897 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1898 | peer->host, |
| 1899 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1900 | p->prefixlen); |
| 1901 | } |
| 1902 | |
| 1903 | /* Increment prefix counter */ |
| 1904 | peer->pcount[afi][safi]++; |
| 1905 | |
| 1906 | /* Make new BGP info. */ |
| 1907 | new = bgp_info_new (); |
| 1908 | new->type = type; |
| 1909 | new->sub_type = sub_type; |
| 1910 | new->peer = peer; |
| 1911 | new->attr = attr_new; |
| 1912 | new->uptime = time (NULL); |
| 1913 | |
| 1914 | /* Update MPLS tag. */ |
| 1915 | if (safi == SAFI_MPLS_VPN) |
| 1916 | memcpy (new->tag, tag, 3); |
| 1917 | |
| 1918 | /* Nexthop reachability check. */ |
| 1919 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 1920 | && safi == SAFI_UNICAST |
| 1921 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 1922 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 1923 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1924 | { |
| 1925 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
| 1926 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1927 | else |
| 1928 | UNSET_FLAG (new->flags, BGP_INFO_VALID); |
| 1929 | } |
| 1930 | else |
| 1931 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1932 | |
| 1933 | /* Aggregate address increment. */ |
| 1934 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 1935 | |
| 1936 | /* Register new BGP information. */ |
| 1937 | bgp_info_add (rn, new); |
| 1938 | |
| 1939 | /* If maximum prefix count is configured and current prefix |
| 1940 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1941 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 1942 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1943 | |
| 1944 | /* Process change. */ |
| 1945 | bgp_process (bgp, rn, afi, safi); |
| 1946 | |
| 1947 | return 0; |
| 1948 | |
| 1949 | /* This BGP update is filtered. Log the reason then update BGP |
| 1950 | entry. */ |
| 1951 | filtered: |
| 1952 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1953 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1954 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 1955 | peer->host, |
| 1956 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1957 | p->prefixlen, reason); |
| 1958 | |
| 1959 | if (ri) |
| 1960 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 1); |
| 1961 | |
| 1962 | bgp_unlock_node (rn); |
| 1963 | |
| 1964 | return 0; |
| 1965 | } |
| 1966 | |
| 1967 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1968 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 1969 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1970 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1971 | { |
| 1972 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1973 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1974 | struct bgp *bgp; |
| 1975 | int ret; |
| 1976 | |
| 1977 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 1978 | soft_reconfig); |
| 1979 | |
| 1980 | bgp = peer->bgp; |
| 1981 | |
| 1982 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1983 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1984 | { |
| 1985 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 1986 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 1987 | sub_type, prd, tag); |
| 1988 | } |
| 1989 | |
| 1990 | return ret; |
| 1991 | } |
| 1992 | |
| 1993 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1994 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
| 1995 | int afi, int safi, int type, int sub_type, struct prefix_rd *prd, |
| 1996 | u_char *tag) |
| 1997 | { |
| 1998 | struct bgp *bgp; |
| 1999 | char buf[SU_ADDRSTRLEN]; |
| 2000 | struct bgp_node *rn; |
| 2001 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2002 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2003 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2004 | |
| 2005 | bgp = peer->bgp; |
| 2006 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2007 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2008 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2009 | { |
| 2010 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2011 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2012 | } |
| 2013 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2014 | /* Logging. */ |
| 2015 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2016 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2017 | peer->host, |
| 2018 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2019 | p->prefixlen); |
| 2020 | |
| 2021 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2022 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2023 | |
| 2024 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2025 | further calculation. */ |
| 2026 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2027 | && peer != bgp->peer_self) |
| 2028 | bgp_adj_in_unset (rn, peer); |
| 2029 | |
| 2030 | /* Lookup withdrawn route. */ |
| 2031 | for (ri = rn->info; ri; ri = ri->next) |
| 2032 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2033 | break; |
| 2034 | |
| 2035 | /* Withdraw specified route from routing table. */ |
| 2036 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2037 | bgp_rib_withdraw (rn, ri, peer, afi, safi, 0); |
| 2038 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2039 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2040 | "%s Can't find the route %s/%d", peer->host, |
| 2041 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2042 | p->prefixlen); |
| 2043 | |
| 2044 | /* Unlock bgp_node_get() lock. */ |
| 2045 | bgp_unlock_node (rn); |
| 2046 | |
| 2047 | return 0; |
| 2048 | } |
| 2049 | |
| 2050 | void |
| 2051 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2052 | { |
| 2053 | struct bgp *bgp; |
| 2054 | struct attr attr; |
| 2055 | struct aspath *aspath; |
| 2056 | struct prefix p; |
| 2057 | struct bgp_info binfo; |
| 2058 | struct peer *from; |
| 2059 | int ret = RMAP_DENYMATCH; |
| 2060 | |
| 2061 | bgp = peer->bgp; |
| 2062 | from = bgp->peer_self; |
| 2063 | |
| 2064 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2065 | aspath = attr.aspath; |
| 2066 | attr.local_pref = bgp->default_local_pref; |
| 2067 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2068 | |
| 2069 | if (afi == AFI_IP) |
| 2070 | str2prefix ("0.0.0.0/0", &p); |
| 2071 | #ifdef HAVE_IPV6 |
| 2072 | else if (afi == AFI_IP6) |
| 2073 | { |
| 2074 | str2prefix ("::/0", &p); |
| 2075 | |
| 2076 | /* IPv6 global nexthop must be included. */ |
| 2077 | memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global, |
| 2078 | IPV6_MAX_BYTELEN); |
| 2079 | attr.mp_nexthop_len = 16; |
| 2080 | |
| 2081 | /* If the peer is on shared nextwork and we have link-local |
| 2082 | nexthop set it. */ |
| 2083 | if (peer->shared_network |
| 2084 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2085 | { |
| 2086 | memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local, |
| 2087 | IPV6_MAX_BYTELEN); |
| 2088 | attr.mp_nexthop_len = 32; |
| 2089 | } |
| 2090 | } |
| 2091 | #endif /* HAVE_IPV6 */ |
| 2092 | else |
| 2093 | return; |
| 2094 | |
| 2095 | if (peer->default_rmap[afi][safi].name) |
| 2096 | { |
| 2097 | binfo.peer = bgp->peer_self; |
| 2098 | binfo.attr = &attr; |
| 2099 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2100 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2101 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2102 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2103 | RMAP_BGP, &binfo); |
| 2104 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2105 | bgp->peer_self->rmap_type = 0; |
| 2106 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2107 | if (ret == RMAP_DENYMATCH) |
| 2108 | { |
| 2109 | bgp_attr_flush (&attr); |
| 2110 | withdraw = 1; |
| 2111 | } |
| 2112 | } |
| 2113 | |
| 2114 | if (withdraw) |
| 2115 | { |
| 2116 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2117 | bgp_default_withdraw_send (peer, afi, safi); |
| 2118 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2119 | } |
| 2120 | else |
| 2121 | { |
| 2122 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2123 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2124 | } |
| 2125 | |
| 2126 | aspath_unintern (aspath); |
| 2127 | } |
| 2128 | |
| 2129 | static void |
| 2130 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2131 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2132 | { |
| 2133 | struct bgp_node *rn; |
| 2134 | struct bgp_info *ri; |
| 2135 | struct attr attr; |
| 2136 | |
| 2137 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2138 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2139 | |
| 2140 | if (safi != SAFI_MPLS_VPN |
| 2141 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2142 | bgp_default_originate (peer, afi, safi, 0); |
| 2143 | |
| 2144 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2145 | for (ri = rn->info; ri; ri = ri->next) |
| 2146 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2147 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2148 | if ( (rsclient) ? |
| 2149 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2150 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2151 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2152 | else |
| 2153 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2154 | } |
| 2155 | } |
| 2156 | |
| 2157 | void |
| 2158 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2159 | { |
| 2160 | struct bgp_node *rn; |
| 2161 | struct bgp_table *table; |
| 2162 | |
| 2163 | if (peer->status != Established) |
| 2164 | return; |
| 2165 | |
| 2166 | if (! peer->afc_nego[afi][safi]) |
| 2167 | return; |
| 2168 | |
| 2169 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2170 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2171 | return; |
| 2172 | |
| 2173 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2174 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2175 | else |
| 2176 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2177 | rn = bgp_route_next(rn)) |
| 2178 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2179 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2180 | |
| 2181 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2182 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2183 | } |
| 2184 | |
| 2185 | void |
| 2186 | bgp_announce_route_all (struct peer *peer) |
| 2187 | { |
| 2188 | afi_t afi; |
| 2189 | safi_t safi; |
| 2190 | |
| 2191 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2192 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2193 | bgp_announce_route (peer, afi, safi); |
| 2194 | } |
| 2195 | |
| 2196 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2197 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
| 2198 | safi_t safi, struct bgp_table *table) |
| 2199 | { |
| 2200 | struct bgp_node *rn; |
| 2201 | struct bgp_adj_in *ain; |
| 2202 | |
| 2203 | if (! table) |
| 2204 | table = rsclient->bgp->rib[afi][safi]; |
| 2205 | |
| 2206 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2207 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2208 | { |
| 2209 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
| 2210 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2211 | } |
| 2212 | } |
| 2213 | |
| 2214 | void |
| 2215 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2216 | { |
| 2217 | struct bgp_table *table; |
| 2218 | struct bgp_node *rn; |
| 2219 | |
| 2220 | if (safi != SAFI_MPLS_VPN) |
| 2221 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); |
| 2222 | |
| 2223 | else |
| 2224 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2225 | rn = bgp_route_next (rn)) |
| 2226 | if ((table = rn->info) != NULL) |
| 2227 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); |
| 2228 | } |
| 2229 | |
| 2230 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2231 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 2232 | struct bgp_table *table) |
| 2233 | { |
| 2234 | int ret; |
| 2235 | struct bgp_node *rn; |
| 2236 | struct bgp_adj_in *ain; |
| 2237 | |
| 2238 | if (! table) |
| 2239 | table = peer->bgp->rib[afi][safi]; |
| 2240 | |
| 2241 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2242 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2243 | { |
| 2244 | if (ain->peer == peer) |
| 2245 | { |
| 2246 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2247 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 2248 | NULL, NULL, 1); |
| 2249 | if (ret < 0) |
| 2250 | { |
| 2251 | bgp_unlock_node (rn); |
| 2252 | return; |
| 2253 | } |
| 2254 | continue; |
| 2255 | } |
| 2256 | } |
| 2257 | } |
| 2258 | |
| 2259 | void |
| 2260 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2261 | { |
| 2262 | struct bgp_node *rn; |
| 2263 | struct bgp_table *table; |
| 2264 | |
| 2265 | if (peer->status != Established) |
| 2266 | return; |
| 2267 | |
| 2268 | if (safi != SAFI_MPLS_VPN) |
| 2269 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 2270 | else |
| 2271 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2272 | rn = bgp_route_next (rn)) |
| 2273 | if ((table = rn->info) != NULL) |
| 2274 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 2275 | } |
| 2276 | |
| 2277 | static void |
| 2278 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2279 | struct bgp_table *table, struct peer *rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2280 | { |
| 2281 | struct bgp_node *rn; |
| 2282 | struct bgp_adj_in *ain; |
| 2283 | struct bgp_adj_out *aout; |
| 2284 | struct bgp_info *ri; |
| 2285 | |
| 2286 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2287 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2288 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2289 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2290 | if (! table) |
| 2291 | return; |
| 2292 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2293 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2294 | { |
| 2295 | for (ri = rn->info; ri; ri = ri->next) |
| 2296 | if (ri->peer == peer) |
| 2297 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2298 | /* graceful restart STALE flag set. */ |
| 2299 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2300 | && peer->nsf[afi][safi] |
| 2301 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
| 2302 | && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) |
| 2303 | && ! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
| 2304 | { |
| 2305 | SET_FLAG (ri->flags, BGP_INFO_STALE); |
| 2306 | peer->pcount[afi][safi]--; |
| 2307 | } |
| 2308 | else |
| 2309 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2310 | break; |
| 2311 | } |
| 2312 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2313 | if (ain->peer == peer) |
| 2314 | { |
| 2315 | bgp_adj_in_remove (rn, ain); |
| 2316 | bgp_unlock_node (rn); |
| 2317 | break; |
| 2318 | } |
| 2319 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2320 | if (aout->peer == peer) |
| 2321 | { |
| 2322 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2323 | bgp_unlock_node (rn); |
| 2324 | break; |
| 2325 | } |
| 2326 | } |
| 2327 | } |
| 2328 | |
| 2329 | void |
| 2330 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2331 | { |
| 2332 | struct bgp_node *rn; |
| 2333 | struct bgp_table *table; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2334 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2335 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2337 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2338 | bgp_clear_route_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2339 | else |
| 2340 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2341 | rn = bgp_route_next (rn)) |
| 2342 | if ((table = rn->info) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2343 | bgp_clear_route_table (peer, afi, safi, table, NULL); |
| 2344 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2345 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2346 | { |
| 2347 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2348 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient); |
| 2349 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2350 | } |
| 2351 | |
| 2352 | void |
| 2353 | bgp_clear_route_all (struct peer *peer) |
| 2354 | { |
| 2355 | afi_t afi; |
| 2356 | safi_t safi; |
| 2357 | |
| 2358 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2359 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2360 | bgp_clear_route (peer, afi, safi); |
| 2361 | } |
| 2362 | |
| 2363 | void |
| 2364 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2365 | { |
| 2366 | struct bgp_table *table; |
| 2367 | struct bgp_node *rn; |
| 2368 | struct bgp_adj_in *ain; |
| 2369 | |
| 2370 | table = peer->bgp->rib[afi][safi]; |
| 2371 | |
| 2372 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2373 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2374 | if (ain->peer == peer) |
| 2375 | { |
| 2376 | bgp_adj_in_remove (rn, ain); |
| 2377 | bgp_unlock_node (rn); |
| 2378 | break; |
| 2379 | } |
| 2380 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2381 | |
| 2382 | void |
| 2383 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2384 | { |
| 2385 | struct bgp_node *rn; |
| 2386 | struct bgp_info *ri; |
| 2387 | struct bgp_table *table; |
| 2388 | |
| 2389 | table = peer->bgp->rib[afi][safi]; |
| 2390 | |
| 2391 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2392 | { |
| 2393 | for (ri = rn->info; ri; ri = ri->next) |
| 2394 | if (ri->peer == peer) |
| 2395 | { |
| 2396 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2397 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 2398 | break; |
| 2399 | } |
| 2400 | } |
| 2401 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2402 | |
| 2403 | /* Delete all kernel routes. */ |
| 2404 | void |
paul | 545acaf | 2004-04-20 15:13:15 +0000 | [diff] [blame] | 2405 | bgp_cleanup_routes () |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2406 | { |
| 2407 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2408 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2409 | struct bgp_node *rn; |
| 2410 | struct bgp_table *table; |
| 2411 | struct bgp_info *ri; |
| 2412 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2413 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2414 | { |
| 2415 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 2416 | |
| 2417 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2418 | for (ri = rn->info; ri; ri = ri->next) |
| 2419 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2420 | && ri->type == ZEBRA_ROUTE_BGP |
| 2421 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2422 | bgp_zebra_withdraw (&rn->p, ri); |
| 2423 | |
| 2424 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 2425 | |
| 2426 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2427 | for (ri = rn->info; ri; ri = ri->next) |
| 2428 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2429 | && ri->type == ZEBRA_ROUTE_BGP |
| 2430 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2431 | bgp_zebra_withdraw (&rn->p, ri); |
| 2432 | } |
| 2433 | } |
| 2434 | |
| 2435 | void |
| 2436 | bgp_reset () |
| 2437 | { |
| 2438 | vty_reset (); |
| 2439 | bgp_zclient_reset (); |
| 2440 | access_list_reset (); |
| 2441 | prefix_list_reset (); |
| 2442 | } |
| 2443 | |
| 2444 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 2445 | value. */ |
| 2446 | int |
| 2447 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 2448 | { |
| 2449 | u_char *pnt; |
| 2450 | u_char *lim; |
| 2451 | struct prefix p; |
| 2452 | int psize; |
| 2453 | int ret; |
| 2454 | |
| 2455 | /* Check peer status. */ |
| 2456 | if (peer->status != Established) |
| 2457 | return 0; |
| 2458 | |
| 2459 | pnt = packet->nlri; |
| 2460 | lim = pnt + packet->length; |
| 2461 | |
| 2462 | for (; pnt < lim; pnt += psize) |
| 2463 | { |
| 2464 | /* Clear prefix structure. */ |
| 2465 | memset (&p, 0, sizeof (struct prefix)); |
| 2466 | |
| 2467 | /* Fetch prefix length. */ |
| 2468 | p.prefixlen = *pnt++; |
| 2469 | p.family = afi2family (packet->afi); |
| 2470 | |
| 2471 | /* Already checked in nlri_sanity_check(). We do double check |
| 2472 | here. */ |
| 2473 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 2474 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 2475 | return -1; |
| 2476 | |
| 2477 | /* Packet size overflow check. */ |
| 2478 | psize = PSIZE (p.prefixlen); |
| 2479 | |
| 2480 | /* When packet overflow occur return immediately. */ |
| 2481 | if (pnt + psize > lim) |
| 2482 | return -1; |
| 2483 | |
| 2484 | /* Fetch prefix from NLRI packet. */ |
| 2485 | memcpy (&p.u.prefix, pnt, psize); |
| 2486 | |
| 2487 | /* Check address. */ |
| 2488 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 2489 | { |
| 2490 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 2491 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2492 | /* |
| 2493 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 2494 | * If a BGP router receives an UPDATE message with a |
| 2495 | * semantically incorrect NLRI field, in which a prefix is |
| 2496 | * semantically incorrect (eg. an unexpected multicast IP |
| 2497 | * address), it should ignore the prefix. |
| 2498 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2499 | zlog (peer->log, LOG_ERR, |
| 2500 | "IPv4 unicast NLRI is multicast address %s", |
| 2501 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2502 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2503 | return -1; |
| 2504 | } |
| 2505 | } |
| 2506 | |
| 2507 | #ifdef HAVE_IPV6 |
| 2508 | /* Check address. */ |
| 2509 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 2510 | { |
| 2511 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2512 | { |
| 2513 | char buf[BUFSIZ]; |
| 2514 | |
| 2515 | zlog (peer->log, LOG_WARNING, |
| 2516 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 2517 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 2518 | |
| 2519 | continue; |
| 2520 | } |
| 2521 | } |
| 2522 | #endif /* HAVE_IPV6 */ |
| 2523 | |
| 2524 | /* Normal process. */ |
| 2525 | if (attr) |
| 2526 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 2527 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 2528 | else |
| 2529 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 2530 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2531 | |
| 2532 | /* Address family configuration mismatch or maximum-prefix count |
| 2533 | overflow. */ |
| 2534 | if (ret < 0) |
| 2535 | return -1; |
| 2536 | } |
| 2537 | |
| 2538 | /* Packet length consistency check. */ |
| 2539 | if (pnt != lim) |
| 2540 | return -1; |
| 2541 | |
| 2542 | return 0; |
| 2543 | } |
| 2544 | |
| 2545 | /* NLRI encode syntax check routine. */ |
| 2546 | int |
| 2547 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 2548 | bgp_size_t length) |
| 2549 | { |
| 2550 | u_char *end; |
| 2551 | u_char prefixlen; |
| 2552 | int psize; |
| 2553 | |
| 2554 | end = pnt + length; |
| 2555 | |
| 2556 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 2557 | syntactic validity. If the field is syntactically incorrect, |
| 2558 | then the Error Subcode is set to Invalid Network Field. */ |
| 2559 | |
| 2560 | while (pnt < end) |
| 2561 | { |
| 2562 | prefixlen = *pnt++; |
| 2563 | |
| 2564 | /* Prefix length check. */ |
| 2565 | if ((afi == AFI_IP && prefixlen > 32) |
| 2566 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 2567 | { |
| 2568 | plog_err (peer->log, |
| 2569 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 2570 | peer->host, prefixlen); |
| 2571 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2572 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2573 | return -1; |
| 2574 | } |
| 2575 | |
| 2576 | /* Packet size overflow check. */ |
| 2577 | psize = PSIZE (prefixlen); |
| 2578 | |
| 2579 | if (pnt + psize > end) |
| 2580 | { |
| 2581 | plog_err (peer->log, |
| 2582 | "%s [Error] Update packet error" |
| 2583 | " (prefix data overflow prefix size is %d)", |
| 2584 | peer->host, psize); |
| 2585 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2586 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2587 | return -1; |
| 2588 | } |
| 2589 | |
| 2590 | pnt += psize; |
| 2591 | } |
| 2592 | |
| 2593 | /* Packet length consistency check. */ |
| 2594 | if (pnt != end) |
| 2595 | { |
| 2596 | plog_err (peer->log, |
| 2597 | "%s [Error] Update packet error" |
| 2598 | " (prefix length mismatch with total length)", |
| 2599 | peer->host); |
| 2600 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2601 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2602 | return -1; |
| 2603 | } |
| 2604 | return 0; |
| 2605 | } |
| 2606 | |
| 2607 | struct bgp_static * |
| 2608 | bgp_static_new () |
| 2609 | { |
| 2610 | struct bgp_static *new; |
| 2611 | new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
| 2612 | memset (new, 0, sizeof (struct bgp_static)); |
| 2613 | return new; |
| 2614 | } |
| 2615 | |
| 2616 | void |
| 2617 | bgp_static_free (struct bgp_static *bgp_static) |
| 2618 | { |
| 2619 | if (bgp_static->rmap.name) |
| 2620 | free (bgp_static->rmap.name); |
| 2621 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 2622 | } |
| 2623 | |
| 2624 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2625 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 2626 | struct prefix *p, afi_t afi, safi_t safi) |
| 2627 | { |
| 2628 | struct bgp_node *rn; |
| 2629 | struct bgp_info *ri; |
| 2630 | |
| 2631 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2632 | |
| 2633 | /* Check selected route and self inserted route. */ |
| 2634 | for (ri = rn->info; ri; ri = ri->next) |
| 2635 | if (ri->peer == bgp->peer_self |
| 2636 | && ri->type == ZEBRA_ROUTE_BGP |
| 2637 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2638 | break; |
| 2639 | |
| 2640 | /* Withdraw static BGP route from routing table. */ |
| 2641 | if (ri) |
| 2642 | { |
| 2643 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2644 | bgp_process (bgp, rn, afi, safi); |
| 2645 | bgp_info_delete (rn, ri); |
| 2646 | bgp_info_free (ri); |
| 2647 | bgp_unlock_node (rn); |
| 2648 | } |
| 2649 | |
| 2650 | /* Unlock bgp_node_lookup. */ |
| 2651 | bgp_unlock_node (rn); |
| 2652 | } |
| 2653 | |
| 2654 | void |
| 2655 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
| 2656 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2657 | { |
| 2658 | struct bgp_node *rn; |
| 2659 | struct bgp_info *ri; |
| 2660 | struct bgp_info *new; |
| 2661 | struct bgp_info info; |
| 2662 | struct attr new_attr; |
| 2663 | struct attr *attr_new; |
| 2664 | struct attr attr; |
| 2665 | struct bgp *bgp; |
| 2666 | int ret; |
| 2667 | char buf[SU_ADDRSTRLEN]; |
| 2668 | |
| 2669 | bgp = rsclient->bgp; |
| 2670 | |
| 2671 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2672 | |
| 2673 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2674 | if (bgp_static) |
| 2675 | { |
| 2676 | attr.nexthop = bgp_static->igpnexthop; |
| 2677 | attr.med = bgp_static->igpmetric; |
| 2678 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 2679 | } |
| 2680 | |
| 2681 | new_attr = attr; |
| 2682 | |
| 2683 | /* Apply network route-map for export to this rsclient. */ |
| 2684 | if (bgp_static->rmap.name) |
| 2685 | { |
| 2686 | info.peer = rsclient; |
| 2687 | info.attr = &new_attr; |
| 2688 | |
| 2689 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 2690 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2691 | |
| 2692 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 2693 | |
| 2694 | rsclient->rmap_type = 0; |
| 2695 | |
| 2696 | if (ret == RMAP_DENYMATCH) |
| 2697 | { |
| 2698 | /* Free uninterned attribute. */ |
| 2699 | bgp_attr_flush (&new_attr); |
| 2700 | |
| 2701 | /* Unintern original. */ |
| 2702 | aspath_unintern (attr.aspath); |
| 2703 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2704 | |
| 2705 | return; |
| 2706 | } |
| 2707 | attr_new = bgp_attr_intern (&new_attr); |
| 2708 | } |
| 2709 | else |
| 2710 | attr_new = bgp_attr_intern (&attr); |
| 2711 | |
| 2712 | new_attr = *attr_new; |
| 2713 | |
| 2714 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2715 | |
| 2716 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2717 | { |
| 2718 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2719 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2720 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2721 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 2722 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2723 | p->prefixlen, rsclient->host); |
| 2724 | |
| 2725 | bgp->peer_self->rmap_type = 0; |
| 2726 | |
| 2727 | bgp_attr_unintern (attr_new); |
| 2728 | aspath_unintern (attr.aspath); |
| 2729 | |
| 2730 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2731 | |
| 2732 | return; |
| 2733 | } |
| 2734 | |
| 2735 | bgp->peer_self->rmap_type = 0; |
| 2736 | |
| 2737 | bgp_attr_unintern (attr_new); |
| 2738 | attr_new = bgp_attr_intern (&new_attr); |
| 2739 | |
| 2740 | for (ri = rn->info; ri; ri = ri->next) |
| 2741 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 2742 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2743 | break; |
| 2744 | |
| 2745 | if (ri) |
| 2746 | { |
| 2747 | if (attrhash_cmp (ri->attr, attr_new)) |
| 2748 | { |
| 2749 | bgp_unlock_node (rn); |
| 2750 | bgp_attr_unintern (attr_new); |
| 2751 | aspath_unintern (attr.aspath); |
| 2752 | return; |
| 2753 | } |
| 2754 | else |
| 2755 | { |
| 2756 | /* The attribute is changed. */ |
| 2757 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2758 | |
| 2759 | /* Rewrite BGP route information. */ |
| 2760 | bgp_attr_unintern (ri->attr); |
| 2761 | ri->attr = attr_new; |
| 2762 | ri->uptime = time (NULL); |
| 2763 | |
| 2764 | /* Process change. */ |
| 2765 | bgp_process (bgp, rn, afi, safi); |
| 2766 | bgp_unlock_node (rn); |
| 2767 | aspath_unintern (attr.aspath); |
| 2768 | return; |
| 2769 | } |
| 2770 | } |
| 2771 | |
| 2772 | /* Make new BGP info. */ |
| 2773 | new = bgp_info_new (); |
| 2774 | new->type = ZEBRA_ROUTE_BGP; |
| 2775 | new->sub_type = BGP_ROUTE_STATIC; |
| 2776 | new->peer = bgp->peer_self; |
| 2777 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2778 | new->attr = attr_new; |
| 2779 | new->uptime = time (NULL); |
| 2780 | |
| 2781 | /* Register new BGP information. */ |
| 2782 | bgp_info_add (rn, new); |
| 2783 | |
| 2784 | /* Process change. */ |
| 2785 | bgp_process (bgp, rn, afi, safi); |
| 2786 | |
| 2787 | /* Unintern original. */ |
| 2788 | aspath_unintern (attr.aspath); |
| 2789 | } |
| 2790 | |
| 2791 | void |
| 2792 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2793 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2794 | { |
| 2795 | struct bgp_node *rn; |
| 2796 | struct bgp_info *ri; |
| 2797 | struct bgp_info *new; |
| 2798 | struct bgp_info info; |
| 2799 | struct attr attr; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2800 | struct attr attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2801 | struct attr *attr_new; |
| 2802 | int ret; |
| 2803 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2804 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2805 | |
| 2806 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2807 | if (bgp_static) |
| 2808 | { |
| 2809 | attr.nexthop = bgp_static->igpnexthop; |
| 2810 | attr.med = bgp_static->igpmetric; |
| 2811 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 2812 | } |
| 2813 | |
| 2814 | /* Apply route-map. */ |
| 2815 | if (bgp_static->rmap.name) |
| 2816 | { |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2817 | attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2818 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2819 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2820 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2821 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2822 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2823 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2824 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2825 | bgp->peer_self->rmap_type = 0; |
| 2826 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2827 | if (ret == RMAP_DENYMATCH) |
| 2828 | { |
| 2829 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2830 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2831 | |
| 2832 | /* Unintern original. */ |
| 2833 | aspath_unintern (attr.aspath); |
| 2834 | bgp_static_withdraw (bgp, p, afi, safi); |
| 2835 | return; |
| 2836 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2837 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2838 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 2839 | else |
| 2840 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2841 | |
| 2842 | for (ri = rn->info; ri; ri = ri->next) |
| 2843 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 2844 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2845 | break; |
| 2846 | |
| 2847 | if (ri) |
| 2848 | { |
| 2849 | if (attrhash_cmp (ri->attr, attr_new)) |
| 2850 | { |
| 2851 | bgp_unlock_node (rn); |
| 2852 | bgp_attr_unintern (attr_new); |
| 2853 | aspath_unintern (attr.aspath); |
| 2854 | return; |
| 2855 | } |
| 2856 | else |
| 2857 | { |
| 2858 | /* The attribute is changed. */ |
| 2859 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2860 | |
| 2861 | /* Rewrite BGP route information. */ |
| 2862 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2863 | bgp_attr_unintern (ri->attr); |
| 2864 | ri->attr = attr_new; |
| 2865 | ri->uptime = time (NULL); |
| 2866 | |
| 2867 | /* Process change. */ |
| 2868 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2869 | bgp_process (bgp, rn, afi, safi); |
| 2870 | bgp_unlock_node (rn); |
| 2871 | aspath_unintern (attr.aspath); |
| 2872 | return; |
| 2873 | } |
| 2874 | } |
| 2875 | |
| 2876 | /* Make new BGP info. */ |
| 2877 | new = bgp_info_new (); |
| 2878 | new->type = ZEBRA_ROUTE_BGP; |
| 2879 | new->sub_type = BGP_ROUTE_STATIC; |
| 2880 | new->peer = bgp->peer_self; |
| 2881 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2882 | new->attr = attr_new; |
| 2883 | new->uptime = time (NULL); |
| 2884 | |
| 2885 | /* Aggregate address increment. */ |
| 2886 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2887 | |
| 2888 | /* Register new BGP information. */ |
| 2889 | bgp_info_add (rn, new); |
| 2890 | |
| 2891 | /* Process change. */ |
| 2892 | bgp_process (bgp, rn, afi, safi); |
| 2893 | |
| 2894 | /* Unintern original. */ |
| 2895 | aspath_unintern (attr.aspath); |
| 2896 | } |
| 2897 | |
| 2898 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2899 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 2900 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2901 | { |
| 2902 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2903 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2904 | |
| 2905 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 2906 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2907 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2908 | { |
| 2909 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
| 2910 | } |
| 2911 | } |
| 2912 | |
| 2913 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2914 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 2915 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 2916 | { |
| 2917 | struct bgp_node *rn; |
| 2918 | struct bgp_info *new; |
| 2919 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2920 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2921 | |
| 2922 | /* Make new BGP info. */ |
| 2923 | new = bgp_info_new (); |
| 2924 | new->type = ZEBRA_ROUTE_BGP; |
| 2925 | new->sub_type = BGP_ROUTE_STATIC; |
| 2926 | new->peer = bgp->peer_self; |
| 2927 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 2928 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2929 | new->uptime = time (NULL); |
| 2930 | memcpy (new->tag, tag, 3); |
| 2931 | |
| 2932 | /* Aggregate address increment. */ |
| 2933 | bgp_aggregate_increment (bgp, p, (struct bgp_info *) new, afi, safi); |
| 2934 | |
| 2935 | /* Register new BGP information. */ |
| 2936 | bgp_info_add (rn, (struct bgp_info *) new); |
| 2937 | |
| 2938 | /* Process change. */ |
| 2939 | bgp_process (bgp, rn, afi, safi); |
| 2940 | } |
| 2941 | |
| 2942 | void |
| 2943 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 2944 | safi_t safi) |
| 2945 | { |
| 2946 | struct bgp_node *rn; |
| 2947 | struct bgp_info *ri; |
| 2948 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2949 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2950 | |
| 2951 | /* Check selected route and self inserted route. */ |
| 2952 | for (ri = rn->info; ri; ri = ri->next) |
| 2953 | if (ri->peer == bgp->peer_self |
| 2954 | && ri->type == ZEBRA_ROUTE_BGP |
| 2955 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2956 | break; |
| 2957 | |
| 2958 | /* Withdraw static BGP route from routing table. */ |
| 2959 | if (ri) |
| 2960 | { |
| 2961 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2962 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2963 | bgp_process (bgp, rn, afi, safi); |
| 2964 | bgp_info_delete (rn, ri); |
| 2965 | bgp_info_free (ri); |
| 2966 | bgp_unlock_node (rn); |
| 2967 | } |
| 2968 | |
| 2969 | /* Unlock bgp_node_lookup. */ |
| 2970 | bgp_unlock_node (rn); |
| 2971 | } |
| 2972 | |
| 2973 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2974 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2975 | { |
| 2976 | struct bgp_static *bgp_static; |
| 2977 | struct bgp *bgp; |
| 2978 | struct bgp_node *rn; |
| 2979 | struct prefix *p; |
| 2980 | |
| 2981 | bgp = rsclient->bgp; |
| 2982 | |
| 2983 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 2984 | if ((bgp_static = rn->info) != NULL) |
| 2985 | { |
| 2986 | p = &rn->p; |
| 2987 | |
| 2988 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 2989 | afi, safi); |
| 2990 | } |
| 2991 | } |
| 2992 | |
| 2993 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2994 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 2995 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 2996 | { |
| 2997 | struct bgp_node *rn; |
| 2998 | struct bgp_info *ri; |
| 2999 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3000 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3001 | |
| 3002 | /* Check selected route and self inserted route. */ |
| 3003 | for (ri = rn->info; ri; ri = ri->next) |
| 3004 | if (ri->peer == bgp->peer_self |
| 3005 | && ri->type == ZEBRA_ROUTE_BGP |
| 3006 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3007 | break; |
| 3008 | |
| 3009 | /* Withdraw static BGP route from routing table. */ |
| 3010 | if (ri) |
| 3011 | { |
| 3012 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3013 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 3014 | bgp_process (bgp, rn, afi, safi); |
| 3015 | bgp_info_delete (rn, ri); |
| 3016 | bgp_info_free (ri); |
| 3017 | bgp_unlock_node (rn); |
| 3018 | } |
| 3019 | |
| 3020 | /* Unlock bgp_node_lookup. */ |
| 3021 | bgp_unlock_node (rn); |
| 3022 | } |
| 3023 | |
| 3024 | /* Configure static BGP network. When user don't run zebra, static |
| 3025 | route should be installed as valid. */ |
| 3026 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3027 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
| 3028 | u_int16_t afi, u_char safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3029 | { |
| 3030 | int ret; |
| 3031 | struct prefix p; |
| 3032 | struct bgp_static *bgp_static; |
| 3033 | struct bgp_node *rn; |
| 3034 | int need_update = 0; |
| 3035 | |
| 3036 | /* Convert IP prefix string to struct prefix. */ |
| 3037 | ret = str2prefix (ip_str, &p); |
| 3038 | if (! ret) |
| 3039 | { |
| 3040 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3041 | return CMD_WARNING; |
| 3042 | } |
| 3043 | #ifdef HAVE_IPV6 |
| 3044 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3045 | { |
| 3046 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3047 | VTY_NEWLINE); |
| 3048 | return CMD_WARNING; |
| 3049 | } |
| 3050 | #endif /* HAVE_IPV6 */ |
| 3051 | |
| 3052 | apply_mask (&p); |
| 3053 | |
| 3054 | /* Set BGP static route configuration. */ |
| 3055 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3056 | |
| 3057 | if (rn->info) |
| 3058 | { |
| 3059 | /* Configuration change. */ |
| 3060 | bgp_static = rn->info; |
| 3061 | |
| 3062 | /* Check previous routes are installed into BGP. */ |
| 3063 | if (! bgp_static->backdoor && bgp_static->valid) |
| 3064 | need_update = 1; |
| 3065 | |
| 3066 | bgp_static->backdoor = backdoor; |
| 3067 | if (rmap) |
| 3068 | { |
| 3069 | if (bgp_static->rmap.name) |
| 3070 | free (bgp_static->rmap.name); |
| 3071 | bgp_static->rmap.name = strdup (rmap); |
| 3072 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3073 | } |
| 3074 | else |
| 3075 | { |
| 3076 | if (bgp_static->rmap.name) |
| 3077 | free (bgp_static->rmap.name); |
| 3078 | bgp_static->rmap.name = NULL; |
| 3079 | bgp_static->rmap.map = NULL; |
| 3080 | bgp_static->valid = 0; |
| 3081 | } |
| 3082 | bgp_unlock_node (rn); |
| 3083 | } |
| 3084 | else |
| 3085 | { |
| 3086 | /* New configuration. */ |
| 3087 | bgp_static = bgp_static_new (); |
| 3088 | bgp_static->backdoor = backdoor; |
| 3089 | bgp_static->valid = 0; |
| 3090 | bgp_static->igpmetric = 0; |
| 3091 | bgp_static->igpnexthop.s_addr = 0; |
| 3092 | if (rmap) |
| 3093 | { |
| 3094 | if (bgp_static->rmap.name) |
| 3095 | free (bgp_static->rmap.name); |
| 3096 | bgp_static->rmap.name = strdup (rmap); |
| 3097 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3098 | } |
| 3099 | rn->info = bgp_static; |
| 3100 | } |
| 3101 | |
| 3102 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3103 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3104 | { |
| 3105 | bgp_static->valid = 1; |
| 3106 | |
| 3107 | if (need_update) |
| 3108 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3109 | |
| 3110 | if (! bgp_static->backdoor) |
| 3111 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3112 | } |
| 3113 | |
| 3114 | return CMD_SUCCESS; |
| 3115 | } |
| 3116 | |
| 3117 | /* Configure static BGP network. */ |
| 3118 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3119 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3120 | u_int16_t afi, u_char safi) |
| 3121 | { |
| 3122 | int ret; |
| 3123 | struct prefix p; |
| 3124 | struct bgp_static *bgp_static; |
| 3125 | struct bgp_node *rn; |
| 3126 | |
| 3127 | /* Convert IP prefix string to struct prefix. */ |
| 3128 | ret = str2prefix (ip_str, &p); |
| 3129 | if (! ret) |
| 3130 | { |
| 3131 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3132 | return CMD_WARNING; |
| 3133 | } |
| 3134 | #ifdef HAVE_IPV6 |
| 3135 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3136 | { |
| 3137 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3138 | VTY_NEWLINE); |
| 3139 | return CMD_WARNING; |
| 3140 | } |
| 3141 | #endif /* HAVE_IPV6 */ |
| 3142 | |
| 3143 | apply_mask (&p); |
| 3144 | |
| 3145 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3146 | if (! rn) |
| 3147 | { |
| 3148 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3149 | VTY_NEWLINE); |
| 3150 | return CMD_WARNING; |
| 3151 | } |
| 3152 | |
| 3153 | bgp_static = rn->info; |
| 3154 | |
| 3155 | /* Update BGP RIB. */ |
| 3156 | if (! bgp_static->backdoor) |
| 3157 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3158 | |
| 3159 | /* Clear configuration. */ |
| 3160 | bgp_static_free (bgp_static); |
| 3161 | rn->info = NULL; |
| 3162 | bgp_unlock_node (rn); |
| 3163 | bgp_unlock_node (rn); |
| 3164 | |
| 3165 | return CMD_SUCCESS; |
| 3166 | } |
| 3167 | |
| 3168 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3169 | instance. */ |
| 3170 | void |
| 3171 | bgp_static_delete (struct bgp *bgp) |
| 3172 | { |
| 3173 | afi_t afi; |
| 3174 | safi_t safi; |
| 3175 | struct bgp_node *rn; |
| 3176 | struct bgp_node *rm; |
| 3177 | struct bgp_table *table; |
| 3178 | struct bgp_static *bgp_static; |
| 3179 | |
| 3180 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3181 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3182 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3183 | if (rn->info != NULL) |
| 3184 | { |
| 3185 | if (safi == SAFI_MPLS_VPN) |
| 3186 | { |
| 3187 | table = rn->info; |
| 3188 | |
| 3189 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3190 | { |
| 3191 | bgp_static = rn->info; |
| 3192 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3193 | AFI_IP, SAFI_MPLS_VPN, |
| 3194 | (struct prefix_rd *)&rn->p, |
| 3195 | bgp_static->tag); |
| 3196 | bgp_static_free (bgp_static); |
| 3197 | rn->info = NULL; |
| 3198 | bgp_unlock_node (rn); |
| 3199 | } |
| 3200 | } |
| 3201 | else |
| 3202 | { |
| 3203 | bgp_static = rn->info; |
| 3204 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3205 | bgp_static_free (bgp_static); |
| 3206 | rn->info = NULL; |
| 3207 | bgp_unlock_node (rn); |
| 3208 | } |
| 3209 | } |
| 3210 | } |
| 3211 | |
| 3212 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3213 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3214 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3215 | { |
| 3216 | int ret; |
| 3217 | struct prefix p; |
| 3218 | struct prefix_rd prd; |
| 3219 | struct bgp *bgp; |
| 3220 | struct bgp_node *prn; |
| 3221 | struct bgp_node *rn; |
| 3222 | struct bgp_table *table; |
| 3223 | struct bgp_static *bgp_static; |
| 3224 | u_char tag[3]; |
| 3225 | |
| 3226 | bgp = vty->index; |
| 3227 | |
| 3228 | ret = str2prefix (ip_str, &p); |
| 3229 | if (! ret) |
| 3230 | { |
| 3231 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3232 | return CMD_WARNING; |
| 3233 | } |
| 3234 | apply_mask (&p); |
| 3235 | |
| 3236 | ret = str2prefix_rd (rd_str, &prd); |
| 3237 | if (! ret) |
| 3238 | { |
| 3239 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3240 | return CMD_WARNING; |
| 3241 | } |
| 3242 | |
| 3243 | ret = str2tag (tag_str, tag); |
| 3244 | if (! ret) |
| 3245 | { |
| 3246 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3247 | return CMD_WARNING; |
| 3248 | } |
| 3249 | |
| 3250 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3251 | (struct prefix *)&prd); |
| 3252 | if (prn->info == NULL) |
| 3253 | prn->info = bgp_table_init (); |
| 3254 | else |
| 3255 | bgp_unlock_node (prn); |
| 3256 | table = prn->info; |
| 3257 | |
| 3258 | rn = bgp_node_get (table, &p); |
| 3259 | |
| 3260 | if (rn->info) |
| 3261 | { |
| 3262 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3263 | bgp_unlock_node (rn); |
| 3264 | } |
| 3265 | else |
| 3266 | { |
| 3267 | /* New configuration. */ |
| 3268 | bgp_static = bgp_static_new (); |
| 3269 | bgp_static->valid = 1; |
| 3270 | memcpy (bgp_static->tag, tag, 3); |
| 3271 | rn->info = bgp_static; |
| 3272 | |
| 3273 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3274 | } |
| 3275 | |
| 3276 | return CMD_SUCCESS; |
| 3277 | } |
| 3278 | |
| 3279 | /* Configure static BGP network. */ |
| 3280 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3281 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3282 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3283 | { |
| 3284 | int ret; |
| 3285 | struct bgp *bgp; |
| 3286 | struct prefix p; |
| 3287 | struct prefix_rd prd; |
| 3288 | struct bgp_node *prn; |
| 3289 | struct bgp_node *rn; |
| 3290 | struct bgp_table *table; |
| 3291 | struct bgp_static *bgp_static; |
| 3292 | u_char tag[3]; |
| 3293 | |
| 3294 | bgp = vty->index; |
| 3295 | |
| 3296 | /* Convert IP prefix string to struct prefix. */ |
| 3297 | ret = str2prefix (ip_str, &p); |
| 3298 | if (! ret) |
| 3299 | { |
| 3300 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3301 | return CMD_WARNING; |
| 3302 | } |
| 3303 | apply_mask (&p); |
| 3304 | |
| 3305 | ret = str2prefix_rd (rd_str, &prd); |
| 3306 | if (! ret) |
| 3307 | { |
| 3308 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3309 | return CMD_WARNING; |
| 3310 | } |
| 3311 | |
| 3312 | ret = str2tag (tag_str, tag); |
| 3313 | if (! ret) |
| 3314 | { |
| 3315 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3316 | return CMD_WARNING; |
| 3317 | } |
| 3318 | |
| 3319 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3320 | (struct prefix *)&prd); |
| 3321 | if (prn->info == NULL) |
| 3322 | prn->info = bgp_table_init (); |
| 3323 | else |
| 3324 | bgp_unlock_node (prn); |
| 3325 | table = prn->info; |
| 3326 | |
| 3327 | rn = bgp_node_lookup (table, &p); |
| 3328 | |
| 3329 | if (rn) |
| 3330 | { |
| 3331 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3332 | |
| 3333 | bgp_static = rn->info; |
| 3334 | bgp_static_free (bgp_static); |
| 3335 | rn->info = NULL; |
| 3336 | bgp_unlock_node (rn); |
| 3337 | bgp_unlock_node (rn); |
| 3338 | } |
| 3339 | else |
| 3340 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3341 | |
| 3342 | return CMD_SUCCESS; |
| 3343 | } |
| 3344 | |
| 3345 | DEFUN (bgp_network, |
| 3346 | bgp_network_cmd, |
| 3347 | "network A.B.C.D/M", |
| 3348 | "Specify a network to announce via BGP\n" |
| 3349 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3350 | { |
| 3351 | return bgp_static_set (vty, vty->index, argv[0], |
| 3352 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3353 | } |
| 3354 | |
| 3355 | DEFUN (bgp_network_route_map, |
| 3356 | bgp_network_route_map_cmd, |
| 3357 | "network A.B.C.D/M route-map WORD", |
| 3358 | "Specify a network to announce via BGP\n" |
| 3359 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3360 | "Route-map to modify the attributes\n" |
| 3361 | "Name of the route map\n") |
| 3362 | { |
| 3363 | return bgp_static_set (vty, vty->index, argv[0], |
| 3364 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3365 | } |
| 3366 | |
| 3367 | DEFUN (bgp_network_backdoor, |
| 3368 | bgp_network_backdoor_cmd, |
| 3369 | "network A.B.C.D/M backdoor", |
| 3370 | "Specify a network to announce via BGP\n" |
| 3371 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3372 | "Specify a BGP backdoor route\n") |
| 3373 | { |
| 3374 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3375 | } |
| 3376 | |
| 3377 | DEFUN (bgp_network_mask, |
| 3378 | bgp_network_mask_cmd, |
| 3379 | "network A.B.C.D mask A.B.C.D", |
| 3380 | "Specify a network to announce via BGP\n" |
| 3381 | "Network number\n" |
| 3382 | "Network mask\n" |
| 3383 | "Network mask\n") |
| 3384 | { |
| 3385 | int ret; |
| 3386 | char prefix_str[BUFSIZ]; |
| 3387 | |
| 3388 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3389 | if (! ret) |
| 3390 | { |
| 3391 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3392 | return CMD_WARNING; |
| 3393 | } |
| 3394 | |
| 3395 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3396 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3397 | } |
| 3398 | |
| 3399 | DEFUN (bgp_network_mask_route_map, |
| 3400 | bgp_network_mask_route_map_cmd, |
| 3401 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 3402 | "Specify a network to announce via BGP\n" |
| 3403 | "Network number\n" |
| 3404 | "Network mask\n" |
| 3405 | "Network mask\n" |
| 3406 | "Route-map to modify the attributes\n" |
| 3407 | "Name of the route map\n") |
| 3408 | { |
| 3409 | int ret; |
| 3410 | char prefix_str[BUFSIZ]; |
| 3411 | |
| 3412 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3413 | if (! ret) |
| 3414 | { |
| 3415 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3416 | return CMD_WARNING; |
| 3417 | } |
| 3418 | |
| 3419 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3420 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
| 3421 | } |
| 3422 | |
| 3423 | DEFUN (bgp_network_mask_backdoor, |
| 3424 | bgp_network_mask_backdoor_cmd, |
| 3425 | "network A.B.C.D mask A.B.C.D backdoor", |
| 3426 | "Specify a network to announce via BGP\n" |
| 3427 | "Network number\n" |
| 3428 | "Network mask\n" |
| 3429 | "Network mask\n" |
| 3430 | "Specify a BGP backdoor route\n") |
| 3431 | { |
| 3432 | int ret; |
| 3433 | char prefix_str[BUFSIZ]; |
| 3434 | |
| 3435 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3436 | if (! ret) |
| 3437 | { |
| 3438 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3439 | return CMD_WARNING; |
| 3440 | } |
| 3441 | |
| 3442 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3443 | } |
| 3444 | |
| 3445 | DEFUN (bgp_network_mask_natural, |
| 3446 | bgp_network_mask_natural_cmd, |
| 3447 | "network A.B.C.D", |
| 3448 | "Specify a network to announce via BGP\n" |
| 3449 | "Network number\n") |
| 3450 | { |
| 3451 | int ret; |
| 3452 | char prefix_str[BUFSIZ]; |
| 3453 | |
| 3454 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3455 | if (! ret) |
| 3456 | { |
| 3457 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3458 | return CMD_WARNING; |
| 3459 | } |
| 3460 | |
| 3461 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3462 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3463 | } |
| 3464 | |
| 3465 | DEFUN (bgp_network_mask_natural_route_map, |
| 3466 | bgp_network_mask_natural_route_map_cmd, |
| 3467 | "network A.B.C.D route-map WORD", |
| 3468 | "Specify a network to announce via BGP\n" |
| 3469 | "Network number\n" |
| 3470 | "Route-map to modify the attributes\n" |
| 3471 | "Name of the route map\n") |
| 3472 | { |
| 3473 | int ret; |
| 3474 | char prefix_str[BUFSIZ]; |
| 3475 | |
| 3476 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3477 | if (! ret) |
| 3478 | { |
| 3479 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3480 | return CMD_WARNING; |
| 3481 | } |
| 3482 | |
| 3483 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3484 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3485 | } |
| 3486 | |
| 3487 | DEFUN (bgp_network_mask_natural_backdoor, |
| 3488 | bgp_network_mask_natural_backdoor_cmd, |
| 3489 | "network A.B.C.D backdoor", |
| 3490 | "Specify a network to announce via BGP\n" |
| 3491 | "Network number\n" |
| 3492 | "Specify a BGP backdoor route\n") |
| 3493 | { |
| 3494 | int ret; |
| 3495 | char prefix_str[BUFSIZ]; |
| 3496 | |
| 3497 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3498 | if (! ret) |
| 3499 | { |
| 3500 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3501 | return CMD_WARNING; |
| 3502 | } |
| 3503 | |
| 3504 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3505 | } |
| 3506 | |
| 3507 | DEFUN (no_bgp_network, |
| 3508 | no_bgp_network_cmd, |
| 3509 | "no network A.B.C.D/M", |
| 3510 | NO_STR |
| 3511 | "Specify a network to announce via BGP\n" |
| 3512 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3513 | { |
| 3514 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 3515 | bgp_node_safi (vty)); |
| 3516 | } |
| 3517 | |
| 3518 | ALIAS (no_bgp_network, |
| 3519 | no_bgp_network_route_map_cmd, |
| 3520 | "no network A.B.C.D/M route-map WORD", |
| 3521 | NO_STR |
| 3522 | "Specify a network to announce via BGP\n" |
| 3523 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3524 | "Route-map to modify the attributes\n" |
| 3525 | "Name of the route map\n") |
| 3526 | |
| 3527 | ALIAS (no_bgp_network, |
| 3528 | no_bgp_network_backdoor_cmd, |
| 3529 | "no network A.B.C.D/M backdoor", |
| 3530 | NO_STR |
| 3531 | "Specify a network to announce via BGP\n" |
| 3532 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3533 | "Specify a BGP backdoor route\n") |
| 3534 | |
| 3535 | DEFUN (no_bgp_network_mask, |
| 3536 | no_bgp_network_mask_cmd, |
| 3537 | "no network A.B.C.D mask A.B.C.D", |
| 3538 | NO_STR |
| 3539 | "Specify a network to announce via BGP\n" |
| 3540 | "Network number\n" |
| 3541 | "Network mask\n" |
| 3542 | "Network mask\n") |
| 3543 | { |
| 3544 | int ret; |
| 3545 | char prefix_str[BUFSIZ]; |
| 3546 | |
| 3547 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3548 | if (! ret) |
| 3549 | { |
| 3550 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3551 | return CMD_WARNING; |
| 3552 | } |
| 3553 | |
| 3554 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3555 | bgp_node_safi (vty)); |
| 3556 | } |
| 3557 | |
| 3558 | ALIAS (no_bgp_network_mask, |
| 3559 | no_bgp_network_mask_route_map_cmd, |
| 3560 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 3561 | NO_STR |
| 3562 | "Specify a network to announce via BGP\n" |
| 3563 | "Network number\n" |
| 3564 | "Network mask\n" |
| 3565 | "Network mask\n" |
| 3566 | "Route-map to modify the attributes\n" |
| 3567 | "Name of the route map\n") |
| 3568 | |
| 3569 | ALIAS (no_bgp_network_mask, |
| 3570 | no_bgp_network_mask_backdoor_cmd, |
| 3571 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 3572 | NO_STR |
| 3573 | "Specify a network to announce via BGP\n" |
| 3574 | "Network number\n" |
| 3575 | "Network mask\n" |
| 3576 | "Network mask\n" |
| 3577 | "Specify a BGP backdoor route\n") |
| 3578 | |
| 3579 | DEFUN (no_bgp_network_mask_natural, |
| 3580 | no_bgp_network_mask_natural_cmd, |
| 3581 | "no network A.B.C.D", |
| 3582 | NO_STR |
| 3583 | "Specify a network to announce via BGP\n" |
| 3584 | "Network number\n") |
| 3585 | { |
| 3586 | int ret; |
| 3587 | char prefix_str[BUFSIZ]; |
| 3588 | |
| 3589 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3590 | if (! ret) |
| 3591 | { |
| 3592 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3593 | return CMD_WARNING; |
| 3594 | } |
| 3595 | |
| 3596 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3597 | bgp_node_safi (vty)); |
| 3598 | } |
| 3599 | |
| 3600 | ALIAS (no_bgp_network_mask_natural, |
| 3601 | no_bgp_network_mask_natural_route_map_cmd, |
| 3602 | "no network A.B.C.D route-map WORD", |
| 3603 | NO_STR |
| 3604 | "Specify a network to announce via BGP\n" |
| 3605 | "Network number\n" |
| 3606 | "Route-map to modify the attributes\n" |
| 3607 | "Name of the route map\n") |
| 3608 | |
| 3609 | ALIAS (no_bgp_network_mask_natural, |
| 3610 | no_bgp_network_mask_natural_backdoor_cmd, |
| 3611 | "no network A.B.C.D backdoor", |
| 3612 | NO_STR |
| 3613 | "Specify a network to announce via BGP\n" |
| 3614 | "Network number\n" |
| 3615 | "Specify a BGP backdoor route\n") |
| 3616 | |
| 3617 | #ifdef HAVE_IPV6 |
| 3618 | DEFUN (ipv6_bgp_network, |
| 3619 | ipv6_bgp_network_cmd, |
| 3620 | "network X:X::X:X/M", |
| 3621 | "Specify a network to announce via BGP\n" |
| 3622 | "IPv6 prefix <network>/<length>\n") |
| 3623 | { |
| 3624 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 3625 | } |
| 3626 | |
| 3627 | DEFUN (ipv6_bgp_network_route_map, |
| 3628 | ipv6_bgp_network_route_map_cmd, |
| 3629 | "network X:X::X:X/M route-map WORD", |
| 3630 | "Specify a network to announce via BGP\n" |
| 3631 | "IPv6 prefix <network>/<length>\n" |
| 3632 | "Route-map to modify the attributes\n" |
| 3633 | "Name of the route map\n") |
| 3634 | { |
| 3635 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
| 3636 | bgp_node_safi (vty), argv[1], 0); |
| 3637 | } |
| 3638 | |
| 3639 | DEFUN (no_ipv6_bgp_network, |
| 3640 | no_ipv6_bgp_network_cmd, |
| 3641 | "no network X:X::X:X/M", |
| 3642 | NO_STR |
| 3643 | "Specify a network to announce via BGP\n" |
| 3644 | "IPv6 prefix <network>/<length>\n") |
| 3645 | { |
| 3646 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); |
| 3647 | } |
| 3648 | |
| 3649 | ALIAS (no_ipv6_bgp_network, |
| 3650 | no_ipv6_bgp_network_route_map_cmd, |
| 3651 | "no network X:X::X:X/M route-map WORD", |
| 3652 | NO_STR |
| 3653 | "Specify a network to announce via BGP\n" |
| 3654 | "IPv6 prefix <network>/<length>\n" |
| 3655 | "Route-map to modify the attributes\n" |
| 3656 | "Name of the route map\n") |
| 3657 | |
| 3658 | ALIAS (ipv6_bgp_network, |
| 3659 | old_ipv6_bgp_network_cmd, |
| 3660 | "ipv6 bgp network X:X::X:X/M", |
| 3661 | IPV6_STR |
| 3662 | BGP_STR |
| 3663 | "Specify a network to announce via BGP\n" |
| 3664 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3665 | |
| 3666 | ALIAS (no_ipv6_bgp_network, |
| 3667 | old_no_ipv6_bgp_network_cmd, |
| 3668 | "no ipv6 bgp network X:X::X:X/M", |
| 3669 | NO_STR |
| 3670 | IPV6_STR |
| 3671 | BGP_STR |
| 3672 | "Specify a network to announce via BGP\n" |
| 3673 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3674 | #endif /* HAVE_IPV6 */ |
| 3675 | |
| 3676 | /* Aggreagete address: |
| 3677 | |
| 3678 | advertise-map Set condition to advertise attribute |
| 3679 | as-set Generate AS set path information |
| 3680 | attribute-map Set attributes of aggregate |
| 3681 | route-map Set parameters of aggregate |
| 3682 | summary-only Filter more specific routes from updates |
| 3683 | suppress-map Conditionally filter more specific routes from updates |
| 3684 | <cr> |
| 3685 | */ |
| 3686 | struct bgp_aggregate |
| 3687 | { |
| 3688 | /* Summary-only flag. */ |
| 3689 | u_char summary_only; |
| 3690 | |
| 3691 | /* AS set generation. */ |
| 3692 | u_char as_set; |
| 3693 | |
| 3694 | /* Route-map for aggregated route. */ |
| 3695 | struct route_map *map; |
| 3696 | |
| 3697 | /* Suppress-count. */ |
| 3698 | unsigned long count; |
| 3699 | |
| 3700 | /* SAFI configuration. */ |
| 3701 | safi_t safi; |
| 3702 | }; |
| 3703 | |
| 3704 | struct bgp_aggregate * |
| 3705 | bgp_aggregate_new () |
| 3706 | { |
| 3707 | struct bgp_aggregate *new; |
| 3708 | new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
| 3709 | memset (new, 0, sizeof (struct bgp_aggregate)); |
| 3710 | return new; |
| 3711 | } |
| 3712 | |
| 3713 | void |
| 3714 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 3715 | { |
| 3716 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 3717 | } |
| 3718 | |
| 3719 | void |
| 3720 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 3721 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 3722 | struct bgp_aggregate *aggregate) |
| 3723 | { |
| 3724 | struct bgp_table *table; |
| 3725 | struct bgp_node *top; |
| 3726 | struct bgp_node *rn; |
| 3727 | u_char origin; |
| 3728 | struct aspath *aspath = NULL; |
| 3729 | struct aspath *asmerge = NULL; |
| 3730 | struct community *community = NULL; |
| 3731 | struct community *commerge = NULL; |
| 3732 | struct in_addr nexthop; |
| 3733 | u_int32_t med = 0; |
| 3734 | struct bgp_info *ri; |
| 3735 | struct bgp_info *new; |
| 3736 | int first = 1; |
| 3737 | unsigned long match = 0; |
| 3738 | |
| 3739 | /* Record adding route's nexthop and med. */ |
| 3740 | if (rinew) |
| 3741 | { |
| 3742 | nexthop = rinew->attr->nexthop; |
| 3743 | med = rinew->attr->med; |
| 3744 | } |
| 3745 | |
| 3746 | /* ORIGIN attribute: If at least one route among routes that are |
| 3747 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 3748 | aggregated route must have the ORIGIN attribute with the value |
| 3749 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 3750 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 3751 | route must have the origin attribute with the value EGP. In all |
| 3752 | other case the value of the ORIGIN attribute of the aggregated |
| 3753 | route is INTERNAL. */ |
| 3754 | origin = BGP_ORIGIN_IGP; |
| 3755 | |
| 3756 | table = bgp->rib[afi][safi]; |
| 3757 | |
| 3758 | top = bgp_node_get (table, p); |
| 3759 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 3760 | if (rn->p.prefixlen > p->prefixlen) |
| 3761 | { |
| 3762 | match = 0; |
| 3763 | |
| 3764 | for (ri = rn->info; ri; ri = ri->next) |
| 3765 | { |
| 3766 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3767 | continue; |
| 3768 | |
| 3769 | if (del && ri == del) |
| 3770 | continue; |
| 3771 | |
| 3772 | if (! rinew && first) |
| 3773 | { |
| 3774 | nexthop = ri->attr->nexthop; |
| 3775 | med = ri->attr->med; |
| 3776 | first = 0; |
| 3777 | } |
| 3778 | |
| 3779 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 3780 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 3781 | || ri->attr->med != med) |
| 3782 | { |
| 3783 | if (aspath) |
| 3784 | aspath_free (aspath); |
| 3785 | if (community) |
| 3786 | community_free (community); |
| 3787 | bgp_unlock_node (rn); |
| 3788 | bgp_unlock_node (top); |
| 3789 | return; |
| 3790 | } |
| 3791 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 3792 | |
| 3793 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 3794 | { |
| 3795 | if (aggregate->summary_only) |
| 3796 | { |
| 3797 | ri->suppress++; |
| 3798 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3799 | match++; |
| 3800 | } |
| 3801 | |
| 3802 | aggregate->count++; |
| 3803 | |
| 3804 | if (aggregate->as_set) |
| 3805 | { |
| 3806 | if (origin < ri->attr->origin) |
| 3807 | origin = ri->attr->origin; |
| 3808 | |
| 3809 | if (aspath) |
| 3810 | { |
| 3811 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 3812 | aspath_free (aspath); |
| 3813 | aspath = asmerge; |
| 3814 | } |
| 3815 | else |
| 3816 | aspath = aspath_dup (ri->attr->aspath); |
| 3817 | |
| 3818 | if (ri->attr->community) |
| 3819 | { |
| 3820 | if (community) |
| 3821 | { |
| 3822 | commerge = community_merge (community, |
| 3823 | ri->attr->community); |
| 3824 | community = community_uniq_sort (commerge); |
| 3825 | community_free (commerge); |
| 3826 | } |
| 3827 | else |
| 3828 | community = community_dup (ri->attr->community); |
| 3829 | } |
| 3830 | } |
| 3831 | } |
| 3832 | } |
| 3833 | if (match) |
| 3834 | bgp_process (bgp, rn, afi, safi); |
| 3835 | } |
| 3836 | bgp_unlock_node (top); |
| 3837 | |
| 3838 | if (rinew) |
| 3839 | { |
| 3840 | aggregate->count++; |
| 3841 | |
| 3842 | if (aggregate->summary_only) |
| 3843 | rinew->suppress++; |
| 3844 | |
| 3845 | if (aggregate->as_set) |
| 3846 | { |
| 3847 | if (origin < rinew->attr->origin) |
| 3848 | origin = rinew->attr->origin; |
| 3849 | |
| 3850 | if (aspath) |
| 3851 | { |
| 3852 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 3853 | aspath_free (aspath); |
| 3854 | aspath = asmerge; |
| 3855 | } |
| 3856 | else |
| 3857 | aspath = aspath_dup (rinew->attr->aspath); |
| 3858 | |
| 3859 | if (rinew->attr->community) |
| 3860 | { |
| 3861 | if (community) |
| 3862 | { |
| 3863 | commerge = community_merge (community, |
| 3864 | rinew->attr->community); |
| 3865 | community = community_uniq_sort (commerge); |
| 3866 | community_free (commerge); |
| 3867 | } |
| 3868 | else |
| 3869 | community = community_dup (rinew->attr->community); |
| 3870 | } |
| 3871 | } |
| 3872 | } |
| 3873 | |
| 3874 | if (aggregate->count > 0) |
| 3875 | { |
| 3876 | rn = bgp_node_get (table, p); |
| 3877 | new = bgp_info_new (); |
| 3878 | new->type = ZEBRA_ROUTE_BGP; |
| 3879 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 3880 | new->peer = bgp->peer_self; |
| 3881 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3882 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 3883 | new->uptime = time (NULL); |
| 3884 | |
| 3885 | bgp_info_add (rn, new); |
| 3886 | bgp_process (bgp, rn, afi, safi); |
| 3887 | } |
| 3888 | else |
| 3889 | { |
| 3890 | if (aspath) |
| 3891 | aspath_free (aspath); |
| 3892 | if (community) |
| 3893 | community_free (community); |
| 3894 | } |
| 3895 | } |
| 3896 | |
| 3897 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 3898 | struct bgp_aggregate *); |
| 3899 | |
| 3900 | void |
| 3901 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 3902 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 3903 | { |
| 3904 | struct bgp_node *child; |
| 3905 | struct bgp_node *rn; |
| 3906 | struct bgp_aggregate *aggregate; |
| 3907 | |
| 3908 | /* MPLS-VPN aggregation is not yet supported. */ |
| 3909 | if (safi == SAFI_MPLS_VPN) |
| 3910 | return; |
| 3911 | |
| 3912 | if (p->prefixlen == 0) |
| 3913 | return; |
| 3914 | |
| 3915 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3916 | return; |
| 3917 | |
| 3918 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 3919 | |
| 3920 | /* Aggregate address configuration check. */ |
| 3921 | for (rn = child; rn; rn = rn->parent) |
| 3922 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 3923 | { |
| 3924 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3925 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3926 | } |
| 3927 | bgp_unlock_node (child); |
| 3928 | } |
| 3929 | |
| 3930 | void |
| 3931 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 3932 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 3933 | { |
| 3934 | struct bgp_node *child; |
| 3935 | struct bgp_node *rn; |
| 3936 | struct bgp_aggregate *aggregate; |
| 3937 | |
| 3938 | /* MPLS-VPN aggregation is not yet supported. */ |
| 3939 | if (safi == SAFI_MPLS_VPN) |
| 3940 | return; |
| 3941 | |
| 3942 | if (p->prefixlen == 0) |
| 3943 | return; |
| 3944 | |
| 3945 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 3946 | |
| 3947 | /* Aggregate address configuration check. */ |
| 3948 | for (rn = child; rn; rn = rn->parent) |
| 3949 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 3950 | { |
| 3951 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3952 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3953 | } |
| 3954 | bgp_unlock_node (child); |
| 3955 | } |
| 3956 | |
| 3957 | void |
| 3958 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 3959 | struct bgp_aggregate *aggregate) |
| 3960 | { |
| 3961 | struct bgp_table *table; |
| 3962 | struct bgp_node *top; |
| 3963 | struct bgp_node *rn; |
| 3964 | struct bgp_info *new; |
| 3965 | struct bgp_info *ri; |
| 3966 | unsigned long match; |
| 3967 | u_char origin = BGP_ORIGIN_IGP; |
| 3968 | struct aspath *aspath = NULL; |
| 3969 | struct aspath *asmerge = NULL; |
| 3970 | struct community *community = NULL; |
| 3971 | struct community *commerge = NULL; |
| 3972 | |
| 3973 | table = bgp->rib[afi][safi]; |
| 3974 | |
| 3975 | /* Sanity check. */ |
| 3976 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 3977 | return; |
| 3978 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 3979 | return; |
| 3980 | |
| 3981 | /* If routes exists below this node, generate aggregate routes. */ |
| 3982 | top = bgp_node_get (table, p); |
| 3983 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 3984 | if (rn->p.prefixlen > p->prefixlen) |
| 3985 | { |
| 3986 | match = 0; |
| 3987 | |
| 3988 | for (ri = rn->info; ri; ri = ri->next) |
| 3989 | { |
| 3990 | if (BGP_INFO_HOLDDOWN (ri)) |
| 3991 | continue; |
| 3992 | |
| 3993 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 3994 | { |
| 3995 | /* summary-only aggregate route suppress aggregated |
| 3996 | route announcement. */ |
| 3997 | if (aggregate->summary_only) |
| 3998 | { |
| 3999 | ri->suppress++; |
| 4000 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4001 | match++; |
| 4002 | } |
| 4003 | /* as-set aggregate route generate origin, as path, |
| 4004 | community aggregation. */ |
| 4005 | if (aggregate->as_set) |
| 4006 | { |
| 4007 | if (origin < ri->attr->origin) |
| 4008 | origin = ri->attr->origin; |
| 4009 | |
| 4010 | if (aspath) |
| 4011 | { |
| 4012 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4013 | aspath_free (aspath); |
| 4014 | aspath = asmerge; |
| 4015 | } |
| 4016 | else |
| 4017 | aspath = aspath_dup (ri->attr->aspath); |
| 4018 | |
| 4019 | if (ri->attr->community) |
| 4020 | { |
| 4021 | if (community) |
| 4022 | { |
| 4023 | commerge = community_merge (community, |
| 4024 | ri->attr->community); |
| 4025 | community = community_uniq_sort (commerge); |
| 4026 | community_free (commerge); |
| 4027 | } |
| 4028 | else |
| 4029 | community = community_dup (ri->attr->community); |
| 4030 | } |
| 4031 | } |
| 4032 | aggregate->count++; |
| 4033 | } |
| 4034 | } |
| 4035 | |
| 4036 | /* If this node is suppressed, process the change. */ |
| 4037 | if (match) |
| 4038 | bgp_process (bgp, rn, afi, safi); |
| 4039 | } |
| 4040 | bgp_unlock_node (top); |
| 4041 | |
| 4042 | /* Add aggregate route to BGP table. */ |
| 4043 | if (aggregate->count) |
| 4044 | { |
| 4045 | rn = bgp_node_get (table, p); |
| 4046 | |
| 4047 | new = bgp_info_new (); |
| 4048 | new->type = ZEBRA_ROUTE_BGP; |
| 4049 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4050 | new->peer = bgp->peer_self; |
| 4051 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4052 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4053 | new->uptime = time (NULL); |
| 4054 | |
| 4055 | bgp_info_add (rn, new); |
| 4056 | |
| 4057 | /* Process change. */ |
| 4058 | bgp_process (bgp, rn, afi, safi); |
| 4059 | } |
| 4060 | } |
| 4061 | |
| 4062 | void |
| 4063 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4064 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4065 | { |
| 4066 | struct bgp_table *table; |
| 4067 | struct bgp_node *top; |
| 4068 | struct bgp_node *rn; |
| 4069 | struct bgp_info *ri; |
| 4070 | unsigned long match; |
| 4071 | |
| 4072 | table = bgp->rib[afi][safi]; |
| 4073 | |
| 4074 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4075 | return; |
| 4076 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4077 | return; |
| 4078 | |
| 4079 | /* If routes exists below this node, generate aggregate routes. */ |
| 4080 | top = bgp_node_get (table, p); |
| 4081 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4082 | if (rn->p.prefixlen > p->prefixlen) |
| 4083 | { |
| 4084 | match = 0; |
| 4085 | |
| 4086 | for (ri = rn->info; ri; ri = ri->next) |
| 4087 | { |
| 4088 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4089 | continue; |
| 4090 | |
| 4091 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4092 | { |
| 4093 | if (aggregate->summary_only) |
| 4094 | { |
| 4095 | ri->suppress--; |
| 4096 | |
| 4097 | if (ri->suppress == 0) |
| 4098 | { |
| 4099 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4100 | match++; |
| 4101 | } |
| 4102 | } |
| 4103 | aggregate->count--; |
| 4104 | } |
| 4105 | } |
| 4106 | |
| 4107 | /* If this node is suppressed, process the change. */ |
| 4108 | if (match) |
| 4109 | bgp_process (bgp, rn, afi, safi); |
| 4110 | } |
| 4111 | bgp_unlock_node (top); |
| 4112 | |
| 4113 | /* Delete aggregate route from BGP table. */ |
| 4114 | rn = bgp_node_get (table, p); |
| 4115 | |
| 4116 | for (ri = rn->info; ri; ri = ri->next) |
| 4117 | if (ri->peer == bgp->peer_self |
| 4118 | && ri->type == ZEBRA_ROUTE_BGP |
| 4119 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4120 | break; |
| 4121 | |
| 4122 | /* Withdraw static BGP route from routing table. */ |
| 4123 | if (ri) |
| 4124 | { |
| 4125 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4126 | bgp_process (bgp, rn, afi, safi); |
| 4127 | bgp_info_delete (rn, ri); |
| 4128 | bgp_info_free (ri); |
| 4129 | bgp_unlock_node (rn); |
| 4130 | } |
| 4131 | |
| 4132 | /* Unlock bgp_node_lookup. */ |
| 4133 | bgp_unlock_node (rn); |
| 4134 | } |
| 4135 | |
| 4136 | /* Aggregate route attribute. */ |
| 4137 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4138 | #define AGGREGATE_AS_SET 1 |
| 4139 | |
| 4140 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4141 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
| 4142 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4143 | u_char summary_only, u_char as_set) |
| 4144 | { |
| 4145 | int ret; |
| 4146 | struct prefix p; |
| 4147 | struct bgp_node *rn; |
| 4148 | struct bgp *bgp; |
| 4149 | struct bgp_aggregate *aggregate; |
| 4150 | |
| 4151 | /* Convert string to prefix structure. */ |
| 4152 | ret = str2prefix (prefix_str, &p); |
| 4153 | if (!ret) |
| 4154 | { |
| 4155 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4156 | return CMD_WARNING; |
| 4157 | } |
| 4158 | apply_mask (&p); |
| 4159 | |
| 4160 | /* Get BGP structure. */ |
| 4161 | bgp = vty->index; |
| 4162 | |
| 4163 | /* Old configuration check. */ |
| 4164 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4165 | |
| 4166 | if (rn->info) |
| 4167 | { |
| 4168 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
| 4169 | bgp_unlock_node (rn); |
| 4170 | return CMD_WARNING; |
| 4171 | } |
| 4172 | |
| 4173 | /* Make aggregate address structure. */ |
| 4174 | aggregate = bgp_aggregate_new (); |
| 4175 | aggregate->summary_only = summary_only; |
| 4176 | aggregate->as_set = as_set; |
| 4177 | aggregate->safi = safi; |
| 4178 | rn->info = aggregate; |
| 4179 | |
| 4180 | /* Aggregate address insert into BGP routing table. */ |
| 4181 | if (safi & SAFI_UNICAST) |
| 4182 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4183 | if (safi & SAFI_MULTICAST) |
| 4184 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4185 | |
| 4186 | return CMD_SUCCESS; |
| 4187 | } |
| 4188 | |
| 4189 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4190 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4191 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4192 | { |
| 4193 | int ret; |
| 4194 | struct prefix p; |
| 4195 | struct bgp_node *rn; |
| 4196 | struct bgp *bgp; |
| 4197 | struct bgp_aggregate *aggregate; |
| 4198 | |
| 4199 | /* Convert string to prefix structure. */ |
| 4200 | ret = str2prefix (prefix_str, &p); |
| 4201 | if (!ret) |
| 4202 | { |
| 4203 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4204 | return CMD_WARNING; |
| 4205 | } |
| 4206 | apply_mask (&p); |
| 4207 | |
| 4208 | /* Get BGP structure. */ |
| 4209 | bgp = vty->index; |
| 4210 | |
| 4211 | /* Old configuration check. */ |
| 4212 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4213 | if (! rn) |
| 4214 | { |
| 4215 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4216 | VTY_NEWLINE); |
| 4217 | return CMD_WARNING; |
| 4218 | } |
| 4219 | |
| 4220 | aggregate = rn->info; |
| 4221 | if (aggregate->safi & SAFI_UNICAST) |
| 4222 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4223 | if (aggregate->safi & SAFI_MULTICAST) |
| 4224 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4225 | |
| 4226 | /* Unlock aggregate address configuration. */ |
| 4227 | rn->info = NULL; |
| 4228 | bgp_aggregate_free (aggregate); |
| 4229 | bgp_unlock_node (rn); |
| 4230 | bgp_unlock_node (rn); |
| 4231 | |
| 4232 | return CMD_SUCCESS; |
| 4233 | } |
| 4234 | |
| 4235 | DEFUN (aggregate_address, |
| 4236 | aggregate_address_cmd, |
| 4237 | "aggregate-address A.B.C.D/M", |
| 4238 | "Configure BGP aggregate entries\n" |
| 4239 | "Aggregate prefix\n") |
| 4240 | { |
| 4241 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 4242 | } |
| 4243 | |
| 4244 | DEFUN (aggregate_address_mask, |
| 4245 | aggregate_address_mask_cmd, |
| 4246 | "aggregate-address A.B.C.D A.B.C.D", |
| 4247 | "Configure BGP aggregate entries\n" |
| 4248 | "Aggregate address\n" |
| 4249 | "Aggregate mask\n") |
| 4250 | { |
| 4251 | int ret; |
| 4252 | char prefix_str[BUFSIZ]; |
| 4253 | |
| 4254 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4255 | |
| 4256 | if (! ret) |
| 4257 | { |
| 4258 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4259 | return CMD_WARNING; |
| 4260 | } |
| 4261 | |
| 4262 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4263 | 0, 0); |
| 4264 | } |
| 4265 | |
| 4266 | DEFUN (aggregate_address_summary_only, |
| 4267 | aggregate_address_summary_only_cmd, |
| 4268 | "aggregate-address A.B.C.D/M summary-only", |
| 4269 | "Configure BGP aggregate entries\n" |
| 4270 | "Aggregate prefix\n" |
| 4271 | "Filter more specific routes from updates\n") |
| 4272 | { |
| 4273 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4274 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4275 | } |
| 4276 | |
| 4277 | DEFUN (aggregate_address_mask_summary_only, |
| 4278 | aggregate_address_mask_summary_only_cmd, |
| 4279 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4280 | "Configure BGP aggregate entries\n" |
| 4281 | "Aggregate address\n" |
| 4282 | "Aggregate mask\n" |
| 4283 | "Filter more specific routes from updates\n") |
| 4284 | { |
| 4285 | int ret; |
| 4286 | char prefix_str[BUFSIZ]; |
| 4287 | |
| 4288 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4289 | |
| 4290 | if (! ret) |
| 4291 | { |
| 4292 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4293 | return CMD_WARNING; |
| 4294 | } |
| 4295 | |
| 4296 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4297 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4298 | } |
| 4299 | |
| 4300 | DEFUN (aggregate_address_as_set, |
| 4301 | aggregate_address_as_set_cmd, |
| 4302 | "aggregate-address A.B.C.D/M as-set", |
| 4303 | "Configure BGP aggregate entries\n" |
| 4304 | "Aggregate prefix\n" |
| 4305 | "Generate AS set path information\n") |
| 4306 | { |
| 4307 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4308 | 0, AGGREGATE_AS_SET); |
| 4309 | } |
| 4310 | |
| 4311 | DEFUN (aggregate_address_mask_as_set, |
| 4312 | aggregate_address_mask_as_set_cmd, |
| 4313 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 4314 | "Configure BGP aggregate entries\n" |
| 4315 | "Aggregate address\n" |
| 4316 | "Aggregate mask\n" |
| 4317 | "Generate AS set path information\n") |
| 4318 | { |
| 4319 | int ret; |
| 4320 | char prefix_str[BUFSIZ]; |
| 4321 | |
| 4322 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4323 | |
| 4324 | if (! ret) |
| 4325 | { |
| 4326 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4327 | return CMD_WARNING; |
| 4328 | } |
| 4329 | |
| 4330 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4331 | 0, AGGREGATE_AS_SET); |
| 4332 | } |
| 4333 | |
| 4334 | |
| 4335 | DEFUN (aggregate_address_as_set_summary, |
| 4336 | aggregate_address_as_set_summary_cmd, |
| 4337 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 4338 | "Configure BGP aggregate entries\n" |
| 4339 | "Aggregate prefix\n" |
| 4340 | "Generate AS set path information\n" |
| 4341 | "Filter more specific routes from updates\n") |
| 4342 | { |
| 4343 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4344 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4345 | } |
| 4346 | |
| 4347 | ALIAS (aggregate_address_as_set_summary, |
| 4348 | aggregate_address_summary_as_set_cmd, |
| 4349 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 4350 | "Configure BGP aggregate entries\n" |
| 4351 | "Aggregate prefix\n" |
| 4352 | "Filter more specific routes from updates\n" |
| 4353 | "Generate AS set path information\n") |
| 4354 | |
| 4355 | DEFUN (aggregate_address_mask_as_set_summary, |
| 4356 | aggregate_address_mask_as_set_summary_cmd, |
| 4357 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4358 | "Configure BGP aggregate entries\n" |
| 4359 | "Aggregate address\n" |
| 4360 | "Aggregate mask\n" |
| 4361 | "Generate AS set path information\n" |
| 4362 | "Filter more specific routes from updates\n") |
| 4363 | { |
| 4364 | int ret; |
| 4365 | char prefix_str[BUFSIZ]; |
| 4366 | |
| 4367 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4368 | |
| 4369 | if (! ret) |
| 4370 | { |
| 4371 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4372 | return CMD_WARNING; |
| 4373 | } |
| 4374 | |
| 4375 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4376 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4377 | } |
| 4378 | |
| 4379 | ALIAS (aggregate_address_mask_as_set_summary, |
| 4380 | aggregate_address_mask_summary_as_set_cmd, |
| 4381 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4382 | "Configure BGP aggregate entries\n" |
| 4383 | "Aggregate address\n" |
| 4384 | "Aggregate mask\n" |
| 4385 | "Filter more specific routes from updates\n" |
| 4386 | "Generate AS set path information\n") |
| 4387 | |
| 4388 | DEFUN (no_aggregate_address, |
| 4389 | no_aggregate_address_cmd, |
| 4390 | "no aggregate-address A.B.C.D/M", |
| 4391 | NO_STR |
| 4392 | "Configure BGP aggregate entries\n" |
| 4393 | "Aggregate prefix\n") |
| 4394 | { |
| 4395 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 4396 | } |
| 4397 | |
| 4398 | ALIAS (no_aggregate_address, |
| 4399 | no_aggregate_address_summary_only_cmd, |
| 4400 | "no aggregate-address A.B.C.D/M summary-only", |
| 4401 | NO_STR |
| 4402 | "Configure BGP aggregate entries\n" |
| 4403 | "Aggregate prefix\n" |
| 4404 | "Filter more specific routes from updates\n") |
| 4405 | |
| 4406 | ALIAS (no_aggregate_address, |
| 4407 | no_aggregate_address_as_set_cmd, |
| 4408 | "no aggregate-address A.B.C.D/M as-set", |
| 4409 | NO_STR |
| 4410 | "Configure BGP aggregate entries\n" |
| 4411 | "Aggregate prefix\n" |
| 4412 | "Generate AS set path information\n") |
| 4413 | |
| 4414 | ALIAS (no_aggregate_address, |
| 4415 | no_aggregate_address_as_set_summary_cmd, |
| 4416 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 4417 | NO_STR |
| 4418 | "Configure BGP aggregate entries\n" |
| 4419 | "Aggregate prefix\n" |
| 4420 | "Generate AS set path information\n" |
| 4421 | "Filter more specific routes from updates\n") |
| 4422 | |
| 4423 | ALIAS (no_aggregate_address, |
| 4424 | no_aggregate_address_summary_as_set_cmd, |
| 4425 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 4426 | NO_STR |
| 4427 | "Configure BGP aggregate entries\n" |
| 4428 | "Aggregate prefix\n" |
| 4429 | "Filter more specific routes from updates\n" |
| 4430 | "Generate AS set path information\n") |
| 4431 | |
| 4432 | DEFUN (no_aggregate_address_mask, |
| 4433 | no_aggregate_address_mask_cmd, |
| 4434 | "no aggregate-address A.B.C.D A.B.C.D", |
| 4435 | NO_STR |
| 4436 | "Configure BGP aggregate entries\n" |
| 4437 | "Aggregate address\n" |
| 4438 | "Aggregate mask\n") |
| 4439 | { |
| 4440 | int ret; |
| 4441 | char prefix_str[BUFSIZ]; |
| 4442 | |
| 4443 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4444 | |
| 4445 | if (! ret) |
| 4446 | { |
| 4447 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4448 | return CMD_WARNING; |
| 4449 | } |
| 4450 | |
| 4451 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 4452 | } |
| 4453 | |
| 4454 | ALIAS (no_aggregate_address_mask, |
| 4455 | no_aggregate_address_mask_summary_only_cmd, |
| 4456 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4457 | NO_STR |
| 4458 | "Configure BGP aggregate entries\n" |
| 4459 | "Aggregate address\n" |
| 4460 | "Aggregate mask\n" |
| 4461 | "Filter more specific routes from updates\n") |
| 4462 | |
| 4463 | ALIAS (no_aggregate_address_mask, |
| 4464 | no_aggregate_address_mask_as_set_cmd, |
| 4465 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 4466 | NO_STR |
| 4467 | "Configure BGP aggregate entries\n" |
| 4468 | "Aggregate address\n" |
| 4469 | "Aggregate mask\n" |
| 4470 | "Generate AS set path information\n") |
| 4471 | |
| 4472 | ALIAS (no_aggregate_address_mask, |
| 4473 | no_aggregate_address_mask_as_set_summary_cmd, |
| 4474 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4475 | NO_STR |
| 4476 | "Configure BGP aggregate entries\n" |
| 4477 | "Aggregate address\n" |
| 4478 | "Aggregate mask\n" |
| 4479 | "Generate AS set path information\n" |
| 4480 | "Filter more specific routes from updates\n") |
| 4481 | |
| 4482 | ALIAS (no_aggregate_address_mask, |
| 4483 | no_aggregate_address_mask_summary_as_set_cmd, |
| 4484 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4485 | NO_STR |
| 4486 | "Configure BGP aggregate entries\n" |
| 4487 | "Aggregate address\n" |
| 4488 | "Aggregate mask\n" |
| 4489 | "Filter more specific routes from updates\n" |
| 4490 | "Generate AS set path information\n") |
| 4491 | |
| 4492 | #ifdef HAVE_IPV6 |
| 4493 | DEFUN (ipv6_aggregate_address, |
| 4494 | ipv6_aggregate_address_cmd, |
| 4495 | "aggregate-address X:X::X:X/M", |
| 4496 | "Configure BGP aggregate entries\n" |
| 4497 | "Aggregate prefix\n") |
| 4498 | { |
| 4499 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 4500 | } |
| 4501 | |
| 4502 | DEFUN (ipv6_aggregate_address_summary_only, |
| 4503 | ipv6_aggregate_address_summary_only_cmd, |
| 4504 | "aggregate-address X:X::X:X/M summary-only", |
| 4505 | "Configure BGP aggregate entries\n" |
| 4506 | "Aggregate prefix\n" |
| 4507 | "Filter more specific routes from updates\n") |
| 4508 | { |
| 4509 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 4510 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4511 | } |
| 4512 | |
| 4513 | DEFUN (no_ipv6_aggregate_address, |
| 4514 | no_ipv6_aggregate_address_cmd, |
| 4515 | "no aggregate-address X:X::X:X/M", |
| 4516 | NO_STR |
| 4517 | "Configure BGP aggregate entries\n" |
| 4518 | "Aggregate prefix\n") |
| 4519 | { |
| 4520 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4521 | } |
| 4522 | |
| 4523 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 4524 | no_ipv6_aggregate_address_summary_only_cmd, |
| 4525 | "no aggregate-address X:X::X:X/M summary-only", |
| 4526 | NO_STR |
| 4527 | "Configure BGP aggregate entries\n" |
| 4528 | "Aggregate prefix\n" |
| 4529 | "Filter more specific routes from updates\n") |
| 4530 | { |
| 4531 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4532 | } |
| 4533 | |
| 4534 | ALIAS (ipv6_aggregate_address, |
| 4535 | old_ipv6_aggregate_address_cmd, |
| 4536 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 4537 | IPV6_STR |
| 4538 | BGP_STR |
| 4539 | "Configure BGP aggregate entries\n" |
| 4540 | "Aggregate prefix\n") |
| 4541 | |
| 4542 | ALIAS (ipv6_aggregate_address_summary_only, |
| 4543 | old_ipv6_aggregate_address_summary_only_cmd, |
| 4544 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4545 | IPV6_STR |
| 4546 | BGP_STR |
| 4547 | "Configure BGP aggregate entries\n" |
| 4548 | "Aggregate prefix\n" |
| 4549 | "Filter more specific routes from updates\n") |
| 4550 | |
| 4551 | ALIAS (no_ipv6_aggregate_address, |
| 4552 | old_no_ipv6_aggregate_address_cmd, |
| 4553 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 4554 | NO_STR |
| 4555 | IPV6_STR |
| 4556 | BGP_STR |
| 4557 | "Configure BGP aggregate entries\n" |
| 4558 | "Aggregate prefix\n") |
| 4559 | |
| 4560 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 4561 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 4562 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4563 | NO_STR |
| 4564 | IPV6_STR |
| 4565 | BGP_STR |
| 4566 | "Configure BGP aggregate entries\n" |
| 4567 | "Aggregate prefix\n" |
| 4568 | "Filter more specific routes from updates\n") |
| 4569 | #endif /* HAVE_IPV6 */ |
| 4570 | |
| 4571 | /* Redistribute route treatment. */ |
| 4572 | void |
| 4573 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, |
| 4574 | u_int32_t metric, u_char type) |
| 4575 | { |
| 4576 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4577 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4578 | struct bgp_info *new; |
| 4579 | struct bgp_info *bi; |
| 4580 | struct bgp_info info; |
| 4581 | struct bgp_node *bn; |
| 4582 | struct attr attr; |
| 4583 | struct attr attr_new; |
| 4584 | struct attr *new_attr; |
| 4585 | afi_t afi; |
| 4586 | int ret; |
| 4587 | |
| 4588 | /* Make default attribute. */ |
| 4589 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 4590 | if (nexthop) |
| 4591 | attr.nexthop = *nexthop; |
| 4592 | |
| 4593 | attr.med = metric; |
| 4594 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 4595 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4596 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4597 | { |
| 4598 | afi = family2afi (p->family); |
| 4599 | |
| 4600 | if (bgp->redist[afi][type]) |
| 4601 | { |
| 4602 | /* Copy attribute for modification. */ |
| 4603 | attr_new = attr; |
| 4604 | |
| 4605 | if (bgp->redist_metric_flag[afi][type]) |
| 4606 | attr_new.med = bgp->redist_metric[afi][type]; |
| 4607 | |
| 4608 | /* Apply route-map. */ |
| 4609 | if (bgp->rmap[afi][type].map) |
| 4610 | { |
| 4611 | info.peer = bgp->peer_self; |
| 4612 | info.attr = &attr_new; |
| 4613 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4614 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 4615 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4616 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 4617 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4618 | |
| 4619 | bgp->peer_self->rmap_type = 0; |
| 4620 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4621 | if (ret == RMAP_DENYMATCH) |
| 4622 | { |
| 4623 | /* Free uninterned attribute. */ |
| 4624 | bgp_attr_flush (&attr_new); |
| 4625 | |
| 4626 | /* Unintern original. */ |
| 4627 | aspath_unintern (attr.aspath); |
| 4628 | bgp_redistribute_delete (p, type); |
| 4629 | return; |
| 4630 | } |
| 4631 | } |
| 4632 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4633 | 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] | 4634 | new_attr = bgp_attr_intern (&attr_new); |
| 4635 | |
| 4636 | for (bi = bn->info; bi; bi = bi->next) |
| 4637 | if (bi->peer == bgp->peer_self |
| 4638 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 4639 | break; |
| 4640 | |
| 4641 | if (bi) |
| 4642 | { |
| 4643 | if (attrhash_cmp (bi->attr, new_attr)) |
| 4644 | { |
| 4645 | bgp_attr_unintern (new_attr); |
| 4646 | aspath_unintern (attr.aspath); |
| 4647 | bgp_unlock_node (bn); |
| 4648 | return; |
| 4649 | } |
| 4650 | else |
| 4651 | { |
| 4652 | /* The attribute is changed. */ |
| 4653 | SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED); |
| 4654 | |
| 4655 | /* Rewrite BGP route information. */ |
| 4656 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
| 4657 | bgp_attr_unintern (bi->attr); |
| 4658 | bi->attr = new_attr; |
| 4659 | bi->uptime = time (NULL); |
| 4660 | |
| 4661 | /* Process change. */ |
| 4662 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 4663 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4664 | bgp_unlock_node (bn); |
| 4665 | aspath_unintern (attr.aspath); |
| 4666 | return; |
| 4667 | } |
| 4668 | } |
| 4669 | |
| 4670 | new = bgp_info_new (); |
| 4671 | new->type = type; |
| 4672 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 4673 | new->peer = bgp->peer_self; |
| 4674 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4675 | new->attr = new_attr; |
| 4676 | new->uptime = time (NULL); |
| 4677 | |
| 4678 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 4679 | bgp_info_add (bn, new); |
| 4680 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4681 | } |
| 4682 | } |
| 4683 | |
| 4684 | /* Unintern original. */ |
| 4685 | aspath_unintern (attr.aspath); |
| 4686 | } |
| 4687 | |
| 4688 | void |
| 4689 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 4690 | { |
| 4691 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4692 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4693 | afi_t afi; |
| 4694 | struct bgp_node *rn; |
| 4695 | struct bgp_info *ri; |
| 4696 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4697 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4698 | { |
| 4699 | afi = family2afi (p->family); |
| 4700 | |
| 4701 | if (bgp->redist[afi][type]) |
| 4702 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4703 | 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] | 4704 | |
| 4705 | for (ri = rn->info; ri; ri = ri->next) |
| 4706 | if (ri->peer == bgp->peer_self |
| 4707 | && ri->type == type) |
| 4708 | break; |
| 4709 | |
| 4710 | if (ri) |
| 4711 | { |
| 4712 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
| 4713 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4714 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4715 | bgp_info_delete (rn, ri); |
| 4716 | bgp_info_free (ri); |
| 4717 | bgp_unlock_node (rn); |
| 4718 | } |
| 4719 | bgp_unlock_node (rn); |
| 4720 | } |
| 4721 | } |
| 4722 | } |
| 4723 | |
| 4724 | /* Withdraw specified route type's route. */ |
| 4725 | void |
| 4726 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 4727 | { |
| 4728 | struct bgp_node *rn; |
| 4729 | struct bgp_info *ri; |
| 4730 | struct bgp_table *table; |
| 4731 | |
| 4732 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 4733 | |
| 4734 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 4735 | { |
| 4736 | for (ri = rn->info; ri; ri = ri->next) |
| 4737 | if (ri->peer == bgp->peer_self |
| 4738 | && ri->type == type) |
| 4739 | break; |
| 4740 | |
| 4741 | if (ri) |
| 4742 | { |
| 4743 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
| 4744 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4745 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4746 | bgp_info_delete (rn, ri); |
| 4747 | bgp_info_free (ri); |
| 4748 | bgp_unlock_node (rn); |
| 4749 | } |
| 4750 | } |
| 4751 | } |
| 4752 | |
| 4753 | /* Static function to display route. */ |
| 4754 | void |
| 4755 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 4756 | { |
| 4757 | int len; |
| 4758 | u_int32_t destination; |
| 4759 | char buf[BUFSIZ]; |
| 4760 | |
| 4761 | if (p->family == AF_INET) |
| 4762 | { |
| 4763 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 4764 | destination = ntohl (p->u.prefix4.s_addr); |
| 4765 | |
| 4766 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 4767 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 4768 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 4769 | || p->u.prefix4.s_addr == 0) |
| 4770 | { |
| 4771 | /* When mask is natural, mask is not displayed. */ |
| 4772 | } |
| 4773 | else |
| 4774 | len += vty_out (vty, "/%d", p->prefixlen); |
| 4775 | } |
| 4776 | else |
| 4777 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 4778 | p->prefixlen); |
| 4779 | |
| 4780 | len = 17 - len; |
| 4781 | if (len < 1) |
| 4782 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 4783 | else |
| 4784 | vty_out (vty, "%*s", len, " "); |
| 4785 | } |
| 4786 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4787 | enum bgp_display_type |
| 4788 | { |
| 4789 | normal_list, |
| 4790 | }; |
| 4791 | |
| 4792 | /* called from terminal list command */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4793 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4794 | route_vty_out (struct vty *vty, struct prefix *p, |
| 4795 | struct bgp_info *binfo, int display, safi_t safi) |
| 4796 | { |
| 4797 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4798 | |
| 4799 | /* Route status display. */ |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 4800 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 4801 | vty_out (vty, "S"); |
| 4802 | else if (binfo->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4803 | vty_out (vty, "s"); |
| 4804 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4805 | vty_out (vty, "*"); |
| 4806 | else |
| 4807 | vty_out (vty, " "); |
| 4808 | |
| 4809 | /* Selected */ |
| 4810 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4811 | vty_out (vty, "h"); |
| 4812 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4813 | vty_out (vty, "d"); |
| 4814 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4815 | vty_out (vty, ">"); |
| 4816 | else |
| 4817 | vty_out (vty, " "); |
| 4818 | |
| 4819 | /* Internal route. */ |
| 4820 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 4821 | vty_out (vty, "i"); |
| 4822 | else |
| 4823 | vty_out (vty, " "); |
| 4824 | |
| 4825 | /* print prefix and mask */ |
| 4826 | if (! display) |
| 4827 | route_vty_out_route (p, vty); |
| 4828 | else |
| 4829 | vty_out (vty, "%*s", 17, " "); |
| 4830 | |
| 4831 | /* Print attribute */ |
| 4832 | attr = binfo->attr; |
| 4833 | if (attr) |
| 4834 | { |
| 4835 | if (p->family == AF_INET) |
| 4836 | { |
| 4837 | if (safi == SAFI_MPLS_VPN) |
| 4838 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4839 | else |
| 4840 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4841 | } |
| 4842 | #ifdef HAVE_IPV6 |
| 4843 | else if (p->family == AF_INET6) |
| 4844 | { |
| 4845 | int len; |
| 4846 | char buf[BUFSIZ]; |
| 4847 | |
| 4848 | len = vty_out (vty, "%s", |
| 4849 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 4850 | len = 16 - len; |
| 4851 | if (len < 1) |
| 4852 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 4853 | else |
| 4854 | vty_out (vty, "%*s", len, " "); |
| 4855 | } |
| 4856 | #endif /* HAVE_IPV6 */ |
| 4857 | |
| 4858 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 4859 | vty_out (vty, "%10d", attr->med); |
| 4860 | else |
| 4861 | vty_out (vty, " "); |
| 4862 | |
| 4863 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 4864 | vty_out (vty, "%7d", attr->local_pref); |
| 4865 | else |
| 4866 | vty_out (vty, " "); |
| 4867 | |
| 4868 | vty_out (vty, "%7u ",attr->weight); |
| 4869 | |
| 4870 | /* Print aspath */ |
| 4871 | if (attr->aspath) |
| 4872 | aspath_print_vty (vty, attr->aspath); |
| 4873 | |
| 4874 | /* Print origin */ |
| 4875 | if (strlen (attr->aspath->str) == 0) |
| 4876 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4877 | else |
| 4878 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4879 | } |
| 4880 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4881 | } |
| 4882 | |
| 4883 | /* called from terminal list command */ |
| 4884 | void |
| 4885 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 4886 | struct attr *attr, safi_t safi) |
| 4887 | { |
| 4888 | /* Route status display. */ |
| 4889 | vty_out (vty, "*"); |
| 4890 | vty_out (vty, ">"); |
| 4891 | vty_out (vty, " "); |
| 4892 | |
| 4893 | /* print prefix and mask */ |
| 4894 | route_vty_out_route (p, vty); |
| 4895 | |
| 4896 | /* Print attribute */ |
| 4897 | if (attr) |
| 4898 | { |
| 4899 | if (p->family == AF_INET) |
| 4900 | { |
| 4901 | if (safi == SAFI_MPLS_VPN) |
| 4902 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4903 | else |
| 4904 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4905 | } |
| 4906 | #ifdef HAVE_IPV6 |
| 4907 | else if (p->family == AF_INET6) |
| 4908 | { |
| 4909 | int len; |
| 4910 | char buf[BUFSIZ]; |
| 4911 | |
| 4912 | len = vty_out (vty, "%s", |
| 4913 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 4914 | len = 16 - len; |
| 4915 | if (len < 1) |
| 4916 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 4917 | else |
| 4918 | vty_out (vty, "%*s", len, " "); |
| 4919 | } |
| 4920 | #endif /* HAVE_IPV6 */ |
| 4921 | |
| 4922 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 4923 | vty_out (vty, "%10d", attr->med); |
| 4924 | else |
| 4925 | vty_out (vty, " "); |
| 4926 | |
| 4927 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 4928 | vty_out (vty, "%7d", attr->local_pref); |
| 4929 | else |
| 4930 | vty_out (vty, " "); |
| 4931 | |
| 4932 | vty_out (vty, "%7d ",attr->weight); |
| 4933 | |
| 4934 | /* Print aspath */ |
| 4935 | if (attr->aspath) |
| 4936 | aspath_print_vty (vty, attr->aspath); |
| 4937 | |
| 4938 | /* Print origin */ |
| 4939 | if (strlen (attr->aspath->str) == 0) |
| 4940 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 4941 | else |
| 4942 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 4943 | } |
| 4944 | |
| 4945 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4946 | } |
| 4947 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 4948 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4949 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 4950 | struct bgp_info *binfo, int display, safi_t safi) |
| 4951 | { |
| 4952 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4953 | u_int32_t label = 0; |
| 4954 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4955 | /* Route status display. */ |
| 4956 | if (binfo->suppress) |
| 4957 | vty_out (vty, "s"); |
| 4958 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4959 | vty_out (vty, "*"); |
| 4960 | else |
| 4961 | vty_out (vty, " "); |
| 4962 | |
| 4963 | /* Selected */ |
| 4964 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 4965 | vty_out (vty, "h"); |
| 4966 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 4967 | vty_out (vty, "d"); |
| 4968 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 4969 | vty_out (vty, ">"); |
| 4970 | else |
| 4971 | vty_out (vty, " "); |
| 4972 | |
| 4973 | /* Internal route. */ |
| 4974 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 4975 | vty_out (vty, "i"); |
| 4976 | else |
| 4977 | vty_out (vty, " "); |
| 4978 | |
| 4979 | /* print prefix and mask */ |
| 4980 | if (! display) |
| 4981 | route_vty_out_route (p, vty); |
| 4982 | else |
| 4983 | vty_out (vty, "%*s", 17, " "); |
| 4984 | |
| 4985 | /* Print attribute */ |
| 4986 | attr = binfo->attr; |
| 4987 | if (attr) |
| 4988 | { |
| 4989 | if (p->family == AF_INET) |
| 4990 | { |
| 4991 | if (safi == SAFI_MPLS_VPN) |
| 4992 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 4993 | else |
| 4994 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 4995 | } |
| 4996 | #ifdef HAVE_IPV6 |
| 4997 | else if (p->family == AF_INET6) |
| 4998 | { |
| 4999 | char buf[BUFSIZ]; |
| 5000 | char buf1[BUFSIZ]; |
| 5001 | if (attr->mp_nexthop_len == 16) |
| 5002 | vty_out (vty, "%s", |
| 5003 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5004 | else if (attr->mp_nexthop_len == 32) |
| 5005 | vty_out (vty, "%s(%s)", |
| 5006 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ), |
| 5007 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ)); |
| 5008 | |
| 5009 | } |
| 5010 | #endif /* HAVE_IPV6 */ |
| 5011 | } |
| 5012 | |
| 5013 | label = decode_label (binfo->tag); |
| 5014 | |
| 5015 | vty_out (vty, "notag/%d", label); |
| 5016 | |
| 5017 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5018 | } |
| 5019 | |
| 5020 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5021 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5022 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5023 | struct bgp_info *binfo, int display, safi_t safi) |
| 5024 | { |
| 5025 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5026 | int len; |
| 5027 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5028 | /* Route status display. */ |
| 5029 | if (binfo->suppress) |
| 5030 | vty_out (vty, "s"); |
| 5031 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5032 | vty_out (vty, "*"); |
| 5033 | else |
| 5034 | vty_out (vty, " "); |
| 5035 | |
| 5036 | /* Selected */ |
| 5037 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5038 | vty_out (vty, "h"); |
| 5039 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5040 | vty_out (vty, "d"); |
| 5041 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5042 | vty_out (vty, ">"); |
| 5043 | else |
| 5044 | vty_out (vty, " "); |
| 5045 | |
| 5046 | vty_out (vty, " "); |
| 5047 | |
| 5048 | /* print prefix and mask */ |
| 5049 | if (! display) |
| 5050 | route_vty_out_route (p, vty); |
| 5051 | else |
| 5052 | vty_out (vty, "%*s", 17, " "); |
| 5053 | |
| 5054 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5055 | len = 17 - len; |
| 5056 | if (len < 1) |
| 5057 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5058 | else |
| 5059 | vty_out (vty, "%*s", len, " "); |
| 5060 | |
| 5061 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5062 | |
| 5063 | /* Print attribute */ |
| 5064 | attr = binfo->attr; |
| 5065 | if (attr) |
| 5066 | { |
| 5067 | /* Print aspath */ |
| 5068 | if (attr->aspath) |
| 5069 | aspath_print_vty (vty, attr->aspath); |
| 5070 | |
| 5071 | /* Print origin */ |
| 5072 | if (strlen (attr->aspath->str) == 0) |
| 5073 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5074 | else |
| 5075 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5076 | } |
| 5077 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5078 | } |
| 5079 | |
| 5080 | #define BGP_UPTIME_LEN 25 |
| 5081 | |
| 5082 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5083 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5084 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5085 | struct bgp_info *binfo, int display, safi_t safi) |
| 5086 | { |
| 5087 | struct attr *attr; |
| 5088 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5089 | char timebuf[BGP_UPTIME_LEN]; |
| 5090 | int len; |
| 5091 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5092 | bdi = binfo->damp_info; |
| 5093 | |
| 5094 | /* Route status display. */ |
| 5095 | if (binfo->suppress) |
| 5096 | vty_out (vty, "s"); |
| 5097 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5098 | vty_out (vty, "*"); |
| 5099 | else |
| 5100 | vty_out (vty, " "); |
| 5101 | |
| 5102 | /* Selected */ |
| 5103 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5104 | vty_out (vty, "h"); |
| 5105 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5106 | vty_out (vty, "d"); |
| 5107 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5108 | vty_out (vty, ">"); |
| 5109 | else |
| 5110 | vty_out (vty, " "); |
| 5111 | |
| 5112 | vty_out (vty, " "); |
| 5113 | |
| 5114 | /* print prefix and mask */ |
| 5115 | if (! display) |
| 5116 | route_vty_out_route (p, vty); |
| 5117 | else |
| 5118 | vty_out (vty, "%*s", 17, " "); |
| 5119 | |
| 5120 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5121 | len = 16 - len; |
| 5122 | if (len < 1) |
| 5123 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5124 | else |
| 5125 | vty_out (vty, "%*s", len, " "); |
| 5126 | |
| 5127 | len = vty_out (vty, "%d", bdi->flap); |
| 5128 | len = 5 - len; |
| 5129 | if (len < 1) |
| 5130 | vty_out (vty, " "); |
| 5131 | else |
| 5132 | vty_out (vty, "%*s ", len, " "); |
| 5133 | |
| 5134 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5135 | timebuf, BGP_UPTIME_LEN)); |
| 5136 | |
| 5137 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5138 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5139 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5140 | else |
| 5141 | vty_out (vty, "%*s ", 8, " "); |
| 5142 | |
| 5143 | /* Print attribute */ |
| 5144 | attr = binfo->attr; |
| 5145 | if (attr) |
| 5146 | { |
| 5147 | /* Print aspath */ |
| 5148 | if (attr->aspath) |
| 5149 | aspath_print_vty (vty, attr->aspath); |
| 5150 | |
| 5151 | /* Print origin */ |
| 5152 | if (strlen (attr->aspath->str) == 0) |
| 5153 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5154 | else |
| 5155 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5156 | } |
| 5157 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5158 | } |
| 5159 | |
| 5160 | void |
| 5161 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5162 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5163 | { |
| 5164 | char buf[INET6_ADDRSTRLEN]; |
| 5165 | char buf1[BUFSIZ]; |
| 5166 | struct attr *attr; |
| 5167 | int sockunion_vty_out (struct vty *, union sockunion *); |
| 5168 | |
| 5169 | attr = binfo->attr; |
| 5170 | |
| 5171 | if (attr) |
| 5172 | { |
| 5173 | /* Line1 display AS-path, Aggregator */ |
| 5174 | if (attr->aspath) |
| 5175 | { |
| 5176 | vty_out (vty, " "); |
| 5177 | if (attr->aspath->length == 0) |
| 5178 | vty_out (vty, "Local"); |
| 5179 | else |
| 5180 | aspath_print_vty (vty, attr->aspath); |
| 5181 | } |
| 5182 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5183 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5184 | vty_out (vty, ", (stale)"); |
| 5185 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
| 5186 | vty_out (vty, ", (aggregated by %d %s)", attr->aggregator_as, |
| 5187 | inet_ntoa (attr->aggregator_addr)); |
| 5188 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5189 | vty_out (vty, ", (Received from a RR-client)"); |
| 5190 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5191 | vty_out (vty, ", (Received from a RS-client)"); |
| 5192 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5193 | vty_out (vty, ", (history entry)"); |
| 5194 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5195 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5196 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5197 | |
| 5198 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5199 | if (p->family == AF_INET) |
| 5200 | { |
| 5201 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
| 5202 | inet_ntoa (attr->mp_nexthop_global_in) : |
| 5203 | inet_ntoa (attr->nexthop)); |
| 5204 | } |
| 5205 | #ifdef HAVE_IPV6 |
| 5206 | else |
| 5207 | { |
| 5208 | vty_out (vty, " %s", |
| 5209 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, |
| 5210 | buf, INET6_ADDRSTRLEN)); |
| 5211 | } |
| 5212 | #endif /* HAVE_IPV6 */ |
| 5213 | |
| 5214 | if (binfo->peer == bgp->peer_self) |
| 5215 | { |
| 5216 | vty_out (vty, " from %s ", |
| 5217 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5218 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5219 | } |
| 5220 | else |
| 5221 | { |
| 5222 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5223 | vty_out (vty, " (inaccessible)"); |
| 5224 | else if (binfo->igpmetric) |
| 5225 | vty_out (vty, " (metric %d)", binfo->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5226 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5227 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5228 | vty_out (vty, " (%s)", inet_ntoa (attr->originator_id)); |
| 5229 | else |
| 5230 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5231 | } |
| 5232 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5233 | |
| 5234 | #ifdef HAVE_IPV6 |
| 5235 | /* display nexthop local */ |
| 5236 | if (attr->mp_nexthop_len == 32) |
| 5237 | { |
| 5238 | vty_out (vty, " (%s)%s", |
| 5239 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, |
| 5240 | buf, INET6_ADDRSTRLEN), |
| 5241 | VTY_NEWLINE); |
| 5242 | } |
| 5243 | #endif /* HAVE_IPV6 */ |
| 5244 | |
| 5245 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5246 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5247 | |
| 5248 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
| 5249 | vty_out (vty, ", metric %d", attr->med); |
| 5250 | |
| 5251 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
| 5252 | vty_out (vty, ", localpref %d", attr->local_pref); |
| 5253 | else |
| 5254 | vty_out (vty, ", localpref %d", bgp->default_local_pref); |
| 5255 | |
| 5256 | if (attr->weight != 0) |
| 5257 | vty_out (vty, ", weight %d", attr->weight); |
| 5258 | |
| 5259 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5260 | vty_out (vty, ", valid"); |
| 5261 | |
| 5262 | if (binfo->peer != bgp->peer_self) |
| 5263 | { |
| 5264 | if (binfo->peer->as == binfo->peer->local_as) |
| 5265 | vty_out (vty, ", internal"); |
| 5266 | else |
| 5267 | vty_out (vty, ", %s", |
| 5268 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 5269 | } |
| 5270 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 5271 | vty_out (vty, ", aggregated, local"); |
| 5272 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 5273 | vty_out (vty, ", sourced"); |
| 5274 | else |
| 5275 | vty_out (vty, ", sourced, local"); |
| 5276 | |
| 5277 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5278 | vty_out (vty, ", atomic-aggregate"); |
| 5279 | |
| 5280 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5281 | vty_out (vty, ", best"); |
| 5282 | |
| 5283 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5284 | |
| 5285 | /* Line 4 display Community */ |
| 5286 | if (attr->community) |
| 5287 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 5288 | VTY_NEWLINE); |
| 5289 | |
| 5290 | /* Line 5 display Extended-community */ |
| 5291 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
| 5292 | vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str, |
| 5293 | VTY_NEWLINE); |
| 5294 | |
| 5295 | /* Line 6 display Originator, Cluster-id */ |
| 5296 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 5297 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 5298 | { |
| 5299 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5300 | vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id)); |
| 5301 | |
| 5302 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 5303 | { |
| 5304 | int i; |
| 5305 | vty_out (vty, ", Cluster list: "); |
| 5306 | for (i = 0; i < attr->cluster->length / 4; i++) |
| 5307 | vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i])); |
| 5308 | } |
| 5309 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5310 | } |
| 5311 | |
| 5312 | if (binfo->damp_info) |
| 5313 | bgp_damp_info_vty (vty, binfo); |
| 5314 | |
| 5315 | /* Line 7 display Uptime */ |
| 5316 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); |
| 5317 | } |
| 5318 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5319 | } |
| 5320 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5321 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale%s" |
| 5322 | #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5323 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 5324 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 5325 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 5326 | |
| 5327 | enum bgp_show_type |
| 5328 | { |
| 5329 | bgp_show_type_normal, |
| 5330 | bgp_show_type_regexp, |
| 5331 | bgp_show_type_prefix_list, |
| 5332 | bgp_show_type_filter_list, |
| 5333 | bgp_show_type_route_map, |
| 5334 | bgp_show_type_neighbor, |
| 5335 | bgp_show_type_cidr_only, |
| 5336 | bgp_show_type_prefix_longer, |
| 5337 | bgp_show_type_community_all, |
| 5338 | bgp_show_type_community, |
| 5339 | bgp_show_type_community_exact, |
| 5340 | bgp_show_type_community_list, |
| 5341 | bgp_show_type_community_list_exact, |
| 5342 | bgp_show_type_flap_statistics, |
| 5343 | bgp_show_type_flap_address, |
| 5344 | bgp_show_type_flap_prefix, |
| 5345 | bgp_show_type_flap_cidr_only, |
| 5346 | bgp_show_type_flap_regexp, |
| 5347 | bgp_show_type_flap_filter_list, |
| 5348 | bgp_show_type_flap_prefix_list, |
| 5349 | bgp_show_type_flap_prefix_longer, |
| 5350 | bgp_show_type_flap_route_map, |
| 5351 | bgp_show_type_flap_neighbor, |
| 5352 | bgp_show_type_dampend_paths, |
| 5353 | bgp_show_type_damp_neighbor |
| 5354 | }; |
| 5355 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5356 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5357 | 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] | 5358 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5359 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5360 | struct bgp_info *ri; |
| 5361 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5362 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5363 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5364 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5365 | |
| 5366 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5367 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5368 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5369 | /* Start processing of routes. */ |
| 5370 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5371 | if (rn->info != NULL) |
| 5372 | { |
| 5373 | display = 0; |
| 5374 | |
| 5375 | for (ri = rn->info; ri; ri = ri->next) |
| 5376 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5377 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5378 | || type == bgp_show_type_flap_address |
| 5379 | || type == bgp_show_type_flap_prefix |
| 5380 | || type == bgp_show_type_flap_cidr_only |
| 5381 | || type == bgp_show_type_flap_regexp |
| 5382 | || type == bgp_show_type_flap_filter_list |
| 5383 | || type == bgp_show_type_flap_prefix_list |
| 5384 | || type == bgp_show_type_flap_prefix_longer |
| 5385 | || type == bgp_show_type_flap_route_map |
| 5386 | || type == bgp_show_type_flap_neighbor |
| 5387 | || type == bgp_show_type_dampend_paths |
| 5388 | || type == bgp_show_type_damp_neighbor) |
| 5389 | { |
| 5390 | if (! ri->damp_info) |
| 5391 | continue; |
| 5392 | } |
| 5393 | if (type == bgp_show_type_regexp |
| 5394 | || type == bgp_show_type_flap_regexp) |
| 5395 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5396 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5397 | |
| 5398 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 5399 | continue; |
| 5400 | } |
| 5401 | if (type == bgp_show_type_prefix_list |
| 5402 | || type == bgp_show_type_flap_prefix_list) |
| 5403 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5404 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5405 | |
| 5406 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 5407 | continue; |
| 5408 | } |
| 5409 | if (type == bgp_show_type_filter_list |
| 5410 | || type == bgp_show_type_flap_filter_list) |
| 5411 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5412 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5413 | |
| 5414 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 5415 | continue; |
| 5416 | } |
| 5417 | if (type == bgp_show_type_route_map |
| 5418 | || type == bgp_show_type_flap_route_map) |
| 5419 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5420 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5421 | struct bgp_info binfo; |
| 5422 | struct attr dummy_attr; |
| 5423 | int ret; |
| 5424 | |
| 5425 | dummy_attr = *ri->attr; |
| 5426 | binfo.peer = ri->peer; |
| 5427 | binfo.attr = &dummy_attr; |
| 5428 | |
| 5429 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 5430 | |
| 5431 | if (ret == RMAP_DENYMATCH) |
| 5432 | continue; |
| 5433 | } |
| 5434 | if (type == bgp_show_type_neighbor |
| 5435 | || type == bgp_show_type_flap_neighbor |
| 5436 | || type == bgp_show_type_damp_neighbor) |
| 5437 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5438 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5439 | |
| 5440 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 5441 | continue; |
| 5442 | } |
| 5443 | if (type == bgp_show_type_cidr_only |
| 5444 | || type == bgp_show_type_flap_cidr_only) |
| 5445 | { |
| 5446 | u_int32_t destination; |
| 5447 | |
| 5448 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 5449 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 5450 | continue; |
| 5451 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 5452 | continue; |
| 5453 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 5454 | continue; |
| 5455 | } |
| 5456 | if (type == bgp_show_type_prefix_longer |
| 5457 | || type == bgp_show_type_flap_prefix_longer) |
| 5458 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5459 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5460 | |
| 5461 | if (! prefix_match (p, &rn->p)) |
| 5462 | continue; |
| 5463 | } |
| 5464 | if (type == bgp_show_type_community_all) |
| 5465 | { |
| 5466 | if (! ri->attr->community) |
| 5467 | continue; |
| 5468 | } |
| 5469 | if (type == bgp_show_type_community) |
| 5470 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5471 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5472 | |
| 5473 | if (! ri->attr->community || |
| 5474 | ! community_match (ri->attr->community, com)) |
| 5475 | continue; |
| 5476 | } |
| 5477 | if (type == bgp_show_type_community_exact) |
| 5478 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5479 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5480 | |
| 5481 | if (! ri->attr->community || |
| 5482 | ! community_cmp (ri->attr->community, com)) |
| 5483 | continue; |
| 5484 | } |
| 5485 | if (type == bgp_show_type_community_list) |
| 5486 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5487 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5488 | |
| 5489 | if (! community_list_match (ri->attr->community, list)) |
| 5490 | continue; |
| 5491 | } |
| 5492 | if (type == bgp_show_type_community_list_exact) |
| 5493 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5494 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5495 | |
| 5496 | if (! community_list_exact_match (ri->attr->community, list)) |
| 5497 | continue; |
| 5498 | } |
| 5499 | if (type == bgp_show_type_flap_address |
| 5500 | || type == bgp_show_type_flap_prefix) |
| 5501 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5502 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5503 | |
| 5504 | if (! prefix_match (&rn->p, p)) |
| 5505 | continue; |
| 5506 | |
| 5507 | if (type == bgp_show_type_flap_prefix) |
| 5508 | if (p->prefixlen != rn->p.prefixlen) |
| 5509 | continue; |
| 5510 | } |
| 5511 | if (type == bgp_show_type_dampend_paths |
| 5512 | || type == bgp_show_type_damp_neighbor) |
| 5513 | { |
| 5514 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 5515 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 5516 | continue; |
| 5517 | } |
| 5518 | |
| 5519 | if (header) |
| 5520 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5521 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 5522 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 5523 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5524 | if (type == bgp_show_type_dampend_paths |
| 5525 | || type == bgp_show_type_damp_neighbor) |
| 5526 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 5527 | else if (type == bgp_show_type_flap_statistics |
| 5528 | || type == bgp_show_type_flap_address |
| 5529 | || type == bgp_show_type_flap_prefix |
| 5530 | || type == bgp_show_type_flap_cidr_only |
| 5531 | || type == bgp_show_type_flap_regexp |
| 5532 | || type == bgp_show_type_flap_filter_list |
| 5533 | || type == bgp_show_type_flap_prefix_list |
| 5534 | || type == bgp_show_type_flap_prefix_longer |
| 5535 | || type == bgp_show_type_flap_route_map |
| 5536 | || type == bgp_show_type_flap_neighbor) |
| 5537 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 5538 | else |
| 5539 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5540 | header = 0; |
| 5541 | } |
| 5542 | |
| 5543 | if (type == bgp_show_type_dampend_paths |
| 5544 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5545 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5546 | else if (type == bgp_show_type_flap_statistics |
| 5547 | || type == bgp_show_type_flap_address |
| 5548 | || type == bgp_show_type_flap_prefix |
| 5549 | || type == bgp_show_type_flap_cidr_only |
| 5550 | || type == bgp_show_type_flap_regexp |
| 5551 | || type == bgp_show_type_flap_filter_list |
| 5552 | || type == bgp_show_type_flap_prefix_list |
| 5553 | || type == bgp_show_type_flap_prefix_longer |
| 5554 | || type == bgp_show_type_flap_route_map |
| 5555 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5556 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5557 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5558 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5559 | display++; |
| 5560 | } |
| 5561 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5562 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5563 | } |
| 5564 | |
| 5565 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5566 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5567 | { |
| 5568 | if (type == bgp_show_type_normal) |
| 5569 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 5570 | } |
| 5571 | else |
| 5572 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5573 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5574 | |
| 5575 | return CMD_SUCCESS; |
| 5576 | } |
| 5577 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5578 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5579 | 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] | 5580 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5581 | { |
| 5582 | struct bgp_table *table; |
| 5583 | |
| 5584 | if (bgp == NULL) { |
| 5585 | bgp = bgp_get_default (); |
| 5586 | } |
| 5587 | |
| 5588 | if (bgp == NULL) |
| 5589 | { |
| 5590 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5591 | return CMD_WARNING; |
| 5592 | } |
| 5593 | |
| 5594 | |
| 5595 | table = bgp->rib[afi][safi]; |
| 5596 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5597 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5598 | } |
| 5599 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5600 | /* Header of detailed BGP route information */ |
| 5601 | void |
| 5602 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 5603 | struct bgp_node *rn, |
| 5604 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 5605 | { |
| 5606 | struct bgp_info *ri; |
| 5607 | struct prefix *p; |
| 5608 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5609 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5610 | char buf1[INET6_ADDRSTRLEN]; |
| 5611 | char buf2[INET6_ADDRSTRLEN]; |
| 5612 | int count = 0; |
| 5613 | int best = 0; |
| 5614 | int suppress = 0; |
| 5615 | int no_export = 0; |
| 5616 | int no_advertise = 0; |
| 5617 | int local_as = 0; |
| 5618 | int first = 0; |
| 5619 | |
| 5620 | p = &rn->p; |
| 5621 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 5622 | (safi == SAFI_MPLS_VPN ? |
| 5623 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 5624 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 5625 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 5626 | p->prefixlen, VTY_NEWLINE); |
| 5627 | |
| 5628 | for (ri = rn->info; ri; ri = ri->next) |
| 5629 | { |
| 5630 | count++; |
| 5631 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 5632 | { |
| 5633 | best = count; |
| 5634 | if (ri->suppress) |
| 5635 | suppress = 1; |
| 5636 | if (ri->attr->community != NULL) |
| 5637 | { |
| 5638 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 5639 | no_advertise = 1; |
| 5640 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 5641 | no_export = 1; |
| 5642 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 5643 | local_as = 1; |
| 5644 | } |
| 5645 | } |
| 5646 | } |
| 5647 | |
| 5648 | vty_out (vty, "Paths: (%d available", count); |
| 5649 | if (best) |
| 5650 | { |
| 5651 | vty_out (vty, ", best #%d", best); |
| 5652 | if (safi == SAFI_UNICAST) |
| 5653 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 5654 | } |
| 5655 | else |
| 5656 | vty_out (vty, ", no best path"); |
| 5657 | if (no_advertise) |
| 5658 | vty_out (vty, ", not advertised to any peer"); |
| 5659 | else if (no_export) |
| 5660 | vty_out (vty, ", not advertised to EBGP peer"); |
| 5661 | else if (local_as) |
| 5662 | vty_out (vty, ", not advertised outside local AS"); |
| 5663 | if (suppress) |
| 5664 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 5665 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 5666 | |
| 5667 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5668 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5669 | { |
| 5670 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 5671 | { |
| 5672 | if (! first) |
| 5673 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 5674 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 5675 | first = 1; |
| 5676 | } |
| 5677 | } |
| 5678 | if (! first) |
| 5679 | vty_out (vty, " Not advertised to any peer"); |
| 5680 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5681 | } |
| 5682 | |
| 5683 | /* Display specified route of BGP table. */ |
| 5684 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5685 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5686 | struct bgp_table *rib, const char *ip_str, |
| 5687 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5688 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5689 | { |
| 5690 | int ret; |
| 5691 | int header; |
| 5692 | int display = 0; |
| 5693 | struct prefix match; |
| 5694 | struct bgp_node *rn; |
| 5695 | struct bgp_node *rm; |
| 5696 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5697 | struct bgp_table *table; |
| 5698 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5699 | /* Check IP address argument. */ |
| 5700 | ret = str2prefix (ip_str, &match); |
| 5701 | if (! ret) |
| 5702 | { |
| 5703 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 5704 | return CMD_WARNING; |
| 5705 | } |
| 5706 | |
| 5707 | match.family = afi2family (afi); |
| 5708 | |
| 5709 | if (safi == SAFI_MPLS_VPN) |
| 5710 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5711 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5712 | { |
| 5713 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 5714 | continue; |
| 5715 | |
| 5716 | if ((table = rn->info) != NULL) |
| 5717 | { |
| 5718 | header = 1; |
| 5719 | |
| 5720 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 5721 | { |
| 5722 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 5723 | continue; |
| 5724 | |
| 5725 | for (ri = rm->info; ri; ri = ri->next) |
| 5726 | { |
| 5727 | if (header) |
| 5728 | { |
| 5729 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 5730 | AFI_IP, SAFI_MPLS_VPN); |
| 5731 | |
| 5732 | header = 0; |
| 5733 | } |
| 5734 | display++; |
| 5735 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 5736 | } |
| 5737 | } |
| 5738 | } |
| 5739 | } |
| 5740 | } |
| 5741 | else |
| 5742 | { |
| 5743 | header = 1; |
| 5744 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5745 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5746 | { |
| 5747 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 5748 | { |
| 5749 | for (ri = rn->info; ri; ri = ri->next) |
| 5750 | { |
| 5751 | if (header) |
| 5752 | { |
| 5753 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 5754 | header = 0; |
| 5755 | } |
| 5756 | display++; |
| 5757 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 5758 | } |
| 5759 | } |
| 5760 | } |
| 5761 | } |
| 5762 | |
| 5763 | if (! display) |
| 5764 | { |
| 5765 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 5766 | return CMD_WARNING; |
| 5767 | } |
| 5768 | |
| 5769 | return CMD_SUCCESS; |
| 5770 | } |
| 5771 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5772 | /* Display specified route of Main RIB */ |
| 5773 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5774 | 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] | 5775 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5776 | int prefix_check) |
| 5777 | { |
| 5778 | struct bgp *bgp; |
| 5779 | |
| 5780 | /* BGP structure lookup. */ |
| 5781 | if (view_name) |
| 5782 | { |
| 5783 | bgp = bgp_lookup_by_name (view_name); |
| 5784 | if (bgp == NULL) |
| 5785 | { |
| 5786 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 5787 | return CMD_WARNING; |
| 5788 | } |
| 5789 | } |
| 5790 | else |
| 5791 | { |
| 5792 | bgp = bgp_get_default (); |
| 5793 | if (bgp == NULL) |
| 5794 | { |
| 5795 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5796 | return CMD_WARNING; |
| 5797 | } |
| 5798 | } |
| 5799 | |
| 5800 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 5801 | afi, safi, prd, prefix_check); |
| 5802 | } |
| 5803 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5804 | /* BGP route print out function. */ |
| 5805 | DEFUN (show_ip_bgp, |
| 5806 | show_ip_bgp_cmd, |
| 5807 | "show ip bgp", |
| 5808 | SHOW_STR |
| 5809 | IP_STR |
| 5810 | BGP_STR) |
| 5811 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5812 | 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] | 5813 | } |
| 5814 | |
| 5815 | DEFUN (show_ip_bgp_ipv4, |
| 5816 | show_ip_bgp_ipv4_cmd, |
| 5817 | "show ip bgp ipv4 (unicast|multicast)", |
| 5818 | SHOW_STR |
| 5819 | IP_STR |
| 5820 | BGP_STR |
| 5821 | "Address family\n" |
| 5822 | "Address Family modifier\n" |
| 5823 | "Address Family modifier\n") |
| 5824 | { |
| 5825 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5826 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 5827 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5828 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5829 | 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] | 5830 | } |
| 5831 | |
| 5832 | DEFUN (show_ip_bgp_route, |
| 5833 | show_ip_bgp_route_cmd, |
| 5834 | "show ip bgp A.B.C.D", |
| 5835 | SHOW_STR |
| 5836 | IP_STR |
| 5837 | BGP_STR |
| 5838 | "Network in the BGP routing table to display\n") |
| 5839 | { |
| 5840 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5841 | } |
| 5842 | |
| 5843 | DEFUN (show_ip_bgp_ipv4_route, |
| 5844 | show_ip_bgp_ipv4_route_cmd, |
| 5845 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 5846 | SHOW_STR |
| 5847 | IP_STR |
| 5848 | BGP_STR |
| 5849 | "Address family\n" |
| 5850 | "Address Family modifier\n" |
| 5851 | "Address Family modifier\n" |
| 5852 | "Network in the BGP routing table to display\n") |
| 5853 | { |
| 5854 | if (strncmp (argv[0], "m", 1) == 0) |
| 5855 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 5856 | |
| 5857 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5858 | } |
| 5859 | |
| 5860 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 5861 | show_ip_bgp_vpnv4_all_route_cmd, |
| 5862 | "show ip bgp vpnv4 all A.B.C.D", |
| 5863 | SHOW_STR |
| 5864 | IP_STR |
| 5865 | BGP_STR |
| 5866 | "Display VPNv4 NLRI specific information\n" |
| 5867 | "Display information about all VPNv4 NLRIs\n" |
| 5868 | "Network in the BGP routing table to display\n") |
| 5869 | { |
| 5870 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 5871 | } |
| 5872 | |
| 5873 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 5874 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 5875 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 5876 | SHOW_STR |
| 5877 | IP_STR |
| 5878 | BGP_STR |
| 5879 | "Display VPNv4 NLRI specific information\n" |
| 5880 | "Display information for a route distinguisher\n" |
| 5881 | "VPN Route Distinguisher\n" |
| 5882 | "Network in the BGP routing table to display\n") |
| 5883 | { |
| 5884 | int ret; |
| 5885 | struct prefix_rd prd; |
| 5886 | |
| 5887 | ret = str2prefix_rd (argv[0], &prd); |
| 5888 | if (! ret) |
| 5889 | { |
| 5890 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5891 | return CMD_WARNING; |
| 5892 | } |
| 5893 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 5894 | } |
| 5895 | |
| 5896 | DEFUN (show_ip_bgp_prefix, |
| 5897 | show_ip_bgp_prefix_cmd, |
| 5898 | "show ip bgp A.B.C.D/M", |
| 5899 | SHOW_STR |
| 5900 | IP_STR |
| 5901 | BGP_STR |
| 5902 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5903 | { |
| 5904 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5905 | } |
| 5906 | |
| 5907 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 5908 | show_ip_bgp_ipv4_prefix_cmd, |
| 5909 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 5910 | SHOW_STR |
| 5911 | IP_STR |
| 5912 | BGP_STR |
| 5913 | "Address family\n" |
| 5914 | "Address Family modifier\n" |
| 5915 | "Address Family modifier\n" |
| 5916 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5917 | { |
| 5918 | if (strncmp (argv[0], "m", 1) == 0) |
| 5919 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 5920 | |
| 5921 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 5922 | } |
| 5923 | |
| 5924 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 5925 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 5926 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 5927 | SHOW_STR |
| 5928 | IP_STR |
| 5929 | BGP_STR |
| 5930 | "Display VPNv4 NLRI specific information\n" |
| 5931 | "Display information about all VPNv4 NLRIs\n" |
| 5932 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5933 | { |
| 5934 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 5935 | } |
| 5936 | |
| 5937 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 5938 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 5939 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 5940 | SHOW_STR |
| 5941 | IP_STR |
| 5942 | BGP_STR |
| 5943 | "Display VPNv4 NLRI specific information\n" |
| 5944 | "Display information for a route distinguisher\n" |
| 5945 | "VPN Route Distinguisher\n" |
| 5946 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 5947 | { |
| 5948 | int ret; |
| 5949 | struct prefix_rd prd; |
| 5950 | |
| 5951 | ret = str2prefix_rd (argv[0], &prd); |
| 5952 | if (! ret) |
| 5953 | { |
| 5954 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 5955 | return CMD_WARNING; |
| 5956 | } |
| 5957 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 5958 | } |
| 5959 | |
| 5960 | DEFUN (show_ip_bgp_view, |
| 5961 | show_ip_bgp_view_cmd, |
| 5962 | "show ip bgp view WORD", |
| 5963 | SHOW_STR |
| 5964 | IP_STR |
| 5965 | BGP_STR |
| 5966 | "BGP view\n" |
| 5967 | "BGP view name\n") |
| 5968 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 5969 | struct bgp *bgp; |
| 5970 | |
| 5971 | /* BGP structure lookup. */ |
| 5972 | bgp = bgp_lookup_by_name (argv[0]); |
| 5973 | if (bgp == NULL) |
| 5974 | { |
| 5975 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 5976 | return CMD_WARNING; |
| 5977 | } |
| 5978 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5979 | 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] | 5980 | } |
| 5981 | |
| 5982 | DEFUN (show_ip_bgp_view_route, |
| 5983 | show_ip_bgp_view_route_cmd, |
| 5984 | "show ip bgp view WORD A.B.C.D", |
| 5985 | SHOW_STR |
| 5986 | IP_STR |
| 5987 | BGP_STR |
| 5988 | "BGP view\n" |
| 5989 | "BGP view name\n" |
| 5990 | "Network in the BGP routing table to display\n") |
| 5991 | { |
| 5992 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 5993 | } |
| 5994 | |
| 5995 | DEFUN (show_ip_bgp_view_prefix, |
| 5996 | show_ip_bgp_view_prefix_cmd, |
| 5997 | "show ip bgp view WORD A.B.C.D/M", |
| 5998 | SHOW_STR |
| 5999 | IP_STR |
| 6000 | BGP_STR |
| 6001 | "BGP view\n" |
| 6002 | "BGP view name\n" |
| 6003 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6004 | { |
| 6005 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6006 | } |
| 6007 | |
| 6008 | #ifdef HAVE_IPV6 |
| 6009 | DEFUN (show_bgp, |
| 6010 | show_bgp_cmd, |
| 6011 | "show bgp", |
| 6012 | SHOW_STR |
| 6013 | BGP_STR) |
| 6014 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6015 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6016 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | } |
| 6018 | |
| 6019 | ALIAS (show_bgp, |
| 6020 | show_bgp_ipv6_cmd, |
| 6021 | "show bgp ipv6", |
| 6022 | SHOW_STR |
| 6023 | BGP_STR |
| 6024 | "Address family\n") |
| 6025 | |
| 6026 | /* old command */ |
| 6027 | DEFUN (show_ipv6_bgp, |
| 6028 | show_ipv6_bgp_cmd, |
| 6029 | "show ipv6 bgp", |
| 6030 | SHOW_STR |
| 6031 | IP_STR |
| 6032 | BGP_STR) |
| 6033 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6034 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6035 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6036 | } |
| 6037 | |
| 6038 | DEFUN (show_bgp_route, |
| 6039 | show_bgp_route_cmd, |
| 6040 | "show bgp X:X::X:X", |
| 6041 | SHOW_STR |
| 6042 | BGP_STR |
| 6043 | "Network in the BGP routing table to display\n") |
| 6044 | { |
| 6045 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6046 | } |
| 6047 | |
| 6048 | ALIAS (show_bgp_route, |
| 6049 | show_bgp_ipv6_route_cmd, |
| 6050 | "show bgp ipv6 X:X::X:X", |
| 6051 | SHOW_STR |
| 6052 | BGP_STR |
| 6053 | "Address family\n" |
| 6054 | "Network in the BGP routing table to display\n") |
| 6055 | |
| 6056 | /* old command */ |
| 6057 | DEFUN (show_ipv6_bgp_route, |
| 6058 | show_ipv6_bgp_route_cmd, |
| 6059 | "show ipv6 bgp X:X::X:X", |
| 6060 | SHOW_STR |
| 6061 | IP_STR |
| 6062 | BGP_STR |
| 6063 | "Network in the BGP routing table to display\n") |
| 6064 | { |
| 6065 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6066 | } |
| 6067 | |
| 6068 | DEFUN (show_bgp_prefix, |
| 6069 | show_bgp_prefix_cmd, |
| 6070 | "show bgp X:X::X:X/M", |
| 6071 | SHOW_STR |
| 6072 | BGP_STR |
| 6073 | "IPv6 prefix <network>/<length>\n") |
| 6074 | { |
| 6075 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6076 | } |
| 6077 | |
| 6078 | ALIAS (show_bgp_prefix, |
| 6079 | show_bgp_ipv6_prefix_cmd, |
| 6080 | "show bgp ipv6 X:X::X:X/M", |
| 6081 | SHOW_STR |
| 6082 | BGP_STR |
| 6083 | "Address family\n" |
| 6084 | "IPv6 prefix <network>/<length>\n") |
| 6085 | |
| 6086 | /* old command */ |
| 6087 | DEFUN (show_ipv6_bgp_prefix, |
| 6088 | show_ipv6_bgp_prefix_cmd, |
| 6089 | "show ipv6 bgp X:X::X:X/M", |
| 6090 | SHOW_STR |
| 6091 | IP_STR |
| 6092 | BGP_STR |
| 6093 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6094 | { |
| 6095 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6096 | } |
| 6097 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6098 | DEFUN (show_bgp_view, |
| 6099 | show_bgp_view_cmd, |
| 6100 | "show bgp view WORD", |
| 6101 | SHOW_STR |
| 6102 | BGP_STR |
| 6103 | "BGP view\n" |
| 6104 | "View name\n") |
| 6105 | { |
| 6106 | struct bgp *bgp; |
| 6107 | |
| 6108 | /* BGP structure lookup. */ |
| 6109 | bgp = bgp_lookup_by_name (argv[0]); |
| 6110 | if (bgp == NULL) |
| 6111 | { |
| 6112 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6113 | return CMD_WARNING; |
| 6114 | } |
| 6115 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6116 | 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] | 6117 | } |
| 6118 | |
| 6119 | ALIAS (show_bgp_view, |
| 6120 | show_bgp_view_ipv6_cmd, |
| 6121 | "show bgp view WORD ipv6", |
| 6122 | SHOW_STR |
| 6123 | BGP_STR |
| 6124 | "BGP view\n" |
| 6125 | "View name\n" |
| 6126 | "Address family\n") |
| 6127 | |
| 6128 | DEFUN (show_bgp_view_route, |
| 6129 | show_bgp_view_route_cmd, |
| 6130 | "show bgp view WORD X:X::X:X", |
| 6131 | SHOW_STR |
| 6132 | BGP_STR |
| 6133 | "BGP view\n" |
| 6134 | "View name\n" |
| 6135 | "Network in the BGP routing table to display\n") |
| 6136 | { |
| 6137 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6138 | } |
| 6139 | |
| 6140 | ALIAS (show_bgp_view_route, |
| 6141 | show_bgp_view_ipv6_route_cmd, |
| 6142 | "show bgp view WORD ipv6 X:X::X:X", |
| 6143 | SHOW_STR |
| 6144 | BGP_STR |
| 6145 | "BGP view\n" |
| 6146 | "View name\n" |
| 6147 | "Address family\n" |
| 6148 | "Network in the BGP routing table to display\n") |
| 6149 | |
| 6150 | DEFUN (show_bgp_view_prefix, |
| 6151 | show_bgp_view_prefix_cmd, |
| 6152 | "show bgp view WORD X:X::X:X/M", |
| 6153 | SHOW_STR |
| 6154 | BGP_STR |
| 6155 | "BGP view\n" |
| 6156 | "View name\n" |
| 6157 | "IPv6 prefix <network>/<length>\n") |
| 6158 | { |
| 6159 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6160 | } |
| 6161 | |
| 6162 | ALIAS (show_bgp_view_prefix, |
| 6163 | show_bgp_view_ipv6_prefix_cmd, |
| 6164 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 6165 | SHOW_STR |
| 6166 | BGP_STR |
| 6167 | "BGP view\n" |
| 6168 | "View name\n" |
| 6169 | "Address family\n" |
| 6170 | "IPv6 prefix <network>/<length>\n") |
| 6171 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6172 | /* old command */ |
| 6173 | DEFUN (show_ipv6_mbgp, |
| 6174 | show_ipv6_mbgp_cmd, |
| 6175 | "show ipv6 mbgp", |
| 6176 | SHOW_STR |
| 6177 | IP_STR |
| 6178 | MBGP_STR) |
| 6179 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6180 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6181 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6182 | } |
| 6183 | |
| 6184 | /* old command */ |
| 6185 | DEFUN (show_ipv6_mbgp_route, |
| 6186 | show_ipv6_mbgp_route_cmd, |
| 6187 | "show ipv6 mbgp X:X::X:X", |
| 6188 | SHOW_STR |
| 6189 | IP_STR |
| 6190 | MBGP_STR |
| 6191 | "Network in the MBGP routing table to display\n") |
| 6192 | { |
| 6193 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6194 | } |
| 6195 | |
| 6196 | /* old command */ |
| 6197 | DEFUN (show_ipv6_mbgp_prefix, |
| 6198 | show_ipv6_mbgp_prefix_cmd, |
| 6199 | "show ipv6 mbgp X:X::X:X/M", |
| 6200 | SHOW_STR |
| 6201 | IP_STR |
| 6202 | MBGP_STR |
| 6203 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6204 | { |
| 6205 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6206 | } |
| 6207 | #endif |
| 6208 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6209 | |
| 6210 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6211 | 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] | 6212 | safi_t safi, enum bgp_show_type type) |
| 6213 | { |
| 6214 | int i; |
| 6215 | struct buffer *b; |
| 6216 | char *regstr; |
| 6217 | int first; |
| 6218 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6219 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6220 | |
| 6221 | first = 0; |
| 6222 | b = buffer_new (1024); |
| 6223 | for (i = 0; i < argc; i++) |
| 6224 | { |
| 6225 | if (first) |
| 6226 | buffer_putc (b, ' '); |
| 6227 | else |
| 6228 | { |
| 6229 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6230 | continue; |
| 6231 | first = 1; |
| 6232 | } |
| 6233 | |
| 6234 | buffer_putstr (b, argv[i]); |
| 6235 | } |
| 6236 | buffer_putc (b, '\0'); |
| 6237 | |
| 6238 | regstr = buffer_getstr (b); |
| 6239 | buffer_free (b); |
| 6240 | |
| 6241 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6242 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6243 | if (! regex) |
| 6244 | { |
| 6245 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 6246 | VTY_NEWLINE); |
| 6247 | return CMD_WARNING; |
| 6248 | } |
| 6249 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6250 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 6251 | bgp_regex_free (regex); |
| 6252 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6253 | } |
| 6254 | |
| 6255 | DEFUN (show_ip_bgp_regexp, |
| 6256 | show_ip_bgp_regexp_cmd, |
| 6257 | "show ip bgp regexp .LINE", |
| 6258 | SHOW_STR |
| 6259 | IP_STR |
| 6260 | BGP_STR |
| 6261 | "Display routes matching the AS path regular expression\n" |
| 6262 | "A regular-expression to match the BGP AS paths\n") |
| 6263 | { |
| 6264 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6265 | bgp_show_type_regexp); |
| 6266 | } |
| 6267 | |
| 6268 | DEFUN (show_ip_bgp_flap_regexp, |
| 6269 | show_ip_bgp_flap_regexp_cmd, |
| 6270 | "show ip bgp flap-statistics regexp .LINE", |
| 6271 | SHOW_STR |
| 6272 | IP_STR |
| 6273 | BGP_STR |
| 6274 | "Display flap statistics of routes\n" |
| 6275 | "Display routes matching the AS path regular expression\n" |
| 6276 | "A regular-expression to match the BGP AS paths\n") |
| 6277 | { |
| 6278 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6279 | bgp_show_type_flap_regexp); |
| 6280 | } |
| 6281 | |
| 6282 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 6283 | show_ip_bgp_ipv4_regexp_cmd, |
| 6284 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 6285 | SHOW_STR |
| 6286 | IP_STR |
| 6287 | BGP_STR |
| 6288 | "Address family\n" |
| 6289 | "Address Family modifier\n" |
| 6290 | "Address Family modifier\n" |
| 6291 | "Display routes matching the AS path regular expression\n" |
| 6292 | "A regular-expression to match the BGP AS paths\n") |
| 6293 | { |
| 6294 | if (strncmp (argv[0], "m", 1) == 0) |
| 6295 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 6296 | bgp_show_type_regexp); |
| 6297 | |
| 6298 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6299 | bgp_show_type_regexp); |
| 6300 | } |
| 6301 | |
| 6302 | #ifdef HAVE_IPV6 |
| 6303 | DEFUN (show_bgp_regexp, |
| 6304 | show_bgp_regexp_cmd, |
| 6305 | "show bgp regexp .LINE", |
| 6306 | SHOW_STR |
| 6307 | BGP_STR |
| 6308 | "Display routes matching the AS path regular expression\n" |
| 6309 | "A regular-expression to match the BGP AS paths\n") |
| 6310 | { |
| 6311 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6312 | bgp_show_type_regexp); |
| 6313 | } |
| 6314 | |
| 6315 | ALIAS (show_bgp_regexp, |
| 6316 | show_bgp_ipv6_regexp_cmd, |
| 6317 | "show bgp ipv6 regexp .LINE", |
| 6318 | SHOW_STR |
| 6319 | BGP_STR |
| 6320 | "Address family\n" |
| 6321 | "Display routes matching the AS path regular expression\n" |
| 6322 | "A regular-expression to match the BGP AS paths\n") |
| 6323 | |
| 6324 | /* old command */ |
| 6325 | DEFUN (show_ipv6_bgp_regexp, |
| 6326 | show_ipv6_bgp_regexp_cmd, |
| 6327 | "show ipv6 bgp regexp .LINE", |
| 6328 | SHOW_STR |
| 6329 | IP_STR |
| 6330 | BGP_STR |
| 6331 | "Display routes matching the AS path regular expression\n" |
| 6332 | "A regular-expression to match the BGP AS paths\n") |
| 6333 | { |
| 6334 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6335 | bgp_show_type_regexp); |
| 6336 | } |
| 6337 | |
| 6338 | /* old command */ |
| 6339 | DEFUN (show_ipv6_mbgp_regexp, |
| 6340 | show_ipv6_mbgp_regexp_cmd, |
| 6341 | "show ipv6 mbgp regexp .LINE", |
| 6342 | SHOW_STR |
| 6343 | IP_STR |
| 6344 | BGP_STR |
| 6345 | "Display routes matching the AS path regular expression\n" |
| 6346 | "A regular-expression to match the MBGP AS paths\n") |
| 6347 | { |
| 6348 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 6349 | bgp_show_type_regexp); |
| 6350 | } |
| 6351 | #endif /* HAVE_IPV6 */ |
| 6352 | |
| 6353 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6354 | 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] | 6355 | safi_t safi, enum bgp_show_type type) |
| 6356 | { |
| 6357 | struct prefix_list *plist; |
| 6358 | |
| 6359 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 6360 | if (plist == NULL) |
| 6361 | { |
| 6362 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 6363 | prefix_list_str, VTY_NEWLINE); |
| 6364 | return CMD_WARNING; |
| 6365 | } |
| 6366 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6367 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6368 | } |
| 6369 | |
| 6370 | DEFUN (show_ip_bgp_prefix_list, |
| 6371 | show_ip_bgp_prefix_list_cmd, |
| 6372 | "show ip bgp prefix-list WORD", |
| 6373 | SHOW_STR |
| 6374 | IP_STR |
| 6375 | BGP_STR |
| 6376 | "Display routes conforming to the prefix-list\n" |
| 6377 | "IP prefix-list name\n") |
| 6378 | { |
| 6379 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6380 | bgp_show_type_prefix_list); |
| 6381 | } |
| 6382 | |
| 6383 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 6384 | show_ip_bgp_flap_prefix_list_cmd, |
| 6385 | "show ip bgp flap-statistics prefix-list WORD", |
| 6386 | SHOW_STR |
| 6387 | IP_STR |
| 6388 | BGP_STR |
| 6389 | "Display flap statistics of routes\n" |
| 6390 | "Display routes conforming to the prefix-list\n" |
| 6391 | "IP prefix-list name\n") |
| 6392 | { |
| 6393 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6394 | bgp_show_type_flap_prefix_list); |
| 6395 | } |
| 6396 | |
| 6397 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 6398 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 6399 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 6400 | SHOW_STR |
| 6401 | IP_STR |
| 6402 | BGP_STR |
| 6403 | "Address family\n" |
| 6404 | "Address Family modifier\n" |
| 6405 | "Address Family modifier\n" |
| 6406 | "Display routes conforming to the prefix-list\n" |
| 6407 | "IP prefix-list name\n") |
| 6408 | { |
| 6409 | if (strncmp (argv[0], "m", 1) == 0) |
| 6410 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6411 | bgp_show_type_prefix_list); |
| 6412 | |
| 6413 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6414 | bgp_show_type_prefix_list); |
| 6415 | } |
| 6416 | |
| 6417 | #ifdef HAVE_IPV6 |
| 6418 | DEFUN (show_bgp_prefix_list, |
| 6419 | show_bgp_prefix_list_cmd, |
| 6420 | "show bgp prefix-list WORD", |
| 6421 | SHOW_STR |
| 6422 | BGP_STR |
| 6423 | "Display routes conforming to the prefix-list\n" |
| 6424 | "IPv6 prefix-list name\n") |
| 6425 | { |
| 6426 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6427 | bgp_show_type_prefix_list); |
| 6428 | } |
| 6429 | |
| 6430 | ALIAS (show_bgp_prefix_list, |
| 6431 | show_bgp_ipv6_prefix_list_cmd, |
| 6432 | "show bgp ipv6 prefix-list WORD", |
| 6433 | SHOW_STR |
| 6434 | BGP_STR |
| 6435 | "Address family\n" |
| 6436 | "Display routes conforming to the prefix-list\n" |
| 6437 | "IPv6 prefix-list name\n") |
| 6438 | |
| 6439 | /* old command */ |
| 6440 | DEFUN (show_ipv6_bgp_prefix_list, |
| 6441 | show_ipv6_bgp_prefix_list_cmd, |
| 6442 | "show ipv6 bgp prefix-list WORD", |
| 6443 | SHOW_STR |
| 6444 | IPV6_STR |
| 6445 | BGP_STR |
| 6446 | "Display routes matching the prefix-list\n" |
| 6447 | "IPv6 prefix-list name\n") |
| 6448 | { |
| 6449 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6450 | bgp_show_type_prefix_list); |
| 6451 | } |
| 6452 | |
| 6453 | /* old command */ |
| 6454 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 6455 | show_ipv6_mbgp_prefix_list_cmd, |
| 6456 | "show ipv6 mbgp prefix-list WORD", |
| 6457 | SHOW_STR |
| 6458 | IPV6_STR |
| 6459 | MBGP_STR |
| 6460 | "Display routes matching the prefix-list\n" |
| 6461 | "IPv6 prefix-list name\n") |
| 6462 | { |
| 6463 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6464 | bgp_show_type_prefix_list); |
| 6465 | } |
| 6466 | #endif /* HAVE_IPV6 */ |
| 6467 | |
| 6468 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6469 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6470 | safi_t safi, enum bgp_show_type type) |
| 6471 | { |
| 6472 | struct as_list *as_list; |
| 6473 | |
| 6474 | as_list = as_list_lookup (filter); |
| 6475 | if (as_list == NULL) |
| 6476 | { |
| 6477 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 6478 | return CMD_WARNING; |
| 6479 | } |
| 6480 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6481 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6482 | } |
| 6483 | |
| 6484 | DEFUN (show_ip_bgp_filter_list, |
| 6485 | show_ip_bgp_filter_list_cmd, |
| 6486 | "show ip bgp filter-list WORD", |
| 6487 | SHOW_STR |
| 6488 | IP_STR |
| 6489 | BGP_STR |
| 6490 | "Display routes conforming to the filter-list\n" |
| 6491 | "Regular expression access list name\n") |
| 6492 | { |
| 6493 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6494 | bgp_show_type_filter_list); |
| 6495 | } |
| 6496 | |
| 6497 | DEFUN (show_ip_bgp_flap_filter_list, |
| 6498 | show_ip_bgp_flap_filter_list_cmd, |
| 6499 | "show ip bgp flap-statistics filter-list WORD", |
| 6500 | SHOW_STR |
| 6501 | IP_STR |
| 6502 | BGP_STR |
| 6503 | "Display flap statistics of routes\n" |
| 6504 | "Display routes conforming to the filter-list\n" |
| 6505 | "Regular expression access list name\n") |
| 6506 | { |
| 6507 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6508 | bgp_show_type_flap_filter_list); |
| 6509 | } |
| 6510 | |
| 6511 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 6512 | show_ip_bgp_ipv4_filter_list_cmd, |
| 6513 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 6514 | SHOW_STR |
| 6515 | IP_STR |
| 6516 | BGP_STR |
| 6517 | "Address family\n" |
| 6518 | "Address Family modifier\n" |
| 6519 | "Address Family modifier\n" |
| 6520 | "Display routes conforming to the filter-list\n" |
| 6521 | "Regular expression access list name\n") |
| 6522 | { |
| 6523 | if (strncmp (argv[0], "m", 1) == 0) |
| 6524 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6525 | bgp_show_type_filter_list); |
| 6526 | |
| 6527 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6528 | bgp_show_type_filter_list); |
| 6529 | } |
| 6530 | |
| 6531 | #ifdef HAVE_IPV6 |
| 6532 | DEFUN (show_bgp_filter_list, |
| 6533 | show_bgp_filter_list_cmd, |
| 6534 | "show bgp filter-list WORD", |
| 6535 | SHOW_STR |
| 6536 | BGP_STR |
| 6537 | "Display routes conforming to the filter-list\n" |
| 6538 | "Regular expression access list name\n") |
| 6539 | { |
| 6540 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6541 | bgp_show_type_filter_list); |
| 6542 | } |
| 6543 | |
| 6544 | ALIAS (show_bgp_filter_list, |
| 6545 | show_bgp_ipv6_filter_list_cmd, |
| 6546 | "show bgp ipv6 filter-list WORD", |
| 6547 | SHOW_STR |
| 6548 | BGP_STR |
| 6549 | "Address family\n" |
| 6550 | "Display routes conforming to the filter-list\n" |
| 6551 | "Regular expression access list name\n") |
| 6552 | |
| 6553 | /* old command */ |
| 6554 | DEFUN (show_ipv6_bgp_filter_list, |
| 6555 | show_ipv6_bgp_filter_list_cmd, |
| 6556 | "show ipv6 bgp filter-list WORD", |
| 6557 | SHOW_STR |
| 6558 | IPV6_STR |
| 6559 | BGP_STR |
| 6560 | "Display routes conforming to the filter-list\n" |
| 6561 | "Regular expression access list name\n") |
| 6562 | { |
| 6563 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6564 | bgp_show_type_filter_list); |
| 6565 | } |
| 6566 | |
| 6567 | /* old command */ |
| 6568 | DEFUN (show_ipv6_mbgp_filter_list, |
| 6569 | show_ipv6_mbgp_filter_list_cmd, |
| 6570 | "show ipv6 mbgp filter-list WORD", |
| 6571 | SHOW_STR |
| 6572 | IPV6_STR |
| 6573 | MBGP_STR |
| 6574 | "Display routes conforming to the filter-list\n" |
| 6575 | "Regular expression access list name\n") |
| 6576 | { |
| 6577 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6578 | bgp_show_type_filter_list); |
| 6579 | } |
| 6580 | #endif /* HAVE_IPV6 */ |
| 6581 | |
| 6582 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6583 | 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] | 6584 | safi_t safi, enum bgp_show_type type) |
| 6585 | { |
| 6586 | struct route_map *rmap; |
| 6587 | |
| 6588 | rmap = route_map_lookup_by_name (rmap_str); |
| 6589 | if (! rmap) |
| 6590 | { |
| 6591 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 6592 | rmap_str, VTY_NEWLINE); |
| 6593 | return CMD_WARNING; |
| 6594 | } |
| 6595 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6596 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6597 | } |
| 6598 | |
| 6599 | DEFUN (show_ip_bgp_route_map, |
| 6600 | show_ip_bgp_route_map_cmd, |
| 6601 | "show ip bgp route-map WORD", |
| 6602 | SHOW_STR |
| 6603 | IP_STR |
| 6604 | BGP_STR |
| 6605 | "Display routes matching the route-map\n" |
| 6606 | "A route-map to match on\n") |
| 6607 | { |
| 6608 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6609 | bgp_show_type_route_map); |
| 6610 | } |
| 6611 | |
| 6612 | DEFUN (show_ip_bgp_flap_route_map, |
| 6613 | show_ip_bgp_flap_route_map_cmd, |
| 6614 | "show ip bgp flap-statistics route-map WORD", |
| 6615 | SHOW_STR |
| 6616 | IP_STR |
| 6617 | BGP_STR |
| 6618 | "Display flap statistics of routes\n" |
| 6619 | "Display routes matching the route-map\n" |
| 6620 | "A route-map to match on\n") |
| 6621 | { |
| 6622 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6623 | bgp_show_type_flap_route_map); |
| 6624 | } |
| 6625 | |
| 6626 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 6627 | show_ip_bgp_ipv4_route_map_cmd, |
| 6628 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 6629 | SHOW_STR |
| 6630 | IP_STR |
| 6631 | BGP_STR |
| 6632 | "Address family\n" |
| 6633 | "Address Family modifier\n" |
| 6634 | "Address Family modifier\n" |
| 6635 | "Display routes matching the route-map\n" |
| 6636 | "A route-map to match on\n") |
| 6637 | { |
| 6638 | if (strncmp (argv[0], "m", 1) == 0) |
| 6639 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6640 | bgp_show_type_route_map); |
| 6641 | |
| 6642 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6643 | bgp_show_type_route_map); |
| 6644 | } |
| 6645 | |
| 6646 | DEFUN (show_bgp_route_map, |
| 6647 | show_bgp_route_map_cmd, |
| 6648 | "show bgp route-map WORD", |
| 6649 | SHOW_STR |
| 6650 | BGP_STR |
| 6651 | "Display routes matching the route-map\n" |
| 6652 | "A route-map to match on\n") |
| 6653 | { |
| 6654 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6655 | bgp_show_type_route_map); |
| 6656 | } |
| 6657 | |
| 6658 | ALIAS (show_bgp_route_map, |
| 6659 | show_bgp_ipv6_route_map_cmd, |
| 6660 | "show bgp ipv6 route-map WORD", |
| 6661 | SHOW_STR |
| 6662 | BGP_STR |
| 6663 | "Address family\n" |
| 6664 | "Display routes matching the route-map\n" |
| 6665 | "A route-map to match on\n") |
| 6666 | |
| 6667 | DEFUN (show_ip_bgp_cidr_only, |
| 6668 | show_ip_bgp_cidr_only_cmd, |
| 6669 | "show ip bgp cidr-only", |
| 6670 | SHOW_STR |
| 6671 | IP_STR |
| 6672 | BGP_STR |
| 6673 | "Display only routes with non-natural netmasks\n") |
| 6674 | { |
| 6675 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6676 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6677 | } |
| 6678 | |
| 6679 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 6680 | show_ip_bgp_flap_cidr_only_cmd, |
| 6681 | "show ip bgp flap-statistics cidr-only", |
| 6682 | SHOW_STR |
| 6683 | IP_STR |
| 6684 | BGP_STR |
| 6685 | "Display flap statistics of routes\n" |
| 6686 | "Display only routes with non-natural netmasks\n") |
| 6687 | { |
| 6688 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6689 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6690 | } |
| 6691 | |
| 6692 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 6693 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 6694 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 6695 | SHOW_STR |
| 6696 | IP_STR |
| 6697 | BGP_STR |
| 6698 | "Address family\n" |
| 6699 | "Address Family modifier\n" |
| 6700 | "Address Family modifier\n" |
| 6701 | "Display only routes with non-natural netmasks\n") |
| 6702 | { |
| 6703 | if (strncmp (argv[0], "m", 1) == 0) |
| 6704 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6705 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6706 | |
| 6707 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6708 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6709 | } |
| 6710 | |
| 6711 | DEFUN (show_ip_bgp_community_all, |
| 6712 | show_ip_bgp_community_all_cmd, |
| 6713 | "show ip bgp community", |
| 6714 | SHOW_STR |
| 6715 | IP_STR |
| 6716 | BGP_STR |
| 6717 | "Display routes matching the communities\n") |
| 6718 | { |
| 6719 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6720 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6721 | } |
| 6722 | |
| 6723 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 6724 | show_ip_bgp_ipv4_community_all_cmd, |
| 6725 | "show ip bgp ipv4 (unicast|multicast) community", |
| 6726 | SHOW_STR |
| 6727 | IP_STR |
| 6728 | BGP_STR |
| 6729 | "Address family\n" |
| 6730 | "Address Family modifier\n" |
| 6731 | "Address Family modifier\n" |
| 6732 | "Display routes matching the communities\n") |
| 6733 | { |
| 6734 | if (strncmp (argv[0], "m", 1) == 0) |
| 6735 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6736 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6737 | |
| 6738 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6739 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6740 | } |
| 6741 | |
| 6742 | #ifdef HAVE_IPV6 |
| 6743 | DEFUN (show_bgp_community_all, |
| 6744 | show_bgp_community_all_cmd, |
| 6745 | "show bgp community", |
| 6746 | SHOW_STR |
| 6747 | BGP_STR |
| 6748 | "Display routes matching the communities\n") |
| 6749 | { |
| 6750 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6751 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6752 | } |
| 6753 | |
| 6754 | ALIAS (show_bgp_community_all, |
| 6755 | show_bgp_ipv6_community_all_cmd, |
| 6756 | "show bgp ipv6 community", |
| 6757 | SHOW_STR |
| 6758 | BGP_STR |
| 6759 | "Address family\n" |
| 6760 | "Display routes matching the communities\n") |
| 6761 | |
| 6762 | /* old command */ |
| 6763 | DEFUN (show_ipv6_bgp_community_all, |
| 6764 | show_ipv6_bgp_community_all_cmd, |
| 6765 | "show ipv6 bgp community", |
| 6766 | SHOW_STR |
| 6767 | IPV6_STR |
| 6768 | BGP_STR |
| 6769 | "Display routes matching the communities\n") |
| 6770 | { |
| 6771 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6772 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6773 | } |
| 6774 | |
| 6775 | /* old command */ |
| 6776 | DEFUN (show_ipv6_mbgp_community_all, |
| 6777 | show_ipv6_mbgp_community_all_cmd, |
| 6778 | "show ipv6 mbgp community", |
| 6779 | SHOW_STR |
| 6780 | IPV6_STR |
| 6781 | MBGP_STR |
| 6782 | "Display routes matching the communities\n") |
| 6783 | { |
| 6784 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6785 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6786 | } |
| 6787 | #endif /* HAVE_IPV6 */ |
| 6788 | |
| 6789 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6790 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
| 6791 | u_int16_t afi, u_char safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6792 | { |
| 6793 | struct community *com; |
| 6794 | struct buffer *b; |
| 6795 | int i; |
| 6796 | char *str; |
| 6797 | int first = 0; |
| 6798 | |
| 6799 | b = buffer_new (1024); |
| 6800 | for (i = 0; i < argc; i++) |
| 6801 | { |
| 6802 | if (first) |
| 6803 | buffer_putc (b, ' '); |
| 6804 | else |
| 6805 | { |
| 6806 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6807 | continue; |
| 6808 | first = 1; |
| 6809 | } |
| 6810 | |
| 6811 | buffer_putstr (b, argv[i]); |
| 6812 | } |
| 6813 | buffer_putc (b, '\0'); |
| 6814 | |
| 6815 | str = buffer_getstr (b); |
| 6816 | buffer_free (b); |
| 6817 | |
| 6818 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6819 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6820 | if (! com) |
| 6821 | { |
| 6822 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 6823 | return CMD_WARNING; |
| 6824 | } |
| 6825 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6826 | return bgp_show (vty, NULL, afi, safi, |
| 6827 | (exact ? bgp_show_type_community_exact : |
| 6828 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6829 | } |
| 6830 | |
| 6831 | DEFUN (show_ip_bgp_community, |
| 6832 | show_ip_bgp_community_cmd, |
| 6833 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 6834 | SHOW_STR |
| 6835 | IP_STR |
| 6836 | BGP_STR |
| 6837 | "Display routes matching the communities\n" |
| 6838 | "community number\n" |
| 6839 | "Do not send outside local AS (well-known community)\n" |
| 6840 | "Do not advertise to any peer (well-known community)\n" |
| 6841 | "Do not export to next AS (well-known community)\n") |
| 6842 | { |
| 6843 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6844 | } |
| 6845 | |
| 6846 | ALIAS (show_ip_bgp_community, |
| 6847 | show_ip_bgp_community2_cmd, |
| 6848 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6849 | SHOW_STR |
| 6850 | IP_STR |
| 6851 | BGP_STR |
| 6852 | "Display routes matching the communities\n" |
| 6853 | "community number\n" |
| 6854 | "Do not send outside local AS (well-known community)\n" |
| 6855 | "Do not advertise to any peer (well-known community)\n" |
| 6856 | "Do not export to next AS (well-known community)\n" |
| 6857 | "community number\n" |
| 6858 | "Do not send outside local AS (well-known community)\n" |
| 6859 | "Do not advertise to any peer (well-known community)\n" |
| 6860 | "Do not export to next AS (well-known community)\n") |
| 6861 | |
| 6862 | ALIAS (show_ip_bgp_community, |
| 6863 | show_ip_bgp_community3_cmd, |
| 6864 | "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)", |
| 6865 | SHOW_STR |
| 6866 | IP_STR |
| 6867 | BGP_STR |
| 6868 | "Display routes matching the communities\n" |
| 6869 | "community number\n" |
| 6870 | "Do not send outside local AS (well-known community)\n" |
| 6871 | "Do not advertise to any peer (well-known community)\n" |
| 6872 | "Do not export to next AS (well-known community)\n" |
| 6873 | "community number\n" |
| 6874 | "Do not send outside local AS (well-known community)\n" |
| 6875 | "Do not advertise to any peer (well-known community)\n" |
| 6876 | "Do not export to next AS (well-known community)\n" |
| 6877 | "community number\n" |
| 6878 | "Do not send outside local AS (well-known community)\n" |
| 6879 | "Do not advertise to any peer (well-known community)\n" |
| 6880 | "Do not export to next AS (well-known community)\n") |
| 6881 | |
| 6882 | ALIAS (show_ip_bgp_community, |
| 6883 | show_ip_bgp_community4_cmd, |
| 6884 | "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)", |
| 6885 | SHOW_STR |
| 6886 | IP_STR |
| 6887 | BGP_STR |
| 6888 | "Display routes matching the communities\n" |
| 6889 | "community number\n" |
| 6890 | "Do not send outside local AS (well-known community)\n" |
| 6891 | "Do not advertise to any peer (well-known community)\n" |
| 6892 | "Do not export to next AS (well-known community)\n" |
| 6893 | "community number\n" |
| 6894 | "Do not send outside local AS (well-known community)\n" |
| 6895 | "Do not advertise to any peer (well-known community)\n" |
| 6896 | "Do not export to next AS (well-known community)\n" |
| 6897 | "community number\n" |
| 6898 | "Do not send outside local AS (well-known community)\n" |
| 6899 | "Do not advertise to any peer (well-known community)\n" |
| 6900 | "Do not export to next AS (well-known community)\n" |
| 6901 | "community number\n" |
| 6902 | "Do not send outside local AS (well-known community)\n" |
| 6903 | "Do not advertise to any peer (well-known community)\n" |
| 6904 | "Do not export to next AS (well-known community)\n") |
| 6905 | |
| 6906 | DEFUN (show_ip_bgp_ipv4_community, |
| 6907 | show_ip_bgp_ipv4_community_cmd, |
| 6908 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 6909 | SHOW_STR |
| 6910 | IP_STR |
| 6911 | BGP_STR |
| 6912 | "Address family\n" |
| 6913 | "Address Family modifier\n" |
| 6914 | "Address Family modifier\n" |
| 6915 | "Display routes matching the communities\n" |
| 6916 | "community number\n" |
| 6917 | "Do not send outside local AS (well-known community)\n" |
| 6918 | "Do not advertise to any peer (well-known community)\n" |
| 6919 | "Do not export to next AS (well-known community)\n") |
| 6920 | { |
| 6921 | if (strncmp (argv[0], "m", 1) == 0) |
| 6922 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 6923 | |
| 6924 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 6925 | } |
| 6926 | |
| 6927 | ALIAS (show_ip_bgp_ipv4_community, |
| 6928 | show_ip_bgp_ipv4_community2_cmd, |
| 6929 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 6930 | SHOW_STR |
| 6931 | IP_STR |
| 6932 | BGP_STR |
| 6933 | "Address family\n" |
| 6934 | "Address Family modifier\n" |
| 6935 | "Address Family modifier\n" |
| 6936 | "Display routes matching the communities\n" |
| 6937 | "community number\n" |
| 6938 | "Do not send outside local AS (well-known community)\n" |
| 6939 | "Do not advertise to any peer (well-known community)\n" |
| 6940 | "Do not export to next AS (well-known community)\n" |
| 6941 | "community number\n" |
| 6942 | "Do not send outside local AS (well-known community)\n" |
| 6943 | "Do not advertise to any peer (well-known community)\n" |
| 6944 | "Do not export to next AS (well-known community)\n") |
| 6945 | |
| 6946 | ALIAS (show_ip_bgp_ipv4_community, |
| 6947 | show_ip_bgp_ipv4_community3_cmd, |
| 6948 | "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)", |
| 6949 | SHOW_STR |
| 6950 | IP_STR |
| 6951 | BGP_STR |
| 6952 | "Address family\n" |
| 6953 | "Address Family modifier\n" |
| 6954 | "Address Family modifier\n" |
| 6955 | "Display routes matching the communities\n" |
| 6956 | "community number\n" |
| 6957 | "Do not send outside local AS (well-known community)\n" |
| 6958 | "Do not advertise to any peer (well-known community)\n" |
| 6959 | "Do not export to next AS (well-known community)\n" |
| 6960 | "community number\n" |
| 6961 | "Do not send outside local AS (well-known community)\n" |
| 6962 | "Do not advertise to any peer (well-known community)\n" |
| 6963 | "Do not export to next AS (well-known community)\n" |
| 6964 | "community number\n" |
| 6965 | "Do not send outside local AS (well-known community)\n" |
| 6966 | "Do not advertise to any peer (well-known community)\n" |
| 6967 | "Do not export to next AS (well-known community)\n") |
| 6968 | |
| 6969 | ALIAS (show_ip_bgp_ipv4_community, |
| 6970 | show_ip_bgp_ipv4_community4_cmd, |
| 6971 | "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)", |
| 6972 | SHOW_STR |
| 6973 | IP_STR |
| 6974 | BGP_STR |
| 6975 | "Address family\n" |
| 6976 | "Address Family modifier\n" |
| 6977 | "Address Family modifier\n" |
| 6978 | "Display routes matching the communities\n" |
| 6979 | "community number\n" |
| 6980 | "Do not send outside local AS (well-known community)\n" |
| 6981 | "Do not advertise to any peer (well-known community)\n" |
| 6982 | "Do not export to next AS (well-known community)\n" |
| 6983 | "community number\n" |
| 6984 | "Do not send outside local AS (well-known community)\n" |
| 6985 | "Do not advertise to any peer (well-known community)\n" |
| 6986 | "Do not export to next AS (well-known community)\n" |
| 6987 | "community number\n" |
| 6988 | "Do not send outside local AS (well-known community)\n" |
| 6989 | "Do not advertise to any peer (well-known community)\n" |
| 6990 | "Do not export to next AS (well-known community)\n" |
| 6991 | "community number\n" |
| 6992 | "Do not send outside local AS (well-known community)\n" |
| 6993 | "Do not advertise to any peer (well-known community)\n" |
| 6994 | "Do not export to next AS (well-known community)\n") |
| 6995 | |
| 6996 | DEFUN (show_ip_bgp_community_exact, |
| 6997 | show_ip_bgp_community_exact_cmd, |
| 6998 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 6999 | SHOW_STR |
| 7000 | IP_STR |
| 7001 | BGP_STR |
| 7002 | "Display routes matching the communities\n" |
| 7003 | "community number\n" |
| 7004 | "Do not send outside local AS (well-known community)\n" |
| 7005 | "Do not advertise to any peer (well-known community)\n" |
| 7006 | "Do not export to next AS (well-known community)\n" |
| 7007 | "Exact match of the communities") |
| 7008 | { |
| 7009 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7010 | } |
| 7011 | |
| 7012 | ALIAS (show_ip_bgp_community_exact, |
| 7013 | show_ip_bgp_community2_exact_cmd, |
| 7014 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7015 | SHOW_STR |
| 7016 | IP_STR |
| 7017 | BGP_STR |
| 7018 | "Display routes matching the communities\n" |
| 7019 | "community number\n" |
| 7020 | "Do not send outside local AS (well-known community)\n" |
| 7021 | "Do not advertise to any peer (well-known community)\n" |
| 7022 | "Do not export to next AS (well-known community)\n" |
| 7023 | "community number\n" |
| 7024 | "Do not send outside local AS (well-known community)\n" |
| 7025 | "Do not advertise to any peer (well-known community)\n" |
| 7026 | "Do not export to next AS (well-known community)\n" |
| 7027 | "Exact match of the communities") |
| 7028 | |
| 7029 | ALIAS (show_ip_bgp_community_exact, |
| 7030 | show_ip_bgp_community3_exact_cmd, |
| 7031 | "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", |
| 7032 | SHOW_STR |
| 7033 | IP_STR |
| 7034 | BGP_STR |
| 7035 | "Display routes matching the communities\n" |
| 7036 | "community number\n" |
| 7037 | "Do not send outside local AS (well-known community)\n" |
| 7038 | "Do not advertise to any peer (well-known community)\n" |
| 7039 | "Do not export to next AS (well-known community)\n" |
| 7040 | "community number\n" |
| 7041 | "Do not send outside local AS (well-known community)\n" |
| 7042 | "Do not advertise to any peer (well-known community)\n" |
| 7043 | "Do not export to next AS (well-known community)\n" |
| 7044 | "community number\n" |
| 7045 | "Do not send outside local AS (well-known community)\n" |
| 7046 | "Do not advertise to any peer (well-known community)\n" |
| 7047 | "Do not export to next AS (well-known community)\n" |
| 7048 | "Exact match of the communities") |
| 7049 | |
| 7050 | ALIAS (show_ip_bgp_community_exact, |
| 7051 | show_ip_bgp_community4_exact_cmd, |
| 7052 | "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", |
| 7053 | SHOW_STR |
| 7054 | IP_STR |
| 7055 | BGP_STR |
| 7056 | "Display routes matching the communities\n" |
| 7057 | "community number\n" |
| 7058 | "Do not send outside local AS (well-known community)\n" |
| 7059 | "Do not advertise to any peer (well-known community)\n" |
| 7060 | "Do not export to next AS (well-known community)\n" |
| 7061 | "community number\n" |
| 7062 | "Do not send outside local AS (well-known community)\n" |
| 7063 | "Do not advertise to any peer (well-known community)\n" |
| 7064 | "Do not export to next AS (well-known community)\n" |
| 7065 | "community number\n" |
| 7066 | "Do not send outside local AS (well-known community)\n" |
| 7067 | "Do not advertise to any peer (well-known community)\n" |
| 7068 | "Do not export to next AS (well-known community)\n" |
| 7069 | "community number\n" |
| 7070 | "Do not send outside local AS (well-known community)\n" |
| 7071 | "Do not advertise to any peer (well-known community)\n" |
| 7072 | "Do not export to next AS (well-known community)\n" |
| 7073 | "Exact match of the communities") |
| 7074 | |
| 7075 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 7076 | show_ip_bgp_ipv4_community_exact_cmd, |
| 7077 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7078 | SHOW_STR |
| 7079 | IP_STR |
| 7080 | BGP_STR |
| 7081 | "Address family\n" |
| 7082 | "Address Family modifier\n" |
| 7083 | "Address Family modifier\n" |
| 7084 | "Display routes matching the communities\n" |
| 7085 | "community number\n" |
| 7086 | "Do not send outside local AS (well-known community)\n" |
| 7087 | "Do not advertise to any peer (well-known community)\n" |
| 7088 | "Do not export to next AS (well-known community)\n" |
| 7089 | "Exact match of the communities") |
| 7090 | { |
| 7091 | if (strncmp (argv[0], "m", 1) == 0) |
| 7092 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 7093 | |
| 7094 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7095 | } |
| 7096 | |
| 7097 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7098 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 7099 | "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", |
| 7100 | SHOW_STR |
| 7101 | IP_STR |
| 7102 | BGP_STR |
| 7103 | "Address family\n" |
| 7104 | "Address Family modifier\n" |
| 7105 | "Address Family modifier\n" |
| 7106 | "Display routes matching the 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 | "community number\n" |
| 7112 | "Do not send outside local AS (well-known community)\n" |
| 7113 | "Do not advertise to any peer (well-known community)\n" |
| 7114 | "Do not export to next AS (well-known community)\n" |
| 7115 | "Exact match of the communities") |
| 7116 | |
| 7117 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7118 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 7119 | "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", |
| 7120 | SHOW_STR |
| 7121 | IP_STR |
| 7122 | BGP_STR |
| 7123 | "Address family\n" |
| 7124 | "Address Family modifier\n" |
| 7125 | "Address Family modifier\n" |
| 7126 | "Display routes matching the communities\n" |
| 7127 | "community number\n" |
| 7128 | "Do not send outside local AS (well-known community)\n" |
| 7129 | "Do not advertise to any peer (well-known community)\n" |
| 7130 | "Do not export to next AS (well-known community)\n" |
| 7131 | "community number\n" |
| 7132 | "Do not send outside local AS (well-known community)\n" |
| 7133 | "Do not advertise to any peer (well-known community)\n" |
| 7134 | "Do not export to next AS (well-known community)\n" |
| 7135 | "community number\n" |
| 7136 | "Do not send outside local AS (well-known community)\n" |
| 7137 | "Do not advertise to any peer (well-known community)\n" |
| 7138 | "Do not export to next AS (well-known community)\n" |
| 7139 | "Exact match of the communities") |
| 7140 | |
| 7141 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7142 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 7143 | "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", |
| 7144 | SHOW_STR |
| 7145 | IP_STR |
| 7146 | BGP_STR |
| 7147 | "Address family\n" |
| 7148 | "Address Family modifier\n" |
| 7149 | "Address Family modifier\n" |
| 7150 | "Display routes matching the communities\n" |
| 7151 | "community number\n" |
| 7152 | "Do not send outside local AS (well-known community)\n" |
| 7153 | "Do not advertise to any peer (well-known community)\n" |
| 7154 | "Do not export to next AS (well-known community)\n" |
| 7155 | "community number\n" |
| 7156 | "Do not send outside local AS (well-known community)\n" |
| 7157 | "Do not advertise to any peer (well-known community)\n" |
| 7158 | "Do not export to next AS (well-known community)\n" |
| 7159 | "community number\n" |
| 7160 | "Do not send outside local AS (well-known community)\n" |
| 7161 | "Do not advertise to any peer (well-known community)\n" |
| 7162 | "Do not export to next AS (well-known community)\n" |
| 7163 | "community number\n" |
| 7164 | "Do not send outside local AS (well-known community)\n" |
| 7165 | "Do not advertise to any peer (well-known community)\n" |
| 7166 | "Do not export to next AS (well-known community)\n" |
| 7167 | "Exact match of the communities") |
| 7168 | |
| 7169 | #ifdef HAVE_IPV6 |
| 7170 | DEFUN (show_bgp_community, |
| 7171 | show_bgp_community_cmd, |
| 7172 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7173 | SHOW_STR |
| 7174 | BGP_STR |
| 7175 | "Display routes matching the communities\n" |
| 7176 | "community number\n" |
| 7177 | "Do not send outside local AS (well-known community)\n" |
| 7178 | "Do not advertise to any peer (well-known community)\n" |
| 7179 | "Do not export to next AS (well-known community)\n") |
| 7180 | { |
| 7181 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7182 | } |
| 7183 | |
| 7184 | ALIAS (show_bgp_community, |
| 7185 | show_bgp_ipv6_community_cmd, |
| 7186 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 7187 | SHOW_STR |
| 7188 | BGP_STR |
| 7189 | "Address family\n" |
| 7190 | "Display routes matching the communities\n" |
| 7191 | "community number\n" |
| 7192 | "Do not send outside local AS (well-known community)\n" |
| 7193 | "Do not advertise to any peer (well-known community)\n" |
| 7194 | "Do not export to next AS (well-known community)\n") |
| 7195 | |
| 7196 | ALIAS (show_bgp_community, |
| 7197 | show_bgp_community2_cmd, |
| 7198 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7199 | SHOW_STR |
| 7200 | BGP_STR |
| 7201 | "Display routes matching the communities\n" |
| 7202 | "community number\n" |
| 7203 | "Do not send outside local AS (well-known community)\n" |
| 7204 | "Do not advertise to any peer (well-known community)\n" |
| 7205 | "Do not export to next AS (well-known community)\n" |
| 7206 | "community number\n" |
| 7207 | "Do not send outside local AS (well-known community)\n" |
| 7208 | "Do not advertise to any peer (well-known community)\n" |
| 7209 | "Do not export to next AS (well-known community)\n") |
| 7210 | |
| 7211 | ALIAS (show_bgp_community, |
| 7212 | show_bgp_ipv6_community2_cmd, |
| 7213 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7214 | SHOW_STR |
| 7215 | BGP_STR |
| 7216 | "Address family\n" |
| 7217 | "Display routes matching the communities\n" |
| 7218 | "community number\n" |
| 7219 | "Do not send outside local AS (well-known community)\n" |
| 7220 | "Do not advertise to any peer (well-known community)\n" |
| 7221 | "Do not export to next AS (well-known community)\n" |
| 7222 | "community number\n" |
| 7223 | "Do not send outside local AS (well-known community)\n" |
| 7224 | "Do not advertise to any peer (well-known community)\n" |
| 7225 | "Do not export to next AS (well-known community)\n") |
| 7226 | |
| 7227 | ALIAS (show_bgp_community, |
| 7228 | show_bgp_community3_cmd, |
| 7229 | "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)", |
| 7230 | SHOW_STR |
| 7231 | BGP_STR |
| 7232 | "Display routes matching the communities\n" |
| 7233 | "community number\n" |
| 7234 | "Do not send outside local AS (well-known community)\n" |
| 7235 | "Do not advertise to any peer (well-known community)\n" |
| 7236 | "Do not export to next AS (well-known community)\n" |
| 7237 | "community number\n" |
| 7238 | "Do not send outside local AS (well-known community)\n" |
| 7239 | "Do not advertise to any peer (well-known community)\n" |
| 7240 | "Do not export to next AS (well-known community)\n" |
| 7241 | "community number\n" |
| 7242 | "Do not send outside local AS (well-known community)\n" |
| 7243 | "Do not advertise to any peer (well-known community)\n" |
| 7244 | "Do not export to next AS (well-known community)\n") |
| 7245 | |
| 7246 | ALIAS (show_bgp_community, |
| 7247 | show_bgp_ipv6_community3_cmd, |
| 7248 | "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)", |
| 7249 | SHOW_STR |
| 7250 | BGP_STR |
| 7251 | "Address family\n" |
| 7252 | "Display routes matching the communities\n" |
| 7253 | "community number\n" |
| 7254 | "Do not send outside local AS (well-known community)\n" |
| 7255 | "Do not advertise to any peer (well-known community)\n" |
| 7256 | "Do not export to next AS (well-known community)\n" |
| 7257 | "community number\n" |
| 7258 | "Do not send outside local AS (well-known community)\n" |
| 7259 | "Do not advertise to any peer (well-known community)\n" |
| 7260 | "Do not export to next AS (well-known community)\n" |
| 7261 | "community number\n" |
| 7262 | "Do not send outside local AS (well-known community)\n" |
| 7263 | "Do not advertise to any peer (well-known community)\n" |
| 7264 | "Do not export to next AS (well-known community)\n") |
| 7265 | |
| 7266 | ALIAS (show_bgp_community, |
| 7267 | show_bgp_community4_cmd, |
| 7268 | "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)", |
| 7269 | SHOW_STR |
| 7270 | BGP_STR |
| 7271 | "Display routes matching the communities\n" |
| 7272 | "community number\n" |
| 7273 | "Do not send outside local AS (well-known community)\n" |
| 7274 | "Do not advertise to any peer (well-known community)\n" |
| 7275 | "Do not export to next AS (well-known community)\n" |
| 7276 | "community number\n" |
| 7277 | "Do not send outside local AS (well-known community)\n" |
| 7278 | "Do not advertise to any peer (well-known community)\n" |
| 7279 | "Do not export to next AS (well-known community)\n" |
| 7280 | "community number\n" |
| 7281 | "Do not send outside local AS (well-known community)\n" |
| 7282 | "Do not advertise to any peer (well-known community)\n" |
| 7283 | "Do not export to next AS (well-known community)\n" |
| 7284 | "community number\n" |
| 7285 | "Do not send outside local AS (well-known community)\n" |
| 7286 | "Do not advertise to any peer (well-known community)\n" |
| 7287 | "Do not export to next AS (well-known community)\n") |
| 7288 | |
| 7289 | ALIAS (show_bgp_community, |
| 7290 | show_bgp_ipv6_community4_cmd, |
| 7291 | "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)", |
| 7292 | SHOW_STR |
| 7293 | BGP_STR |
| 7294 | "Address family\n" |
| 7295 | "Display routes matching the communities\n" |
| 7296 | "community number\n" |
| 7297 | "Do not send outside local AS (well-known community)\n" |
| 7298 | "Do not advertise to any peer (well-known community)\n" |
| 7299 | "Do not export to next AS (well-known community)\n" |
| 7300 | "community number\n" |
| 7301 | "Do not send outside local AS (well-known community)\n" |
| 7302 | "Do not advertise to any peer (well-known community)\n" |
| 7303 | "Do not export to next AS (well-known community)\n" |
| 7304 | "community number\n" |
| 7305 | "Do not send outside local AS (well-known community)\n" |
| 7306 | "Do not advertise to any peer (well-known community)\n" |
| 7307 | "Do not export to next AS (well-known community)\n" |
| 7308 | "community number\n" |
| 7309 | "Do not send outside local AS (well-known community)\n" |
| 7310 | "Do not advertise to any peer (well-known community)\n" |
| 7311 | "Do not export to next AS (well-known community)\n") |
| 7312 | |
| 7313 | /* old command */ |
| 7314 | DEFUN (show_ipv6_bgp_community, |
| 7315 | show_ipv6_bgp_community_cmd, |
| 7316 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7317 | SHOW_STR |
| 7318 | IPV6_STR |
| 7319 | BGP_STR |
| 7320 | "Display routes matching the communities\n" |
| 7321 | "community number\n" |
| 7322 | "Do not send outside local AS (well-known community)\n" |
| 7323 | "Do not advertise to any peer (well-known community)\n" |
| 7324 | "Do not export to next AS (well-known community)\n") |
| 7325 | { |
| 7326 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7327 | } |
| 7328 | |
| 7329 | /* old command */ |
| 7330 | ALIAS (show_ipv6_bgp_community, |
| 7331 | show_ipv6_bgp_community2_cmd, |
| 7332 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7333 | SHOW_STR |
| 7334 | IPV6_STR |
| 7335 | BGP_STR |
| 7336 | "Display routes matching the communities\n" |
| 7337 | "community number\n" |
| 7338 | "Do not send outside local AS (well-known community)\n" |
| 7339 | "Do not advertise to any peer (well-known community)\n" |
| 7340 | "Do not export to next AS (well-known community)\n" |
| 7341 | "community number\n" |
| 7342 | "Do not send outside local AS (well-known community)\n" |
| 7343 | "Do not advertise to any peer (well-known community)\n" |
| 7344 | "Do not export to next AS (well-known community)\n") |
| 7345 | |
| 7346 | /* old command */ |
| 7347 | ALIAS (show_ipv6_bgp_community, |
| 7348 | show_ipv6_bgp_community3_cmd, |
| 7349 | "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)", |
| 7350 | SHOW_STR |
| 7351 | IPV6_STR |
| 7352 | BGP_STR |
| 7353 | "Display routes matching the communities\n" |
| 7354 | "community number\n" |
| 7355 | "Do not send outside local AS (well-known community)\n" |
| 7356 | "Do not advertise to any peer (well-known community)\n" |
| 7357 | "Do not export to next AS (well-known community)\n" |
| 7358 | "community number\n" |
| 7359 | "Do not send outside local AS (well-known community)\n" |
| 7360 | "Do not advertise to any peer (well-known community)\n" |
| 7361 | "Do not export to next AS (well-known community)\n" |
| 7362 | "community number\n" |
| 7363 | "Do not send outside local AS (well-known community)\n" |
| 7364 | "Do not advertise to any peer (well-known community)\n" |
| 7365 | "Do not export to next AS (well-known community)\n") |
| 7366 | |
| 7367 | /* old command */ |
| 7368 | ALIAS (show_ipv6_bgp_community, |
| 7369 | show_ipv6_bgp_community4_cmd, |
| 7370 | "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)", |
| 7371 | SHOW_STR |
| 7372 | IPV6_STR |
| 7373 | BGP_STR |
| 7374 | "Display routes matching the communities\n" |
| 7375 | "community number\n" |
| 7376 | "Do not send outside local AS (well-known community)\n" |
| 7377 | "Do not advertise to any peer (well-known community)\n" |
| 7378 | "Do not export to next AS (well-known community)\n" |
| 7379 | "community number\n" |
| 7380 | "Do not send outside local AS (well-known community)\n" |
| 7381 | "Do not advertise to any peer (well-known community)\n" |
| 7382 | "Do not export to next AS (well-known community)\n" |
| 7383 | "community number\n" |
| 7384 | "Do not send outside local AS (well-known community)\n" |
| 7385 | "Do not advertise to any peer (well-known community)\n" |
| 7386 | "Do not export to next AS (well-known community)\n" |
| 7387 | "community number\n" |
| 7388 | "Do not send outside local AS (well-known community)\n" |
| 7389 | "Do not advertise to any peer (well-known community)\n" |
| 7390 | "Do not export to next AS (well-known community)\n") |
| 7391 | |
| 7392 | DEFUN (show_bgp_community_exact, |
| 7393 | show_bgp_community_exact_cmd, |
| 7394 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7395 | SHOW_STR |
| 7396 | BGP_STR |
| 7397 | "Display routes matching the communities\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 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7405 | } |
| 7406 | |
| 7407 | ALIAS (show_bgp_community_exact, |
| 7408 | show_bgp_ipv6_community_exact_cmd, |
| 7409 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7410 | SHOW_STR |
| 7411 | BGP_STR |
| 7412 | "Address family\n" |
| 7413 | "Display routes matching the communities\n" |
| 7414 | "community number\n" |
| 7415 | "Do not send outside local AS (well-known community)\n" |
| 7416 | "Do not advertise to any peer (well-known community)\n" |
| 7417 | "Do not export to next AS (well-known community)\n" |
| 7418 | "Exact match of the communities") |
| 7419 | |
| 7420 | ALIAS (show_bgp_community_exact, |
| 7421 | show_bgp_community2_exact_cmd, |
| 7422 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7423 | SHOW_STR |
| 7424 | BGP_STR |
| 7425 | "Display routes matching the communities\n" |
| 7426 | "community number\n" |
| 7427 | "Do not send outside local AS (well-known community)\n" |
| 7428 | "Do not advertise to any peer (well-known community)\n" |
| 7429 | "Do not export to next AS (well-known community)\n" |
| 7430 | "community number\n" |
| 7431 | "Do not send outside local AS (well-known community)\n" |
| 7432 | "Do not advertise to any peer (well-known community)\n" |
| 7433 | "Do not export to next AS (well-known community)\n" |
| 7434 | "Exact match of the communities") |
| 7435 | |
| 7436 | ALIAS (show_bgp_community_exact, |
| 7437 | show_bgp_ipv6_community2_exact_cmd, |
| 7438 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7439 | SHOW_STR |
| 7440 | BGP_STR |
| 7441 | "Address family\n" |
| 7442 | "Display routes matching the communities\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 | "community number\n" |
| 7448 | "Do not send outside local AS (well-known community)\n" |
| 7449 | "Do not advertise to any peer (well-known community)\n" |
| 7450 | "Do not export to next AS (well-known community)\n" |
| 7451 | "Exact match of the communities") |
| 7452 | |
| 7453 | ALIAS (show_bgp_community_exact, |
| 7454 | show_bgp_community3_exact_cmd, |
| 7455 | "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", |
| 7456 | SHOW_STR |
| 7457 | BGP_STR |
| 7458 | "Display routes matching the communities\n" |
| 7459 | "community number\n" |
| 7460 | "Do not send outside local AS (well-known community)\n" |
| 7461 | "Do not advertise to any peer (well-known community)\n" |
| 7462 | "Do not export to next AS (well-known community)\n" |
| 7463 | "community number\n" |
| 7464 | "Do not send outside local AS (well-known community)\n" |
| 7465 | "Do not advertise to any peer (well-known community)\n" |
| 7466 | "Do not export to next AS (well-known community)\n" |
| 7467 | "community number\n" |
| 7468 | "Do not send outside local AS (well-known community)\n" |
| 7469 | "Do not advertise to any peer (well-known community)\n" |
| 7470 | "Do not export to next AS (well-known community)\n" |
| 7471 | "Exact match of the communities") |
| 7472 | |
| 7473 | ALIAS (show_bgp_community_exact, |
| 7474 | show_bgp_ipv6_community3_exact_cmd, |
| 7475 | "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", |
| 7476 | SHOW_STR |
| 7477 | BGP_STR |
| 7478 | "Address family\n" |
| 7479 | "Display routes matching the communities\n" |
| 7480 | "community number\n" |
| 7481 | "Do not send outside local AS (well-known community)\n" |
| 7482 | "Do not advertise to any peer (well-known community)\n" |
| 7483 | "Do not export to next AS (well-known community)\n" |
| 7484 | "community number\n" |
| 7485 | "Do not send outside local AS (well-known community)\n" |
| 7486 | "Do not advertise to any peer (well-known community)\n" |
| 7487 | "Do not export to next AS (well-known community)\n" |
| 7488 | "community number\n" |
| 7489 | "Do not send outside local AS (well-known community)\n" |
| 7490 | "Do not advertise to any peer (well-known community)\n" |
| 7491 | "Do not export to next AS (well-known community)\n" |
| 7492 | "Exact match of the communities") |
| 7493 | |
| 7494 | ALIAS (show_bgp_community_exact, |
| 7495 | show_bgp_community4_exact_cmd, |
| 7496 | "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", |
| 7497 | SHOW_STR |
| 7498 | BGP_STR |
| 7499 | "Display routes matching the communities\n" |
| 7500 | "community number\n" |
| 7501 | "Do not send outside local AS (well-known community)\n" |
| 7502 | "Do not advertise to any peer (well-known community)\n" |
| 7503 | "Do not export to next AS (well-known community)\n" |
| 7504 | "community number\n" |
| 7505 | "Do not send outside local AS (well-known community)\n" |
| 7506 | "Do not advertise to any peer (well-known community)\n" |
| 7507 | "Do not export to next AS (well-known community)\n" |
| 7508 | "community number\n" |
| 7509 | "Do not send outside local AS (well-known community)\n" |
| 7510 | "Do not advertise to any peer (well-known community)\n" |
| 7511 | "Do not export to next AS (well-known community)\n" |
| 7512 | "community number\n" |
| 7513 | "Do not send outside local AS (well-known community)\n" |
| 7514 | "Do not advertise to any peer (well-known community)\n" |
| 7515 | "Do not export to next AS (well-known community)\n" |
| 7516 | "Exact match of the communities") |
| 7517 | |
| 7518 | ALIAS (show_bgp_community_exact, |
| 7519 | show_bgp_ipv6_community4_exact_cmd, |
| 7520 | "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", |
| 7521 | SHOW_STR |
| 7522 | BGP_STR |
| 7523 | "Address family\n" |
| 7524 | "Display routes matching the communities\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 | "community number\n" |
| 7530 | "Do not send outside local AS (well-known community)\n" |
| 7531 | "Do not advertise to any peer (well-known community)\n" |
| 7532 | "Do not export to next AS (well-known community)\n" |
| 7533 | "community number\n" |
| 7534 | "Do not send outside local AS (well-known community)\n" |
| 7535 | "Do not advertise to any peer (well-known community)\n" |
| 7536 | "Do not export to next AS (well-known community)\n" |
| 7537 | "community number\n" |
| 7538 | "Do not send outside local AS (well-known community)\n" |
| 7539 | "Do not advertise to any peer (well-known community)\n" |
| 7540 | "Do not export to next AS (well-known community)\n" |
| 7541 | "Exact match of the communities") |
| 7542 | |
| 7543 | /* old command */ |
| 7544 | DEFUN (show_ipv6_bgp_community_exact, |
| 7545 | show_ipv6_bgp_community_exact_cmd, |
| 7546 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7547 | SHOW_STR |
| 7548 | IPV6_STR |
| 7549 | BGP_STR |
| 7550 | "Display routes matching the communities\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 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7558 | } |
| 7559 | |
| 7560 | /* old command */ |
| 7561 | ALIAS (show_ipv6_bgp_community_exact, |
| 7562 | show_ipv6_bgp_community2_exact_cmd, |
| 7563 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7564 | SHOW_STR |
| 7565 | IPV6_STR |
| 7566 | BGP_STR |
| 7567 | "Display routes matching the communities\n" |
| 7568 | "community number\n" |
| 7569 | "Do not send outside local AS (well-known community)\n" |
| 7570 | "Do not advertise to any peer (well-known community)\n" |
| 7571 | "Do not export to next AS (well-known community)\n" |
| 7572 | "community number\n" |
| 7573 | "Do not send outside local AS (well-known community)\n" |
| 7574 | "Do not advertise to any peer (well-known community)\n" |
| 7575 | "Do not export to next AS (well-known community)\n" |
| 7576 | "Exact match of the communities") |
| 7577 | |
| 7578 | /* old command */ |
| 7579 | ALIAS (show_ipv6_bgp_community_exact, |
| 7580 | show_ipv6_bgp_community3_exact_cmd, |
| 7581 | "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", |
| 7582 | SHOW_STR |
| 7583 | IPV6_STR |
| 7584 | BGP_STR |
| 7585 | "Display routes matching the communities\n" |
| 7586 | "community number\n" |
| 7587 | "Do not send outside local AS (well-known community)\n" |
| 7588 | "Do not advertise to any peer (well-known community)\n" |
| 7589 | "Do not export to next AS (well-known community)\n" |
| 7590 | "community number\n" |
| 7591 | "Do not send outside local AS (well-known community)\n" |
| 7592 | "Do not advertise to any peer (well-known community)\n" |
| 7593 | "Do not export to next AS (well-known community)\n" |
| 7594 | "community number\n" |
| 7595 | "Do not send outside local AS (well-known community)\n" |
| 7596 | "Do not advertise to any peer (well-known community)\n" |
| 7597 | "Do not export to next AS (well-known community)\n" |
| 7598 | "Exact match of the communities") |
| 7599 | |
| 7600 | /* old command */ |
| 7601 | ALIAS (show_ipv6_bgp_community_exact, |
| 7602 | show_ipv6_bgp_community4_exact_cmd, |
| 7603 | "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", |
| 7604 | SHOW_STR |
| 7605 | IPV6_STR |
| 7606 | BGP_STR |
| 7607 | "Display routes matching the communities\n" |
| 7608 | "community number\n" |
| 7609 | "Do not send outside local AS (well-known community)\n" |
| 7610 | "Do not advertise to any peer (well-known community)\n" |
| 7611 | "Do not export to next AS (well-known community)\n" |
| 7612 | "community number\n" |
| 7613 | "Do not send outside local AS (well-known community)\n" |
| 7614 | "Do not advertise to any peer (well-known community)\n" |
| 7615 | "Do not export to next AS (well-known community)\n" |
| 7616 | "community number\n" |
| 7617 | "Do not send outside local AS (well-known community)\n" |
| 7618 | "Do not advertise to any peer (well-known community)\n" |
| 7619 | "Do not export to next AS (well-known community)\n" |
| 7620 | "community number\n" |
| 7621 | "Do not send outside local AS (well-known community)\n" |
| 7622 | "Do not advertise to any peer (well-known community)\n" |
| 7623 | "Do not export to next AS (well-known community)\n" |
| 7624 | "Exact match of the communities") |
| 7625 | |
| 7626 | /* old command */ |
| 7627 | DEFUN (show_ipv6_mbgp_community, |
| 7628 | show_ipv6_mbgp_community_cmd, |
| 7629 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7630 | SHOW_STR |
| 7631 | IPV6_STR |
| 7632 | MBGP_STR |
| 7633 | "Display routes matching the communities\n" |
| 7634 | "community number\n" |
| 7635 | "Do not send outside local AS (well-known community)\n" |
| 7636 | "Do not advertise to any peer (well-known community)\n" |
| 7637 | "Do not export to next AS (well-known community)\n") |
| 7638 | { |
| 7639 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 7640 | } |
| 7641 | |
| 7642 | /* old command */ |
| 7643 | ALIAS (show_ipv6_mbgp_community, |
| 7644 | show_ipv6_mbgp_community2_cmd, |
| 7645 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7646 | SHOW_STR |
| 7647 | IPV6_STR |
| 7648 | MBGP_STR |
| 7649 | "Display routes matching the communities\n" |
| 7650 | "community number\n" |
| 7651 | "Do not send outside local AS (well-known community)\n" |
| 7652 | "Do not advertise to any peer (well-known community)\n" |
| 7653 | "Do not export to next AS (well-known community)\n" |
| 7654 | "community number\n" |
| 7655 | "Do not send outside local AS (well-known community)\n" |
| 7656 | "Do not advertise to any peer (well-known community)\n" |
| 7657 | "Do not export to next AS (well-known community)\n") |
| 7658 | |
| 7659 | /* old command */ |
| 7660 | ALIAS (show_ipv6_mbgp_community, |
| 7661 | show_ipv6_mbgp_community3_cmd, |
| 7662 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7663 | SHOW_STR |
| 7664 | IPV6_STR |
| 7665 | MBGP_STR |
| 7666 | "Display routes matching the communities\n" |
| 7667 | "community number\n" |
| 7668 | "Do not send outside local AS (well-known community)\n" |
| 7669 | "Do not advertise to any peer (well-known community)\n" |
| 7670 | "Do not export to next AS (well-known community)\n" |
| 7671 | "community number\n" |
| 7672 | "Do not send outside local AS (well-known community)\n" |
| 7673 | "Do not advertise to any peer (well-known community)\n" |
| 7674 | "Do not export to next AS (well-known community)\n" |
| 7675 | "community number\n" |
| 7676 | "Do not send outside local AS (well-known community)\n" |
| 7677 | "Do not advertise to any peer (well-known community)\n" |
| 7678 | "Do not export to next AS (well-known community)\n") |
| 7679 | |
| 7680 | /* old command */ |
| 7681 | ALIAS (show_ipv6_mbgp_community, |
| 7682 | show_ipv6_mbgp_community4_cmd, |
| 7683 | "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)", |
| 7684 | SHOW_STR |
| 7685 | IPV6_STR |
| 7686 | MBGP_STR |
| 7687 | "Display routes matching the communities\n" |
| 7688 | "community number\n" |
| 7689 | "Do not send outside local AS (well-known community)\n" |
| 7690 | "Do not advertise to any peer (well-known community)\n" |
| 7691 | "Do not export to next AS (well-known community)\n" |
| 7692 | "community number\n" |
| 7693 | "Do not send outside local AS (well-known community)\n" |
| 7694 | "Do not advertise to any peer (well-known community)\n" |
| 7695 | "Do not export to next AS (well-known community)\n" |
| 7696 | "community number\n" |
| 7697 | "Do not send outside local AS (well-known community)\n" |
| 7698 | "Do not advertise to any peer (well-known community)\n" |
| 7699 | "Do not export to next AS (well-known community)\n" |
| 7700 | "community number\n" |
| 7701 | "Do not send outside local AS (well-known community)\n" |
| 7702 | "Do not advertise to any peer (well-known community)\n" |
| 7703 | "Do not export to next AS (well-known community)\n") |
| 7704 | |
| 7705 | /* old command */ |
| 7706 | DEFUN (show_ipv6_mbgp_community_exact, |
| 7707 | show_ipv6_mbgp_community_exact_cmd, |
| 7708 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7709 | SHOW_STR |
| 7710 | IPV6_STR |
| 7711 | MBGP_STR |
| 7712 | "Display routes matching the communities\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 | { |
| 7719 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 7720 | } |
| 7721 | |
| 7722 | /* old command */ |
| 7723 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7724 | show_ipv6_mbgp_community2_exact_cmd, |
| 7725 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7726 | SHOW_STR |
| 7727 | IPV6_STR |
| 7728 | MBGP_STR |
| 7729 | "Display routes matching the communities\n" |
| 7730 | "community number\n" |
| 7731 | "Do not send outside local AS (well-known community)\n" |
| 7732 | "Do not advertise to any peer (well-known community)\n" |
| 7733 | "Do not export to next AS (well-known community)\n" |
| 7734 | "community number\n" |
| 7735 | "Do not send outside local AS (well-known community)\n" |
| 7736 | "Do not advertise to any peer (well-known community)\n" |
| 7737 | "Do not export to next AS (well-known community)\n" |
| 7738 | "Exact match of the communities") |
| 7739 | |
| 7740 | /* old command */ |
| 7741 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7742 | show_ipv6_mbgp_community3_exact_cmd, |
| 7743 | "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", |
| 7744 | SHOW_STR |
| 7745 | IPV6_STR |
| 7746 | MBGP_STR |
| 7747 | "Display routes matching the communities\n" |
| 7748 | "community number\n" |
| 7749 | "Do not send outside local AS (well-known community)\n" |
| 7750 | "Do not advertise to any peer (well-known community)\n" |
| 7751 | "Do not export to next AS (well-known community)\n" |
| 7752 | "community number\n" |
| 7753 | "Do not send outside local AS (well-known community)\n" |
| 7754 | "Do not advertise to any peer (well-known community)\n" |
| 7755 | "Do not export to next AS (well-known community)\n" |
| 7756 | "community number\n" |
| 7757 | "Do not send outside local AS (well-known community)\n" |
| 7758 | "Do not advertise to any peer (well-known community)\n" |
| 7759 | "Do not export to next AS (well-known community)\n" |
| 7760 | "Exact match of the communities") |
| 7761 | |
| 7762 | /* old command */ |
| 7763 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7764 | show_ipv6_mbgp_community4_exact_cmd, |
| 7765 | "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", |
| 7766 | SHOW_STR |
| 7767 | IPV6_STR |
| 7768 | MBGP_STR |
| 7769 | "Display routes matching the communities\n" |
| 7770 | "community number\n" |
| 7771 | "Do not send outside local AS (well-known community)\n" |
| 7772 | "Do not advertise to any peer (well-known community)\n" |
| 7773 | "Do not export to next AS (well-known community)\n" |
| 7774 | "community number\n" |
| 7775 | "Do not send outside local AS (well-known community)\n" |
| 7776 | "Do not advertise to any peer (well-known community)\n" |
| 7777 | "Do not export to next AS (well-known community)\n" |
| 7778 | "community number\n" |
| 7779 | "Do not send outside local AS (well-known community)\n" |
| 7780 | "Do not advertise to any peer (well-known community)\n" |
| 7781 | "Do not export to next AS (well-known community)\n" |
| 7782 | "community number\n" |
| 7783 | "Do not send outside local AS (well-known community)\n" |
| 7784 | "Do not advertise to any peer (well-known community)\n" |
| 7785 | "Do not export to next AS (well-known community)\n" |
| 7786 | "Exact match of the communities") |
| 7787 | #endif /* HAVE_IPV6 */ |
| 7788 | |
| 7789 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7790 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7791 | u_int16_t afi, u_char safi) |
| 7792 | { |
| 7793 | struct community_list *list; |
| 7794 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7795 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7796 | if (list == NULL) |
| 7797 | { |
| 7798 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 7799 | VTY_NEWLINE); |
| 7800 | return CMD_WARNING; |
| 7801 | } |
| 7802 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7803 | return bgp_show (vty, NULL, afi, safi, |
| 7804 | (exact ? bgp_show_type_community_list_exact : |
| 7805 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7806 | } |
| 7807 | |
| 7808 | DEFUN (show_ip_bgp_community_list, |
| 7809 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7810 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7811 | SHOW_STR |
| 7812 | IP_STR |
| 7813 | BGP_STR |
| 7814 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7815 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7816 | "community-list name\n") |
| 7817 | { |
| 7818 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 7819 | } |
| 7820 | |
| 7821 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 7822 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7823 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7824 | SHOW_STR |
| 7825 | IP_STR |
| 7826 | BGP_STR |
| 7827 | "Address family\n" |
| 7828 | "Address Family modifier\n" |
| 7829 | "Address Family modifier\n" |
| 7830 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7831 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7832 | "community-list name\n") |
| 7833 | { |
| 7834 | if (strncmp (argv[0], "m", 1) == 0) |
| 7835 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 7836 | |
| 7837 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 7838 | } |
| 7839 | |
| 7840 | DEFUN (show_ip_bgp_community_list_exact, |
| 7841 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7842 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7843 | SHOW_STR |
| 7844 | IP_STR |
| 7845 | BGP_STR |
| 7846 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7847 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7848 | "community-list name\n" |
| 7849 | "Exact match of the communities\n") |
| 7850 | { |
| 7851 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 7852 | } |
| 7853 | |
| 7854 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 7855 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7856 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7857 | SHOW_STR |
| 7858 | IP_STR |
| 7859 | BGP_STR |
| 7860 | "Address family\n" |
| 7861 | "Address Family modifier\n" |
| 7862 | "Address Family modifier\n" |
| 7863 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7864 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7865 | "community-list name\n" |
| 7866 | "Exact match of the communities\n") |
| 7867 | { |
| 7868 | if (strncmp (argv[0], "m", 1) == 0) |
| 7869 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 7870 | |
| 7871 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 7872 | } |
| 7873 | |
| 7874 | #ifdef HAVE_IPV6 |
| 7875 | DEFUN (show_bgp_community_list, |
| 7876 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7877 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7878 | SHOW_STR |
| 7879 | BGP_STR |
| 7880 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7881 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7882 | "community-list name\n") |
| 7883 | { |
| 7884 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7885 | } |
| 7886 | |
| 7887 | ALIAS (show_bgp_community_list, |
| 7888 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7889 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7890 | SHOW_STR |
| 7891 | BGP_STR |
| 7892 | "Address family\n" |
| 7893 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7894 | "community-list number\n" |
| 7895 | "community-list name\n"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7896 | |
| 7897 | /* old command */ |
| 7898 | DEFUN (show_ipv6_bgp_community_list, |
| 7899 | show_ipv6_bgp_community_list_cmd, |
| 7900 | "show ipv6 bgp community-list WORD", |
| 7901 | SHOW_STR |
| 7902 | IPV6_STR |
| 7903 | BGP_STR |
| 7904 | "Display routes matching the community-list\n" |
| 7905 | "community-list name\n") |
| 7906 | { |
| 7907 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 7908 | } |
| 7909 | |
| 7910 | /* old command */ |
| 7911 | DEFUN (show_ipv6_mbgp_community_list, |
| 7912 | show_ipv6_mbgp_community_list_cmd, |
| 7913 | "show ipv6 mbgp community-list WORD", |
| 7914 | SHOW_STR |
| 7915 | IPV6_STR |
| 7916 | MBGP_STR |
| 7917 | "Display routes matching the community-list\n" |
| 7918 | "community-list name\n") |
| 7919 | { |
| 7920 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 7921 | } |
| 7922 | |
| 7923 | DEFUN (show_bgp_community_list_exact, |
| 7924 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7925 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7926 | SHOW_STR |
| 7927 | BGP_STR |
| 7928 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7929 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7930 | "community-list name\n" |
| 7931 | "Exact match of the communities\n") |
| 7932 | { |
| 7933 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7934 | } |
| 7935 | |
| 7936 | ALIAS (show_bgp_community_list_exact, |
| 7937 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7938 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7939 | SHOW_STR |
| 7940 | BGP_STR |
| 7941 | "Address family\n" |
| 7942 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7943 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7944 | "community-list name\n" |
| 7945 | "Exact match of the communities\n") |
| 7946 | |
| 7947 | /* old command */ |
| 7948 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 7949 | show_ipv6_bgp_community_list_exact_cmd, |
| 7950 | "show ipv6 bgp community-list WORD exact-match", |
| 7951 | SHOW_STR |
| 7952 | IPV6_STR |
| 7953 | BGP_STR |
| 7954 | "Display routes matching the community-list\n" |
| 7955 | "community-list name\n" |
| 7956 | "Exact match of the communities\n") |
| 7957 | { |
| 7958 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 7959 | } |
| 7960 | |
| 7961 | /* old command */ |
| 7962 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 7963 | show_ipv6_mbgp_community_list_exact_cmd, |
| 7964 | "show ipv6 mbgp community-list WORD exact-match", |
| 7965 | SHOW_STR |
| 7966 | IPV6_STR |
| 7967 | MBGP_STR |
| 7968 | "Display routes matching the community-list\n" |
| 7969 | "community-list name\n" |
| 7970 | "Exact match of the communities\n") |
| 7971 | { |
| 7972 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 7973 | } |
| 7974 | #endif /* HAVE_IPV6 */ |
| 7975 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7976 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7977 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7978 | safi_t safi, enum bgp_show_type type) |
| 7979 | { |
| 7980 | int ret; |
| 7981 | struct prefix *p; |
| 7982 | |
| 7983 | p = prefix_new(); |
| 7984 | |
| 7985 | ret = str2prefix (prefix, p); |
| 7986 | if (! ret) |
| 7987 | { |
| 7988 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 7989 | return CMD_WARNING; |
| 7990 | } |
| 7991 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7992 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 7993 | prefix_free(p); |
| 7994 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7995 | } |
| 7996 | |
| 7997 | DEFUN (show_ip_bgp_prefix_longer, |
| 7998 | show_ip_bgp_prefix_longer_cmd, |
| 7999 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 8000 | SHOW_STR |
| 8001 | IP_STR |
| 8002 | BGP_STR |
| 8003 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8004 | "Display route and more specific routes\n") |
| 8005 | { |
| 8006 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8007 | bgp_show_type_prefix_longer); |
| 8008 | } |
| 8009 | |
| 8010 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 8011 | show_ip_bgp_flap_prefix_longer_cmd, |
| 8012 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 8013 | SHOW_STR |
| 8014 | IP_STR |
| 8015 | BGP_STR |
| 8016 | "Display flap statistics of routes\n" |
| 8017 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8018 | "Display route and more specific routes\n") |
| 8019 | { |
| 8020 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8021 | bgp_show_type_flap_prefix_longer); |
| 8022 | } |
| 8023 | |
| 8024 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 8025 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 8026 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 8027 | SHOW_STR |
| 8028 | IP_STR |
| 8029 | BGP_STR |
| 8030 | "Address family\n" |
| 8031 | "Address Family modifier\n" |
| 8032 | "Address Family modifier\n" |
| 8033 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8034 | "Display route and more specific routes\n") |
| 8035 | { |
| 8036 | if (strncmp (argv[0], "m", 1) == 0) |
| 8037 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8038 | bgp_show_type_prefix_longer); |
| 8039 | |
| 8040 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8041 | bgp_show_type_prefix_longer); |
| 8042 | } |
| 8043 | |
| 8044 | DEFUN (show_ip_bgp_flap_address, |
| 8045 | show_ip_bgp_flap_address_cmd, |
| 8046 | "show ip bgp flap-statistics A.B.C.D", |
| 8047 | SHOW_STR |
| 8048 | IP_STR |
| 8049 | BGP_STR |
| 8050 | "Display flap statistics of routes\n" |
| 8051 | "Network in the BGP routing table to display\n") |
| 8052 | { |
| 8053 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8054 | bgp_show_type_flap_address); |
| 8055 | } |
| 8056 | |
| 8057 | DEFUN (show_ip_bgp_flap_prefix, |
| 8058 | show_ip_bgp_flap_prefix_cmd, |
| 8059 | "show ip bgp flap-statistics A.B.C.D/M", |
| 8060 | SHOW_STR |
| 8061 | IP_STR |
| 8062 | BGP_STR |
| 8063 | "Display flap statistics of routes\n" |
| 8064 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8065 | { |
| 8066 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8067 | bgp_show_type_flap_prefix); |
| 8068 | } |
| 8069 | #ifdef HAVE_IPV6 |
| 8070 | DEFUN (show_bgp_prefix_longer, |
| 8071 | show_bgp_prefix_longer_cmd, |
| 8072 | "show bgp X:X::X:X/M longer-prefixes", |
| 8073 | SHOW_STR |
| 8074 | BGP_STR |
| 8075 | "IPv6 prefix <network>/<length>\n" |
| 8076 | "Display route and more specific routes\n") |
| 8077 | { |
| 8078 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8079 | bgp_show_type_prefix_longer); |
| 8080 | } |
| 8081 | |
| 8082 | ALIAS (show_bgp_prefix_longer, |
| 8083 | show_bgp_ipv6_prefix_longer_cmd, |
| 8084 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 8085 | SHOW_STR |
| 8086 | BGP_STR |
| 8087 | "Address family\n" |
| 8088 | "IPv6 prefix <network>/<length>\n" |
| 8089 | "Display route and more specific routes\n") |
| 8090 | |
| 8091 | /* old command */ |
| 8092 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 8093 | show_ipv6_bgp_prefix_longer_cmd, |
| 8094 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 8095 | SHOW_STR |
| 8096 | IPV6_STR |
| 8097 | BGP_STR |
| 8098 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8099 | "Display route and more specific routes\n") |
| 8100 | { |
| 8101 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8102 | bgp_show_type_prefix_longer); |
| 8103 | } |
| 8104 | |
| 8105 | /* old command */ |
| 8106 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 8107 | show_ipv6_mbgp_prefix_longer_cmd, |
| 8108 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 8109 | SHOW_STR |
| 8110 | IPV6_STR |
| 8111 | MBGP_STR |
| 8112 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8113 | "Display route and more specific routes\n") |
| 8114 | { |
| 8115 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8116 | bgp_show_type_prefix_longer); |
| 8117 | } |
| 8118 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8119 | |
| 8120 | struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8121 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 8122 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8123 | { |
| 8124 | int ret; |
| 8125 | struct bgp *bgp; |
| 8126 | struct peer *peer; |
| 8127 | union sockunion su; |
| 8128 | |
| 8129 | /* BGP structure lookup. */ |
| 8130 | if (view_name) |
| 8131 | { |
| 8132 | bgp = bgp_lookup_by_name (view_name); |
| 8133 | if (! bgp) |
| 8134 | { |
| 8135 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8136 | return NULL; |
| 8137 | } |
| 8138 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 8139 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8140 | { |
| 8141 | bgp = bgp_get_default (); |
| 8142 | if (! bgp) |
| 8143 | { |
| 8144 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8145 | return NULL; |
| 8146 | } |
| 8147 | } |
| 8148 | |
| 8149 | /* Get peer sockunion. */ |
| 8150 | ret = str2sockunion (ip_str, &su); |
| 8151 | if (ret < 0) |
| 8152 | { |
| 8153 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 8154 | return NULL; |
| 8155 | } |
| 8156 | |
| 8157 | /* Peer structure lookup. */ |
| 8158 | peer = peer_lookup (bgp, &su); |
| 8159 | if (! peer) |
| 8160 | { |
| 8161 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 8162 | return NULL; |
| 8163 | } |
| 8164 | |
| 8165 | return peer; |
| 8166 | } |
| 8167 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8168 | void |
| 8169 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 8170 | int in) |
| 8171 | { |
| 8172 | struct bgp_table *table; |
| 8173 | struct bgp_adj_in *ain; |
| 8174 | struct bgp_adj_out *adj; |
| 8175 | unsigned long output_count; |
| 8176 | struct bgp_node *rn; |
| 8177 | int header1 = 1; |
| 8178 | struct bgp *bgp; |
| 8179 | int header2 = 1; |
| 8180 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8181 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8182 | |
| 8183 | if (! bgp) |
| 8184 | return; |
| 8185 | |
| 8186 | table = bgp->rib[afi][safi]; |
| 8187 | |
| 8188 | output_count = 0; |
| 8189 | |
| 8190 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 8191 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 8192 | { |
| 8193 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 8194 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8195 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8196 | |
| 8197 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 8198 | VTY_NEWLINE, VTY_NEWLINE); |
| 8199 | header1 = 0; |
| 8200 | } |
| 8201 | |
| 8202 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 8203 | if (in) |
| 8204 | { |
| 8205 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 8206 | if (ain->peer == peer) |
| 8207 | { |
| 8208 | if (header1) |
| 8209 | { |
| 8210 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 8211 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8212 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8213 | header1 = 0; |
| 8214 | } |
| 8215 | if (header2) |
| 8216 | { |
| 8217 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8218 | header2 = 0; |
| 8219 | } |
| 8220 | if (ain->attr) |
| 8221 | { |
| 8222 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 8223 | output_count++; |
| 8224 | } |
| 8225 | } |
| 8226 | } |
| 8227 | else |
| 8228 | { |
| 8229 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 8230 | if (adj->peer == peer) |
| 8231 | { |
| 8232 | if (header1) |
| 8233 | { |
| 8234 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 8235 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8236 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8237 | header1 = 0; |
| 8238 | } |
| 8239 | if (header2) |
| 8240 | { |
| 8241 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8242 | header2 = 0; |
| 8243 | } |
| 8244 | if (adj->attr) |
| 8245 | { |
| 8246 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 8247 | output_count++; |
| 8248 | } |
| 8249 | } |
| 8250 | } |
| 8251 | |
| 8252 | if (output_count != 0) |
| 8253 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 8254 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 8255 | } |
| 8256 | |
| 8257 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8258 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 8259 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8260 | if (! peer || ! peer->afc[afi][safi]) |
| 8261 | { |
| 8262 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 8263 | return CMD_WARNING; |
| 8264 | } |
| 8265 | |
| 8266 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 8267 | { |
| 8268 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 8269 | VTY_NEWLINE); |
| 8270 | return CMD_WARNING; |
| 8271 | } |
| 8272 | |
| 8273 | show_adj_route (vty, peer, afi, safi, in); |
| 8274 | |
| 8275 | return CMD_SUCCESS; |
| 8276 | } |
| 8277 | |
| 8278 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 8279 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 8280 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8281 | SHOW_STR |
| 8282 | IP_STR |
| 8283 | BGP_STR |
| 8284 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8285 | "Neighbor to display information about\n" |
| 8286 | "Neighbor to display information about\n" |
| 8287 | "Display the routes advertised to a BGP neighbor\n") |
| 8288 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8289 | struct peer *peer; |
| 8290 | |
| 8291 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8292 | if (! peer) |
| 8293 | return CMD_WARNING; |
| 8294 | |
| 8295 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8296 | } |
| 8297 | |
| 8298 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 8299 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 8300 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8301 | SHOW_STR |
| 8302 | IP_STR |
| 8303 | BGP_STR |
| 8304 | "Address family\n" |
| 8305 | "Address Family modifier\n" |
| 8306 | "Address Family modifier\n" |
| 8307 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8308 | "Neighbor to display information about\n" |
| 8309 | "Neighbor to display information about\n" |
| 8310 | "Display the routes advertised to a BGP neighbor\n") |
| 8311 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8312 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8313 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8314 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8315 | if (! peer) |
| 8316 | return CMD_WARNING; |
| 8317 | |
| 8318 | if (strncmp (argv[0], "m", 1) == 0) |
| 8319 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 8320 | |
| 8321 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8322 | } |
| 8323 | |
| 8324 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8325 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 8326 | show_bgp_view_neighbor_advertised_route_cmd, |
| 8327 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8328 | SHOW_STR |
| 8329 | BGP_STR |
| 8330 | "BGP view\n" |
| 8331 | "View name\n" |
| 8332 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8333 | "Neighbor to display information about\n" |
| 8334 | "Neighbor to display information about\n" |
| 8335 | "Display the routes advertised to a BGP neighbor\n") |
| 8336 | { |
| 8337 | struct peer *peer; |
| 8338 | |
| 8339 | if (argc == 2) |
| 8340 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8341 | else |
| 8342 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8343 | |
| 8344 | if (! peer) |
| 8345 | return CMD_WARNING; |
| 8346 | |
| 8347 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 8348 | } |
| 8349 | |
| 8350 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 8351 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 8352 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8353 | SHOW_STR |
| 8354 | BGP_STR |
| 8355 | "BGP view\n" |
| 8356 | "View name\n" |
| 8357 | "Address family\n" |
| 8358 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8359 | "Neighbor to display information about\n" |
| 8360 | "Neighbor to display information about\n" |
| 8361 | "Display the routes advertised to a BGP neighbor\n") |
| 8362 | |
| 8363 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 8364 | show_bgp_view_neighbor_received_routes_cmd, |
| 8365 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8366 | SHOW_STR |
| 8367 | BGP_STR |
| 8368 | "BGP view\n" |
| 8369 | "View name\n" |
| 8370 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8371 | "Neighbor to display information about\n" |
| 8372 | "Neighbor to display information about\n" |
| 8373 | "Display the received routes from neighbor\n") |
| 8374 | { |
| 8375 | struct peer *peer; |
| 8376 | |
| 8377 | if (argc == 2) |
| 8378 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8379 | else |
| 8380 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8381 | |
| 8382 | if (! peer) |
| 8383 | return CMD_WARNING; |
| 8384 | |
| 8385 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 8386 | } |
| 8387 | |
| 8388 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 8389 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 8390 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8391 | SHOW_STR |
| 8392 | BGP_STR |
| 8393 | "BGP view\n" |
| 8394 | "View name\n" |
| 8395 | "Address family\n" |
| 8396 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8397 | "Neighbor to display information about\n" |
| 8398 | "Neighbor to display information about\n" |
| 8399 | "Display the received routes from neighbor\n") |
| 8400 | |
| 8401 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8402 | show_bgp_neighbor_advertised_route_cmd, |
| 8403 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8404 | SHOW_STR |
| 8405 | BGP_STR |
| 8406 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8407 | "Neighbor to display information about\n" |
| 8408 | "Neighbor to display information about\n" |
| 8409 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8410 | |
| 8411 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8412 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 8413 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8414 | SHOW_STR |
| 8415 | BGP_STR |
| 8416 | "Address family\n" |
| 8417 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8418 | "Neighbor to display information about\n" |
| 8419 | "Neighbor to display information about\n" |
| 8420 | "Display the routes advertised to a BGP neighbor\n") |
| 8421 | |
| 8422 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8423 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8424 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 8425 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8426 | SHOW_STR |
| 8427 | IPV6_STR |
| 8428 | BGP_STR |
| 8429 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8430 | "Neighbor to display information about\n" |
| 8431 | "Neighbor to display information about\n" |
| 8432 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8433 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8434 | /* old command */ |
| 8435 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 8436 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 8437 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8438 | SHOW_STR |
| 8439 | IPV6_STR |
| 8440 | MBGP_STR |
| 8441 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8442 | "Neighbor to display information about\n" |
| 8443 | "Neighbor to display information about\n" |
| 8444 | "Display the routes advertised to a BGP neighbor\n") |
| 8445 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8446 | struct peer *peer; |
| 8447 | |
| 8448 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8449 | if (! peer) |
| 8450 | return CMD_WARNING; |
| 8451 | |
| 8452 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8453 | } |
| 8454 | #endif /* HAVE_IPV6 */ |
| 8455 | |
| 8456 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 8457 | show_ip_bgp_neighbor_received_routes_cmd, |
| 8458 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8459 | SHOW_STR |
| 8460 | IP_STR |
| 8461 | BGP_STR |
| 8462 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8463 | "Neighbor to display information about\n" |
| 8464 | "Neighbor to display information about\n" |
| 8465 | "Display the received routes from neighbor\n") |
| 8466 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8467 | struct peer *peer; |
| 8468 | |
| 8469 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8470 | if (! peer) |
| 8471 | return CMD_WARNING; |
| 8472 | |
| 8473 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8474 | } |
| 8475 | |
| 8476 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 8477 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 8478 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8479 | SHOW_STR |
| 8480 | IP_STR |
| 8481 | BGP_STR |
| 8482 | "Address family\n" |
| 8483 | "Address Family modifier\n" |
| 8484 | "Address Family modifier\n" |
| 8485 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8486 | "Neighbor to display information about\n" |
| 8487 | "Neighbor to display information about\n" |
| 8488 | "Display the received routes from neighbor\n") |
| 8489 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8490 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8491 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8492 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8493 | if (! peer) |
| 8494 | return CMD_WARNING; |
| 8495 | |
| 8496 | if (strncmp (argv[0], "m", 1) == 0) |
| 8497 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 8498 | |
| 8499 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8500 | } |
| 8501 | |
| 8502 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 8503 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 8504 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8505 | SHOW_STR |
| 8506 | IP_STR |
| 8507 | BGP_STR |
| 8508 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8509 | "Neighbor to display information about\n" |
| 8510 | "Neighbor to display information about\n" |
| 8511 | "Display information received from a BGP neighbor\n" |
| 8512 | "Display the prefixlist filter\n") |
| 8513 | { |
| 8514 | char name[BUFSIZ]; |
| 8515 | union sockunion *su; |
| 8516 | struct peer *peer; |
| 8517 | int count; |
| 8518 | |
| 8519 | su = sockunion_str2su (argv[0]); |
| 8520 | if (su == NULL) |
| 8521 | return CMD_WARNING; |
| 8522 | |
| 8523 | peer = peer_lookup (NULL, su); |
| 8524 | if (! peer) |
| 8525 | return CMD_WARNING; |
| 8526 | |
| 8527 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8528 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8529 | if (count) |
| 8530 | { |
| 8531 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8532 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8533 | } |
| 8534 | |
| 8535 | return CMD_SUCCESS; |
| 8536 | } |
| 8537 | |
| 8538 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 8539 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 8540 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8541 | SHOW_STR |
| 8542 | IP_STR |
| 8543 | BGP_STR |
| 8544 | "Address family\n" |
| 8545 | "Address Family modifier\n" |
| 8546 | "Address Family modifier\n" |
| 8547 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8548 | "Neighbor to display information about\n" |
| 8549 | "Neighbor to display information about\n" |
| 8550 | "Display information received from a BGP neighbor\n" |
| 8551 | "Display the prefixlist filter\n") |
| 8552 | { |
| 8553 | char name[BUFSIZ]; |
| 8554 | union sockunion *su; |
| 8555 | struct peer *peer; |
| 8556 | int count; |
| 8557 | |
| 8558 | su = sockunion_str2su (argv[1]); |
| 8559 | if (su == NULL) |
| 8560 | return CMD_WARNING; |
| 8561 | |
| 8562 | peer = peer_lookup (NULL, su); |
| 8563 | if (! peer) |
| 8564 | return CMD_WARNING; |
| 8565 | |
| 8566 | if (strncmp (argv[0], "m", 1) == 0) |
| 8567 | { |
| 8568 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 8569 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8570 | if (count) |
| 8571 | { |
| 8572 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 8573 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8574 | } |
| 8575 | } |
| 8576 | else |
| 8577 | { |
| 8578 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8579 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8580 | if (count) |
| 8581 | { |
| 8582 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8583 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8584 | } |
| 8585 | } |
| 8586 | |
| 8587 | return CMD_SUCCESS; |
| 8588 | } |
| 8589 | |
| 8590 | |
| 8591 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8592 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8593 | show_bgp_neighbor_received_routes_cmd, |
| 8594 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8595 | SHOW_STR |
| 8596 | BGP_STR |
| 8597 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8598 | "Neighbor to display information about\n" |
| 8599 | "Neighbor to display information about\n" |
| 8600 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8601 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8602 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8603 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 8604 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8605 | SHOW_STR |
| 8606 | BGP_STR |
| 8607 | "Address family\n" |
| 8608 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8609 | "Neighbor to display information about\n" |
| 8610 | "Neighbor to display information about\n" |
| 8611 | "Display the received routes from neighbor\n") |
| 8612 | |
| 8613 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 8614 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 8615 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8616 | SHOW_STR |
| 8617 | BGP_STR |
| 8618 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8619 | "Neighbor to display information about\n" |
| 8620 | "Neighbor to display information about\n" |
| 8621 | "Display information received from a BGP neighbor\n" |
| 8622 | "Display the prefixlist filter\n") |
| 8623 | { |
| 8624 | char name[BUFSIZ]; |
| 8625 | union sockunion *su; |
| 8626 | struct peer *peer; |
| 8627 | int count; |
| 8628 | |
| 8629 | su = sockunion_str2su (argv[0]); |
| 8630 | if (su == NULL) |
| 8631 | return CMD_WARNING; |
| 8632 | |
| 8633 | peer = peer_lookup (NULL, su); |
| 8634 | if (! peer) |
| 8635 | return CMD_WARNING; |
| 8636 | |
| 8637 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8638 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8639 | if (count) |
| 8640 | { |
| 8641 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8642 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8643 | } |
| 8644 | |
| 8645 | return CMD_SUCCESS; |
| 8646 | } |
| 8647 | |
| 8648 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 8649 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 8650 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8651 | SHOW_STR |
| 8652 | BGP_STR |
| 8653 | "Address family\n" |
| 8654 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8655 | "Neighbor to display information about\n" |
| 8656 | "Neighbor to display information about\n" |
| 8657 | "Display information received from a BGP neighbor\n" |
| 8658 | "Display the prefixlist filter\n") |
| 8659 | |
| 8660 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8661 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8662 | ipv6_bgp_neighbor_received_routes_cmd, |
| 8663 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8664 | SHOW_STR |
| 8665 | IPV6_STR |
| 8666 | BGP_STR |
| 8667 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8668 | "Neighbor to display information about\n" |
| 8669 | "Neighbor to display information about\n" |
| 8670 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8671 | |
| 8672 | /* old command */ |
| 8673 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 8674 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 8675 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8676 | SHOW_STR |
| 8677 | IPV6_STR |
| 8678 | MBGP_STR |
| 8679 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8680 | "Neighbor to display information about\n" |
| 8681 | "Neighbor to display information about\n" |
| 8682 | "Display the received routes from neighbor\n") |
| 8683 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8684 | struct peer *peer; |
| 8685 | |
| 8686 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8687 | if (! peer) |
| 8688 | return CMD_WARNING; |
| 8689 | |
| 8690 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8691 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8692 | |
| 8693 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 8694 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 8695 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8696 | SHOW_STR |
| 8697 | BGP_STR |
| 8698 | "BGP view\n" |
| 8699 | "View name\n" |
| 8700 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8701 | "Neighbor to display information about\n" |
| 8702 | "Neighbor to display information about\n" |
| 8703 | "Display information received from a BGP neighbor\n" |
| 8704 | "Display the prefixlist filter\n") |
| 8705 | { |
| 8706 | char name[BUFSIZ]; |
| 8707 | union sockunion *su; |
| 8708 | struct peer *peer; |
| 8709 | struct bgp *bgp; |
| 8710 | int count; |
| 8711 | |
| 8712 | /* BGP structure lookup. */ |
| 8713 | bgp = bgp_lookup_by_name (argv[0]); |
| 8714 | if (bgp == NULL) |
| 8715 | { |
| 8716 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8717 | return CMD_WARNING; |
| 8718 | } |
| 8719 | |
| 8720 | su = sockunion_str2su (argv[1]); |
| 8721 | if (su == NULL) |
| 8722 | return CMD_WARNING; |
| 8723 | |
| 8724 | peer = peer_lookup (bgp, su); |
| 8725 | if (! peer) |
| 8726 | return CMD_WARNING; |
| 8727 | |
| 8728 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8729 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8730 | if (count) |
| 8731 | { |
| 8732 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8733 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8734 | } |
| 8735 | |
| 8736 | return CMD_SUCCESS; |
| 8737 | } |
| 8738 | |
| 8739 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 8740 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 8741 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8742 | SHOW_STR |
| 8743 | BGP_STR |
| 8744 | "BGP view\n" |
| 8745 | "View name\n" |
| 8746 | "Address family\n" |
| 8747 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8748 | "Neighbor to display information about\n" |
| 8749 | "Neighbor to display information about\n" |
| 8750 | "Display information received from a BGP neighbor\n" |
| 8751 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8752 | #endif /* HAVE_IPV6 */ |
| 8753 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8754 | int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8755 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8756 | safi_t safi, enum bgp_show_type type) |
| 8757 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8758 | if (! peer || ! peer->afc[afi][safi]) |
| 8759 | { |
| 8760 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8761 | return CMD_WARNING; |
| 8762 | } |
| 8763 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8764 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8765 | } |
| 8766 | |
| 8767 | DEFUN (show_ip_bgp_neighbor_routes, |
| 8768 | show_ip_bgp_neighbor_routes_cmd, |
| 8769 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8770 | SHOW_STR |
| 8771 | IP_STR |
| 8772 | BGP_STR |
| 8773 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8774 | "Neighbor to display information about\n" |
| 8775 | "Neighbor to display information about\n" |
| 8776 | "Display routes learned from neighbor\n") |
| 8777 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8778 | struct peer *peer; |
| 8779 | |
| 8780 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8781 | if (! peer) |
| 8782 | return CMD_WARNING; |
| 8783 | |
| 8784 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8785 | bgp_show_type_neighbor); |
| 8786 | } |
| 8787 | |
| 8788 | DEFUN (show_ip_bgp_neighbor_flap, |
| 8789 | show_ip_bgp_neighbor_flap_cmd, |
| 8790 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8791 | SHOW_STR |
| 8792 | IP_STR |
| 8793 | BGP_STR |
| 8794 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8795 | "Neighbor to display information about\n" |
| 8796 | "Neighbor to display information about\n" |
| 8797 | "Display flap statistics of the routes learned from neighbor\n") |
| 8798 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8799 | struct peer *peer; |
| 8800 | |
| 8801 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8802 | if (! peer) |
| 8803 | return CMD_WARNING; |
| 8804 | |
| 8805 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8806 | bgp_show_type_flap_neighbor); |
| 8807 | } |
| 8808 | |
| 8809 | DEFUN (show_ip_bgp_neighbor_damp, |
| 8810 | show_ip_bgp_neighbor_damp_cmd, |
| 8811 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 8812 | SHOW_STR |
| 8813 | IP_STR |
| 8814 | BGP_STR |
| 8815 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8816 | "Neighbor to display information about\n" |
| 8817 | "Neighbor to display information about\n" |
| 8818 | "Display the dampened routes received from neighbor\n") |
| 8819 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8820 | struct peer *peer; |
| 8821 | |
| 8822 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8823 | if (! peer) |
| 8824 | return CMD_WARNING; |
| 8825 | |
| 8826 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8827 | bgp_show_type_damp_neighbor); |
| 8828 | } |
| 8829 | |
| 8830 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 8831 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 8832 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 8833 | SHOW_STR |
| 8834 | IP_STR |
| 8835 | BGP_STR |
| 8836 | "Address family\n" |
| 8837 | "Address Family modifier\n" |
| 8838 | "Address Family modifier\n" |
| 8839 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8840 | "Neighbor to display information about\n" |
| 8841 | "Neighbor to display information about\n" |
| 8842 | "Display routes learned from neighbor\n") |
| 8843 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8844 | struct peer *peer; |
| 8845 | |
| 8846 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8847 | if (! peer) |
| 8848 | return CMD_WARNING; |
| 8849 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8850 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8851 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8852 | bgp_show_type_neighbor); |
| 8853 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8854 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8855 | bgp_show_type_neighbor); |
| 8856 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8857 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 8858 | DEFUN (show_ip_bgp_view_rsclient, |
| 8859 | show_ip_bgp_view_rsclient_cmd, |
| 8860 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 8861 | SHOW_STR |
| 8862 | IP_STR |
| 8863 | BGP_STR |
| 8864 | "BGP view\n" |
| 8865 | "BGP view name\n" |
| 8866 | "Information about Route Server Client\n" |
| 8867 | NEIGHBOR_ADDR_STR) |
| 8868 | { |
| 8869 | struct bgp_table *table; |
| 8870 | struct peer *peer; |
| 8871 | |
| 8872 | if (argc == 2) |
| 8873 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8874 | else |
| 8875 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8876 | |
| 8877 | if (! peer) |
| 8878 | return CMD_WARNING; |
| 8879 | |
| 8880 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 8881 | { |
| 8882 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 8883 | VTY_NEWLINE); |
| 8884 | return CMD_WARNING; |
| 8885 | } |
| 8886 | |
| 8887 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 8888 | PEER_FLAG_RSERVER_CLIENT)) |
| 8889 | { |
| 8890 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 8891 | VTY_NEWLINE); |
| 8892 | return CMD_WARNING; |
| 8893 | } |
| 8894 | |
| 8895 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 8896 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8897 | 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] | 8898 | } |
| 8899 | |
| 8900 | ALIAS (show_ip_bgp_view_rsclient, |
| 8901 | show_ip_bgp_rsclient_cmd, |
| 8902 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 8903 | SHOW_STR |
| 8904 | IP_STR |
| 8905 | BGP_STR |
| 8906 | "Information about Route Server Client\n" |
| 8907 | NEIGHBOR_ADDR_STR) |
| 8908 | |
| 8909 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 8910 | show_ip_bgp_view_rsclient_route_cmd, |
| 8911 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 8912 | SHOW_STR |
| 8913 | IP_STR |
| 8914 | BGP_STR |
| 8915 | "BGP view\n" |
| 8916 | "BGP view name\n" |
| 8917 | "Information about Route Server Client\n" |
| 8918 | NEIGHBOR_ADDR_STR |
| 8919 | "Network in the BGP routing table to display\n") |
| 8920 | { |
| 8921 | struct bgp *bgp; |
| 8922 | struct peer *peer; |
| 8923 | |
| 8924 | /* BGP structure lookup. */ |
| 8925 | if (argc == 3) |
| 8926 | { |
| 8927 | bgp = bgp_lookup_by_name (argv[0]); |
| 8928 | if (bgp == NULL) |
| 8929 | { |
| 8930 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8931 | return CMD_WARNING; |
| 8932 | } |
| 8933 | } |
| 8934 | else |
| 8935 | { |
| 8936 | bgp = bgp_get_default (); |
| 8937 | if (bgp == NULL) |
| 8938 | { |
| 8939 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8940 | return CMD_WARNING; |
| 8941 | } |
| 8942 | } |
| 8943 | |
| 8944 | if (argc == 3) |
| 8945 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8946 | else |
| 8947 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8948 | |
| 8949 | if (! peer) |
| 8950 | return CMD_WARNING; |
| 8951 | |
| 8952 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 8953 | { |
| 8954 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 8955 | VTY_NEWLINE); |
| 8956 | return CMD_WARNING; |
| 8957 | } |
| 8958 | |
| 8959 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 8960 | PEER_FLAG_RSERVER_CLIENT)) |
| 8961 | { |
| 8962 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 8963 | VTY_NEWLINE); |
| 8964 | return CMD_WARNING; |
| 8965 | } |
| 8966 | |
| 8967 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 8968 | (argc == 3) ? argv[2] : argv[1], |
| 8969 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 8970 | } |
| 8971 | |
| 8972 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 8973 | show_ip_bgp_rsclient_route_cmd, |
| 8974 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 8975 | SHOW_STR |
| 8976 | IP_STR |
| 8977 | BGP_STR |
| 8978 | "Information about Route Server Client\n" |
| 8979 | NEIGHBOR_ADDR_STR |
| 8980 | "Network in the BGP routing table to display\n") |
| 8981 | |
| 8982 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 8983 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 8984 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 8985 | SHOW_STR |
| 8986 | IP_STR |
| 8987 | BGP_STR |
| 8988 | "BGP view\n" |
| 8989 | "BGP view name\n" |
| 8990 | "Information about Route Server Client\n" |
| 8991 | NEIGHBOR_ADDR_STR |
| 8992 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8993 | { |
| 8994 | struct bgp *bgp; |
| 8995 | struct peer *peer; |
| 8996 | |
| 8997 | /* BGP structure lookup. */ |
| 8998 | if (argc == 3) |
| 8999 | { |
| 9000 | bgp = bgp_lookup_by_name (argv[0]); |
| 9001 | if (bgp == NULL) |
| 9002 | { |
| 9003 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9004 | return CMD_WARNING; |
| 9005 | } |
| 9006 | } |
| 9007 | else |
| 9008 | { |
| 9009 | bgp = bgp_get_default (); |
| 9010 | if (bgp == NULL) |
| 9011 | { |
| 9012 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9013 | return CMD_WARNING; |
| 9014 | } |
| 9015 | } |
| 9016 | |
| 9017 | if (argc == 3) |
| 9018 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9019 | else |
| 9020 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9021 | |
| 9022 | if (! peer) |
| 9023 | return CMD_WARNING; |
| 9024 | |
| 9025 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9026 | { |
| 9027 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9028 | VTY_NEWLINE); |
| 9029 | return CMD_WARNING; |
| 9030 | } |
| 9031 | |
| 9032 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9033 | PEER_FLAG_RSERVER_CLIENT)) |
| 9034 | { |
| 9035 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9036 | VTY_NEWLINE); |
| 9037 | return CMD_WARNING; |
| 9038 | } |
| 9039 | |
| 9040 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 9041 | (argc == 3) ? argv[2] : argv[1], |
| 9042 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 9043 | } |
| 9044 | |
| 9045 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 9046 | show_ip_bgp_rsclient_prefix_cmd, |
| 9047 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 9048 | SHOW_STR |
| 9049 | IP_STR |
| 9050 | BGP_STR |
| 9051 | "Information about Route Server Client\n" |
| 9052 | NEIGHBOR_ADDR_STR |
| 9053 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9054 | |
| 9055 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9056 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9057 | DEFUN (show_bgp_view_neighbor_routes, |
| 9058 | show_bgp_view_neighbor_routes_cmd, |
| 9059 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 9060 | SHOW_STR |
| 9061 | BGP_STR |
| 9062 | "BGP view\n" |
| 9063 | "BGP view name\n" |
| 9064 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9065 | "Neighbor to display information about\n" |
| 9066 | "Neighbor to display information about\n" |
| 9067 | "Display routes learned from neighbor\n") |
| 9068 | { |
| 9069 | struct peer *peer; |
| 9070 | |
| 9071 | if (argc == 2) |
| 9072 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9073 | else |
| 9074 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9075 | |
| 9076 | if (! peer) |
| 9077 | return CMD_WARNING; |
| 9078 | |
| 9079 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9080 | bgp_show_type_neighbor); |
| 9081 | } |
| 9082 | |
| 9083 | ALIAS (show_bgp_view_neighbor_routes, |
| 9084 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 9085 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9086 | SHOW_STR |
| 9087 | BGP_STR |
| 9088 | "BGP view\n" |
| 9089 | "BGP view name\n" |
| 9090 | "Address family\n" |
| 9091 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9092 | "Neighbor to display information about\n" |
| 9093 | "Neighbor to display information about\n" |
| 9094 | "Display routes learned from neighbor\n") |
| 9095 | |
| 9096 | DEFUN (show_bgp_view_neighbor_damp, |
| 9097 | show_bgp_view_neighbor_damp_cmd, |
| 9098 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9099 | SHOW_STR |
| 9100 | BGP_STR |
| 9101 | "BGP view\n" |
| 9102 | "BGP view name\n" |
| 9103 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9104 | "Neighbor to display information about\n" |
| 9105 | "Neighbor to display information about\n" |
| 9106 | "Display the dampened routes received from neighbor\n") |
| 9107 | { |
| 9108 | struct peer *peer; |
| 9109 | |
| 9110 | if (argc == 2) |
| 9111 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9112 | else |
| 9113 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9114 | |
| 9115 | if (! peer) |
| 9116 | return CMD_WARNING; |
| 9117 | |
| 9118 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9119 | bgp_show_type_damp_neighbor); |
| 9120 | } |
| 9121 | |
| 9122 | ALIAS (show_bgp_view_neighbor_damp, |
| 9123 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 9124 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9125 | SHOW_STR |
| 9126 | BGP_STR |
| 9127 | "BGP view\n" |
| 9128 | "BGP view name\n" |
| 9129 | "Address family\n" |
| 9130 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9131 | "Neighbor to display information about\n" |
| 9132 | "Neighbor to display information about\n" |
| 9133 | "Display the dampened routes received from neighbor\n") |
| 9134 | |
| 9135 | DEFUN (show_bgp_view_neighbor_flap, |
| 9136 | show_bgp_view_neighbor_flap_cmd, |
| 9137 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9138 | SHOW_STR |
| 9139 | BGP_STR |
| 9140 | "BGP view\n" |
| 9141 | "BGP view name\n" |
| 9142 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9143 | "Neighbor to display information about\n" |
| 9144 | "Neighbor to display information about\n" |
| 9145 | "Display flap statistics of the routes learned from neighbor\n") |
| 9146 | { |
| 9147 | struct peer *peer; |
| 9148 | |
| 9149 | if (argc == 2) |
| 9150 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9151 | else |
| 9152 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9153 | |
| 9154 | if (! peer) |
| 9155 | return CMD_WARNING; |
| 9156 | |
| 9157 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9158 | bgp_show_type_flap_neighbor); |
| 9159 | } |
| 9160 | |
| 9161 | ALIAS (show_bgp_view_neighbor_flap, |
| 9162 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 9163 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9164 | SHOW_STR |
| 9165 | BGP_STR |
| 9166 | "BGP view\n" |
| 9167 | "BGP view name\n" |
| 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_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9175 | show_bgp_neighbor_routes_cmd, |
| 9176 | "show bgp neighbors (A.B.C.D|X:X::X:X) 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 routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9183 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9184 | |
| 9185 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9186 | show_bgp_ipv6_neighbor_routes_cmd, |
| 9187 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9188 | SHOW_STR |
| 9189 | BGP_STR |
| 9190 | "Address family\n" |
| 9191 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9192 | "Neighbor to display information about\n" |
| 9193 | "Neighbor to display information about\n" |
| 9194 | "Display routes learned from neighbor\n") |
| 9195 | |
| 9196 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9197 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9198 | ipv6_bgp_neighbor_routes_cmd, |
| 9199 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9200 | SHOW_STR |
| 9201 | IPV6_STR |
| 9202 | BGP_STR |
| 9203 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9204 | "Neighbor to display information about\n" |
| 9205 | "Neighbor to display information about\n" |
| 9206 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9207 | |
| 9208 | /* old command */ |
| 9209 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 9210 | ipv6_mbgp_neighbor_routes_cmd, |
| 9211 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9212 | SHOW_STR |
| 9213 | IPV6_STR |
| 9214 | MBGP_STR |
| 9215 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9216 | "Neighbor to display information about\n" |
| 9217 | "Neighbor to display information about\n" |
| 9218 | "Display routes learned from neighbor\n") |
| 9219 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9220 | struct peer *peer; |
| 9221 | |
| 9222 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9223 | if (! peer) |
| 9224 | return CMD_WARNING; |
| 9225 | |
| 9226 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9227 | bgp_show_type_neighbor); |
| 9228 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9229 | |
| 9230 | ALIAS (show_bgp_view_neighbor_flap, |
| 9231 | show_bgp_neighbor_flap_cmd, |
| 9232 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9233 | SHOW_STR |
| 9234 | BGP_STR |
| 9235 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9236 | "Neighbor to display information about\n" |
| 9237 | "Neighbor to display information about\n" |
| 9238 | "Display flap statistics of the routes learned from neighbor\n") |
| 9239 | |
| 9240 | ALIAS (show_bgp_view_neighbor_flap, |
| 9241 | show_bgp_ipv6_neighbor_flap_cmd, |
| 9242 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9243 | SHOW_STR |
| 9244 | BGP_STR |
| 9245 | "Address family\n" |
| 9246 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9247 | "Neighbor to display information about\n" |
| 9248 | "Neighbor to display information about\n" |
| 9249 | "Display flap statistics of the routes learned from neighbor\n") |
| 9250 | |
| 9251 | ALIAS (show_bgp_view_neighbor_damp, |
| 9252 | show_bgp_neighbor_damp_cmd, |
| 9253 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9254 | SHOW_STR |
| 9255 | BGP_STR |
| 9256 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9257 | "Neighbor to display information about\n" |
| 9258 | "Neighbor to display information about\n" |
| 9259 | "Display the dampened routes received from neighbor\n") |
| 9260 | |
| 9261 | ALIAS (show_bgp_view_neighbor_damp, |
| 9262 | show_bgp_ipv6_neighbor_damp_cmd, |
| 9263 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9264 | SHOW_STR |
| 9265 | BGP_STR |
| 9266 | "Address family\n" |
| 9267 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9268 | "Neighbor to display information about\n" |
| 9269 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 9270 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9271 | |
| 9272 | DEFUN (show_bgp_view_rsclient, |
| 9273 | show_bgp_view_rsclient_cmd, |
| 9274 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9275 | SHOW_STR |
| 9276 | BGP_STR |
| 9277 | "BGP view\n" |
| 9278 | "BGP view name\n" |
| 9279 | "Information about Route Server Client\n" |
| 9280 | NEIGHBOR_ADDR_STR) |
| 9281 | { |
| 9282 | struct bgp_table *table; |
| 9283 | struct peer *peer; |
| 9284 | |
| 9285 | if (argc == 2) |
| 9286 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9287 | else |
| 9288 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9289 | |
| 9290 | if (! peer) |
| 9291 | return CMD_WARNING; |
| 9292 | |
| 9293 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9294 | { |
| 9295 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9296 | VTY_NEWLINE); |
| 9297 | return CMD_WARNING; |
| 9298 | } |
| 9299 | |
| 9300 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9301 | PEER_FLAG_RSERVER_CLIENT)) |
| 9302 | { |
| 9303 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9304 | VTY_NEWLINE); |
| 9305 | return CMD_WARNING; |
| 9306 | } |
| 9307 | |
| 9308 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 9309 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9310 | 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] | 9311 | } |
| 9312 | |
| 9313 | ALIAS (show_bgp_view_rsclient, |
| 9314 | show_bgp_rsclient_cmd, |
| 9315 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9316 | SHOW_STR |
| 9317 | BGP_STR |
| 9318 | "Information about Route Server Client\n" |
| 9319 | NEIGHBOR_ADDR_STR) |
| 9320 | |
| 9321 | DEFUN (show_bgp_view_rsclient_route, |
| 9322 | show_bgp_view_rsclient_route_cmd, |
| 9323 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9324 | SHOW_STR |
| 9325 | BGP_STR |
| 9326 | "BGP view\n" |
| 9327 | "BGP view name\n" |
| 9328 | "Information about Route Server Client\n" |
| 9329 | NEIGHBOR_ADDR_STR |
| 9330 | "Network in the BGP routing table to display\n") |
| 9331 | { |
| 9332 | struct bgp *bgp; |
| 9333 | struct peer *peer; |
| 9334 | |
| 9335 | /* BGP structure lookup. */ |
| 9336 | if (argc == 3) |
| 9337 | { |
| 9338 | bgp = bgp_lookup_by_name (argv[0]); |
| 9339 | if (bgp == NULL) |
| 9340 | { |
| 9341 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9342 | return CMD_WARNING; |
| 9343 | } |
| 9344 | } |
| 9345 | else |
| 9346 | { |
| 9347 | bgp = bgp_get_default (); |
| 9348 | if (bgp == NULL) |
| 9349 | { |
| 9350 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9351 | return CMD_WARNING; |
| 9352 | } |
| 9353 | } |
| 9354 | |
| 9355 | if (argc == 3) |
| 9356 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9357 | else |
| 9358 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9359 | |
| 9360 | if (! peer) |
| 9361 | return CMD_WARNING; |
| 9362 | |
| 9363 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9364 | { |
| 9365 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9366 | VTY_NEWLINE); |
| 9367 | return CMD_WARNING; |
| 9368 | } |
| 9369 | |
| 9370 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9371 | PEER_FLAG_RSERVER_CLIENT)) |
| 9372 | { |
| 9373 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9374 | VTY_NEWLINE); |
| 9375 | return CMD_WARNING; |
| 9376 | } |
| 9377 | |
| 9378 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9379 | (argc == 3) ? argv[2] : argv[1], |
| 9380 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 9381 | } |
| 9382 | |
| 9383 | ALIAS (show_bgp_view_rsclient_route, |
| 9384 | show_bgp_rsclient_route_cmd, |
| 9385 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9386 | SHOW_STR |
| 9387 | BGP_STR |
| 9388 | "Information about Route Server Client\n" |
| 9389 | NEIGHBOR_ADDR_STR |
| 9390 | "Network in the BGP routing table to display\n") |
| 9391 | |
| 9392 | DEFUN (show_bgp_view_rsclient_prefix, |
| 9393 | show_bgp_view_rsclient_prefix_cmd, |
| 9394 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9395 | SHOW_STR |
| 9396 | BGP_STR |
| 9397 | "BGP view\n" |
| 9398 | "BGP view name\n" |
| 9399 | "Information about Route Server Client\n" |
| 9400 | NEIGHBOR_ADDR_STR |
| 9401 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9402 | { |
| 9403 | struct bgp *bgp; |
| 9404 | struct peer *peer; |
| 9405 | |
| 9406 | /* BGP structure lookup. */ |
| 9407 | if (argc == 3) |
| 9408 | { |
| 9409 | bgp = bgp_lookup_by_name (argv[0]); |
| 9410 | if (bgp == NULL) |
| 9411 | { |
| 9412 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9413 | return CMD_WARNING; |
| 9414 | } |
| 9415 | } |
| 9416 | else |
| 9417 | { |
| 9418 | bgp = bgp_get_default (); |
| 9419 | if (bgp == NULL) |
| 9420 | { |
| 9421 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9422 | return CMD_WARNING; |
| 9423 | } |
| 9424 | } |
| 9425 | |
| 9426 | if (argc == 3) |
| 9427 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9428 | else |
| 9429 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9430 | |
| 9431 | if (! peer) |
| 9432 | return CMD_WARNING; |
| 9433 | |
| 9434 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9435 | { |
| 9436 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9437 | VTY_NEWLINE); |
| 9438 | return CMD_WARNING; |
| 9439 | } |
| 9440 | |
| 9441 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9442 | PEER_FLAG_RSERVER_CLIENT)) |
| 9443 | { |
| 9444 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9445 | VTY_NEWLINE); |
| 9446 | return CMD_WARNING; |
| 9447 | } |
| 9448 | |
| 9449 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9450 | (argc == 3) ? argv[2] : argv[1], |
| 9451 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 9452 | } |
| 9453 | |
| 9454 | ALIAS (show_bgp_view_rsclient_prefix, |
| 9455 | show_bgp_rsclient_prefix_cmd, |
| 9456 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9457 | SHOW_STR |
| 9458 | BGP_STR |
| 9459 | "Information about Route Server Client\n" |
| 9460 | NEIGHBOR_ADDR_STR |
| 9461 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9462 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9463 | #endif /* HAVE_IPV6 */ |
| 9464 | |
| 9465 | struct bgp_table *bgp_distance_table; |
| 9466 | |
| 9467 | struct bgp_distance |
| 9468 | { |
| 9469 | /* Distance value for the IP source prefix. */ |
| 9470 | u_char distance; |
| 9471 | |
| 9472 | /* Name of the access-list to be matched. */ |
| 9473 | char *access_list; |
| 9474 | }; |
| 9475 | |
| 9476 | struct bgp_distance * |
| 9477 | bgp_distance_new () |
| 9478 | { |
| 9479 | struct bgp_distance *new; |
| 9480 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 9481 | memset (new, 0, sizeof (struct bgp_distance)); |
| 9482 | return new; |
| 9483 | } |
| 9484 | |
| 9485 | void |
| 9486 | bgp_distance_free (struct bgp_distance *bdistance) |
| 9487 | { |
| 9488 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 9489 | } |
| 9490 | |
| 9491 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9492 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 9493 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9494 | { |
| 9495 | int ret; |
| 9496 | struct prefix_ipv4 p; |
| 9497 | u_char distance; |
| 9498 | struct bgp_node *rn; |
| 9499 | struct bgp_distance *bdistance; |
| 9500 | |
| 9501 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9502 | if (ret == 0) |
| 9503 | { |
| 9504 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9505 | return CMD_WARNING; |
| 9506 | } |
| 9507 | |
| 9508 | distance = atoi (distance_str); |
| 9509 | |
| 9510 | /* Get BGP distance node. */ |
| 9511 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 9512 | if (rn->info) |
| 9513 | { |
| 9514 | bdistance = rn->info; |
| 9515 | bgp_unlock_node (rn); |
| 9516 | } |
| 9517 | else |
| 9518 | { |
| 9519 | bdistance = bgp_distance_new (); |
| 9520 | rn->info = bdistance; |
| 9521 | } |
| 9522 | |
| 9523 | /* Set distance value. */ |
| 9524 | bdistance->distance = distance; |
| 9525 | |
| 9526 | /* Reset access-list configuration. */ |
| 9527 | if (bdistance->access_list) |
| 9528 | { |
| 9529 | free (bdistance->access_list); |
| 9530 | bdistance->access_list = NULL; |
| 9531 | } |
| 9532 | if (access_list_str) |
| 9533 | bdistance->access_list = strdup (access_list_str); |
| 9534 | |
| 9535 | return CMD_SUCCESS; |
| 9536 | } |
| 9537 | |
| 9538 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9539 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 9540 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9541 | { |
| 9542 | int ret; |
| 9543 | struct prefix_ipv4 p; |
| 9544 | u_char distance; |
| 9545 | struct bgp_node *rn; |
| 9546 | struct bgp_distance *bdistance; |
| 9547 | |
| 9548 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9549 | if (ret == 0) |
| 9550 | { |
| 9551 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9552 | return CMD_WARNING; |
| 9553 | } |
| 9554 | |
| 9555 | distance = atoi (distance_str); |
| 9556 | |
| 9557 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 9558 | if (! rn) |
| 9559 | { |
| 9560 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 9561 | return CMD_WARNING; |
| 9562 | } |
| 9563 | |
| 9564 | bdistance = rn->info; |
| 9565 | |
| 9566 | if (bdistance->access_list) |
| 9567 | free (bdistance->access_list); |
| 9568 | bgp_distance_free (bdistance); |
| 9569 | |
| 9570 | rn->info = NULL; |
| 9571 | bgp_unlock_node (rn); |
| 9572 | bgp_unlock_node (rn); |
| 9573 | |
| 9574 | return CMD_SUCCESS; |
| 9575 | } |
| 9576 | |
| 9577 | void |
| 9578 | bgp_distance_reset () |
| 9579 | { |
| 9580 | struct bgp_node *rn; |
| 9581 | struct bgp_distance *bdistance; |
| 9582 | |
| 9583 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 9584 | if ((bdistance = rn->info) != NULL) |
| 9585 | { |
| 9586 | if (bdistance->access_list) |
| 9587 | free (bdistance->access_list); |
| 9588 | bgp_distance_free (bdistance); |
| 9589 | rn->info = NULL; |
| 9590 | bgp_unlock_node (rn); |
| 9591 | } |
| 9592 | } |
| 9593 | |
| 9594 | /* Apply BGP information to distance method. */ |
| 9595 | u_char |
| 9596 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 9597 | { |
| 9598 | struct bgp_node *rn; |
| 9599 | struct prefix_ipv4 q; |
| 9600 | struct peer *peer; |
| 9601 | struct bgp_distance *bdistance; |
| 9602 | struct access_list *alist; |
| 9603 | struct bgp_static *bgp_static; |
| 9604 | |
| 9605 | if (! bgp) |
| 9606 | return 0; |
| 9607 | |
| 9608 | if (p->family != AF_INET) |
| 9609 | return 0; |
| 9610 | |
| 9611 | peer = rinfo->peer; |
| 9612 | |
| 9613 | if (peer->su.sa.sa_family != AF_INET) |
| 9614 | return 0; |
| 9615 | |
| 9616 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 9617 | q.family = AF_INET; |
| 9618 | q.prefix = peer->su.sin.sin_addr; |
| 9619 | q.prefixlen = IPV4_MAX_BITLEN; |
| 9620 | |
| 9621 | /* Check source address. */ |
| 9622 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 9623 | if (rn) |
| 9624 | { |
| 9625 | bdistance = rn->info; |
| 9626 | bgp_unlock_node (rn); |
| 9627 | |
| 9628 | if (bdistance->access_list) |
| 9629 | { |
| 9630 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 9631 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 9632 | return bdistance->distance; |
| 9633 | } |
| 9634 | else |
| 9635 | return bdistance->distance; |
| 9636 | } |
| 9637 | |
| 9638 | /* Backdoor check. */ |
| 9639 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 9640 | if (rn) |
| 9641 | { |
| 9642 | bgp_static = rn->info; |
| 9643 | bgp_unlock_node (rn); |
| 9644 | |
| 9645 | if (bgp_static->backdoor) |
| 9646 | { |
| 9647 | if (bgp->distance_local) |
| 9648 | return bgp->distance_local; |
| 9649 | else |
| 9650 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9651 | } |
| 9652 | } |
| 9653 | |
| 9654 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 9655 | { |
| 9656 | if (bgp->distance_ebgp) |
| 9657 | return bgp->distance_ebgp; |
| 9658 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 9659 | } |
| 9660 | else |
| 9661 | { |
| 9662 | if (bgp->distance_ibgp) |
| 9663 | return bgp->distance_ibgp; |
| 9664 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9665 | } |
| 9666 | } |
| 9667 | |
| 9668 | DEFUN (bgp_distance, |
| 9669 | bgp_distance_cmd, |
| 9670 | "distance bgp <1-255> <1-255> <1-255>", |
| 9671 | "Define an administrative distance\n" |
| 9672 | "BGP distance\n" |
| 9673 | "Distance for routes external to the AS\n" |
| 9674 | "Distance for routes internal to the AS\n" |
| 9675 | "Distance for local routes\n") |
| 9676 | { |
| 9677 | struct bgp *bgp; |
| 9678 | |
| 9679 | bgp = vty->index; |
| 9680 | |
| 9681 | bgp->distance_ebgp = atoi (argv[0]); |
| 9682 | bgp->distance_ibgp = atoi (argv[1]); |
| 9683 | bgp->distance_local = atoi (argv[2]); |
| 9684 | return CMD_SUCCESS; |
| 9685 | } |
| 9686 | |
| 9687 | DEFUN (no_bgp_distance, |
| 9688 | no_bgp_distance_cmd, |
| 9689 | "no distance bgp <1-255> <1-255> <1-255>", |
| 9690 | NO_STR |
| 9691 | "Define an administrative distance\n" |
| 9692 | "BGP distance\n" |
| 9693 | "Distance for routes external to the AS\n" |
| 9694 | "Distance for routes internal to the AS\n" |
| 9695 | "Distance for local routes\n") |
| 9696 | { |
| 9697 | struct bgp *bgp; |
| 9698 | |
| 9699 | bgp = vty->index; |
| 9700 | |
| 9701 | bgp->distance_ebgp= 0; |
| 9702 | bgp->distance_ibgp = 0; |
| 9703 | bgp->distance_local = 0; |
| 9704 | return CMD_SUCCESS; |
| 9705 | } |
| 9706 | |
| 9707 | ALIAS (no_bgp_distance, |
| 9708 | no_bgp_distance2_cmd, |
| 9709 | "no distance bgp", |
| 9710 | NO_STR |
| 9711 | "Define an administrative distance\n" |
| 9712 | "BGP distance\n") |
| 9713 | |
| 9714 | DEFUN (bgp_distance_source, |
| 9715 | bgp_distance_source_cmd, |
| 9716 | "distance <1-255> A.B.C.D/M", |
| 9717 | "Define an administrative distance\n" |
| 9718 | "Administrative distance\n" |
| 9719 | "IP source prefix\n") |
| 9720 | { |
| 9721 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 9722 | return CMD_SUCCESS; |
| 9723 | } |
| 9724 | |
| 9725 | DEFUN (no_bgp_distance_source, |
| 9726 | no_bgp_distance_source_cmd, |
| 9727 | "no distance <1-255> A.B.C.D/M", |
| 9728 | NO_STR |
| 9729 | "Define an administrative distance\n" |
| 9730 | "Administrative distance\n" |
| 9731 | "IP source prefix\n") |
| 9732 | { |
| 9733 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 9734 | return CMD_SUCCESS; |
| 9735 | } |
| 9736 | |
| 9737 | DEFUN (bgp_distance_source_access_list, |
| 9738 | bgp_distance_source_access_list_cmd, |
| 9739 | "distance <1-255> A.B.C.D/M WORD", |
| 9740 | "Define an administrative distance\n" |
| 9741 | "Administrative distance\n" |
| 9742 | "IP source prefix\n" |
| 9743 | "Access list name\n") |
| 9744 | { |
| 9745 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 9746 | return CMD_SUCCESS; |
| 9747 | } |
| 9748 | |
| 9749 | DEFUN (no_bgp_distance_source_access_list, |
| 9750 | no_bgp_distance_source_access_list_cmd, |
| 9751 | "no distance <1-255> A.B.C.D/M WORD", |
| 9752 | NO_STR |
| 9753 | "Define an administrative distance\n" |
| 9754 | "Administrative distance\n" |
| 9755 | "IP source prefix\n" |
| 9756 | "Access list name\n") |
| 9757 | { |
| 9758 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 9759 | return CMD_SUCCESS; |
| 9760 | } |
| 9761 | |
| 9762 | DEFUN (bgp_damp_set, |
| 9763 | bgp_damp_set_cmd, |
| 9764 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 9765 | "BGP Specific commands\n" |
| 9766 | "Enable route-flap dampening\n" |
| 9767 | "Half-life time for the penalty\n" |
| 9768 | "Value to start reusing a route\n" |
| 9769 | "Value to start suppressing a route\n" |
| 9770 | "Maximum duration to suppress a stable route\n") |
| 9771 | { |
| 9772 | struct bgp *bgp; |
| 9773 | int half = DEFAULT_HALF_LIFE * 60; |
| 9774 | int reuse = DEFAULT_REUSE; |
| 9775 | int suppress = DEFAULT_SUPPRESS; |
| 9776 | int max = 4 * half; |
| 9777 | |
| 9778 | if (argc == 4) |
| 9779 | { |
| 9780 | half = atoi (argv[0]) * 60; |
| 9781 | reuse = atoi (argv[1]); |
| 9782 | suppress = atoi (argv[2]); |
| 9783 | max = atoi (argv[3]) * 60; |
| 9784 | } |
| 9785 | else if (argc == 1) |
| 9786 | { |
| 9787 | half = atoi (argv[0]) * 60; |
| 9788 | max = 4 * half; |
| 9789 | } |
| 9790 | |
| 9791 | bgp = vty->index; |
| 9792 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 9793 | half, reuse, suppress, max); |
| 9794 | } |
| 9795 | |
| 9796 | ALIAS (bgp_damp_set, |
| 9797 | bgp_damp_set2_cmd, |
| 9798 | "bgp dampening <1-45>", |
| 9799 | "BGP Specific commands\n" |
| 9800 | "Enable route-flap dampening\n" |
| 9801 | "Half-life time for the penalty\n") |
| 9802 | |
| 9803 | ALIAS (bgp_damp_set, |
| 9804 | bgp_damp_set3_cmd, |
| 9805 | "bgp dampening", |
| 9806 | "BGP Specific commands\n" |
| 9807 | "Enable route-flap dampening\n") |
| 9808 | |
| 9809 | DEFUN (bgp_damp_unset, |
| 9810 | bgp_damp_unset_cmd, |
| 9811 | "no bgp dampening", |
| 9812 | NO_STR |
| 9813 | "BGP Specific commands\n" |
| 9814 | "Enable route-flap dampening\n") |
| 9815 | { |
| 9816 | struct bgp *bgp; |
| 9817 | |
| 9818 | bgp = vty->index; |
| 9819 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 9820 | } |
| 9821 | |
| 9822 | ALIAS (bgp_damp_unset, |
| 9823 | bgp_damp_unset2_cmd, |
| 9824 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 9825 | NO_STR |
| 9826 | "BGP Specific commands\n" |
| 9827 | "Enable route-flap dampening\n" |
| 9828 | "Half-life time for the penalty\n" |
| 9829 | "Value to start reusing a route\n" |
| 9830 | "Value to start suppressing a route\n" |
| 9831 | "Maximum duration to suppress a stable route\n") |
| 9832 | |
| 9833 | DEFUN (show_ip_bgp_dampened_paths, |
| 9834 | show_ip_bgp_dampened_paths_cmd, |
| 9835 | "show ip bgp dampened-paths", |
| 9836 | SHOW_STR |
| 9837 | IP_STR |
| 9838 | BGP_STR |
| 9839 | "Display paths suppressed due to dampening\n") |
| 9840 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9841 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 9842 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9843 | } |
| 9844 | |
| 9845 | DEFUN (show_ip_bgp_flap_statistics, |
| 9846 | show_ip_bgp_flap_statistics_cmd, |
| 9847 | "show ip bgp flap-statistics", |
| 9848 | SHOW_STR |
| 9849 | IP_STR |
| 9850 | BGP_STR |
| 9851 | "Display flap statistics of routes\n") |
| 9852 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9853 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9854 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9855 | } |
| 9856 | |
| 9857 | /* Display specified route of BGP table. */ |
| 9858 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9859 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 9860 | const char *ip_str, afi_t afi, safi_t safi, |
| 9861 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9862 | { |
| 9863 | int ret; |
| 9864 | struct prefix match; |
| 9865 | struct bgp_node *rn; |
| 9866 | struct bgp_node *rm; |
| 9867 | struct bgp_info *ri; |
| 9868 | struct bgp_info *ri_temp; |
| 9869 | struct bgp *bgp; |
| 9870 | struct bgp_table *table; |
| 9871 | |
| 9872 | /* BGP structure lookup. */ |
| 9873 | if (view_name) |
| 9874 | { |
| 9875 | bgp = bgp_lookup_by_name (view_name); |
| 9876 | if (bgp == NULL) |
| 9877 | { |
| 9878 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9879 | return CMD_WARNING; |
| 9880 | } |
| 9881 | } |
| 9882 | else |
| 9883 | { |
| 9884 | bgp = bgp_get_default (); |
| 9885 | if (bgp == NULL) |
| 9886 | { |
| 9887 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 9888 | return CMD_WARNING; |
| 9889 | } |
| 9890 | } |
| 9891 | |
| 9892 | /* Check IP address argument. */ |
| 9893 | ret = str2prefix (ip_str, &match); |
| 9894 | if (! ret) |
| 9895 | { |
| 9896 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 9897 | return CMD_WARNING; |
| 9898 | } |
| 9899 | |
| 9900 | match.family = afi2family (afi); |
| 9901 | |
| 9902 | if (safi == SAFI_MPLS_VPN) |
| 9903 | { |
| 9904 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 9905 | { |
| 9906 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 9907 | continue; |
| 9908 | |
| 9909 | if ((table = rn->info) != NULL) |
| 9910 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 9911 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 9912 | { |
| 9913 | ri = rm->info; |
| 9914 | while (ri) |
| 9915 | { |
| 9916 | if (ri->damp_info) |
| 9917 | { |
| 9918 | ri_temp = ri->next; |
| 9919 | bgp_damp_info_free (ri->damp_info, 1); |
| 9920 | ri = ri_temp; |
| 9921 | } |
| 9922 | else |
| 9923 | ri = ri->next; |
| 9924 | } |
| 9925 | } |
| 9926 | } |
| 9927 | } |
| 9928 | else |
| 9929 | { |
| 9930 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 9931 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 9932 | { |
| 9933 | ri = rn->info; |
| 9934 | while (ri) |
| 9935 | { |
| 9936 | if (ri->damp_info) |
| 9937 | { |
| 9938 | ri_temp = ri->next; |
| 9939 | bgp_damp_info_free (ri->damp_info, 1); |
| 9940 | ri = ri_temp; |
| 9941 | } |
| 9942 | else |
| 9943 | ri = ri->next; |
| 9944 | } |
| 9945 | } |
| 9946 | } |
| 9947 | |
| 9948 | return CMD_SUCCESS; |
| 9949 | } |
| 9950 | |
| 9951 | DEFUN (clear_ip_bgp_dampening, |
| 9952 | clear_ip_bgp_dampening_cmd, |
| 9953 | "clear ip bgp dampening", |
| 9954 | CLEAR_STR |
| 9955 | IP_STR |
| 9956 | BGP_STR |
| 9957 | "Clear route flap dampening information\n") |
| 9958 | { |
| 9959 | bgp_damp_info_clean (); |
| 9960 | return CMD_SUCCESS; |
| 9961 | } |
| 9962 | |
| 9963 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 9964 | clear_ip_bgp_dampening_prefix_cmd, |
| 9965 | "clear ip bgp dampening A.B.C.D/M", |
| 9966 | CLEAR_STR |
| 9967 | IP_STR |
| 9968 | BGP_STR |
| 9969 | "Clear route flap dampening information\n" |
| 9970 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9971 | { |
| 9972 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 9973 | SAFI_UNICAST, NULL, 1); |
| 9974 | } |
| 9975 | |
| 9976 | DEFUN (clear_ip_bgp_dampening_address, |
| 9977 | clear_ip_bgp_dampening_address_cmd, |
| 9978 | "clear ip bgp dampening A.B.C.D", |
| 9979 | CLEAR_STR |
| 9980 | IP_STR |
| 9981 | BGP_STR |
| 9982 | "Clear route flap dampening information\n" |
| 9983 | "Network to clear damping information\n") |
| 9984 | { |
| 9985 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 9986 | SAFI_UNICAST, NULL, 0); |
| 9987 | } |
| 9988 | |
| 9989 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 9990 | clear_ip_bgp_dampening_address_mask_cmd, |
| 9991 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 9992 | CLEAR_STR |
| 9993 | IP_STR |
| 9994 | BGP_STR |
| 9995 | "Clear route flap dampening information\n" |
| 9996 | "Network to clear damping information\n" |
| 9997 | "Network mask\n") |
| 9998 | { |
| 9999 | int ret; |
| 10000 | char prefix_str[BUFSIZ]; |
| 10001 | |
| 10002 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 10003 | if (! ret) |
| 10004 | { |
| 10005 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 10006 | return CMD_WARNING; |
| 10007 | } |
| 10008 | |
| 10009 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 10010 | SAFI_UNICAST, NULL, 0); |
| 10011 | } |
| 10012 | |
| 10013 | int |
| 10014 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 10015 | afi_t afi, safi_t safi, int *write) |
| 10016 | { |
| 10017 | struct bgp_node *prn; |
| 10018 | struct bgp_node *rn; |
| 10019 | struct bgp_table *table; |
| 10020 | struct prefix *p; |
| 10021 | struct prefix_rd *prd; |
| 10022 | struct bgp_static *bgp_static; |
| 10023 | u_int32_t label; |
| 10024 | char buf[SU_ADDRSTRLEN]; |
| 10025 | char rdbuf[RD_ADDRSTRLEN]; |
| 10026 | |
| 10027 | /* Network configuration. */ |
| 10028 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 10029 | if ((table = prn->info) != NULL) |
| 10030 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 10031 | if ((bgp_static = rn->info) != NULL) |
| 10032 | { |
| 10033 | p = &rn->p; |
| 10034 | prd = (struct prefix_rd *) &prn->p; |
| 10035 | |
| 10036 | /* "address-family" display. */ |
| 10037 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10038 | |
| 10039 | /* "network" configuration display. */ |
| 10040 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 10041 | label = decode_label (bgp_static->tag); |
| 10042 | |
| 10043 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 10044 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10045 | p->prefixlen, |
| 10046 | rdbuf, label); |
| 10047 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10048 | } |
| 10049 | return 0; |
| 10050 | } |
| 10051 | |
| 10052 | /* Configuration of static route announcement and aggregate |
| 10053 | information. */ |
| 10054 | int |
| 10055 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 10056 | afi_t afi, safi_t safi, int *write) |
| 10057 | { |
| 10058 | struct bgp_node *rn; |
| 10059 | struct prefix *p; |
| 10060 | struct bgp_static *bgp_static; |
| 10061 | struct bgp_aggregate *bgp_aggregate; |
| 10062 | char buf[SU_ADDRSTRLEN]; |
| 10063 | |
| 10064 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 10065 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 10066 | |
| 10067 | /* Network configuration. */ |
| 10068 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10069 | if ((bgp_static = rn->info) != NULL) |
| 10070 | { |
| 10071 | p = &rn->p; |
| 10072 | |
| 10073 | /* "address-family" display. */ |
| 10074 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10075 | |
| 10076 | /* "network" configuration display. */ |
| 10077 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10078 | { |
| 10079 | u_int32_t destination; |
| 10080 | struct in_addr netmask; |
| 10081 | |
| 10082 | destination = ntohl (p->u.prefix4.s_addr); |
| 10083 | masklen2ip (p->prefixlen, &netmask); |
| 10084 | vty_out (vty, " network %s", |
| 10085 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 10086 | |
| 10087 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 10088 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 10089 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 10090 | || p->u.prefix4.s_addr == 0) |
| 10091 | { |
| 10092 | /* Natural mask is not display. */ |
| 10093 | } |
| 10094 | else |
| 10095 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 10096 | } |
| 10097 | else |
| 10098 | { |
| 10099 | vty_out (vty, " network %s/%d", |
| 10100 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10101 | p->prefixlen); |
| 10102 | } |
| 10103 | |
| 10104 | if (bgp_static->rmap.name) |
| 10105 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 10106 | else if (bgp_static->backdoor) |
| 10107 | vty_out (vty, " backdoor"); |
| 10108 | |
| 10109 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10110 | } |
| 10111 | |
| 10112 | /* Aggregate-address configuration. */ |
| 10113 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10114 | if ((bgp_aggregate = rn->info) != NULL) |
| 10115 | { |
| 10116 | p = &rn->p; |
| 10117 | |
| 10118 | /* "address-family" display. */ |
| 10119 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10120 | |
| 10121 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10122 | { |
| 10123 | struct in_addr netmask; |
| 10124 | |
| 10125 | masklen2ip (p->prefixlen, &netmask); |
| 10126 | vty_out (vty, " aggregate-address %s %s", |
| 10127 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10128 | inet_ntoa (netmask)); |
| 10129 | } |
| 10130 | else |
| 10131 | { |
| 10132 | vty_out (vty, " aggregate-address %s/%d", |
| 10133 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10134 | p->prefixlen); |
| 10135 | } |
| 10136 | |
| 10137 | if (bgp_aggregate->as_set) |
| 10138 | vty_out (vty, " as-set"); |
| 10139 | |
| 10140 | if (bgp_aggregate->summary_only) |
| 10141 | vty_out (vty, " summary-only"); |
| 10142 | |
| 10143 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10144 | } |
| 10145 | |
| 10146 | return 0; |
| 10147 | } |
| 10148 | |
| 10149 | int |
| 10150 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 10151 | { |
| 10152 | struct bgp_node *rn; |
| 10153 | struct bgp_distance *bdistance; |
| 10154 | |
| 10155 | /* Distance configuration. */ |
| 10156 | if (bgp->distance_ebgp |
| 10157 | && bgp->distance_ibgp |
| 10158 | && bgp->distance_local |
| 10159 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 10160 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 10161 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 10162 | vty_out (vty, " distance bgp %d %d %d%s", |
| 10163 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 10164 | VTY_NEWLINE); |
| 10165 | |
| 10166 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 10167 | if ((bdistance = rn->info) != NULL) |
| 10168 | { |
| 10169 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 10170 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 10171 | bdistance->access_list ? bdistance->access_list : "", |
| 10172 | VTY_NEWLINE); |
| 10173 | } |
| 10174 | |
| 10175 | return 0; |
| 10176 | } |
| 10177 | |
| 10178 | /* Allocate routing table structure and install commands. */ |
| 10179 | void |
| 10180 | bgp_route_init () |
| 10181 | { |
| 10182 | /* Init BGP distance table. */ |
| 10183 | bgp_distance_table = bgp_table_init (); |
| 10184 | |
| 10185 | /* IPv4 BGP commands. */ |
| 10186 | install_element (BGP_NODE, &bgp_network_cmd); |
| 10187 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 10188 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 10189 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 10190 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 10191 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10192 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 10193 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 10194 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 10195 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 10196 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 10197 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 10198 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 10199 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10200 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10201 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 10202 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 10203 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 10204 | |
| 10205 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 10206 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 10207 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 10208 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10209 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 10210 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 10211 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 10212 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10213 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 10214 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10215 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 10216 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 10217 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 10218 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10219 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10220 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 10221 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10222 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10223 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10224 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10225 | |
| 10226 | /* IPv4 unicast configuration. */ |
| 10227 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 10228 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 10229 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 10230 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 10231 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 10232 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10233 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 10234 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 10235 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 10236 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 10237 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10238 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10239 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 10240 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 10241 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 10242 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10243 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 10244 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 10245 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 10246 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10247 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 10248 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10249 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 10250 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 10251 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 10252 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10253 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10254 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 10255 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10256 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10257 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10258 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10259 | |
| 10260 | /* IPv4 multicast configuration. */ |
| 10261 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 10262 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 10263 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 10264 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 10265 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 10266 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10267 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 10268 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 10269 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 10270 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 10271 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10272 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10273 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 10274 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 10275 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 10276 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10277 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 10278 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 10279 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 10280 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10281 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 10282 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10283 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 10284 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 10285 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 10286 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10287 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10288 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 10289 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10290 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10291 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10292 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10293 | |
| 10294 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 10295 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 10296 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 10297 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10298 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10299 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10300 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 10301 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10302 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10303 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10304 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 10305 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 10306 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10307 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 10308 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10309 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10310 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10311 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 10312 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10313 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 10314 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10315 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10316 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10317 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 10318 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10319 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 10320 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 10321 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 10322 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 10323 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10324 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10325 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10326 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10327 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 10328 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10329 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10330 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10331 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10332 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10333 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10334 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10335 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 10336 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10337 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10338 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10339 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10340 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10341 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10342 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10343 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10344 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10345 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10346 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10347 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10348 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10349 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10350 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10351 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 10352 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10353 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10354 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10355 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10356 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10357 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10358 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10359 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10360 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10361 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 10362 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10363 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10364 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10365 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10366 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10367 | |
| 10368 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 10369 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 10370 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 10371 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10372 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10373 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10374 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 10375 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10376 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10377 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10378 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 10379 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 10380 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10381 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 10382 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10383 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10384 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10385 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 10386 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10387 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 10388 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10389 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10390 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10391 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 10392 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10393 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 10394 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 10395 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 10396 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 10397 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10398 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10399 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10400 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10401 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 10402 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10403 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10404 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10405 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10406 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10407 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10408 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10409 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 10410 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10411 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10412 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10413 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10414 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10415 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10416 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10417 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10418 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10419 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10420 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10421 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10422 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10423 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10424 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10425 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 10426 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10427 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10428 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10429 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10430 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10431 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10432 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10433 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10434 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10435 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 10436 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10437 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10438 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10439 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10440 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10441 | |
| 10442 | /* BGP dampening clear commands */ |
| 10443 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 10444 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 10445 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 10446 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 10447 | |
| 10448 | #ifdef HAVE_IPV6 |
| 10449 | /* New config IPv6 BGP commands. */ |
| 10450 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 10451 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 10452 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 10453 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 10454 | |
| 10455 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 10456 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 10457 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 10458 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 10459 | |
| 10460 | /* Old config IPv6 BGP commands. */ |
| 10461 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 10462 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 10463 | |
| 10464 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 10465 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 10466 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 10467 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 10468 | |
| 10469 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 10470 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 10471 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 10472 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 10473 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 10474 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10475 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 10476 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10477 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 10478 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10479 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 10480 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10481 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 10482 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10483 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 10484 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10485 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 10486 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 10487 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 10488 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 10489 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 10490 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 10491 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 10492 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 10493 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 10494 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10495 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 10496 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10497 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 10498 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10499 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 10500 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10501 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 10502 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10503 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 10504 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10505 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 10506 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10507 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10508 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10509 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10510 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10511 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 10512 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10513 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10514 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10515 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 10516 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10517 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 10518 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10519 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 10520 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 10521 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10522 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 10523 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 10524 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 10525 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10526 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 10527 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10528 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10529 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10530 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10531 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10532 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10533 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10534 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10535 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10536 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10537 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10538 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10539 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10540 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 10541 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10542 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10543 | |
| 10544 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 10545 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 10546 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 10547 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 10548 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 10549 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10550 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 10551 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10552 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 10553 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10554 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 10555 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10556 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 10557 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10558 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 10559 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10560 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 10561 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 10562 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 10563 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 10564 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 10565 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 10566 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 10567 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 10568 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 10569 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10570 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 10571 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10572 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 10573 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10574 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 10575 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10576 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 10577 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10578 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 10579 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10580 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 10581 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10582 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10583 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10584 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10585 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10586 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 10587 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10588 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10589 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10590 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 10591 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10592 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 10593 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10594 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 10595 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 10596 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10597 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 10598 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 10599 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 10600 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10601 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 10602 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10603 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10604 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10605 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10606 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10607 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10608 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10609 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10610 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10611 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10612 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10613 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10614 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10615 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 10616 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10617 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10618 | |
| 10619 | /* old command */ |
| 10620 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 10621 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 10622 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10623 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10624 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10625 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10626 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10627 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 10628 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 10629 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 10630 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 10631 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10632 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10633 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10634 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10635 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10636 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10637 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10638 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 10639 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 10640 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10641 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10642 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10643 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10644 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10645 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 10646 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10647 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10648 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10649 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10650 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10651 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10652 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10653 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10654 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10655 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10656 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10657 | /* old command */ |
| 10658 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 10659 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 10660 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10661 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10662 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10663 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10664 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10665 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 10666 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 10667 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 10668 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 10669 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10670 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10671 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10672 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10673 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10674 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10675 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10676 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 10677 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 10678 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10679 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10680 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10681 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10682 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10683 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 10684 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10685 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10686 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10687 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10688 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10689 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10690 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10691 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10692 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10693 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 10694 | |
| 10695 | /* old command */ |
| 10696 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10697 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10698 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10699 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10700 | |
| 10701 | /* old command */ |
| 10702 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10703 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10704 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10705 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10706 | |
| 10707 | /* old command */ |
| 10708 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10709 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10710 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10711 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10712 | #endif /* HAVE_IPV6 */ |
| 10713 | |
| 10714 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 10715 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 10716 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 10717 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 10718 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 10719 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 10720 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 10721 | |
| 10722 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 10723 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 10724 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 10725 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 10726 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 10727 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 10728 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 10729 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 10730 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 10731 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 10732 | } |