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" |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 36 | #include "workqueue.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | |
| 38 | #include "bgpd/bgpd.h" |
| 39 | #include "bgpd/bgp_table.h" |
| 40 | #include "bgpd/bgp_route.h" |
| 41 | #include "bgpd/bgp_attr.h" |
| 42 | #include "bgpd/bgp_debug.h" |
| 43 | #include "bgpd/bgp_aspath.h" |
| 44 | #include "bgpd/bgp_regex.h" |
| 45 | #include "bgpd/bgp_community.h" |
| 46 | #include "bgpd/bgp_ecommunity.h" |
| 47 | #include "bgpd/bgp_clist.h" |
| 48 | #include "bgpd/bgp_packet.h" |
| 49 | #include "bgpd/bgp_filter.h" |
| 50 | #include "bgpd/bgp_fsm.h" |
| 51 | #include "bgpd/bgp_mplsvpn.h" |
| 52 | #include "bgpd/bgp_nexthop.h" |
| 53 | #include "bgpd/bgp_damp.h" |
| 54 | #include "bgpd/bgp_advertise.h" |
| 55 | #include "bgpd/bgp_zebra.h" |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 56 | #include "bgpd/bgp_vty.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 57 | |
| 58 | /* Extern from bgp_dump.c */ |
| 59 | extern char *bgp_origin_str[]; |
| 60 | extern char *bgp_origin_long_str[]; |
| 61 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 62 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 63 | 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] | 64 | struct prefix_rd *prd) |
| 65 | { |
| 66 | struct bgp_node *rn; |
| 67 | struct bgp_node *prn = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | |
| 69 | if (safi == SAFI_MPLS_VPN) |
| 70 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 71 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | |
| 73 | if (prn->info == NULL) |
| 74 | prn->info = bgp_table_init (); |
| 75 | else |
| 76 | bgp_unlock_node (prn); |
| 77 | table = prn->info; |
| 78 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 79 | |
| 80 | rn = bgp_node_get (table, p); |
| 81 | |
| 82 | if (safi == SAFI_MPLS_VPN) |
| 83 | rn->prn = prn; |
| 84 | |
| 85 | return rn; |
| 86 | } |
| 87 | |
| 88 | /* Allocate new bgp info structure. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 89 | static struct bgp_info * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | bgp_info_new () |
| 91 | { |
| 92 | struct bgp_info *new; |
| 93 | |
| 94 | new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 95 | memset (new, 0, sizeof (struct bgp_info)); |
| 96 | |
| 97 | return new; |
| 98 | } |
| 99 | |
| 100 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 101 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | bgp_info_free (struct bgp_info *binfo) |
| 103 | { |
| 104 | if (binfo->attr) |
| 105 | bgp_attr_unintern (binfo->attr); |
| 106 | |
| 107 | if (binfo->damp_info) |
| 108 | bgp_damp_info_free (binfo->damp_info, 0); |
| 109 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 110 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 111 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 112 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 113 | } |
| 114 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 115 | struct bgp_info * |
| 116 | bgp_info_lock (struct bgp_info *binfo) |
| 117 | { |
| 118 | binfo->lock++; |
| 119 | return binfo; |
| 120 | } |
| 121 | |
| 122 | struct bgp_info * |
| 123 | bgp_info_unlock (struct bgp_info *binfo) |
| 124 | { |
| 125 | assert (binfo && binfo->lock > 0); |
| 126 | binfo->lock--; |
| 127 | |
| 128 | if (binfo->lock == 0) |
| 129 | { |
| 130 | #if 0 |
| 131 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 132 | zlog_backtrace (LOG_DEBUG); |
| 133 | #endif |
| 134 | bgp_info_free (binfo); |
| 135 | return NULL; |
| 136 | } |
| 137 | |
| 138 | #if 0 |
| 139 | if (binfo->lock == 1) |
| 140 | { |
| 141 | zlog_debug ("%s: unlocked to 1", __func__); |
| 142 | zlog_backtrace (LOG_DEBUG); |
| 143 | } |
| 144 | #endif |
| 145 | |
| 146 | return binfo; |
| 147 | } |
| 148 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 149 | void |
| 150 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 151 | { |
| 152 | struct bgp_info *top; |
| 153 | |
| 154 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 155 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 156 | ri->next = rn->info; |
| 157 | ri->prev = NULL; |
| 158 | if (top) |
| 159 | top->prev = ri; |
| 160 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 161 | |
| 162 | bgp_info_lock (ri); |
| 163 | bgp_lock_node (rn); |
| 164 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | } |
| 166 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 167 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 168 | completion callback *only* */ |
| 169 | static void |
| 170 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 171 | { |
| 172 | if (ri->next) |
| 173 | ri->next->prev = ri->prev; |
| 174 | if (ri->prev) |
| 175 | ri->prev->next = ri->next; |
| 176 | else |
| 177 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 178 | |
| 179 | bgp_info_unlock (ri); |
| 180 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 181 | } |
| 182 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 183 | void |
| 184 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 185 | { |
| 186 | /* leave info in place for now in place for now, |
| 187 | * bgp_process will reap it later. */ |
| 188 | SET_FLAG (ri->flags, BGP_INFO_REMOVED); |
| 189 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 190 | } |
| 191 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 192 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 193 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 194 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 196 | { |
| 197 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 198 | return attr->med; |
| 199 | else |
| 200 | { |
| 201 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 202 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 203 | else |
| 204 | return 0; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | /* Compare two bgp route entity. br is preferable then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 209 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 210 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) |
| 211 | { |
| 212 | u_int32_t new_pref; |
| 213 | u_int32_t exist_pref; |
| 214 | u_int32_t new_med; |
| 215 | u_int32_t exist_med; |
| 216 | struct in_addr new_id; |
| 217 | struct in_addr exist_id; |
| 218 | int new_cluster; |
| 219 | int exist_cluster; |
| 220 | int internal_as_route = 0; |
| 221 | int confed_as_route = 0; |
| 222 | int ret; |
| 223 | |
| 224 | /* 0. Null check. */ |
| 225 | if (new == NULL) |
| 226 | return 0; |
| 227 | if (exist == NULL) |
| 228 | return 1; |
| 229 | |
| 230 | /* 1. Weight check. */ |
| 231 | if (new->attr->weight > exist->attr->weight) |
| 232 | return 1; |
| 233 | if (new->attr->weight < exist->attr->weight) |
| 234 | return 0; |
| 235 | |
| 236 | /* 2. Local preference check. */ |
| 237 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 238 | new_pref = new->attr->local_pref; |
| 239 | else |
| 240 | new_pref = bgp->default_local_pref; |
| 241 | |
| 242 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 243 | exist_pref = exist->attr->local_pref; |
| 244 | else |
| 245 | exist_pref = bgp->default_local_pref; |
| 246 | |
| 247 | if (new_pref > exist_pref) |
| 248 | return 1; |
| 249 | if (new_pref < exist_pref) |
| 250 | return 0; |
| 251 | |
| 252 | /* 3. Local route check. */ |
| 253 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 254 | return 1; |
| 255 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 256 | return 0; |
| 257 | |
| 258 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 259 | return 1; |
| 260 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 261 | return 0; |
| 262 | |
| 263 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 264 | return 1; |
| 265 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 266 | return 0; |
| 267 | |
| 268 | /* 4. AS path length check. */ |
| 269 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 270 | { |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 271 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 272 | { |
| 273 | if ((new->attr->aspath->count + |
| 274 | new->attr->aspath->confed_count) |
| 275 | < (exist->attr->aspath->count + |
| 276 | exist->attr->aspath->confed_count)) |
| 277 | return 1; |
| 278 | if ((new->attr->aspath->count + |
| 279 | new->attr->aspath->confed_count) |
| 280 | > (exist->attr->aspath->count + |
| 281 | exist->attr->aspath->confed_count)) |
| 282 | return 0; |
| 283 | } |
| 284 | else |
| 285 | { |
| 286 | if (new->attr->aspath->count < exist->attr->aspath->count) |
| 287 | return 1; |
| 288 | if (new->attr->aspath->count > exist->attr->aspath->count) |
| 289 | return 0; |
| 290 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | /* 5. Origin check. */ |
| 294 | if (new->attr->origin < exist->attr->origin) |
| 295 | return 1; |
| 296 | if (new->attr->origin > exist->attr->origin) |
| 297 | return 0; |
| 298 | |
| 299 | /* 6. MED check. */ |
| 300 | internal_as_route = (new->attr->aspath->length == 0 |
| 301 | && exist->attr->aspath->length == 0); |
| 302 | confed_as_route = (new->attr->aspath->length > 0 |
| 303 | && exist->attr->aspath->length > 0 |
| 304 | && new->attr->aspath->count == 0 |
| 305 | && exist->attr->aspath->count == 0); |
| 306 | |
| 307 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 308 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 309 | && confed_as_route) |
| 310 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 311 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 312 | || internal_as_route) |
| 313 | { |
| 314 | new_med = bgp_med_value (new->attr, bgp); |
| 315 | exist_med = bgp_med_value (exist->attr, bgp); |
| 316 | |
| 317 | if (new_med < exist_med) |
| 318 | return 1; |
| 319 | if (new_med > exist_med) |
| 320 | return 0; |
| 321 | } |
| 322 | |
| 323 | /* 7. Peer type check. */ |
| 324 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 325 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 326 | return 1; |
| 327 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 328 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 329 | return 1; |
| 330 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 331 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 332 | return 0; |
| 333 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 334 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 335 | return 0; |
| 336 | |
| 337 | /* 8. IGP metric check. */ |
| 338 | if (new->igpmetric < exist->igpmetric) |
| 339 | return 1; |
| 340 | if (new->igpmetric > exist->igpmetric) |
| 341 | return 0; |
| 342 | |
| 343 | /* 9. Maximum path check. */ |
| 344 | |
| 345 | /* 10. If both paths are external, prefer the path that was received |
| 346 | first (the oldest one). This step minimizes route-flap, since a |
| 347 | newer path won't displace an older one, even if it was the |
| 348 | preferred route based on the additional decision criteria below. */ |
| 349 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 350 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 351 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 352 | { |
| 353 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 354 | return 1; |
| 355 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 356 | return 0; |
| 357 | } |
| 358 | |
| 359 | /* 11. Rourter-ID comparision. */ |
| 360 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 361 | new_id.s_addr = new->attr->originator_id.s_addr; |
| 362 | else |
| 363 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 364 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 365 | exist_id.s_addr = exist->attr->originator_id.s_addr; |
| 366 | else |
| 367 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 368 | |
| 369 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 370 | return 1; |
| 371 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 372 | return 0; |
| 373 | |
| 374 | /* 12. Cluster length comparision. */ |
| 375 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 376 | new_cluster = new->attr->cluster->length; |
| 377 | else |
| 378 | new_cluster = 0; |
| 379 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 380 | exist_cluster = exist->attr->cluster->length; |
| 381 | else |
| 382 | exist_cluster = 0; |
| 383 | |
| 384 | if (new_cluster < exist_cluster) |
| 385 | return 1; |
| 386 | if (new_cluster > exist_cluster) |
| 387 | return 0; |
| 388 | |
| 389 | /* 13. Neighbor address comparision. */ |
| 390 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 391 | |
| 392 | if (ret == 1) |
| 393 | return 0; |
| 394 | if (ret == -1) |
| 395 | return 1; |
| 396 | |
| 397 | return 1; |
| 398 | } |
| 399 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 400 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 401 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 402 | afi_t afi, safi_t safi) |
| 403 | { |
| 404 | struct bgp_filter *filter; |
| 405 | |
| 406 | filter = &peer->filter[afi][safi]; |
| 407 | |
| 408 | if (DISTRIBUTE_IN_NAME (filter)) |
| 409 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 410 | return FILTER_DENY; |
| 411 | |
| 412 | if (PREFIX_LIST_IN_NAME (filter)) |
| 413 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 414 | return FILTER_DENY; |
| 415 | |
| 416 | if (FILTER_LIST_IN_NAME (filter)) |
| 417 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 418 | return FILTER_DENY; |
| 419 | |
| 420 | return FILTER_PERMIT; |
| 421 | } |
| 422 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 423 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 424 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 425 | afi_t afi, safi_t safi) |
| 426 | { |
| 427 | struct bgp_filter *filter; |
| 428 | |
| 429 | filter = &peer->filter[afi][safi]; |
| 430 | |
| 431 | if (DISTRIBUTE_OUT_NAME (filter)) |
| 432 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 433 | return FILTER_DENY; |
| 434 | |
| 435 | if (PREFIX_LIST_OUT_NAME (filter)) |
| 436 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 437 | return FILTER_DENY; |
| 438 | |
| 439 | if (FILTER_LIST_OUT_NAME (filter)) |
| 440 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 441 | return FILTER_DENY; |
| 442 | |
| 443 | return FILTER_PERMIT; |
| 444 | } |
| 445 | |
| 446 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 447 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 448 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 449 | { |
| 450 | if (attr->community) |
| 451 | { |
| 452 | /* NO_ADVERTISE check. */ |
| 453 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 454 | return 1; |
| 455 | |
| 456 | /* NO_EXPORT check. */ |
| 457 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 458 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 459 | return 1; |
| 460 | |
| 461 | /* NO_EXPORT_SUBCONFED check. */ |
| 462 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 463 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 464 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 465 | return 1; |
| 466 | } |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | /* Route reflection loop check. */ |
| 471 | static int |
| 472 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 473 | { |
| 474 | struct in_addr cluster_id; |
| 475 | |
| 476 | if (attr->cluster) |
| 477 | { |
| 478 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 479 | cluster_id = peer->bgp->cluster_id; |
| 480 | else |
| 481 | cluster_id = peer->bgp->router_id; |
| 482 | |
| 483 | if (cluster_loop_check (attr->cluster, cluster_id)) |
| 484 | return 1; |
| 485 | } |
| 486 | return 0; |
| 487 | } |
| 488 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 489 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 490 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 491 | afi_t afi, safi_t safi) |
| 492 | { |
| 493 | struct bgp_filter *filter; |
| 494 | struct bgp_info info; |
| 495 | route_map_result_t ret; |
| 496 | |
| 497 | filter = &peer->filter[afi][safi]; |
| 498 | |
| 499 | /* Apply default weight value. */ |
| 500 | attr->weight = peer->weight; |
| 501 | |
| 502 | /* Route map apply. */ |
| 503 | if (ROUTE_MAP_IN_NAME (filter)) |
| 504 | { |
| 505 | /* Duplicate current value to new strucutre for modification. */ |
| 506 | info.peer = peer; |
| 507 | info.attr = attr; |
| 508 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 509 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 510 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | /* Apply BGP route map to the attribute. */ |
| 512 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 513 | |
| 514 | peer->rmap_type = 0; |
| 515 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 516 | if (ret == RMAP_DENYMATCH) |
| 517 | { |
| 518 | /* Free newly generated AS path and community by route-map. */ |
| 519 | bgp_attr_flush (attr); |
| 520 | return RMAP_DENY; |
| 521 | } |
| 522 | } |
| 523 | return RMAP_PERMIT; |
| 524 | } |
| 525 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 526 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 527 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 528 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 529 | { |
| 530 | struct bgp_filter *filter; |
| 531 | struct bgp_info info; |
| 532 | route_map_result_t ret; |
| 533 | |
| 534 | filter = &peer->filter[afi][safi]; |
| 535 | |
| 536 | /* Route map apply. */ |
| 537 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 538 | { |
| 539 | /* Duplicate current value to new strucutre for modification. */ |
| 540 | info.peer = rsclient; |
| 541 | info.attr = attr; |
| 542 | |
| 543 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 544 | |
| 545 | /* Apply BGP route map to the attribute. */ |
| 546 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 547 | |
| 548 | rsclient->rmap_type = 0; |
| 549 | |
| 550 | if (ret == RMAP_DENYMATCH) |
| 551 | { |
| 552 | /* Free newly generated AS path and community by route-map. */ |
| 553 | bgp_attr_flush (attr); |
| 554 | return RMAP_DENY; |
| 555 | } |
| 556 | } |
| 557 | return RMAP_PERMIT; |
| 558 | } |
| 559 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 560 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 561 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 562 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 563 | { |
| 564 | struct bgp_filter *filter; |
| 565 | struct bgp_info info; |
| 566 | route_map_result_t ret; |
| 567 | |
| 568 | filter = &rsclient->filter[afi][safi]; |
| 569 | |
| 570 | /* Apply default weight value. */ |
| 571 | attr->weight = peer->weight; |
| 572 | |
| 573 | /* Route map apply. */ |
| 574 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 575 | { |
| 576 | /* Duplicate current value to new strucutre for modification. */ |
| 577 | info.peer = peer; |
| 578 | info.attr = attr; |
| 579 | |
| 580 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 581 | |
| 582 | /* Apply BGP route map to the attribute. */ |
| 583 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 584 | |
| 585 | peer->rmap_type = 0; |
| 586 | |
| 587 | if (ret == RMAP_DENYMATCH) |
| 588 | { |
| 589 | /* Free newly generated AS path and community by route-map. */ |
| 590 | bgp_attr_flush (attr); |
| 591 | return RMAP_DENY; |
| 592 | } |
| 593 | } |
| 594 | return RMAP_PERMIT; |
| 595 | } |
| 596 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 597 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 599 | struct attr *attr, afi_t afi, safi_t safi) |
| 600 | { |
| 601 | int ret; |
| 602 | char buf[SU_ADDRSTRLEN]; |
| 603 | struct bgp_filter *filter; |
| 604 | struct bgp_info info; |
| 605 | struct peer *from; |
| 606 | struct bgp *bgp; |
| 607 | struct attr dummy_attr; |
| 608 | int transparent; |
| 609 | int reflect; |
| 610 | |
| 611 | from = ri->peer; |
| 612 | filter = &peer->filter[afi][safi]; |
| 613 | bgp = peer->bgp; |
| 614 | |
| 615 | #ifdef DISABLE_BGP_ANNOUNCE |
| 616 | return 0; |
| 617 | #endif |
| 618 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 619 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 620 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 621 | return 0; |
| 622 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | /* Do not send back route to sender. */ |
| 624 | if (from == peer) |
| 625 | return 0; |
| 626 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 627 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 628 | if (p->family == AF_INET |
| 629 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 630 | return 0; |
| 631 | #ifdef HAVE_IPV6 |
| 632 | if (p->family == AF_INET6 |
| 633 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 634 | return 0; |
| 635 | #endif |
| 636 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 637 | /* Aggregate-address suppress check. */ |
| 638 | if (ri->suppress) |
| 639 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 640 | return 0; |
| 641 | |
| 642 | /* Default route check. */ |
| 643 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 644 | { |
| 645 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 646 | return 0; |
| 647 | #ifdef HAVE_IPV6 |
| 648 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 649 | return 0; |
| 650 | #endif /* HAVE_IPV6 */ |
| 651 | } |
| 652 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 653 | /* Transparency check. */ |
| 654 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 655 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 656 | transparent = 1; |
| 657 | else |
| 658 | transparent = 0; |
| 659 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 660 | /* If community is not disabled check the no-export and local. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 661 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 662 | return 0; |
| 663 | |
| 664 | /* If the attribute has originator-id and it is same as remote |
| 665 | peer's id. */ |
| 666 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 667 | { |
| 668 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id)) |
| 669 | { |
| 670 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 671 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 672 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 673 | peer->host, |
| 674 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 675 | p->prefixlen); |
| 676 | return 0; |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | /* ORF prefix-list filter check */ |
| 681 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 682 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 683 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 684 | if (peer->orf_plist[afi][safi]) |
| 685 | { |
| 686 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 690 | /* Output filter check. */ |
| 691 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) |
| 692 | { |
| 693 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 694 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 695 | "%s [Update:SEND] %s/%d is filtered", |
| 696 | peer->host, |
| 697 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 698 | p->prefixlen); |
| 699 | return 0; |
| 700 | } |
| 701 | |
| 702 | #ifdef BGP_SEND_ASPATH_CHECK |
| 703 | /* AS path loop check. */ |
| 704 | if (aspath_loop_check (ri->attr->aspath, peer->as)) |
| 705 | { |
| 706 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 707 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 708 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 709 | peer->host, peer->as); |
| 710 | return 0; |
| 711 | } |
| 712 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 713 | |
| 714 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 715 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 716 | { |
| 717 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) |
| 718 | { |
| 719 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 720 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 722 | peer->host, |
| 723 | bgp->confed_id); |
| 724 | return 0; |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | /* Route-Reflect check. */ |
| 729 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 730 | reflect = 1; |
| 731 | else |
| 732 | reflect = 0; |
| 733 | |
| 734 | /* IBGP reflection check. */ |
| 735 | if (reflect) |
| 736 | { |
| 737 | /* A route from a Client peer. */ |
| 738 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 739 | { |
| 740 | /* Reflect to all the Non-Client peers and also to the |
| 741 | Client peers other than the originator. Originator check |
| 742 | is already done. So there is noting to do. */ |
| 743 | /* no bgp client-to-client reflection check. */ |
| 744 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 745 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 746 | return 0; |
| 747 | } |
| 748 | else |
| 749 | { |
| 750 | /* A route from a Non-client peer. Reflect to all other |
| 751 | clients. */ |
| 752 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 753 | return 0; |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | /* For modify attribute, copy it to temporary structure. */ |
| 758 | *attr = *ri->attr; |
| 759 | |
| 760 | /* If local-preference is not set. */ |
| 761 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 762 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 763 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 764 | { |
| 765 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 766 | attr->local_pref = bgp->default_local_pref; |
| 767 | } |
| 768 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 769 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 770 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 771 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 772 | { |
| 773 | if (ri->peer != bgp->peer_self && ! transparent |
| 774 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 775 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 776 | } |
| 777 | |
| 778 | /* next-hop-set */ |
| 779 | if (transparent || reflect |
| 780 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 781 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 782 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 783 | || (p->family == AF_INET6 && |
| 784 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 785 | #endif /* HAVE_IPV6 */ |
| 786 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | { |
| 788 | /* NEXT-HOP Unchanged. */ |
| 789 | } |
| 790 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 791 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 792 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 793 | || (p->family == AF_INET6 && |
| 794 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 795 | #endif /* HAVE_IPV6 */ |
| 796 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 797 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 798 | { |
| 799 | /* Set IPv4 nexthop. */ |
| 800 | if (p->family == AF_INET) |
| 801 | { |
| 802 | if (safi == SAFI_MPLS_VPN) |
| 803 | memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 804 | else |
| 805 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 806 | } |
| 807 | #ifdef HAVE_IPV6 |
| 808 | /* Set IPv6 nexthop. */ |
| 809 | if (p->family == AF_INET6) |
| 810 | { |
| 811 | /* IPv6 global nexthop must be included. */ |
| 812 | memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global, |
| 813 | IPV6_MAX_BYTELEN); |
| 814 | attr->mp_nexthop_len = 16; |
| 815 | } |
| 816 | #endif /* HAVE_IPV6 */ |
| 817 | } |
| 818 | |
| 819 | #ifdef HAVE_IPV6 |
| 820 | if (p->family == AF_INET6) |
| 821 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 822 | /* Left nexthop_local unchanged if so configured. */ |
| 823 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 824 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 825 | { |
| 826 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 827 | attr->mp_nexthop_len=32; |
| 828 | else |
| 829 | attr->mp_nexthop_len=16; |
| 830 | } |
| 831 | |
| 832 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 833 | else |
| 834 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 835 | /* Link-local address should not be transit to different peer. */ |
| 836 | attr->mp_nexthop_len = 16; |
| 837 | |
| 838 | /* Set link-local address for shared network peer. */ |
| 839 | if (peer->shared_network |
| 840 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 841 | { |
| 842 | memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local, |
| 843 | IPV6_MAX_BYTELEN); |
| 844 | attr->mp_nexthop_len = 32; |
| 845 | } |
| 846 | |
| 847 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 848 | address.*/ |
| 849 | if (reflect) |
| 850 | attr->mp_nexthop_len = 16; |
| 851 | |
| 852 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 853 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
| 854 | attr->mp_nexthop_len = 16; |
| 855 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 856 | |
| 857 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 858 | #endif /* HAVE_IPV6 */ |
| 859 | |
| 860 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 861 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 862 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 863 | && aspath_private_as_check (attr->aspath)) |
| 864 | attr->aspath = aspath_empty_get (); |
| 865 | |
| 866 | /* Route map & unsuppress-map apply. */ |
| 867 | if (ROUTE_MAP_OUT_NAME (filter) |
| 868 | || ri->suppress) |
| 869 | { |
| 870 | info.peer = peer; |
| 871 | info.attr = attr; |
| 872 | |
| 873 | /* The route reflector is not allowed to modify the attributes |
| 874 | of the reflected IBGP routes. */ |
| 875 | if (peer_sort (from) == BGP_PEER_IBGP |
| 876 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 877 | { |
| 878 | dummy_attr = *attr; |
| 879 | info.attr = &dummy_attr; |
| 880 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 881 | |
| 882 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 883 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 884 | if (ri->suppress) |
| 885 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 886 | else |
| 887 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 888 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 889 | peer->rmap_type = 0; |
| 890 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 891 | if (ret == RMAP_DENYMATCH) |
| 892 | { |
| 893 | bgp_attr_flush (attr); |
| 894 | return 0; |
| 895 | } |
| 896 | } |
| 897 | return 1; |
| 898 | } |
| 899 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 900 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 901 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 902 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 903 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 904 | int ret; |
| 905 | char buf[SU_ADDRSTRLEN]; |
| 906 | struct bgp_filter *filter; |
| 907 | struct bgp_info info; |
| 908 | struct peer *from; |
| 909 | struct bgp *bgp; |
| 910 | |
| 911 | from = ri->peer; |
| 912 | filter = &rsclient->filter[afi][safi]; |
| 913 | bgp = rsclient->bgp; |
| 914 | |
| 915 | #ifdef DISABLE_BGP_ANNOUNCE |
| 916 | return 0; |
| 917 | #endif |
| 918 | |
| 919 | /* Do not send back route to sender. */ |
| 920 | if (from == rsclient) |
| 921 | return 0; |
| 922 | |
| 923 | /* Aggregate-address suppress check. */ |
| 924 | if (ri->suppress) |
| 925 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 926 | return 0; |
| 927 | |
| 928 | /* Default route check. */ |
| 929 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 930 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 931 | { |
| 932 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 933 | return 0; |
| 934 | #ifdef HAVE_IPV6 |
| 935 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 936 | return 0; |
| 937 | #endif /* HAVE_IPV6 */ |
| 938 | } |
| 939 | |
| 940 | /* If the attribute has originator-id and it is same as remote |
| 941 | peer's id. */ |
| 942 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 943 | { |
| 944 | if (IPV4_ADDR_SAME (&rsclient->remote_id, &ri->attr->originator_id)) |
| 945 | { |
| 946 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 947 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 948 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 949 | rsclient->host, |
| 950 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 951 | p->prefixlen); |
| 952 | return 0; |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | /* ORF prefix-list filter check */ |
| 957 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 958 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 959 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 960 | if (rsclient->orf_plist[afi][safi]) |
| 961 | { |
| 962 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 963 | return 0; |
| 964 | } |
| 965 | |
| 966 | /* Output filter check. */ |
| 967 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) |
| 968 | { |
| 969 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 970 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 971 | "%s [Update:SEND] %s/%d is filtered", |
| 972 | rsclient->host, |
| 973 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 974 | p->prefixlen); |
| 975 | return 0; |
| 976 | } |
| 977 | |
| 978 | #ifdef BGP_SEND_ASPATH_CHECK |
| 979 | /* AS path loop check. */ |
| 980 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) |
| 981 | { |
| 982 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 983 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 984 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 985 | rsclient->host, rsclient->as); |
| 986 | return 0; |
| 987 | } |
| 988 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 989 | |
| 990 | /* For modify attribute, copy it to temporary structure. */ |
| 991 | *attr = *ri->attr; |
| 992 | |
| 993 | /* next-hop-set */ |
| 994 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 995 | #ifdef HAVE_IPV6 |
| 996 | || (p->family == AF_INET6 && |
| 997 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
| 998 | #endif /* HAVE_IPV6 */ |
| 999 | ) |
| 1000 | { |
| 1001 | /* Set IPv4 nexthop. */ |
| 1002 | if (p->family == AF_INET) |
| 1003 | { |
| 1004 | if (safi == SAFI_MPLS_VPN) |
| 1005 | memcpy (&attr->mp_nexthop_global_in, &rsclient->nexthop.v4, |
| 1006 | IPV4_MAX_BYTELEN); |
| 1007 | else |
| 1008 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1009 | } |
| 1010 | #ifdef HAVE_IPV6 |
| 1011 | /* Set IPv6 nexthop. */ |
| 1012 | if (p->family == AF_INET6) |
| 1013 | { |
| 1014 | /* IPv6 global nexthop must be included. */ |
| 1015 | memcpy (&attr->mp_nexthop_global, &rsclient->nexthop.v6_global, |
| 1016 | |
| 1017 | IPV6_MAX_BYTELEN); |
| 1018 | attr->mp_nexthop_len = 16; |
| 1019 | } |
| 1020 | #endif /* HAVE_IPV6 */ |
| 1021 | } |
| 1022 | |
| 1023 | #ifdef HAVE_IPV6 |
| 1024 | if (p->family == AF_INET6) |
| 1025 | { |
| 1026 | /* Left nexthop_local unchanged if so configured. */ |
| 1027 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1028 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1029 | { |
| 1030 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 1031 | attr->mp_nexthop_len=32; |
| 1032 | else |
| 1033 | attr->mp_nexthop_len=16; |
| 1034 | } |
| 1035 | |
| 1036 | /* Default nexthop_local treatment for RS-Clients */ |
| 1037 | else |
| 1038 | { |
| 1039 | /* Announcer and RS-Client are both in the same network */ |
| 1040 | if (rsclient->shared_network && from->shared_network && |
| 1041 | (rsclient->ifindex == from->ifindex)) |
| 1042 | { |
| 1043 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 1044 | attr->mp_nexthop_len=32; |
| 1045 | else |
| 1046 | attr->mp_nexthop_len=16; |
| 1047 | } |
| 1048 | |
| 1049 | /* Set link-local address for shared network peer. */ |
| 1050 | else if (rsclient->shared_network |
| 1051 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1052 | { |
| 1053 | memcpy (&attr->mp_nexthop_local, &rsclient->nexthop.v6_local, |
| 1054 | IPV6_MAX_BYTELEN); |
| 1055 | attr->mp_nexthop_len = 32; |
| 1056 | } |
| 1057 | |
| 1058 | else |
| 1059 | attr->mp_nexthop_len = 16; |
| 1060 | } |
| 1061 | |
| 1062 | } |
| 1063 | #endif /* HAVE_IPV6 */ |
| 1064 | |
| 1065 | |
| 1066 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1067 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 1068 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1069 | && aspath_private_as_check (attr->aspath)) |
| 1070 | attr->aspath = aspath_empty_get (); |
| 1071 | |
| 1072 | /* Route map & unsuppress-map apply. */ |
| 1073 | if (ROUTE_MAP_OUT_NAME (filter) || ri->suppress) |
| 1074 | { |
| 1075 | info.peer = rsclient; |
| 1076 | info.attr = attr; |
| 1077 | |
| 1078 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1079 | |
| 1080 | if (ri->suppress) |
| 1081 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1082 | else |
| 1083 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1084 | |
| 1085 | rsclient->rmap_type = 0; |
| 1086 | |
| 1087 | if (ret == RMAP_DENYMATCH) |
| 1088 | { |
| 1089 | bgp_attr_flush (attr); |
| 1090 | return 0; |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | return 1; |
| 1095 | } |
| 1096 | |
| 1097 | struct bgp_info_pair |
| 1098 | { |
| 1099 | struct bgp_info *old; |
| 1100 | struct bgp_info *new; |
| 1101 | }; |
| 1102 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1103 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1104 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
| 1105 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1106 | struct bgp_info *new_select; |
| 1107 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1108 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1109 | struct bgp_info *ri1; |
| 1110 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1111 | struct bgp_info *nextri = NULL; |
| 1112 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1113 | /* bgp deterministic-med */ |
| 1114 | new_select = NULL; |
| 1115 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1116 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1117 | { |
| 1118 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1119 | continue; |
| 1120 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1121 | continue; |
| 1122 | |
| 1123 | new_select = ri1; |
| 1124 | if (ri1->next) |
| 1125 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1126 | { |
| 1127 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1128 | continue; |
| 1129 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1130 | continue; |
| 1131 | |
| 1132 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1133 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1134 | ri2->attr->aspath)) |
| 1135 | { |
| 1136 | if (bgp_info_cmp (bgp, ri2, new_select)) |
| 1137 | { |
| 1138 | UNSET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1139 | new_select = ri2; |
| 1140 | } |
| 1141 | |
| 1142 | SET_FLAG (ri2->flags, BGP_INFO_DMED_CHECK); |
| 1143 | } |
| 1144 | } |
| 1145 | SET_FLAG (new_select->flags, BGP_INFO_DMED_CHECK); |
| 1146 | SET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1147 | } |
| 1148 | |
| 1149 | /* Check old selected route and new selected route. */ |
| 1150 | old_select = NULL; |
| 1151 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1152 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1153 | { |
| 1154 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1155 | old_select = ri; |
| 1156 | |
| 1157 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1158 | { |
| 1159 | /* reap REMOVED routes, if needs be |
| 1160 | * selected route must stay for a while longer though |
| 1161 | */ |
| 1162 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1163 | && (ri != old_select)) |
| 1164 | bgp_info_reap (rn, ri); |
| 1165 | |
| 1166 | continue; |
| 1167 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1168 | |
| 1169 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1170 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1171 | { |
| 1172 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1173 | continue; |
| 1174 | } |
| 1175 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1176 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_SELECTED); |
| 1177 | |
| 1178 | if (bgp_info_cmp (bgp, ri, new_select)) |
| 1179 | new_select = ri; |
| 1180 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1181 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1182 | result->old = old_select; |
| 1183 | result->new = new_select; |
| 1184 | |
| 1185 | return; |
| 1186 | } |
| 1187 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1188 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1189 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
| 1190 | struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi) |
| 1191 | { |
| 1192 | struct prefix *p; |
| 1193 | |
| 1194 | p = &rn->p; |
| 1195 | |
| 1196 | /* Announce route to Established peer. */ |
| 1197 | if (peer->status != Established) |
| 1198 | return 0; |
| 1199 | |
| 1200 | /* Address family configuration check. */ |
| 1201 | if (! peer->afc_nego[afi][safi]) |
| 1202 | return 0; |
| 1203 | |
| 1204 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 1205 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1206 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1207 | return 0; |
| 1208 | |
| 1209 | switch (rn->table->type) |
| 1210 | { |
| 1211 | case BGP_TABLE_MAIN: |
| 1212 | /* Announcement to peer->conf. If the route is filtered, |
| 1213 | withdraw it. */ |
| 1214 | if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi)) |
| 1215 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1216 | else |
| 1217 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1218 | break; |
| 1219 | case BGP_TABLE_RSCLIENT: |
| 1220 | /* Announcement to peer->conf. If the route is filtered, |
| 1221 | withdraw it. */ |
| 1222 | if (selected && bgp_announce_check_rsclient |
| 1223 | (selected, peer, p, attr, afi, safi)) |
| 1224 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1225 | else |
| 1226 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1227 | break; |
| 1228 | } |
| 1229 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1230 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1231 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1232 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1233 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1234 | struct bgp *bgp; |
| 1235 | struct bgp_node *rn; |
| 1236 | afi_t afi; |
| 1237 | safi_t safi; |
| 1238 | }; |
| 1239 | |
| 1240 | static wq_item_status |
| 1241 | bgp_process_rsclient (struct bgp_process_queue *pq) |
| 1242 | { |
| 1243 | struct bgp *bgp = pq->bgp; |
| 1244 | struct bgp_node *rn = pq->rn; |
| 1245 | afi_t afi = pq->afi; |
| 1246 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1247 | struct bgp_info *new_select; |
| 1248 | struct bgp_info *old_select; |
| 1249 | struct bgp_info_pair old_and_new; |
| 1250 | struct attr attr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1251 | struct listnode *node, *nnode; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1252 | struct peer *rsclient = rn->table->owner; |
| 1253 | |
| 1254 | /* we shouldn't run if the clear_route_node queue is still running |
| 1255 | * or scheduled to run, or we can race with session coming up |
| 1256 | * and adding routes back before we've cleared them |
| 1257 | */ |
| 1258 | if (bm->clear_node_queue && bm->clear_node_queue->thread) |
| 1259 | return WQ_QUEUE_BLOCKED; |
| 1260 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1261 | /* Best path selection. */ |
| 1262 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1263 | new_select = old_and_new.new; |
| 1264 | old_select = old_and_new.old; |
| 1265 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1266 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1267 | { |
| 1268 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1269 | { |
| 1270 | /* Nothing to do. */ |
| 1271 | if (old_select && old_select == new_select) |
| 1272 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1273 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1274 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1275 | if (old_select) |
| 1276 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1277 | if (new_select) |
| 1278 | { |
| 1279 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1280 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1281 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1282 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1283 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, |
| 1284 | afi, safi); |
| 1285 | } |
| 1286 | } |
| 1287 | else |
| 1288 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1289 | if (old_select) |
| 1290 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1291 | if (new_select) |
| 1292 | { |
| 1293 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1294 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1295 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1296 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1297 | &attr, afi, safi); |
| 1298 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1299 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1300 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1301 | bgp_info_reap (rn, old_select); |
| 1302 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1303 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1304 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1305 | } |
| 1306 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1307 | static wq_item_status |
| 1308 | bgp_process_main (struct bgp_process_queue *pq) |
| 1309 | { |
| 1310 | struct bgp *bgp = pq->bgp; |
| 1311 | struct bgp_node *rn = pq->rn; |
| 1312 | afi_t afi = pq->afi; |
| 1313 | safi_t safi = pq->safi; |
| 1314 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1315 | struct bgp_info *new_select; |
| 1316 | struct bgp_info *old_select; |
| 1317 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1318 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1319 | struct peer *peer; |
| 1320 | struct attr attr; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1321 | |
| 1322 | /* we shouldn't run if the clear_route_node queue is still running |
| 1323 | * or scheduled to run, or we can race with session coming up |
| 1324 | * and adding routes back before we've cleared them |
| 1325 | */ |
| 1326 | if (bm->clear_node_queue && bm->clear_node_queue->thread) |
| 1327 | return WQ_QUEUE_BLOCKED; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1328 | |
| 1329 | /* Best path selection. */ |
| 1330 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1331 | old_select = old_and_new.old; |
| 1332 | new_select = old_and_new.new; |
| 1333 | |
| 1334 | /* Nothing to do. */ |
| 1335 | if (old_select && old_select == new_select) |
| 1336 | { |
| 1337 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1338 | { |
| 1339 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) |
| 1340 | bgp_zebra_announce (p, old_select, bgp); |
| 1341 | |
| 1342 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1343 | return WQ_SUCCESS; |
| 1344 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1345 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1346 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1347 | if (old_select) |
| 1348 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1349 | if (new_select) |
| 1350 | { |
| 1351 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1352 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1353 | } |
| 1354 | |
| 1355 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1356 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1357 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1358 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1359 | bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1360 | } |
| 1361 | |
| 1362 | /* FIB update. */ |
| 1363 | if (safi == SAFI_UNICAST && ! bgp->name && |
| 1364 | ! bgp_option_check (BGP_OPT_NO_FIB)) |
| 1365 | { |
| 1366 | if (new_select |
| 1367 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1368 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
| 1369 | bgp_zebra_announce (p, new_select, bgp); |
| 1370 | else |
| 1371 | { |
| 1372 | /* Withdraw the route from the kernel. */ |
| 1373 | if (old_select |
| 1374 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1375 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
| 1376 | bgp_zebra_withdraw (p, old_select); |
| 1377 | } |
| 1378 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1379 | |
| 1380 | /* Reap old select bgp_info, it it has been removed */ |
| 1381 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1382 | bgp_info_reap (rn, old_select); |
| 1383 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1384 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1385 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1386 | } |
| 1387 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1388 | static void |
| 1389 | bgp_processq_del (struct bgp_process_queue *pq) |
| 1390 | { |
| 1391 | bgp_unlock_node (pq->rn); |
| 1392 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1393 | } |
| 1394 | |
| 1395 | static void |
| 1396 | bgp_process_queue_init (void) |
| 1397 | { |
| 1398 | bm->process_main_queue |
| 1399 | = work_queue_new (bm->master, "process_main_queue"); |
| 1400 | bm->process_rsclient_queue |
| 1401 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1402 | |
| 1403 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1404 | { |
| 1405 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1406 | exit (1); |
| 1407 | } |
| 1408 | |
| 1409 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
| 1410 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
| 1411 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
| 1412 | bm->process_rsclient_queue->spec.del_item_data |
| 1413 | = bm->process_main_queue->spec.del_item_data; |
| 1414 | bm->process_main_queue->spec.max_retries |
| 1415 | = bm->process_main_queue->spec.max_retries = 0; |
| 1416 | bm->process_rsclient_queue->spec.hold |
| 1417 | = bm->process_main_queue->spec.hold = 500; |
| 1418 | bm->process_rsclient_queue->spec.delay |
| 1419 | = bm->process_main_queue->spec.delay = 10; |
| 1420 | } |
| 1421 | |
| 1422 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1423 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1424 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1425 | struct bgp_process_queue *pqnode; |
| 1426 | |
| 1427 | /* already scheduled for processing? */ |
| 1428 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1429 | return; |
| 1430 | |
| 1431 | if ( (bm->process_main_queue == NULL) || |
| 1432 | (bm->process_rsclient_queue == NULL) ) |
| 1433 | bgp_process_queue_init (); |
| 1434 | |
| 1435 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1436 | sizeof (struct bgp_process_queue)); |
| 1437 | if (!pqnode) |
| 1438 | return; |
| 1439 | |
| 1440 | pqnode->rn = bgp_lock_node (rn); /* unlocked by bgp_processq_del */ |
| 1441 | pqnode->bgp = bgp; |
| 1442 | pqnode->afi = afi; |
| 1443 | pqnode->safi = safi; |
| 1444 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1445 | switch (rn->table->type) |
| 1446 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1447 | case BGP_TABLE_MAIN: |
| 1448 | work_queue_add (bm->process_main_queue, pqnode); |
| 1449 | break; |
| 1450 | case BGP_TABLE_RSCLIENT: |
| 1451 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1452 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1453 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1454 | |
| 1455 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1456 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1457 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1458 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1459 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1460 | { |
| 1461 | struct peer *peer; |
| 1462 | |
| 1463 | peer = THREAD_ARG (thread); |
| 1464 | peer->t_pmax_restart = NULL; |
| 1465 | |
| 1466 | if (BGP_DEBUG (events, EVENTS)) |
| 1467 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1468 | peer->host); |
| 1469 | |
| 1470 | peer_clear (peer); |
| 1471 | |
| 1472 | return 0; |
| 1473 | } |
| 1474 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1475 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1476 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1477 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1478 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1479 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1480 | return 0; |
| 1481 | |
| 1482 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1483 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1484 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1485 | && ! always) |
| 1486 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1487 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1488 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1489 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1490 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1491 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1492 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1493 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1494 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1495 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1496 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1497 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1498 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1499 | |
| 1500 | if (safi == SAFI_MPLS_VPN) |
| 1501 | safi = BGP_SAFI_VPNV4; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1502 | |
| 1503 | ndata[0] = (afi >> 8); |
| 1504 | ndata[1] = afi; |
| 1505 | ndata[2] = safi; |
| 1506 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1507 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1508 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1509 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1510 | |
| 1511 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1512 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1513 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1514 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1515 | |
| 1516 | /* restart timer start */ |
| 1517 | if (peer->pmax_restart[afi][safi]) |
| 1518 | { |
| 1519 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1520 | |
| 1521 | if (BGP_DEBUG (events, EVENTS)) |
| 1522 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1523 | peer->host, peer->v_pmax_restart); |
| 1524 | |
| 1525 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1526 | peer->v_pmax_restart); |
| 1527 | } |
| 1528 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1529 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1530 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1531 | else |
| 1532 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1533 | |
| 1534 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1535 | { |
| 1536 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1537 | && ! always) |
| 1538 | return 0; |
| 1539 | |
| 1540 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1541 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1542 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1543 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1544 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1545 | } |
| 1546 | else |
| 1547 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1548 | return 0; |
| 1549 | } |
| 1550 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1551 | /* Unconditionally remove the route from the RIB, without taking |
| 1552 | * damping into consideration (eg, because the session went down) |
| 1553 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1554 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1555 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1556 | afi_t afi, safi_t safi) |
| 1557 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1558 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) |
| 1559 | && rn->table->type == BGP_TABLE_MAIN) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1560 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1561 | /* Ignore 'pcount' for RS-client tables */ |
| 1562 | if ( rn->table->type == BGP_TABLE_MAIN) |
| 1563 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1564 | peer->pcount[afi][safi]--; |
| 1565 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1566 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1567 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1568 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1569 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1570 | } |
| 1571 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1572 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1573 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1574 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1575 | { |
| 1576 | int valid; |
| 1577 | int status = BGP_DAMP_NONE; |
| 1578 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1579 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) |
| 1580 | && rn->table->type == BGP_TABLE_MAIN) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1581 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1582 | /* Ignore 'pcount' for RS-client tables */ |
| 1583 | if ( rn->table->type == BGP_TABLE_MAIN) |
| 1584 | { |
| 1585 | peer->pcount[afi][safi]--; |
| 1586 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1587 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1588 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1589 | |
| 1590 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1591 | * the bgp_info in the RIB for historical reference. |
| 1592 | */ |
| 1593 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1594 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1595 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1596 | == BGP_DAMP_SUPPRESSED) |
| 1597 | return; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1598 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1599 | bgp_process (peer->bgp, rn, afi, safi); |
| 1600 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1601 | if (status != BGP_DAMP_USED) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1602 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1603 | } |
| 1604 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1605 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1606 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1607 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1608 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1609 | { |
| 1610 | struct bgp_node *rn; |
| 1611 | struct bgp *bgp; |
| 1612 | struct attr new_attr; |
| 1613 | struct attr *attr_new; |
| 1614 | struct attr *attr_new2; |
| 1615 | struct bgp_info *ri; |
| 1616 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1617 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1618 | char buf[SU_ADDRSTRLEN]; |
| 1619 | |
| 1620 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1621 | if (peer == rsclient) |
| 1622 | return; |
| 1623 | |
| 1624 | bgp = peer->bgp; |
| 1625 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1626 | |
| 1627 | /* Check previously received route. */ |
| 1628 | for (ri = rn->info; ri; ri = ri->next) |
| 1629 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1630 | break; |
| 1631 | |
| 1632 | /* AS path loop check. */ |
| 1633 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1634 | { |
| 1635 | reason = "as-path contains our own AS;"; |
| 1636 | goto filtered; |
| 1637 | } |
| 1638 | |
| 1639 | /* Route reflector originator ID check. */ |
| 1640 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1641 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->originator_id)) |
| 1642 | { |
| 1643 | reason = "originator is us;"; |
| 1644 | goto filtered; |
| 1645 | } |
| 1646 | |
| 1647 | new_attr = *attr; |
| 1648 | |
| 1649 | /* Apply export policy. */ |
| 1650 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1651 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1652 | { |
| 1653 | reason = "export-policy;"; |
| 1654 | goto filtered; |
| 1655 | } |
| 1656 | |
| 1657 | attr_new2 = bgp_attr_intern (&new_attr); |
| 1658 | |
| 1659 | /* Apply import policy. */ |
| 1660 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1661 | { |
| 1662 | bgp_attr_unintern (attr_new2); |
| 1663 | |
| 1664 | reason = "import-policy;"; |
| 1665 | goto filtered; |
| 1666 | } |
| 1667 | |
| 1668 | attr_new = bgp_attr_intern (&new_attr); |
| 1669 | bgp_attr_unintern (attr_new2); |
| 1670 | |
| 1671 | /* IPv4 unicast next hop check. */ |
| 1672 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1673 | { |
| 1674 | /* Next hop must not be 0.0.0.0 nor Class E address. */ |
| 1675 | if (new_attr.nexthop.s_addr == 0 |
| 1676 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1677 | { |
| 1678 | bgp_attr_unintern (attr_new); |
| 1679 | |
| 1680 | reason = "martian next-hop;"; |
| 1681 | goto filtered; |
| 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | /* If the update is implicit withdraw. */ |
| 1686 | if (ri) |
| 1687 | { |
| 1688 | ri->uptime = time (NULL); |
| 1689 | |
| 1690 | /* Same attribute comes in. */ |
| 1691 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1692 | { |
| 1693 | |
| 1694 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1695 | |
| 1696 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1697 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1698 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1699 | peer->host, |
| 1700 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1701 | p->prefixlen, rsclient->host); |
| 1702 | |
| 1703 | bgp_unlock_node (rn); |
| 1704 | bgp_attr_unintern (attr_new); |
| 1705 | |
| 1706 | return; |
| 1707 | } |
| 1708 | |
| 1709 | /* Received Logging. */ |
| 1710 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1711 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1712 | peer->host, |
| 1713 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1714 | p->prefixlen, rsclient->host); |
| 1715 | |
| 1716 | /* The attribute is changed. */ |
| 1717 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1718 | |
| 1719 | /* Update to new attribute. */ |
| 1720 | bgp_attr_unintern (ri->attr); |
| 1721 | ri->attr = attr_new; |
| 1722 | |
| 1723 | /* Update MPLS tag. */ |
| 1724 | if (safi == SAFI_MPLS_VPN) |
| 1725 | memcpy (ri->tag, tag, 3); |
| 1726 | |
| 1727 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1728 | |
| 1729 | /* Process change. */ |
| 1730 | bgp_process (bgp, rn, afi, safi); |
| 1731 | bgp_unlock_node (rn); |
| 1732 | |
| 1733 | return; |
| 1734 | } |
| 1735 | |
| 1736 | /* Received Logging. */ |
| 1737 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1738 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1739 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1740 | peer->host, |
| 1741 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1742 | p->prefixlen, rsclient->host); |
| 1743 | } |
| 1744 | |
| 1745 | /* Make new BGP info. */ |
| 1746 | new = bgp_info_new (); |
| 1747 | new->type = type; |
| 1748 | new->sub_type = sub_type; |
| 1749 | new->peer = peer; |
| 1750 | new->attr = attr_new; |
| 1751 | new->uptime = time (NULL); |
| 1752 | |
| 1753 | /* Update MPLS tag. */ |
| 1754 | if (safi == SAFI_MPLS_VPN) |
| 1755 | memcpy (new->tag, tag, 3); |
| 1756 | |
| 1757 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1758 | |
| 1759 | /* Register new BGP information. */ |
| 1760 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1761 | |
| 1762 | /* route_node_get lock */ |
| 1763 | bgp_unlock_node (rn); |
| 1764 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1765 | /* Process change. */ |
| 1766 | bgp_process (bgp, rn, afi, safi); |
| 1767 | |
| 1768 | return; |
| 1769 | |
| 1770 | filtered: |
| 1771 | |
| 1772 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 1773 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1774 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1775 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 1776 | peer->host, |
| 1777 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1778 | p->prefixlen, rsclient->host, reason); |
| 1779 | |
| 1780 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1781 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1782 | |
| 1783 | bgp_unlock_node (rn); |
| 1784 | |
| 1785 | return; |
| 1786 | } |
| 1787 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1788 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1789 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1790 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 1791 | struct prefix_rd *prd, u_char *tag) |
| 1792 | { |
| 1793 | struct bgp_node *rn; |
| 1794 | struct bgp_info *ri; |
| 1795 | char buf[SU_ADDRSTRLEN]; |
| 1796 | |
| 1797 | if (rsclient == peer) |
| 1798 | return; |
| 1799 | |
| 1800 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1801 | |
| 1802 | /* Lookup withdrawn route. */ |
| 1803 | for (ri = rn->info; ri; ri = ri->next) |
| 1804 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1805 | break; |
| 1806 | |
| 1807 | /* Withdraw specified route from routing table. */ |
| 1808 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1809 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1810 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1811 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1812 | "%s Can't find the route %s/%d", peer->host, |
| 1813 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1814 | p->prefixlen); |
| 1815 | |
| 1816 | /* Unlock bgp_node_get() lock. */ |
| 1817 | bgp_unlock_node (rn); |
| 1818 | } |
| 1819 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1820 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1821 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1822 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1823 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1824 | { |
| 1825 | int ret; |
| 1826 | int aspath_loop_count = 0; |
| 1827 | struct bgp_node *rn; |
| 1828 | struct bgp *bgp; |
| 1829 | struct attr new_attr; |
| 1830 | struct attr *attr_new; |
| 1831 | struct bgp_info *ri; |
| 1832 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1833 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1834 | char buf[SU_ADDRSTRLEN]; |
| 1835 | |
| 1836 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1837 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1838 | |
| 1839 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 1840 | Adj-RIBs-In. */ |
| 1841 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1842 | && peer != bgp->peer_self && ! soft_reconfig) |
| 1843 | bgp_adj_in_set (rn, peer, attr); |
| 1844 | |
| 1845 | /* Check previously received route. */ |
| 1846 | for (ri = rn->info; ri; ri = ri->next) |
| 1847 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1848 | break; |
| 1849 | |
| 1850 | /* AS path local-as loop check. */ |
| 1851 | if (peer->change_local_as) |
| 1852 | { |
| 1853 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 1854 | aspath_loop_count = 1; |
| 1855 | |
| 1856 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 1857 | { |
| 1858 | reason = "as-path contains our own AS;"; |
| 1859 | goto filtered; |
| 1860 | } |
| 1861 | } |
| 1862 | |
| 1863 | /* AS path loop check. */ |
| 1864 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 1865 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 1866 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 1867 | > peer->allowas_in[afi][safi])) |
| 1868 | { |
| 1869 | reason = "as-path contains our own AS;"; |
| 1870 | goto filtered; |
| 1871 | } |
| 1872 | |
| 1873 | /* Route reflector originator ID check. */ |
| 1874 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1875 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id)) |
| 1876 | { |
| 1877 | reason = "originator is us;"; |
| 1878 | goto filtered; |
| 1879 | } |
| 1880 | |
| 1881 | /* Route reflector cluster ID check. */ |
| 1882 | if (bgp_cluster_filter (peer, attr)) |
| 1883 | { |
| 1884 | reason = "reflected from the same cluster;"; |
| 1885 | goto filtered; |
| 1886 | } |
| 1887 | |
| 1888 | /* Apply incoming filter. */ |
| 1889 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 1890 | { |
| 1891 | reason = "filter;"; |
| 1892 | goto filtered; |
| 1893 | } |
| 1894 | |
| 1895 | /* Apply incoming route-map. */ |
| 1896 | new_attr = *attr; |
| 1897 | |
| 1898 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1899 | { |
| 1900 | reason = "route-map;"; |
| 1901 | goto filtered; |
| 1902 | } |
| 1903 | |
| 1904 | /* IPv4 unicast next hop check. */ |
| 1905 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1906 | { |
| 1907 | /* If the peer is EBGP and nexthop is not on connected route, |
| 1908 | discard it. */ |
| 1909 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
| 1910 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 1911 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1912 | { |
| 1913 | reason = "non-connected next-hop;"; |
| 1914 | goto filtered; |
| 1915 | } |
| 1916 | |
| 1917 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop |
| 1918 | must not be my own address. */ |
| 1919 | if (bgp_nexthop_self (afi, &new_attr) |
| 1920 | || new_attr.nexthop.s_addr == 0 |
| 1921 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1922 | { |
| 1923 | reason = "martian next-hop;"; |
| 1924 | goto filtered; |
| 1925 | } |
| 1926 | } |
| 1927 | |
| 1928 | attr_new = bgp_attr_intern (&new_attr); |
| 1929 | |
| 1930 | /* If the update is implicit withdraw. */ |
| 1931 | if (ri) |
| 1932 | { |
| 1933 | ri->uptime = time (NULL); |
| 1934 | |
| 1935 | /* Same attribute comes in. */ |
| 1936 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1937 | { |
| 1938 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1939 | |
| 1940 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1941 | && peer_sort (peer) == BGP_PEER_EBGP |
| 1942 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1943 | { |
| 1944 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1945 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1946 | peer->host, |
| 1947 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1948 | p->prefixlen); |
| 1949 | |
| 1950 | peer->pcount[afi][safi]++; |
| 1951 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 1952 | if (ret != BGP_DAMP_SUPPRESSED) |
| 1953 | { |
| 1954 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1955 | bgp_process (bgp, rn, afi, safi); |
| 1956 | } |
| 1957 | } |
| 1958 | else |
| 1959 | { |
| 1960 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1961 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1962 | "%s rcvd %s/%d...duplicate ignored", |
| 1963 | peer->host, |
| 1964 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1965 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 1966 | |
| 1967 | /* graceful restart STALE flag unset. */ |
| 1968 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 1969 | { |
| 1970 | UNSET_FLAG (ri->flags, BGP_INFO_STALE); |
| 1971 | peer->pcount[afi][safi]++; |
| 1972 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1973 | } |
| 1974 | |
| 1975 | bgp_unlock_node (rn); |
| 1976 | bgp_attr_unintern (attr_new); |
| 1977 | return 0; |
| 1978 | } |
| 1979 | |
| 1980 | /* Received Logging. */ |
| 1981 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1982 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1983 | peer->host, |
| 1984 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1985 | p->prefixlen); |
| 1986 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 1987 | /* graceful restart STALE flag unset. */ |
| 1988 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 1989 | { |
| 1990 | UNSET_FLAG (ri->flags, BGP_INFO_STALE); |
| 1991 | peer->pcount[afi][safi]++; |
| 1992 | } |
| 1993 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1994 | /* The attribute is changed. */ |
| 1995 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1996 | |
| 1997 | /* Update bgp route dampening information. */ |
| 1998 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1999 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2000 | { |
| 2001 | /* This is implicit withdraw so we should update dampening |
| 2002 | information. */ |
| 2003 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2004 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
| 2005 | else |
| 2006 | peer->pcount[afi][safi]++; |
| 2007 | } |
| 2008 | |
| 2009 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2010 | |
| 2011 | /* Update to new attribute. */ |
| 2012 | bgp_attr_unintern (ri->attr); |
| 2013 | ri->attr = attr_new; |
| 2014 | |
| 2015 | /* Update MPLS tag. */ |
| 2016 | if (safi == SAFI_MPLS_VPN) |
| 2017 | memcpy (ri->tag, tag, 3); |
| 2018 | |
| 2019 | /* Update bgp route dampening information. */ |
| 2020 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2021 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2022 | { |
| 2023 | /* Now we do normal update dampening. */ |
| 2024 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2025 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2026 | { |
| 2027 | bgp_unlock_node (rn); |
| 2028 | return 0; |
| 2029 | } |
| 2030 | } |
| 2031 | |
| 2032 | /* Nexthop reachability check. */ |
| 2033 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2034 | && safi == SAFI_UNICAST |
| 2035 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 2036 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2037 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2038 | { |
| 2039 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
| 2040 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2041 | else |
| 2042 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2043 | } |
| 2044 | else |
| 2045 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2046 | |
| 2047 | /* Process change. */ |
| 2048 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2049 | |
| 2050 | bgp_process (bgp, rn, afi, safi); |
| 2051 | bgp_unlock_node (rn); |
| 2052 | return 0; |
| 2053 | } |
| 2054 | |
| 2055 | /* Received Logging. */ |
| 2056 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2057 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2058 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2059 | peer->host, |
| 2060 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2061 | p->prefixlen); |
| 2062 | } |
| 2063 | |
| 2064 | /* Increment prefix counter */ |
| 2065 | peer->pcount[afi][safi]++; |
| 2066 | |
| 2067 | /* Make new BGP info. */ |
| 2068 | new = bgp_info_new (); |
| 2069 | new->type = type; |
| 2070 | new->sub_type = sub_type; |
| 2071 | new->peer = peer; |
| 2072 | new->attr = attr_new; |
| 2073 | new->uptime = time (NULL); |
| 2074 | |
| 2075 | /* Update MPLS tag. */ |
| 2076 | if (safi == SAFI_MPLS_VPN) |
| 2077 | memcpy (new->tag, tag, 3); |
| 2078 | |
| 2079 | /* Nexthop reachability check. */ |
| 2080 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2081 | && safi == SAFI_UNICAST |
| 2082 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 2083 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2084 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2085 | { |
| 2086 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
| 2087 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2088 | else |
| 2089 | UNSET_FLAG (new->flags, BGP_INFO_VALID); |
| 2090 | } |
| 2091 | else |
| 2092 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2093 | |
| 2094 | /* Aggregate address increment. */ |
| 2095 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2096 | |
| 2097 | /* Register new BGP information. */ |
| 2098 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2099 | |
| 2100 | /* route_node_get lock */ |
| 2101 | bgp_unlock_node (rn); |
| 2102 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2103 | /* If maximum prefix count is configured and current prefix |
| 2104 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2105 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2106 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2107 | |
| 2108 | /* Process change. */ |
| 2109 | bgp_process (bgp, rn, afi, safi); |
| 2110 | |
| 2111 | return 0; |
| 2112 | |
| 2113 | /* This BGP update is filtered. Log the reason then update BGP |
| 2114 | entry. */ |
| 2115 | filtered: |
| 2116 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2117 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2118 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2119 | peer->host, |
| 2120 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2121 | p->prefixlen, reason); |
| 2122 | |
| 2123 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2124 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2125 | |
| 2126 | bgp_unlock_node (rn); |
| 2127 | |
| 2128 | return 0; |
| 2129 | } |
| 2130 | |
| 2131 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2132 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2133 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2134 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2135 | { |
| 2136 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2137 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2138 | struct bgp *bgp; |
| 2139 | int ret; |
| 2140 | |
| 2141 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2142 | soft_reconfig); |
| 2143 | |
| 2144 | bgp = peer->bgp; |
| 2145 | |
| 2146 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2147 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2148 | { |
| 2149 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2150 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2151 | sub_type, prd, tag); |
| 2152 | } |
| 2153 | |
| 2154 | return ret; |
| 2155 | } |
| 2156 | |
| 2157 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2158 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2159 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2160 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2161 | { |
| 2162 | struct bgp *bgp; |
| 2163 | char buf[SU_ADDRSTRLEN]; |
| 2164 | struct bgp_node *rn; |
| 2165 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2166 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2167 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2168 | |
| 2169 | bgp = peer->bgp; |
| 2170 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2171 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2172 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2173 | { |
| 2174 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2175 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2176 | } |
| 2177 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2178 | /* Logging. */ |
| 2179 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2180 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2181 | peer->host, |
| 2182 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2183 | p->prefixlen); |
| 2184 | |
| 2185 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2186 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2187 | |
| 2188 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2189 | further calculation. */ |
| 2190 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2191 | && peer != bgp->peer_self) |
| 2192 | bgp_adj_in_unset (rn, peer); |
| 2193 | |
| 2194 | /* Lookup withdrawn route. */ |
| 2195 | for (ri = rn->info; ri; ri = ri->next) |
| 2196 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2197 | break; |
| 2198 | |
| 2199 | /* Withdraw specified route from routing table. */ |
| 2200 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2201 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2202 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2203 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2204 | "%s Can't find the route %s/%d", peer->host, |
| 2205 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2206 | p->prefixlen); |
| 2207 | |
| 2208 | /* Unlock bgp_node_get() lock. */ |
| 2209 | bgp_unlock_node (rn); |
| 2210 | |
| 2211 | return 0; |
| 2212 | } |
| 2213 | |
| 2214 | void |
| 2215 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2216 | { |
| 2217 | struct bgp *bgp; |
| 2218 | struct attr attr; |
| 2219 | struct aspath *aspath; |
| 2220 | struct prefix p; |
| 2221 | struct bgp_info binfo; |
| 2222 | struct peer *from; |
| 2223 | int ret = RMAP_DENYMATCH; |
| 2224 | |
| 2225 | bgp = peer->bgp; |
| 2226 | from = bgp->peer_self; |
| 2227 | |
| 2228 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2229 | aspath = attr.aspath; |
| 2230 | attr.local_pref = bgp->default_local_pref; |
| 2231 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2232 | |
| 2233 | if (afi == AFI_IP) |
| 2234 | str2prefix ("0.0.0.0/0", &p); |
| 2235 | #ifdef HAVE_IPV6 |
| 2236 | else if (afi == AFI_IP6) |
| 2237 | { |
| 2238 | str2prefix ("::/0", &p); |
| 2239 | |
| 2240 | /* IPv6 global nexthop must be included. */ |
| 2241 | memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global, |
| 2242 | IPV6_MAX_BYTELEN); |
| 2243 | attr.mp_nexthop_len = 16; |
| 2244 | |
| 2245 | /* If the peer is on shared nextwork and we have link-local |
| 2246 | nexthop set it. */ |
| 2247 | if (peer->shared_network |
| 2248 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2249 | { |
| 2250 | memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local, |
| 2251 | IPV6_MAX_BYTELEN); |
| 2252 | attr.mp_nexthop_len = 32; |
| 2253 | } |
| 2254 | } |
| 2255 | #endif /* HAVE_IPV6 */ |
| 2256 | else |
| 2257 | return; |
| 2258 | |
| 2259 | if (peer->default_rmap[afi][safi].name) |
| 2260 | { |
| 2261 | binfo.peer = bgp->peer_self; |
| 2262 | binfo.attr = &attr; |
| 2263 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2264 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2265 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2266 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2267 | RMAP_BGP, &binfo); |
| 2268 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2269 | bgp->peer_self->rmap_type = 0; |
| 2270 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2271 | if (ret == RMAP_DENYMATCH) |
| 2272 | { |
| 2273 | bgp_attr_flush (&attr); |
| 2274 | withdraw = 1; |
| 2275 | } |
| 2276 | } |
| 2277 | |
| 2278 | if (withdraw) |
| 2279 | { |
| 2280 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2281 | bgp_default_withdraw_send (peer, afi, safi); |
| 2282 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2283 | } |
| 2284 | else |
| 2285 | { |
| 2286 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2287 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2288 | } |
| 2289 | |
| 2290 | aspath_unintern (aspath); |
| 2291 | } |
| 2292 | |
| 2293 | static void |
| 2294 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2295 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2296 | { |
| 2297 | struct bgp_node *rn; |
| 2298 | struct bgp_info *ri; |
| 2299 | struct attr attr; |
| 2300 | |
| 2301 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2302 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2303 | |
| 2304 | if (safi != SAFI_MPLS_VPN |
| 2305 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2306 | bgp_default_originate (peer, afi, safi, 0); |
| 2307 | |
| 2308 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2309 | for (ri = rn->info; ri; ri = ri->next) |
| 2310 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2311 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2312 | if ( (rsclient) ? |
| 2313 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2314 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2315 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2316 | else |
| 2317 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2318 | } |
| 2319 | } |
| 2320 | |
| 2321 | void |
| 2322 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2323 | { |
| 2324 | struct bgp_node *rn; |
| 2325 | struct bgp_table *table; |
| 2326 | |
| 2327 | if (peer->status != Established) |
| 2328 | return; |
| 2329 | |
| 2330 | if (! peer->afc_nego[afi][safi]) |
| 2331 | return; |
| 2332 | |
| 2333 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2334 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2335 | return; |
| 2336 | |
| 2337 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2338 | bgp_announce_table (peer, afi, safi, NULL, 0); |
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_announce_table (peer, afi, safi, table, 0); |
| 2344 | |
| 2345 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2346 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2347 | } |
| 2348 | |
| 2349 | void |
| 2350 | bgp_announce_route_all (struct peer *peer) |
| 2351 | { |
| 2352 | afi_t afi; |
| 2353 | safi_t safi; |
| 2354 | |
| 2355 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2356 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2357 | bgp_announce_route (peer, afi, safi); |
| 2358 | } |
| 2359 | |
| 2360 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2361 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
| 2362 | safi_t safi, struct bgp_table *table) |
| 2363 | { |
| 2364 | struct bgp_node *rn; |
| 2365 | struct bgp_adj_in *ain; |
| 2366 | |
| 2367 | if (! table) |
| 2368 | table = rsclient->bgp->rib[afi][safi]; |
| 2369 | |
| 2370 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2371 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2372 | { |
| 2373 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
| 2374 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2375 | } |
| 2376 | } |
| 2377 | |
| 2378 | void |
| 2379 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2380 | { |
| 2381 | struct bgp_table *table; |
| 2382 | struct bgp_node *rn; |
| 2383 | |
| 2384 | if (safi != SAFI_MPLS_VPN) |
| 2385 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); |
| 2386 | |
| 2387 | else |
| 2388 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2389 | rn = bgp_route_next (rn)) |
| 2390 | if ((table = rn->info) != NULL) |
| 2391 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); |
| 2392 | } |
| 2393 | |
| 2394 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2395 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 2396 | struct bgp_table *table) |
| 2397 | { |
| 2398 | int ret; |
| 2399 | struct bgp_node *rn; |
| 2400 | struct bgp_adj_in *ain; |
| 2401 | |
| 2402 | if (! table) |
| 2403 | table = peer->bgp->rib[afi][safi]; |
| 2404 | |
| 2405 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2406 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2407 | { |
| 2408 | if (ain->peer == peer) |
| 2409 | { |
| 2410 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2411 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 2412 | NULL, NULL, 1); |
| 2413 | if (ret < 0) |
| 2414 | { |
| 2415 | bgp_unlock_node (rn); |
| 2416 | return; |
| 2417 | } |
| 2418 | continue; |
| 2419 | } |
| 2420 | } |
| 2421 | } |
| 2422 | |
| 2423 | void |
| 2424 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2425 | { |
| 2426 | struct bgp_node *rn; |
| 2427 | struct bgp_table *table; |
| 2428 | |
| 2429 | if (peer->status != Established) |
| 2430 | return; |
| 2431 | |
| 2432 | if (safi != SAFI_MPLS_VPN) |
| 2433 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 2434 | else |
| 2435 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2436 | rn = bgp_route_next (rn)) |
| 2437 | if ((table = rn->info) != NULL) |
| 2438 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 2439 | } |
| 2440 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2441 | struct bgp_clear_node_queue |
| 2442 | { |
| 2443 | struct bgp_node *rn; |
| 2444 | struct peer *peer; |
| 2445 | afi_t afi; |
| 2446 | safi_t safi; |
| 2447 | }; |
| 2448 | |
| 2449 | static wq_item_status |
| 2450 | bgp_clear_route_node (struct bgp_clear_node_queue *cq) |
| 2451 | { |
| 2452 | struct bgp_adj_in *ain; |
| 2453 | struct bgp_adj_out *aout; |
| 2454 | struct bgp_info *ri; |
| 2455 | |
| 2456 | assert (cq->rn && cq->peer); |
| 2457 | |
| 2458 | for (ri = cq->rn->info; ri; ri = ri->next) |
| 2459 | if (ri->peer == cq->peer) |
| 2460 | { |
| 2461 | /* graceful restart STALE flag set. */ |
| 2462 | if (CHECK_FLAG (cq->peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2463 | && cq->peer->nsf[cq->afi][cq->safi] |
| 2464 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
| 2465 | && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) |
| 2466 | && ! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
| 2467 | { |
| 2468 | SET_FLAG (ri->flags, BGP_INFO_STALE); |
| 2469 | cq->peer->pcount[cq->afi][cq->safi]--; |
| 2470 | } |
| 2471 | else |
| 2472 | bgp_rib_remove (cq->rn, ri, cq->peer, cq->afi, cq->safi); |
| 2473 | break; |
| 2474 | } |
| 2475 | for (ain = cq->rn->adj_in; ain; ain = ain->next) |
| 2476 | if (ain->peer == cq->peer) |
| 2477 | { |
| 2478 | bgp_adj_in_remove (cq->rn, ain); |
| 2479 | bgp_unlock_node (cq->rn); |
| 2480 | break; |
| 2481 | } |
| 2482 | for (aout = cq->rn->adj_out; aout; aout = aout->next) |
| 2483 | if (aout->peer == cq->peer) |
| 2484 | { |
| 2485 | bgp_adj_out_remove (cq->rn, aout, cq->peer, cq->afi, cq->safi); |
| 2486 | bgp_unlock_node (cq->rn); |
| 2487 | break; |
| 2488 | } |
| 2489 | return WQ_SUCCESS; |
| 2490 | } |
| 2491 | |
| 2492 | static void |
| 2493 | bgp_clear_node_queue_del (struct bgp_clear_node_queue *cq) |
| 2494 | { |
| 2495 | bgp_unlock_node (cq->rn); |
| 2496 | peer_unlock (cq->peer); /* bgp_clear_node_queue_del */ |
| 2497 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cq); |
| 2498 | } |
| 2499 | |
| 2500 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2501 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2502 | { |
| 2503 | /* unplug the 2 processing queues */ |
| 2504 | if (bm->process_main_queue) |
| 2505 | work_queue_unplug (bm->process_main_queue); |
| 2506 | if (bm->process_rsclient_queue) |
| 2507 | work_queue_unplug (bm->process_rsclient_queue); |
| 2508 | } |
| 2509 | |
| 2510 | static void |
| 2511 | bgp_clear_node_queue_init (void) |
| 2512 | { |
| 2513 | if ( (bm->clear_node_queue |
| 2514 | = work_queue_new (bm->master, "clear_route_node")) == NULL) |
| 2515 | { |
| 2516 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2517 | exit (1); |
| 2518 | } |
| 2519 | bm->clear_node_queue->spec.hold = 10; |
| 2520 | bm->clear_node_queue->spec.delay = 0; /* no gathering to be gained */ |
| 2521 | bm->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2522 | bm->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2523 | bm->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2524 | bm->clear_node_queue->spec.max_retries = 0; |
| 2525 | } |
| 2526 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2527 | static void |
| 2528 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2529 | struct bgp_table *table, struct peer *rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2530 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2531 | struct bgp_clear_node_queue *cqnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2532 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2533 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2534 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2535 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2536 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2537 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2538 | if (! table) |
| 2539 | return; |
| 2540 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2541 | if (bm->clear_node_queue == NULL) |
| 2542 | bgp_clear_node_queue_init (); |
| 2543 | |
| 2544 | /* plug the two bgp_process queues to avoid any chance of racing |
| 2545 | * with a session coming back up and adding routes before we've |
| 2546 | * cleared them all. We'll unplug them with completion callback. |
| 2547 | */ |
| 2548 | if (bm->process_main_queue) |
| 2549 | work_queue_plug (bm->process_main_queue); |
| 2550 | if (bm->process_rsclient_queue) |
| 2551 | work_queue_plug (bm->process_rsclient_queue); |
| 2552 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2553 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2554 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2555 | if (rn->info == NULL) |
| 2556 | continue; |
| 2557 | |
| 2558 | if ( (cqnode = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2559 | sizeof (struct bgp_clear_node_queue))) == NULL) |
| 2560 | continue; |
| 2561 | |
| 2562 | cqnode->rn = bgp_lock_node (rn); /* unlocked: bgp_clear_node_queue_del */ |
| 2563 | cqnode->afi = afi; |
| 2564 | cqnode->safi = safi; |
| 2565 | cqnode->peer = peer_lock (peer); /* bgp_clear_node_queue_del */ |
| 2566 | work_queue_add (bm->clear_node_queue, cqnode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2567 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2568 | return; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2569 | } |
| 2570 | |
| 2571 | void |
| 2572 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2573 | { |
| 2574 | struct bgp_node *rn; |
| 2575 | struct bgp_table *table; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2576 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2577 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2578 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2579 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2580 | bgp_clear_route_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2581 | else |
| 2582 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2583 | rn = bgp_route_next (rn)) |
| 2584 | if ((table = rn->info) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2585 | bgp_clear_route_table (peer, afi, safi, table, NULL); |
| 2586 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2587 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2588 | { |
| 2589 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2590 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient); |
| 2591 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2592 | } |
| 2593 | |
| 2594 | void |
| 2595 | bgp_clear_route_all (struct peer *peer) |
| 2596 | { |
| 2597 | afi_t afi; |
| 2598 | safi_t safi; |
| 2599 | |
| 2600 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2601 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2602 | bgp_clear_route (peer, afi, safi); |
| 2603 | } |
| 2604 | |
| 2605 | void |
| 2606 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2607 | { |
| 2608 | struct bgp_table *table; |
| 2609 | struct bgp_node *rn; |
| 2610 | struct bgp_adj_in *ain; |
| 2611 | |
| 2612 | table = peer->bgp->rib[afi][safi]; |
| 2613 | |
| 2614 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2615 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2616 | if (ain->peer == peer) |
| 2617 | { |
| 2618 | bgp_adj_in_remove (rn, ain); |
| 2619 | bgp_unlock_node (rn); |
| 2620 | break; |
| 2621 | } |
| 2622 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2623 | |
| 2624 | void |
| 2625 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2626 | { |
| 2627 | struct bgp_node *rn; |
| 2628 | struct bgp_info *ri; |
| 2629 | struct bgp_table *table; |
| 2630 | |
| 2631 | table = peer->bgp->rib[afi][safi]; |
| 2632 | |
| 2633 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2634 | { |
| 2635 | for (ri = rn->info; ri; ri = ri->next) |
| 2636 | if (ri->peer == peer) |
| 2637 | { |
| 2638 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2639 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 2640 | break; |
| 2641 | } |
| 2642 | } |
| 2643 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2644 | |
| 2645 | /* Delete all kernel routes. */ |
| 2646 | void |
paul | 545acaf | 2004-04-20 15:13:15 +0000 | [diff] [blame] | 2647 | bgp_cleanup_routes () |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2648 | { |
| 2649 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2650 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2651 | struct bgp_node *rn; |
| 2652 | struct bgp_table *table; |
| 2653 | struct bgp_info *ri; |
| 2654 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2655 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2656 | { |
| 2657 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 2658 | |
| 2659 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2660 | for (ri = rn->info; ri; ri = ri->next) |
| 2661 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2662 | && ri->type == ZEBRA_ROUTE_BGP |
| 2663 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2664 | bgp_zebra_withdraw (&rn->p, ri); |
| 2665 | |
| 2666 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 2667 | |
| 2668 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2669 | for (ri = rn->info; ri; ri = ri->next) |
| 2670 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2671 | && ri->type == ZEBRA_ROUTE_BGP |
| 2672 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2673 | bgp_zebra_withdraw (&rn->p, ri); |
| 2674 | } |
| 2675 | } |
| 2676 | |
| 2677 | void |
| 2678 | bgp_reset () |
| 2679 | { |
| 2680 | vty_reset (); |
| 2681 | bgp_zclient_reset (); |
| 2682 | access_list_reset (); |
| 2683 | prefix_list_reset (); |
| 2684 | } |
| 2685 | |
| 2686 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 2687 | value. */ |
| 2688 | int |
| 2689 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 2690 | { |
| 2691 | u_char *pnt; |
| 2692 | u_char *lim; |
| 2693 | struct prefix p; |
| 2694 | int psize; |
| 2695 | int ret; |
| 2696 | |
| 2697 | /* Check peer status. */ |
| 2698 | if (peer->status != Established) |
| 2699 | return 0; |
| 2700 | |
| 2701 | pnt = packet->nlri; |
| 2702 | lim = pnt + packet->length; |
| 2703 | |
| 2704 | for (; pnt < lim; pnt += psize) |
| 2705 | { |
| 2706 | /* Clear prefix structure. */ |
| 2707 | memset (&p, 0, sizeof (struct prefix)); |
| 2708 | |
| 2709 | /* Fetch prefix length. */ |
| 2710 | p.prefixlen = *pnt++; |
| 2711 | p.family = afi2family (packet->afi); |
| 2712 | |
| 2713 | /* Already checked in nlri_sanity_check(). We do double check |
| 2714 | here. */ |
| 2715 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 2716 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 2717 | return -1; |
| 2718 | |
| 2719 | /* Packet size overflow check. */ |
| 2720 | psize = PSIZE (p.prefixlen); |
| 2721 | |
| 2722 | /* When packet overflow occur return immediately. */ |
| 2723 | if (pnt + psize > lim) |
| 2724 | return -1; |
| 2725 | |
| 2726 | /* Fetch prefix from NLRI packet. */ |
| 2727 | memcpy (&p.u.prefix, pnt, psize); |
| 2728 | |
| 2729 | /* Check address. */ |
| 2730 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 2731 | { |
| 2732 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 2733 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2734 | /* |
| 2735 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 2736 | * If a BGP router receives an UPDATE message with a |
| 2737 | * semantically incorrect NLRI field, in which a prefix is |
| 2738 | * semantically incorrect (eg. an unexpected multicast IP |
| 2739 | * address), it should ignore the prefix. |
| 2740 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2741 | zlog (peer->log, LOG_ERR, |
| 2742 | "IPv4 unicast NLRI is multicast address %s", |
| 2743 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2744 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2745 | return -1; |
| 2746 | } |
| 2747 | } |
| 2748 | |
| 2749 | #ifdef HAVE_IPV6 |
| 2750 | /* Check address. */ |
| 2751 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 2752 | { |
| 2753 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2754 | { |
| 2755 | char buf[BUFSIZ]; |
| 2756 | |
| 2757 | zlog (peer->log, LOG_WARNING, |
| 2758 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 2759 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 2760 | |
| 2761 | continue; |
| 2762 | } |
| 2763 | } |
| 2764 | #endif /* HAVE_IPV6 */ |
| 2765 | |
| 2766 | /* Normal process. */ |
| 2767 | if (attr) |
| 2768 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 2769 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 2770 | else |
| 2771 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 2772 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2773 | |
| 2774 | /* Address family configuration mismatch or maximum-prefix count |
| 2775 | overflow. */ |
| 2776 | if (ret < 0) |
| 2777 | return -1; |
| 2778 | } |
| 2779 | |
| 2780 | /* Packet length consistency check. */ |
| 2781 | if (pnt != lim) |
| 2782 | return -1; |
| 2783 | |
| 2784 | return 0; |
| 2785 | } |
| 2786 | |
| 2787 | /* NLRI encode syntax check routine. */ |
| 2788 | int |
| 2789 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 2790 | bgp_size_t length) |
| 2791 | { |
| 2792 | u_char *end; |
| 2793 | u_char prefixlen; |
| 2794 | int psize; |
| 2795 | |
| 2796 | end = pnt + length; |
| 2797 | |
| 2798 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 2799 | syntactic validity. If the field is syntactically incorrect, |
| 2800 | then the Error Subcode is set to Invalid Network Field. */ |
| 2801 | |
| 2802 | while (pnt < end) |
| 2803 | { |
| 2804 | prefixlen = *pnt++; |
| 2805 | |
| 2806 | /* Prefix length check. */ |
| 2807 | if ((afi == AFI_IP && prefixlen > 32) |
| 2808 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 2809 | { |
| 2810 | plog_err (peer->log, |
| 2811 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 2812 | peer->host, prefixlen); |
| 2813 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2814 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2815 | return -1; |
| 2816 | } |
| 2817 | |
| 2818 | /* Packet size overflow check. */ |
| 2819 | psize = PSIZE (prefixlen); |
| 2820 | |
| 2821 | if (pnt + psize > end) |
| 2822 | { |
| 2823 | plog_err (peer->log, |
| 2824 | "%s [Error] Update packet error" |
| 2825 | " (prefix data overflow prefix size is %d)", |
| 2826 | peer->host, psize); |
| 2827 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2828 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2829 | return -1; |
| 2830 | } |
| 2831 | |
| 2832 | pnt += psize; |
| 2833 | } |
| 2834 | |
| 2835 | /* Packet length consistency check. */ |
| 2836 | if (pnt != end) |
| 2837 | { |
| 2838 | plog_err (peer->log, |
| 2839 | "%s [Error] Update packet error" |
| 2840 | " (prefix length mismatch with total length)", |
| 2841 | peer->host); |
| 2842 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2843 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2844 | return -1; |
| 2845 | } |
| 2846 | return 0; |
| 2847 | } |
| 2848 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2849 | static struct bgp_static * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2850 | bgp_static_new () |
| 2851 | { |
| 2852 | struct bgp_static *new; |
| 2853 | new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
| 2854 | memset (new, 0, sizeof (struct bgp_static)); |
| 2855 | return new; |
| 2856 | } |
| 2857 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2858 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2859 | bgp_static_free (struct bgp_static *bgp_static) |
| 2860 | { |
| 2861 | if (bgp_static->rmap.name) |
| 2862 | free (bgp_static->rmap.name); |
| 2863 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 2864 | } |
| 2865 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2866 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2867 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 2868 | struct prefix *p, afi_t afi, safi_t safi) |
| 2869 | { |
| 2870 | struct bgp_node *rn; |
| 2871 | struct bgp_info *ri; |
| 2872 | |
| 2873 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2874 | |
| 2875 | /* Check selected route and self inserted route. */ |
| 2876 | for (ri = rn->info; ri; ri = ri->next) |
| 2877 | if (ri->peer == bgp->peer_self |
| 2878 | && ri->type == ZEBRA_ROUTE_BGP |
| 2879 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2880 | break; |
| 2881 | |
| 2882 | /* Withdraw static BGP route from routing table. */ |
| 2883 | if (ri) |
| 2884 | { |
| 2885 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2886 | bgp_process (bgp, rn, afi, safi); |
| 2887 | bgp_info_delete (rn, ri); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2888 | } |
| 2889 | |
| 2890 | /* Unlock bgp_node_lookup. */ |
| 2891 | bgp_unlock_node (rn); |
| 2892 | } |
| 2893 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2894 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2895 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
| 2896 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2897 | { |
| 2898 | struct bgp_node *rn; |
| 2899 | struct bgp_info *ri; |
| 2900 | struct bgp_info *new; |
| 2901 | struct bgp_info info; |
| 2902 | struct attr new_attr; |
| 2903 | struct attr *attr_new; |
| 2904 | struct attr attr; |
| 2905 | struct bgp *bgp; |
| 2906 | int ret; |
| 2907 | char buf[SU_ADDRSTRLEN]; |
| 2908 | |
| 2909 | bgp = rsclient->bgp; |
| 2910 | |
| 2911 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2912 | |
| 2913 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2914 | if (bgp_static) |
| 2915 | { |
| 2916 | attr.nexthop = bgp_static->igpnexthop; |
| 2917 | attr.med = bgp_static->igpmetric; |
| 2918 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 2919 | } |
| 2920 | |
| 2921 | new_attr = attr; |
| 2922 | |
| 2923 | /* Apply network route-map for export to this rsclient. */ |
| 2924 | if (bgp_static->rmap.name) |
| 2925 | { |
| 2926 | info.peer = rsclient; |
| 2927 | info.attr = &new_attr; |
| 2928 | |
| 2929 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 2930 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2931 | |
| 2932 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 2933 | |
| 2934 | rsclient->rmap_type = 0; |
| 2935 | |
| 2936 | if (ret == RMAP_DENYMATCH) |
| 2937 | { |
| 2938 | /* Free uninterned attribute. */ |
| 2939 | bgp_attr_flush (&new_attr); |
| 2940 | |
| 2941 | /* Unintern original. */ |
| 2942 | aspath_unintern (attr.aspath); |
| 2943 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2944 | |
| 2945 | return; |
| 2946 | } |
| 2947 | attr_new = bgp_attr_intern (&new_attr); |
| 2948 | } |
| 2949 | else |
| 2950 | attr_new = bgp_attr_intern (&attr); |
| 2951 | |
| 2952 | new_attr = *attr_new; |
| 2953 | |
| 2954 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2955 | |
| 2956 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2957 | { |
| 2958 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2959 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2960 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2961 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 2962 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2963 | p->prefixlen, rsclient->host); |
| 2964 | |
| 2965 | bgp->peer_self->rmap_type = 0; |
| 2966 | |
| 2967 | bgp_attr_unintern (attr_new); |
| 2968 | aspath_unintern (attr.aspath); |
| 2969 | |
| 2970 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2971 | |
| 2972 | return; |
| 2973 | } |
| 2974 | |
| 2975 | bgp->peer_self->rmap_type = 0; |
| 2976 | |
| 2977 | bgp_attr_unintern (attr_new); |
| 2978 | attr_new = bgp_attr_intern (&new_attr); |
| 2979 | |
| 2980 | for (ri = rn->info; ri; ri = ri->next) |
| 2981 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 2982 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2983 | break; |
| 2984 | |
| 2985 | if (ri) |
| 2986 | { |
| 2987 | if (attrhash_cmp (ri->attr, attr_new)) |
| 2988 | { |
| 2989 | bgp_unlock_node (rn); |
| 2990 | bgp_attr_unintern (attr_new); |
| 2991 | aspath_unintern (attr.aspath); |
| 2992 | return; |
| 2993 | } |
| 2994 | else |
| 2995 | { |
| 2996 | /* The attribute is changed. */ |
| 2997 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 2998 | |
| 2999 | /* Rewrite BGP route information. */ |
| 3000 | bgp_attr_unintern (ri->attr); |
| 3001 | ri->attr = attr_new; |
| 3002 | ri->uptime = time (NULL); |
| 3003 | |
| 3004 | /* Process change. */ |
| 3005 | bgp_process (bgp, rn, afi, safi); |
| 3006 | bgp_unlock_node (rn); |
| 3007 | aspath_unintern (attr.aspath); |
| 3008 | return; |
| 3009 | } |
| 3010 | } |
| 3011 | |
| 3012 | /* Make new BGP info. */ |
| 3013 | new = bgp_info_new (); |
| 3014 | new->type = ZEBRA_ROUTE_BGP; |
| 3015 | new->sub_type = BGP_ROUTE_STATIC; |
| 3016 | new->peer = bgp->peer_self; |
| 3017 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3018 | new->attr = attr_new; |
| 3019 | new->uptime = time (NULL); |
| 3020 | |
| 3021 | /* Register new BGP information. */ |
| 3022 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3023 | |
| 3024 | /* route_node_get lock */ |
| 3025 | bgp_unlock_node (rn); |
| 3026 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3027 | /* Process change. */ |
| 3028 | bgp_process (bgp, rn, afi, safi); |
| 3029 | |
| 3030 | /* Unintern original. */ |
| 3031 | aspath_unintern (attr.aspath); |
| 3032 | } |
| 3033 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3034 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3035 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3036 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3037 | { |
| 3038 | struct bgp_node *rn; |
| 3039 | struct bgp_info *ri; |
| 3040 | struct bgp_info *new; |
| 3041 | struct bgp_info info; |
| 3042 | struct attr attr; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3043 | struct attr attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3044 | struct attr *attr_new; |
| 3045 | int ret; |
| 3046 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3047 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3048 | |
| 3049 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 3050 | if (bgp_static) |
| 3051 | { |
| 3052 | attr.nexthop = bgp_static->igpnexthop; |
| 3053 | attr.med = bgp_static->igpmetric; |
| 3054 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3055 | } |
| 3056 | |
| 3057 | /* Apply route-map. */ |
| 3058 | if (bgp_static->rmap.name) |
| 3059 | { |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3060 | attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3061 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3062 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3063 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3064 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3065 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3066 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3067 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3068 | bgp->peer_self->rmap_type = 0; |
| 3069 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3070 | if (ret == RMAP_DENYMATCH) |
| 3071 | { |
| 3072 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3073 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3074 | |
| 3075 | /* Unintern original. */ |
| 3076 | aspath_unintern (attr.aspath); |
| 3077 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3078 | return; |
| 3079 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3080 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3081 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3082 | else |
| 3083 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3084 | |
| 3085 | for (ri = rn->info; ri; ri = ri->next) |
| 3086 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3087 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3088 | break; |
| 3089 | |
| 3090 | if (ri) |
| 3091 | { |
| 3092 | if (attrhash_cmp (ri->attr, attr_new)) |
| 3093 | { |
| 3094 | bgp_unlock_node (rn); |
| 3095 | bgp_attr_unintern (attr_new); |
| 3096 | aspath_unintern (attr.aspath); |
| 3097 | return; |
| 3098 | } |
| 3099 | else |
| 3100 | { |
| 3101 | /* The attribute is changed. */ |
| 3102 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3103 | |
| 3104 | /* Rewrite BGP route information. */ |
| 3105 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3106 | bgp_attr_unintern (ri->attr); |
| 3107 | ri->attr = attr_new; |
| 3108 | ri->uptime = time (NULL); |
| 3109 | |
| 3110 | /* Process change. */ |
| 3111 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3112 | bgp_process (bgp, rn, afi, safi); |
| 3113 | bgp_unlock_node (rn); |
| 3114 | aspath_unintern (attr.aspath); |
| 3115 | return; |
| 3116 | } |
| 3117 | } |
| 3118 | |
| 3119 | /* Make new BGP info. */ |
| 3120 | new = bgp_info_new (); |
| 3121 | new->type = ZEBRA_ROUTE_BGP; |
| 3122 | new->sub_type = BGP_ROUTE_STATIC; |
| 3123 | new->peer = bgp->peer_self; |
| 3124 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3125 | new->attr = attr_new; |
| 3126 | new->uptime = time (NULL); |
| 3127 | |
| 3128 | /* Aggregate address increment. */ |
| 3129 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3130 | |
| 3131 | /* Register new BGP information. */ |
| 3132 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3133 | |
| 3134 | /* route_node_get lock */ |
| 3135 | bgp_unlock_node (rn); |
| 3136 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3137 | /* Process change. */ |
| 3138 | bgp_process (bgp, rn, afi, safi); |
| 3139 | |
| 3140 | /* Unintern original. */ |
| 3141 | aspath_unintern (attr.aspath); |
| 3142 | } |
| 3143 | |
| 3144 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3145 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3146 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3147 | { |
| 3148 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3149 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3150 | |
| 3151 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3152 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3153 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3154 | { |
| 3155 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
| 3156 | } |
| 3157 | } |
| 3158 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3159 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3160 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 3161 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 3162 | { |
| 3163 | struct bgp_node *rn; |
| 3164 | struct bgp_info *new; |
| 3165 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3166 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3167 | |
| 3168 | /* Make new BGP info. */ |
| 3169 | new = bgp_info_new (); |
| 3170 | new->type = ZEBRA_ROUTE_BGP; |
| 3171 | new->sub_type = BGP_ROUTE_STATIC; |
| 3172 | new->peer = bgp->peer_self; |
| 3173 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3174 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3175 | new->uptime = time (NULL); |
| 3176 | memcpy (new->tag, tag, 3); |
| 3177 | |
| 3178 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3179 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3180 | |
| 3181 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3182 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3183 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3184 | /* route_node_get lock */ |
| 3185 | bgp_unlock_node (rn); |
| 3186 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3187 | /* Process change. */ |
| 3188 | bgp_process (bgp, rn, afi, safi); |
| 3189 | } |
| 3190 | |
| 3191 | void |
| 3192 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3193 | safi_t safi) |
| 3194 | { |
| 3195 | struct bgp_node *rn; |
| 3196 | struct bgp_info *ri; |
| 3197 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3198 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3199 | |
| 3200 | /* Check selected route and self inserted route. */ |
| 3201 | for (ri = rn->info; ri; ri = ri->next) |
| 3202 | if (ri->peer == bgp->peer_self |
| 3203 | && ri->type == ZEBRA_ROUTE_BGP |
| 3204 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3205 | break; |
| 3206 | |
| 3207 | /* Withdraw static BGP route from routing table. */ |
| 3208 | if (ri) |
| 3209 | { |
| 3210 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3211 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 3212 | bgp_process (bgp, rn, afi, safi); |
| 3213 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3214 | } |
| 3215 | |
| 3216 | /* Unlock bgp_node_lookup. */ |
| 3217 | bgp_unlock_node (rn); |
| 3218 | } |
| 3219 | |
| 3220 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3221 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3222 | { |
| 3223 | struct bgp_static *bgp_static; |
| 3224 | struct bgp *bgp; |
| 3225 | struct bgp_node *rn; |
| 3226 | struct prefix *p; |
| 3227 | |
| 3228 | bgp = rsclient->bgp; |
| 3229 | |
| 3230 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3231 | if ((bgp_static = rn->info) != NULL) |
| 3232 | { |
| 3233 | p = &rn->p; |
| 3234 | |
| 3235 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3236 | afi, safi); |
| 3237 | } |
| 3238 | } |
| 3239 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3240 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3241 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 3242 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 3243 | { |
| 3244 | struct bgp_node *rn; |
| 3245 | struct bgp_info *ri; |
| 3246 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3247 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3248 | |
| 3249 | /* Check selected route and self inserted route. */ |
| 3250 | for (ri = rn->info; ri; ri = ri->next) |
| 3251 | if (ri->peer == bgp->peer_self |
| 3252 | && ri->type == ZEBRA_ROUTE_BGP |
| 3253 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3254 | break; |
| 3255 | |
| 3256 | /* Withdraw static BGP route from routing table. */ |
| 3257 | if (ri) |
| 3258 | { |
| 3259 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3260 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 3261 | bgp_process (bgp, rn, afi, safi); |
| 3262 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3263 | } |
| 3264 | |
| 3265 | /* Unlock bgp_node_lookup. */ |
| 3266 | bgp_unlock_node (rn); |
| 3267 | } |
| 3268 | |
| 3269 | /* Configure static BGP network. When user don't run zebra, static |
| 3270 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3271 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3272 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
| 3273 | u_int16_t afi, u_char safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3274 | { |
| 3275 | int ret; |
| 3276 | struct prefix p; |
| 3277 | struct bgp_static *bgp_static; |
| 3278 | struct bgp_node *rn; |
| 3279 | int need_update = 0; |
| 3280 | |
| 3281 | /* Convert IP prefix string to struct prefix. */ |
| 3282 | ret = str2prefix (ip_str, &p); |
| 3283 | if (! ret) |
| 3284 | { |
| 3285 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3286 | return CMD_WARNING; |
| 3287 | } |
| 3288 | #ifdef HAVE_IPV6 |
| 3289 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3290 | { |
| 3291 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3292 | VTY_NEWLINE); |
| 3293 | return CMD_WARNING; |
| 3294 | } |
| 3295 | #endif /* HAVE_IPV6 */ |
| 3296 | |
| 3297 | apply_mask (&p); |
| 3298 | |
| 3299 | /* Set BGP static route configuration. */ |
| 3300 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3301 | |
| 3302 | if (rn->info) |
| 3303 | { |
| 3304 | /* Configuration change. */ |
| 3305 | bgp_static = rn->info; |
| 3306 | |
| 3307 | /* Check previous routes are installed into BGP. */ |
| 3308 | if (! bgp_static->backdoor && bgp_static->valid) |
| 3309 | need_update = 1; |
| 3310 | |
| 3311 | bgp_static->backdoor = backdoor; |
| 3312 | if (rmap) |
| 3313 | { |
| 3314 | if (bgp_static->rmap.name) |
| 3315 | free (bgp_static->rmap.name); |
| 3316 | bgp_static->rmap.name = strdup (rmap); |
| 3317 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3318 | } |
| 3319 | else |
| 3320 | { |
| 3321 | if (bgp_static->rmap.name) |
| 3322 | free (bgp_static->rmap.name); |
| 3323 | bgp_static->rmap.name = NULL; |
| 3324 | bgp_static->rmap.map = NULL; |
| 3325 | bgp_static->valid = 0; |
| 3326 | } |
| 3327 | bgp_unlock_node (rn); |
| 3328 | } |
| 3329 | else |
| 3330 | { |
| 3331 | /* New configuration. */ |
| 3332 | bgp_static = bgp_static_new (); |
| 3333 | bgp_static->backdoor = backdoor; |
| 3334 | bgp_static->valid = 0; |
| 3335 | bgp_static->igpmetric = 0; |
| 3336 | bgp_static->igpnexthop.s_addr = 0; |
| 3337 | if (rmap) |
| 3338 | { |
| 3339 | if (bgp_static->rmap.name) |
| 3340 | free (bgp_static->rmap.name); |
| 3341 | bgp_static->rmap.name = strdup (rmap); |
| 3342 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3343 | } |
| 3344 | rn->info = bgp_static; |
| 3345 | } |
| 3346 | |
| 3347 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3348 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3349 | { |
| 3350 | bgp_static->valid = 1; |
| 3351 | |
| 3352 | if (need_update) |
| 3353 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3354 | |
| 3355 | if (! bgp_static->backdoor) |
| 3356 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3357 | } |
| 3358 | |
| 3359 | return CMD_SUCCESS; |
| 3360 | } |
| 3361 | |
| 3362 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3363 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3364 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3365 | u_int16_t afi, u_char safi) |
| 3366 | { |
| 3367 | int ret; |
| 3368 | struct prefix p; |
| 3369 | struct bgp_static *bgp_static; |
| 3370 | struct bgp_node *rn; |
| 3371 | |
| 3372 | /* Convert IP prefix string to struct prefix. */ |
| 3373 | ret = str2prefix (ip_str, &p); |
| 3374 | if (! ret) |
| 3375 | { |
| 3376 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3377 | return CMD_WARNING; |
| 3378 | } |
| 3379 | #ifdef HAVE_IPV6 |
| 3380 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3381 | { |
| 3382 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3383 | VTY_NEWLINE); |
| 3384 | return CMD_WARNING; |
| 3385 | } |
| 3386 | #endif /* HAVE_IPV6 */ |
| 3387 | |
| 3388 | apply_mask (&p); |
| 3389 | |
| 3390 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3391 | if (! rn) |
| 3392 | { |
| 3393 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3394 | VTY_NEWLINE); |
| 3395 | return CMD_WARNING; |
| 3396 | } |
| 3397 | |
| 3398 | bgp_static = rn->info; |
| 3399 | |
| 3400 | /* Update BGP RIB. */ |
| 3401 | if (! bgp_static->backdoor) |
| 3402 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3403 | |
| 3404 | /* Clear configuration. */ |
| 3405 | bgp_static_free (bgp_static); |
| 3406 | rn->info = NULL; |
| 3407 | bgp_unlock_node (rn); |
| 3408 | bgp_unlock_node (rn); |
| 3409 | |
| 3410 | return CMD_SUCCESS; |
| 3411 | } |
| 3412 | |
| 3413 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3414 | instance. */ |
| 3415 | void |
| 3416 | bgp_static_delete (struct bgp *bgp) |
| 3417 | { |
| 3418 | afi_t afi; |
| 3419 | safi_t safi; |
| 3420 | struct bgp_node *rn; |
| 3421 | struct bgp_node *rm; |
| 3422 | struct bgp_table *table; |
| 3423 | struct bgp_static *bgp_static; |
| 3424 | |
| 3425 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3426 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3427 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3428 | if (rn->info != NULL) |
| 3429 | { |
| 3430 | if (safi == SAFI_MPLS_VPN) |
| 3431 | { |
| 3432 | table = rn->info; |
| 3433 | |
| 3434 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3435 | { |
| 3436 | bgp_static = rn->info; |
| 3437 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3438 | AFI_IP, SAFI_MPLS_VPN, |
| 3439 | (struct prefix_rd *)&rn->p, |
| 3440 | bgp_static->tag); |
| 3441 | bgp_static_free (bgp_static); |
| 3442 | rn->info = NULL; |
| 3443 | bgp_unlock_node (rn); |
| 3444 | } |
| 3445 | } |
| 3446 | else |
| 3447 | { |
| 3448 | bgp_static = rn->info; |
| 3449 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3450 | bgp_static_free (bgp_static); |
| 3451 | rn->info = NULL; |
| 3452 | bgp_unlock_node (rn); |
| 3453 | } |
| 3454 | } |
| 3455 | } |
| 3456 | |
| 3457 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3458 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3459 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3460 | { |
| 3461 | int ret; |
| 3462 | struct prefix p; |
| 3463 | struct prefix_rd prd; |
| 3464 | struct bgp *bgp; |
| 3465 | struct bgp_node *prn; |
| 3466 | struct bgp_node *rn; |
| 3467 | struct bgp_table *table; |
| 3468 | struct bgp_static *bgp_static; |
| 3469 | u_char tag[3]; |
| 3470 | |
| 3471 | bgp = vty->index; |
| 3472 | |
| 3473 | ret = str2prefix (ip_str, &p); |
| 3474 | if (! ret) |
| 3475 | { |
| 3476 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3477 | return CMD_WARNING; |
| 3478 | } |
| 3479 | apply_mask (&p); |
| 3480 | |
| 3481 | ret = str2prefix_rd (rd_str, &prd); |
| 3482 | if (! ret) |
| 3483 | { |
| 3484 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3485 | return CMD_WARNING; |
| 3486 | } |
| 3487 | |
| 3488 | ret = str2tag (tag_str, tag); |
| 3489 | if (! ret) |
| 3490 | { |
| 3491 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3492 | return CMD_WARNING; |
| 3493 | } |
| 3494 | |
| 3495 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3496 | (struct prefix *)&prd); |
| 3497 | if (prn->info == NULL) |
| 3498 | prn->info = bgp_table_init (); |
| 3499 | else |
| 3500 | bgp_unlock_node (prn); |
| 3501 | table = prn->info; |
| 3502 | |
| 3503 | rn = bgp_node_get (table, &p); |
| 3504 | |
| 3505 | if (rn->info) |
| 3506 | { |
| 3507 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3508 | bgp_unlock_node (rn); |
| 3509 | } |
| 3510 | else |
| 3511 | { |
| 3512 | /* New configuration. */ |
| 3513 | bgp_static = bgp_static_new (); |
| 3514 | bgp_static->valid = 1; |
| 3515 | memcpy (bgp_static->tag, tag, 3); |
| 3516 | rn->info = bgp_static; |
| 3517 | |
| 3518 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3519 | } |
| 3520 | |
| 3521 | return CMD_SUCCESS; |
| 3522 | } |
| 3523 | |
| 3524 | /* Configure static BGP network. */ |
| 3525 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3526 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3527 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3528 | { |
| 3529 | int ret; |
| 3530 | struct bgp *bgp; |
| 3531 | struct prefix p; |
| 3532 | struct prefix_rd prd; |
| 3533 | struct bgp_node *prn; |
| 3534 | struct bgp_node *rn; |
| 3535 | struct bgp_table *table; |
| 3536 | struct bgp_static *bgp_static; |
| 3537 | u_char tag[3]; |
| 3538 | |
| 3539 | bgp = vty->index; |
| 3540 | |
| 3541 | /* Convert IP prefix string to struct prefix. */ |
| 3542 | ret = str2prefix (ip_str, &p); |
| 3543 | if (! ret) |
| 3544 | { |
| 3545 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3546 | return CMD_WARNING; |
| 3547 | } |
| 3548 | apply_mask (&p); |
| 3549 | |
| 3550 | ret = str2prefix_rd (rd_str, &prd); |
| 3551 | if (! ret) |
| 3552 | { |
| 3553 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3554 | return CMD_WARNING; |
| 3555 | } |
| 3556 | |
| 3557 | ret = str2tag (tag_str, tag); |
| 3558 | if (! ret) |
| 3559 | { |
| 3560 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3561 | return CMD_WARNING; |
| 3562 | } |
| 3563 | |
| 3564 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3565 | (struct prefix *)&prd); |
| 3566 | if (prn->info == NULL) |
| 3567 | prn->info = bgp_table_init (); |
| 3568 | else |
| 3569 | bgp_unlock_node (prn); |
| 3570 | table = prn->info; |
| 3571 | |
| 3572 | rn = bgp_node_lookup (table, &p); |
| 3573 | |
| 3574 | if (rn) |
| 3575 | { |
| 3576 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3577 | |
| 3578 | bgp_static = rn->info; |
| 3579 | bgp_static_free (bgp_static); |
| 3580 | rn->info = NULL; |
| 3581 | bgp_unlock_node (rn); |
| 3582 | bgp_unlock_node (rn); |
| 3583 | } |
| 3584 | else |
| 3585 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3586 | |
| 3587 | return CMD_SUCCESS; |
| 3588 | } |
| 3589 | |
| 3590 | DEFUN (bgp_network, |
| 3591 | bgp_network_cmd, |
| 3592 | "network A.B.C.D/M", |
| 3593 | "Specify a network to announce via BGP\n" |
| 3594 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3595 | { |
| 3596 | return bgp_static_set (vty, vty->index, argv[0], |
| 3597 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3598 | } |
| 3599 | |
| 3600 | DEFUN (bgp_network_route_map, |
| 3601 | bgp_network_route_map_cmd, |
| 3602 | "network A.B.C.D/M route-map WORD", |
| 3603 | "Specify a network to announce via BGP\n" |
| 3604 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3605 | "Route-map to modify the attributes\n" |
| 3606 | "Name of the route map\n") |
| 3607 | { |
| 3608 | return bgp_static_set (vty, vty->index, argv[0], |
| 3609 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3610 | } |
| 3611 | |
| 3612 | DEFUN (bgp_network_backdoor, |
| 3613 | bgp_network_backdoor_cmd, |
| 3614 | "network A.B.C.D/M backdoor", |
| 3615 | "Specify a network to announce via BGP\n" |
| 3616 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3617 | "Specify a BGP backdoor route\n") |
| 3618 | { |
| 3619 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3620 | } |
| 3621 | |
| 3622 | DEFUN (bgp_network_mask, |
| 3623 | bgp_network_mask_cmd, |
| 3624 | "network A.B.C.D mask A.B.C.D", |
| 3625 | "Specify a network to announce via BGP\n" |
| 3626 | "Network number\n" |
| 3627 | "Network mask\n" |
| 3628 | "Network mask\n") |
| 3629 | { |
| 3630 | int ret; |
| 3631 | char prefix_str[BUFSIZ]; |
| 3632 | |
| 3633 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3634 | if (! ret) |
| 3635 | { |
| 3636 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3637 | return CMD_WARNING; |
| 3638 | } |
| 3639 | |
| 3640 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3641 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3642 | } |
| 3643 | |
| 3644 | DEFUN (bgp_network_mask_route_map, |
| 3645 | bgp_network_mask_route_map_cmd, |
| 3646 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 3647 | "Specify a network to announce via BGP\n" |
| 3648 | "Network number\n" |
| 3649 | "Network mask\n" |
| 3650 | "Network mask\n" |
| 3651 | "Route-map to modify the attributes\n" |
| 3652 | "Name of the route map\n") |
| 3653 | { |
| 3654 | int ret; |
| 3655 | char prefix_str[BUFSIZ]; |
| 3656 | |
| 3657 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3658 | if (! ret) |
| 3659 | { |
| 3660 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3661 | return CMD_WARNING; |
| 3662 | } |
| 3663 | |
| 3664 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3665 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
| 3666 | } |
| 3667 | |
| 3668 | DEFUN (bgp_network_mask_backdoor, |
| 3669 | bgp_network_mask_backdoor_cmd, |
| 3670 | "network A.B.C.D mask A.B.C.D backdoor", |
| 3671 | "Specify a network to announce via BGP\n" |
| 3672 | "Network number\n" |
| 3673 | "Network mask\n" |
| 3674 | "Network mask\n" |
| 3675 | "Specify a BGP backdoor route\n") |
| 3676 | { |
| 3677 | int ret; |
| 3678 | char prefix_str[BUFSIZ]; |
| 3679 | |
| 3680 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3681 | if (! ret) |
| 3682 | { |
| 3683 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3684 | return CMD_WARNING; |
| 3685 | } |
| 3686 | |
| 3687 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3688 | } |
| 3689 | |
| 3690 | DEFUN (bgp_network_mask_natural, |
| 3691 | bgp_network_mask_natural_cmd, |
| 3692 | "network A.B.C.D", |
| 3693 | "Specify a network to announce via BGP\n" |
| 3694 | "Network number\n") |
| 3695 | { |
| 3696 | int ret; |
| 3697 | char prefix_str[BUFSIZ]; |
| 3698 | |
| 3699 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3700 | if (! ret) |
| 3701 | { |
| 3702 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3703 | return CMD_WARNING; |
| 3704 | } |
| 3705 | |
| 3706 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3707 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3708 | } |
| 3709 | |
| 3710 | DEFUN (bgp_network_mask_natural_route_map, |
| 3711 | bgp_network_mask_natural_route_map_cmd, |
| 3712 | "network A.B.C.D route-map WORD", |
| 3713 | "Specify a network to announce via BGP\n" |
| 3714 | "Network number\n" |
| 3715 | "Route-map to modify the attributes\n" |
| 3716 | "Name of the route map\n") |
| 3717 | { |
| 3718 | int ret; |
| 3719 | char prefix_str[BUFSIZ]; |
| 3720 | |
| 3721 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3722 | if (! ret) |
| 3723 | { |
| 3724 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3725 | return CMD_WARNING; |
| 3726 | } |
| 3727 | |
| 3728 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3729 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3730 | } |
| 3731 | |
| 3732 | DEFUN (bgp_network_mask_natural_backdoor, |
| 3733 | bgp_network_mask_natural_backdoor_cmd, |
| 3734 | "network A.B.C.D backdoor", |
| 3735 | "Specify a network to announce via BGP\n" |
| 3736 | "Network number\n" |
| 3737 | "Specify a BGP backdoor route\n") |
| 3738 | { |
| 3739 | int ret; |
| 3740 | char prefix_str[BUFSIZ]; |
| 3741 | |
| 3742 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3743 | if (! ret) |
| 3744 | { |
| 3745 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3746 | return CMD_WARNING; |
| 3747 | } |
| 3748 | |
| 3749 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3750 | } |
| 3751 | |
| 3752 | DEFUN (no_bgp_network, |
| 3753 | no_bgp_network_cmd, |
| 3754 | "no network A.B.C.D/M", |
| 3755 | NO_STR |
| 3756 | "Specify a network to announce via BGP\n" |
| 3757 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3758 | { |
| 3759 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 3760 | bgp_node_safi (vty)); |
| 3761 | } |
| 3762 | |
| 3763 | ALIAS (no_bgp_network, |
| 3764 | no_bgp_network_route_map_cmd, |
| 3765 | "no network A.B.C.D/M route-map WORD", |
| 3766 | NO_STR |
| 3767 | "Specify a network to announce via BGP\n" |
| 3768 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3769 | "Route-map to modify the attributes\n" |
| 3770 | "Name of the route map\n") |
| 3771 | |
| 3772 | ALIAS (no_bgp_network, |
| 3773 | no_bgp_network_backdoor_cmd, |
| 3774 | "no network A.B.C.D/M backdoor", |
| 3775 | NO_STR |
| 3776 | "Specify a network to announce via BGP\n" |
| 3777 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3778 | "Specify a BGP backdoor route\n") |
| 3779 | |
| 3780 | DEFUN (no_bgp_network_mask, |
| 3781 | no_bgp_network_mask_cmd, |
| 3782 | "no network A.B.C.D mask A.B.C.D", |
| 3783 | NO_STR |
| 3784 | "Specify a network to announce via BGP\n" |
| 3785 | "Network number\n" |
| 3786 | "Network mask\n" |
| 3787 | "Network mask\n") |
| 3788 | { |
| 3789 | int ret; |
| 3790 | char prefix_str[BUFSIZ]; |
| 3791 | |
| 3792 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3793 | if (! ret) |
| 3794 | { |
| 3795 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3796 | return CMD_WARNING; |
| 3797 | } |
| 3798 | |
| 3799 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3800 | bgp_node_safi (vty)); |
| 3801 | } |
| 3802 | |
| 3803 | ALIAS (no_bgp_network_mask, |
| 3804 | no_bgp_network_mask_route_map_cmd, |
| 3805 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 3806 | NO_STR |
| 3807 | "Specify a network to announce via BGP\n" |
| 3808 | "Network number\n" |
| 3809 | "Network mask\n" |
| 3810 | "Network mask\n" |
| 3811 | "Route-map to modify the attributes\n" |
| 3812 | "Name of the route map\n") |
| 3813 | |
| 3814 | ALIAS (no_bgp_network_mask, |
| 3815 | no_bgp_network_mask_backdoor_cmd, |
| 3816 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 3817 | NO_STR |
| 3818 | "Specify a network to announce via BGP\n" |
| 3819 | "Network number\n" |
| 3820 | "Network mask\n" |
| 3821 | "Network mask\n" |
| 3822 | "Specify a BGP backdoor route\n") |
| 3823 | |
| 3824 | DEFUN (no_bgp_network_mask_natural, |
| 3825 | no_bgp_network_mask_natural_cmd, |
| 3826 | "no network A.B.C.D", |
| 3827 | NO_STR |
| 3828 | "Specify a network to announce via BGP\n" |
| 3829 | "Network number\n") |
| 3830 | { |
| 3831 | int ret; |
| 3832 | char prefix_str[BUFSIZ]; |
| 3833 | |
| 3834 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3835 | if (! ret) |
| 3836 | { |
| 3837 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3838 | return CMD_WARNING; |
| 3839 | } |
| 3840 | |
| 3841 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3842 | bgp_node_safi (vty)); |
| 3843 | } |
| 3844 | |
| 3845 | ALIAS (no_bgp_network_mask_natural, |
| 3846 | no_bgp_network_mask_natural_route_map_cmd, |
| 3847 | "no network A.B.C.D route-map WORD", |
| 3848 | NO_STR |
| 3849 | "Specify a network to announce via BGP\n" |
| 3850 | "Network number\n" |
| 3851 | "Route-map to modify the attributes\n" |
| 3852 | "Name of the route map\n") |
| 3853 | |
| 3854 | ALIAS (no_bgp_network_mask_natural, |
| 3855 | no_bgp_network_mask_natural_backdoor_cmd, |
| 3856 | "no network A.B.C.D backdoor", |
| 3857 | NO_STR |
| 3858 | "Specify a network to announce via BGP\n" |
| 3859 | "Network number\n" |
| 3860 | "Specify a BGP backdoor route\n") |
| 3861 | |
| 3862 | #ifdef HAVE_IPV6 |
| 3863 | DEFUN (ipv6_bgp_network, |
| 3864 | ipv6_bgp_network_cmd, |
| 3865 | "network X:X::X:X/M", |
| 3866 | "Specify a network to announce via BGP\n" |
| 3867 | "IPv6 prefix <network>/<length>\n") |
| 3868 | { |
| 3869 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 3870 | } |
| 3871 | |
| 3872 | DEFUN (ipv6_bgp_network_route_map, |
| 3873 | ipv6_bgp_network_route_map_cmd, |
| 3874 | "network X:X::X:X/M route-map WORD", |
| 3875 | "Specify a network to announce via BGP\n" |
| 3876 | "IPv6 prefix <network>/<length>\n" |
| 3877 | "Route-map to modify the attributes\n" |
| 3878 | "Name of the route map\n") |
| 3879 | { |
| 3880 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
| 3881 | bgp_node_safi (vty), argv[1], 0); |
| 3882 | } |
| 3883 | |
| 3884 | DEFUN (no_ipv6_bgp_network, |
| 3885 | no_ipv6_bgp_network_cmd, |
| 3886 | "no network X:X::X:X/M", |
| 3887 | NO_STR |
| 3888 | "Specify a network to announce via BGP\n" |
| 3889 | "IPv6 prefix <network>/<length>\n") |
| 3890 | { |
| 3891 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); |
| 3892 | } |
| 3893 | |
| 3894 | ALIAS (no_ipv6_bgp_network, |
| 3895 | no_ipv6_bgp_network_route_map_cmd, |
| 3896 | "no network X:X::X:X/M route-map WORD", |
| 3897 | NO_STR |
| 3898 | "Specify a network to announce via BGP\n" |
| 3899 | "IPv6 prefix <network>/<length>\n" |
| 3900 | "Route-map to modify the attributes\n" |
| 3901 | "Name of the route map\n") |
| 3902 | |
| 3903 | ALIAS (ipv6_bgp_network, |
| 3904 | old_ipv6_bgp_network_cmd, |
| 3905 | "ipv6 bgp network X:X::X:X/M", |
| 3906 | IPV6_STR |
| 3907 | BGP_STR |
| 3908 | "Specify a network to announce via BGP\n" |
| 3909 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3910 | |
| 3911 | ALIAS (no_ipv6_bgp_network, |
| 3912 | old_no_ipv6_bgp_network_cmd, |
| 3913 | "no ipv6 bgp network X:X::X:X/M", |
| 3914 | NO_STR |
| 3915 | IPV6_STR |
| 3916 | BGP_STR |
| 3917 | "Specify a network to announce via BGP\n" |
| 3918 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3919 | #endif /* HAVE_IPV6 */ |
| 3920 | |
| 3921 | /* Aggreagete address: |
| 3922 | |
| 3923 | advertise-map Set condition to advertise attribute |
| 3924 | as-set Generate AS set path information |
| 3925 | attribute-map Set attributes of aggregate |
| 3926 | route-map Set parameters of aggregate |
| 3927 | summary-only Filter more specific routes from updates |
| 3928 | suppress-map Conditionally filter more specific routes from updates |
| 3929 | <cr> |
| 3930 | */ |
| 3931 | struct bgp_aggregate |
| 3932 | { |
| 3933 | /* Summary-only flag. */ |
| 3934 | u_char summary_only; |
| 3935 | |
| 3936 | /* AS set generation. */ |
| 3937 | u_char as_set; |
| 3938 | |
| 3939 | /* Route-map for aggregated route. */ |
| 3940 | struct route_map *map; |
| 3941 | |
| 3942 | /* Suppress-count. */ |
| 3943 | unsigned long count; |
| 3944 | |
| 3945 | /* SAFI configuration. */ |
| 3946 | safi_t safi; |
| 3947 | }; |
| 3948 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3949 | static struct bgp_aggregate * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3950 | bgp_aggregate_new () |
| 3951 | { |
| 3952 | struct bgp_aggregate *new; |
| 3953 | new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
| 3954 | memset (new, 0, sizeof (struct bgp_aggregate)); |
| 3955 | return new; |
| 3956 | } |
| 3957 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3958 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3959 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 3960 | { |
| 3961 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 3962 | } |
| 3963 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3964 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3965 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 3966 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 3967 | struct bgp_aggregate *aggregate) |
| 3968 | { |
| 3969 | struct bgp_table *table; |
| 3970 | struct bgp_node *top; |
| 3971 | struct bgp_node *rn; |
| 3972 | u_char origin; |
| 3973 | struct aspath *aspath = NULL; |
| 3974 | struct aspath *asmerge = NULL; |
| 3975 | struct community *community = NULL; |
| 3976 | struct community *commerge = NULL; |
| 3977 | struct in_addr nexthop; |
| 3978 | u_int32_t med = 0; |
| 3979 | struct bgp_info *ri; |
| 3980 | struct bgp_info *new; |
| 3981 | int first = 1; |
| 3982 | unsigned long match = 0; |
| 3983 | |
| 3984 | /* Record adding route's nexthop and med. */ |
| 3985 | if (rinew) |
| 3986 | { |
| 3987 | nexthop = rinew->attr->nexthop; |
| 3988 | med = rinew->attr->med; |
| 3989 | } |
| 3990 | |
| 3991 | /* ORIGIN attribute: If at least one route among routes that are |
| 3992 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 3993 | aggregated route must have the ORIGIN attribute with the value |
| 3994 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 3995 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 3996 | route must have the origin attribute with the value EGP. In all |
| 3997 | other case the value of the ORIGIN attribute of the aggregated |
| 3998 | route is INTERNAL. */ |
| 3999 | origin = BGP_ORIGIN_IGP; |
| 4000 | |
| 4001 | table = bgp->rib[afi][safi]; |
| 4002 | |
| 4003 | top = bgp_node_get (table, p); |
| 4004 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4005 | if (rn->p.prefixlen > p->prefixlen) |
| 4006 | { |
| 4007 | match = 0; |
| 4008 | |
| 4009 | for (ri = rn->info; ri; ri = ri->next) |
| 4010 | { |
| 4011 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4012 | continue; |
| 4013 | |
| 4014 | if (del && ri == del) |
| 4015 | continue; |
| 4016 | |
| 4017 | if (! rinew && first) |
| 4018 | { |
| 4019 | nexthop = ri->attr->nexthop; |
| 4020 | med = ri->attr->med; |
| 4021 | first = 0; |
| 4022 | } |
| 4023 | |
| 4024 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4025 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4026 | || ri->attr->med != med) |
| 4027 | { |
| 4028 | if (aspath) |
| 4029 | aspath_free (aspath); |
| 4030 | if (community) |
| 4031 | community_free (community); |
| 4032 | bgp_unlock_node (rn); |
| 4033 | bgp_unlock_node (top); |
| 4034 | return; |
| 4035 | } |
| 4036 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4037 | |
| 4038 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4039 | { |
| 4040 | if (aggregate->summary_only) |
| 4041 | { |
| 4042 | ri->suppress++; |
| 4043 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4044 | match++; |
| 4045 | } |
| 4046 | |
| 4047 | aggregate->count++; |
| 4048 | |
| 4049 | if (aggregate->as_set) |
| 4050 | { |
| 4051 | if (origin < ri->attr->origin) |
| 4052 | origin = ri->attr->origin; |
| 4053 | |
| 4054 | if (aspath) |
| 4055 | { |
| 4056 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4057 | aspath_free (aspath); |
| 4058 | aspath = asmerge; |
| 4059 | } |
| 4060 | else |
| 4061 | aspath = aspath_dup (ri->attr->aspath); |
| 4062 | |
| 4063 | if (ri->attr->community) |
| 4064 | { |
| 4065 | if (community) |
| 4066 | { |
| 4067 | commerge = community_merge (community, |
| 4068 | ri->attr->community); |
| 4069 | community = community_uniq_sort (commerge); |
| 4070 | community_free (commerge); |
| 4071 | } |
| 4072 | else |
| 4073 | community = community_dup (ri->attr->community); |
| 4074 | } |
| 4075 | } |
| 4076 | } |
| 4077 | } |
| 4078 | if (match) |
| 4079 | bgp_process (bgp, rn, afi, safi); |
| 4080 | } |
| 4081 | bgp_unlock_node (top); |
| 4082 | |
| 4083 | if (rinew) |
| 4084 | { |
| 4085 | aggregate->count++; |
| 4086 | |
| 4087 | if (aggregate->summary_only) |
| 4088 | rinew->suppress++; |
| 4089 | |
| 4090 | if (aggregate->as_set) |
| 4091 | { |
| 4092 | if (origin < rinew->attr->origin) |
| 4093 | origin = rinew->attr->origin; |
| 4094 | |
| 4095 | if (aspath) |
| 4096 | { |
| 4097 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4098 | aspath_free (aspath); |
| 4099 | aspath = asmerge; |
| 4100 | } |
| 4101 | else |
| 4102 | aspath = aspath_dup (rinew->attr->aspath); |
| 4103 | |
| 4104 | if (rinew->attr->community) |
| 4105 | { |
| 4106 | if (community) |
| 4107 | { |
| 4108 | commerge = community_merge (community, |
| 4109 | rinew->attr->community); |
| 4110 | community = community_uniq_sort (commerge); |
| 4111 | community_free (commerge); |
| 4112 | } |
| 4113 | else |
| 4114 | community = community_dup (rinew->attr->community); |
| 4115 | } |
| 4116 | } |
| 4117 | } |
| 4118 | |
| 4119 | if (aggregate->count > 0) |
| 4120 | { |
| 4121 | rn = bgp_node_get (table, p); |
| 4122 | new = bgp_info_new (); |
| 4123 | new->type = ZEBRA_ROUTE_BGP; |
| 4124 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4125 | new->peer = bgp->peer_self; |
| 4126 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4127 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4128 | new->uptime = time (NULL); |
| 4129 | |
| 4130 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4131 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4132 | bgp_process (bgp, rn, afi, safi); |
| 4133 | } |
| 4134 | else |
| 4135 | { |
| 4136 | if (aspath) |
| 4137 | aspath_free (aspath); |
| 4138 | if (community) |
| 4139 | community_free (community); |
| 4140 | } |
| 4141 | } |
| 4142 | |
| 4143 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4144 | struct bgp_aggregate *); |
| 4145 | |
| 4146 | void |
| 4147 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4148 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4149 | { |
| 4150 | struct bgp_node *child; |
| 4151 | struct bgp_node *rn; |
| 4152 | struct bgp_aggregate *aggregate; |
| 4153 | |
| 4154 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4155 | if (safi == SAFI_MPLS_VPN) |
| 4156 | return; |
| 4157 | |
| 4158 | if (p->prefixlen == 0) |
| 4159 | return; |
| 4160 | |
| 4161 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4162 | return; |
| 4163 | |
| 4164 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4165 | |
| 4166 | /* Aggregate address configuration check. */ |
| 4167 | for (rn = child; rn; rn = rn->parent) |
| 4168 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4169 | { |
| 4170 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4171 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4172 | } |
| 4173 | bgp_unlock_node (child); |
| 4174 | } |
| 4175 | |
| 4176 | void |
| 4177 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4178 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4179 | { |
| 4180 | struct bgp_node *child; |
| 4181 | struct bgp_node *rn; |
| 4182 | struct bgp_aggregate *aggregate; |
| 4183 | |
| 4184 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4185 | if (safi == SAFI_MPLS_VPN) |
| 4186 | return; |
| 4187 | |
| 4188 | if (p->prefixlen == 0) |
| 4189 | return; |
| 4190 | |
| 4191 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4192 | |
| 4193 | /* Aggregate address configuration check. */ |
| 4194 | for (rn = child; rn; rn = rn->parent) |
| 4195 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4196 | { |
| 4197 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4198 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4199 | } |
| 4200 | bgp_unlock_node (child); |
| 4201 | } |
| 4202 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4203 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4204 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4205 | struct bgp_aggregate *aggregate) |
| 4206 | { |
| 4207 | struct bgp_table *table; |
| 4208 | struct bgp_node *top; |
| 4209 | struct bgp_node *rn; |
| 4210 | struct bgp_info *new; |
| 4211 | struct bgp_info *ri; |
| 4212 | unsigned long match; |
| 4213 | u_char origin = BGP_ORIGIN_IGP; |
| 4214 | struct aspath *aspath = NULL; |
| 4215 | struct aspath *asmerge = NULL; |
| 4216 | struct community *community = NULL; |
| 4217 | struct community *commerge = NULL; |
| 4218 | |
| 4219 | table = bgp->rib[afi][safi]; |
| 4220 | |
| 4221 | /* Sanity check. */ |
| 4222 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4223 | return; |
| 4224 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4225 | return; |
| 4226 | |
| 4227 | /* If routes exists below this node, generate aggregate routes. */ |
| 4228 | top = bgp_node_get (table, p); |
| 4229 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4230 | if (rn->p.prefixlen > p->prefixlen) |
| 4231 | { |
| 4232 | match = 0; |
| 4233 | |
| 4234 | for (ri = rn->info; ri; ri = ri->next) |
| 4235 | { |
| 4236 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4237 | continue; |
| 4238 | |
| 4239 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4240 | { |
| 4241 | /* summary-only aggregate route suppress aggregated |
| 4242 | route announcement. */ |
| 4243 | if (aggregate->summary_only) |
| 4244 | { |
| 4245 | ri->suppress++; |
| 4246 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4247 | match++; |
| 4248 | } |
| 4249 | /* as-set aggregate route generate origin, as path, |
| 4250 | community aggregation. */ |
| 4251 | if (aggregate->as_set) |
| 4252 | { |
| 4253 | if (origin < ri->attr->origin) |
| 4254 | origin = ri->attr->origin; |
| 4255 | |
| 4256 | if (aspath) |
| 4257 | { |
| 4258 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4259 | aspath_free (aspath); |
| 4260 | aspath = asmerge; |
| 4261 | } |
| 4262 | else |
| 4263 | aspath = aspath_dup (ri->attr->aspath); |
| 4264 | |
| 4265 | if (ri->attr->community) |
| 4266 | { |
| 4267 | if (community) |
| 4268 | { |
| 4269 | commerge = community_merge (community, |
| 4270 | ri->attr->community); |
| 4271 | community = community_uniq_sort (commerge); |
| 4272 | community_free (commerge); |
| 4273 | } |
| 4274 | else |
| 4275 | community = community_dup (ri->attr->community); |
| 4276 | } |
| 4277 | } |
| 4278 | aggregate->count++; |
| 4279 | } |
| 4280 | } |
| 4281 | |
| 4282 | /* If this node is suppressed, process the change. */ |
| 4283 | if (match) |
| 4284 | bgp_process (bgp, rn, afi, safi); |
| 4285 | } |
| 4286 | bgp_unlock_node (top); |
| 4287 | |
| 4288 | /* Add aggregate route to BGP table. */ |
| 4289 | if (aggregate->count) |
| 4290 | { |
| 4291 | rn = bgp_node_get (table, p); |
| 4292 | |
| 4293 | new = bgp_info_new (); |
| 4294 | new->type = ZEBRA_ROUTE_BGP; |
| 4295 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4296 | new->peer = bgp->peer_self; |
| 4297 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4298 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4299 | new->uptime = time (NULL); |
| 4300 | |
| 4301 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4302 | bgp_unlock_node (rn); |
| 4303 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4304 | /* Process change. */ |
| 4305 | bgp_process (bgp, rn, afi, safi); |
| 4306 | } |
| 4307 | } |
| 4308 | |
| 4309 | void |
| 4310 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4311 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4312 | { |
| 4313 | struct bgp_table *table; |
| 4314 | struct bgp_node *top; |
| 4315 | struct bgp_node *rn; |
| 4316 | struct bgp_info *ri; |
| 4317 | unsigned long match; |
| 4318 | |
| 4319 | table = bgp->rib[afi][safi]; |
| 4320 | |
| 4321 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4322 | return; |
| 4323 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4324 | return; |
| 4325 | |
| 4326 | /* If routes exists below this node, generate aggregate routes. */ |
| 4327 | top = bgp_node_get (table, p); |
| 4328 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4329 | if (rn->p.prefixlen > p->prefixlen) |
| 4330 | { |
| 4331 | match = 0; |
| 4332 | |
| 4333 | for (ri = rn->info; ri; ri = ri->next) |
| 4334 | { |
| 4335 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4336 | continue; |
| 4337 | |
| 4338 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4339 | { |
| 4340 | if (aggregate->summary_only) |
| 4341 | { |
| 4342 | ri->suppress--; |
| 4343 | |
| 4344 | if (ri->suppress == 0) |
| 4345 | { |
| 4346 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4347 | match++; |
| 4348 | } |
| 4349 | } |
| 4350 | aggregate->count--; |
| 4351 | } |
| 4352 | } |
| 4353 | |
| 4354 | /* If this node is suppressed, process the change. */ |
| 4355 | if (match) |
| 4356 | bgp_process (bgp, rn, afi, safi); |
| 4357 | } |
| 4358 | bgp_unlock_node (top); |
| 4359 | |
| 4360 | /* Delete aggregate route from BGP table. */ |
| 4361 | rn = bgp_node_get (table, p); |
| 4362 | |
| 4363 | for (ri = rn->info; ri; ri = ri->next) |
| 4364 | if (ri->peer == bgp->peer_self |
| 4365 | && ri->type == ZEBRA_ROUTE_BGP |
| 4366 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4367 | break; |
| 4368 | |
| 4369 | /* Withdraw static BGP route from routing table. */ |
| 4370 | if (ri) |
| 4371 | { |
| 4372 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4373 | bgp_process (bgp, rn, afi, safi); |
| 4374 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4375 | } |
| 4376 | |
| 4377 | /* Unlock bgp_node_lookup. */ |
| 4378 | bgp_unlock_node (rn); |
| 4379 | } |
| 4380 | |
| 4381 | /* Aggregate route attribute. */ |
| 4382 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4383 | #define AGGREGATE_AS_SET 1 |
| 4384 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4385 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4386 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
| 4387 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4388 | u_char summary_only, u_char as_set) |
| 4389 | { |
| 4390 | int ret; |
| 4391 | struct prefix p; |
| 4392 | struct bgp_node *rn; |
| 4393 | struct bgp *bgp; |
| 4394 | struct bgp_aggregate *aggregate; |
| 4395 | |
| 4396 | /* Convert string to prefix structure. */ |
| 4397 | ret = str2prefix (prefix_str, &p); |
| 4398 | if (!ret) |
| 4399 | { |
| 4400 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4401 | return CMD_WARNING; |
| 4402 | } |
| 4403 | apply_mask (&p); |
| 4404 | |
| 4405 | /* Get BGP structure. */ |
| 4406 | bgp = vty->index; |
| 4407 | |
| 4408 | /* Old configuration check. */ |
| 4409 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4410 | |
| 4411 | if (rn->info) |
| 4412 | { |
| 4413 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
| 4414 | bgp_unlock_node (rn); |
| 4415 | return CMD_WARNING; |
| 4416 | } |
| 4417 | |
| 4418 | /* Make aggregate address structure. */ |
| 4419 | aggregate = bgp_aggregate_new (); |
| 4420 | aggregate->summary_only = summary_only; |
| 4421 | aggregate->as_set = as_set; |
| 4422 | aggregate->safi = safi; |
| 4423 | rn->info = aggregate; |
| 4424 | |
| 4425 | /* Aggregate address insert into BGP routing table. */ |
| 4426 | if (safi & SAFI_UNICAST) |
| 4427 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4428 | if (safi & SAFI_MULTICAST) |
| 4429 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4430 | |
| 4431 | return CMD_SUCCESS; |
| 4432 | } |
| 4433 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4434 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4435 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4436 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4437 | { |
| 4438 | int ret; |
| 4439 | struct prefix p; |
| 4440 | struct bgp_node *rn; |
| 4441 | struct bgp *bgp; |
| 4442 | struct bgp_aggregate *aggregate; |
| 4443 | |
| 4444 | /* Convert string to prefix structure. */ |
| 4445 | ret = str2prefix (prefix_str, &p); |
| 4446 | if (!ret) |
| 4447 | { |
| 4448 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4449 | return CMD_WARNING; |
| 4450 | } |
| 4451 | apply_mask (&p); |
| 4452 | |
| 4453 | /* Get BGP structure. */ |
| 4454 | bgp = vty->index; |
| 4455 | |
| 4456 | /* Old configuration check. */ |
| 4457 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4458 | if (! rn) |
| 4459 | { |
| 4460 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4461 | VTY_NEWLINE); |
| 4462 | return CMD_WARNING; |
| 4463 | } |
| 4464 | |
| 4465 | aggregate = rn->info; |
| 4466 | if (aggregate->safi & SAFI_UNICAST) |
| 4467 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4468 | if (aggregate->safi & SAFI_MULTICAST) |
| 4469 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4470 | |
| 4471 | /* Unlock aggregate address configuration. */ |
| 4472 | rn->info = NULL; |
| 4473 | bgp_aggregate_free (aggregate); |
| 4474 | bgp_unlock_node (rn); |
| 4475 | bgp_unlock_node (rn); |
| 4476 | |
| 4477 | return CMD_SUCCESS; |
| 4478 | } |
| 4479 | |
| 4480 | DEFUN (aggregate_address, |
| 4481 | aggregate_address_cmd, |
| 4482 | "aggregate-address A.B.C.D/M", |
| 4483 | "Configure BGP aggregate entries\n" |
| 4484 | "Aggregate prefix\n") |
| 4485 | { |
| 4486 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 4487 | } |
| 4488 | |
| 4489 | DEFUN (aggregate_address_mask, |
| 4490 | aggregate_address_mask_cmd, |
| 4491 | "aggregate-address A.B.C.D A.B.C.D", |
| 4492 | "Configure BGP aggregate entries\n" |
| 4493 | "Aggregate address\n" |
| 4494 | "Aggregate mask\n") |
| 4495 | { |
| 4496 | int ret; |
| 4497 | char prefix_str[BUFSIZ]; |
| 4498 | |
| 4499 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4500 | |
| 4501 | if (! ret) |
| 4502 | { |
| 4503 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4504 | return CMD_WARNING; |
| 4505 | } |
| 4506 | |
| 4507 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4508 | 0, 0); |
| 4509 | } |
| 4510 | |
| 4511 | DEFUN (aggregate_address_summary_only, |
| 4512 | aggregate_address_summary_only_cmd, |
| 4513 | "aggregate-address A.B.C.D/M summary-only", |
| 4514 | "Configure BGP aggregate entries\n" |
| 4515 | "Aggregate prefix\n" |
| 4516 | "Filter more specific routes from updates\n") |
| 4517 | { |
| 4518 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4519 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4520 | } |
| 4521 | |
| 4522 | DEFUN (aggregate_address_mask_summary_only, |
| 4523 | aggregate_address_mask_summary_only_cmd, |
| 4524 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4525 | "Configure BGP aggregate entries\n" |
| 4526 | "Aggregate address\n" |
| 4527 | "Aggregate mask\n" |
| 4528 | "Filter more specific routes from updates\n") |
| 4529 | { |
| 4530 | int ret; |
| 4531 | char prefix_str[BUFSIZ]; |
| 4532 | |
| 4533 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4534 | |
| 4535 | if (! ret) |
| 4536 | { |
| 4537 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4538 | return CMD_WARNING; |
| 4539 | } |
| 4540 | |
| 4541 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4542 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4543 | } |
| 4544 | |
| 4545 | DEFUN (aggregate_address_as_set, |
| 4546 | aggregate_address_as_set_cmd, |
| 4547 | "aggregate-address A.B.C.D/M as-set", |
| 4548 | "Configure BGP aggregate entries\n" |
| 4549 | "Aggregate prefix\n" |
| 4550 | "Generate AS set path information\n") |
| 4551 | { |
| 4552 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4553 | 0, AGGREGATE_AS_SET); |
| 4554 | } |
| 4555 | |
| 4556 | DEFUN (aggregate_address_mask_as_set, |
| 4557 | aggregate_address_mask_as_set_cmd, |
| 4558 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 4559 | "Configure BGP aggregate entries\n" |
| 4560 | "Aggregate address\n" |
| 4561 | "Aggregate mask\n" |
| 4562 | "Generate AS set path information\n") |
| 4563 | { |
| 4564 | int ret; |
| 4565 | char prefix_str[BUFSIZ]; |
| 4566 | |
| 4567 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4568 | |
| 4569 | if (! ret) |
| 4570 | { |
| 4571 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4572 | return CMD_WARNING; |
| 4573 | } |
| 4574 | |
| 4575 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4576 | 0, AGGREGATE_AS_SET); |
| 4577 | } |
| 4578 | |
| 4579 | |
| 4580 | DEFUN (aggregate_address_as_set_summary, |
| 4581 | aggregate_address_as_set_summary_cmd, |
| 4582 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 4583 | "Configure BGP aggregate entries\n" |
| 4584 | "Aggregate prefix\n" |
| 4585 | "Generate AS set path information\n" |
| 4586 | "Filter more specific routes from updates\n") |
| 4587 | { |
| 4588 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4589 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4590 | } |
| 4591 | |
| 4592 | ALIAS (aggregate_address_as_set_summary, |
| 4593 | aggregate_address_summary_as_set_cmd, |
| 4594 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 4595 | "Configure BGP aggregate entries\n" |
| 4596 | "Aggregate prefix\n" |
| 4597 | "Filter more specific routes from updates\n" |
| 4598 | "Generate AS set path information\n") |
| 4599 | |
| 4600 | DEFUN (aggregate_address_mask_as_set_summary, |
| 4601 | aggregate_address_mask_as_set_summary_cmd, |
| 4602 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4603 | "Configure BGP aggregate entries\n" |
| 4604 | "Aggregate address\n" |
| 4605 | "Aggregate mask\n" |
| 4606 | "Generate AS set path information\n" |
| 4607 | "Filter more specific routes from updates\n") |
| 4608 | { |
| 4609 | int ret; |
| 4610 | char prefix_str[BUFSIZ]; |
| 4611 | |
| 4612 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4613 | |
| 4614 | if (! ret) |
| 4615 | { |
| 4616 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4617 | return CMD_WARNING; |
| 4618 | } |
| 4619 | |
| 4620 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4621 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4622 | } |
| 4623 | |
| 4624 | ALIAS (aggregate_address_mask_as_set_summary, |
| 4625 | aggregate_address_mask_summary_as_set_cmd, |
| 4626 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4627 | "Configure BGP aggregate entries\n" |
| 4628 | "Aggregate address\n" |
| 4629 | "Aggregate mask\n" |
| 4630 | "Filter more specific routes from updates\n" |
| 4631 | "Generate AS set path information\n") |
| 4632 | |
| 4633 | DEFUN (no_aggregate_address, |
| 4634 | no_aggregate_address_cmd, |
| 4635 | "no aggregate-address A.B.C.D/M", |
| 4636 | NO_STR |
| 4637 | "Configure BGP aggregate entries\n" |
| 4638 | "Aggregate prefix\n") |
| 4639 | { |
| 4640 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 4641 | } |
| 4642 | |
| 4643 | ALIAS (no_aggregate_address, |
| 4644 | no_aggregate_address_summary_only_cmd, |
| 4645 | "no aggregate-address A.B.C.D/M summary-only", |
| 4646 | NO_STR |
| 4647 | "Configure BGP aggregate entries\n" |
| 4648 | "Aggregate prefix\n" |
| 4649 | "Filter more specific routes from updates\n") |
| 4650 | |
| 4651 | ALIAS (no_aggregate_address, |
| 4652 | no_aggregate_address_as_set_cmd, |
| 4653 | "no aggregate-address A.B.C.D/M as-set", |
| 4654 | NO_STR |
| 4655 | "Configure BGP aggregate entries\n" |
| 4656 | "Aggregate prefix\n" |
| 4657 | "Generate AS set path information\n") |
| 4658 | |
| 4659 | ALIAS (no_aggregate_address, |
| 4660 | no_aggregate_address_as_set_summary_cmd, |
| 4661 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 4662 | NO_STR |
| 4663 | "Configure BGP aggregate entries\n" |
| 4664 | "Aggregate prefix\n" |
| 4665 | "Generate AS set path information\n" |
| 4666 | "Filter more specific routes from updates\n") |
| 4667 | |
| 4668 | ALIAS (no_aggregate_address, |
| 4669 | no_aggregate_address_summary_as_set_cmd, |
| 4670 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 4671 | NO_STR |
| 4672 | "Configure BGP aggregate entries\n" |
| 4673 | "Aggregate prefix\n" |
| 4674 | "Filter more specific routes from updates\n" |
| 4675 | "Generate AS set path information\n") |
| 4676 | |
| 4677 | DEFUN (no_aggregate_address_mask, |
| 4678 | no_aggregate_address_mask_cmd, |
| 4679 | "no aggregate-address A.B.C.D A.B.C.D", |
| 4680 | NO_STR |
| 4681 | "Configure BGP aggregate entries\n" |
| 4682 | "Aggregate address\n" |
| 4683 | "Aggregate mask\n") |
| 4684 | { |
| 4685 | int ret; |
| 4686 | char prefix_str[BUFSIZ]; |
| 4687 | |
| 4688 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4689 | |
| 4690 | if (! ret) |
| 4691 | { |
| 4692 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4693 | return CMD_WARNING; |
| 4694 | } |
| 4695 | |
| 4696 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 4697 | } |
| 4698 | |
| 4699 | ALIAS (no_aggregate_address_mask, |
| 4700 | no_aggregate_address_mask_summary_only_cmd, |
| 4701 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4702 | NO_STR |
| 4703 | "Configure BGP aggregate entries\n" |
| 4704 | "Aggregate address\n" |
| 4705 | "Aggregate mask\n" |
| 4706 | "Filter more specific routes from updates\n") |
| 4707 | |
| 4708 | ALIAS (no_aggregate_address_mask, |
| 4709 | no_aggregate_address_mask_as_set_cmd, |
| 4710 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 4711 | NO_STR |
| 4712 | "Configure BGP aggregate entries\n" |
| 4713 | "Aggregate address\n" |
| 4714 | "Aggregate mask\n" |
| 4715 | "Generate AS set path information\n") |
| 4716 | |
| 4717 | ALIAS (no_aggregate_address_mask, |
| 4718 | no_aggregate_address_mask_as_set_summary_cmd, |
| 4719 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4720 | NO_STR |
| 4721 | "Configure BGP aggregate entries\n" |
| 4722 | "Aggregate address\n" |
| 4723 | "Aggregate mask\n" |
| 4724 | "Generate AS set path information\n" |
| 4725 | "Filter more specific routes from updates\n") |
| 4726 | |
| 4727 | ALIAS (no_aggregate_address_mask, |
| 4728 | no_aggregate_address_mask_summary_as_set_cmd, |
| 4729 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4730 | NO_STR |
| 4731 | "Configure BGP aggregate entries\n" |
| 4732 | "Aggregate address\n" |
| 4733 | "Aggregate mask\n" |
| 4734 | "Filter more specific routes from updates\n" |
| 4735 | "Generate AS set path information\n") |
| 4736 | |
| 4737 | #ifdef HAVE_IPV6 |
| 4738 | DEFUN (ipv6_aggregate_address, |
| 4739 | ipv6_aggregate_address_cmd, |
| 4740 | "aggregate-address X:X::X:X/M", |
| 4741 | "Configure BGP aggregate entries\n" |
| 4742 | "Aggregate prefix\n") |
| 4743 | { |
| 4744 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 4745 | } |
| 4746 | |
| 4747 | DEFUN (ipv6_aggregate_address_summary_only, |
| 4748 | ipv6_aggregate_address_summary_only_cmd, |
| 4749 | "aggregate-address X:X::X:X/M summary-only", |
| 4750 | "Configure BGP aggregate entries\n" |
| 4751 | "Aggregate prefix\n" |
| 4752 | "Filter more specific routes from updates\n") |
| 4753 | { |
| 4754 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 4755 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4756 | } |
| 4757 | |
| 4758 | DEFUN (no_ipv6_aggregate_address, |
| 4759 | no_ipv6_aggregate_address_cmd, |
| 4760 | "no aggregate-address X:X::X:X/M", |
| 4761 | NO_STR |
| 4762 | "Configure BGP aggregate entries\n" |
| 4763 | "Aggregate prefix\n") |
| 4764 | { |
| 4765 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4766 | } |
| 4767 | |
| 4768 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 4769 | no_ipv6_aggregate_address_summary_only_cmd, |
| 4770 | "no aggregate-address X:X::X:X/M summary-only", |
| 4771 | NO_STR |
| 4772 | "Configure BGP aggregate entries\n" |
| 4773 | "Aggregate prefix\n" |
| 4774 | "Filter more specific routes from updates\n") |
| 4775 | { |
| 4776 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4777 | } |
| 4778 | |
| 4779 | ALIAS (ipv6_aggregate_address, |
| 4780 | old_ipv6_aggregate_address_cmd, |
| 4781 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 4782 | IPV6_STR |
| 4783 | BGP_STR |
| 4784 | "Configure BGP aggregate entries\n" |
| 4785 | "Aggregate prefix\n") |
| 4786 | |
| 4787 | ALIAS (ipv6_aggregate_address_summary_only, |
| 4788 | old_ipv6_aggregate_address_summary_only_cmd, |
| 4789 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4790 | IPV6_STR |
| 4791 | BGP_STR |
| 4792 | "Configure BGP aggregate entries\n" |
| 4793 | "Aggregate prefix\n" |
| 4794 | "Filter more specific routes from updates\n") |
| 4795 | |
| 4796 | ALIAS (no_ipv6_aggregate_address, |
| 4797 | old_no_ipv6_aggregate_address_cmd, |
| 4798 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 4799 | NO_STR |
| 4800 | IPV6_STR |
| 4801 | BGP_STR |
| 4802 | "Configure BGP aggregate entries\n" |
| 4803 | "Aggregate prefix\n") |
| 4804 | |
| 4805 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 4806 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 4807 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4808 | NO_STR |
| 4809 | IPV6_STR |
| 4810 | BGP_STR |
| 4811 | "Configure BGP aggregate entries\n" |
| 4812 | "Aggregate prefix\n" |
| 4813 | "Filter more specific routes from updates\n") |
| 4814 | #endif /* HAVE_IPV6 */ |
| 4815 | |
| 4816 | /* Redistribute route treatment. */ |
| 4817 | void |
| 4818 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, |
| 4819 | u_int32_t metric, u_char type) |
| 4820 | { |
| 4821 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4822 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4823 | struct bgp_info *new; |
| 4824 | struct bgp_info *bi; |
| 4825 | struct bgp_info info; |
| 4826 | struct bgp_node *bn; |
| 4827 | struct attr attr; |
| 4828 | struct attr attr_new; |
| 4829 | struct attr *new_attr; |
| 4830 | afi_t afi; |
| 4831 | int ret; |
| 4832 | |
| 4833 | /* Make default attribute. */ |
| 4834 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 4835 | if (nexthop) |
| 4836 | attr.nexthop = *nexthop; |
| 4837 | |
| 4838 | attr.med = metric; |
| 4839 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 4840 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4841 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4842 | { |
| 4843 | afi = family2afi (p->family); |
| 4844 | |
| 4845 | if (bgp->redist[afi][type]) |
| 4846 | { |
| 4847 | /* Copy attribute for modification. */ |
| 4848 | attr_new = attr; |
| 4849 | |
| 4850 | if (bgp->redist_metric_flag[afi][type]) |
| 4851 | attr_new.med = bgp->redist_metric[afi][type]; |
| 4852 | |
| 4853 | /* Apply route-map. */ |
| 4854 | if (bgp->rmap[afi][type].map) |
| 4855 | { |
| 4856 | info.peer = bgp->peer_self; |
| 4857 | info.attr = &attr_new; |
| 4858 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4859 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 4860 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4861 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 4862 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4863 | |
| 4864 | bgp->peer_self->rmap_type = 0; |
| 4865 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4866 | if (ret == RMAP_DENYMATCH) |
| 4867 | { |
| 4868 | /* Free uninterned attribute. */ |
| 4869 | bgp_attr_flush (&attr_new); |
| 4870 | |
| 4871 | /* Unintern original. */ |
| 4872 | aspath_unintern (attr.aspath); |
| 4873 | bgp_redistribute_delete (p, type); |
| 4874 | return; |
| 4875 | } |
| 4876 | } |
| 4877 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4878 | 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] | 4879 | new_attr = bgp_attr_intern (&attr_new); |
| 4880 | |
| 4881 | for (bi = bn->info; bi; bi = bi->next) |
| 4882 | if (bi->peer == bgp->peer_self |
| 4883 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 4884 | break; |
| 4885 | |
| 4886 | if (bi) |
| 4887 | { |
| 4888 | if (attrhash_cmp (bi->attr, new_attr)) |
| 4889 | { |
| 4890 | bgp_attr_unintern (new_attr); |
| 4891 | aspath_unintern (attr.aspath); |
| 4892 | bgp_unlock_node (bn); |
| 4893 | return; |
| 4894 | } |
| 4895 | else |
| 4896 | { |
| 4897 | /* The attribute is changed. */ |
| 4898 | SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED); |
| 4899 | |
| 4900 | /* Rewrite BGP route information. */ |
| 4901 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
| 4902 | bgp_attr_unintern (bi->attr); |
| 4903 | bi->attr = new_attr; |
| 4904 | bi->uptime = time (NULL); |
| 4905 | |
| 4906 | /* Process change. */ |
| 4907 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 4908 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4909 | bgp_unlock_node (bn); |
| 4910 | aspath_unintern (attr.aspath); |
| 4911 | return; |
| 4912 | } |
| 4913 | } |
| 4914 | |
| 4915 | new = bgp_info_new (); |
| 4916 | new->type = type; |
| 4917 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 4918 | new->peer = bgp->peer_self; |
| 4919 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4920 | new->attr = new_attr; |
| 4921 | new->uptime = time (NULL); |
| 4922 | |
| 4923 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 4924 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4925 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4926 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4927 | } |
| 4928 | } |
| 4929 | |
| 4930 | /* Unintern original. */ |
| 4931 | aspath_unintern (attr.aspath); |
| 4932 | } |
| 4933 | |
| 4934 | void |
| 4935 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 4936 | { |
| 4937 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4938 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4939 | afi_t afi; |
| 4940 | struct bgp_node *rn; |
| 4941 | struct bgp_info *ri; |
| 4942 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4943 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4944 | { |
| 4945 | afi = family2afi (p->family); |
| 4946 | |
| 4947 | if (bgp->redist[afi][type]) |
| 4948 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4949 | 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] | 4950 | |
| 4951 | for (ri = rn->info; ri; ri = ri->next) |
| 4952 | if (ri->peer == bgp->peer_self |
| 4953 | && ri->type == type) |
| 4954 | break; |
| 4955 | |
| 4956 | if (ri) |
| 4957 | { |
| 4958 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
| 4959 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4960 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4961 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4962 | } |
| 4963 | bgp_unlock_node (rn); |
| 4964 | } |
| 4965 | } |
| 4966 | } |
| 4967 | |
| 4968 | /* Withdraw specified route type's route. */ |
| 4969 | void |
| 4970 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 4971 | { |
| 4972 | struct bgp_node *rn; |
| 4973 | struct bgp_info *ri; |
| 4974 | struct bgp_table *table; |
| 4975 | |
| 4976 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 4977 | |
| 4978 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 4979 | { |
| 4980 | for (ri = rn->info; ri; ri = ri->next) |
| 4981 | if (ri->peer == bgp->peer_self |
| 4982 | && ri->type == type) |
| 4983 | break; |
| 4984 | |
| 4985 | if (ri) |
| 4986 | { |
| 4987 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
| 4988 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4989 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4990 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4991 | } |
| 4992 | } |
| 4993 | } |
| 4994 | |
| 4995 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4996 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4997 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 4998 | { |
| 4999 | int len; |
| 5000 | u_int32_t destination; |
| 5001 | char buf[BUFSIZ]; |
| 5002 | |
| 5003 | if (p->family == AF_INET) |
| 5004 | { |
| 5005 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5006 | destination = ntohl (p->u.prefix4.s_addr); |
| 5007 | |
| 5008 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5009 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5010 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5011 | || p->u.prefix4.s_addr == 0) |
| 5012 | { |
| 5013 | /* When mask is natural, mask is not displayed. */ |
| 5014 | } |
| 5015 | else |
| 5016 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5017 | } |
| 5018 | else |
| 5019 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5020 | p->prefixlen); |
| 5021 | |
| 5022 | len = 17 - len; |
| 5023 | if (len < 1) |
| 5024 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5025 | else |
| 5026 | vty_out (vty, "%*s", len, " "); |
| 5027 | } |
| 5028 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5029 | enum bgp_display_type |
| 5030 | { |
| 5031 | normal_list, |
| 5032 | }; |
| 5033 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5034 | /* Print the short form route status for a bgp_info */ |
| 5035 | static void |
| 5036 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5037 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5038 | /* Route status display. */ |
| 5039 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5040 | vty_out (vty, "R"); |
| 5041 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5042 | vty_out (vty, "S"); |
| 5043 | else if (binfo->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5044 | vty_out (vty, "s"); |
| 5045 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5046 | vty_out (vty, "*"); |
| 5047 | else |
| 5048 | vty_out (vty, " "); |
| 5049 | |
| 5050 | /* Selected */ |
| 5051 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5052 | vty_out (vty, "h"); |
| 5053 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5054 | vty_out (vty, "d"); |
| 5055 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5056 | vty_out (vty, ">"); |
| 5057 | else |
| 5058 | vty_out (vty, " "); |
| 5059 | |
| 5060 | /* Internal route. */ |
| 5061 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5062 | vty_out (vty, "i"); |
| 5063 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5064 | vty_out (vty, " "); |
| 5065 | } |
| 5066 | |
| 5067 | /* called from terminal list command */ |
| 5068 | void |
| 5069 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5070 | struct bgp_info *binfo, int display, safi_t safi) |
| 5071 | { |
| 5072 | struct attr *attr; |
| 5073 | |
| 5074 | /* short status lead text */ |
| 5075 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5076 | |
| 5077 | /* print prefix and mask */ |
| 5078 | if (! display) |
| 5079 | route_vty_out_route (p, vty); |
| 5080 | else |
| 5081 | vty_out (vty, "%*s", 17, " "); |
| 5082 | |
| 5083 | /* Print attribute */ |
| 5084 | attr = binfo->attr; |
| 5085 | if (attr) |
| 5086 | { |
| 5087 | if (p->family == AF_INET) |
| 5088 | { |
| 5089 | if (safi == SAFI_MPLS_VPN) |
| 5090 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5091 | else |
| 5092 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5093 | } |
| 5094 | #ifdef HAVE_IPV6 |
| 5095 | else if (p->family == AF_INET6) |
| 5096 | { |
| 5097 | int len; |
| 5098 | char buf[BUFSIZ]; |
| 5099 | |
| 5100 | len = vty_out (vty, "%s", |
| 5101 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5102 | len = 16 - len; |
| 5103 | if (len < 1) |
| 5104 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5105 | else |
| 5106 | vty_out (vty, "%*s", len, " "); |
| 5107 | } |
| 5108 | #endif /* HAVE_IPV6 */ |
| 5109 | |
| 5110 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 5111 | vty_out (vty, "%10d", attr->med); |
| 5112 | else |
| 5113 | vty_out (vty, " "); |
| 5114 | |
| 5115 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 5116 | vty_out (vty, "%7d", attr->local_pref); |
| 5117 | else |
| 5118 | vty_out (vty, " "); |
| 5119 | |
| 5120 | vty_out (vty, "%7u ",attr->weight); |
| 5121 | |
| 5122 | /* Print aspath */ |
| 5123 | if (attr->aspath) |
| 5124 | aspath_print_vty (vty, attr->aspath); |
| 5125 | |
| 5126 | /* Print origin */ |
| 5127 | if (strlen (attr->aspath->str) == 0) |
| 5128 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5129 | else |
| 5130 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5131 | } |
| 5132 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5133 | } |
| 5134 | |
| 5135 | /* called from terminal list command */ |
| 5136 | void |
| 5137 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5138 | struct attr *attr, safi_t safi) |
| 5139 | { |
| 5140 | /* Route status display. */ |
| 5141 | vty_out (vty, "*"); |
| 5142 | vty_out (vty, ">"); |
| 5143 | vty_out (vty, " "); |
| 5144 | |
| 5145 | /* print prefix and mask */ |
| 5146 | route_vty_out_route (p, vty); |
| 5147 | |
| 5148 | /* Print attribute */ |
| 5149 | if (attr) |
| 5150 | { |
| 5151 | if (p->family == AF_INET) |
| 5152 | { |
| 5153 | if (safi == SAFI_MPLS_VPN) |
| 5154 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5155 | else |
| 5156 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5157 | } |
| 5158 | #ifdef HAVE_IPV6 |
| 5159 | else if (p->family == AF_INET6) |
| 5160 | { |
| 5161 | int len; |
| 5162 | char buf[BUFSIZ]; |
| 5163 | |
| 5164 | len = vty_out (vty, "%s", |
| 5165 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5166 | len = 16 - len; |
| 5167 | if (len < 1) |
| 5168 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5169 | else |
| 5170 | vty_out (vty, "%*s", len, " "); |
| 5171 | } |
| 5172 | #endif /* HAVE_IPV6 */ |
| 5173 | |
| 5174 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 5175 | vty_out (vty, "%10d", attr->med); |
| 5176 | else |
| 5177 | vty_out (vty, " "); |
| 5178 | |
| 5179 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 5180 | vty_out (vty, "%7d", attr->local_pref); |
| 5181 | else |
| 5182 | vty_out (vty, " "); |
| 5183 | |
| 5184 | vty_out (vty, "%7d ",attr->weight); |
| 5185 | |
| 5186 | /* Print aspath */ |
| 5187 | if (attr->aspath) |
| 5188 | aspath_print_vty (vty, attr->aspath); |
| 5189 | |
| 5190 | /* Print origin */ |
| 5191 | if (strlen (attr->aspath->str) == 0) |
| 5192 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5193 | else |
| 5194 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5195 | } |
| 5196 | |
| 5197 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5198 | } |
| 5199 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5200 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5201 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5202 | struct bgp_info *binfo, int display, safi_t safi) |
| 5203 | { |
| 5204 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5205 | u_int32_t label = 0; |
| 5206 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5207 | /* short status lead text */ |
| 5208 | route_vty_short_status_out (vty, binfo); |
| 5209 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5210 | /* print prefix and mask */ |
| 5211 | if (! display) |
| 5212 | route_vty_out_route (p, vty); |
| 5213 | else |
| 5214 | vty_out (vty, "%*s", 17, " "); |
| 5215 | |
| 5216 | /* Print attribute */ |
| 5217 | attr = binfo->attr; |
| 5218 | if (attr) |
| 5219 | { |
| 5220 | if (p->family == AF_INET) |
| 5221 | { |
| 5222 | if (safi == SAFI_MPLS_VPN) |
| 5223 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5224 | else |
| 5225 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5226 | } |
| 5227 | #ifdef HAVE_IPV6 |
| 5228 | else if (p->family == AF_INET6) |
| 5229 | { |
| 5230 | char buf[BUFSIZ]; |
| 5231 | char buf1[BUFSIZ]; |
| 5232 | if (attr->mp_nexthop_len == 16) |
| 5233 | vty_out (vty, "%s", |
| 5234 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5235 | else if (attr->mp_nexthop_len == 32) |
| 5236 | vty_out (vty, "%s(%s)", |
| 5237 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ), |
| 5238 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ)); |
| 5239 | |
| 5240 | } |
| 5241 | #endif /* HAVE_IPV6 */ |
| 5242 | } |
| 5243 | |
| 5244 | label = decode_label (binfo->tag); |
| 5245 | |
| 5246 | vty_out (vty, "notag/%d", label); |
| 5247 | |
| 5248 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5249 | } |
| 5250 | |
| 5251 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5252 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5253 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5254 | struct bgp_info *binfo, int display, safi_t safi) |
| 5255 | { |
| 5256 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5257 | int len; |
| 5258 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5259 | /* short status lead text */ |
| 5260 | route_vty_short_status_out (vty, binfo); |
| 5261 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5262 | /* print prefix and mask */ |
| 5263 | if (! display) |
| 5264 | route_vty_out_route (p, vty); |
| 5265 | else |
| 5266 | vty_out (vty, "%*s", 17, " "); |
| 5267 | |
| 5268 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5269 | len = 17 - len; |
| 5270 | if (len < 1) |
| 5271 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5272 | else |
| 5273 | vty_out (vty, "%*s", len, " "); |
| 5274 | |
| 5275 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5276 | |
| 5277 | /* Print attribute */ |
| 5278 | attr = binfo->attr; |
| 5279 | if (attr) |
| 5280 | { |
| 5281 | /* Print aspath */ |
| 5282 | if (attr->aspath) |
| 5283 | aspath_print_vty (vty, attr->aspath); |
| 5284 | |
| 5285 | /* Print origin */ |
| 5286 | if (strlen (attr->aspath->str) == 0) |
| 5287 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5288 | else |
| 5289 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5290 | } |
| 5291 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5292 | } |
| 5293 | |
| 5294 | #define BGP_UPTIME_LEN 25 |
| 5295 | |
| 5296 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5297 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5298 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5299 | struct bgp_info *binfo, int display, safi_t safi) |
| 5300 | { |
| 5301 | struct attr *attr; |
| 5302 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5303 | char timebuf[BGP_UPTIME_LEN]; |
| 5304 | int len; |
| 5305 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5306 | bdi = binfo->damp_info; |
| 5307 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5308 | /* short status lead text */ |
| 5309 | route_vty_short_status_out (vty, binfo); |
| 5310 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5311 | /* print prefix and mask */ |
| 5312 | if (! display) |
| 5313 | route_vty_out_route (p, vty); |
| 5314 | else |
| 5315 | vty_out (vty, "%*s", 17, " "); |
| 5316 | |
| 5317 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5318 | len = 16 - len; |
| 5319 | if (len < 1) |
| 5320 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5321 | else |
| 5322 | vty_out (vty, "%*s", len, " "); |
| 5323 | |
| 5324 | len = vty_out (vty, "%d", bdi->flap); |
| 5325 | len = 5 - len; |
| 5326 | if (len < 1) |
| 5327 | vty_out (vty, " "); |
| 5328 | else |
| 5329 | vty_out (vty, "%*s ", len, " "); |
| 5330 | |
| 5331 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5332 | timebuf, BGP_UPTIME_LEN)); |
| 5333 | |
| 5334 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5335 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5336 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5337 | else |
| 5338 | vty_out (vty, "%*s ", 8, " "); |
| 5339 | |
| 5340 | /* Print attribute */ |
| 5341 | attr = binfo->attr; |
| 5342 | if (attr) |
| 5343 | { |
| 5344 | /* Print aspath */ |
| 5345 | if (attr->aspath) |
| 5346 | aspath_print_vty (vty, attr->aspath); |
| 5347 | |
| 5348 | /* Print origin */ |
| 5349 | if (strlen (attr->aspath->str) == 0) |
| 5350 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5351 | else |
| 5352 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5353 | } |
| 5354 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5355 | } |
| 5356 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5357 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5358 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5359 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5360 | { |
| 5361 | char buf[INET6_ADDRSTRLEN]; |
| 5362 | char buf1[BUFSIZ]; |
| 5363 | struct attr *attr; |
| 5364 | int sockunion_vty_out (struct vty *, union sockunion *); |
| 5365 | |
| 5366 | attr = binfo->attr; |
| 5367 | |
| 5368 | if (attr) |
| 5369 | { |
| 5370 | /* Line1 display AS-path, Aggregator */ |
| 5371 | if (attr->aspath) |
| 5372 | { |
| 5373 | vty_out (vty, " "); |
| 5374 | if (attr->aspath->length == 0) |
| 5375 | vty_out (vty, "Local"); |
| 5376 | else |
| 5377 | aspath_print_vty (vty, attr->aspath); |
| 5378 | } |
| 5379 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5380 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5381 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5382 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5383 | vty_out (vty, ", (stale)"); |
| 5384 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
| 5385 | vty_out (vty, ", (aggregated by %d %s)", attr->aggregator_as, |
| 5386 | inet_ntoa (attr->aggregator_addr)); |
| 5387 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5388 | vty_out (vty, ", (Received from a RR-client)"); |
| 5389 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5390 | vty_out (vty, ", (Received from a RS-client)"); |
| 5391 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5392 | vty_out (vty, ", (history entry)"); |
| 5393 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5394 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5395 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5396 | |
| 5397 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5398 | if (p->family == AF_INET) |
| 5399 | { |
| 5400 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
| 5401 | inet_ntoa (attr->mp_nexthop_global_in) : |
| 5402 | inet_ntoa (attr->nexthop)); |
| 5403 | } |
| 5404 | #ifdef HAVE_IPV6 |
| 5405 | else |
| 5406 | { |
| 5407 | vty_out (vty, " %s", |
| 5408 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, |
| 5409 | buf, INET6_ADDRSTRLEN)); |
| 5410 | } |
| 5411 | #endif /* HAVE_IPV6 */ |
| 5412 | |
| 5413 | if (binfo->peer == bgp->peer_self) |
| 5414 | { |
| 5415 | vty_out (vty, " from %s ", |
| 5416 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5417 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5418 | } |
| 5419 | else |
| 5420 | { |
| 5421 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5422 | vty_out (vty, " (inaccessible)"); |
| 5423 | else if (binfo->igpmetric) |
| 5424 | vty_out (vty, " (metric %d)", binfo->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5425 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5426 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5427 | vty_out (vty, " (%s)", inet_ntoa (attr->originator_id)); |
| 5428 | else |
| 5429 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5430 | } |
| 5431 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5432 | |
| 5433 | #ifdef HAVE_IPV6 |
| 5434 | /* display nexthop local */ |
| 5435 | if (attr->mp_nexthop_len == 32) |
| 5436 | { |
| 5437 | vty_out (vty, " (%s)%s", |
| 5438 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, |
| 5439 | buf, INET6_ADDRSTRLEN), |
| 5440 | VTY_NEWLINE); |
| 5441 | } |
| 5442 | #endif /* HAVE_IPV6 */ |
| 5443 | |
| 5444 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5445 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5446 | |
| 5447 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
| 5448 | vty_out (vty, ", metric %d", attr->med); |
| 5449 | |
| 5450 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
| 5451 | vty_out (vty, ", localpref %d", attr->local_pref); |
| 5452 | else |
| 5453 | vty_out (vty, ", localpref %d", bgp->default_local_pref); |
| 5454 | |
| 5455 | if (attr->weight != 0) |
| 5456 | vty_out (vty, ", weight %d", attr->weight); |
| 5457 | |
| 5458 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5459 | vty_out (vty, ", valid"); |
| 5460 | |
| 5461 | if (binfo->peer != bgp->peer_self) |
| 5462 | { |
| 5463 | if (binfo->peer->as == binfo->peer->local_as) |
| 5464 | vty_out (vty, ", internal"); |
| 5465 | else |
| 5466 | vty_out (vty, ", %s", |
| 5467 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 5468 | } |
| 5469 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 5470 | vty_out (vty, ", aggregated, local"); |
| 5471 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 5472 | vty_out (vty, ", sourced"); |
| 5473 | else |
| 5474 | vty_out (vty, ", sourced, local"); |
| 5475 | |
| 5476 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5477 | vty_out (vty, ", atomic-aggregate"); |
| 5478 | |
| 5479 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5480 | vty_out (vty, ", best"); |
| 5481 | |
| 5482 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5483 | |
| 5484 | /* Line 4 display Community */ |
| 5485 | if (attr->community) |
| 5486 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 5487 | VTY_NEWLINE); |
| 5488 | |
| 5489 | /* Line 5 display Extended-community */ |
| 5490 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
| 5491 | vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str, |
| 5492 | VTY_NEWLINE); |
| 5493 | |
| 5494 | /* Line 6 display Originator, Cluster-id */ |
| 5495 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 5496 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 5497 | { |
| 5498 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5499 | vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id)); |
| 5500 | |
| 5501 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 5502 | { |
| 5503 | int i; |
| 5504 | vty_out (vty, ", Cluster list: "); |
| 5505 | for (i = 0; i < attr->cluster->length / 4; i++) |
| 5506 | vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i])); |
| 5507 | } |
| 5508 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5509 | } |
| 5510 | |
| 5511 | if (binfo->damp_info) |
| 5512 | bgp_damp_info_vty (vty, binfo); |
| 5513 | |
| 5514 | /* Line 7 display Uptime */ |
| 5515 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); |
| 5516 | } |
| 5517 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5518 | } |
| 5519 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5520 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5521 | #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] | 5522 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 5523 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 5524 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 5525 | |
| 5526 | enum bgp_show_type |
| 5527 | { |
| 5528 | bgp_show_type_normal, |
| 5529 | bgp_show_type_regexp, |
| 5530 | bgp_show_type_prefix_list, |
| 5531 | bgp_show_type_filter_list, |
| 5532 | bgp_show_type_route_map, |
| 5533 | bgp_show_type_neighbor, |
| 5534 | bgp_show_type_cidr_only, |
| 5535 | bgp_show_type_prefix_longer, |
| 5536 | bgp_show_type_community_all, |
| 5537 | bgp_show_type_community, |
| 5538 | bgp_show_type_community_exact, |
| 5539 | bgp_show_type_community_list, |
| 5540 | bgp_show_type_community_list_exact, |
| 5541 | bgp_show_type_flap_statistics, |
| 5542 | bgp_show_type_flap_address, |
| 5543 | bgp_show_type_flap_prefix, |
| 5544 | bgp_show_type_flap_cidr_only, |
| 5545 | bgp_show_type_flap_regexp, |
| 5546 | bgp_show_type_flap_filter_list, |
| 5547 | bgp_show_type_flap_prefix_list, |
| 5548 | bgp_show_type_flap_prefix_longer, |
| 5549 | bgp_show_type_flap_route_map, |
| 5550 | bgp_show_type_flap_neighbor, |
| 5551 | bgp_show_type_dampend_paths, |
| 5552 | bgp_show_type_damp_neighbor |
| 5553 | }; |
| 5554 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5555 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5556 | 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] | 5557 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5558 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5559 | struct bgp_info *ri; |
| 5560 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5561 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5562 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5563 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5564 | |
| 5565 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5566 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5567 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5568 | /* Start processing of routes. */ |
| 5569 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5570 | if (rn->info != NULL) |
| 5571 | { |
| 5572 | display = 0; |
| 5573 | |
| 5574 | for (ri = rn->info; ri; ri = ri->next) |
| 5575 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5576 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5577 | || type == bgp_show_type_flap_address |
| 5578 | || type == bgp_show_type_flap_prefix |
| 5579 | || type == bgp_show_type_flap_cidr_only |
| 5580 | || type == bgp_show_type_flap_regexp |
| 5581 | || type == bgp_show_type_flap_filter_list |
| 5582 | || type == bgp_show_type_flap_prefix_list |
| 5583 | || type == bgp_show_type_flap_prefix_longer |
| 5584 | || type == bgp_show_type_flap_route_map |
| 5585 | || type == bgp_show_type_flap_neighbor |
| 5586 | || type == bgp_show_type_dampend_paths |
| 5587 | || type == bgp_show_type_damp_neighbor) |
| 5588 | { |
| 5589 | if (! ri->damp_info) |
| 5590 | continue; |
| 5591 | } |
| 5592 | if (type == bgp_show_type_regexp |
| 5593 | || type == bgp_show_type_flap_regexp) |
| 5594 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5595 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5596 | |
| 5597 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 5598 | continue; |
| 5599 | } |
| 5600 | if (type == bgp_show_type_prefix_list |
| 5601 | || type == bgp_show_type_flap_prefix_list) |
| 5602 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5603 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5604 | |
| 5605 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 5606 | continue; |
| 5607 | } |
| 5608 | if (type == bgp_show_type_filter_list |
| 5609 | || type == bgp_show_type_flap_filter_list) |
| 5610 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5611 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5612 | |
| 5613 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 5614 | continue; |
| 5615 | } |
| 5616 | if (type == bgp_show_type_route_map |
| 5617 | || type == bgp_show_type_flap_route_map) |
| 5618 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5619 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5620 | struct bgp_info binfo; |
| 5621 | struct attr dummy_attr; |
| 5622 | int ret; |
| 5623 | |
| 5624 | dummy_attr = *ri->attr; |
| 5625 | binfo.peer = ri->peer; |
| 5626 | binfo.attr = &dummy_attr; |
| 5627 | |
| 5628 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 5629 | |
| 5630 | if (ret == RMAP_DENYMATCH) |
| 5631 | continue; |
| 5632 | } |
| 5633 | if (type == bgp_show_type_neighbor |
| 5634 | || type == bgp_show_type_flap_neighbor |
| 5635 | || type == bgp_show_type_damp_neighbor) |
| 5636 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5637 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5638 | |
| 5639 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 5640 | continue; |
| 5641 | } |
| 5642 | if (type == bgp_show_type_cidr_only |
| 5643 | || type == bgp_show_type_flap_cidr_only) |
| 5644 | { |
| 5645 | u_int32_t destination; |
| 5646 | |
| 5647 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 5648 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 5649 | continue; |
| 5650 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 5651 | continue; |
| 5652 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 5653 | continue; |
| 5654 | } |
| 5655 | if (type == bgp_show_type_prefix_longer |
| 5656 | || type == bgp_show_type_flap_prefix_longer) |
| 5657 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5658 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5659 | |
| 5660 | if (! prefix_match (p, &rn->p)) |
| 5661 | continue; |
| 5662 | } |
| 5663 | if (type == bgp_show_type_community_all) |
| 5664 | { |
| 5665 | if (! ri->attr->community) |
| 5666 | continue; |
| 5667 | } |
| 5668 | if (type == bgp_show_type_community) |
| 5669 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5670 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5671 | |
| 5672 | if (! ri->attr->community || |
| 5673 | ! community_match (ri->attr->community, com)) |
| 5674 | continue; |
| 5675 | } |
| 5676 | if (type == bgp_show_type_community_exact) |
| 5677 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5678 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5679 | |
| 5680 | if (! ri->attr->community || |
| 5681 | ! community_cmp (ri->attr->community, com)) |
| 5682 | continue; |
| 5683 | } |
| 5684 | if (type == bgp_show_type_community_list) |
| 5685 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5686 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5687 | |
| 5688 | if (! community_list_match (ri->attr->community, list)) |
| 5689 | continue; |
| 5690 | } |
| 5691 | if (type == bgp_show_type_community_list_exact) |
| 5692 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5693 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5694 | |
| 5695 | if (! community_list_exact_match (ri->attr->community, list)) |
| 5696 | continue; |
| 5697 | } |
| 5698 | if (type == bgp_show_type_flap_address |
| 5699 | || type == bgp_show_type_flap_prefix) |
| 5700 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5701 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5702 | |
| 5703 | if (! prefix_match (&rn->p, p)) |
| 5704 | continue; |
| 5705 | |
| 5706 | if (type == bgp_show_type_flap_prefix) |
| 5707 | if (p->prefixlen != rn->p.prefixlen) |
| 5708 | continue; |
| 5709 | } |
| 5710 | if (type == bgp_show_type_dampend_paths |
| 5711 | || type == bgp_show_type_damp_neighbor) |
| 5712 | { |
| 5713 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 5714 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 5715 | continue; |
| 5716 | } |
| 5717 | |
| 5718 | if (header) |
| 5719 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5720 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 5721 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 5722 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5723 | if (type == bgp_show_type_dampend_paths |
| 5724 | || type == bgp_show_type_damp_neighbor) |
| 5725 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 5726 | else if (type == bgp_show_type_flap_statistics |
| 5727 | || type == bgp_show_type_flap_address |
| 5728 | || type == bgp_show_type_flap_prefix |
| 5729 | || type == bgp_show_type_flap_cidr_only |
| 5730 | || type == bgp_show_type_flap_regexp |
| 5731 | || type == bgp_show_type_flap_filter_list |
| 5732 | || type == bgp_show_type_flap_prefix_list |
| 5733 | || type == bgp_show_type_flap_prefix_longer |
| 5734 | || type == bgp_show_type_flap_route_map |
| 5735 | || type == bgp_show_type_flap_neighbor) |
| 5736 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 5737 | else |
| 5738 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5739 | header = 0; |
| 5740 | } |
| 5741 | |
| 5742 | if (type == bgp_show_type_dampend_paths |
| 5743 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5744 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5745 | else if (type == bgp_show_type_flap_statistics |
| 5746 | || type == bgp_show_type_flap_address |
| 5747 | || type == bgp_show_type_flap_prefix |
| 5748 | || type == bgp_show_type_flap_cidr_only |
| 5749 | || type == bgp_show_type_flap_regexp |
| 5750 | || type == bgp_show_type_flap_filter_list |
| 5751 | || type == bgp_show_type_flap_prefix_list |
| 5752 | || type == bgp_show_type_flap_prefix_longer |
| 5753 | || type == bgp_show_type_flap_route_map |
| 5754 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5755 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5756 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5757 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5758 | display++; |
| 5759 | } |
| 5760 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5761 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5762 | } |
| 5763 | |
| 5764 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5765 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5766 | { |
| 5767 | if (type == bgp_show_type_normal) |
| 5768 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 5769 | } |
| 5770 | else |
| 5771 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5772 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5773 | |
| 5774 | return CMD_SUCCESS; |
| 5775 | } |
| 5776 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5777 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5778 | 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] | 5779 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5780 | { |
| 5781 | struct bgp_table *table; |
| 5782 | |
| 5783 | if (bgp == NULL) { |
| 5784 | bgp = bgp_get_default (); |
| 5785 | } |
| 5786 | |
| 5787 | if (bgp == NULL) |
| 5788 | { |
| 5789 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5790 | return CMD_WARNING; |
| 5791 | } |
| 5792 | |
| 5793 | |
| 5794 | table = bgp->rib[afi][safi]; |
| 5795 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5796 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5797 | } |
| 5798 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5799 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5800 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5801 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 5802 | struct bgp_node *rn, |
| 5803 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 5804 | { |
| 5805 | struct bgp_info *ri; |
| 5806 | struct prefix *p; |
| 5807 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5808 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5809 | char buf1[INET6_ADDRSTRLEN]; |
| 5810 | char buf2[INET6_ADDRSTRLEN]; |
| 5811 | int count = 0; |
| 5812 | int best = 0; |
| 5813 | int suppress = 0; |
| 5814 | int no_export = 0; |
| 5815 | int no_advertise = 0; |
| 5816 | int local_as = 0; |
| 5817 | int first = 0; |
| 5818 | |
| 5819 | p = &rn->p; |
| 5820 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 5821 | (safi == SAFI_MPLS_VPN ? |
| 5822 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 5823 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 5824 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 5825 | p->prefixlen, VTY_NEWLINE); |
| 5826 | |
| 5827 | for (ri = rn->info; ri; ri = ri->next) |
| 5828 | { |
| 5829 | count++; |
| 5830 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 5831 | { |
| 5832 | best = count; |
| 5833 | if (ri->suppress) |
| 5834 | suppress = 1; |
| 5835 | if (ri->attr->community != NULL) |
| 5836 | { |
| 5837 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 5838 | no_advertise = 1; |
| 5839 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 5840 | no_export = 1; |
| 5841 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 5842 | local_as = 1; |
| 5843 | } |
| 5844 | } |
| 5845 | } |
| 5846 | |
| 5847 | vty_out (vty, "Paths: (%d available", count); |
| 5848 | if (best) |
| 5849 | { |
| 5850 | vty_out (vty, ", best #%d", best); |
| 5851 | if (safi == SAFI_UNICAST) |
| 5852 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 5853 | } |
| 5854 | else |
| 5855 | vty_out (vty, ", no best path"); |
| 5856 | if (no_advertise) |
| 5857 | vty_out (vty, ", not advertised to any peer"); |
| 5858 | else if (no_export) |
| 5859 | vty_out (vty, ", not advertised to EBGP peer"); |
| 5860 | else if (local_as) |
| 5861 | vty_out (vty, ", not advertised outside local AS"); |
| 5862 | if (suppress) |
| 5863 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 5864 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 5865 | |
| 5866 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5867 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5868 | { |
| 5869 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 5870 | { |
| 5871 | if (! first) |
| 5872 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 5873 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 5874 | first = 1; |
| 5875 | } |
| 5876 | } |
| 5877 | if (! first) |
| 5878 | vty_out (vty, " Not advertised to any peer"); |
| 5879 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5880 | } |
| 5881 | |
| 5882 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5883 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5884 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5885 | struct bgp_table *rib, const char *ip_str, |
| 5886 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5887 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5888 | { |
| 5889 | int ret; |
| 5890 | int header; |
| 5891 | int display = 0; |
| 5892 | struct prefix match; |
| 5893 | struct bgp_node *rn; |
| 5894 | struct bgp_node *rm; |
| 5895 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5896 | struct bgp_table *table; |
| 5897 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5898 | /* Check IP address argument. */ |
| 5899 | ret = str2prefix (ip_str, &match); |
| 5900 | if (! ret) |
| 5901 | { |
| 5902 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 5903 | return CMD_WARNING; |
| 5904 | } |
| 5905 | |
| 5906 | match.family = afi2family (afi); |
| 5907 | |
| 5908 | if (safi == SAFI_MPLS_VPN) |
| 5909 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5910 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5911 | { |
| 5912 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 5913 | continue; |
| 5914 | |
| 5915 | if ((table = rn->info) != NULL) |
| 5916 | { |
| 5917 | header = 1; |
| 5918 | |
| 5919 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 5920 | { |
| 5921 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 5922 | continue; |
| 5923 | |
| 5924 | for (ri = rm->info; ri; ri = ri->next) |
| 5925 | { |
| 5926 | if (header) |
| 5927 | { |
| 5928 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 5929 | AFI_IP, SAFI_MPLS_VPN); |
| 5930 | |
| 5931 | header = 0; |
| 5932 | } |
| 5933 | display++; |
| 5934 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 5935 | } |
| 5936 | } |
| 5937 | } |
| 5938 | } |
| 5939 | } |
| 5940 | else |
| 5941 | { |
| 5942 | header = 1; |
| 5943 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5944 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5945 | { |
| 5946 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 5947 | { |
| 5948 | for (ri = rn->info; ri; ri = ri->next) |
| 5949 | { |
| 5950 | if (header) |
| 5951 | { |
| 5952 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 5953 | header = 0; |
| 5954 | } |
| 5955 | display++; |
| 5956 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 5957 | } |
| 5958 | } |
| 5959 | } |
| 5960 | } |
| 5961 | |
| 5962 | if (! display) |
| 5963 | { |
| 5964 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 5965 | return CMD_WARNING; |
| 5966 | } |
| 5967 | |
| 5968 | return CMD_SUCCESS; |
| 5969 | } |
| 5970 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5971 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5972 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5973 | 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] | 5974 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5975 | int prefix_check) |
| 5976 | { |
| 5977 | struct bgp *bgp; |
| 5978 | |
| 5979 | /* BGP structure lookup. */ |
| 5980 | if (view_name) |
| 5981 | { |
| 5982 | bgp = bgp_lookup_by_name (view_name); |
| 5983 | if (bgp == NULL) |
| 5984 | { |
| 5985 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 5986 | return CMD_WARNING; |
| 5987 | } |
| 5988 | } |
| 5989 | else |
| 5990 | { |
| 5991 | bgp = bgp_get_default (); |
| 5992 | if (bgp == NULL) |
| 5993 | { |
| 5994 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5995 | return CMD_WARNING; |
| 5996 | } |
| 5997 | } |
| 5998 | |
| 5999 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6000 | afi, safi, prd, prefix_check); |
| 6001 | } |
| 6002 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6003 | /* BGP route print out function. */ |
| 6004 | DEFUN (show_ip_bgp, |
| 6005 | show_ip_bgp_cmd, |
| 6006 | "show ip bgp", |
| 6007 | SHOW_STR |
| 6008 | IP_STR |
| 6009 | BGP_STR) |
| 6010 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6011 | 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] | 6012 | } |
| 6013 | |
| 6014 | DEFUN (show_ip_bgp_ipv4, |
| 6015 | show_ip_bgp_ipv4_cmd, |
| 6016 | "show ip bgp ipv4 (unicast|multicast)", |
| 6017 | SHOW_STR |
| 6018 | IP_STR |
| 6019 | BGP_STR |
| 6020 | "Address family\n" |
| 6021 | "Address Family modifier\n" |
| 6022 | "Address Family modifier\n") |
| 6023 | { |
| 6024 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6025 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6026 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6027 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6028 | 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] | 6029 | } |
| 6030 | |
| 6031 | DEFUN (show_ip_bgp_route, |
| 6032 | show_ip_bgp_route_cmd, |
| 6033 | "show ip bgp A.B.C.D", |
| 6034 | SHOW_STR |
| 6035 | IP_STR |
| 6036 | BGP_STR |
| 6037 | "Network in the BGP routing table to display\n") |
| 6038 | { |
| 6039 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6040 | } |
| 6041 | |
| 6042 | DEFUN (show_ip_bgp_ipv4_route, |
| 6043 | show_ip_bgp_ipv4_route_cmd, |
| 6044 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6045 | SHOW_STR |
| 6046 | IP_STR |
| 6047 | BGP_STR |
| 6048 | "Address family\n" |
| 6049 | "Address Family modifier\n" |
| 6050 | "Address Family modifier\n" |
| 6051 | "Network in the BGP routing table to display\n") |
| 6052 | { |
| 6053 | if (strncmp (argv[0], "m", 1) == 0) |
| 6054 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6055 | |
| 6056 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6057 | } |
| 6058 | |
| 6059 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6060 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6061 | "show ip bgp vpnv4 all A.B.C.D", |
| 6062 | SHOW_STR |
| 6063 | IP_STR |
| 6064 | BGP_STR |
| 6065 | "Display VPNv4 NLRI specific information\n" |
| 6066 | "Display information about all VPNv4 NLRIs\n" |
| 6067 | "Network in the BGP routing table to display\n") |
| 6068 | { |
| 6069 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6070 | } |
| 6071 | |
| 6072 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6073 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6074 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6075 | SHOW_STR |
| 6076 | IP_STR |
| 6077 | BGP_STR |
| 6078 | "Display VPNv4 NLRI specific information\n" |
| 6079 | "Display information for a route distinguisher\n" |
| 6080 | "VPN Route Distinguisher\n" |
| 6081 | "Network in the BGP routing table to display\n") |
| 6082 | { |
| 6083 | int ret; |
| 6084 | struct prefix_rd prd; |
| 6085 | |
| 6086 | ret = str2prefix_rd (argv[0], &prd); |
| 6087 | if (! ret) |
| 6088 | { |
| 6089 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6090 | return CMD_WARNING; |
| 6091 | } |
| 6092 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6093 | } |
| 6094 | |
| 6095 | DEFUN (show_ip_bgp_prefix, |
| 6096 | show_ip_bgp_prefix_cmd, |
| 6097 | "show ip bgp A.B.C.D/M", |
| 6098 | SHOW_STR |
| 6099 | IP_STR |
| 6100 | BGP_STR |
| 6101 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6102 | { |
| 6103 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6104 | } |
| 6105 | |
| 6106 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6107 | show_ip_bgp_ipv4_prefix_cmd, |
| 6108 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6109 | SHOW_STR |
| 6110 | IP_STR |
| 6111 | BGP_STR |
| 6112 | "Address family\n" |
| 6113 | "Address Family modifier\n" |
| 6114 | "Address Family modifier\n" |
| 6115 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6116 | { |
| 6117 | if (strncmp (argv[0], "m", 1) == 0) |
| 6118 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6119 | |
| 6120 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6121 | } |
| 6122 | |
| 6123 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6124 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6125 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6126 | SHOW_STR |
| 6127 | IP_STR |
| 6128 | BGP_STR |
| 6129 | "Display VPNv4 NLRI specific information\n" |
| 6130 | "Display information about all VPNv4 NLRIs\n" |
| 6131 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6132 | { |
| 6133 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6134 | } |
| 6135 | |
| 6136 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6137 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6138 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6139 | SHOW_STR |
| 6140 | IP_STR |
| 6141 | BGP_STR |
| 6142 | "Display VPNv4 NLRI specific information\n" |
| 6143 | "Display information for a route distinguisher\n" |
| 6144 | "VPN Route Distinguisher\n" |
| 6145 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6146 | { |
| 6147 | int ret; |
| 6148 | struct prefix_rd prd; |
| 6149 | |
| 6150 | ret = str2prefix_rd (argv[0], &prd); |
| 6151 | if (! ret) |
| 6152 | { |
| 6153 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6154 | return CMD_WARNING; |
| 6155 | } |
| 6156 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6157 | } |
| 6158 | |
| 6159 | DEFUN (show_ip_bgp_view, |
| 6160 | show_ip_bgp_view_cmd, |
| 6161 | "show ip bgp view WORD", |
| 6162 | SHOW_STR |
| 6163 | IP_STR |
| 6164 | BGP_STR |
| 6165 | "BGP view\n" |
| 6166 | "BGP view name\n") |
| 6167 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6168 | struct bgp *bgp; |
| 6169 | |
| 6170 | /* BGP structure lookup. */ |
| 6171 | bgp = bgp_lookup_by_name (argv[0]); |
| 6172 | if (bgp == NULL) |
| 6173 | { |
| 6174 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6175 | return CMD_WARNING; |
| 6176 | } |
| 6177 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6178 | 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] | 6179 | } |
| 6180 | |
| 6181 | DEFUN (show_ip_bgp_view_route, |
| 6182 | show_ip_bgp_view_route_cmd, |
| 6183 | "show ip bgp view WORD A.B.C.D", |
| 6184 | SHOW_STR |
| 6185 | IP_STR |
| 6186 | BGP_STR |
| 6187 | "BGP view\n" |
| 6188 | "BGP view name\n" |
| 6189 | "Network in the BGP routing table to display\n") |
| 6190 | { |
| 6191 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6192 | } |
| 6193 | |
| 6194 | DEFUN (show_ip_bgp_view_prefix, |
| 6195 | show_ip_bgp_view_prefix_cmd, |
| 6196 | "show ip bgp view WORD A.B.C.D/M", |
| 6197 | SHOW_STR |
| 6198 | IP_STR |
| 6199 | BGP_STR |
| 6200 | "BGP view\n" |
| 6201 | "BGP view name\n" |
| 6202 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6203 | { |
| 6204 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6205 | } |
| 6206 | |
| 6207 | #ifdef HAVE_IPV6 |
| 6208 | DEFUN (show_bgp, |
| 6209 | show_bgp_cmd, |
| 6210 | "show bgp", |
| 6211 | SHOW_STR |
| 6212 | BGP_STR) |
| 6213 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6214 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6215 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6216 | } |
| 6217 | |
| 6218 | ALIAS (show_bgp, |
| 6219 | show_bgp_ipv6_cmd, |
| 6220 | "show bgp ipv6", |
| 6221 | SHOW_STR |
| 6222 | BGP_STR |
| 6223 | "Address family\n") |
| 6224 | |
| 6225 | /* old command */ |
| 6226 | DEFUN (show_ipv6_bgp, |
| 6227 | show_ipv6_bgp_cmd, |
| 6228 | "show ipv6 bgp", |
| 6229 | SHOW_STR |
| 6230 | IP_STR |
| 6231 | BGP_STR) |
| 6232 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6233 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6234 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6235 | } |
| 6236 | |
| 6237 | DEFUN (show_bgp_route, |
| 6238 | show_bgp_route_cmd, |
| 6239 | "show bgp X:X::X:X", |
| 6240 | SHOW_STR |
| 6241 | BGP_STR |
| 6242 | "Network in the BGP routing table to display\n") |
| 6243 | { |
| 6244 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6245 | } |
| 6246 | |
| 6247 | ALIAS (show_bgp_route, |
| 6248 | show_bgp_ipv6_route_cmd, |
| 6249 | "show bgp ipv6 X:X::X:X", |
| 6250 | SHOW_STR |
| 6251 | BGP_STR |
| 6252 | "Address family\n" |
| 6253 | "Network in the BGP routing table to display\n") |
| 6254 | |
| 6255 | /* old command */ |
| 6256 | DEFUN (show_ipv6_bgp_route, |
| 6257 | show_ipv6_bgp_route_cmd, |
| 6258 | "show ipv6 bgp X:X::X:X", |
| 6259 | SHOW_STR |
| 6260 | IP_STR |
| 6261 | BGP_STR |
| 6262 | "Network in the BGP routing table to display\n") |
| 6263 | { |
| 6264 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6265 | } |
| 6266 | |
| 6267 | DEFUN (show_bgp_prefix, |
| 6268 | show_bgp_prefix_cmd, |
| 6269 | "show bgp X:X::X:X/M", |
| 6270 | SHOW_STR |
| 6271 | BGP_STR |
| 6272 | "IPv6 prefix <network>/<length>\n") |
| 6273 | { |
| 6274 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6275 | } |
| 6276 | |
| 6277 | ALIAS (show_bgp_prefix, |
| 6278 | show_bgp_ipv6_prefix_cmd, |
| 6279 | "show bgp ipv6 X:X::X:X/M", |
| 6280 | SHOW_STR |
| 6281 | BGP_STR |
| 6282 | "Address family\n" |
| 6283 | "IPv6 prefix <network>/<length>\n") |
| 6284 | |
| 6285 | /* old command */ |
| 6286 | DEFUN (show_ipv6_bgp_prefix, |
| 6287 | show_ipv6_bgp_prefix_cmd, |
| 6288 | "show ipv6 bgp X:X::X:X/M", |
| 6289 | SHOW_STR |
| 6290 | IP_STR |
| 6291 | BGP_STR |
| 6292 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6293 | { |
| 6294 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6295 | } |
| 6296 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6297 | DEFUN (show_bgp_view, |
| 6298 | show_bgp_view_cmd, |
| 6299 | "show bgp view WORD", |
| 6300 | SHOW_STR |
| 6301 | BGP_STR |
| 6302 | "BGP view\n" |
| 6303 | "View name\n") |
| 6304 | { |
| 6305 | struct bgp *bgp; |
| 6306 | |
| 6307 | /* BGP structure lookup. */ |
| 6308 | bgp = bgp_lookup_by_name (argv[0]); |
| 6309 | if (bgp == NULL) |
| 6310 | { |
| 6311 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6312 | return CMD_WARNING; |
| 6313 | } |
| 6314 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6315 | 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] | 6316 | } |
| 6317 | |
| 6318 | ALIAS (show_bgp_view, |
| 6319 | show_bgp_view_ipv6_cmd, |
| 6320 | "show bgp view WORD ipv6", |
| 6321 | SHOW_STR |
| 6322 | BGP_STR |
| 6323 | "BGP view\n" |
| 6324 | "View name\n" |
| 6325 | "Address family\n") |
| 6326 | |
| 6327 | DEFUN (show_bgp_view_route, |
| 6328 | show_bgp_view_route_cmd, |
| 6329 | "show bgp view WORD X:X::X:X", |
| 6330 | SHOW_STR |
| 6331 | BGP_STR |
| 6332 | "BGP view\n" |
| 6333 | "View name\n" |
| 6334 | "Network in the BGP routing table to display\n") |
| 6335 | { |
| 6336 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6337 | } |
| 6338 | |
| 6339 | ALIAS (show_bgp_view_route, |
| 6340 | show_bgp_view_ipv6_route_cmd, |
| 6341 | "show bgp view WORD ipv6 X:X::X:X", |
| 6342 | SHOW_STR |
| 6343 | BGP_STR |
| 6344 | "BGP view\n" |
| 6345 | "View name\n" |
| 6346 | "Address family\n" |
| 6347 | "Network in the BGP routing table to display\n") |
| 6348 | |
| 6349 | DEFUN (show_bgp_view_prefix, |
| 6350 | show_bgp_view_prefix_cmd, |
| 6351 | "show bgp view WORD X:X::X:X/M", |
| 6352 | SHOW_STR |
| 6353 | BGP_STR |
| 6354 | "BGP view\n" |
| 6355 | "View name\n" |
| 6356 | "IPv6 prefix <network>/<length>\n") |
| 6357 | { |
| 6358 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6359 | } |
| 6360 | |
| 6361 | ALIAS (show_bgp_view_prefix, |
| 6362 | show_bgp_view_ipv6_prefix_cmd, |
| 6363 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 6364 | SHOW_STR |
| 6365 | BGP_STR |
| 6366 | "BGP view\n" |
| 6367 | "View name\n" |
| 6368 | "Address family\n" |
| 6369 | "IPv6 prefix <network>/<length>\n") |
| 6370 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6371 | /* old command */ |
| 6372 | DEFUN (show_ipv6_mbgp, |
| 6373 | show_ipv6_mbgp_cmd, |
| 6374 | "show ipv6 mbgp", |
| 6375 | SHOW_STR |
| 6376 | IP_STR |
| 6377 | MBGP_STR) |
| 6378 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6379 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6380 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6381 | } |
| 6382 | |
| 6383 | /* old command */ |
| 6384 | DEFUN (show_ipv6_mbgp_route, |
| 6385 | show_ipv6_mbgp_route_cmd, |
| 6386 | "show ipv6 mbgp X:X::X:X", |
| 6387 | SHOW_STR |
| 6388 | IP_STR |
| 6389 | MBGP_STR |
| 6390 | "Network in the MBGP routing table to display\n") |
| 6391 | { |
| 6392 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6393 | } |
| 6394 | |
| 6395 | /* old command */ |
| 6396 | DEFUN (show_ipv6_mbgp_prefix, |
| 6397 | show_ipv6_mbgp_prefix_cmd, |
| 6398 | "show ipv6 mbgp X:X::X:X/M", |
| 6399 | SHOW_STR |
| 6400 | IP_STR |
| 6401 | MBGP_STR |
| 6402 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6403 | { |
| 6404 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6405 | } |
| 6406 | #endif |
| 6407 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6408 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6409 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6410 | 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] | 6411 | safi_t safi, enum bgp_show_type type) |
| 6412 | { |
| 6413 | int i; |
| 6414 | struct buffer *b; |
| 6415 | char *regstr; |
| 6416 | int first; |
| 6417 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6418 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6419 | |
| 6420 | first = 0; |
| 6421 | b = buffer_new (1024); |
| 6422 | for (i = 0; i < argc; i++) |
| 6423 | { |
| 6424 | if (first) |
| 6425 | buffer_putc (b, ' '); |
| 6426 | else |
| 6427 | { |
| 6428 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6429 | continue; |
| 6430 | first = 1; |
| 6431 | } |
| 6432 | |
| 6433 | buffer_putstr (b, argv[i]); |
| 6434 | } |
| 6435 | buffer_putc (b, '\0'); |
| 6436 | |
| 6437 | regstr = buffer_getstr (b); |
| 6438 | buffer_free (b); |
| 6439 | |
| 6440 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6441 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6442 | if (! regex) |
| 6443 | { |
| 6444 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 6445 | VTY_NEWLINE); |
| 6446 | return CMD_WARNING; |
| 6447 | } |
| 6448 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6449 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 6450 | bgp_regex_free (regex); |
| 6451 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6452 | } |
| 6453 | |
| 6454 | DEFUN (show_ip_bgp_regexp, |
| 6455 | show_ip_bgp_regexp_cmd, |
| 6456 | "show ip bgp regexp .LINE", |
| 6457 | SHOW_STR |
| 6458 | IP_STR |
| 6459 | BGP_STR |
| 6460 | "Display routes matching the AS path regular expression\n" |
| 6461 | "A regular-expression to match the BGP AS paths\n") |
| 6462 | { |
| 6463 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6464 | bgp_show_type_regexp); |
| 6465 | } |
| 6466 | |
| 6467 | DEFUN (show_ip_bgp_flap_regexp, |
| 6468 | show_ip_bgp_flap_regexp_cmd, |
| 6469 | "show ip bgp flap-statistics regexp .LINE", |
| 6470 | SHOW_STR |
| 6471 | IP_STR |
| 6472 | BGP_STR |
| 6473 | "Display flap statistics of routes\n" |
| 6474 | "Display routes matching the AS path regular expression\n" |
| 6475 | "A regular-expression to match the BGP AS paths\n") |
| 6476 | { |
| 6477 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6478 | bgp_show_type_flap_regexp); |
| 6479 | } |
| 6480 | |
| 6481 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 6482 | show_ip_bgp_ipv4_regexp_cmd, |
| 6483 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 6484 | SHOW_STR |
| 6485 | IP_STR |
| 6486 | BGP_STR |
| 6487 | "Address family\n" |
| 6488 | "Address Family modifier\n" |
| 6489 | "Address Family modifier\n" |
| 6490 | "Display routes matching the AS path regular expression\n" |
| 6491 | "A regular-expression to match the BGP AS paths\n") |
| 6492 | { |
| 6493 | if (strncmp (argv[0], "m", 1) == 0) |
| 6494 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 6495 | bgp_show_type_regexp); |
| 6496 | |
| 6497 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6498 | bgp_show_type_regexp); |
| 6499 | } |
| 6500 | |
| 6501 | #ifdef HAVE_IPV6 |
| 6502 | DEFUN (show_bgp_regexp, |
| 6503 | show_bgp_regexp_cmd, |
| 6504 | "show bgp regexp .LINE", |
| 6505 | SHOW_STR |
| 6506 | BGP_STR |
| 6507 | "Display routes matching the AS path regular expression\n" |
| 6508 | "A regular-expression to match the BGP AS paths\n") |
| 6509 | { |
| 6510 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6511 | bgp_show_type_regexp); |
| 6512 | } |
| 6513 | |
| 6514 | ALIAS (show_bgp_regexp, |
| 6515 | show_bgp_ipv6_regexp_cmd, |
| 6516 | "show bgp ipv6 regexp .LINE", |
| 6517 | SHOW_STR |
| 6518 | BGP_STR |
| 6519 | "Address family\n" |
| 6520 | "Display routes matching the AS path regular expression\n" |
| 6521 | "A regular-expression to match the BGP AS paths\n") |
| 6522 | |
| 6523 | /* old command */ |
| 6524 | DEFUN (show_ipv6_bgp_regexp, |
| 6525 | show_ipv6_bgp_regexp_cmd, |
| 6526 | "show ipv6 bgp regexp .LINE", |
| 6527 | SHOW_STR |
| 6528 | IP_STR |
| 6529 | BGP_STR |
| 6530 | "Display routes matching the AS path regular expression\n" |
| 6531 | "A regular-expression to match the BGP AS paths\n") |
| 6532 | { |
| 6533 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6534 | bgp_show_type_regexp); |
| 6535 | } |
| 6536 | |
| 6537 | /* old command */ |
| 6538 | DEFUN (show_ipv6_mbgp_regexp, |
| 6539 | show_ipv6_mbgp_regexp_cmd, |
| 6540 | "show ipv6 mbgp regexp .LINE", |
| 6541 | SHOW_STR |
| 6542 | IP_STR |
| 6543 | BGP_STR |
| 6544 | "Display routes matching the AS path regular expression\n" |
| 6545 | "A regular-expression to match the MBGP AS paths\n") |
| 6546 | { |
| 6547 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 6548 | bgp_show_type_regexp); |
| 6549 | } |
| 6550 | #endif /* HAVE_IPV6 */ |
| 6551 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6552 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6553 | 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] | 6554 | safi_t safi, enum bgp_show_type type) |
| 6555 | { |
| 6556 | struct prefix_list *plist; |
| 6557 | |
| 6558 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 6559 | if (plist == NULL) |
| 6560 | { |
| 6561 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 6562 | prefix_list_str, VTY_NEWLINE); |
| 6563 | return CMD_WARNING; |
| 6564 | } |
| 6565 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6566 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6567 | } |
| 6568 | |
| 6569 | DEFUN (show_ip_bgp_prefix_list, |
| 6570 | show_ip_bgp_prefix_list_cmd, |
| 6571 | "show ip bgp prefix-list WORD", |
| 6572 | SHOW_STR |
| 6573 | IP_STR |
| 6574 | BGP_STR |
| 6575 | "Display routes conforming to the prefix-list\n" |
| 6576 | "IP prefix-list name\n") |
| 6577 | { |
| 6578 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6579 | bgp_show_type_prefix_list); |
| 6580 | } |
| 6581 | |
| 6582 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 6583 | show_ip_bgp_flap_prefix_list_cmd, |
| 6584 | "show ip bgp flap-statistics prefix-list WORD", |
| 6585 | SHOW_STR |
| 6586 | IP_STR |
| 6587 | BGP_STR |
| 6588 | "Display flap statistics of routes\n" |
| 6589 | "Display routes conforming to the prefix-list\n" |
| 6590 | "IP prefix-list name\n") |
| 6591 | { |
| 6592 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6593 | bgp_show_type_flap_prefix_list); |
| 6594 | } |
| 6595 | |
| 6596 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 6597 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 6598 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 6599 | SHOW_STR |
| 6600 | IP_STR |
| 6601 | BGP_STR |
| 6602 | "Address family\n" |
| 6603 | "Address Family modifier\n" |
| 6604 | "Address Family modifier\n" |
| 6605 | "Display routes conforming to the prefix-list\n" |
| 6606 | "IP prefix-list name\n") |
| 6607 | { |
| 6608 | if (strncmp (argv[0], "m", 1) == 0) |
| 6609 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6610 | bgp_show_type_prefix_list); |
| 6611 | |
| 6612 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6613 | bgp_show_type_prefix_list); |
| 6614 | } |
| 6615 | |
| 6616 | #ifdef HAVE_IPV6 |
| 6617 | DEFUN (show_bgp_prefix_list, |
| 6618 | show_bgp_prefix_list_cmd, |
| 6619 | "show bgp prefix-list WORD", |
| 6620 | SHOW_STR |
| 6621 | BGP_STR |
| 6622 | "Display routes conforming to the prefix-list\n" |
| 6623 | "IPv6 prefix-list name\n") |
| 6624 | { |
| 6625 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6626 | bgp_show_type_prefix_list); |
| 6627 | } |
| 6628 | |
| 6629 | ALIAS (show_bgp_prefix_list, |
| 6630 | show_bgp_ipv6_prefix_list_cmd, |
| 6631 | "show bgp ipv6 prefix-list WORD", |
| 6632 | SHOW_STR |
| 6633 | BGP_STR |
| 6634 | "Address family\n" |
| 6635 | "Display routes conforming to the prefix-list\n" |
| 6636 | "IPv6 prefix-list name\n") |
| 6637 | |
| 6638 | /* old command */ |
| 6639 | DEFUN (show_ipv6_bgp_prefix_list, |
| 6640 | show_ipv6_bgp_prefix_list_cmd, |
| 6641 | "show ipv6 bgp prefix-list WORD", |
| 6642 | SHOW_STR |
| 6643 | IPV6_STR |
| 6644 | BGP_STR |
| 6645 | "Display routes matching the prefix-list\n" |
| 6646 | "IPv6 prefix-list name\n") |
| 6647 | { |
| 6648 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6649 | bgp_show_type_prefix_list); |
| 6650 | } |
| 6651 | |
| 6652 | /* old command */ |
| 6653 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 6654 | show_ipv6_mbgp_prefix_list_cmd, |
| 6655 | "show ipv6 mbgp prefix-list WORD", |
| 6656 | SHOW_STR |
| 6657 | IPV6_STR |
| 6658 | MBGP_STR |
| 6659 | "Display routes matching the prefix-list\n" |
| 6660 | "IPv6 prefix-list name\n") |
| 6661 | { |
| 6662 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6663 | bgp_show_type_prefix_list); |
| 6664 | } |
| 6665 | #endif /* HAVE_IPV6 */ |
| 6666 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6667 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6668 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6669 | safi_t safi, enum bgp_show_type type) |
| 6670 | { |
| 6671 | struct as_list *as_list; |
| 6672 | |
| 6673 | as_list = as_list_lookup (filter); |
| 6674 | if (as_list == NULL) |
| 6675 | { |
| 6676 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 6677 | return CMD_WARNING; |
| 6678 | } |
| 6679 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6680 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6681 | } |
| 6682 | |
| 6683 | DEFUN (show_ip_bgp_filter_list, |
| 6684 | show_ip_bgp_filter_list_cmd, |
| 6685 | "show ip bgp filter-list WORD", |
| 6686 | SHOW_STR |
| 6687 | IP_STR |
| 6688 | BGP_STR |
| 6689 | "Display routes conforming to the filter-list\n" |
| 6690 | "Regular expression access list name\n") |
| 6691 | { |
| 6692 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6693 | bgp_show_type_filter_list); |
| 6694 | } |
| 6695 | |
| 6696 | DEFUN (show_ip_bgp_flap_filter_list, |
| 6697 | show_ip_bgp_flap_filter_list_cmd, |
| 6698 | "show ip bgp flap-statistics filter-list WORD", |
| 6699 | SHOW_STR |
| 6700 | IP_STR |
| 6701 | BGP_STR |
| 6702 | "Display flap statistics of routes\n" |
| 6703 | "Display routes conforming to the filter-list\n" |
| 6704 | "Regular expression access list name\n") |
| 6705 | { |
| 6706 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6707 | bgp_show_type_flap_filter_list); |
| 6708 | } |
| 6709 | |
| 6710 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 6711 | show_ip_bgp_ipv4_filter_list_cmd, |
| 6712 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 6713 | SHOW_STR |
| 6714 | IP_STR |
| 6715 | BGP_STR |
| 6716 | "Address family\n" |
| 6717 | "Address Family modifier\n" |
| 6718 | "Address Family modifier\n" |
| 6719 | "Display routes conforming to the filter-list\n" |
| 6720 | "Regular expression access list name\n") |
| 6721 | { |
| 6722 | if (strncmp (argv[0], "m", 1) == 0) |
| 6723 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6724 | bgp_show_type_filter_list); |
| 6725 | |
| 6726 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6727 | bgp_show_type_filter_list); |
| 6728 | } |
| 6729 | |
| 6730 | #ifdef HAVE_IPV6 |
| 6731 | DEFUN (show_bgp_filter_list, |
| 6732 | show_bgp_filter_list_cmd, |
| 6733 | "show bgp filter-list WORD", |
| 6734 | SHOW_STR |
| 6735 | BGP_STR |
| 6736 | "Display routes conforming to the filter-list\n" |
| 6737 | "Regular expression access list name\n") |
| 6738 | { |
| 6739 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6740 | bgp_show_type_filter_list); |
| 6741 | } |
| 6742 | |
| 6743 | ALIAS (show_bgp_filter_list, |
| 6744 | show_bgp_ipv6_filter_list_cmd, |
| 6745 | "show bgp ipv6 filter-list WORD", |
| 6746 | SHOW_STR |
| 6747 | BGP_STR |
| 6748 | "Address family\n" |
| 6749 | "Display routes conforming to the filter-list\n" |
| 6750 | "Regular expression access list name\n") |
| 6751 | |
| 6752 | /* old command */ |
| 6753 | DEFUN (show_ipv6_bgp_filter_list, |
| 6754 | show_ipv6_bgp_filter_list_cmd, |
| 6755 | "show ipv6 bgp filter-list WORD", |
| 6756 | SHOW_STR |
| 6757 | IPV6_STR |
| 6758 | BGP_STR |
| 6759 | "Display routes conforming to the filter-list\n" |
| 6760 | "Regular expression access list name\n") |
| 6761 | { |
| 6762 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6763 | bgp_show_type_filter_list); |
| 6764 | } |
| 6765 | |
| 6766 | /* old command */ |
| 6767 | DEFUN (show_ipv6_mbgp_filter_list, |
| 6768 | show_ipv6_mbgp_filter_list_cmd, |
| 6769 | "show ipv6 mbgp filter-list WORD", |
| 6770 | SHOW_STR |
| 6771 | IPV6_STR |
| 6772 | MBGP_STR |
| 6773 | "Display routes conforming to the filter-list\n" |
| 6774 | "Regular expression access list name\n") |
| 6775 | { |
| 6776 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6777 | bgp_show_type_filter_list); |
| 6778 | } |
| 6779 | #endif /* HAVE_IPV6 */ |
| 6780 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6781 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6782 | 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] | 6783 | safi_t safi, enum bgp_show_type type) |
| 6784 | { |
| 6785 | struct route_map *rmap; |
| 6786 | |
| 6787 | rmap = route_map_lookup_by_name (rmap_str); |
| 6788 | if (! rmap) |
| 6789 | { |
| 6790 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 6791 | rmap_str, VTY_NEWLINE); |
| 6792 | return CMD_WARNING; |
| 6793 | } |
| 6794 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6795 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6796 | } |
| 6797 | |
| 6798 | DEFUN (show_ip_bgp_route_map, |
| 6799 | show_ip_bgp_route_map_cmd, |
| 6800 | "show ip bgp route-map WORD", |
| 6801 | SHOW_STR |
| 6802 | IP_STR |
| 6803 | BGP_STR |
| 6804 | "Display routes matching the route-map\n" |
| 6805 | "A route-map to match on\n") |
| 6806 | { |
| 6807 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6808 | bgp_show_type_route_map); |
| 6809 | } |
| 6810 | |
| 6811 | DEFUN (show_ip_bgp_flap_route_map, |
| 6812 | show_ip_bgp_flap_route_map_cmd, |
| 6813 | "show ip bgp flap-statistics route-map WORD", |
| 6814 | SHOW_STR |
| 6815 | IP_STR |
| 6816 | BGP_STR |
| 6817 | "Display flap statistics of routes\n" |
| 6818 | "Display routes matching the route-map\n" |
| 6819 | "A route-map to match on\n") |
| 6820 | { |
| 6821 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6822 | bgp_show_type_flap_route_map); |
| 6823 | } |
| 6824 | |
| 6825 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 6826 | show_ip_bgp_ipv4_route_map_cmd, |
| 6827 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 6828 | SHOW_STR |
| 6829 | IP_STR |
| 6830 | BGP_STR |
| 6831 | "Address family\n" |
| 6832 | "Address Family modifier\n" |
| 6833 | "Address Family modifier\n" |
| 6834 | "Display routes matching the route-map\n" |
| 6835 | "A route-map to match on\n") |
| 6836 | { |
| 6837 | if (strncmp (argv[0], "m", 1) == 0) |
| 6838 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6839 | bgp_show_type_route_map); |
| 6840 | |
| 6841 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6842 | bgp_show_type_route_map); |
| 6843 | } |
| 6844 | |
| 6845 | DEFUN (show_bgp_route_map, |
| 6846 | show_bgp_route_map_cmd, |
| 6847 | "show bgp route-map WORD", |
| 6848 | SHOW_STR |
| 6849 | BGP_STR |
| 6850 | "Display routes matching the route-map\n" |
| 6851 | "A route-map to match on\n") |
| 6852 | { |
| 6853 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6854 | bgp_show_type_route_map); |
| 6855 | } |
| 6856 | |
| 6857 | ALIAS (show_bgp_route_map, |
| 6858 | show_bgp_ipv6_route_map_cmd, |
| 6859 | "show bgp ipv6 route-map WORD", |
| 6860 | SHOW_STR |
| 6861 | BGP_STR |
| 6862 | "Address family\n" |
| 6863 | "Display routes matching the route-map\n" |
| 6864 | "A route-map to match on\n") |
| 6865 | |
| 6866 | DEFUN (show_ip_bgp_cidr_only, |
| 6867 | show_ip_bgp_cidr_only_cmd, |
| 6868 | "show ip bgp cidr-only", |
| 6869 | SHOW_STR |
| 6870 | IP_STR |
| 6871 | BGP_STR |
| 6872 | "Display only routes with non-natural netmasks\n") |
| 6873 | { |
| 6874 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6875 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6876 | } |
| 6877 | |
| 6878 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 6879 | show_ip_bgp_flap_cidr_only_cmd, |
| 6880 | "show ip bgp flap-statistics cidr-only", |
| 6881 | SHOW_STR |
| 6882 | IP_STR |
| 6883 | BGP_STR |
| 6884 | "Display flap statistics of routes\n" |
| 6885 | "Display only routes with non-natural netmasks\n") |
| 6886 | { |
| 6887 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6888 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6889 | } |
| 6890 | |
| 6891 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 6892 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 6893 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 6894 | SHOW_STR |
| 6895 | IP_STR |
| 6896 | BGP_STR |
| 6897 | "Address family\n" |
| 6898 | "Address Family modifier\n" |
| 6899 | "Address Family modifier\n" |
| 6900 | "Display only routes with non-natural netmasks\n") |
| 6901 | { |
| 6902 | if (strncmp (argv[0], "m", 1) == 0) |
| 6903 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6904 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6905 | |
| 6906 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6907 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6908 | } |
| 6909 | |
| 6910 | DEFUN (show_ip_bgp_community_all, |
| 6911 | show_ip_bgp_community_all_cmd, |
| 6912 | "show ip bgp community", |
| 6913 | SHOW_STR |
| 6914 | IP_STR |
| 6915 | BGP_STR |
| 6916 | "Display routes matching the communities\n") |
| 6917 | { |
| 6918 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6919 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6920 | } |
| 6921 | |
| 6922 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 6923 | show_ip_bgp_ipv4_community_all_cmd, |
| 6924 | "show ip bgp ipv4 (unicast|multicast) community", |
| 6925 | SHOW_STR |
| 6926 | IP_STR |
| 6927 | BGP_STR |
| 6928 | "Address family\n" |
| 6929 | "Address Family modifier\n" |
| 6930 | "Address Family modifier\n" |
| 6931 | "Display routes matching the communities\n") |
| 6932 | { |
| 6933 | if (strncmp (argv[0], "m", 1) == 0) |
| 6934 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6935 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6936 | |
| 6937 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6938 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6939 | } |
| 6940 | |
| 6941 | #ifdef HAVE_IPV6 |
| 6942 | DEFUN (show_bgp_community_all, |
| 6943 | show_bgp_community_all_cmd, |
| 6944 | "show bgp community", |
| 6945 | SHOW_STR |
| 6946 | BGP_STR |
| 6947 | "Display routes matching the communities\n") |
| 6948 | { |
| 6949 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6950 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6951 | } |
| 6952 | |
| 6953 | ALIAS (show_bgp_community_all, |
| 6954 | show_bgp_ipv6_community_all_cmd, |
| 6955 | "show bgp ipv6 community", |
| 6956 | SHOW_STR |
| 6957 | BGP_STR |
| 6958 | "Address family\n" |
| 6959 | "Display routes matching the communities\n") |
| 6960 | |
| 6961 | /* old command */ |
| 6962 | DEFUN (show_ipv6_bgp_community_all, |
| 6963 | show_ipv6_bgp_community_all_cmd, |
| 6964 | "show ipv6 bgp community", |
| 6965 | SHOW_STR |
| 6966 | IPV6_STR |
| 6967 | BGP_STR |
| 6968 | "Display routes matching the communities\n") |
| 6969 | { |
| 6970 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6971 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6972 | } |
| 6973 | |
| 6974 | /* old command */ |
| 6975 | DEFUN (show_ipv6_mbgp_community_all, |
| 6976 | show_ipv6_mbgp_community_all_cmd, |
| 6977 | "show ipv6 mbgp community", |
| 6978 | SHOW_STR |
| 6979 | IPV6_STR |
| 6980 | MBGP_STR |
| 6981 | "Display routes matching the communities\n") |
| 6982 | { |
| 6983 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6984 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6985 | } |
| 6986 | #endif /* HAVE_IPV6 */ |
| 6987 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6988 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6989 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
| 6990 | u_int16_t afi, u_char safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6991 | { |
| 6992 | struct community *com; |
| 6993 | struct buffer *b; |
| 6994 | int i; |
| 6995 | char *str; |
| 6996 | int first = 0; |
| 6997 | |
| 6998 | b = buffer_new (1024); |
| 6999 | for (i = 0; i < argc; i++) |
| 7000 | { |
| 7001 | if (first) |
| 7002 | buffer_putc (b, ' '); |
| 7003 | else |
| 7004 | { |
| 7005 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7006 | continue; |
| 7007 | first = 1; |
| 7008 | } |
| 7009 | |
| 7010 | buffer_putstr (b, argv[i]); |
| 7011 | } |
| 7012 | buffer_putc (b, '\0'); |
| 7013 | |
| 7014 | str = buffer_getstr (b); |
| 7015 | buffer_free (b); |
| 7016 | |
| 7017 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7018 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7019 | if (! com) |
| 7020 | { |
| 7021 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7022 | return CMD_WARNING; |
| 7023 | } |
| 7024 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7025 | return bgp_show (vty, NULL, afi, safi, |
| 7026 | (exact ? bgp_show_type_community_exact : |
| 7027 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7028 | } |
| 7029 | |
| 7030 | DEFUN (show_ip_bgp_community, |
| 7031 | show_ip_bgp_community_cmd, |
| 7032 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7033 | SHOW_STR |
| 7034 | IP_STR |
| 7035 | BGP_STR |
| 7036 | "Display routes matching the communities\n" |
| 7037 | "community number\n" |
| 7038 | "Do not send outside local AS (well-known community)\n" |
| 7039 | "Do not advertise to any peer (well-known community)\n" |
| 7040 | "Do not export to next AS (well-known community)\n") |
| 7041 | { |
| 7042 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 7043 | } |
| 7044 | |
| 7045 | ALIAS (show_ip_bgp_community, |
| 7046 | show_ip_bgp_community2_cmd, |
| 7047 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7048 | SHOW_STR |
| 7049 | IP_STR |
| 7050 | BGP_STR |
| 7051 | "Display routes matching the communities\n" |
| 7052 | "community number\n" |
| 7053 | "Do not send outside local AS (well-known community)\n" |
| 7054 | "Do not advertise to any peer (well-known community)\n" |
| 7055 | "Do not export to next AS (well-known community)\n" |
| 7056 | "community number\n" |
| 7057 | "Do not send outside local AS (well-known community)\n" |
| 7058 | "Do not advertise to any peer (well-known community)\n" |
| 7059 | "Do not export to next AS (well-known community)\n") |
| 7060 | |
| 7061 | ALIAS (show_ip_bgp_community, |
| 7062 | show_ip_bgp_community3_cmd, |
| 7063 | "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)", |
| 7064 | SHOW_STR |
| 7065 | IP_STR |
| 7066 | BGP_STR |
| 7067 | "Display routes matching the communities\n" |
| 7068 | "community number\n" |
| 7069 | "Do not send outside local AS (well-known community)\n" |
| 7070 | "Do not advertise to any peer (well-known community)\n" |
| 7071 | "Do not export to next AS (well-known community)\n" |
| 7072 | "community number\n" |
| 7073 | "Do not send outside local AS (well-known community)\n" |
| 7074 | "Do not advertise to any peer (well-known community)\n" |
| 7075 | "Do not export to next AS (well-known community)\n" |
| 7076 | "community number\n" |
| 7077 | "Do not send outside local AS (well-known community)\n" |
| 7078 | "Do not advertise to any peer (well-known community)\n" |
| 7079 | "Do not export to next AS (well-known community)\n") |
| 7080 | |
| 7081 | ALIAS (show_ip_bgp_community, |
| 7082 | show_ip_bgp_community4_cmd, |
| 7083 | "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)", |
| 7084 | SHOW_STR |
| 7085 | IP_STR |
| 7086 | BGP_STR |
| 7087 | "Display routes matching the communities\n" |
| 7088 | "community number\n" |
| 7089 | "Do not send outside local AS (well-known community)\n" |
| 7090 | "Do not advertise to any peer (well-known community)\n" |
| 7091 | "Do not export to next AS (well-known community)\n" |
| 7092 | "community number\n" |
| 7093 | "Do not send outside local AS (well-known community)\n" |
| 7094 | "Do not advertise to any peer (well-known community)\n" |
| 7095 | "Do not export to next AS (well-known community)\n" |
| 7096 | "community number\n" |
| 7097 | "Do not send outside local AS (well-known community)\n" |
| 7098 | "Do not advertise to any peer (well-known community)\n" |
| 7099 | "Do not export to next AS (well-known community)\n" |
| 7100 | "community number\n" |
| 7101 | "Do not send outside local AS (well-known community)\n" |
| 7102 | "Do not advertise to any peer (well-known community)\n" |
| 7103 | "Do not export to next AS (well-known community)\n") |
| 7104 | |
| 7105 | DEFUN (show_ip_bgp_ipv4_community, |
| 7106 | show_ip_bgp_ipv4_community_cmd, |
| 7107 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7108 | SHOW_STR |
| 7109 | IP_STR |
| 7110 | BGP_STR |
| 7111 | "Address family\n" |
| 7112 | "Address Family modifier\n" |
| 7113 | "Address Family modifier\n" |
| 7114 | "Display routes matching the communities\n" |
| 7115 | "community number\n" |
| 7116 | "Do not send outside local AS (well-known community)\n" |
| 7117 | "Do not advertise to any peer (well-known community)\n" |
| 7118 | "Do not export to next AS (well-known community)\n") |
| 7119 | { |
| 7120 | if (strncmp (argv[0], "m", 1) == 0) |
| 7121 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 7122 | |
| 7123 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 7124 | } |
| 7125 | |
| 7126 | ALIAS (show_ip_bgp_ipv4_community, |
| 7127 | show_ip_bgp_ipv4_community2_cmd, |
| 7128 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7129 | SHOW_STR |
| 7130 | IP_STR |
| 7131 | BGP_STR |
| 7132 | "Address family\n" |
| 7133 | "Address Family modifier\n" |
| 7134 | "Address Family modifier\n" |
| 7135 | "Display routes matching the communities\n" |
| 7136 | "community number\n" |
| 7137 | "Do not send outside local AS (well-known community)\n" |
| 7138 | "Do not advertise to any peer (well-known community)\n" |
| 7139 | "Do not export to next AS (well-known community)\n" |
| 7140 | "community number\n" |
| 7141 | "Do not send outside local AS (well-known community)\n" |
| 7142 | "Do not advertise to any peer (well-known community)\n" |
| 7143 | "Do not export to next AS (well-known community)\n") |
| 7144 | |
| 7145 | ALIAS (show_ip_bgp_ipv4_community, |
| 7146 | show_ip_bgp_ipv4_community3_cmd, |
| 7147 | "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)", |
| 7148 | SHOW_STR |
| 7149 | IP_STR |
| 7150 | BGP_STR |
| 7151 | "Address family\n" |
| 7152 | "Address Family modifier\n" |
| 7153 | "Address Family modifier\n" |
| 7154 | "Display routes matching the communities\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 | |
| 7168 | ALIAS (show_ip_bgp_ipv4_community, |
| 7169 | show_ip_bgp_ipv4_community4_cmd, |
| 7170 | "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)", |
| 7171 | SHOW_STR |
| 7172 | IP_STR |
| 7173 | BGP_STR |
| 7174 | "Address family\n" |
| 7175 | "Address Family modifier\n" |
| 7176 | "Address Family modifier\n" |
| 7177 | "Display routes matching the communities\n" |
| 7178 | "community number\n" |
| 7179 | "Do not send outside local AS (well-known community)\n" |
| 7180 | "Do not advertise to any peer (well-known community)\n" |
| 7181 | "Do not export to next AS (well-known community)\n" |
| 7182 | "community number\n" |
| 7183 | "Do not send outside local AS (well-known community)\n" |
| 7184 | "Do not advertise to any peer (well-known community)\n" |
| 7185 | "Do not export to next AS (well-known community)\n" |
| 7186 | "community number\n" |
| 7187 | "Do not send outside local AS (well-known community)\n" |
| 7188 | "Do not advertise to any peer (well-known community)\n" |
| 7189 | "Do not export to next AS (well-known community)\n" |
| 7190 | "community number\n" |
| 7191 | "Do not send outside local AS (well-known community)\n" |
| 7192 | "Do not advertise to any peer (well-known community)\n" |
| 7193 | "Do not export to next AS (well-known community)\n") |
| 7194 | |
| 7195 | DEFUN (show_ip_bgp_community_exact, |
| 7196 | show_ip_bgp_community_exact_cmd, |
| 7197 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7198 | SHOW_STR |
| 7199 | IP_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 | "Exact match of the communities") |
| 7207 | { |
| 7208 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7209 | } |
| 7210 | |
| 7211 | ALIAS (show_ip_bgp_community_exact, |
| 7212 | show_ip_bgp_community2_exact_cmd, |
| 7213 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7214 | SHOW_STR |
| 7215 | IP_STR |
| 7216 | BGP_STR |
| 7217 | "Display routes matching the communities\n" |
| 7218 | "community number\n" |
| 7219 | "Do not send outside local AS (well-known community)\n" |
| 7220 | "Do not advertise to any peer (well-known community)\n" |
| 7221 | "Do not export to next AS (well-known community)\n" |
| 7222 | "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 | "Exact match of the communities") |
| 7227 | |
| 7228 | ALIAS (show_ip_bgp_community_exact, |
| 7229 | show_ip_bgp_community3_exact_cmd, |
| 7230 | "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", |
| 7231 | SHOW_STR |
| 7232 | IP_STR |
| 7233 | BGP_STR |
| 7234 | "Display routes matching the communities\n" |
| 7235 | "community number\n" |
| 7236 | "Do not send outside local AS (well-known community)\n" |
| 7237 | "Do not advertise to any peer (well-known community)\n" |
| 7238 | "Do not export to next AS (well-known community)\n" |
| 7239 | "community number\n" |
| 7240 | "Do not send outside local AS (well-known community)\n" |
| 7241 | "Do not advertise to any peer (well-known community)\n" |
| 7242 | "Do not export to next AS (well-known community)\n" |
| 7243 | "community number\n" |
| 7244 | "Do not send outside local AS (well-known community)\n" |
| 7245 | "Do not advertise to any peer (well-known community)\n" |
| 7246 | "Do not export to next AS (well-known community)\n" |
| 7247 | "Exact match of the communities") |
| 7248 | |
| 7249 | ALIAS (show_ip_bgp_community_exact, |
| 7250 | show_ip_bgp_community4_exact_cmd, |
| 7251 | "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", |
| 7252 | SHOW_STR |
| 7253 | IP_STR |
| 7254 | BGP_STR |
| 7255 | "Display routes matching the communities\n" |
| 7256 | "community number\n" |
| 7257 | "Do not send outside local AS (well-known community)\n" |
| 7258 | "Do not advertise to any peer (well-known community)\n" |
| 7259 | "Do not export to next AS (well-known community)\n" |
| 7260 | "community number\n" |
| 7261 | "Do not send outside local AS (well-known community)\n" |
| 7262 | "Do not advertise to any peer (well-known community)\n" |
| 7263 | "Do not export to next AS (well-known community)\n" |
| 7264 | "community number\n" |
| 7265 | "Do not send outside local AS (well-known community)\n" |
| 7266 | "Do not advertise to any peer (well-known community)\n" |
| 7267 | "Do not export to next AS (well-known community)\n" |
| 7268 | "community number\n" |
| 7269 | "Do not send outside local AS (well-known community)\n" |
| 7270 | "Do not advertise to any peer (well-known community)\n" |
| 7271 | "Do not export to next AS (well-known community)\n" |
| 7272 | "Exact match of the communities") |
| 7273 | |
| 7274 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 7275 | show_ip_bgp_ipv4_community_exact_cmd, |
| 7276 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7277 | SHOW_STR |
| 7278 | IP_STR |
| 7279 | BGP_STR |
| 7280 | "Address family\n" |
| 7281 | "Address Family modifier\n" |
| 7282 | "Address Family modifier\n" |
| 7283 | "Display routes matching the communities\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 | "Exact match of the communities") |
| 7289 | { |
| 7290 | if (strncmp (argv[0], "m", 1) == 0) |
| 7291 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 7292 | |
| 7293 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7294 | } |
| 7295 | |
| 7296 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7297 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 7298 | "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", |
| 7299 | SHOW_STR |
| 7300 | IP_STR |
| 7301 | BGP_STR |
| 7302 | "Address family\n" |
| 7303 | "Address Family modifier\n" |
| 7304 | "Address Family modifier\n" |
| 7305 | "Display routes matching the communities\n" |
| 7306 | "community number\n" |
| 7307 | "Do not send outside local AS (well-known community)\n" |
| 7308 | "Do not advertise to any peer (well-known community)\n" |
| 7309 | "Do not export to next AS (well-known community)\n" |
| 7310 | "community number\n" |
| 7311 | "Do not send outside local AS (well-known community)\n" |
| 7312 | "Do not advertise to any peer (well-known community)\n" |
| 7313 | "Do not export to next AS (well-known community)\n" |
| 7314 | "Exact match of the communities") |
| 7315 | |
| 7316 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7317 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 7318 | "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", |
| 7319 | SHOW_STR |
| 7320 | IP_STR |
| 7321 | BGP_STR |
| 7322 | "Address family\n" |
| 7323 | "Address Family modifier\n" |
| 7324 | "Address Family modifier\n" |
| 7325 | "Display routes matching the communities\n" |
| 7326 | "community number\n" |
| 7327 | "Do not send outside local AS (well-known community)\n" |
| 7328 | "Do not advertise to any peer (well-known community)\n" |
| 7329 | "Do not export to next AS (well-known community)\n" |
| 7330 | "community number\n" |
| 7331 | "Do not send outside local AS (well-known community)\n" |
| 7332 | "Do not advertise to any peer (well-known community)\n" |
| 7333 | "Do not export to next AS (well-known community)\n" |
| 7334 | "community number\n" |
| 7335 | "Do not send outside local AS (well-known community)\n" |
| 7336 | "Do not advertise to any peer (well-known community)\n" |
| 7337 | "Do not export to next AS (well-known community)\n" |
| 7338 | "Exact match of the communities") |
| 7339 | |
| 7340 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7341 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 7342 | "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", |
| 7343 | SHOW_STR |
| 7344 | IP_STR |
| 7345 | BGP_STR |
| 7346 | "Address family\n" |
| 7347 | "Address Family modifier\n" |
| 7348 | "Address Family modifier\n" |
| 7349 | "Display routes matching the communities\n" |
| 7350 | "community number\n" |
| 7351 | "Do not send outside local AS (well-known community)\n" |
| 7352 | "Do not advertise to any peer (well-known community)\n" |
| 7353 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 7367 | |
| 7368 | #ifdef HAVE_IPV6 |
| 7369 | DEFUN (show_bgp_community, |
| 7370 | show_bgp_community_cmd, |
| 7371 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7372 | SHOW_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 | { |
| 7380 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7381 | } |
| 7382 | |
| 7383 | ALIAS (show_bgp_community, |
| 7384 | show_bgp_ipv6_community_cmd, |
| 7385 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 7386 | SHOW_STR |
| 7387 | BGP_STR |
| 7388 | "Address family\n" |
| 7389 | "Display routes matching the communities\n" |
| 7390 | "community number\n" |
| 7391 | "Do not send outside local AS (well-known community)\n" |
| 7392 | "Do not advertise to any peer (well-known community)\n" |
| 7393 | "Do not export to next AS (well-known community)\n") |
| 7394 | |
| 7395 | ALIAS (show_bgp_community, |
| 7396 | show_bgp_community2_cmd, |
| 7397 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7398 | SHOW_STR |
| 7399 | BGP_STR |
| 7400 | "Display routes matching the communities\n" |
| 7401 | "community number\n" |
| 7402 | "Do not send outside local AS (well-known community)\n" |
| 7403 | "Do not advertise to any peer (well-known community)\n" |
| 7404 | "Do not export to next AS (well-known community)\n" |
| 7405 | "community number\n" |
| 7406 | "Do not send outside local AS (well-known community)\n" |
| 7407 | "Do not advertise to any peer (well-known community)\n" |
| 7408 | "Do not export to next AS (well-known community)\n") |
| 7409 | |
| 7410 | ALIAS (show_bgp_community, |
| 7411 | show_bgp_ipv6_community2_cmd, |
| 7412 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7413 | SHOW_STR |
| 7414 | BGP_STR |
| 7415 | "Address family\n" |
| 7416 | "Display routes matching the communities\n" |
| 7417 | "community number\n" |
| 7418 | "Do not send outside local AS (well-known community)\n" |
| 7419 | "Do not advertise to any peer (well-known community)\n" |
| 7420 | "Do not export to next AS (well-known community)\n" |
| 7421 | "community number\n" |
| 7422 | "Do not send outside local AS (well-known community)\n" |
| 7423 | "Do not advertise to any peer (well-known community)\n" |
| 7424 | "Do not export to next AS (well-known community)\n") |
| 7425 | |
| 7426 | ALIAS (show_bgp_community, |
| 7427 | show_bgp_community3_cmd, |
| 7428 | "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)", |
| 7429 | SHOW_STR |
| 7430 | BGP_STR |
| 7431 | "Display routes matching the communities\n" |
| 7432 | "community number\n" |
| 7433 | "Do not send outside local AS (well-known community)\n" |
| 7434 | "Do not advertise to any peer (well-known community)\n" |
| 7435 | "Do not export to next AS (well-known community)\n" |
| 7436 | "community number\n" |
| 7437 | "Do not send outside local AS (well-known community)\n" |
| 7438 | "Do not advertise to any peer (well-known community)\n" |
| 7439 | "Do not export to next AS (well-known community)\n" |
| 7440 | "community number\n" |
| 7441 | "Do not send outside local AS (well-known community)\n" |
| 7442 | "Do not advertise to any peer (well-known community)\n" |
| 7443 | "Do not export to next AS (well-known community)\n") |
| 7444 | |
| 7445 | ALIAS (show_bgp_community, |
| 7446 | show_bgp_ipv6_community3_cmd, |
| 7447 | "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)", |
| 7448 | SHOW_STR |
| 7449 | BGP_STR |
| 7450 | "Address family\n" |
| 7451 | "Display routes matching the communities\n" |
| 7452 | "community number\n" |
| 7453 | "Do not send outside local AS (well-known community)\n" |
| 7454 | "Do not advertise to any peer (well-known community)\n" |
| 7455 | "Do not export to next AS (well-known community)\n" |
| 7456 | "community number\n" |
| 7457 | "Do not send outside local AS (well-known community)\n" |
| 7458 | "Do not advertise to any peer (well-known community)\n" |
| 7459 | "Do not export to next AS (well-known community)\n" |
| 7460 | "community number\n" |
| 7461 | "Do not send outside local AS (well-known community)\n" |
| 7462 | "Do not advertise to any peer (well-known community)\n" |
| 7463 | "Do not export to next AS (well-known community)\n") |
| 7464 | |
| 7465 | ALIAS (show_bgp_community, |
| 7466 | show_bgp_community4_cmd, |
| 7467 | "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)", |
| 7468 | SHOW_STR |
| 7469 | BGP_STR |
| 7470 | "Display routes matching the communities\n" |
| 7471 | "community number\n" |
| 7472 | "Do not send outside local AS (well-known community)\n" |
| 7473 | "Do not advertise to any peer (well-known community)\n" |
| 7474 | "Do not export to next AS (well-known community)\n" |
| 7475 | "community number\n" |
| 7476 | "Do not send outside local AS (well-known community)\n" |
| 7477 | "Do not advertise to any peer (well-known community)\n" |
| 7478 | "Do not export to next AS (well-known community)\n" |
| 7479 | "community number\n" |
| 7480 | "Do not send outside local AS (well-known community)\n" |
| 7481 | "Do not advertise to any peer (well-known community)\n" |
| 7482 | "Do not export to next AS (well-known community)\n" |
| 7483 | "community number\n" |
| 7484 | "Do not send outside local AS (well-known community)\n" |
| 7485 | "Do not advertise to any peer (well-known community)\n" |
| 7486 | "Do not export to next AS (well-known community)\n") |
| 7487 | |
| 7488 | ALIAS (show_bgp_community, |
| 7489 | show_bgp_ipv6_community4_cmd, |
| 7490 | "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)", |
| 7491 | SHOW_STR |
| 7492 | BGP_STR |
| 7493 | "Address family\n" |
| 7494 | "Display routes matching the communities\n" |
| 7495 | "community number\n" |
| 7496 | "Do not send outside local AS (well-known community)\n" |
| 7497 | "Do not advertise to any peer (well-known community)\n" |
| 7498 | "Do not export to next AS (well-known community)\n" |
| 7499 | "community number\n" |
| 7500 | "Do not send outside local AS (well-known community)\n" |
| 7501 | "Do not advertise to any peer (well-known community)\n" |
| 7502 | "Do not export to next AS (well-known community)\n" |
| 7503 | "community number\n" |
| 7504 | "Do not send outside local AS (well-known community)\n" |
| 7505 | "Do not advertise to any peer (well-known community)\n" |
| 7506 | "Do not export to next AS (well-known community)\n" |
| 7507 | "community number\n" |
| 7508 | "Do not send outside local AS (well-known community)\n" |
| 7509 | "Do not advertise to any peer (well-known community)\n" |
| 7510 | "Do not export to next AS (well-known community)\n") |
| 7511 | |
| 7512 | /* old command */ |
| 7513 | DEFUN (show_ipv6_bgp_community, |
| 7514 | show_ipv6_bgp_community_cmd, |
| 7515 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7516 | SHOW_STR |
| 7517 | IPV6_STR |
| 7518 | BGP_STR |
| 7519 | "Display routes matching the communities\n" |
| 7520 | "community number\n" |
| 7521 | "Do not send outside local AS (well-known community)\n" |
| 7522 | "Do not advertise to any peer (well-known community)\n" |
| 7523 | "Do not export to next AS (well-known community)\n") |
| 7524 | { |
| 7525 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7526 | } |
| 7527 | |
| 7528 | /* old command */ |
| 7529 | ALIAS (show_ipv6_bgp_community, |
| 7530 | show_ipv6_bgp_community2_cmd, |
| 7531 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7532 | SHOW_STR |
| 7533 | IPV6_STR |
| 7534 | BGP_STR |
| 7535 | "Display routes matching the communities\n" |
| 7536 | "community number\n" |
| 7537 | "Do not send outside local AS (well-known community)\n" |
| 7538 | "Do not advertise to any peer (well-known community)\n" |
| 7539 | "Do not export to next AS (well-known community)\n" |
| 7540 | "community number\n" |
| 7541 | "Do not send outside local AS (well-known community)\n" |
| 7542 | "Do not advertise to any peer (well-known community)\n" |
| 7543 | "Do not export to next AS (well-known community)\n") |
| 7544 | |
| 7545 | /* old command */ |
| 7546 | ALIAS (show_ipv6_bgp_community, |
| 7547 | show_ipv6_bgp_community3_cmd, |
| 7548 | "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)", |
| 7549 | SHOW_STR |
| 7550 | IPV6_STR |
| 7551 | BGP_STR |
| 7552 | "Display routes matching the communities\n" |
| 7553 | "community number\n" |
| 7554 | "Do not send outside local AS (well-known community)\n" |
| 7555 | "Do not advertise to any peer (well-known community)\n" |
| 7556 | "Do not export to next AS (well-known community)\n" |
| 7557 | "community number\n" |
| 7558 | "Do not send outside local AS (well-known community)\n" |
| 7559 | "Do not advertise to any peer (well-known community)\n" |
| 7560 | "Do not export to next AS (well-known community)\n" |
| 7561 | "community number\n" |
| 7562 | "Do not send outside local AS (well-known community)\n" |
| 7563 | "Do not advertise to any peer (well-known community)\n" |
| 7564 | "Do not export to next AS (well-known community)\n") |
| 7565 | |
| 7566 | /* old command */ |
| 7567 | ALIAS (show_ipv6_bgp_community, |
| 7568 | show_ipv6_bgp_community4_cmd, |
| 7569 | "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)", |
| 7570 | SHOW_STR |
| 7571 | IPV6_STR |
| 7572 | BGP_STR |
| 7573 | "Display routes matching the communities\n" |
| 7574 | "community number\n" |
| 7575 | "Do not send outside local AS (well-known community)\n" |
| 7576 | "Do not advertise to any peer (well-known community)\n" |
| 7577 | "Do not export to next AS (well-known community)\n" |
| 7578 | "community number\n" |
| 7579 | "Do not send outside local AS (well-known community)\n" |
| 7580 | "Do not advertise to any peer (well-known community)\n" |
| 7581 | "Do not export to next AS (well-known community)\n" |
| 7582 | "community number\n" |
| 7583 | "Do not send outside local AS (well-known community)\n" |
| 7584 | "Do not advertise to any peer (well-known community)\n" |
| 7585 | "Do not export to next AS (well-known community)\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 | |
| 7591 | DEFUN (show_bgp_community_exact, |
| 7592 | show_bgp_community_exact_cmd, |
| 7593 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7594 | SHOW_STR |
| 7595 | BGP_STR |
| 7596 | "Display routes matching the communities\n" |
| 7597 | "community number\n" |
| 7598 | "Do not send outside local AS (well-known community)\n" |
| 7599 | "Do not advertise to any peer (well-known community)\n" |
| 7600 | "Do not export to next AS (well-known community)\n" |
| 7601 | "Exact match of the communities") |
| 7602 | { |
| 7603 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7604 | } |
| 7605 | |
| 7606 | ALIAS (show_bgp_community_exact, |
| 7607 | show_bgp_ipv6_community_exact_cmd, |
| 7608 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7609 | SHOW_STR |
| 7610 | BGP_STR |
| 7611 | "Address family\n" |
| 7612 | "Display routes matching the communities\n" |
| 7613 | "community number\n" |
| 7614 | "Do not send outside local AS (well-known community)\n" |
| 7615 | "Do not advertise to any peer (well-known community)\n" |
| 7616 | "Do not export to next AS (well-known community)\n" |
| 7617 | "Exact match of the communities") |
| 7618 | |
| 7619 | ALIAS (show_bgp_community_exact, |
| 7620 | show_bgp_community2_exact_cmd, |
| 7621 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7622 | SHOW_STR |
| 7623 | BGP_STR |
| 7624 | "Display routes matching the communities\n" |
| 7625 | "community number\n" |
| 7626 | "Do not send outside local AS (well-known community)\n" |
| 7627 | "Do not advertise to any peer (well-known community)\n" |
| 7628 | "Do not export to next AS (well-known community)\n" |
| 7629 | "community number\n" |
| 7630 | "Do not send outside local AS (well-known community)\n" |
| 7631 | "Do not advertise to any peer (well-known community)\n" |
| 7632 | "Do not export to next AS (well-known community)\n" |
| 7633 | "Exact match of the communities") |
| 7634 | |
| 7635 | ALIAS (show_bgp_community_exact, |
| 7636 | show_bgp_ipv6_community2_exact_cmd, |
| 7637 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7638 | SHOW_STR |
| 7639 | BGP_STR |
| 7640 | "Address family\n" |
| 7641 | "Display routes matching the communities\n" |
| 7642 | "community number\n" |
| 7643 | "Do not send outside local AS (well-known community)\n" |
| 7644 | "Do not advertise to any peer (well-known community)\n" |
| 7645 | "Do not export to next AS (well-known community)\n" |
| 7646 | "community number\n" |
| 7647 | "Do not send outside local AS (well-known community)\n" |
| 7648 | "Do not advertise to any peer (well-known community)\n" |
| 7649 | "Do not export to next AS (well-known community)\n" |
| 7650 | "Exact match of the communities") |
| 7651 | |
| 7652 | ALIAS (show_bgp_community_exact, |
| 7653 | show_bgp_community3_exact_cmd, |
| 7654 | "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", |
| 7655 | SHOW_STR |
| 7656 | BGP_STR |
| 7657 | "Display routes matching the communities\n" |
| 7658 | "community number\n" |
| 7659 | "Do not send outside local AS (well-known community)\n" |
| 7660 | "Do not advertise to any peer (well-known community)\n" |
| 7661 | "Do not export to next AS (well-known community)\n" |
| 7662 | "community number\n" |
| 7663 | "Do not send outside local AS (well-known community)\n" |
| 7664 | "Do not advertise to any peer (well-known community)\n" |
| 7665 | "Do not export to next AS (well-known community)\n" |
| 7666 | "community number\n" |
| 7667 | "Do not send outside local AS (well-known community)\n" |
| 7668 | "Do not advertise to any peer (well-known community)\n" |
| 7669 | "Do not export to next AS (well-known community)\n" |
| 7670 | "Exact match of the communities") |
| 7671 | |
| 7672 | ALIAS (show_bgp_community_exact, |
| 7673 | show_bgp_ipv6_community3_exact_cmd, |
| 7674 | "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", |
| 7675 | SHOW_STR |
| 7676 | BGP_STR |
| 7677 | "Address family\n" |
| 7678 | "Display routes matching the communities\n" |
| 7679 | "community number\n" |
| 7680 | "Do not send outside local AS (well-known community)\n" |
| 7681 | "Do not advertise to any peer (well-known community)\n" |
| 7682 | "Do not export to next AS (well-known community)\n" |
| 7683 | "community number\n" |
| 7684 | "Do not send outside local AS (well-known community)\n" |
| 7685 | "Do not advertise to any peer (well-known community)\n" |
| 7686 | "Do not export to next AS (well-known community)\n" |
| 7687 | "community number\n" |
| 7688 | "Do not send outside local AS (well-known community)\n" |
| 7689 | "Do not advertise to any peer (well-known community)\n" |
| 7690 | "Do not export to next AS (well-known community)\n" |
| 7691 | "Exact match of the communities") |
| 7692 | |
| 7693 | ALIAS (show_bgp_community_exact, |
| 7694 | show_bgp_community4_exact_cmd, |
| 7695 | "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", |
| 7696 | SHOW_STR |
| 7697 | BGP_STR |
| 7698 | "Display routes matching the communities\n" |
| 7699 | "community number\n" |
| 7700 | "Do not send outside local AS (well-known community)\n" |
| 7701 | "Do not advertise to any peer (well-known community)\n" |
| 7702 | "Do not export to next AS (well-known community)\n" |
| 7703 | "community number\n" |
| 7704 | "Do not send outside local AS (well-known community)\n" |
| 7705 | "Do not advertise to any peer (well-known community)\n" |
| 7706 | "Do not export to next AS (well-known community)\n" |
| 7707 | "community number\n" |
| 7708 | "Do not send outside local AS (well-known community)\n" |
| 7709 | "Do not advertise to any peer (well-known community)\n" |
| 7710 | "Do not export to next AS (well-known community)\n" |
| 7711 | "community number\n" |
| 7712 | "Do not send outside local AS (well-known community)\n" |
| 7713 | "Do not advertise to any peer (well-known community)\n" |
| 7714 | "Do not export to next AS (well-known community)\n" |
| 7715 | "Exact match of the communities") |
| 7716 | |
| 7717 | ALIAS (show_bgp_community_exact, |
| 7718 | show_bgp_ipv6_community4_exact_cmd, |
| 7719 | "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", |
| 7720 | SHOW_STR |
| 7721 | BGP_STR |
| 7722 | "Address family\n" |
| 7723 | "Display routes matching the communities\n" |
| 7724 | "community number\n" |
| 7725 | "Do not send outside local AS (well-known community)\n" |
| 7726 | "Do not advertise to any peer (well-known community)\n" |
| 7727 | "Do not export to next AS (well-known community)\n" |
| 7728 | "community number\n" |
| 7729 | "Do not send outside local AS (well-known community)\n" |
| 7730 | "Do not advertise to any peer (well-known community)\n" |
| 7731 | "Do not export to next AS (well-known community)\n" |
| 7732 | "community number\n" |
| 7733 | "Do not send outside local AS (well-known community)\n" |
| 7734 | "Do not advertise to any peer (well-known community)\n" |
| 7735 | "Do not export to next AS (well-known community)\n" |
| 7736 | "community number\n" |
| 7737 | "Do not send outside local AS (well-known community)\n" |
| 7738 | "Do not advertise to any peer (well-known community)\n" |
| 7739 | "Do not export to next AS (well-known community)\n" |
| 7740 | "Exact match of the communities") |
| 7741 | |
| 7742 | /* old command */ |
| 7743 | DEFUN (show_ipv6_bgp_community_exact, |
| 7744 | show_ipv6_bgp_community_exact_cmd, |
| 7745 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7746 | SHOW_STR |
| 7747 | IPV6_STR |
| 7748 | BGP_STR |
| 7749 | "Display routes matching the communities\n" |
| 7750 | "community number\n" |
| 7751 | "Do not send outside local AS (well-known community)\n" |
| 7752 | "Do not advertise to any peer (well-known community)\n" |
| 7753 | "Do not export to next AS (well-known community)\n" |
| 7754 | "Exact match of the communities") |
| 7755 | { |
| 7756 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7757 | } |
| 7758 | |
| 7759 | /* old command */ |
| 7760 | ALIAS (show_ipv6_bgp_community_exact, |
| 7761 | show_ipv6_bgp_community2_exact_cmd, |
| 7762 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7763 | SHOW_STR |
| 7764 | IPV6_STR |
| 7765 | BGP_STR |
| 7766 | "Display routes matching the communities\n" |
| 7767 | "community number\n" |
| 7768 | "Do not send outside local AS (well-known community)\n" |
| 7769 | "Do not advertise to any peer (well-known community)\n" |
| 7770 | "Do not export to next AS (well-known community)\n" |
| 7771 | "community number\n" |
| 7772 | "Do not send outside local AS (well-known community)\n" |
| 7773 | "Do not advertise to any peer (well-known community)\n" |
| 7774 | "Do not export to next AS (well-known community)\n" |
| 7775 | "Exact match of the communities") |
| 7776 | |
| 7777 | /* old command */ |
| 7778 | ALIAS (show_ipv6_bgp_community_exact, |
| 7779 | show_ipv6_bgp_community3_exact_cmd, |
| 7780 | "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", |
| 7781 | SHOW_STR |
| 7782 | IPV6_STR |
| 7783 | BGP_STR |
| 7784 | "Display routes matching the communities\n" |
| 7785 | "community number\n" |
| 7786 | "Do not send outside local AS (well-known community)\n" |
| 7787 | "Do not advertise to any peer (well-known community)\n" |
| 7788 | "Do not export to next AS (well-known community)\n" |
| 7789 | "community number\n" |
| 7790 | "Do not send outside local AS (well-known community)\n" |
| 7791 | "Do not advertise to any peer (well-known community)\n" |
| 7792 | "Do not export to next AS (well-known community)\n" |
| 7793 | "community number\n" |
| 7794 | "Do not send outside local AS (well-known community)\n" |
| 7795 | "Do not advertise to any peer (well-known community)\n" |
| 7796 | "Do not export to next AS (well-known community)\n" |
| 7797 | "Exact match of the communities") |
| 7798 | |
| 7799 | /* old command */ |
| 7800 | ALIAS (show_ipv6_bgp_community_exact, |
| 7801 | show_ipv6_bgp_community4_exact_cmd, |
| 7802 | "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", |
| 7803 | SHOW_STR |
| 7804 | IPV6_STR |
| 7805 | BGP_STR |
| 7806 | "Display routes matching the communities\n" |
| 7807 | "community number\n" |
| 7808 | "Do not send outside local AS (well-known community)\n" |
| 7809 | "Do not advertise to any peer (well-known community)\n" |
| 7810 | "Do not export to next AS (well-known community)\n" |
| 7811 | "community number\n" |
| 7812 | "Do not send outside local AS (well-known community)\n" |
| 7813 | "Do not advertise to any peer (well-known community)\n" |
| 7814 | "Do not export to next AS (well-known community)\n" |
| 7815 | "community number\n" |
| 7816 | "Do not send outside local AS (well-known community)\n" |
| 7817 | "Do not advertise to any peer (well-known community)\n" |
| 7818 | "Do not export to next AS (well-known community)\n" |
| 7819 | "community number\n" |
| 7820 | "Do not send outside local AS (well-known community)\n" |
| 7821 | "Do not advertise to any peer (well-known community)\n" |
| 7822 | "Do not export to next AS (well-known community)\n" |
| 7823 | "Exact match of the communities") |
| 7824 | |
| 7825 | /* old command */ |
| 7826 | DEFUN (show_ipv6_mbgp_community, |
| 7827 | show_ipv6_mbgp_community_cmd, |
| 7828 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7829 | SHOW_STR |
| 7830 | IPV6_STR |
| 7831 | MBGP_STR |
| 7832 | "Display routes matching the communities\n" |
| 7833 | "community number\n" |
| 7834 | "Do not send outside local AS (well-known community)\n" |
| 7835 | "Do not advertise to any peer (well-known community)\n" |
| 7836 | "Do not export to next AS (well-known community)\n") |
| 7837 | { |
| 7838 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 7839 | } |
| 7840 | |
| 7841 | /* old command */ |
| 7842 | ALIAS (show_ipv6_mbgp_community, |
| 7843 | show_ipv6_mbgp_community2_cmd, |
| 7844 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7845 | SHOW_STR |
| 7846 | IPV6_STR |
| 7847 | MBGP_STR |
| 7848 | "Display routes matching the communities\n" |
| 7849 | "community number\n" |
| 7850 | "Do not send outside local AS (well-known community)\n" |
| 7851 | "Do not advertise to any peer (well-known community)\n" |
| 7852 | "Do not export to next AS (well-known community)\n" |
| 7853 | "community number\n" |
| 7854 | "Do not send outside local AS (well-known community)\n" |
| 7855 | "Do not advertise to any peer (well-known community)\n" |
| 7856 | "Do not export to next AS (well-known community)\n") |
| 7857 | |
| 7858 | /* old command */ |
| 7859 | ALIAS (show_ipv6_mbgp_community, |
| 7860 | show_ipv6_mbgp_community3_cmd, |
| 7861 | "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)", |
| 7862 | SHOW_STR |
| 7863 | IPV6_STR |
| 7864 | MBGP_STR |
| 7865 | "Display routes matching the communities\n" |
| 7866 | "community number\n" |
| 7867 | "Do not send outside local AS (well-known community)\n" |
| 7868 | "Do not advertise to any peer (well-known community)\n" |
| 7869 | "Do not export to next AS (well-known community)\n" |
| 7870 | "community number\n" |
| 7871 | "Do not send outside local AS (well-known community)\n" |
| 7872 | "Do not advertise to any peer (well-known community)\n" |
| 7873 | "Do not export to next AS (well-known community)\n" |
| 7874 | "community number\n" |
| 7875 | "Do not send outside local AS (well-known community)\n" |
| 7876 | "Do not advertise to any peer (well-known community)\n" |
| 7877 | "Do not export to next AS (well-known community)\n") |
| 7878 | |
| 7879 | /* old command */ |
| 7880 | ALIAS (show_ipv6_mbgp_community, |
| 7881 | show_ipv6_mbgp_community4_cmd, |
| 7882 | "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)", |
| 7883 | SHOW_STR |
| 7884 | IPV6_STR |
| 7885 | MBGP_STR |
| 7886 | "Display routes matching the communities\n" |
| 7887 | "community number\n" |
| 7888 | "Do not send outside local AS (well-known community)\n" |
| 7889 | "Do not advertise to any peer (well-known community)\n" |
| 7890 | "Do not export to next AS (well-known community)\n" |
| 7891 | "community number\n" |
| 7892 | "Do not send outside local AS (well-known community)\n" |
| 7893 | "Do not advertise to any peer (well-known community)\n" |
| 7894 | "Do not export to next AS (well-known community)\n" |
| 7895 | "community number\n" |
| 7896 | "Do not send outside local AS (well-known community)\n" |
| 7897 | "Do not advertise to any peer (well-known community)\n" |
| 7898 | "Do not export to next AS (well-known community)\n" |
| 7899 | "community number\n" |
| 7900 | "Do not send outside local AS (well-known community)\n" |
| 7901 | "Do not advertise to any peer (well-known community)\n" |
| 7902 | "Do not export to next AS (well-known community)\n") |
| 7903 | |
| 7904 | /* old command */ |
| 7905 | DEFUN (show_ipv6_mbgp_community_exact, |
| 7906 | show_ipv6_mbgp_community_exact_cmd, |
| 7907 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7908 | SHOW_STR |
| 7909 | IPV6_STR |
| 7910 | MBGP_STR |
| 7911 | "Display routes matching the communities\n" |
| 7912 | "community number\n" |
| 7913 | "Do not send outside local AS (well-known community)\n" |
| 7914 | "Do not advertise to any peer (well-known community)\n" |
| 7915 | "Do not export to next AS (well-known community)\n" |
| 7916 | "Exact match of the communities") |
| 7917 | { |
| 7918 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 7919 | } |
| 7920 | |
| 7921 | /* old command */ |
| 7922 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7923 | show_ipv6_mbgp_community2_exact_cmd, |
| 7924 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7925 | SHOW_STR |
| 7926 | IPV6_STR |
| 7927 | MBGP_STR |
| 7928 | "Display routes matching the communities\n" |
| 7929 | "community number\n" |
| 7930 | "Do not send outside local AS (well-known community)\n" |
| 7931 | "Do not advertise to any peer (well-known community)\n" |
| 7932 | "Do not export to next AS (well-known community)\n" |
| 7933 | "community number\n" |
| 7934 | "Do not send outside local AS (well-known community)\n" |
| 7935 | "Do not advertise to any peer (well-known community)\n" |
| 7936 | "Do not export to next AS (well-known community)\n" |
| 7937 | "Exact match of the communities") |
| 7938 | |
| 7939 | /* old command */ |
| 7940 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7941 | show_ipv6_mbgp_community3_exact_cmd, |
| 7942 | "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", |
| 7943 | SHOW_STR |
| 7944 | IPV6_STR |
| 7945 | MBGP_STR |
| 7946 | "Display routes matching the communities\n" |
| 7947 | "community number\n" |
| 7948 | "Do not send outside local AS (well-known community)\n" |
| 7949 | "Do not advertise to any peer (well-known community)\n" |
| 7950 | "Do not export to next AS (well-known community)\n" |
| 7951 | "community number\n" |
| 7952 | "Do not send outside local AS (well-known community)\n" |
| 7953 | "Do not advertise to any peer (well-known community)\n" |
| 7954 | "Do not export to next AS (well-known community)\n" |
| 7955 | "community number\n" |
| 7956 | "Do not send outside local AS (well-known community)\n" |
| 7957 | "Do not advertise to any peer (well-known community)\n" |
| 7958 | "Do not export to next AS (well-known community)\n" |
| 7959 | "Exact match of the communities") |
| 7960 | |
| 7961 | /* old command */ |
| 7962 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7963 | show_ipv6_mbgp_community4_exact_cmd, |
| 7964 | "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", |
| 7965 | SHOW_STR |
| 7966 | IPV6_STR |
| 7967 | MBGP_STR |
| 7968 | "Display routes matching the communities\n" |
| 7969 | "community number\n" |
| 7970 | "Do not send outside local AS (well-known community)\n" |
| 7971 | "Do not advertise to any peer (well-known community)\n" |
| 7972 | "Do not export to next AS (well-known community)\n" |
| 7973 | "community number\n" |
| 7974 | "Do not send outside local AS (well-known community)\n" |
| 7975 | "Do not advertise to any peer (well-known community)\n" |
| 7976 | "Do not export to next AS (well-known community)\n" |
| 7977 | "community number\n" |
| 7978 | "Do not send outside local AS (well-known community)\n" |
| 7979 | "Do not advertise to any peer (well-known community)\n" |
| 7980 | "Do not export to next AS (well-known community)\n" |
| 7981 | "community number\n" |
| 7982 | "Do not send outside local AS (well-known community)\n" |
| 7983 | "Do not advertise to any peer (well-known community)\n" |
| 7984 | "Do not export to next AS (well-known community)\n" |
| 7985 | "Exact match of the communities") |
| 7986 | #endif /* HAVE_IPV6 */ |
| 7987 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7988 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7989 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7990 | u_int16_t afi, u_char safi) |
| 7991 | { |
| 7992 | struct community_list *list; |
| 7993 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 7994 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7995 | if (list == NULL) |
| 7996 | { |
| 7997 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 7998 | VTY_NEWLINE); |
| 7999 | return CMD_WARNING; |
| 8000 | } |
| 8001 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8002 | return bgp_show (vty, NULL, afi, safi, |
| 8003 | (exact ? bgp_show_type_community_list_exact : |
| 8004 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8005 | } |
| 8006 | |
| 8007 | DEFUN (show_ip_bgp_community_list, |
| 8008 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8009 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8010 | SHOW_STR |
| 8011 | IP_STR |
| 8012 | BGP_STR |
| 8013 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8014 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8015 | "community-list name\n") |
| 8016 | { |
| 8017 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8018 | } |
| 8019 | |
| 8020 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8021 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8022 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8023 | SHOW_STR |
| 8024 | IP_STR |
| 8025 | BGP_STR |
| 8026 | "Address family\n" |
| 8027 | "Address Family modifier\n" |
| 8028 | "Address Family modifier\n" |
| 8029 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8030 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8031 | "community-list name\n") |
| 8032 | { |
| 8033 | if (strncmp (argv[0], "m", 1) == 0) |
| 8034 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8035 | |
| 8036 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8037 | } |
| 8038 | |
| 8039 | DEFUN (show_ip_bgp_community_list_exact, |
| 8040 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8041 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8042 | SHOW_STR |
| 8043 | IP_STR |
| 8044 | BGP_STR |
| 8045 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8046 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8047 | "community-list name\n" |
| 8048 | "Exact match of the communities\n") |
| 8049 | { |
| 8050 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8051 | } |
| 8052 | |
| 8053 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8054 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8055 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8056 | SHOW_STR |
| 8057 | IP_STR |
| 8058 | BGP_STR |
| 8059 | "Address family\n" |
| 8060 | "Address Family modifier\n" |
| 8061 | "Address Family modifier\n" |
| 8062 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8063 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8064 | "community-list name\n" |
| 8065 | "Exact match of the communities\n") |
| 8066 | { |
| 8067 | if (strncmp (argv[0], "m", 1) == 0) |
| 8068 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8069 | |
| 8070 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8071 | } |
| 8072 | |
| 8073 | #ifdef HAVE_IPV6 |
| 8074 | DEFUN (show_bgp_community_list, |
| 8075 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8076 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8077 | SHOW_STR |
| 8078 | BGP_STR |
| 8079 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8080 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8081 | "community-list name\n") |
| 8082 | { |
| 8083 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8084 | } |
| 8085 | |
| 8086 | ALIAS (show_bgp_community_list, |
| 8087 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8088 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8089 | SHOW_STR |
| 8090 | BGP_STR |
| 8091 | "Address family\n" |
| 8092 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8093 | "community-list number\n" |
| 8094 | "community-list name\n"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8095 | |
| 8096 | /* old command */ |
| 8097 | DEFUN (show_ipv6_bgp_community_list, |
| 8098 | show_ipv6_bgp_community_list_cmd, |
| 8099 | "show ipv6 bgp community-list WORD", |
| 8100 | SHOW_STR |
| 8101 | IPV6_STR |
| 8102 | BGP_STR |
| 8103 | "Display routes matching the community-list\n" |
| 8104 | "community-list name\n") |
| 8105 | { |
| 8106 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8107 | } |
| 8108 | |
| 8109 | /* old command */ |
| 8110 | DEFUN (show_ipv6_mbgp_community_list, |
| 8111 | show_ipv6_mbgp_community_list_cmd, |
| 8112 | "show ipv6 mbgp community-list WORD", |
| 8113 | SHOW_STR |
| 8114 | IPV6_STR |
| 8115 | MBGP_STR |
| 8116 | "Display routes matching the community-list\n" |
| 8117 | "community-list name\n") |
| 8118 | { |
| 8119 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8120 | } |
| 8121 | |
| 8122 | DEFUN (show_bgp_community_list_exact, |
| 8123 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8124 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8125 | SHOW_STR |
| 8126 | BGP_STR |
| 8127 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8128 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8129 | "community-list name\n" |
| 8130 | "Exact match of the communities\n") |
| 8131 | { |
| 8132 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8133 | } |
| 8134 | |
| 8135 | ALIAS (show_bgp_community_list_exact, |
| 8136 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8137 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8138 | SHOW_STR |
| 8139 | BGP_STR |
| 8140 | "Address family\n" |
| 8141 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8142 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8143 | "community-list name\n" |
| 8144 | "Exact match of the communities\n") |
| 8145 | |
| 8146 | /* old command */ |
| 8147 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 8148 | show_ipv6_bgp_community_list_exact_cmd, |
| 8149 | "show ipv6 bgp community-list WORD exact-match", |
| 8150 | SHOW_STR |
| 8151 | IPV6_STR |
| 8152 | BGP_STR |
| 8153 | "Display routes matching the community-list\n" |
| 8154 | "community-list name\n" |
| 8155 | "Exact match of the communities\n") |
| 8156 | { |
| 8157 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8158 | } |
| 8159 | |
| 8160 | /* old command */ |
| 8161 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 8162 | show_ipv6_mbgp_community_list_exact_cmd, |
| 8163 | "show ipv6 mbgp community-list WORD exact-match", |
| 8164 | SHOW_STR |
| 8165 | IPV6_STR |
| 8166 | MBGP_STR |
| 8167 | "Display routes matching the community-list\n" |
| 8168 | "community-list name\n" |
| 8169 | "Exact match of the communities\n") |
| 8170 | { |
| 8171 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 8172 | } |
| 8173 | #endif /* HAVE_IPV6 */ |
| 8174 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8175 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8176 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8177 | safi_t safi, enum bgp_show_type type) |
| 8178 | { |
| 8179 | int ret; |
| 8180 | struct prefix *p; |
| 8181 | |
| 8182 | p = prefix_new(); |
| 8183 | |
| 8184 | ret = str2prefix (prefix, p); |
| 8185 | if (! ret) |
| 8186 | { |
| 8187 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 8188 | return CMD_WARNING; |
| 8189 | } |
| 8190 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8191 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 8192 | prefix_free(p); |
| 8193 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8194 | } |
| 8195 | |
| 8196 | DEFUN (show_ip_bgp_prefix_longer, |
| 8197 | show_ip_bgp_prefix_longer_cmd, |
| 8198 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 8199 | SHOW_STR |
| 8200 | IP_STR |
| 8201 | BGP_STR |
| 8202 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8203 | "Display route and more specific routes\n") |
| 8204 | { |
| 8205 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8206 | bgp_show_type_prefix_longer); |
| 8207 | } |
| 8208 | |
| 8209 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 8210 | show_ip_bgp_flap_prefix_longer_cmd, |
| 8211 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 8212 | SHOW_STR |
| 8213 | IP_STR |
| 8214 | BGP_STR |
| 8215 | "Display flap statistics of routes\n" |
| 8216 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8217 | "Display route and more specific routes\n") |
| 8218 | { |
| 8219 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8220 | bgp_show_type_flap_prefix_longer); |
| 8221 | } |
| 8222 | |
| 8223 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 8224 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 8225 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 8226 | SHOW_STR |
| 8227 | IP_STR |
| 8228 | BGP_STR |
| 8229 | "Address family\n" |
| 8230 | "Address Family modifier\n" |
| 8231 | "Address Family modifier\n" |
| 8232 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8233 | "Display route and more specific routes\n") |
| 8234 | { |
| 8235 | if (strncmp (argv[0], "m", 1) == 0) |
| 8236 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8237 | bgp_show_type_prefix_longer); |
| 8238 | |
| 8239 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8240 | bgp_show_type_prefix_longer); |
| 8241 | } |
| 8242 | |
| 8243 | DEFUN (show_ip_bgp_flap_address, |
| 8244 | show_ip_bgp_flap_address_cmd, |
| 8245 | "show ip bgp flap-statistics A.B.C.D", |
| 8246 | SHOW_STR |
| 8247 | IP_STR |
| 8248 | BGP_STR |
| 8249 | "Display flap statistics of routes\n" |
| 8250 | "Network in the BGP routing table to display\n") |
| 8251 | { |
| 8252 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8253 | bgp_show_type_flap_address); |
| 8254 | } |
| 8255 | |
| 8256 | DEFUN (show_ip_bgp_flap_prefix, |
| 8257 | show_ip_bgp_flap_prefix_cmd, |
| 8258 | "show ip bgp flap-statistics A.B.C.D/M", |
| 8259 | SHOW_STR |
| 8260 | IP_STR |
| 8261 | BGP_STR |
| 8262 | "Display flap statistics of routes\n" |
| 8263 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8264 | { |
| 8265 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8266 | bgp_show_type_flap_prefix); |
| 8267 | } |
| 8268 | #ifdef HAVE_IPV6 |
| 8269 | DEFUN (show_bgp_prefix_longer, |
| 8270 | show_bgp_prefix_longer_cmd, |
| 8271 | "show bgp X:X::X:X/M longer-prefixes", |
| 8272 | SHOW_STR |
| 8273 | BGP_STR |
| 8274 | "IPv6 prefix <network>/<length>\n" |
| 8275 | "Display route and more specific routes\n") |
| 8276 | { |
| 8277 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8278 | bgp_show_type_prefix_longer); |
| 8279 | } |
| 8280 | |
| 8281 | ALIAS (show_bgp_prefix_longer, |
| 8282 | show_bgp_ipv6_prefix_longer_cmd, |
| 8283 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 8284 | SHOW_STR |
| 8285 | BGP_STR |
| 8286 | "Address family\n" |
| 8287 | "IPv6 prefix <network>/<length>\n" |
| 8288 | "Display route and more specific routes\n") |
| 8289 | |
| 8290 | /* old command */ |
| 8291 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 8292 | show_ipv6_bgp_prefix_longer_cmd, |
| 8293 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 8294 | SHOW_STR |
| 8295 | IPV6_STR |
| 8296 | BGP_STR |
| 8297 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8298 | "Display route and more specific routes\n") |
| 8299 | { |
| 8300 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8301 | bgp_show_type_prefix_longer); |
| 8302 | } |
| 8303 | |
| 8304 | /* old command */ |
| 8305 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 8306 | show_ipv6_mbgp_prefix_longer_cmd, |
| 8307 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 8308 | SHOW_STR |
| 8309 | IPV6_STR |
| 8310 | MBGP_STR |
| 8311 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8312 | "Display route and more specific routes\n") |
| 8313 | { |
| 8314 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8315 | bgp_show_type_prefix_longer); |
| 8316 | } |
| 8317 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8318 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8319 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8320 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 8321 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8322 | { |
| 8323 | int ret; |
| 8324 | struct bgp *bgp; |
| 8325 | struct peer *peer; |
| 8326 | union sockunion su; |
| 8327 | |
| 8328 | /* BGP structure lookup. */ |
| 8329 | if (view_name) |
| 8330 | { |
| 8331 | bgp = bgp_lookup_by_name (view_name); |
| 8332 | if (! bgp) |
| 8333 | { |
| 8334 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8335 | return NULL; |
| 8336 | } |
| 8337 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 8338 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8339 | { |
| 8340 | bgp = bgp_get_default (); |
| 8341 | if (! bgp) |
| 8342 | { |
| 8343 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8344 | return NULL; |
| 8345 | } |
| 8346 | } |
| 8347 | |
| 8348 | /* Get peer sockunion. */ |
| 8349 | ret = str2sockunion (ip_str, &su); |
| 8350 | if (ret < 0) |
| 8351 | { |
| 8352 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 8353 | return NULL; |
| 8354 | } |
| 8355 | |
| 8356 | /* Peer structure lookup. */ |
| 8357 | peer = peer_lookup (bgp, &su); |
| 8358 | if (! peer) |
| 8359 | { |
| 8360 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 8361 | return NULL; |
| 8362 | } |
| 8363 | |
| 8364 | return peer; |
| 8365 | } |
| 8366 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8367 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8368 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 8369 | int in) |
| 8370 | { |
| 8371 | struct bgp_table *table; |
| 8372 | struct bgp_adj_in *ain; |
| 8373 | struct bgp_adj_out *adj; |
| 8374 | unsigned long output_count; |
| 8375 | struct bgp_node *rn; |
| 8376 | int header1 = 1; |
| 8377 | struct bgp *bgp; |
| 8378 | int header2 = 1; |
| 8379 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8380 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8381 | |
| 8382 | if (! bgp) |
| 8383 | return; |
| 8384 | |
| 8385 | table = bgp->rib[afi][safi]; |
| 8386 | |
| 8387 | output_count = 0; |
| 8388 | |
| 8389 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 8390 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 8391 | { |
| 8392 | 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] | 8393 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8394 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8395 | |
| 8396 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 8397 | VTY_NEWLINE, VTY_NEWLINE); |
| 8398 | header1 = 0; |
| 8399 | } |
| 8400 | |
| 8401 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 8402 | if (in) |
| 8403 | { |
| 8404 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 8405 | if (ain->peer == peer) |
| 8406 | { |
| 8407 | if (header1) |
| 8408 | { |
| 8409 | 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] | 8410 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8411 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8412 | header1 = 0; |
| 8413 | } |
| 8414 | if (header2) |
| 8415 | { |
| 8416 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8417 | header2 = 0; |
| 8418 | } |
| 8419 | if (ain->attr) |
| 8420 | { |
| 8421 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 8422 | output_count++; |
| 8423 | } |
| 8424 | } |
| 8425 | } |
| 8426 | else |
| 8427 | { |
| 8428 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 8429 | if (adj->peer == peer) |
| 8430 | { |
| 8431 | if (header1) |
| 8432 | { |
| 8433 | 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] | 8434 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8435 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8436 | header1 = 0; |
| 8437 | } |
| 8438 | if (header2) |
| 8439 | { |
| 8440 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8441 | header2 = 0; |
| 8442 | } |
| 8443 | if (adj->attr) |
| 8444 | { |
| 8445 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 8446 | output_count++; |
| 8447 | } |
| 8448 | } |
| 8449 | } |
| 8450 | |
| 8451 | if (output_count != 0) |
| 8452 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 8453 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 8454 | } |
| 8455 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8456 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8457 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 8458 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8459 | if (! peer || ! peer->afc[afi][safi]) |
| 8460 | { |
| 8461 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 8462 | return CMD_WARNING; |
| 8463 | } |
| 8464 | |
| 8465 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 8466 | { |
| 8467 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 8468 | VTY_NEWLINE); |
| 8469 | return CMD_WARNING; |
| 8470 | } |
| 8471 | |
| 8472 | show_adj_route (vty, peer, afi, safi, in); |
| 8473 | |
| 8474 | return CMD_SUCCESS; |
| 8475 | } |
| 8476 | |
| 8477 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 8478 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 8479 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8480 | SHOW_STR |
| 8481 | IP_STR |
| 8482 | BGP_STR |
| 8483 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8484 | "Neighbor to display information about\n" |
| 8485 | "Neighbor to display information about\n" |
| 8486 | "Display the routes advertised to a BGP neighbor\n") |
| 8487 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8488 | struct peer *peer; |
| 8489 | |
| 8490 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8491 | if (! peer) |
| 8492 | return CMD_WARNING; |
| 8493 | |
| 8494 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8495 | } |
| 8496 | |
| 8497 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 8498 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 8499 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8500 | SHOW_STR |
| 8501 | IP_STR |
| 8502 | BGP_STR |
| 8503 | "Address family\n" |
| 8504 | "Address Family modifier\n" |
| 8505 | "Address Family modifier\n" |
| 8506 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8507 | "Neighbor to display information about\n" |
| 8508 | "Neighbor to display information about\n" |
| 8509 | "Display the routes advertised to a BGP neighbor\n") |
| 8510 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8511 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8512 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8513 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8514 | if (! peer) |
| 8515 | return CMD_WARNING; |
| 8516 | |
| 8517 | if (strncmp (argv[0], "m", 1) == 0) |
| 8518 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 8519 | |
| 8520 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8521 | } |
| 8522 | |
| 8523 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8524 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 8525 | show_bgp_view_neighbor_advertised_route_cmd, |
| 8526 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8527 | SHOW_STR |
| 8528 | BGP_STR |
| 8529 | "BGP view\n" |
| 8530 | "View name\n" |
| 8531 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8532 | "Neighbor to display information about\n" |
| 8533 | "Neighbor to display information about\n" |
| 8534 | "Display the routes advertised to a BGP neighbor\n") |
| 8535 | { |
| 8536 | struct peer *peer; |
| 8537 | |
| 8538 | if (argc == 2) |
| 8539 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8540 | else |
| 8541 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8542 | |
| 8543 | if (! peer) |
| 8544 | return CMD_WARNING; |
| 8545 | |
| 8546 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 8547 | } |
| 8548 | |
| 8549 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 8550 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 8551 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8552 | SHOW_STR |
| 8553 | BGP_STR |
| 8554 | "BGP view\n" |
| 8555 | "View name\n" |
| 8556 | "Address family\n" |
| 8557 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8558 | "Neighbor to display information about\n" |
| 8559 | "Neighbor to display information about\n" |
| 8560 | "Display the routes advertised to a BGP neighbor\n") |
| 8561 | |
| 8562 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 8563 | show_bgp_view_neighbor_received_routes_cmd, |
| 8564 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8565 | SHOW_STR |
| 8566 | BGP_STR |
| 8567 | "BGP view\n" |
| 8568 | "View name\n" |
| 8569 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8570 | "Neighbor to display information about\n" |
| 8571 | "Neighbor to display information about\n" |
| 8572 | "Display the received routes from neighbor\n") |
| 8573 | { |
| 8574 | struct peer *peer; |
| 8575 | |
| 8576 | if (argc == 2) |
| 8577 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8578 | else |
| 8579 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8580 | |
| 8581 | if (! peer) |
| 8582 | return CMD_WARNING; |
| 8583 | |
| 8584 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 8585 | } |
| 8586 | |
| 8587 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 8588 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 8589 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8590 | SHOW_STR |
| 8591 | BGP_STR |
| 8592 | "BGP view\n" |
| 8593 | "View name\n" |
| 8594 | "Address family\n" |
| 8595 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8596 | "Neighbor to display information about\n" |
| 8597 | "Neighbor to display information about\n" |
| 8598 | "Display the received routes from neighbor\n") |
| 8599 | |
| 8600 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8601 | show_bgp_neighbor_advertised_route_cmd, |
| 8602 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8603 | SHOW_STR |
| 8604 | BGP_STR |
| 8605 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8606 | "Neighbor to display information about\n" |
| 8607 | "Neighbor to display information about\n" |
| 8608 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8609 | |
| 8610 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8611 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 8612 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8613 | SHOW_STR |
| 8614 | BGP_STR |
| 8615 | "Address family\n" |
| 8616 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8617 | "Neighbor to display information about\n" |
| 8618 | "Neighbor to display information about\n" |
| 8619 | "Display the routes advertised to a BGP neighbor\n") |
| 8620 | |
| 8621 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8622 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8623 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 8624 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8625 | SHOW_STR |
| 8626 | IPV6_STR |
| 8627 | BGP_STR |
| 8628 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8629 | "Neighbor to display information about\n" |
| 8630 | "Neighbor to display information about\n" |
| 8631 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8632 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8633 | /* old command */ |
| 8634 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 8635 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 8636 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8637 | SHOW_STR |
| 8638 | IPV6_STR |
| 8639 | MBGP_STR |
| 8640 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8641 | "Neighbor to display information about\n" |
| 8642 | "Neighbor to display information about\n" |
| 8643 | "Display the routes advertised to a BGP neighbor\n") |
| 8644 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8645 | struct peer *peer; |
| 8646 | |
| 8647 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8648 | if (! peer) |
| 8649 | return CMD_WARNING; |
| 8650 | |
| 8651 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8652 | } |
| 8653 | #endif /* HAVE_IPV6 */ |
| 8654 | |
| 8655 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 8656 | show_ip_bgp_neighbor_received_routes_cmd, |
| 8657 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8658 | SHOW_STR |
| 8659 | IP_STR |
| 8660 | BGP_STR |
| 8661 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8662 | "Neighbor to display information about\n" |
| 8663 | "Neighbor to display information about\n" |
| 8664 | "Display the received routes from neighbor\n") |
| 8665 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8666 | struct peer *peer; |
| 8667 | |
| 8668 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8669 | if (! peer) |
| 8670 | return CMD_WARNING; |
| 8671 | |
| 8672 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8673 | } |
| 8674 | |
| 8675 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 8676 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 8677 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8678 | SHOW_STR |
| 8679 | IP_STR |
| 8680 | BGP_STR |
| 8681 | "Address family\n" |
| 8682 | "Address Family modifier\n" |
| 8683 | "Address Family modifier\n" |
| 8684 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8685 | "Neighbor to display information about\n" |
| 8686 | "Neighbor to display information about\n" |
| 8687 | "Display the received routes from neighbor\n") |
| 8688 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8689 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8690 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8691 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8692 | if (! peer) |
| 8693 | return CMD_WARNING; |
| 8694 | |
| 8695 | if (strncmp (argv[0], "m", 1) == 0) |
| 8696 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 8697 | |
| 8698 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8699 | } |
| 8700 | |
| 8701 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 8702 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 8703 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8704 | SHOW_STR |
| 8705 | IP_STR |
| 8706 | BGP_STR |
| 8707 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8708 | "Neighbor to display information about\n" |
| 8709 | "Neighbor to display information about\n" |
| 8710 | "Display information received from a BGP neighbor\n" |
| 8711 | "Display the prefixlist filter\n") |
| 8712 | { |
| 8713 | char name[BUFSIZ]; |
| 8714 | union sockunion *su; |
| 8715 | struct peer *peer; |
| 8716 | int count; |
| 8717 | |
| 8718 | su = sockunion_str2su (argv[0]); |
| 8719 | if (su == NULL) |
| 8720 | return CMD_WARNING; |
| 8721 | |
| 8722 | peer = peer_lookup (NULL, su); |
| 8723 | if (! peer) |
| 8724 | return CMD_WARNING; |
| 8725 | |
| 8726 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8727 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8728 | if (count) |
| 8729 | { |
| 8730 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8731 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8732 | } |
| 8733 | |
| 8734 | return CMD_SUCCESS; |
| 8735 | } |
| 8736 | |
| 8737 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 8738 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 8739 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8740 | SHOW_STR |
| 8741 | IP_STR |
| 8742 | BGP_STR |
| 8743 | "Address family\n" |
| 8744 | "Address Family modifier\n" |
| 8745 | "Address Family modifier\n" |
| 8746 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8747 | "Neighbor to display information about\n" |
| 8748 | "Neighbor to display information about\n" |
| 8749 | "Display information received from a BGP neighbor\n" |
| 8750 | "Display the prefixlist filter\n") |
| 8751 | { |
| 8752 | char name[BUFSIZ]; |
| 8753 | union sockunion *su; |
| 8754 | struct peer *peer; |
| 8755 | int count; |
| 8756 | |
| 8757 | su = sockunion_str2su (argv[1]); |
| 8758 | if (su == NULL) |
| 8759 | return CMD_WARNING; |
| 8760 | |
| 8761 | peer = peer_lookup (NULL, su); |
| 8762 | if (! peer) |
| 8763 | return CMD_WARNING; |
| 8764 | |
| 8765 | if (strncmp (argv[0], "m", 1) == 0) |
| 8766 | { |
| 8767 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 8768 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8769 | if (count) |
| 8770 | { |
| 8771 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 8772 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8773 | } |
| 8774 | } |
| 8775 | else |
| 8776 | { |
| 8777 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8778 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8779 | if (count) |
| 8780 | { |
| 8781 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8782 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8783 | } |
| 8784 | } |
| 8785 | |
| 8786 | return CMD_SUCCESS; |
| 8787 | } |
| 8788 | |
| 8789 | |
| 8790 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8791 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8792 | show_bgp_neighbor_received_routes_cmd, |
| 8793 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8794 | SHOW_STR |
| 8795 | BGP_STR |
| 8796 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8797 | "Neighbor to display information about\n" |
| 8798 | "Neighbor to display information about\n" |
| 8799 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8800 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8801 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8802 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 8803 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8804 | SHOW_STR |
| 8805 | BGP_STR |
| 8806 | "Address family\n" |
| 8807 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8808 | "Neighbor to display information about\n" |
| 8809 | "Neighbor to display information about\n" |
| 8810 | "Display the received routes from neighbor\n") |
| 8811 | |
| 8812 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 8813 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 8814 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8815 | SHOW_STR |
| 8816 | BGP_STR |
| 8817 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8818 | "Neighbor to display information about\n" |
| 8819 | "Neighbor to display information about\n" |
| 8820 | "Display information received from a BGP neighbor\n" |
| 8821 | "Display the prefixlist filter\n") |
| 8822 | { |
| 8823 | char name[BUFSIZ]; |
| 8824 | union sockunion *su; |
| 8825 | struct peer *peer; |
| 8826 | int count; |
| 8827 | |
| 8828 | su = sockunion_str2su (argv[0]); |
| 8829 | if (su == NULL) |
| 8830 | return CMD_WARNING; |
| 8831 | |
| 8832 | peer = peer_lookup (NULL, su); |
| 8833 | if (! peer) |
| 8834 | return CMD_WARNING; |
| 8835 | |
| 8836 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8837 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8838 | if (count) |
| 8839 | { |
| 8840 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8841 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8842 | } |
| 8843 | |
| 8844 | return CMD_SUCCESS; |
| 8845 | } |
| 8846 | |
| 8847 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 8848 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 8849 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8850 | SHOW_STR |
| 8851 | BGP_STR |
| 8852 | "Address family\n" |
| 8853 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8854 | "Neighbor to display information about\n" |
| 8855 | "Neighbor to display information about\n" |
| 8856 | "Display information received from a BGP neighbor\n" |
| 8857 | "Display the prefixlist filter\n") |
| 8858 | |
| 8859 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8860 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8861 | ipv6_bgp_neighbor_received_routes_cmd, |
| 8862 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8863 | SHOW_STR |
| 8864 | IPV6_STR |
| 8865 | BGP_STR |
| 8866 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8867 | "Neighbor to display information about\n" |
| 8868 | "Neighbor to display information about\n" |
| 8869 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8870 | |
| 8871 | /* old command */ |
| 8872 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 8873 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 8874 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8875 | SHOW_STR |
| 8876 | IPV6_STR |
| 8877 | MBGP_STR |
| 8878 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8879 | "Neighbor to display information about\n" |
| 8880 | "Neighbor to display information about\n" |
| 8881 | "Display the received routes from neighbor\n") |
| 8882 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8883 | struct peer *peer; |
| 8884 | |
| 8885 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8886 | if (! peer) |
| 8887 | return CMD_WARNING; |
| 8888 | |
| 8889 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8890 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8891 | |
| 8892 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 8893 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 8894 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8895 | SHOW_STR |
| 8896 | BGP_STR |
| 8897 | "BGP view\n" |
| 8898 | "View name\n" |
| 8899 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8900 | "Neighbor to display information about\n" |
| 8901 | "Neighbor to display information about\n" |
| 8902 | "Display information received from a BGP neighbor\n" |
| 8903 | "Display the prefixlist filter\n") |
| 8904 | { |
| 8905 | char name[BUFSIZ]; |
| 8906 | union sockunion *su; |
| 8907 | struct peer *peer; |
| 8908 | struct bgp *bgp; |
| 8909 | int count; |
| 8910 | |
| 8911 | /* BGP structure lookup. */ |
| 8912 | bgp = bgp_lookup_by_name (argv[0]); |
| 8913 | if (bgp == NULL) |
| 8914 | { |
| 8915 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8916 | return CMD_WARNING; |
| 8917 | } |
| 8918 | |
| 8919 | su = sockunion_str2su (argv[1]); |
| 8920 | if (su == NULL) |
| 8921 | return CMD_WARNING; |
| 8922 | |
| 8923 | peer = peer_lookup (bgp, su); |
| 8924 | if (! peer) |
| 8925 | return CMD_WARNING; |
| 8926 | |
| 8927 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8928 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8929 | if (count) |
| 8930 | { |
| 8931 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8932 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8933 | } |
| 8934 | |
| 8935 | return CMD_SUCCESS; |
| 8936 | } |
| 8937 | |
| 8938 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 8939 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 8940 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8941 | SHOW_STR |
| 8942 | BGP_STR |
| 8943 | "BGP view\n" |
| 8944 | "View name\n" |
| 8945 | "Address family\n" |
| 8946 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8947 | "Neighbor to display information about\n" |
| 8948 | "Neighbor to display information about\n" |
| 8949 | "Display information received from a BGP neighbor\n" |
| 8950 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8951 | #endif /* HAVE_IPV6 */ |
| 8952 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8953 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8954 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8955 | safi_t safi, enum bgp_show_type type) |
| 8956 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8957 | if (! peer || ! peer->afc[afi][safi]) |
| 8958 | { |
| 8959 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8960 | return CMD_WARNING; |
| 8961 | } |
| 8962 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8963 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8964 | } |
| 8965 | |
| 8966 | DEFUN (show_ip_bgp_neighbor_routes, |
| 8967 | show_ip_bgp_neighbor_routes_cmd, |
| 8968 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8969 | SHOW_STR |
| 8970 | IP_STR |
| 8971 | BGP_STR |
| 8972 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8973 | "Neighbor to display information about\n" |
| 8974 | "Neighbor to display information about\n" |
| 8975 | "Display routes learned from neighbor\n") |
| 8976 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8977 | struct peer *peer; |
| 8978 | |
| 8979 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8980 | if (! peer) |
| 8981 | return CMD_WARNING; |
| 8982 | |
| 8983 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8984 | bgp_show_type_neighbor); |
| 8985 | } |
| 8986 | |
| 8987 | DEFUN (show_ip_bgp_neighbor_flap, |
| 8988 | show_ip_bgp_neighbor_flap_cmd, |
| 8989 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 8990 | SHOW_STR |
| 8991 | IP_STR |
| 8992 | BGP_STR |
| 8993 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8994 | "Neighbor to display information about\n" |
| 8995 | "Neighbor to display information about\n" |
| 8996 | "Display flap statistics of the routes learned from neighbor\n") |
| 8997 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8998 | struct peer *peer; |
| 8999 | |
| 9000 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9001 | if (! peer) |
| 9002 | return CMD_WARNING; |
| 9003 | |
| 9004 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9005 | bgp_show_type_flap_neighbor); |
| 9006 | } |
| 9007 | |
| 9008 | DEFUN (show_ip_bgp_neighbor_damp, |
| 9009 | show_ip_bgp_neighbor_damp_cmd, |
| 9010 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9011 | SHOW_STR |
| 9012 | IP_STR |
| 9013 | BGP_STR |
| 9014 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9015 | "Neighbor to display information about\n" |
| 9016 | "Neighbor to display information about\n" |
| 9017 | "Display the dampened routes received from neighbor\n") |
| 9018 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9019 | struct peer *peer; |
| 9020 | |
| 9021 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9022 | if (! peer) |
| 9023 | return CMD_WARNING; |
| 9024 | |
| 9025 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9026 | bgp_show_type_damp_neighbor); |
| 9027 | } |
| 9028 | |
| 9029 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 9030 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 9031 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 9032 | SHOW_STR |
| 9033 | IP_STR |
| 9034 | BGP_STR |
| 9035 | "Address family\n" |
| 9036 | "Address Family modifier\n" |
| 9037 | "Address Family modifier\n" |
| 9038 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9039 | "Neighbor to display information about\n" |
| 9040 | "Neighbor to display information about\n" |
| 9041 | "Display routes learned from neighbor\n") |
| 9042 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9043 | struct peer *peer; |
| 9044 | |
| 9045 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9046 | if (! peer) |
| 9047 | return CMD_WARNING; |
| 9048 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9049 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9050 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9051 | bgp_show_type_neighbor); |
| 9052 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9053 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9054 | bgp_show_type_neighbor); |
| 9055 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9056 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9057 | DEFUN (show_ip_bgp_view_rsclient, |
| 9058 | show_ip_bgp_view_rsclient_cmd, |
| 9059 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9060 | SHOW_STR |
| 9061 | IP_STR |
| 9062 | BGP_STR |
| 9063 | "BGP view\n" |
| 9064 | "BGP view name\n" |
| 9065 | "Information about Route Server Client\n" |
| 9066 | NEIGHBOR_ADDR_STR) |
| 9067 | { |
| 9068 | struct bgp_table *table; |
| 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 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9080 | { |
| 9081 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9082 | VTY_NEWLINE); |
| 9083 | return CMD_WARNING; |
| 9084 | } |
| 9085 | |
| 9086 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9087 | PEER_FLAG_RSERVER_CLIENT)) |
| 9088 | { |
| 9089 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9090 | VTY_NEWLINE); |
| 9091 | return CMD_WARNING; |
| 9092 | } |
| 9093 | |
| 9094 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 9095 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9096 | 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] | 9097 | } |
| 9098 | |
| 9099 | ALIAS (show_ip_bgp_view_rsclient, |
| 9100 | show_ip_bgp_rsclient_cmd, |
| 9101 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9102 | SHOW_STR |
| 9103 | IP_STR |
| 9104 | BGP_STR |
| 9105 | "Information about Route Server Client\n" |
| 9106 | NEIGHBOR_ADDR_STR) |
| 9107 | |
| 9108 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 9109 | show_ip_bgp_view_rsclient_route_cmd, |
| 9110 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 9111 | SHOW_STR |
| 9112 | IP_STR |
| 9113 | BGP_STR |
| 9114 | "BGP view\n" |
| 9115 | "BGP view name\n" |
| 9116 | "Information about Route Server Client\n" |
| 9117 | NEIGHBOR_ADDR_STR |
| 9118 | "Network in the BGP routing table to display\n") |
| 9119 | { |
| 9120 | struct bgp *bgp; |
| 9121 | struct peer *peer; |
| 9122 | |
| 9123 | /* BGP structure lookup. */ |
| 9124 | if (argc == 3) |
| 9125 | { |
| 9126 | bgp = bgp_lookup_by_name (argv[0]); |
| 9127 | if (bgp == NULL) |
| 9128 | { |
| 9129 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9130 | return CMD_WARNING; |
| 9131 | } |
| 9132 | } |
| 9133 | else |
| 9134 | { |
| 9135 | bgp = bgp_get_default (); |
| 9136 | if (bgp == NULL) |
| 9137 | { |
| 9138 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9139 | return CMD_WARNING; |
| 9140 | } |
| 9141 | } |
| 9142 | |
| 9143 | if (argc == 3) |
| 9144 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9145 | else |
| 9146 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9147 | |
| 9148 | if (! peer) |
| 9149 | return CMD_WARNING; |
| 9150 | |
| 9151 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9152 | { |
| 9153 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9154 | VTY_NEWLINE); |
| 9155 | return CMD_WARNING; |
| 9156 | } |
| 9157 | |
| 9158 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9159 | PEER_FLAG_RSERVER_CLIENT)) |
| 9160 | { |
| 9161 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9162 | VTY_NEWLINE); |
| 9163 | return CMD_WARNING; |
| 9164 | } |
| 9165 | |
| 9166 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 9167 | (argc == 3) ? argv[2] : argv[1], |
| 9168 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 9169 | } |
| 9170 | |
| 9171 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 9172 | show_ip_bgp_rsclient_route_cmd, |
| 9173 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 9174 | SHOW_STR |
| 9175 | IP_STR |
| 9176 | BGP_STR |
| 9177 | "Information about Route Server Client\n" |
| 9178 | NEIGHBOR_ADDR_STR |
| 9179 | "Network in the BGP routing table to display\n") |
| 9180 | |
| 9181 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 9182 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 9183 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 9184 | SHOW_STR |
| 9185 | IP_STR |
| 9186 | BGP_STR |
| 9187 | "BGP view\n" |
| 9188 | "BGP view name\n" |
| 9189 | "Information about Route Server Client\n" |
| 9190 | NEIGHBOR_ADDR_STR |
| 9191 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9192 | { |
| 9193 | struct bgp *bgp; |
| 9194 | struct peer *peer; |
| 9195 | |
| 9196 | /* BGP structure lookup. */ |
| 9197 | if (argc == 3) |
| 9198 | { |
| 9199 | bgp = bgp_lookup_by_name (argv[0]); |
| 9200 | if (bgp == NULL) |
| 9201 | { |
| 9202 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9203 | return CMD_WARNING; |
| 9204 | } |
| 9205 | } |
| 9206 | else |
| 9207 | { |
| 9208 | bgp = bgp_get_default (); |
| 9209 | if (bgp == NULL) |
| 9210 | { |
| 9211 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9212 | return CMD_WARNING; |
| 9213 | } |
| 9214 | } |
| 9215 | |
| 9216 | if (argc == 3) |
| 9217 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9218 | else |
| 9219 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9220 | |
| 9221 | if (! peer) |
| 9222 | return CMD_WARNING; |
| 9223 | |
| 9224 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9225 | { |
| 9226 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9227 | VTY_NEWLINE); |
| 9228 | return CMD_WARNING; |
| 9229 | } |
| 9230 | |
| 9231 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9232 | PEER_FLAG_RSERVER_CLIENT)) |
| 9233 | { |
| 9234 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9235 | VTY_NEWLINE); |
| 9236 | return CMD_WARNING; |
| 9237 | } |
| 9238 | |
| 9239 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 9240 | (argc == 3) ? argv[2] : argv[1], |
| 9241 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 9242 | } |
| 9243 | |
| 9244 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 9245 | show_ip_bgp_rsclient_prefix_cmd, |
| 9246 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 9247 | SHOW_STR |
| 9248 | IP_STR |
| 9249 | BGP_STR |
| 9250 | "Information about Route Server Client\n" |
| 9251 | NEIGHBOR_ADDR_STR |
| 9252 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9253 | |
| 9254 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9255 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9256 | DEFUN (show_bgp_view_neighbor_routes, |
| 9257 | show_bgp_view_neighbor_routes_cmd, |
| 9258 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 9259 | SHOW_STR |
| 9260 | BGP_STR |
| 9261 | "BGP view\n" |
| 9262 | "BGP view name\n" |
| 9263 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9264 | "Neighbor to display information about\n" |
| 9265 | "Neighbor to display information about\n" |
| 9266 | "Display routes learned from neighbor\n") |
| 9267 | { |
| 9268 | struct peer *peer; |
| 9269 | |
| 9270 | if (argc == 2) |
| 9271 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9272 | else |
| 9273 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9274 | |
| 9275 | if (! peer) |
| 9276 | return CMD_WARNING; |
| 9277 | |
| 9278 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9279 | bgp_show_type_neighbor); |
| 9280 | } |
| 9281 | |
| 9282 | ALIAS (show_bgp_view_neighbor_routes, |
| 9283 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 9284 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9285 | SHOW_STR |
| 9286 | BGP_STR |
| 9287 | "BGP view\n" |
| 9288 | "BGP view name\n" |
| 9289 | "Address family\n" |
| 9290 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9291 | "Neighbor to display information about\n" |
| 9292 | "Neighbor to display information about\n" |
| 9293 | "Display routes learned from neighbor\n") |
| 9294 | |
| 9295 | DEFUN (show_bgp_view_neighbor_damp, |
| 9296 | show_bgp_view_neighbor_damp_cmd, |
| 9297 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9298 | SHOW_STR |
| 9299 | BGP_STR |
| 9300 | "BGP view\n" |
| 9301 | "BGP view name\n" |
| 9302 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9303 | "Neighbor to display information about\n" |
| 9304 | "Neighbor to display information about\n" |
| 9305 | "Display the dampened routes received from neighbor\n") |
| 9306 | { |
| 9307 | struct peer *peer; |
| 9308 | |
| 9309 | if (argc == 2) |
| 9310 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9311 | else |
| 9312 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9313 | |
| 9314 | if (! peer) |
| 9315 | return CMD_WARNING; |
| 9316 | |
| 9317 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9318 | bgp_show_type_damp_neighbor); |
| 9319 | } |
| 9320 | |
| 9321 | ALIAS (show_bgp_view_neighbor_damp, |
| 9322 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 9323 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9324 | SHOW_STR |
| 9325 | BGP_STR |
| 9326 | "BGP view\n" |
| 9327 | "BGP view name\n" |
| 9328 | "Address family\n" |
| 9329 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9330 | "Neighbor to display information about\n" |
| 9331 | "Neighbor to display information about\n" |
| 9332 | "Display the dampened routes received from neighbor\n") |
| 9333 | |
| 9334 | DEFUN (show_bgp_view_neighbor_flap, |
| 9335 | show_bgp_view_neighbor_flap_cmd, |
| 9336 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9337 | SHOW_STR |
| 9338 | BGP_STR |
| 9339 | "BGP view\n" |
| 9340 | "BGP view name\n" |
| 9341 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9342 | "Neighbor to display information about\n" |
| 9343 | "Neighbor to display information about\n" |
| 9344 | "Display flap statistics of the routes learned from neighbor\n") |
| 9345 | { |
| 9346 | struct peer *peer; |
| 9347 | |
| 9348 | if (argc == 2) |
| 9349 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9350 | else |
| 9351 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9352 | |
| 9353 | if (! peer) |
| 9354 | return CMD_WARNING; |
| 9355 | |
| 9356 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9357 | bgp_show_type_flap_neighbor); |
| 9358 | } |
| 9359 | |
| 9360 | ALIAS (show_bgp_view_neighbor_flap, |
| 9361 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 9362 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9363 | SHOW_STR |
| 9364 | BGP_STR |
| 9365 | "BGP view\n" |
| 9366 | "BGP view name\n" |
| 9367 | "Address family\n" |
| 9368 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9369 | "Neighbor to display information about\n" |
| 9370 | "Neighbor to display information about\n" |
| 9371 | "Display flap statistics of the routes learned from neighbor\n") |
| 9372 | |
| 9373 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9374 | show_bgp_neighbor_routes_cmd, |
| 9375 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9376 | SHOW_STR |
| 9377 | BGP_STR |
| 9378 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9379 | "Neighbor to display information about\n" |
| 9380 | "Neighbor to display information about\n" |
| 9381 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9382 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9383 | |
| 9384 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9385 | show_bgp_ipv6_neighbor_routes_cmd, |
| 9386 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9387 | SHOW_STR |
| 9388 | BGP_STR |
| 9389 | "Address family\n" |
| 9390 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9391 | "Neighbor to display information about\n" |
| 9392 | "Neighbor to display information about\n" |
| 9393 | "Display routes learned from neighbor\n") |
| 9394 | |
| 9395 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9396 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9397 | ipv6_bgp_neighbor_routes_cmd, |
| 9398 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9399 | SHOW_STR |
| 9400 | IPV6_STR |
| 9401 | BGP_STR |
| 9402 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9403 | "Neighbor to display information about\n" |
| 9404 | "Neighbor to display information about\n" |
| 9405 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9406 | |
| 9407 | /* old command */ |
| 9408 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 9409 | ipv6_mbgp_neighbor_routes_cmd, |
| 9410 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9411 | SHOW_STR |
| 9412 | IPV6_STR |
| 9413 | MBGP_STR |
| 9414 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9415 | "Neighbor to display information about\n" |
| 9416 | "Neighbor to display information about\n" |
| 9417 | "Display routes learned from neighbor\n") |
| 9418 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9419 | struct peer *peer; |
| 9420 | |
| 9421 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9422 | if (! peer) |
| 9423 | return CMD_WARNING; |
| 9424 | |
| 9425 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9426 | bgp_show_type_neighbor); |
| 9427 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9428 | |
| 9429 | ALIAS (show_bgp_view_neighbor_flap, |
| 9430 | show_bgp_neighbor_flap_cmd, |
| 9431 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9432 | SHOW_STR |
| 9433 | BGP_STR |
| 9434 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9435 | "Neighbor to display information about\n" |
| 9436 | "Neighbor to display information about\n" |
| 9437 | "Display flap statistics of the routes learned from neighbor\n") |
| 9438 | |
| 9439 | ALIAS (show_bgp_view_neighbor_flap, |
| 9440 | show_bgp_ipv6_neighbor_flap_cmd, |
| 9441 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9442 | SHOW_STR |
| 9443 | BGP_STR |
| 9444 | "Address family\n" |
| 9445 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9446 | "Neighbor to display information about\n" |
| 9447 | "Neighbor to display information about\n" |
| 9448 | "Display flap statistics of the routes learned from neighbor\n") |
| 9449 | |
| 9450 | ALIAS (show_bgp_view_neighbor_damp, |
| 9451 | show_bgp_neighbor_damp_cmd, |
| 9452 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9453 | SHOW_STR |
| 9454 | BGP_STR |
| 9455 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9456 | "Neighbor to display information about\n" |
| 9457 | "Neighbor to display information about\n" |
| 9458 | "Display the dampened routes received from neighbor\n") |
| 9459 | |
| 9460 | ALIAS (show_bgp_view_neighbor_damp, |
| 9461 | show_bgp_ipv6_neighbor_damp_cmd, |
| 9462 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9463 | SHOW_STR |
| 9464 | BGP_STR |
| 9465 | "Address family\n" |
| 9466 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9467 | "Neighbor to display information about\n" |
| 9468 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 9469 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9470 | |
| 9471 | DEFUN (show_bgp_view_rsclient, |
| 9472 | show_bgp_view_rsclient_cmd, |
| 9473 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9474 | SHOW_STR |
| 9475 | BGP_STR |
| 9476 | "BGP view\n" |
| 9477 | "BGP view name\n" |
| 9478 | "Information about Route Server Client\n" |
| 9479 | NEIGHBOR_ADDR_STR) |
| 9480 | { |
| 9481 | struct bgp_table *table; |
| 9482 | struct peer *peer; |
| 9483 | |
| 9484 | if (argc == 2) |
| 9485 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9486 | else |
| 9487 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9488 | |
| 9489 | if (! peer) |
| 9490 | return CMD_WARNING; |
| 9491 | |
| 9492 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9493 | { |
| 9494 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9495 | VTY_NEWLINE); |
| 9496 | return CMD_WARNING; |
| 9497 | } |
| 9498 | |
| 9499 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9500 | PEER_FLAG_RSERVER_CLIENT)) |
| 9501 | { |
| 9502 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9503 | VTY_NEWLINE); |
| 9504 | return CMD_WARNING; |
| 9505 | } |
| 9506 | |
| 9507 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 9508 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9509 | 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] | 9510 | } |
| 9511 | |
| 9512 | ALIAS (show_bgp_view_rsclient, |
| 9513 | show_bgp_rsclient_cmd, |
| 9514 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9515 | SHOW_STR |
| 9516 | BGP_STR |
| 9517 | "Information about Route Server Client\n" |
| 9518 | NEIGHBOR_ADDR_STR) |
| 9519 | |
| 9520 | DEFUN (show_bgp_view_rsclient_route, |
| 9521 | show_bgp_view_rsclient_route_cmd, |
| 9522 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9523 | SHOW_STR |
| 9524 | BGP_STR |
| 9525 | "BGP view\n" |
| 9526 | "BGP view name\n" |
| 9527 | "Information about Route Server Client\n" |
| 9528 | NEIGHBOR_ADDR_STR |
| 9529 | "Network in the BGP routing table to display\n") |
| 9530 | { |
| 9531 | struct bgp *bgp; |
| 9532 | struct peer *peer; |
| 9533 | |
| 9534 | /* BGP structure lookup. */ |
| 9535 | if (argc == 3) |
| 9536 | { |
| 9537 | bgp = bgp_lookup_by_name (argv[0]); |
| 9538 | if (bgp == NULL) |
| 9539 | { |
| 9540 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9541 | return CMD_WARNING; |
| 9542 | } |
| 9543 | } |
| 9544 | else |
| 9545 | { |
| 9546 | bgp = bgp_get_default (); |
| 9547 | if (bgp == NULL) |
| 9548 | { |
| 9549 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9550 | return CMD_WARNING; |
| 9551 | } |
| 9552 | } |
| 9553 | |
| 9554 | if (argc == 3) |
| 9555 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9556 | else |
| 9557 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9558 | |
| 9559 | if (! peer) |
| 9560 | return CMD_WARNING; |
| 9561 | |
| 9562 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9563 | { |
| 9564 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9565 | VTY_NEWLINE); |
| 9566 | return CMD_WARNING; |
| 9567 | } |
| 9568 | |
| 9569 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9570 | PEER_FLAG_RSERVER_CLIENT)) |
| 9571 | { |
| 9572 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9573 | VTY_NEWLINE); |
| 9574 | return CMD_WARNING; |
| 9575 | } |
| 9576 | |
| 9577 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9578 | (argc == 3) ? argv[2] : argv[1], |
| 9579 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 9580 | } |
| 9581 | |
| 9582 | ALIAS (show_bgp_view_rsclient_route, |
| 9583 | show_bgp_rsclient_route_cmd, |
| 9584 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9585 | SHOW_STR |
| 9586 | BGP_STR |
| 9587 | "Information about Route Server Client\n" |
| 9588 | NEIGHBOR_ADDR_STR |
| 9589 | "Network in the BGP routing table to display\n") |
| 9590 | |
| 9591 | DEFUN (show_bgp_view_rsclient_prefix, |
| 9592 | show_bgp_view_rsclient_prefix_cmd, |
| 9593 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9594 | SHOW_STR |
| 9595 | BGP_STR |
| 9596 | "BGP view\n" |
| 9597 | "BGP view name\n" |
| 9598 | "Information about Route Server Client\n" |
| 9599 | NEIGHBOR_ADDR_STR |
| 9600 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9601 | { |
| 9602 | struct bgp *bgp; |
| 9603 | struct peer *peer; |
| 9604 | |
| 9605 | /* BGP structure lookup. */ |
| 9606 | if (argc == 3) |
| 9607 | { |
| 9608 | bgp = bgp_lookup_by_name (argv[0]); |
| 9609 | if (bgp == NULL) |
| 9610 | { |
| 9611 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9612 | return CMD_WARNING; |
| 9613 | } |
| 9614 | } |
| 9615 | else |
| 9616 | { |
| 9617 | bgp = bgp_get_default (); |
| 9618 | if (bgp == NULL) |
| 9619 | { |
| 9620 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9621 | return CMD_WARNING; |
| 9622 | } |
| 9623 | } |
| 9624 | |
| 9625 | if (argc == 3) |
| 9626 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9627 | else |
| 9628 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9629 | |
| 9630 | if (! peer) |
| 9631 | return CMD_WARNING; |
| 9632 | |
| 9633 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9634 | { |
| 9635 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9636 | VTY_NEWLINE); |
| 9637 | return CMD_WARNING; |
| 9638 | } |
| 9639 | |
| 9640 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9641 | PEER_FLAG_RSERVER_CLIENT)) |
| 9642 | { |
| 9643 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9644 | VTY_NEWLINE); |
| 9645 | return CMD_WARNING; |
| 9646 | } |
| 9647 | |
| 9648 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9649 | (argc == 3) ? argv[2] : argv[1], |
| 9650 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 9651 | } |
| 9652 | |
| 9653 | ALIAS (show_bgp_view_rsclient_prefix, |
| 9654 | show_bgp_rsclient_prefix_cmd, |
| 9655 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9656 | SHOW_STR |
| 9657 | BGP_STR |
| 9658 | "Information about Route Server Client\n" |
| 9659 | NEIGHBOR_ADDR_STR |
| 9660 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9661 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9662 | #endif /* HAVE_IPV6 */ |
| 9663 | |
| 9664 | struct bgp_table *bgp_distance_table; |
| 9665 | |
| 9666 | struct bgp_distance |
| 9667 | { |
| 9668 | /* Distance value for the IP source prefix. */ |
| 9669 | u_char distance; |
| 9670 | |
| 9671 | /* Name of the access-list to be matched. */ |
| 9672 | char *access_list; |
| 9673 | }; |
| 9674 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9675 | static struct bgp_distance * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9676 | bgp_distance_new () |
| 9677 | { |
| 9678 | struct bgp_distance *new; |
| 9679 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 9680 | memset (new, 0, sizeof (struct bgp_distance)); |
| 9681 | return new; |
| 9682 | } |
| 9683 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9684 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9685 | bgp_distance_free (struct bgp_distance *bdistance) |
| 9686 | { |
| 9687 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 9688 | } |
| 9689 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9690 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9691 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 9692 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9693 | { |
| 9694 | int ret; |
| 9695 | struct prefix_ipv4 p; |
| 9696 | u_char distance; |
| 9697 | struct bgp_node *rn; |
| 9698 | struct bgp_distance *bdistance; |
| 9699 | |
| 9700 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9701 | if (ret == 0) |
| 9702 | { |
| 9703 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9704 | return CMD_WARNING; |
| 9705 | } |
| 9706 | |
| 9707 | distance = atoi (distance_str); |
| 9708 | |
| 9709 | /* Get BGP distance node. */ |
| 9710 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 9711 | if (rn->info) |
| 9712 | { |
| 9713 | bdistance = rn->info; |
| 9714 | bgp_unlock_node (rn); |
| 9715 | } |
| 9716 | else |
| 9717 | { |
| 9718 | bdistance = bgp_distance_new (); |
| 9719 | rn->info = bdistance; |
| 9720 | } |
| 9721 | |
| 9722 | /* Set distance value. */ |
| 9723 | bdistance->distance = distance; |
| 9724 | |
| 9725 | /* Reset access-list configuration. */ |
| 9726 | if (bdistance->access_list) |
| 9727 | { |
| 9728 | free (bdistance->access_list); |
| 9729 | bdistance->access_list = NULL; |
| 9730 | } |
| 9731 | if (access_list_str) |
| 9732 | bdistance->access_list = strdup (access_list_str); |
| 9733 | |
| 9734 | return CMD_SUCCESS; |
| 9735 | } |
| 9736 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9737 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9738 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 9739 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9740 | { |
| 9741 | int ret; |
| 9742 | struct prefix_ipv4 p; |
| 9743 | u_char distance; |
| 9744 | struct bgp_node *rn; |
| 9745 | struct bgp_distance *bdistance; |
| 9746 | |
| 9747 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9748 | if (ret == 0) |
| 9749 | { |
| 9750 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9751 | return CMD_WARNING; |
| 9752 | } |
| 9753 | |
| 9754 | distance = atoi (distance_str); |
| 9755 | |
| 9756 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 9757 | if (! rn) |
| 9758 | { |
| 9759 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 9760 | return CMD_WARNING; |
| 9761 | } |
| 9762 | |
| 9763 | bdistance = rn->info; |
| 9764 | |
| 9765 | if (bdistance->access_list) |
| 9766 | free (bdistance->access_list); |
| 9767 | bgp_distance_free (bdistance); |
| 9768 | |
| 9769 | rn->info = NULL; |
| 9770 | bgp_unlock_node (rn); |
| 9771 | bgp_unlock_node (rn); |
| 9772 | |
| 9773 | return CMD_SUCCESS; |
| 9774 | } |
| 9775 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9776 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9777 | bgp_distance_reset () |
| 9778 | { |
| 9779 | struct bgp_node *rn; |
| 9780 | struct bgp_distance *bdistance; |
| 9781 | |
| 9782 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 9783 | if ((bdistance = rn->info) != NULL) |
| 9784 | { |
| 9785 | if (bdistance->access_list) |
| 9786 | free (bdistance->access_list); |
| 9787 | bgp_distance_free (bdistance); |
| 9788 | rn->info = NULL; |
| 9789 | bgp_unlock_node (rn); |
| 9790 | } |
| 9791 | } |
| 9792 | |
| 9793 | /* Apply BGP information to distance method. */ |
| 9794 | u_char |
| 9795 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 9796 | { |
| 9797 | struct bgp_node *rn; |
| 9798 | struct prefix_ipv4 q; |
| 9799 | struct peer *peer; |
| 9800 | struct bgp_distance *bdistance; |
| 9801 | struct access_list *alist; |
| 9802 | struct bgp_static *bgp_static; |
| 9803 | |
| 9804 | if (! bgp) |
| 9805 | return 0; |
| 9806 | |
| 9807 | if (p->family != AF_INET) |
| 9808 | return 0; |
| 9809 | |
| 9810 | peer = rinfo->peer; |
| 9811 | |
| 9812 | if (peer->su.sa.sa_family != AF_INET) |
| 9813 | return 0; |
| 9814 | |
| 9815 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 9816 | q.family = AF_INET; |
| 9817 | q.prefix = peer->su.sin.sin_addr; |
| 9818 | q.prefixlen = IPV4_MAX_BITLEN; |
| 9819 | |
| 9820 | /* Check source address. */ |
| 9821 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 9822 | if (rn) |
| 9823 | { |
| 9824 | bdistance = rn->info; |
| 9825 | bgp_unlock_node (rn); |
| 9826 | |
| 9827 | if (bdistance->access_list) |
| 9828 | { |
| 9829 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 9830 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 9831 | return bdistance->distance; |
| 9832 | } |
| 9833 | else |
| 9834 | return bdistance->distance; |
| 9835 | } |
| 9836 | |
| 9837 | /* Backdoor check. */ |
| 9838 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 9839 | if (rn) |
| 9840 | { |
| 9841 | bgp_static = rn->info; |
| 9842 | bgp_unlock_node (rn); |
| 9843 | |
| 9844 | if (bgp_static->backdoor) |
| 9845 | { |
| 9846 | if (bgp->distance_local) |
| 9847 | return bgp->distance_local; |
| 9848 | else |
| 9849 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9850 | } |
| 9851 | } |
| 9852 | |
| 9853 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 9854 | { |
| 9855 | if (bgp->distance_ebgp) |
| 9856 | return bgp->distance_ebgp; |
| 9857 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 9858 | } |
| 9859 | else |
| 9860 | { |
| 9861 | if (bgp->distance_ibgp) |
| 9862 | return bgp->distance_ibgp; |
| 9863 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9864 | } |
| 9865 | } |
| 9866 | |
| 9867 | DEFUN (bgp_distance, |
| 9868 | bgp_distance_cmd, |
| 9869 | "distance bgp <1-255> <1-255> <1-255>", |
| 9870 | "Define an administrative distance\n" |
| 9871 | "BGP distance\n" |
| 9872 | "Distance for routes external to the AS\n" |
| 9873 | "Distance for routes internal to the AS\n" |
| 9874 | "Distance for local routes\n") |
| 9875 | { |
| 9876 | struct bgp *bgp; |
| 9877 | |
| 9878 | bgp = vty->index; |
| 9879 | |
| 9880 | bgp->distance_ebgp = atoi (argv[0]); |
| 9881 | bgp->distance_ibgp = atoi (argv[1]); |
| 9882 | bgp->distance_local = atoi (argv[2]); |
| 9883 | return CMD_SUCCESS; |
| 9884 | } |
| 9885 | |
| 9886 | DEFUN (no_bgp_distance, |
| 9887 | no_bgp_distance_cmd, |
| 9888 | "no distance bgp <1-255> <1-255> <1-255>", |
| 9889 | NO_STR |
| 9890 | "Define an administrative distance\n" |
| 9891 | "BGP distance\n" |
| 9892 | "Distance for routes external to the AS\n" |
| 9893 | "Distance for routes internal to the AS\n" |
| 9894 | "Distance for local routes\n") |
| 9895 | { |
| 9896 | struct bgp *bgp; |
| 9897 | |
| 9898 | bgp = vty->index; |
| 9899 | |
| 9900 | bgp->distance_ebgp= 0; |
| 9901 | bgp->distance_ibgp = 0; |
| 9902 | bgp->distance_local = 0; |
| 9903 | return CMD_SUCCESS; |
| 9904 | } |
| 9905 | |
| 9906 | ALIAS (no_bgp_distance, |
| 9907 | no_bgp_distance2_cmd, |
| 9908 | "no distance bgp", |
| 9909 | NO_STR |
| 9910 | "Define an administrative distance\n" |
| 9911 | "BGP distance\n") |
| 9912 | |
| 9913 | DEFUN (bgp_distance_source, |
| 9914 | bgp_distance_source_cmd, |
| 9915 | "distance <1-255> A.B.C.D/M", |
| 9916 | "Define an administrative distance\n" |
| 9917 | "Administrative distance\n" |
| 9918 | "IP source prefix\n") |
| 9919 | { |
| 9920 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 9921 | return CMD_SUCCESS; |
| 9922 | } |
| 9923 | |
| 9924 | DEFUN (no_bgp_distance_source, |
| 9925 | no_bgp_distance_source_cmd, |
| 9926 | "no distance <1-255> A.B.C.D/M", |
| 9927 | NO_STR |
| 9928 | "Define an administrative distance\n" |
| 9929 | "Administrative distance\n" |
| 9930 | "IP source prefix\n") |
| 9931 | { |
| 9932 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 9933 | return CMD_SUCCESS; |
| 9934 | } |
| 9935 | |
| 9936 | DEFUN (bgp_distance_source_access_list, |
| 9937 | bgp_distance_source_access_list_cmd, |
| 9938 | "distance <1-255> A.B.C.D/M WORD", |
| 9939 | "Define an administrative distance\n" |
| 9940 | "Administrative distance\n" |
| 9941 | "IP source prefix\n" |
| 9942 | "Access list name\n") |
| 9943 | { |
| 9944 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 9945 | return CMD_SUCCESS; |
| 9946 | } |
| 9947 | |
| 9948 | DEFUN (no_bgp_distance_source_access_list, |
| 9949 | no_bgp_distance_source_access_list_cmd, |
| 9950 | "no distance <1-255> A.B.C.D/M WORD", |
| 9951 | NO_STR |
| 9952 | "Define an administrative distance\n" |
| 9953 | "Administrative distance\n" |
| 9954 | "IP source prefix\n" |
| 9955 | "Access list name\n") |
| 9956 | { |
| 9957 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 9958 | return CMD_SUCCESS; |
| 9959 | } |
| 9960 | |
| 9961 | DEFUN (bgp_damp_set, |
| 9962 | bgp_damp_set_cmd, |
| 9963 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 9964 | "BGP Specific commands\n" |
| 9965 | "Enable route-flap dampening\n" |
| 9966 | "Half-life time for the penalty\n" |
| 9967 | "Value to start reusing a route\n" |
| 9968 | "Value to start suppressing a route\n" |
| 9969 | "Maximum duration to suppress a stable route\n") |
| 9970 | { |
| 9971 | struct bgp *bgp; |
| 9972 | int half = DEFAULT_HALF_LIFE * 60; |
| 9973 | int reuse = DEFAULT_REUSE; |
| 9974 | int suppress = DEFAULT_SUPPRESS; |
| 9975 | int max = 4 * half; |
| 9976 | |
| 9977 | if (argc == 4) |
| 9978 | { |
| 9979 | half = atoi (argv[0]) * 60; |
| 9980 | reuse = atoi (argv[1]); |
| 9981 | suppress = atoi (argv[2]); |
| 9982 | max = atoi (argv[3]) * 60; |
| 9983 | } |
| 9984 | else if (argc == 1) |
| 9985 | { |
| 9986 | half = atoi (argv[0]) * 60; |
| 9987 | max = 4 * half; |
| 9988 | } |
| 9989 | |
| 9990 | bgp = vty->index; |
| 9991 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 9992 | half, reuse, suppress, max); |
| 9993 | } |
| 9994 | |
| 9995 | ALIAS (bgp_damp_set, |
| 9996 | bgp_damp_set2_cmd, |
| 9997 | "bgp dampening <1-45>", |
| 9998 | "BGP Specific commands\n" |
| 9999 | "Enable route-flap dampening\n" |
| 10000 | "Half-life time for the penalty\n") |
| 10001 | |
| 10002 | ALIAS (bgp_damp_set, |
| 10003 | bgp_damp_set3_cmd, |
| 10004 | "bgp dampening", |
| 10005 | "BGP Specific commands\n" |
| 10006 | "Enable route-flap dampening\n") |
| 10007 | |
| 10008 | DEFUN (bgp_damp_unset, |
| 10009 | bgp_damp_unset_cmd, |
| 10010 | "no bgp dampening", |
| 10011 | NO_STR |
| 10012 | "BGP Specific commands\n" |
| 10013 | "Enable route-flap dampening\n") |
| 10014 | { |
| 10015 | struct bgp *bgp; |
| 10016 | |
| 10017 | bgp = vty->index; |
| 10018 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 10019 | } |
| 10020 | |
| 10021 | ALIAS (bgp_damp_unset, |
| 10022 | bgp_damp_unset2_cmd, |
| 10023 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 10024 | NO_STR |
| 10025 | "BGP Specific commands\n" |
| 10026 | "Enable route-flap dampening\n" |
| 10027 | "Half-life time for the penalty\n" |
| 10028 | "Value to start reusing a route\n" |
| 10029 | "Value to start suppressing a route\n" |
| 10030 | "Maximum duration to suppress a stable route\n") |
| 10031 | |
| 10032 | DEFUN (show_ip_bgp_dampened_paths, |
| 10033 | show_ip_bgp_dampened_paths_cmd, |
| 10034 | "show ip bgp dampened-paths", |
| 10035 | SHOW_STR |
| 10036 | IP_STR |
| 10037 | BGP_STR |
| 10038 | "Display paths suppressed due to dampening\n") |
| 10039 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10040 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 10041 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10042 | } |
| 10043 | |
| 10044 | DEFUN (show_ip_bgp_flap_statistics, |
| 10045 | show_ip_bgp_flap_statistics_cmd, |
| 10046 | "show ip bgp flap-statistics", |
| 10047 | SHOW_STR |
| 10048 | IP_STR |
| 10049 | BGP_STR |
| 10050 | "Display flap statistics of routes\n") |
| 10051 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10052 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 10053 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10054 | } |
| 10055 | |
| 10056 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10057 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10058 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 10059 | const char *ip_str, afi_t afi, safi_t safi, |
| 10060 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10061 | { |
| 10062 | int ret; |
| 10063 | struct prefix match; |
| 10064 | struct bgp_node *rn; |
| 10065 | struct bgp_node *rm; |
| 10066 | struct bgp_info *ri; |
| 10067 | struct bgp_info *ri_temp; |
| 10068 | struct bgp *bgp; |
| 10069 | struct bgp_table *table; |
| 10070 | |
| 10071 | /* BGP structure lookup. */ |
| 10072 | if (view_name) |
| 10073 | { |
| 10074 | bgp = bgp_lookup_by_name (view_name); |
| 10075 | if (bgp == NULL) |
| 10076 | { |
| 10077 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 10078 | return CMD_WARNING; |
| 10079 | } |
| 10080 | } |
| 10081 | else |
| 10082 | { |
| 10083 | bgp = bgp_get_default (); |
| 10084 | if (bgp == NULL) |
| 10085 | { |
| 10086 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 10087 | return CMD_WARNING; |
| 10088 | } |
| 10089 | } |
| 10090 | |
| 10091 | /* Check IP address argument. */ |
| 10092 | ret = str2prefix (ip_str, &match); |
| 10093 | if (! ret) |
| 10094 | { |
| 10095 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 10096 | return CMD_WARNING; |
| 10097 | } |
| 10098 | |
| 10099 | match.family = afi2family (afi); |
| 10100 | |
| 10101 | if (safi == SAFI_MPLS_VPN) |
| 10102 | { |
| 10103 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 10104 | { |
| 10105 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 10106 | continue; |
| 10107 | |
| 10108 | if ((table = rn->info) != NULL) |
| 10109 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 10110 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 10111 | { |
| 10112 | ri = rm->info; |
| 10113 | while (ri) |
| 10114 | { |
| 10115 | if (ri->damp_info) |
| 10116 | { |
| 10117 | ri_temp = ri->next; |
| 10118 | bgp_damp_info_free (ri->damp_info, 1); |
| 10119 | ri = ri_temp; |
| 10120 | } |
| 10121 | else |
| 10122 | ri = ri->next; |
| 10123 | } |
| 10124 | } |
| 10125 | } |
| 10126 | } |
| 10127 | else |
| 10128 | { |
| 10129 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 10130 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 10131 | { |
| 10132 | ri = rn->info; |
| 10133 | while (ri) |
| 10134 | { |
| 10135 | if (ri->damp_info) |
| 10136 | { |
| 10137 | ri_temp = ri->next; |
| 10138 | bgp_damp_info_free (ri->damp_info, 1); |
| 10139 | ri = ri_temp; |
| 10140 | } |
| 10141 | else |
| 10142 | ri = ri->next; |
| 10143 | } |
| 10144 | } |
| 10145 | } |
| 10146 | |
| 10147 | return CMD_SUCCESS; |
| 10148 | } |
| 10149 | |
| 10150 | DEFUN (clear_ip_bgp_dampening, |
| 10151 | clear_ip_bgp_dampening_cmd, |
| 10152 | "clear ip bgp dampening", |
| 10153 | CLEAR_STR |
| 10154 | IP_STR |
| 10155 | BGP_STR |
| 10156 | "Clear route flap dampening information\n") |
| 10157 | { |
| 10158 | bgp_damp_info_clean (); |
| 10159 | return CMD_SUCCESS; |
| 10160 | } |
| 10161 | |
| 10162 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 10163 | clear_ip_bgp_dampening_prefix_cmd, |
| 10164 | "clear ip bgp dampening A.B.C.D/M", |
| 10165 | CLEAR_STR |
| 10166 | IP_STR |
| 10167 | BGP_STR |
| 10168 | "Clear route flap dampening information\n" |
| 10169 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10170 | { |
| 10171 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 10172 | SAFI_UNICAST, NULL, 1); |
| 10173 | } |
| 10174 | |
| 10175 | DEFUN (clear_ip_bgp_dampening_address, |
| 10176 | clear_ip_bgp_dampening_address_cmd, |
| 10177 | "clear ip bgp dampening A.B.C.D", |
| 10178 | CLEAR_STR |
| 10179 | IP_STR |
| 10180 | BGP_STR |
| 10181 | "Clear route flap dampening information\n" |
| 10182 | "Network to clear damping information\n") |
| 10183 | { |
| 10184 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 10185 | SAFI_UNICAST, NULL, 0); |
| 10186 | } |
| 10187 | |
| 10188 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 10189 | clear_ip_bgp_dampening_address_mask_cmd, |
| 10190 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 10191 | CLEAR_STR |
| 10192 | IP_STR |
| 10193 | BGP_STR |
| 10194 | "Clear route flap dampening information\n" |
| 10195 | "Network to clear damping information\n" |
| 10196 | "Network mask\n") |
| 10197 | { |
| 10198 | int ret; |
| 10199 | char prefix_str[BUFSIZ]; |
| 10200 | |
| 10201 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 10202 | if (! ret) |
| 10203 | { |
| 10204 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 10205 | return CMD_WARNING; |
| 10206 | } |
| 10207 | |
| 10208 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 10209 | SAFI_UNICAST, NULL, 0); |
| 10210 | } |
| 10211 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10212 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10213 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 10214 | afi_t afi, safi_t safi, int *write) |
| 10215 | { |
| 10216 | struct bgp_node *prn; |
| 10217 | struct bgp_node *rn; |
| 10218 | struct bgp_table *table; |
| 10219 | struct prefix *p; |
| 10220 | struct prefix_rd *prd; |
| 10221 | struct bgp_static *bgp_static; |
| 10222 | u_int32_t label; |
| 10223 | char buf[SU_ADDRSTRLEN]; |
| 10224 | char rdbuf[RD_ADDRSTRLEN]; |
| 10225 | |
| 10226 | /* Network configuration. */ |
| 10227 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 10228 | if ((table = prn->info) != NULL) |
| 10229 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 10230 | if ((bgp_static = rn->info) != NULL) |
| 10231 | { |
| 10232 | p = &rn->p; |
| 10233 | prd = (struct prefix_rd *) &prn->p; |
| 10234 | |
| 10235 | /* "address-family" display. */ |
| 10236 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10237 | |
| 10238 | /* "network" configuration display. */ |
| 10239 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 10240 | label = decode_label (bgp_static->tag); |
| 10241 | |
| 10242 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 10243 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10244 | p->prefixlen, |
| 10245 | rdbuf, label); |
| 10246 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10247 | } |
| 10248 | return 0; |
| 10249 | } |
| 10250 | |
| 10251 | /* Configuration of static route announcement and aggregate |
| 10252 | information. */ |
| 10253 | int |
| 10254 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 10255 | afi_t afi, safi_t safi, int *write) |
| 10256 | { |
| 10257 | struct bgp_node *rn; |
| 10258 | struct prefix *p; |
| 10259 | struct bgp_static *bgp_static; |
| 10260 | struct bgp_aggregate *bgp_aggregate; |
| 10261 | char buf[SU_ADDRSTRLEN]; |
| 10262 | |
| 10263 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 10264 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 10265 | |
| 10266 | /* Network configuration. */ |
| 10267 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10268 | if ((bgp_static = rn->info) != NULL) |
| 10269 | { |
| 10270 | p = &rn->p; |
| 10271 | |
| 10272 | /* "address-family" display. */ |
| 10273 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10274 | |
| 10275 | /* "network" configuration display. */ |
| 10276 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10277 | { |
| 10278 | u_int32_t destination; |
| 10279 | struct in_addr netmask; |
| 10280 | |
| 10281 | destination = ntohl (p->u.prefix4.s_addr); |
| 10282 | masklen2ip (p->prefixlen, &netmask); |
| 10283 | vty_out (vty, " network %s", |
| 10284 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 10285 | |
| 10286 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 10287 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 10288 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 10289 | || p->u.prefix4.s_addr == 0) |
| 10290 | { |
| 10291 | /* Natural mask is not display. */ |
| 10292 | } |
| 10293 | else |
| 10294 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 10295 | } |
| 10296 | else |
| 10297 | { |
| 10298 | vty_out (vty, " network %s/%d", |
| 10299 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10300 | p->prefixlen); |
| 10301 | } |
| 10302 | |
| 10303 | if (bgp_static->rmap.name) |
| 10304 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 10305 | else if (bgp_static->backdoor) |
| 10306 | vty_out (vty, " backdoor"); |
| 10307 | |
| 10308 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10309 | } |
| 10310 | |
| 10311 | /* Aggregate-address configuration. */ |
| 10312 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10313 | if ((bgp_aggregate = rn->info) != NULL) |
| 10314 | { |
| 10315 | p = &rn->p; |
| 10316 | |
| 10317 | /* "address-family" display. */ |
| 10318 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10319 | |
| 10320 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10321 | { |
| 10322 | struct in_addr netmask; |
| 10323 | |
| 10324 | masklen2ip (p->prefixlen, &netmask); |
| 10325 | vty_out (vty, " aggregate-address %s %s", |
| 10326 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10327 | inet_ntoa (netmask)); |
| 10328 | } |
| 10329 | else |
| 10330 | { |
| 10331 | vty_out (vty, " aggregate-address %s/%d", |
| 10332 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10333 | p->prefixlen); |
| 10334 | } |
| 10335 | |
| 10336 | if (bgp_aggregate->as_set) |
| 10337 | vty_out (vty, " as-set"); |
| 10338 | |
| 10339 | if (bgp_aggregate->summary_only) |
| 10340 | vty_out (vty, " summary-only"); |
| 10341 | |
| 10342 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10343 | } |
| 10344 | |
| 10345 | return 0; |
| 10346 | } |
| 10347 | |
| 10348 | int |
| 10349 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 10350 | { |
| 10351 | struct bgp_node *rn; |
| 10352 | struct bgp_distance *bdistance; |
| 10353 | |
| 10354 | /* Distance configuration. */ |
| 10355 | if (bgp->distance_ebgp |
| 10356 | && bgp->distance_ibgp |
| 10357 | && bgp->distance_local |
| 10358 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 10359 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 10360 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 10361 | vty_out (vty, " distance bgp %d %d %d%s", |
| 10362 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 10363 | VTY_NEWLINE); |
| 10364 | |
| 10365 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 10366 | if ((bdistance = rn->info) != NULL) |
| 10367 | { |
| 10368 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 10369 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 10370 | bdistance->access_list ? bdistance->access_list : "", |
| 10371 | VTY_NEWLINE); |
| 10372 | } |
| 10373 | |
| 10374 | return 0; |
| 10375 | } |
| 10376 | |
| 10377 | /* Allocate routing table structure and install commands. */ |
| 10378 | void |
| 10379 | bgp_route_init () |
| 10380 | { |
| 10381 | /* Init BGP distance table. */ |
| 10382 | bgp_distance_table = bgp_table_init (); |
| 10383 | |
| 10384 | /* IPv4 BGP commands. */ |
| 10385 | install_element (BGP_NODE, &bgp_network_cmd); |
| 10386 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 10387 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 10388 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 10389 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 10390 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10391 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 10392 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 10393 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 10394 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 10395 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 10396 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 10397 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 10398 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10399 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10400 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 10401 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 10402 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 10403 | |
| 10404 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 10405 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 10406 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 10407 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10408 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 10409 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 10410 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 10411 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10412 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 10413 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10414 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 10415 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 10416 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 10417 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10418 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10419 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 10420 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10421 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10422 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10423 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10424 | |
| 10425 | /* IPv4 unicast configuration. */ |
| 10426 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 10427 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 10428 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 10429 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 10430 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 10431 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10432 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 10433 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 10434 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 10435 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 10436 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10437 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10438 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 10439 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 10440 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 10441 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10442 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 10443 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 10444 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 10445 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10446 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 10447 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10448 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 10449 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 10450 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 10451 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10452 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10453 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 10454 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10455 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10456 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10457 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10458 | |
| 10459 | /* IPv4 multicast configuration. */ |
| 10460 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 10461 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 10462 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 10463 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 10464 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 10465 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10466 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 10467 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 10468 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 10469 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 10470 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10471 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10472 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 10473 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 10474 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 10475 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10476 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 10477 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 10478 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 10479 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10480 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 10481 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10482 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 10483 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 10484 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 10485 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10486 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10487 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 10488 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10489 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10490 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10491 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10492 | |
| 10493 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 10494 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 10495 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 10496 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10497 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10498 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10499 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 10500 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10501 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10502 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10503 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 10504 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 10505 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10506 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 10507 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10508 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10509 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10510 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 10511 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10512 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 10513 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10514 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10515 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10516 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 10517 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10518 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 10519 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 10520 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 10521 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 10522 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10523 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10524 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10525 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10526 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 10527 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10528 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10529 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10530 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10531 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10532 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10533 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10534 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 10535 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10536 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10537 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10538 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10539 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10540 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10541 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10542 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10543 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10544 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10545 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10546 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10547 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10548 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10549 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10550 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 10551 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10552 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10553 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10554 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10555 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10556 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10557 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10558 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10559 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10560 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 10561 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10562 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10563 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10564 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10565 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10566 | |
| 10567 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 10568 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 10569 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 10570 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10571 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10572 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10573 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 10574 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10575 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10576 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10577 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 10578 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 10579 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10580 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 10581 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10582 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10583 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10584 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 10585 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10586 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 10587 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10588 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10589 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10590 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 10591 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10592 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 10593 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 10594 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 10595 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 10596 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10597 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10598 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10599 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10600 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 10601 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10602 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10603 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10604 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10605 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10606 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10607 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10608 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 10609 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10610 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10611 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10612 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10613 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10614 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10615 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10616 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10617 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10618 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10619 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10620 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10621 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10622 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10623 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10624 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 10625 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10626 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10627 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10628 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10629 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10630 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10631 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10632 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10633 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10634 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 10635 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10636 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10637 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10638 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10639 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10640 | |
| 10641 | /* BGP dampening clear commands */ |
| 10642 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 10643 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 10644 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 10645 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 10646 | |
| 10647 | #ifdef HAVE_IPV6 |
| 10648 | /* New config IPv6 BGP commands. */ |
| 10649 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 10650 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 10651 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 10652 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 10653 | |
| 10654 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 10655 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 10656 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 10657 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 10658 | |
| 10659 | /* Old config IPv6 BGP commands. */ |
| 10660 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 10661 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 10662 | |
| 10663 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 10664 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 10665 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 10666 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 10667 | |
| 10668 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 10669 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 10670 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 10671 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 10672 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 10673 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10674 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 10675 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10676 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 10677 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10678 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 10679 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10680 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 10681 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10682 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 10683 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10684 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 10685 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 10686 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 10687 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 10688 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 10689 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 10690 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 10691 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 10692 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 10693 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10694 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 10695 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10696 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 10697 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10698 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 10699 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10700 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 10701 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10702 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 10703 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10704 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 10705 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10706 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10707 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10708 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10709 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10710 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 10711 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10712 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10713 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10714 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 10715 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10716 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 10717 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10718 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 10719 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 10720 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10721 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 10722 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 10723 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 10724 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10725 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 10726 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10727 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10728 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10729 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10730 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10731 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10732 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10733 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10734 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10735 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10736 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10737 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10738 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10739 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 10740 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10741 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10742 | |
| 10743 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 10744 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 10745 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 10746 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 10747 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 10748 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10749 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 10750 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10751 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 10752 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10753 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 10754 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10755 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 10756 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10757 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 10758 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10759 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 10760 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 10761 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 10762 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 10763 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 10764 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 10765 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 10766 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 10767 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 10768 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10769 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 10770 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10771 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 10772 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10773 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 10774 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10775 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 10776 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10777 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 10778 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10779 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 10780 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10781 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10782 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10783 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10784 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10785 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 10786 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10787 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10788 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10789 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 10790 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10791 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 10792 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10793 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 10794 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 10795 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10796 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 10797 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 10798 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 10799 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10800 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 10801 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10802 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10803 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10804 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10805 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10806 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10807 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10808 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10809 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10810 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10811 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10812 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10813 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10814 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 10815 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10816 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10817 | |
| 10818 | /* old command */ |
| 10819 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 10820 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 10821 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10822 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10823 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10824 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10825 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10826 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 10827 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 10828 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 10829 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 10830 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10831 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10832 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10833 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10834 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10835 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10836 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10837 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 10838 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 10839 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10840 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10841 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10842 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10843 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10844 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 10845 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10846 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10847 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10848 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10849 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10850 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10851 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10852 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10853 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10854 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10855 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10856 | /* old command */ |
| 10857 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 10858 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 10859 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10860 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10861 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10862 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10863 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10864 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 10865 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 10866 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 10867 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 10868 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10869 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10870 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10871 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10872 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10873 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10874 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10875 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 10876 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 10877 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10878 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10879 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10880 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10881 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10882 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 10883 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10884 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10885 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10886 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10887 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10888 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10889 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10890 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10891 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10892 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 10893 | |
| 10894 | /* old command */ |
| 10895 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10896 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10897 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10898 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10899 | |
| 10900 | /* old command */ |
| 10901 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10902 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10903 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10904 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10905 | |
| 10906 | /* old command */ |
| 10907 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10908 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10909 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10910 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10911 | #endif /* HAVE_IPV6 */ |
| 10912 | |
| 10913 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 10914 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 10915 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 10916 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 10917 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 10918 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 10919 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 10920 | |
| 10921 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 10922 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 10923 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 10924 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 10925 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 10926 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 10927 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 10928 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 10929 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 10930 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 10931 | } |