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 Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 68 | |
| 69 | assert (table); |
| 70 | if (!table) |
| 71 | return NULL; |
| 72 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 73 | if (safi == SAFI_MPLS_VPN) |
| 74 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 75 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | |
| 77 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 78 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 79 | else |
| 80 | bgp_unlock_node (prn); |
| 81 | table = prn->info; |
| 82 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 83 | |
| 84 | rn = bgp_node_get (table, p); |
| 85 | |
| 86 | if (safi == SAFI_MPLS_VPN) |
| 87 | rn->prn = prn; |
| 88 | |
| 89 | return rn; |
| 90 | } |
| 91 | |
| 92 | /* Allocate new bgp info structure. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 93 | static struct bgp_info * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 94 | bgp_info_new () |
| 95 | { |
| 96 | struct bgp_info *new; |
| 97 | |
| 98 | new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 99 | memset (new, 0, sizeof (struct bgp_info)); |
| 100 | |
| 101 | return new; |
| 102 | } |
| 103 | |
| 104 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 105 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 106 | bgp_info_free (struct bgp_info *binfo) |
| 107 | { |
| 108 | if (binfo->attr) |
| 109 | bgp_attr_unintern (binfo->attr); |
| 110 | |
| 111 | if (binfo->damp_info) |
| 112 | bgp_damp_info_free (binfo->damp_info, 0); |
| 113 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 114 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 115 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 116 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 117 | } |
| 118 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 119 | struct bgp_info * |
| 120 | bgp_info_lock (struct bgp_info *binfo) |
| 121 | { |
| 122 | binfo->lock++; |
| 123 | return binfo; |
| 124 | } |
| 125 | |
| 126 | struct bgp_info * |
| 127 | bgp_info_unlock (struct bgp_info *binfo) |
| 128 | { |
| 129 | assert (binfo && binfo->lock > 0); |
| 130 | binfo->lock--; |
| 131 | |
| 132 | if (binfo->lock == 0) |
| 133 | { |
| 134 | #if 0 |
| 135 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 136 | zlog_backtrace (LOG_DEBUG); |
| 137 | #endif |
| 138 | bgp_info_free (binfo); |
| 139 | return NULL; |
| 140 | } |
| 141 | |
| 142 | #if 0 |
| 143 | if (binfo->lock == 1) |
| 144 | { |
| 145 | zlog_debug ("%s: unlocked to 1", __func__); |
| 146 | zlog_backtrace (LOG_DEBUG); |
| 147 | } |
| 148 | #endif |
| 149 | |
| 150 | return binfo; |
| 151 | } |
| 152 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 153 | void |
| 154 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 155 | { |
| 156 | struct bgp_info *top; |
| 157 | |
| 158 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 159 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 160 | ri->next = rn->info; |
| 161 | ri->prev = NULL; |
| 162 | if (top) |
| 163 | top->prev = ri; |
| 164 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 165 | |
| 166 | bgp_info_lock (ri); |
| 167 | bgp_lock_node (rn); |
| 168 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 169 | } |
| 170 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 171 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 172 | completion callback *only* */ |
| 173 | static void |
| 174 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 175 | { |
| 176 | if (ri->next) |
| 177 | ri->next->prev = ri->prev; |
| 178 | if (ri->prev) |
| 179 | ri->prev->next = ri->next; |
| 180 | else |
| 181 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 182 | |
| 183 | bgp_info_unlock (ri); |
| 184 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 185 | } |
| 186 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 187 | void |
| 188 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 189 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 190 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
| 191 | /* set of previous already took care of pcount */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 192 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 193 | } |
| 194 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 195 | /* Adjust pcount as required */ |
| 196 | static void |
| 197 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) |
| 198 | { |
| 199 | /* Ignore 'pcount' for RS-client tables */ |
| 200 | if (rn->table->type != BGP_TABLE_MAIN |
| 201 | || ri->peer == ri->peer->bgp->peer_self) |
| 202 | return; |
| 203 | |
| 204 | if (BGP_INFO_HOLDDOWN (ri) |
| 205 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 206 | { |
| 207 | |
| 208 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 209 | |
| 210 | /* slight hack, but more robust against errors. */ |
| 211 | if (ri->peer->pcount[rn->table->afi][rn->table->safi]) |
| 212 | ri->peer->pcount[rn->table->afi][rn->table->safi]--; |
| 213 | else |
| 214 | { |
| 215 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 216 | __func__, ri->peer->host); |
| 217 | zlog_backtrace (LOG_WARNING); |
| 218 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 219 | } |
| 220 | } |
| 221 | else if (!BGP_INFO_HOLDDOWN (ri) |
| 222 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 223 | { |
| 224 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 225 | ri->peer->pcount[rn->table->afi][rn->table->safi]++; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | |
| 230 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 231 | * This is here primarily to keep prefix-count in check. |
| 232 | */ |
| 233 | void |
| 234 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 235 | { |
| 236 | SET_FLAG (ri->flags, flag); |
| 237 | |
| 238 | /* early bath if we know it's not a flag that changes useability state */ |
| 239 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 240 | return; |
| 241 | |
| 242 | bgp_pcount_adjust (rn, ri); |
| 243 | } |
| 244 | |
| 245 | void |
| 246 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 247 | { |
| 248 | UNSET_FLAG (ri->flags, flag); |
| 249 | |
| 250 | /* early bath if we know it's not a flag that changes useability state */ |
| 251 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 252 | return; |
| 253 | |
| 254 | bgp_pcount_adjust (rn, ri); |
| 255 | } |
| 256 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 257 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 258 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 259 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 260 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 261 | { |
| 262 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 263 | return attr->med; |
| 264 | else |
| 265 | { |
| 266 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 267 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 268 | else |
| 269 | return 0; |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | /* Compare two bgp route entity. br is preferable then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 274 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 275 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) |
| 276 | { |
| 277 | u_int32_t new_pref; |
| 278 | u_int32_t exist_pref; |
| 279 | u_int32_t new_med; |
| 280 | u_int32_t exist_med; |
| 281 | struct in_addr new_id; |
| 282 | struct in_addr exist_id; |
| 283 | int new_cluster; |
| 284 | int exist_cluster; |
| 285 | int internal_as_route = 0; |
| 286 | int confed_as_route = 0; |
| 287 | int ret; |
| 288 | |
| 289 | /* 0. Null check. */ |
| 290 | if (new == NULL) |
| 291 | return 0; |
| 292 | if (exist == NULL) |
| 293 | return 1; |
| 294 | |
| 295 | /* 1. Weight check. */ |
| 296 | if (new->attr->weight > exist->attr->weight) |
| 297 | return 1; |
| 298 | if (new->attr->weight < exist->attr->weight) |
| 299 | return 0; |
| 300 | |
| 301 | /* 2. Local preference check. */ |
| 302 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 303 | new_pref = new->attr->local_pref; |
| 304 | else |
| 305 | new_pref = bgp->default_local_pref; |
| 306 | |
| 307 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 308 | exist_pref = exist->attr->local_pref; |
| 309 | else |
| 310 | exist_pref = bgp->default_local_pref; |
| 311 | |
| 312 | if (new_pref > exist_pref) |
| 313 | return 1; |
| 314 | if (new_pref < exist_pref) |
| 315 | return 0; |
| 316 | |
| 317 | /* 3. Local route check. */ |
| 318 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 319 | return 1; |
| 320 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 321 | return 0; |
| 322 | |
| 323 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 324 | return 1; |
| 325 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 326 | return 0; |
| 327 | |
| 328 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 329 | return 1; |
| 330 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 331 | return 0; |
| 332 | |
| 333 | /* 4. AS path length check. */ |
| 334 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 335 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 336 | int exist_hops = aspath_count_hops (exist->attr->aspath); |
| 337 | int exist_confeds = aspath_count_confeds (exist->attr->aspath); |
| 338 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 339 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 340 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 341 | int aspath_hops; |
| 342 | |
| 343 | aspath_hops = aspath_count_hops (new->attr->aspath); |
| 344 | aspath_hops += aspath_count_confeds (new->attr->aspath); |
| 345 | |
| 346 | if ( aspath_hops < (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 347 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 348 | if ( aspath_hops > (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 349 | return 0; |
| 350 | } |
| 351 | else |
| 352 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 353 | int newhops = aspath_count_hops (new->attr->aspath); |
| 354 | |
| 355 | if (newhops < exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 356 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 357 | if (newhops > exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 358 | return 0; |
| 359 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | /* 5. Origin check. */ |
| 363 | if (new->attr->origin < exist->attr->origin) |
| 364 | return 1; |
| 365 | if (new->attr->origin > exist->attr->origin) |
| 366 | return 0; |
| 367 | |
| 368 | /* 6. MED check. */ |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 369 | internal_as_route = (aspath_count_hops (new->attr->aspath) == 0 |
| 370 | && aspath_count_hops (exist->attr->aspath) == 0); |
| 371 | confed_as_route = (aspath_count_confeds (new->attr->aspath) > 0 |
| 372 | && aspath_count_confeds (exist->attr->aspath) > 0 |
| 373 | && aspath_count_hops (new->attr->aspath) == 0 |
| 374 | && aspath_count_hops (exist->attr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 375 | |
| 376 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 377 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 378 | && confed_as_route) |
| 379 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 380 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 381 | || internal_as_route) |
| 382 | { |
| 383 | new_med = bgp_med_value (new->attr, bgp); |
| 384 | exist_med = bgp_med_value (exist->attr, bgp); |
| 385 | |
| 386 | if (new_med < exist_med) |
| 387 | return 1; |
| 388 | if (new_med > exist_med) |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | /* 7. Peer type check. */ |
| 393 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 394 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 395 | return 1; |
| 396 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 397 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 398 | return 1; |
| 399 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 400 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 401 | return 0; |
| 402 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 403 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 404 | return 0; |
| 405 | |
| 406 | /* 8. IGP metric check. */ |
| 407 | if (new->igpmetric < exist->igpmetric) |
| 408 | return 1; |
| 409 | if (new->igpmetric > exist->igpmetric) |
| 410 | return 0; |
| 411 | |
| 412 | /* 9. Maximum path check. */ |
| 413 | |
| 414 | /* 10. If both paths are external, prefer the path that was received |
| 415 | first (the oldest one). This step minimizes route-flap, since a |
| 416 | newer path won't displace an older one, even if it was the |
| 417 | preferred route based on the additional decision criteria below. */ |
| 418 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 419 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 420 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 421 | { |
| 422 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 423 | return 1; |
| 424 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | /* 11. Rourter-ID comparision. */ |
| 429 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 430 | new_id.s_addr = new->attr->originator_id.s_addr; |
| 431 | else |
| 432 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 433 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 434 | exist_id.s_addr = exist->attr->originator_id.s_addr; |
| 435 | else |
| 436 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 437 | |
| 438 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 439 | return 1; |
| 440 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 441 | return 0; |
| 442 | |
| 443 | /* 12. Cluster length comparision. */ |
| 444 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 445 | new_cluster = new->attr->cluster->length; |
| 446 | else |
| 447 | new_cluster = 0; |
| 448 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 449 | exist_cluster = exist->attr->cluster->length; |
| 450 | else |
| 451 | exist_cluster = 0; |
| 452 | |
| 453 | if (new_cluster < exist_cluster) |
| 454 | return 1; |
| 455 | if (new_cluster > exist_cluster) |
| 456 | return 0; |
| 457 | |
| 458 | /* 13. Neighbor address comparision. */ |
| 459 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 460 | |
| 461 | if (ret == 1) |
| 462 | return 0; |
| 463 | if (ret == -1) |
| 464 | return 1; |
| 465 | |
| 466 | return 1; |
| 467 | } |
| 468 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 469 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 470 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 471 | afi_t afi, safi_t safi) |
| 472 | { |
| 473 | struct bgp_filter *filter; |
| 474 | |
| 475 | filter = &peer->filter[afi][safi]; |
| 476 | |
| 477 | if (DISTRIBUTE_IN_NAME (filter)) |
| 478 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 479 | return FILTER_DENY; |
| 480 | |
| 481 | if (PREFIX_LIST_IN_NAME (filter)) |
| 482 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 483 | return FILTER_DENY; |
| 484 | |
| 485 | if (FILTER_LIST_IN_NAME (filter)) |
| 486 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 487 | return FILTER_DENY; |
| 488 | |
| 489 | return FILTER_PERMIT; |
| 490 | } |
| 491 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 492 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 493 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 494 | afi_t afi, safi_t safi) |
| 495 | { |
| 496 | struct bgp_filter *filter; |
| 497 | |
| 498 | filter = &peer->filter[afi][safi]; |
| 499 | |
| 500 | if (DISTRIBUTE_OUT_NAME (filter)) |
| 501 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 502 | return FILTER_DENY; |
| 503 | |
| 504 | if (PREFIX_LIST_OUT_NAME (filter)) |
| 505 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 506 | return FILTER_DENY; |
| 507 | |
| 508 | if (FILTER_LIST_OUT_NAME (filter)) |
| 509 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 510 | return FILTER_DENY; |
| 511 | |
| 512 | return FILTER_PERMIT; |
| 513 | } |
| 514 | |
| 515 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 516 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 517 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 518 | { |
| 519 | if (attr->community) |
| 520 | { |
| 521 | /* NO_ADVERTISE check. */ |
| 522 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 523 | return 1; |
| 524 | |
| 525 | /* NO_EXPORT check. */ |
| 526 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 527 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 528 | return 1; |
| 529 | |
| 530 | /* NO_EXPORT_SUBCONFED check. */ |
| 531 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 532 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 533 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 534 | return 1; |
| 535 | } |
| 536 | return 0; |
| 537 | } |
| 538 | |
| 539 | /* Route reflection loop check. */ |
| 540 | static int |
| 541 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 542 | { |
| 543 | struct in_addr cluster_id; |
| 544 | |
| 545 | if (attr->cluster) |
| 546 | { |
| 547 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 548 | cluster_id = peer->bgp->cluster_id; |
| 549 | else |
| 550 | cluster_id = peer->bgp->router_id; |
| 551 | |
| 552 | if (cluster_loop_check (attr->cluster, cluster_id)) |
| 553 | return 1; |
| 554 | } |
| 555 | return 0; |
| 556 | } |
| 557 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 558 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 559 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 560 | afi_t afi, safi_t safi) |
| 561 | { |
| 562 | struct bgp_filter *filter; |
| 563 | struct bgp_info info; |
| 564 | route_map_result_t ret; |
| 565 | |
| 566 | filter = &peer->filter[afi][safi]; |
| 567 | |
| 568 | /* Apply default weight value. */ |
| 569 | attr->weight = peer->weight; |
| 570 | |
| 571 | /* Route map apply. */ |
| 572 | if (ROUTE_MAP_IN_NAME (filter)) |
| 573 | { |
| 574 | /* Duplicate current value to new strucutre for modification. */ |
| 575 | info.peer = peer; |
| 576 | info.attr = attr; |
| 577 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 578 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 579 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 580 | /* Apply BGP route map to the attribute. */ |
| 581 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 582 | |
| 583 | peer->rmap_type = 0; |
| 584 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 585 | if (ret == RMAP_DENYMATCH) |
| 586 | { |
| 587 | /* Free newly generated AS path and community by route-map. */ |
| 588 | bgp_attr_flush (attr); |
| 589 | return RMAP_DENY; |
| 590 | } |
| 591 | } |
| 592 | return RMAP_PERMIT; |
| 593 | } |
| 594 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 595 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 596 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 597 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 598 | { |
| 599 | struct bgp_filter *filter; |
| 600 | struct bgp_info info; |
| 601 | route_map_result_t ret; |
| 602 | |
| 603 | filter = &peer->filter[afi][safi]; |
| 604 | |
| 605 | /* Route map apply. */ |
| 606 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 607 | { |
| 608 | /* Duplicate current value to new strucutre for modification. */ |
| 609 | info.peer = rsclient; |
| 610 | info.attr = attr; |
| 611 | |
| 612 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 613 | |
| 614 | /* Apply BGP route map to the attribute. */ |
| 615 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 616 | |
| 617 | rsclient->rmap_type = 0; |
| 618 | |
| 619 | if (ret == RMAP_DENYMATCH) |
| 620 | { |
| 621 | /* Free newly generated AS path and community by route-map. */ |
| 622 | bgp_attr_flush (attr); |
| 623 | return RMAP_DENY; |
| 624 | } |
| 625 | } |
| 626 | return RMAP_PERMIT; |
| 627 | } |
| 628 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 629 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 630 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 631 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 632 | { |
| 633 | struct bgp_filter *filter; |
| 634 | struct bgp_info info; |
| 635 | route_map_result_t ret; |
| 636 | |
| 637 | filter = &rsclient->filter[afi][safi]; |
| 638 | |
| 639 | /* Apply default weight value. */ |
| 640 | attr->weight = peer->weight; |
| 641 | |
| 642 | /* Route map apply. */ |
| 643 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 644 | { |
| 645 | /* Duplicate current value to new strucutre for modification. */ |
| 646 | info.peer = peer; |
| 647 | info.attr = attr; |
| 648 | |
| 649 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 650 | |
| 651 | /* Apply BGP route map to the attribute. */ |
| 652 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 653 | |
| 654 | peer->rmap_type = 0; |
| 655 | |
| 656 | if (ret == RMAP_DENYMATCH) |
| 657 | { |
| 658 | /* Free newly generated AS path and community by route-map. */ |
| 659 | bgp_attr_flush (attr); |
| 660 | return RMAP_DENY; |
| 661 | } |
| 662 | } |
| 663 | return RMAP_PERMIT; |
| 664 | } |
| 665 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 666 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 667 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 668 | struct attr *attr, afi_t afi, safi_t safi) |
| 669 | { |
| 670 | int ret; |
| 671 | char buf[SU_ADDRSTRLEN]; |
| 672 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 673 | struct peer *from; |
| 674 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 675 | int transparent; |
| 676 | int reflect; |
| 677 | |
| 678 | from = ri->peer; |
| 679 | filter = &peer->filter[afi][safi]; |
| 680 | bgp = peer->bgp; |
| 681 | |
| 682 | #ifdef DISABLE_BGP_ANNOUNCE |
| 683 | return 0; |
| 684 | #endif |
| 685 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 686 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 687 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 688 | return 0; |
| 689 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | /* Do not send back route to sender. */ |
| 691 | if (from == peer) |
| 692 | return 0; |
| 693 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 694 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 695 | if (p->family == AF_INET |
| 696 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 697 | return 0; |
| 698 | #ifdef HAVE_IPV6 |
| 699 | if (p->family == AF_INET6 |
| 700 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 701 | return 0; |
| 702 | #endif |
| 703 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 704 | /* Aggregate-address suppress check. */ |
| 705 | if (ri->suppress) |
| 706 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 707 | return 0; |
| 708 | |
| 709 | /* Default route check. */ |
| 710 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 711 | { |
| 712 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 713 | return 0; |
| 714 | #ifdef HAVE_IPV6 |
| 715 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 716 | return 0; |
| 717 | #endif /* HAVE_IPV6 */ |
| 718 | } |
| 719 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 720 | /* Transparency check. */ |
| 721 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 722 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 723 | transparent = 1; |
| 724 | else |
| 725 | transparent = 0; |
| 726 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 727 | /* If community is not disabled check the no-export and local. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 728 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 729 | return 0; |
| 730 | |
| 731 | /* If the attribute has originator-id and it is same as remote |
| 732 | peer's id. */ |
| 733 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 734 | { |
| 735 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id)) |
| 736 | { |
| 737 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 738 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 739 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 740 | peer->host, |
| 741 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 742 | p->prefixlen); |
| 743 | return 0; |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | /* ORF prefix-list filter check */ |
| 748 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 749 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 750 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 751 | if (peer->orf_plist[afi][safi]) |
| 752 | { |
| 753 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 754 | return 0; |
| 755 | } |
| 756 | |
| 757 | /* Output filter check. */ |
| 758 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) |
| 759 | { |
| 760 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 761 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 762 | "%s [Update:SEND] %s/%d is filtered", |
| 763 | peer->host, |
| 764 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 765 | p->prefixlen); |
| 766 | return 0; |
| 767 | } |
| 768 | |
| 769 | #ifdef BGP_SEND_ASPATH_CHECK |
| 770 | /* AS path loop check. */ |
| 771 | if (aspath_loop_check (ri->attr->aspath, peer->as)) |
| 772 | { |
| 773 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 774 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 775 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 776 | peer->host, peer->as); |
| 777 | return 0; |
| 778 | } |
| 779 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 780 | |
| 781 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 782 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 783 | { |
| 784 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) |
| 785 | { |
| 786 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 787 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 788 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 789 | peer->host, |
| 790 | bgp->confed_id); |
| 791 | return 0; |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | /* Route-Reflect check. */ |
| 796 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 797 | reflect = 1; |
| 798 | else |
| 799 | reflect = 0; |
| 800 | |
| 801 | /* IBGP reflection check. */ |
| 802 | if (reflect) |
| 803 | { |
| 804 | /* A route from a Client peer. */ |
| 805 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 806 | { |
| 807 | /* Reflect to all the Non-Client peers and also to the |
| 808 | Client peers other than the originator. Originator check |
| 809 | is already done. So there is noting to do. */ |
| 810 | /* no bgp client-to-client reflection check. */ |
| 811 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 812 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 813 | return 0; |
| 814 | } |
| 815 | else |
| 816 | { |
| 817 | /* A route from a Non-client peer. Reflect to all other |
| 818 | clients. */ |
| 819 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 820 | return 0; |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | /* For modify attribute, copy it to temporary structure. */ |
| 825 | *attr = *ri->attr; |
| 826 | |
| 827 | /* If local-preference is not set. */ |
| 828 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 829 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 830 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 831 | { |
| 832 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 833 | attr->local_pref = bgp->default_local_pref; |
| 834 | } |
| 835 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 837 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 838 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 839 | { |
| 840 | if (ri->peer != bgp->peer_self && ! transparent |
| 841 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 842 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 843 | } |
| 844 | |
| 845 | /* next-hop-set */ |
| 846 | if (transparent || reflect |
| 847 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 848 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 849 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 850 | || (p->family == AF_INET6 && |
| 851 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 852 | #endif /* HAVE_IPV6 */ |
| 853 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | { |
| 855 | /* NEXT-HOP Unchanged. */ |
| 856 | } |
| 857 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 858 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 859 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 860 | || (p->family == AF_INET6 && |
| 861 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 862 | #endif /* HAVE_IPV6 */ |
| 863 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 864 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 865 | { |
| 866 | /* Set IPv4 nexthop. */ |
| 867 | if (p->family == AF_INET) |
| 868 | { |
| 869 | if (safi == SAFI_MPLS_VPN) |
| 870 | memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 871 | else |
| 872 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 873 | } |
| 874 | #ifdef HAVE_IPV6 |
| 875 | /* Set IPv6 nexthop. */ |
| 876 | if (p->family == AF_INET6) |
| 877 | { |
| 878 | /* IPv6 global nexthop must be included. */ |
| 879 | memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global, |
| 880 | IPV6_MAX_BYTELEN); |
| 881 | attr->mp_nexthop_len = 16; |
| 882 | } |
| 883 | #endif /* HAVE_IPV6 */ |
| 884 | } |
| 885 | |
| 886 | #ifdef HAVE_IPV6 |
| 887 | if (p->family == AF_INET6) |
| 888 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 889 | /* Left nexthop_local unchanged if so configured. */ |
| 890 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 891 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 892 | { |
| 893 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 894 | attr->mp_nexthop_len=32; |
| 895 | else |
| 896 | attr->mp_nexthop_len=16; |
| 897 | } |
| 898 | |
| 899 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 900 | else |
| 901 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 902 | /* Link-local address should not be transit to different peer. */ |
| 903 | attr->mp_nexthop_len = 16; |
| 904 | |
| 905 | /* Set link-local address for shared network peer. */ |
| 906 | if (peer->shared_network |
| 907 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 908 | { |
| 909 | memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local, |
| 910 | IPV6_MAX_BYTELEN); |
| 911 | attr->mp_nexthop_len = 32; |
| 912 | } |
| 913 | |
| 914 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 915 | address.*/ |
| 916 | if (reflect) |
| 917 | attr->mp_nexthop_len = 16; |
| 918 | |
| 919 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 920 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
| 921 | attr->mp_nexthop_len = 16; |
| 922 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 923 | |
| 924 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 925 | #endif /* HAVE_IPV6 */ |
| 926 | |
| 927 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 928 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 929 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 930 | && aspath_private_as_check (attr->aspath)) |
| 931 | attr->aspath = aspath_empty_get (); |
| 932 | |
| 933 | /* Route map & unsuppress-map apply. */ |
| 934 | if (ROUTE_MAP_OUT_NAME (filter) |
| 935 | || ri->suppress) |
| 936 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 937 | struct bgp_info info; |
| 938 | struct attr dummy_attr; |
| 939 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 940 | info.peer = peer; |
| 941 | info.attr = attr; |
| 942 | |
| 943 | /* The route reflector is not allowed to modify the attributes |
| 944 | of the reflected IBGP routes. */ |
| 945 | if (peer_sort (from) == BGP_PEER_IBGP |
| 946 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 947 | { |
| 948 | dummy_attr = *attr; |
| 949 | info.attr = &dummy_attr; |
| 950 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 951 | |
| 952 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 953 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 954 | if (ri->suppress) |
| 955 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 956 | else |
| 957 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 958 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 959 | peer->rmap_type = 0; |
| 960 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 961 | if (ret == RMAP_DENYMATCH) |
| 962 | { |
| 963 | bgp_attr_flush (attr); |
| 964 | return 0; |
| 965 | } |
| 966 | } |
| 967 | return 1; |
| 968 | } |
| 969 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 970 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 971 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 972 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 973 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 974 | int ret; |
| 975 | char buf[SU_ADDRSTRLEN]; |
| 976 | struct bgp_filter *filter; |
| 977 | struct bgp_info info; |
| 978 | struct peer *from; |
| 979 | struct bgp *bgp; |
| 980 | |
| 981 | from = ri->peer; |
| 982 | filter = &rsclient->filter[afi][safi]; |
| 983 | bgp = rsclient->bgp; |
| 984 | |
| 985 | #ifdef DISABLE_BGP_ANNOUNCE |
| 986 | return 0; |
| 987 | #endif |
| 988 | |
| 989 | /* Do not send back route to sender. */ |
| 990 | if (from == rsclient) |
| 991 | return 0; |
| 992 | |
| 993 | /* Aggregate-address suppress check. */ |
| 994 | if (ri->suppress) |
| 995 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 996 | return 0; |
| 997 | |
| 998 | /* Default route check. */ |
| 999 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1000 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1001 | { |
| 1002 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1003 | return 0; |
| 1004 | #ifdef HAVE_IPV6 |
| 1005 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1006 | return 0; |
| 1007 | #endif /* HAVE_IPV6 */ |
| 1008 | } |
| 1009 | |
| 1010 | /* If the attribute has originator-id and it is same as remote |
| 1011 | peer's id. */ |
| 1012 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 1013 | { |
| 1014 | if (IPV4_ADDR_SAME (&rsclient->remote_id, &ri->attr->originator_id)) |
| 1015 | { |
| 1016 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1017 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1018 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1019 | rsclient->host, |
| 1020 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1021 | p->prefixlen); |
| 1022 | return 0; |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | /* ORF prefix-list filter check */ |
| 1027 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1028 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1029 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1030 | if (rsclient->orf_plist[afi][safi]) |
| 1031 | { |
| 1032 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1033 | return 0; |
| 1034 | } |
| 1035 | |
| 1036 | /* Output filter check. */ |
| 1037 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) |
| 1038 | { |
| 1039 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1040 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1041 | "%s [Update:SEND] %s/%d is filtered", |
| 1042 | rsclient->host, |
| 1043 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1044 | p->prefixlen); |
| 1045 | return 0; |
| 1046 | } |
| 1047 | |
| 1048 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1049 | /* AS path loop check. */ |
| 1050 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) |
| 1051 | { |
| 1052 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1053 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1054 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 1055 | rsclient->host, rsclient->as); |
| 1056 | return 0; |
| 1057 | } |
| 1058 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1059 | |
| 1060 | /* For modify attribute, copy it to temporary structure. */ |
| 1061 | *attr = *ri->attr; |
| 1062 | |
| 1063 | /* next-hop-set */ |
| 1064 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1065 | #ifdef HAVE_IPV6 |
| 1066 | || (p->family == AF_INET6 && |
| 1067 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
| 1068 | #endif /* HAVE_IPV6 */ |
| 1069 | ) |
| 1070 | { |
| 1071 | /* Set IPv4 nexthop. */ |
| 1072 | if (p->family == AF_INET) |
| 1073 | { |
| 1074 | if (safi == SAFI_MPLS_VPN) |
| 1075 | memcpy (&attr->mp_nexthop_global_in, &rsclient->nexthop.v4, |
| 1076 | IPV4_MAX_BYTELEN); |
| 1077 | else |
| 1078 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1079 | } |
| 1080 | #ifdef HAVE_IPV6 |
| 1081 | /* Set IPv6 nexthop. */ |
| 1082 | if (p->family == AF_INET6) |
| 1083 | { |
| 1084 | /* IPv6 global nexthop must be included. */ |
| 1085 | memcpy (&attr->mp_nexthop_global, &rsclient->nexthop.v6_global, |
| 1086 | |
| 1087 | IPV6_MAX_BYTELEN); |
| 1088 | attr->mp_nexthop_len = 16; |
| 1089 | } |
| 1090 | #endif /* HAVE_IPV6 */ |
| 1091 | } |
| 1092 | |
| 1093 | #ifdef HAVE_IPV6 |
| 1094 | if (p->family == AF_INET6) |
| 1095 | { |
| 1096 | /* Left nexthop_local unchanged if so configured. */ |
| 1097 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1098 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1099 | { |
| 1100 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 1101 | attr->mp_nexthop_len=32; |
| 1102 | else |
| 1103 | attr->mp_nexthop_len=16; |
| 1104 | } |
| 1105 | |
| 1106 | /* Default nexthop_local treatment for RS-Clients */ |
| 1107 | else |
| 1108 | { |
| 1109 | /* Announcer and RS-Client are both in the same network */ |
| 1110 | if (rsclient->shared_network && from->shared_network && |
| 1111 | (rsclient->ifindex == from->ifindex)) |
| 1112 | { |
| 1113 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 1114 | attr->mp_nexthop_len=32; |
| 1115 | else |
| 1116 | attr->mp_nexthop_len=16; |
| 1117 | } |
| 1118 | |
| 1119 | /* Set link-local address for shared network peer. */ |
| 1120 | else if (rsclient->shared_network |
| 1121 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1122 | { |
| 1123 | memcpy (&attr->mp_nexthop_local, &rsclient->nexthop.v6_local, |
| 1124 | IPV6_MAX_BYTELEN); |
| 1125 | attr->mp_nexthop_len = 32; |
| 1126 | } |
| 1127 | |
| 1128 | else |
| 1129 | attr->mp_nexthop_len = 16; |
| 1130 | } |
| 1131 | |
| 1132 | } |
| 1133 | #endif /* HAVE_IPV6 */ |
| 1134 | |
| 1135 | |
| 1136 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1137 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 1138 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1139 | && aspath_private_as_check (attr->aspath)) |
| 1140 | attr->aspath = aspath_empty_get (); |
| 1141 | |
| 1142 | /* Route map & unsuppress-map apply. */ |
| 1143 | if (ROUTE_MAP_OUT_NAME (filter) || ri->suppress) |
| 1144 | { |
| 1145 | info.peer = rsclient; |
| 1146 | info.attr = attr; |
| 1147 | |
| 1148 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1149 | |
| 1150 | if (ri->suppress) |
| 1151 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1152 | else |
| 1153 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1154 | |
| 1155 | rsclient->rmap_type = 0; |
| 1156 | |
| 1157 | if (ret == RMAP_DENYMATCH) |
| 1158 | { |
| 1159 | bgp_attr_flush (attr); |
| 1160 | return 0; |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | return 1; |
| 1165 | } |
| 1166 | |
| 1167 | struct bgp_info_pair |
| 1168 | { |
| 1169 | struct bgp_info *old; |
| 1170 | struct bgp_info *new; |
| 1171 | }; |
| 1172 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1173 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1174 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
| 1175 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1176 | struct bgp_info *new_select; |
| 1177 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1178 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1179 | struct bgp_info *ri1; |
| 1180 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1181 | struct bgp_info *nextri = NULL; |
| 1182 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1183 | /* bgp deterministic-med */ |
| 1184 | new_select = NULL; |
| 1185 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1186 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1187 | { |
| 1188 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1189 | continue; |
| 1190 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1191 | continue; |
| 1192 | |
| 1193 | new_select = ri1; |
| 1194 | if (ri1->next) |
| 1195 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1196 | { |
| 1197 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1198 | continue; |
| 1199 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1200 | continue; |
| 1201 | |
| 1202 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1203 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1204 | ri2->attr->aspath)) |
| 1205 | { |
| 1206 | if (bgp_info_cmp (bgp, ri2, new_select)) |
| 1207 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1208 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1209 | new_select = ri2; |
| 1210 | } |
| 1211 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1212 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1213 | } |
| 1214 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1215 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1216 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1217 | } |
| 1218 | |
| 1219 | /* Check old selected route and new selected route. */ |
| 1220 | old_select = NULL; |
| 1221 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1222 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1223 | { |
| 1224 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1225 | old_select = ri; |
| 1226 | |
| 1227 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1228 | { |
| 1229 | /* reap REMOVED routes, if needs be |
| 1230 | * selected route must stay for a while longer though |
| 1231 | */ |
| 1232 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1233 | && (ri != old_select)) |
| 1234 | bgp_info_reap (rn, ri); |
| 1235 | |
| 1236 | continue; |
| 1237 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1238 | |
| 1239 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1240 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1241 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1242 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1243 | continue; |
| 1244 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1245 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1246 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | |
| 1248 | if (bgp_info_cmp (bgp, ri, new_select)) |
| 1249 | new_select = ri; |
| 1250 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1251 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1252 | result->old = old_select; |
| 1253 | result->new = new_select; |
| 1254 | |
| 1255 | return; |
| 1256 | } |
| 1257 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1258 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1259 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
| 1260 | struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi) |
| 1261 | { |
| 1262 | struct prefix *p; |
| 1263 | |
| 1264 | p = &rn->p; |
| 1265 | |
| 1266 | /* Announce route to Established peer. */ |
| 1267 | if (peer->status != Established) |
| 1268 | return 0; |
| 1269 | |
| 1270 | /* Address family configuration check. */ |
| 1271 | if (! peer->afc_nego[afi][safi]) |
| 1272 | return 0; |
| 1273 | |
| 1274 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 1275 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1276 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1277 | return 0; |
| 1278 | |
| 1279 | switch (rn->table->type) |
| 1280 | { |
| 1281 | case BGP_TABLE_MAIN: |
| 1282 | /* Announcement to peer->conf. If the route is filtered, |
| 1283 | withdraw it. */ |
| 1284 | if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi)) |
| 1285 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1286 | else |
| 1287 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1288 | break; |
| 1289 | case BGP_TABLE_RSCLIENT: |
| 1290 | /* Announcement to peer->conf. If the route is filtered, |
| 1291 | withdraw it. */ |
| 1292 | if (selected && bgp_announce_check_rsclient |
| 1293 | (selected, peer, p, attr, afi, safi)) |
| 1294 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1295 | else |
| 1296 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1297 | break; |
| 1298 | } |
| 1299 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1300 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1301 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1302 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1303 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1304 | struct bgp *bgp; |
| 1305 | struct bgp_node *rn; |
| 1306 | afi_t afi; |
| 1307 | safi_t safi; |
| 1308 | }; |
| 1309 | |
| 1310 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1311 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1312 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1313 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1314 | struct bgp *bgp = pq->bgp; |
| 1315 | struct bgp_node *rn = pq->rn; |
| 1316 | afi_t afi = pq->afi; |
| 1317 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1318 | struct bgp_info *new_select; |
| 1319 | struct bgp_info *old_select; |
| 1320 | struct bgp_info_pair old_and_new; |
| 1321 | struct attr attr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1322 | struct listnode *node, *nnode; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1323 | struct peer *rsclient = rn->table->owner; |
| 1324 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1325 | /* Best path selection. */ |
| 1326 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1327 | new_select = old_and_new.new; |
| 1328 | old_select = old_and_new.old; |
| 1329 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1330 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1331 | { |
| 1332 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1333 | { |
| 1334 | /* Nothing to do. */ |
| 1335 | if (old_select && old_select == new_select) |
| 1336 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1337 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1338 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1339 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1340 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1341 | if (new_select) |
| 1342 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1343 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1344 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1345 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1346 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1347 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, |
| 1348 | afi, safi); |
| 1349 | } |
| 1350 | } |
| 1351 | else |
| 1352 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1353 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1354 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1355 | if (new_select) |
| 1356 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1357 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1358 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1359 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1360 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1361 | &attr, afi, safi); |
| 1362 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1363 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1364 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1365 | bgp_info_reap (rn, old_select); |
| 1366 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1367 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1368 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1369 | } |
| 1370 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1371 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1372 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1373 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1374 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1375 | struct bgp *bgp = pq->bgp; |
| 1376 | struct bgp_node *rn = pq->rn; |
| 1377 | afi_t afi = pq->afi; |
| 1378 | safi_t safi = pq->safi; |
| 1379 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1380 | struct bgp_info *new_select; |
| 1381 | struct bgp_info *old_select; |
| 1382 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1383 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1384 | struct peer *peer; |
| 1385 | struct attr attr; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1386 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1387 | /* Best path selection. */ |
| 1388 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1389 | old_select = old_and_new.old; |
| 1390 | new_select = old_and_new.new; |
| 1391 | |
| 1392 | /* Nothing to do. */ |
| 1393 | if (old_select && old_select == new_select) |
| 1394 | { |
| 1395 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1396 | { |
| 1397 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) |
| 1398 | bgp_zebra_announce (p, old_select, bgp); |
| 1399 | |
| 1400 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1401 | return WQ_SUCCESS; |
| 1402 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1403 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1404 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1405 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1406 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1407 | if (new_select) |
| 1408 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1409 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1410 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1411 | } |
| 1412 | |
| 1413 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1414 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1415 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1416 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1417 | bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1418 | } |
| 1419 | |
| 1420 | /* FIB update. */ |
| 1421 | if (safi == SAFI_UNICAST && ! bgp->name && |
| 1422 | ! bgp_option_check (BGP_OPT_NO_FIB)) |
| 1423 | { |
| 1424 | if (new_select |
| 1425 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1426 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
| 1427 | bgp_zebra_announce (p, new_select, bgp); |
| 1428 | else |
| 1429 | { |
| 1430 | /* Withdraw the route from the kernel. */ |
| 1431 | if (old_select |
| 1432 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1433 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
| 1434 | bgp_zebra_withdraw (p, old_select); |
| 1435 | } |
| 1436 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1437 | |
| 1438 | /* Reap old select bgp_info, it it has been removed */ |
| 1439 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1440 | bgp_info_reap (rn, old_select); |
| 1441 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1442 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1443 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1444 | } |
| 1445 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1446 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1447 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1448 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1449 | struct bgp_process_queue *pq = data; |
| 1450 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1451 | bgp_unlock_node (pq->rn); |
| 1452 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1453 | } |
| 1454 | |
| 1455 | static void |
| 1456 | bgp_process_queue_init (void) |
| 1457 | { |
| 1458 | bm->process_main_queue |
| 1459 | = work_queue_new (bm->master, "process_main_queue"); |
| 1460 | bm->process_rsclient_queue |
| 1461 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1462 | |
| 1463 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1464 | { |
| 1465 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1466 | exit (1); |
| 1467 | } |
| 1468 | |
| 1469 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
| 1470 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
| 1471 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
| 1472 | bm->process_rsclient_queue->spec.del_item_data |
| 1473 | = bm->process_main_queue->spec.del_item_data; |
| 1474 | bm->process_main_queue->spec.max_retries |
| 1475 | = bm->process_main_queue->spec.max_retries = 0; |
| 1476 | bm->process_rsclient_queue->spec.hold |
| 1477 | = bm->process_main_queue->spec.hold = 500; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1478 | } |
| 1479 | |
| 1480 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1481 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1482 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1483 | struct bgp_process_queue *pqnode; |
| 1484 | |
| 1485 | /* already scheduled for processing? */ |
| 1486 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1487 | return; |
| 1488 | |
| 1489 | if ( (bm->process_main_queue == NULL) || |
| 1490 | (bm->process_rsclient_queue == NULL) ) |
| 1491 | bgp_process_queue_init (); |
| 1492 | |
| 1493 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1494 | sizeof (struct bgp_process_queue)); |
| 1495 | if (!pqnode) |
| 1496 | return; |
| 1497 | |
| 1498 | pqnode->rn = bgp_lock_node (rn); /* unlocked by bgp_processq_del */ |
| 1499 | pqnode->bgp = bgp; |
| 1500 | pqnode->afi = afi; |
| 1501 | pqnode->safi = safi; |
| 1502 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1503 | switch (rn->table->type) |
| 1504 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1505 | case BGP_TABLE_MAIN: |
| 1506 | work_queue_add (bm->process_main_queue, pqnode); |
| 1507 | break; |
| 1508 | case BGP_TABLE_RSCLIENT: |
| 1509 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1510 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1511 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1512 | |
| 1513 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1514 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1515 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1516 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1517 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1518 | { |
| 1519 | struct peer *peer; |
| 1520 | |
| 1521 | peer = THREAD_ARG (thread); |
| 1522 | peer->t_pmax_restart = NULL; |
| 1523 | |
| 1524 | if (BGP_DEBUG (events, EVENTS)) |
| 1525 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1526 | peer->host); |
| 1527 | |
| 1528 | peer_clear (peer); |
| 1529 | |
| 1530 | return 0; |
| 1531 | } |
| 1532 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1533 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1534 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1535 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1536 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1537 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1538 | return 0; |
| 1539 | |
| 1540 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1541 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1542 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1543 | && ! always) |
| 1544 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1545 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1546 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1547 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1548 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1549 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1550 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1551 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1552 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1553 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1554 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1555 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1556 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1557 | |
| 1558 | if (safi == SAFI_MPLS_VPN) |
| 1559 | safi = BGP_SAFI_VPNV4; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1560 | |
| 1561 | ndata[0] = (afi >> 8); |
| 1562 | ndata[1] = afi; |
| 1563 | ndata[2] = safi; |
| 1564 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1565 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1566 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1567 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1568 | |
| 1569 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1570 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1571 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1572 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1573 | |
| 1574 | /* restart timer start */ |
| 1575 | if (peer->pmax_restart[afi][safi]) |
| 1576 | { |
| 1577 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1578 | |
| 1579 | if (BGP_DEBUG (events, EVENTS)) |
| 1580 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1581 | peer->host, peer->v_pmax_restart); |
| 1582 | |
| 1583 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1584 | peer->v_pmax_restart); |
| 1585 | } |
| 1586 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1587 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1588 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1589 | else |
| 1590 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1591 | |
| 1592 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1593 | { |
| 1594 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1595 | && ! always) |
| 1596 | return 0; |
| 1597 | |
| 1598 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1599 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1600 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1601 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1602 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1603 | } |
| 1604 | else |
| 1605 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1606 | return 0; |
| 1607 | } |
| 1608 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1609 | /* Unconditionally remove the route from the RIB, without taking |
| 1610 | * damping into consideration (eg, because the session went down) |
| 1611 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1612 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1613 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1614 | afi_t afi, safi_t safi) |
| 1615 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1616 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1617 | |
| 1618 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1619 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1620 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1621 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1622 | } |
| 1623 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1624 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1625 | 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] | 1626 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1627 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1628 | int status = BGP_DAMP_NONE; |
| 1629 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1630 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1631 | * the bgp_info in the RIB for historical reference. |
| 1632 | */ |
| 1633 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1634 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1635 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1636 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1637 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1638 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1639 | return; |
| 1640 | } |
| 1641 | |
| 1642 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1643 | } |
| 1644 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1645 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1646 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1647 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1648 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1649 | { |
| 1650 | struct bgp_node *rn; |
| 1651 | struct bgp *bgp; |
| 1652 | struct attr new_attr; |
| 1653 | struct attr *attr_new; |
| 1654 | struct attr *attr_new2; |
| 1655 | struct bgp_info *ri; |
| 1656 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1657 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1658 | char buf[SU_ADDRSTRLEN]; |
| 1659 | |
| 1660 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1661 | if (peer == rsclient) |
| 1662 | return; |
| 1663 | |
| 1664 | bgp = peer->bgp; |
| 1665 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1666 | |
| 1667 | /* Check previously received route. */ |
| 1668 | for (ri = rn->info; ri; ri = ri->next) |
| 1669 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1670 | break; |
| 1671 | |
| 1672 | /* AS path loop check. */ |
| 1673 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1674 | { |
| 1675 | reason = "as-path contains our own AS;"; |
| 1676 | goto filtered; |
| 1677 | } |
| 1678 | |
| 1679 | /* Route reflector originator ID check. */ |
| 1680 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1681 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->originator_id)) |
| 1682 | { |
| 1683 | reason = "originator is us;"; |
| 1684 | goto filtered; |
| 1685 | } |
| 1686 | |
| 1687 | new_attr = *attr; |
| 1688 | |
| 1689 | /* Apply export policy. */ |
| 1690 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1691 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1692 | { |
| 1693 | reason = "export-policy;"; |
| 1694 | goto filtered; |
| 1695 | } |
| 1696 | |
| 1697 | attr_new2 = bgp_attr_intern (&new_attr); |
| 1698 | |
| 1699 | /* Apply import policy. */ |
| 1700 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1701 | { |
| 1702 | bgp_attr_unintern (attr_new2); |
| 1703 | |
| 1704 | reason = "import-policy;"; |
| 1705 | goto filtered; |
| 1706 | } |
| 1707 | |
| 1708 | attr_new = bgp_attr_intern (&new_attr); |
| 1709 | bgp_attr_unintern (attr_new2); |
| 1710 | |
| 1711 | /* IPv4 unicast next hop check. */ |
| 1712 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1713 | { |
| 1714 | /* Next hop must not be 0.0.0.0 nor Class E address. */ |
| 1715 | if (new_attr.nexthop.s_addr == 0 |
| 1716 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1717 | { |
| 1718 | bgp_attr_unintern (attr_new); |
| 1719 | |
| 1720 | reason = "martian next-hop;"; |
| 1721 | goto filtered; |
| 1722 | } |
| 1723 | } |
| 1724 | |
| 1725 | /* If the update is implicit withdraw. */ |
| 1726 | if (ri) |
| 1727 | { |
| 1728 | ri->uptime = time (NULL); |
| 1729 | |
| 1730 | /* Same attribute comes in. */ |
| 1731 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1732 | { |
| 1733 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1734 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1735 | |
| 1736 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1737 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1738 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1739 | peer->host, |
| 1740 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1741 | p->prefixlen, rsclient->host); |
| 1742 | |
| 1743 | bgp_unlock_node (rn); |
| 1744 | bgp_attr_unintern (attr_new); |
| 1745 | |
| 1746 | return; |
| 1747 | } |
| 1748 | |
| 1749 | /* Received Logging. */ |
| 1750 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1751 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1752 | peer->host, |
| 1753 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1754 | p->prefixlen, rsclient->host); |
| 1755 | |
| 1756 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1757 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1758 | |
| 1759 | /* Update to new attribute. */ |
| 1760 | bgp_attr_unintern (ri->attr); |
| 1761 | ri->attr = attr_new; |
| 1762 | |
| 1763 | /* Update MPLS tag. */ |
| 1764 | if (safi == SAFI_MPLS_VPN) |
| 1765 | memcpy (ri->tag, tag, 3); |
| 1766 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1767 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1768 | |
| 1769 | /* Process change. */ |
| 1770 | bgp_process (bgp, rn, afi, safi); |
| 1771 | bgp_unlock_node (rn); |
| 1772 | |
| 1773 | return; |
| 1774 | } |
| 1775 | |
| 1776 | /* Received Logging. */ |
| 1777 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1778 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1779 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1780 | peer->host, |
| 1781 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1782 | p->prefixlen, rsclient->host); |
| 1783 | } |
| 1784 | |
| 1785 | /* Make new BGP info. */ |
| 1786 | new = bgp_info_new (); |
| 1787 | new->type = type; |
| 1788 | new->sub_type = sub_type; |
| 1789 | new->peer = peer; |
| 1790 | new->attr = attr_new; |
| 1791 | new->uptime = time (NULL); |
| 1792 | |
| 1793 | /* Update MPLS tag. */ |
| 1794 | if (safi == SAFI_MPLS_VPN) |
| 1795 | memcpy (new->tag, tag, 3); |
| 1796 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1797 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1798 | |
| 1799 | /* Register new BGP information. */ |
| 1800 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1801 | |
| 1802 | /* route_node_get lock */ |
| 1803 | bgp_unlock_node (rn); |
| 1804 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1805 | /* Process change. */ |
| 1806 | bgp_process (bgp, rn, afi, safi); |
| 1807 | |
| 1808 | return; |
| 1809 | |
| 1810 | filtered: |
| 1811 | |
| 1812 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 1813 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1814 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1815 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 1816 | peer->host, |
| 1817 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1818 | p->prefixlen, rsclient->host, reason); |
| 1819 | |
| 1820 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1821 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1822 | |
| 1823 | bgp_unlock_node (rn); |
| 1824 | |
| 1825 | return; |
| 1826 | } |
| 1827 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1828 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1829 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1830 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 1831 | struct prefix_rd *prd, u_char *tag) |
| 1832 | { |
| 1833 | struct bgp_node *rn; |
| 1834 | struct bgp_info *ri; |
| 1835 | char buf[SU_ADDRSTRLEN]; |
| 1836 | |
| 1837 | if (rsclient == peer) |
| 1838 | return; |
| 1839 | |
| 1840 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1841 | |
| 1842 | /* Lookup withdrawn route. */ |
| 1843 | for (ri = rn->info; ri; ri = ri->next) |
| 1844 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1845 | break; |
| 1846 | |
| 1847 | /* Withdraw specified route from routing table. */ |
| 1848 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1849 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1850 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1851 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1852 | "%s Can't find the route %s/%d", peer->host, |
| 1853 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1854 | p->prefixlen); |
| 1855 | |
| 1856 | /* Unlock bgp_node_get() lock. */ |
| 1857 | bgp_unlock_node (rn); |
| 1858 | } |
| 1859 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1860 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1861 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1862 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1863 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1864 | { |
| 1865 | int ret; |
| 1866 | int aspath_loop_count = 0; |
| 1867 | struct bgp_node *rn; |
| 1868 | struct bgp *bgp; |
| 1869 | struct attr new_attr; |
| 1870 | struct attr *attr_new; |
| 1871 | struct bgp_info *ri; |
| 1872 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1873 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1874 | char buf[SU_ADDRSTRLEN]; |
| 1875 | |
| 1876 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1877 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1878 | |
| 1879 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 1880 | Adj-RIBs-In. */ |
| 1881 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1882 | && peer != bgp->peer_self && ! soft_reconfig) |
| 1883 | bgp_adj_in_set (rn, peer, attr); |
| 1884 | |
| 1885 | /* Check previously received route. */ |
| 1886 | for (ri = rn->info; ri; ri = ri->next) |
| 1887 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1888 | break; |
| 1889 | |
| 1890 | /* AS path local-as loop check. */ |
| 1891 | if (peer->change_local_as) |
| 1892 | { |
| 1893 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 1894 | aspath_loop_count = 1; |
| 1895 | |
| 1896 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 1897 | { |
| 1898 | reason = "as-path contains our own AS;"; |
| 1899 | goto filtered; |
| 1900 | } |
| 1901 | } |
| 1902 | |
| 1903 | /* AS path loop check. */ |
| 1904 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 1905 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 1906 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 1907 | > peer->allowas_in[afi][safi])) |
| 1908 | { |
| 1909 | reason = "as-path contains our own AS;"; |
| 1910 | goto filtered; |
| 1911 | } |
| 1912 | |
| 1913 | /* Route reflector originator ID check. */ |
| 1914 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1915 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id)) |
| 1916 | { |
| 1917 | reason = "originator is us;"; |
| 1918 | goto filtered; |
| 1919 | } |
| 1920 | |
| 1921 | /* Route reflector cluster ID check. */ |
| 1922 | if (bgp_cluster_filter (peer, attr)) |
| 1923 | { |
| 1924 | reason = "reflected from the same cluster;"; |
| 1925 | goto filtered; |
| 1926 | } |
| 1927 | |
| 1928 | /* Apply incoming filter. */ |
| 1929 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 1930 | { |
| 1931 | reason = "filter;"; |
| 1932 | goto filtered; |
| 1933 | } |
| 1934 | |
| 1935 | /* Apply incoming route-map. */ |
| 1936 | new_attr = *attr; |
| 1937 | |
| 1938 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1939 | { |
| 1940 | reason = "route-map;"; |
| 1941 | goto filtered; |
| 1942 | } |
| 1943 | |
| 1944 | /* IPv4 unicast next hop check. */ |
| 1945 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1946 | { |
| 1947 | /* If the peer is EBGP and nexthop is not on connected route, |
| 1948 | discard it. */ |
| 1949 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
| 1950 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 1951 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1952 | { |
| 1953 | reason = "non-connected next-hop;"; |
| 1954 | goto filtered; |
| 1955 | } |
| 1956 | |
| 1957 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop |
| 1958 | must not be my own address. */ |
| 1959 | if (bgp_nexthop_self (afi, &new_attr) |
| 1960 | || new_attr.nexthop.s_addr == 0 |
| 1961 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1962 | { |
| 1963 | reason = "martian next-hop;"; |
| 1964 | goto filtered; |
| 1965 | } |
| 1966 | } |
| 1967 | |
| 1968 | attr_new = bgp_attr_intern (&new_attr); |
| 1969 | |
| 1970 | /* If the update is implicit withdraw. */ |
| 1971 | if (ri) |
| 1972 | { |
| 1973 | ri->uptime = time (NULL); |
| 1974 | |
| 1975 | /* Same attribute comes in. */ |
| 1976 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1977 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1978 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1979 | |
| 1980 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1981 | && peer_sort (peer) == BGP_PEER_EBGP |
| 1982 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1983 | { |
| 1984 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1985 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1986 | peer->host, |
| 1987 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1988 | p->prefixlen); |
| 1989 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1990 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 1991 | { |
| 1992 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1993 | bgp_process (bgp, rn, afi, safi); |
| 1994 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1995 | } |
| 1996 | else |
| 1997 | { |
| 1998 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1999 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2000 | "%s rcvd %s/%d...duplicate ignored", |
| 2001 | peer->host, |
| 2002 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2003 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2004 | |
| 2005 | /* graceful restart STALE flag unset. */ |
| 2006 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2007 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2008 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2009 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2010 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2011 | } |
| 2012 | |
| 2013 | bgp_unlock_node (rn); |
| 2014 | bgp_attr_unintern (attr_new); |
| 2015 | return 0; |
| 2016 | } |
| 2017 | |
| 2018 | /* Received Logging. */ |
| 2019 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2020 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2021 | peer->host, |
| 2022 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2023 | p->prefixlen); |
| 2024 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2025 | /* graceful restart STALE flag unset. */ |
| 2026 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2027 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2028 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2029 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2030 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2031 | |
| 2032 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2033 | * only if update is accepted, they'll increment below. |
| 2034 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2035 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2036 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2037 | /* Update bgp route dampening information. */ |
| 2038 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2039 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2040 | { |
| 2041 | /* This is implicit withdraw so we should update dampening |
| 2042 | information. */ |
| 2043 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2044 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2045 | } |
| 2046 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2047 | /* Update to new attribute. */ |
| 2048 | bgp_attr_unintern (ri->attr); |
| 2049 | ri->attr = attr_new; |
| 2050 | |
| 2051 | /* Update MPLS tag. */ |
| 2052 | if (safi == SAFI_MPLS_VPN) |
| 2053 | memcpy (ri->tag, tag, 3); |
| 2054 | |
| 2055 | /* Update bgp route dampening information. */ |
| 2056 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2057 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2058 | { |
| 2059 | /* Now we do normal update dampening. */ |
| 2060 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2061 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2062 | { |
| 2063 | bgp_unlock_node (rn); |
| 2064 | return 0; |
| 2065 | } |
| 2066 | } |
| 2067 | |
| 2068 | /* Nexthop reachability check. */ |
| 2069 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2070 | && safi == SAFI_UNICAST |
| 2071 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 2072 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2073 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2074 | { |
| 2075 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2076 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2077 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2078 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2079 | } |
| 2080 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2081 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2082 | |
| 2083 | /* Process change. */ |
| 2084 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2085 | |
| 2086 | bgp_process (bgp, rn, afi, safi); |
| 2087 | bgp_unlock_node (rn); |
| 2088 | return 0; |
| 2089 | } |
| 2090 | |
| 2091 | /* Received Logging. */ |
| 2092 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2093 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2094 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2095 | peer->host, |
| 2096 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2097 | p->prefixlen); |
| 2098 | } |
| 2099 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2100 | /* Make new BGP info. */ |
| 2101 | new = bgp_info_new (); |
| 2102 | new->type = type; |
| 2103 | new->sub_type = sub_type; |
| 2104 | new->peer = peer; |
| 2105 | new->attr = attr_new; |
| 2106 | new->uptime = time (NULL); |
| 2107 | |
| 2108 | /* Update MPLS tag. */ |
| 2109 | if (safi == SAFI_MPLS_VPN) |
| 2110 | memcpy (new->tag, tag, 3); |
| 2111 | |
| 2112 | /* Nexthop reachability check. */ |
| 2113 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2114 | && safi == SAFI_UNICAST |
| 2115 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 2116 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2117 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2118 | { |
| 2119 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2120 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2121 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2122 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2123 | } |
| 2124 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2125 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2126 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2127 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2129 | |
| 2130 | /* Register new BGP information. */ |
| 2131 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2132 | |
| 2133 | /* route_node_get lock */ |
| 2134 | bgp_unlock_node (rn); |
| 2135 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2136 | /* If maximum prefix count is configured and current prefix |
| 2137 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2138 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2139 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2140 | |
| 2141 | /* Process change. */ |
| 2142 | bgp_process (bgp, rn, afi, safi); |
| 2143 | |
| 2144 | return 0; |
| 2145 | |
| 2146 | /* This BGP update is filtered. Log the reason then update BGP |
| 2147 | entry. */ |
| 2148 | filtered: |
| 2149 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2150 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2151 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2152 | peer->host, |
| 2153 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2154 | p->prefixlen, reason); |
| 2155 | |
| 2156 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2157 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2158 | |
| 2159 | bgp_unlock_node (rn); |
| 2160 | |
| 2161 | return 0; |
| 2162 | } |
| 2163 | |
| 2164 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2165 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2166 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2167 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2168 | { |
| 2169 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2170 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2171 | struct bgp *bgp; |
| 2172 | int ret; |
| 2173 | |
| 2174 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2175 | soft_reconfig); |
| 2176 | |
| 2177 | bgp = peer->bgp; |
| 2178 | |
| 2179 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2180 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2181 | { |
| 2182 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2183 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2184 | sub_type, prd, tag); |
| 2185 | } |
| 2186 | |
| 2187 | return ret; |
| 2188 | } |
| 2189 | |
| 2190 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2191 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2192 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2193 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2194 | { |
| 2195 | struct bgp *bgp; |
| 2196 | char buf[SU_ADDRSTRLEN]; |
| 2197 | struct bgp_node *rn; |
| 2198 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2199 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2200 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2201 | |
| 2202 | bgp = peer->bgp; |
| 2203 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2204 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2205 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2206 | { |
| 2207 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2208 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2209 | } |
| 2210 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2211 | /* Logging. */ |
| 2212 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2213 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2214 | peer->host, |
| 2215 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2216 | p->prefixlen); |
| 2217 | |
| 2218 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2219 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2220 | |
| 2221 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2222 | further calculation. */ |
| 2223 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2224 | && peer != bgp->peer_self) |
| 2225 | bgp_adj_in_unset (rn, peer); |
| 2226 | |
| 2227 | /* Lookup withdrawn route. */ |
| 2228 | for (ri = rn->info; ri; ri = ri->next) |
| 2229 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2230 | break; |
| 2231 | |
| 2232 | /* Withdraw specified route from routing table. */ |
| 2233 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2234 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2235 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2236 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2237 | "%s Can't find the route %s/%d", peer->host, |
| 2238 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2239 | p->prefixlen); |
| 2240 | |
| 2241 | /* Unlock bgp_node_get() lock. */ |
| 2242 | bgp_unlock_node (rn); |
| 2243 | |
| 2244 | return 0; |
| 2245 | } |
| 2246 | |
| 2247 | void |
| 2248 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2249 | { |
| 2250 | struct bgp *bgp; |
| 2251 | struct attr attr; |
| 2252 | struct aspath *aspath; |
| 2253 | struct prefix p; |
| 2254 | struct bgp_info binfo; |
| 2255 | struct peer *from; |
| 2256 | int ret = RMAP_DENYMATCH; |
| 2257 | |
| 2258 | bgp = peer->bgp; |
| 2259 | from = bgp->peer_self; |
| 2260 | |
| 2261 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2262 | aspath = attr.aspath; |
| 2263 | attr.local_pref = bgp->default_local_pref; |
| 2264 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2265 | |
| 2266 | if (afi == AFI_IP) |
| 2267 | str2prefix ("0.0.0.0/0", &p); |
| 2268 | #ifdef HAVE_IPV6 |
| 2269 | else if (afi == AFI_IP6) |
| 2270 | { |
| 2271 | str2prefix ("::/0", &p); |
| 2272 | |
| 2273 | /* IPv6 global nexthop must be included. */ |
| 2274 | memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global, |
| 2275 | IPV6_MAX_BYTELEN); |
| 2276 | attr.mp_nexthop_len = 16; |
| 2277 | |
| 2278 | /* If the peer is on shared nextwork and we have link-local |
| 2279 | nexthop set it. */ |
| 2280 | if (peer->shared_network |
| 2281 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2282 | { |
| 2283 | memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local, |
| 2284 | IPV6_MAX_BYTELEN); |
| 2285 | attr.mp_nexthop_len = 32; |
| 2286 | } |
| 2287 | } |
| 2288 | #endif /* HAVE_IPV6 */ |
| 2289 | else |
| 2290 | return; |
| 2291 | |
| 2292 | if (peer->default_rmap[afi][safi].name) |
| 2293 | { |
| 2294 | binfo.peer = bgp->peer_self; |
| 2295 | binfo.attr = &attr; |
| 2296 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2297 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2298 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2299 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2300 | RMAP_BGP, &binfo); |
| 2301 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2302 | bgp->peer_self->rmap_type = 0; |
| 2303 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2304 | if (ret == RMAP_DENYMATCH) |
| 2305 | { |
| 2306 | bgp_attr_flush (&attr); |
| 2307 | withdraw = 1; |
| 2308 | } |
| 2309 | } |
| 2310 | |
| 2311 | if (withdraw) |
| 2312 | { |
| 2313 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2314 | bgp_default_withdraw_send (peer, afi, safi); |
| 2315 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2316 | } |
| 2317 | else |
| 2318 | { |
| 2319 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2320 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2321 | } |
| 2322 | |
| 2323 | aspath_unintern (aspath); |
| 2324 | } |
| 2325 | |
| 2326 | static void |
| 2327 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2328 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2329 | { |
| 2330 | struct bgp_node *rn; |
| 2331 | struct bgp_info *ri; |
| 2332 | struct attr attr; |
| 2333 | |
| 2334 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2335 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | |
| 2337 | if (safi != SAFI_MPLS_VPN |
| 2338 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2339 | bgp_default_originate (peer, afi, safi, 0); |
| 2340 | |
| 2341 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2342 | for (ri = rn->info; ri; ri = ri->next) |
| 2343 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2344 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2345 | if ( (rsclient) ? |
| 2346 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2347 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2348 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2349 | else |
| 2350 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2351 | } |
| 2352 | } |
| 2353 | |
| 2354 | void |
| 2355 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2356 | { |
| 2357 | struct bgp_node *rn; |
| 2358 | struct bgp_table *table; |
| 2359 | |
| 2360 | if (peer->status != Established) |
| 2361 | return; |
| 2362 | |
| 2363 | if (! peer->afc_nego[afi][safi]) |
| 2364 | return; |
| 2365 | |
| 2366 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2367 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2368 | return; |
| 2369 | |
| 2370 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2371 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2372 | else |
| 2373 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2374 | rn = bgp_route_next(rn)) |
| 2375 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2376 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2377 | |
| 2378 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2379 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2380 | } |
| 2381 | |
| 2382 | void |
| 2383 | bgp_announce_route_all (struct peer *peer) |
| 2384 | { |
| 2385 | afi_t afi; |
| 2386 | safi_t safi; |
| 2387 | |
| 2388 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2389 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2390 | bgp_announce_route (peer, afi, safi); |
| 2391 | } |
| 2392 | |
| 2393 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2394 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
| 2395 | safi_t safi, struct bgp_table *table) |
| 2396 | { |
| 2397 | struct bgp_node *rn; |
| 2398 | struct bgp_adj_in *ain; |
| 2399 | |
| 2400 | if (! table) |
| 2401 | table = rsclient->bgp->rib[afi][safi]; |
| 2402 | |
| 2403 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2404 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2405 | { |
| 2406 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
| 2407 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2408 | } |
| 2409 | } |
| 2410 | |
| 2411 | void |
| 2412 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2413 | { |
| 2414 | struct bgp_table *table; |
| 2415 | struct bgp_node *rn; |
| 2416 | |
| 2417 | if (safi != SAFI_MPLS_VPN) |
| 2418 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); |
| 2419 | |
| 2420 | else |
| 2421 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2422 | rn = bgp_route_next (rn)) |
| 2423 | if ((table = rn->info) != NULL) |
| 2424 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); |
| 2425 | } |
| 2426 | |
| 2427 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2428 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 2429 | struct bgp_table *table) |
| 2430 | { |
| 2431 | int ret; |
| 2432 | struct bgp_node *rn; |
| 2433 | struct bgp_adj_in *ain; |
| 2434 | |
| 2435 | if (! table) |
| 2436 | table = peer->bgp->rib[afi][safi]; |
| 2437 | |
| 2438 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2439 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2440 | { |
| 2441 | if (ain->peer == peer) |
| 2442 | { |
| 2443 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2444 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 2445 | NULL, NULL, 1); |
| 2446 | if (ret < 0) |
| 2447 | { |
| 2448 | bgp_unlock_node (rn); |
| 2449 | return; |
| 2450 | } |
| 2451 | continue; |
| 2452 | } |
| 2453 | } |
| 2454 | } |
| 2455 | |
| 2456 | void |
| 2457 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2458 | { |
| 2459 | struct bgp_node *rn; |
| 2460 | struct bgp_table *table; |
| 2461 | |
| 2462 | if (peer->status != Established) |
| 2463 | return; |
| 2464 | |
| 2465 | if (safi != SAFI_MPLS_VPN) |
| 2466 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 2467 | else |
| 2468 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2469 | rn = bgp_route_next (rn)) |
| 2470 | if ((table = rn->info) != NULL) |
| 2471 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 2472 | } |
| 2473 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2474 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2475 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2476 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2477 | struct bgp_node *rn = data; |
| 2478 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2479 | struct bgp_adj_in *ain; |
| 2480 | struct bgp_adj_out *aout; |
| 2481 | struct bgp_info *ri; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2482 | afi_t afi = rn->table->afi; |
| 2483 | safi_t safi = rn->table->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2484 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2485 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2486 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2487 | for (ri = rn->info; ri; ri = ri->next) |
| 2488 | if (ri->peer == peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2489 | { |
| 2490 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2491 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2492 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2493 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2494 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2495 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2496 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2497 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2498 | break; |
| 2499 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2500 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2501 | if (ain->peer == peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2502 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2503 | bgp_adj_in_remove (rn, ain); |
| 2504 | bgp_unlock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2505 | break; |
| 2506 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2507 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2508 | if (aout->peer == peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2509 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2510 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2511 | bgp_unlock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2512 | break; |
| 2513 | } |
| 2514 | return WQ_SUCCESS; |
| 2515 | } |
| 2516 | |
| 2517 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2518 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2519 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2520 | struct bgp_node *rn = data; |
| 2521 | |
| 2522 | bgp_unlock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2523 | } |
| 2524 | |
| 2525 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2526 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2527 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2528 | struct peer *peer = wq->spec.data; |
| 2529 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2530 | peer_unlock (peer); /* bgp_clear_node_complete */ |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2531 | |
| 2532 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2533 | BGP_EVENT_ADD (peer, Clearing_Completed); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2534 | } |
| 2535 | |
| 2536 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2537 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2538 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2539 | #define CLEAR_QUEUE_NAME_LEN 26 /* "clear 2001:123:123:123::1" */ |
| 2540 | char wname[CLEAR_QUEUE_NAME_LEN]; |
| 2541 | |
| 2542 | snprintf (wname, CLEAR_QUEUE_NAME_LEN, "clear %s", peer->host); |
| 2543 | #undef CLEAR_QUEUE_NAME_LEN |
| 2544 | |
| 2545 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2546 | { |
| 2547 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2548 | exit (1); |
| 2549 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2550 | peer->clear_node_queue->spec.hold = 10; |
| 2551 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2552 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2553 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2554 | peer->clear_node_queue->spec.max_retries = 0; |
| 2555 | |
| 2556 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2557 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2558 | } |
| 2559 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2560 | static void |
| 2561 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2562 | struct bgp_table *table, struct peer *rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2563 | { |
| 2564 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2565 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2567 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2568 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2569 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2570 | if (! table) |
| 2571 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2572 | |
| 2573 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2574 | { |
| 2575 | if (rn->info == NULL) |
| 2576 | continue; |
| 2577 | |
| 2578 | bgp_lock_node (rn); /* unlocked: bgp_clear_node_queue_del */ |
| 2579 | work_queue_add (peer->clear_node_queue, rn); |
| 2580 | } |
| 2581 | return; |
| 2582 | } |
| 2583 | |
| 2584 | void |
| 2585 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2586 | { |
| 2587 | struct bgp_node *rn; |
| 2588 | struct bgp_table *table; |
| 2589 | struct peer *rsclient; |
| 2590 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2591 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2592 | if (peer->clear_node_queue == NULL) |
| 2593 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2594 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2595 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2596 | * Idle until it receives a Clearing_Completed event. This protects |
| 2597 | * against peers which flap faster than we can we clear, which could |
| 2598 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2599 | * |
| 2600 | * a) race with routes from the new session being installed before |
| 2601 | * clear_route_node visits the node (to delete the route of that |
| 2602 | * peer) |
| 2603 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2604 | * on the process_main queue. Fast-flapping could cause that queue |
| 2605 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2606 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2607 | if (!peer->clear_node_queue->thread) |
| 2608 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2609 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2610 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2611 | bgp_clear_route_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2612 | else |
| 2613 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2614 | rn = bgp_route_next (rn)) |
| 2615 | if ((table = rn->info) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2616 | bgp_clear_route_table (peer, afi, safi, table, NULL); |
| 2617 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2618 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2619 | { |
| 2620 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2621 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient); |
| 2622 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2623 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2624 | /* If no routes were cleared, nothing was added to workqueue, the |
| 2625 | * completion function won't be run by workqueue code - call it here. |
| 2626 | * |
| 2627 | * Additionally, there is a presumption in FSM that clearing is only |
| 2628 | * needed if peer state is Established - peers in pre-Established states |
| 2629 | * shouldn't have any route-update state associated with them (in or out). |
| 2630 | * |
| 2631 | * We still get here from FSM through bgp_stop->clear_route_all in |
| 2632 | * pre-Established though, so this is a useful sanity check to ensure |
| 2633 | * the assumption above holds. |
| 2634 | * |
| 2635 | * At some future point, this check could be move to the top of the |
| 2636 | * function, and do a quick early-return when state is |
| 2637 | * pre-Established, avoiding above list and table scans. Once we're |
| 2638 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2639 | */ |
| 2640 | if (!peer->clear_node_queue->thread) |
| 2641 | bgp_clear_node_complete (peer->clear_node_queue); |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2642 | else |
| 2643 | { |
| 2644 | /* clearing queue scheduled. Normal if in Established state |
| 2645 | * (and about to transition out of it), but otherwise... |
| 2646 | */ |
| 2647 | if (peer->status != Established) |
| 2648 | { |
| 2649 | plog_err (peer->log, "%s [Error] State %s is not Established," |
| 2650 | " but routes were cleared - bug!", |
| 2651 | peer->host, LOOKUP (bgp_status_msg, peer->status)); |
| 2652 | assert (peer->status == Established); |
| 2653 | } |
| 2654 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2655 | } |
| 2656 | |
| 2657 | void |
| 2658 | bgp_clear_route_all (struct peer *peer) |
| 2659 | { |
| 2660 | afi_t afi; |
| 2661 | safi_t safi; |
| 2662 | |
| 2663 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2664 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2665 | bgp_clear_route (peer, afi, safi); |
| 2666 | } |
| 2667 | |
| 2668 | void |
| 2669 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2670 | { |
| 2671 | struct bgp_table *table; |
| 2672 | struct bgp_node *rn; |
| 2673 | struct bgp_adj_in *ain; |
| 2674 | |
| 2675 | table = peer->bgp->rib[afi][safi]; |
| 2676 | |
| 2677 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2678 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2679 | if (ain->peer == peer) |
| 2680 | { |
| 2681 | bgp_adj_in_remove (rn, ain); |
| 2682 | bgp_unlock_node (rn); |
| 2683 | break; |
| 2684 | } |
| 2685 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2686 | |
| 2687 | void |
| 2688 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2689 | { |
| 2690 | struct bgp_node *rn; |
| 2691 | struct bgp_info *ri; |
| 2692 | struct bgp_table *table; |
| 2693 | |
| 2694 | table = peer->bgp->rib[afi][safi]; |
| 2695 | |
| 2696 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2697 | { |
| 2698 | for (ri = rn->info; ri; ri = ri->next) |
| 2699 | if (ri->peer == peer) |
| 2700 | { |
| 2701 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2702 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 2703 | break; |
| 2704 | } |
| 2705 | } |
| 2706 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2707 | |
| 2708 | /* Delete all kernel routes. */ |
| 2709 | void |
paul | 545acaf | 2004-04-20 15:13:15 +0000 | [diff] [blame] | 2710 | bgp_cleanup_routes () |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2711 | { |
| 2712 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2713 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2714 | struct bgp_node *rn; |
| 2715 | struct bgp_table *table; |
| 2716 | struct bgp_info *ri; |
| 2717 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2718 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2719 | { |
| 2720 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 2721 | |
| 2722 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2723 | for (ri = rn->info; ri; ri = ri->next) |
| 2724 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2725 | && ri->type == ZEBRA_ROUTE_BGP |
| 2726 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2727 | bgp_zebra_withdraw (&rn->p, ri); |
| 2728 | |
| 2729 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 2730 | |
| 2731 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2732 | for (ri = rn->info; ri; ri = ri->next) |
| 2733 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2734 | && ri->type == ZEBRA_ROUTE_BGP |
| 2735 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2736 | bgp_zebra_withdraw (&rn->p, ri); |
| 2737 | } |
| 2738 | } |
| 2739 | |
| 2740 | void |
| 2741 | bgp_reset () |
| 2742 | { |
| 2743 | vty_reset (); |
| 2744 | bgp_zclient_reset (); |
| 2745 | access_list_reset (); |
| 2746 | prefix_list_reset (); |
| 2747 | } |
| 2748 | |
| 2749 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 2750 | value. */ |
| 2751 | int |
| 2752 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 2753 | { |
| 2754 | u_char *pnt; |
| 2755 | u_char *lim; |
| 2756 | struct prefix p; |
| 2757 | int psize; |
| 2758 | int ret; |
| 2759 | |
| 2760 | /* Check peer status. */ |
| 2761 | if (peer->status != Established) |
| 2762 | return 0; |
| 2763 | |
| 2764 | pnt = packet->nlri; |
| 2765 | lim = pnt + packet->length; |
| 2766 | |
| 2767 | for (; pnt < lim; pnt += psize) |
| 2768 | { |
| 2769 | /* Clear prefix structure. */ |
| 2770 | memset (&p, 0, sizeof (struct prefix)); |
| 2771 | |
| 2772 | /* Fetch prefix length. */ |
| 2773 | p.prefixlen = *pnt++; |
| 2774 | p.family = afi2family (packet->afi); |
| 2775 | |
| 2776 | /* Already checked in nlri_sanity_check(). We do double check |
| 2777 | here. */ |
| 2778 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 2779 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 2780 | return -1; |
| 2781 | |
| 2782 | /* Packet size overflow check. */ |
| 2783 | psize = PSIZE (p.prefixlen); |
| 2784 | |
| 2785 | /* When packet overflow occur return immediately. */ |
| 2786 | if (pnt + psize > lim) |
| 2787 | return -1; |
| 2788 | |
| 2789 | /* Fetch prefix from NLRI packet. */ |
| 2790 | memcpy (&p.u.prefix, pnt, psize); |
| 2791 | |
| 2792 | /* Check address. */ |
| 2793 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 2794 | { |
| 2795 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 2796 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2797 | /* |
| 2798 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 2799 | * If a BGP router receives an UPDATE message with a |
| 2800 | * semantically incorrect NLRI field, in which a prefix is |
| 2801 | * semantically incorrect (eg. an unexpected multicast IP |
| 2802 | * address), it should ignore the prefix. |
| 2803 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2804 | zlog (peer->log, LOG_ERR, |
| 2805 | "IPv4 unicast NLRI is multicast address %s", |
| 2806 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2807 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2808 | return -1; |
| 2809 | } |
| 2810 | } |
| 2811 | |
| 2812 | #ifdef HAVE_IPV6 |
| 2813 | /* Check address. */ |
| 2814 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 2815 | { |
| 2816 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2817 | { |
| 2818 | char buf[BUFSIZ]; |
| 2819 | |
| 2820 | zlog (peer->log, LOG_WARNING, |
| 2821 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 2822 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 2823 | |
| 2824 | continue; |
| 2825 | } |
| 2826 | } |
| 2827 | #endif /* HAVE_IPV6 */ |
| 2828 | |
| 2829 | /* Normal process. */ |
| 2830 | if (attr) |
| 2831 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 2832 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 2833 | else |
| 2834 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 2835 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2836 | |
| 2837 | /* Address family configuration mismatch or maximum-prefix count |
| 2838 | overflow. */ |
| 2839 | if (ret < 0) |
| 2840 | return -1; |
| 2841 | } |
| 2842 | |
| 2843 | /* Packet length consistency check. */ |
| 2844 | if (pnt != lim) |
| 2845 | return -1; |
| 2846 | |
| 2847 | return 0; |
| 2848 | } |
| 2849 | |
| 2850 | /* NLRI encode syntax check routine. */ |
| 2851 | int |
| 2852 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 2853 | bgp_size_t length) |
| 2854 | { |
| 2855 | u_char *end; |
| 2856 | u_char prefixlen; |
| 2857 | int psize; |
| 2858 | |
| 2859 | end = pnt + length; |
| 2860 | |
| 2861 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 2862 | syntactic validity. If the field is syntactically incorrect, |
| 2863 | then the Error Subcode is set to Invalid Network Field. */ |
| 2864 | |
| 2865 | while (pnt < end) |
| 2866 | { |
| 2867 | prefixlen = *pnt++; |
| 2868 | |
| 2869 | /* Prefix length check. */ |
| 2870 | if ((afi == AFI_IP && prefixlen > 32) |
| 2871 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 2872 | { |
| 2873 | plog_err (peer->log, |
| 2874 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 2875 | peer->host, prefixlen); |
| 2876 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2877 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2878 | return -1; |
| 2879 | } |
| 2880 | |
| 2881 | /* Packet size overflow check. */ |
| 2882 | psize = PSIZE (prefixlen); |
| 2883 | |
| 2884 | if (pnt + psize > end) |
| 2885 | { |
| 2886 | plog_err (peer->log, |
| 2887 | "%s [Error] Update packet error" |
| 2888 | " (prefix data overflow prefix size is %d)", |
| 2889 | peer->host, psize); |
| 2890 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2891 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2892 | return -1; |
| 2893 | } |
| 2894 | |
| 2895 | pnt += psize; |
| 2896 | } |
| 2897 | |
| 2898 | /* Packet length consistency check. */ |
| 2899 | if (pnt != end) |
| 2900 | { |
| 2901 | plog_err (peer->log, |
| 2902 | "%s [Error] Update packet error" |
| 2903 | " (prefix length mismatch with total length)", |
| 2904 | peer->host); |
| 2905 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2906 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2907 | return -1; |
| 2908 | } |
| 2909 | return 0; |
| 2910 | } |
| 2911 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2912 | static struct bgp_static * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2913 | bgp_static_new () |
| 2914 | { |
| 2915 | struct bgp_static *new; |
| 2916 | new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
| 2917 | memset (new, 0, sizeof (struct bgp_static)); |
| 2918 | return new; |
| 2919 | } |
| 2920 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2921 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2922 | bgp_static_free (struct bgp_static *bgp_static) |
| 2923 | { |
| 2924 | if (bgp_static->rmap.name) |
| 2925 | free (bgp_static->rmap.name); |
| 2926 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 2927 | } |
| 2928 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2929 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2930 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 2931 | struct prefix *p, afi_t afi, safi_t safi) |
| 2932 | { |
| 2933 | struct bgp_node *rn; |
| 2934 | struct bgp_info *ri; |
| 2935 | |
| 2936 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2937 | |
| 2938 | /* Check selected route and self inserted route. */ |
| 2939 | for (ri = rn->info; ri; ri = ri->next) |
| 2940 | if (ri->peer == bgp->peer_self |
| 2941 | && ri->type == ZEBRA_ROUTE_BGP |
| 2942 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2943 | break; |
| 2944 | |
| 2945 | /* Withdraw static BGP route from routing table. */ |
| 2946 | if (ri) |
| 2947 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2948 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2949 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2950 | } |
| 2951 | |
| 2952 | /* Unlock bgp_node_lookup. */ |
| 2953 | bgp_unlock_node (rn); |
| 2954 | } |
| 2955 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2956 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2957 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
| 2958 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2959 | { |
| 2960 | struct bgp_node *rn; |
| 2961 | struct bgp_info *ri; |
| 2962 | struct bgp_info *new; |
| 2963 | struct bgp_info info; |
| 2964 | struct attr new_attr; |
| 2965 | struct attr *attr_new; |
| 2966 | struct attr attr; |
| 2967 | struct bgp *bgp; |
| 2968 | int ret; |
| 2969 | char buf[SU_ADDRSTRLEN]; |
| 2970 | |
| 2971 | bgp = rsclient->bgp; |
| 2972 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 2973 | assert (bgp_static); |
| 2974 | if (!bgp_static) |
| 2975 | return; |
| 2976 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2977 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2978 | |
| 2979 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 2980 | |
| 2981 | attr.nexthop = bgp_static->igpnexthop; |
| 2982 | attr.med = bgp_static->igpmetric; |
| 2983 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2984 | |
| 2985 | new_attr = attr; |
| 2986 | |
| 2987 | /* Apply network route-map for export to this rsclient. */ |
| 2988 | if (bgp_static->rmap.name) |
| 2989 | { |
| 2990 | info.peer = rsclient; |
| 2991 | info.attr = &new_attr; |
| 2992 | |
| 2993 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 2994 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2995 | |
| 2996 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 2997 | |
| 2998 | rsclient->rmap_type = 0; |
| 2999 | |
| 3000 | if (ret == RMAP_DENYMATCH) |
| 3001 | { |
| 3002 | /* Free uninterned attribute. */ |
| 3003 | bgp_attr_flush (&new_attr); |
| 3004 | |
| 3005 | /* Unintern original. */ |
| 3006 | aspath_unintern (attr.aspath); |
| 3007 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3008 | |
| 3009 | return; |
| 3010 | } |
| 3011 | attr_new = bgp_attr_intern (&new_attr); |
| 3012 | } |
| 3013 | else |
| 3014 | attr_new = bgp_attr_intern (&attr); |
| 3015 | |
| 3016 | new_attr = *attr_new; |
| 3017 | |
| 3018 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3019 | |
| 3020 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY) |
| 3021 | { |
| 3022 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3023 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3024 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3025 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3026 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3027 | p->prefixlen, rsclient->host); |
| 3028 | |
| 3029 | bgp->peer_self->rmap_type = 0; |
| 3030 | |
| 3031 | bgp_attr_unintern (attr_new); |
| 3032 | aspath_unintern (attr.aspath); |
| 3033 | |
| 3034 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3035 | |
| 3036 | return; |
| 3037 | } |
| 3038 | |
| 3039 | bgp->peer_self->rmap_type = 0; |
| 3040 | |
| 3041 | bgp_attr_unintern (attr_new); |
| 3042 | attr_new = bgp_attr_intern (&new_attr); |
| 3043 | |
| 3044 | for (ri = rn->info; ri; ri = ri->next) |
| 3045 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3046 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3047 | break; |
| 3048 | |
| 3049 | if (ri) |
| 3050 | { |
| 3051 | if (attrhash_cmp (ri->attr, attr_new)) |
| 3052 | { |
| 3053 | bgp_unlock_node (rn); |
| 3054 | bgp_attr_unintern (attr_new); |
| 3055 | aspath_unintern (attr.aspath); |
| 3056 | return; |
| 3057 | } |
| 3058 | else |
| 3059 | { |
| 3060 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3061 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3062 | |
| 3063 | /* Rewrite BGP route information. */ |
| 3064 | bgp_attr_unintern (ri->attr); |
| 3065 | ri->attr = attr_new; |
| 3066 | ri->uptime = time (NULL); |
| 3067 | |
| 3068 | /* Process change. */ |
| 3069 | bgp_process (bgp, rn, afi, safi); |
| 3070 | bgp_unlock_node (rn); |
| 3071 | aspath_unintern (attr.aspath); |
| 3072 | return; |
| 3073 | } |
| 3074 | } |
| 3075 | |
| 3076 | /* Make new BGP info. */ |
| 3077 | new = bgp_info_new (); |
| 3078 | new->type = ZEBRA_ROUTE_BGP; |
| 3079 | new->sub_type = BGP_ROUTE_STATIC; |
| 3080 | new->peer = bgp->peer_self; |
| 3081 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3082 | new->attr = attr_new; |
| 3083 | new->uptime = time (NULL); |
| 3084 | |
| 3085 | /* Register new BGP information. */ |
| 3086 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3087 | |
| 3088 | /* route_node_get lock */ |
| 3089 | bgp_unlock_node (rn); |
| 3090 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3091 | /* Process change. */ |
| 3092 | bgp_process (bgp, rn, afi, safi); |
| 3093 | |
| 3094 | /* Unintern original. */ |
| 3095 | aspath_unintern (attr.aspath); |
| 3096 | } |
| 3097 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3098 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3099 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3100 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3101 | { |
| 3102 | struct bgp_node *rn; |
| 3103 | struct bgp_info *ri; |
| 3104 | struct bgp_info *new; |
| 3105 | struct bgp_info info; |
| 3106 | struct attr attr; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3107 | struct attr attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3108 | struct attr *attr_new; |
| 3109 | int ret; |
| 3110 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3111 | assert (bgp_static); |
| 3112 | if (!bgp_static) |
| 3113 | return; |
| 3114 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3115 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3116 | |
| 3117 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3118 | |
| 3119 | attr.nexthop = bgp_static->igpnexthop; |
| 3120 | attr.med = bgp_static->igpmetric; |
| 3121 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3122 | |
| 3123 | /* Apply route-map. */ |
| 3124 | if (bgp_static->rmap.name) |
| 3125 | { |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3126 | attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3127 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3128 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3129 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3130 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3131 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3132 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3133 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3134 | bgp->peer_self->rmap_type = 0; |
| 3135 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3136 | if (ret == RMAP_DENYMATCH) |
| 3137 | { |
| 3138 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3139 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3140 | |
| 3141 | /* Unintern original. */ |
| 3142 | aspath_unintern (attr.aspath); |
| 3143 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3144 | return; |
| 3145 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3146 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3147 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3148 | else |
| 3149 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3150 | |
| 3151 | for (ri = rn->info; ri; ri = ri->next) |
| 3152 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3153 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3154 | break; |
| 3155 | |
| 3156 | if (ri) |
| 3157 | { |
| 3158 | if (attrhash_cmp (ri->attr, attr_new)) |
| 3159 | { |
| 3160 | bgp_unlock_node (rn); |
| 3161 | bgp_attr_unintern (attr_new); |
| 3162 | aspath_unintern (attr.aspath); |
| 3163 | return; |
| 3164 | } |
| 3165 | else |
| 3166 | { |
| 3167 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3168 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3169 | |
| 3170 | /* Rewrite BGP route information. */ |
| 3171 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3172 | bgp_attr_unintern (ri->attr); |
| 3173 | ri->attr = attr_new; |
| 3174 | ri->uptime = time (NULL); |
| 3175 | |
| 3176 | /* Process change. */ |
| 3177 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3178 | bgp_process (bgp, rn, afi, safi); |
| 3179 | bgp_unlock_node (rn); |
| 3180 | aspath_unintern (attr.aspath); |
| 3181 | return; |
| 3182 | } |
| 3183 | } |
| 3184 | |
| 3185 | /* Make new BGP info. */ |
| 3186 | new = bgp_info_new (); |
| 3187 | new->type = ZEBRA_ROUTE_BGP; |
| 3188 | new->sub_type = BGP_ROUTE_STATIC; |
| 3189 | new->peer = bgp->peer_self; |
| 3190 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3191 | new->attr = attr_new; |
| 3192 | new->uptime = time (NULL); |
| 3193 | |
| 3194 | /* Aggregate address increment. */ |
| 3195 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3196 | |
| 3197 | /* Register new BGP information. */ |
| 3198 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3199 | |
| 3200 | /* route_node_get lock */ |
| 3201 | bgp_unlock_node (rn); |
| 3202 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3203 | /* Process change. */ |
| 3204 | bgp_process (bgp, rn, afi, safi); |
| 3205 | |
| 3206 | /* Unintern original. */ |
| 3207 | aspath_unintern (attr.aspath); |
| 3208 | } |
| 3209 | |
| 3210 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3211 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3212 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3213 | { |
| 3214 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3215 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3216 | |
| 3217 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3218 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3219 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3220 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3221 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3222 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3223 | } |
| 3224 | } |
| 3225 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3226 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3227 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 3228 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 3229 | { |
| 3230 | struct bgp_node *rn; |
| 3231 | struct bgp_info *new; |
| 3232 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3233 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3234 | |
| 3235 | /* Make new BGP info. */ |
| 3236 | new = bgp_info_new (); |
| 3237 | new->type = ZEBRA_ROUTE_BGP; |
| 3238 | new->sub_type = BGP_ROUTE_STATIC; |
| 3239 | new->peer = bgp->peer_self; |
| 3240 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3241 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3242 | new->uptime = time (NULL); |
| 3243 | memcpy (new->tag, tag, 3); |
| 3244 | |
| 3245 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3246 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3247 | |
| 3248 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3249 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3250 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3251 | /* route_node_get lock */ |
| 3252 | bgp_unlock_node (rn); |
| 3253 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3254 | /* Process change. */ |
| 3255 | bgp_process (bgp, rn, afi, safi); |
| 3256 | } |
| 3257 | |
| 3258 | void |
| 3259 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3260 | safi_t safi) |
| 3261 | { |
| 3262 | struct bgp_node *rn; |
| 3263 | struct bgp_info *ri; |
| 3264 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3265 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3266 | |
| 3267 | /* Check selected route and self inserted route. */ |
| 3268 | for (ri = rn->info; ri; ri = ri->next) |
| 3269 | if (ri->peer == bgp->peer_self |
| 3270 | && ri->type == ZEBRA_ROUTE_BGP |
| 3271 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3272 | break; |
| 3273 | |
| 3274 | /* Withdraw static BGP route from routing table. */ |
| 3275 | if (ri) |
| 3276 | { |
| 3277 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3278 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3279 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3280 | } |
| 3281 | |
| 3282 | /* Unlock bgp_node_lookup. */ |
| 3283 | bgp_unlock_node (rn); |
| 3284 | } |
| 3285 | |
| 3286 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3287 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3288 | { |
| 3289 | struct bgp_static *bgp_static; |
| 3290 | struct bgp *bgp; |
| 3291 | struct bgp_node *rn; |
| 3292 | struct prefix *p; |
| 3293 | |
| 3294 | bgp = rsclient->bgp; |
| 3295 | |
| 3296 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3297 | if ((bgp_static = rn->info) != NULL) |
| 3298 | { |
| 3299 | p = &rn->p; |
| 3300 | |
| 3301 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3302 | afi, safi); |
| 3303 | } |
| 3304 | } |
| 3305 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3306 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3307 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 3308 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 3309 | { |
| 3310 | struct bgp_node *rn; |
| 3311 | struct bgp_info *ri; |
| 3312 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3313 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3314 | |
| 3315 | /* Check selected route and self inserted route. */ |
| 3316 | for (ri = rn->info; ri; ri = ri->next) |
| 3317 | if (ri->peer == bgp->peer_self |
| 3318 | && ri->type == ZEBRA_ROUTE_BGP |
| 3319 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3320 | break; |
| 3321 | |
| 3322 | /* Withdraw static BGP route from routing table. */ |
| 3323 | if (ri) |
| 3324 | { |
| 3325 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3326 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3327 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3328 | } |
| 3329 | |
| 3330 | /* Unlock bgp_node_lookup. */ |
| 3331 | bgp_unlock_node (rn); |
| 3332 | } |
| 3333 | |
| 3334 | /* Configure static BGP network. When user don't run zebra, static |
| 3335 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3336 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3337 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
| 3338 | u_int16_t afi, u_char safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3339 | { |
| 3340 | int ret; |
| 3341 | struct prefix p; |
| 3342 | struct bgp_static *bgp_static; |
| 3343 | struct bgp_node *rn; |
| 3344 | int need_update = 0; |
| 3345 | |
| 3346 | /* Convert IP prefix string to struct prefix. */ |
| 3347 | ret = str2prefix (ip_str, &p); |
| 3348 | if (! ret) |
| 3349 | { |
| 3350 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3351 | return CMD_WARNING; |
| 3352 | } |
| 3353 | #ifdef HAVE_IPV6 |
| 3354 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3355 | { |
| 3356 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3357 | VTY_NEWLINE); |
| 3358 | return CMD_WARNING; |
| 3359 | } |
| 3360 | #endif /* HAVE_IPV6 */ |
| 3361 | |
| 3362 | apply_mask (&p); |
| 3363 | |
| 3364 | /* Set BGP static route configuration. */ |
| 3365 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3366 | |
| 3367 | if (rn->info) |
| 3368 | { |
| 3369 | /* Configuration change. */ |
| 3370 | bgp_static = rn->info; |
| 3371 | |
| 3372 | /* Check previous routes are installed into BGP. */ |
| 3373 | if (! bgp_static->backdoor && bgp_static->valid) |
| 3374 | need_update = 1; |
| 3375 | |
| 3376 | bgp_static->backdoor = backdoor; |
| 3377 | if (rmap) |
| 3378 | { |
| 3379 | if (bgp_static->rmap.name) |
| 3380 | free (bgp_static->rmap.name); |
| 3381 | bgp_static->rmap.name = strdup (rmap); |
| 3382 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3383 | } |
| 3384 | else |
| 3385 | { |
| 3386 | if (bgp_static->rmap.name) |
| 3387 | free (bgp_static->rmap.name); |
| 3388 | bgp_static->rmap.name = NULL; |
| 3389 | bgp_static->rmap.map = NULL; |
| 3390 | bgp_static->valid = 0; |
| 3391 | } |
| 3392 | bgp_unlock_node (rn); |
| 3393 | } |
| 3394 | else |
| 3395 | { |
| 3396 | /* New configuration. */ |
| 3397 | bgp_static = bgp_static_new (); |
| 3398 | bgp_static->backdoor = backdoor; |
| 3399 | bgp_static->valid = 0; |
| 3400 | bgp_static->igpmetric = 0; |
| 3401 | bgp_static->igpnexthop.s_addr = 0; |
| 3402 | if (rmap) |
| 3403 | { |
| 3404 | if (bgp_static->rmap.name) |
| 3405 | free (bgp_static->rmap.name); |
| 3406 | bgp_static->rmap.name = strdup (rmap); |
| 3407 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3408 | } |
| 3409 | rn->info = bgp_static; |
| 3410 | } |
| 3411 | |
| 3412 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3413 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3414 | { |
| 3415 | bgp_static->valid = 1; |
| 3416 | |
| 3417 | if (need_update) |
| 3418 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3419 | |
| 3420 | if (! bgp_static->backdoor) |
| 3421 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3422 | } |
| 3423 | |
| 3424 | return CMD_SUCCESS; |
| 3425 | } |
| 3426 | |
| 3427 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3428 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3429 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3430 | u_int16_t afi, u_char safi) |
| 3431 | { |
| 3432 | int ret; |
| 3433 | struct prefix p; |
| 3434 | struct bgp_static *bgp_static; |
| 3435 | struct bgp_node *rn; |
| 3436 | |
| 3437 | /* Convert IP prefix string to struct prefix. */ |
| 3438 | ret = str2prefix (ip_str, &p); |
| 3439 | if (! ret) |
| 3440 | { |
| 3441 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3442 | return CMD_WARNING; |
| 3443 | } |
| 3444 | #ifdef HAVE_IPV6 |
| 3445 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3446 | { |
| 3447 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3448 | VTY_NEWLINE); |
| 3449 | return CMD_WARNING; |
| 3450 | } |
| 3451 | #endif /* HAVE_IPV6 */ |
| 3452 | |
| 3453 | apply_mask (&p); |
| 3454 | |
| 3455 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3456 | if (! rn) |
| 3457 | { |
| 3458 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3459 | VTY_NEWLINE); |
| 3460 | return CMD_WARNING; |
| 3461 | } |
| 3462 | |
| 3463 | bgp_static = rn->info; |
| 3464 | |
| 3465 | /* Update BGP RIB. */ |
| 3466 | if (! bgp_static->backdoor) |
| 3467 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3468 | |
| 3469 | /* Clear configuration. */ |
| 3470 | bgp_static_free (bgp_static); |
| 3471 | rn->info = NULL; |
| 3472 | bgp_unlock_node (rn); |
| 3473 | bgp_unlock_node (rn); |
| 3474 | |
| 3475 | return CMD_SUCCESS; |
| 3476 | } |
| 3477 | |
| 3478 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3479 | instance. */ |
| 3480 | void |
| 3481 | bgp_static_delete (struct bgp *bgp) |
| 3482 | { |
| 3483 | afi_t afi; |
| 3484 | safi_t safi; |
| 3485 | struct bgp_node *rn; |
| 3486 | struct bgp_node *rm; |
| 3487 | struct bgp_table *table; |
| 3488 | struct bgp_static *bgp_static; |
| 3489 | |
| 3490 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3491 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3492 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3493 | if (rn->info != NULL) |
| 3494 | { |
| 3495 | if (safi == SAFI_MPLS_VPN) |
| 3496 | { |
| 3497 | table = rn->info; |
| 3498 | |
| 3499 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3500 | { |
| 3501 | bgp_static = rn->info; |
| 3502 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3503 | AFI_IP, SAFI_MPLS_VPN, |
| 3504 | (struct prefix_rd *)&rn->p, |
| 3505 | bgp_static->tag); |
| 3506 | bgp_static_free (bgp_static); |
| 3507 | rn->info = NULL; |
| 3508 | bgp_unlock_node (rn); |
| 3509 | } |
| 3510 | } |
| 3511 | else |
| 3512 | { |
| 3513 | bgp_static = rn->info; |
| 3514 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3515 | bgp_static_free (bgp_static); |
| 3516 | rn->info = NULL; |
| 3517 | bgp_unlock_node (rn); |
| 3518 | } |
| 3519 | } |
| 3520 | } |
| 3521 | |
| 3522 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3523 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3524 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3525 | { |
| 3526 | int ret; |
| 3527 | struct prefix p; |
| 3528 | struct prefix_rd prd; |
| 3529 | struct bgp *bgp; |
| 3530 | struct bgp_node *prn; |
| 3531 | struct bgp_node *rn; |
| 3532 | struct bgp_table *table; |
| 3533 | struct bgp_static *bgp_static; |
| 3534 | u_char tag[3]; |
| 3535 | |
| 3536 | bgp = vty->index; |
| 3537 | |
| 3538 | ret = str2prefix (ip_str, &p); |
| 3539 | if (! ret) |
| 3540 | { |
| 3541 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3542 | return CMD_WARNING; |
| 3543 | } |
| 3544 | apply_mask (&p); |
| 3545 | |
| 3546 | ret = str2prefix_rd (rd_str, &prd); |
| 3547 | if (! ret) |
| 3548 | { |
| 3549 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3550 | return CMD_WARNING; |
| 3551 | } |
| 3552 | |
| 3553 | ret = str2tag (tag_str, tag); |
| 3554 | if (! ret) |
| 3555 | { |
| 3556 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3557 | return CMD_WARNING; |
| 3558 | } |
| 3559 | |
| 3560 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3561 | (struct prefix *)&prd); |
| 3562 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3563 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3564 | else |
| 3565 | bgp_unlock_node (prn); |
| 3566 | table = prn->info; |
| 3567 | |
| 3568 | rn = bgp_node_get (table, &p); |
| 3569 | |
| 3570 | if (rn->info) |
| 3571 | { |
| 3572 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3573 | bgp_unlock_node (rn); |
| 3574 | } |
| 3575 | else |
| 3576 | { |
| 3577 | /* New configuration. */ |
| 3578 | bgp_static = bgp_static_new (); |
| 3579 | bgp_static->valid = 1; |
| 3580 | memcpy (bgp_static->tag, tag, 3); |
| 3581 | rn->info = bgp_static; |
| 3582 | |
| 3583 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3584 | } |
| 3585 | |
| 3586 | return CMD_SUCCESS; |
| 3587 | } |
| 3588 | |
| 3589 | /* Configure static BGP network. */ |
| 3590 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3591 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3592 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3593 | { |
| 3594 | int ret; |
| 3595 | struct bgp *bgp; |
| 3596 | struct prefix p; |
| 3597 | struct prefix_rd prd; |
| 3598 | struct bgp_node *prn; |
| 3599 | struct bgp_node *rn; |
| 3600 | struct bgp_table *table; |
| 3601 | struct bgp_static *bgp_static; |
| 3602 | u_char tag[3]; |
| 3603 | |
| 3604 | bgp = vty->index; |
| 3605 | |
| 3606 | /* Convert IP prefix string to struct prefix. */ |
| 3607 | ret = str2prefix (ip_str, &p); |
| 3608 | if (! ret) |
| 3609 | { |
| 3610 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3611 | return CMD_WARNING; |
| 3612 | } |
| 3613 | apply_mask (&p); |
| 3614 | |
| 3615 | ret = str2prefix_rd (rd_str, &prd); |
| 3616 | if (! ret) |
| 3617 | { |
| 3618 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3619 | return CMD_WARNING; |
| 3620 | } |
| 3621 | |
| 3622 | ret = str2tag (tag_str, tag); |
| 3623 | if (! ret) |
| 3624 | { |
| 3625 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3626 | return CMD_WARNING; |
| 3627 | } |
| 3628 | |
| 3629 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3630 | (struct prefix *)&prd); |
| 3631 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3632 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3633 | else |
| 3634 | bgp_unlock_node (prn); |
| 3635 | table = prn->info; |
| 3636 | |
| 3637 | rn = bgp_node_lookup (table, &p); |
| 3638 | |
| 3639 | if (rn) |
| 3640 | { |
| 3641 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3642 | |
| 3643 | bgp_static = rn->info; |
| 3644 | bgp_static_free (bgp_static); |
| 3645 | rn->info = NULL; |
| 3646 | bgp_unlock_node (rn); |
| 3647 | bgp_unlock_node (rn); |
| 3648 | } |
| 3649 | else |
| 3650 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3651 | |
| 3652 | return CMD_SUCCESS; |
| 3653 | } |
| 3654 | |
| 3655 | DEFUN (bgp_network, |
| 3656 | bgp_network_cmd, |
| 3657 | "network A.B.C.D/M", |
| 3658 | "Specify a network to announce via BGP\n" |
| 3659 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3660 | { |
| 3661 | return bgp_static_set (vty, vty->index, argv[0], |
| 3662 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3663 | } |
| 3664 | |
| 3665 | DEFUN (bgp_network_route_map, |
| 3666 | bgp_network_route_map_cmd, |
| 3667 | "network A.B.C.D/M route-map WORD", |
| 3668 | "Specify a network to announce via BGP\n" |
| 3669 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3670 | "Route-map to modify the attributes\n" |
| 3671 | "Name of the route map\n") |
| 3672 | { |
| 3673 | return bgp_static_set (vty, vty->index, argv[0], |
| 3674 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3675 | } |
| 3676 | |
| 3677 | DEFUN (bgp_network_backdoor, |
| 3678 | bgp_network_backdoor_cmd, |
| 3679 | "network A.B.C.D/M backdoor", |
| 3680 | "Specify a network to announce via BGP\n" |
| 3681 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3682 | "Specify a BGP backdoor route\n") |
| 3683 | { |
| 3684 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3685 | } |
| 3686 | |
| 3687 | DEFUN (bgp_network_mask, |
| 3688 | bgp_network_mask_cmd, |
| 3689 | "network A.B.C.D mask A.B.C.D", |
| 3690 | "Specify a network to announce via BGP\n" |
| 3691 | "Network number\n" |
| 3692 | "Network mask\n" |
| 3693 | "Network mask\n") |
| 3694 | { |
| 3695 | int ret; |
| 3696 | char prefix_str[BUFSIZ]; |
| 3697 | |
| 3698 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3699 | if (! ret) |
| 3700 | { |
| 3701 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3702 | return CMD_WARNING; |
| 3703 | } |
| 3704 | |
| 3705 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3706 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3707 | } |
| 3708 | |
| 3709 | DEFUN (bgp_network_mask_route_map, |
| 3710 | bgp_network_mask_route_map_cmd, |
| 3711 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 3712 | "Specify a network to announce via BGP\n" |
| 3713 | "Network number\n" |
| 3714 | "Network mask\n" |
| 3715 | "Network mask\n" |
| 3716 | "Route-map to modify the attributes\n" |
| 3717 | "Name of the route map\n") |
| 3718 | { |
| 3719 | int ret; |
| 3720 | char prefix_str[BUFSIZ]; |
| 3721 | |
| 3722 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3723 | if (! ret) |
| 3724 | { |
| 3725 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3726 | return CMD_WARNING; |
| 3727 | } |
| 3728 | |
| 3729 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3730 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
| 3731 | } |
| 3732 | |
| 3733 | DEFUN (bgp_network_mask_backdoor, |
| 3734 | bgp_network_mask_backdoor_cmd, |
| 3735 | "network A.B.C.D mask A.B.C.D backdoor", |
| 3736 | "Specify a network to announce via BGP\n" |
| 3737 | "Network number\n" |
| 3738 | "Network mask\n" |
| 3739 | "Network mask\n" |
| 3740 | "Specify a BGP backdoor route\n") |
| 3741 | { |
| 3742 | int ret; |
| 3743 | char prefix_str[BUFSIZ]; |
| 3744 | |
| 3745 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3746 | if (! ret) |
| 3747 | { |
| 3748 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3749 | return CMD_WARNING; |
| 3750 | } |
| 3751 | |
| 3752 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3753 | } |
| 3754 | |
| 3755 | DEFUN (bgp_network_mask_natural, |
| 3756 | bgp_network_mask_natural_cmd, |
| 3757 | "network A.B.C.D", |
| 3758 | "Specify a network to announce via BGP\n" |
| 3759 | "Network number\n") |
| 3760 | { |
| 3761 | int ret; |
| 3762 | char prefix_str[BUFSIZ]; |
| 3763 | |
| 3764 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3765 | if (! ret) |
| 3766 | { |
| 3767 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3768 | return CMD_WARNING; |
| 3769 | } |
| 3770 | |
| 3771 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3772 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3773 | } |
| 3774 | |
| 3775 | DEFUN (bgp_network_mask_natural_route_map, |
| 3776 | bgp_network_mask_natural_route_map_cmd, |
| 3777 | "network A.B.C.D route-map WORD", |
| 3778 | "Specify a network to announce via BGP\n" |
| 3779 | "Network number\n" |
| 3780 | "Route-map to modify the attributes\n" |
| 3781 | "Name of the route map\n") |
| 3782 | { |
| 3783 | int ret; |
| 3784 | char prefix_str[BUFSIZ]; |
| 3785 | |
| 3786 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3787 | if (! ret) |
| 3788 | { |
| 3789 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3790 | return CMD_WARNING; |
| 3791 | } |
| 3792 | |
| 3793 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3794 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3795 | } |
| 3796 | |
| 3797 | DEFUN (bgp_network_mask_natural_backdoor, |
| 3798 | bgp_network_mask_natural_backdoor_cmd, |
| 3799 | "network A.B.C.D backdoor", |
| 3800 | "Specify a network to announce via BGP\n" |
| 3801 | "Network number\n" |
| 3802 | "Specify a BGP backdoor route\n") |
| 3803 | { |
| 3804 | int ret; |
| 3805 | char prefix_str[BUFSIZ]; |
| 3806 | |
| 3807 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3808 | if (! ret) |
| 3809 | { |
| 3810 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3811 | return CMD_WARNING; |
| 3812 | } |
| 3813 | |
| 3814 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3815 | } |
| 3816 | |
| 3817 | DEFUN (no_bgp_network, |
| 3818 | no_bgp_network_cmd, |
| 3819 | "no network A.B.C.D/M", |
| 3820 | NO_STR |
| 3821 | "Specify a network to announce via BGP\n" |
| 3822 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3823 | { |
| 3824 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 3825 | bgp_node_safi (vty)); |
| 3826 | } |
| 3827 | |
| 3828 | ALIAS (no_bgp_network, |
| 3829 | no_bgp_network_route_map_cmd, |
| 3830 | "no network A.B.C.D/M route-map WORD", |
| 3831 | NO_STR |
| 3832 | "Specify a network to announce via BGP\n" |
| 3833 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3834 | "Route-map to modify the attributes\n" |
| 3835 | "Name of the route map\n") |
| 3836 | |
| 3837 | ALIAS (no_bgp_network, |
| 3838 | no_bgp_network_backdoor_cmd, |
| 3839 | "no network A.B.C.D/M backdoor", |
| 3840 | NO_STR |
| 3841 | "Specify a network to announce via BGP\n" |
| 3842 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3843 | "Specify a BGP backdoor route\n") |
| 3844 | |
| 3845 | DEFUN (no_bgp_network_mask, |
| 3846 | no_bgp_network_mask_cmd, |
| 3847 | "no network A.B.C.D mask A.B.C.D", |
| 3848 | NO_STR |
| 3849 | "Specify a network to announce via BGP\n" |
| 3850 | "Network number\n" |
| 3851 | "Network mask\n" |
| 3852 | "Network mask\n") |
| 3853 | { |
| 3854 | int ret; |
| 3855 | char prefix_str[BUFSIZ]; |
| 3856 | |
| 3857 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3858 | if (! ret) |
| 3859 | { |
| 3860 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3861 | return CMD_WARNING; |
| 3862 | } |
| 3863 | |
| 3864 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3865 | bgp_node_safi (vty)); |
| 3866 | } |
| 3867 | |
| 3868 | ALIAS (no_bgp_network_mask, |
| 3869 | no_bgp_network_mask_route_map_cmd, |
| 3870 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 3871 | NO_STR |
| 3872 | "Specify a network to announce via BGP\n" |
| 3873 | "Network number\n" |
| 3874 | "Network mask\n" |
| 3875 | "Network mask\n" |
| 3876 | "Route-map to modify the attributes\n" |
| 3877 | "Name of the route map\n") |
| 3878 | |
| 3879 | ALIAS (no_bgp_network_mask, |
| 3880 | no_bgp_network_mask_backdoor_cmd, |
| 3881 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 3882 | NO_STR |
| 3883 | "Specify a network to announce via BGP\n" |
| 3884 | "Network number\n" |
| 3885 | "Network mask\n" |
| 3886 | "Network mask\n" |
| 3887 | "Specify a BGP backdoor route\n") |
| 3888 | |
| 3889 | DEFUN (no_bgp_network_mask_natural, |
| 3890 | no_bgp_network_mask_natural_cmd, |
| 3891 | "no network A.B.C.D", |
| 3892 | NO_STR |
| 3893 | "Specify a network to announce via BGP\n" |
| 3894 | "Network number\n") |
| 3895 | { |
| 3896 | int ret; |
| 3897 | char prefix_str[BUFSIZ]; |
| 3898 | |
| 3899 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3900 | if (! ret) |
| 3901 | { |
| 3902 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3903 | return CMD_WARNING; |
| 3904 | } |
| 3905 | |
| 3906 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3907 | bgp_node_safi (vty)); |
| 3908 | } |
| 3909 | |
| 3910 | ALIAS (no_bgp_network_mask_natural, |
| 3911 | no_bgp_network_mask_natural_route_map_cmd, |
| 3912 | "no network A.B.C.D route-map WORD", |
| 3913 | NO_STR |
| 3914 | "Specify a network to announce via BGP\n" |
| 3915 | "Network number\n" |
| 3916 | "Route-map to modify the attributes\n" |
| 3917 | "Name of the route map\n") |
| 3918 | |
| 3919 | ALIAS (no_bgp_network_mask_natural, |
| 3920 | no_bgp_network_mask_natural_backdoor_cmd, |
| 3921 | "no network A.B.C.D backdoor", |
| 3922 | NO_STR |
| 3923 | "Specify a network to announce via BGP\n" |
| 3924 | "Network number\n" |
| 3925 | "Specify a BGP backdoor route\n") |
| 3926 | |
| 3927 | #ifdef HAVE_IPV6 |
| 3928 | DEFUN (ipv6_bgp_network, |
| 3929 | ipv6_bgp_network_cmd, |
| 3930 | "network X:X::X:X/M", |
| 3931 | "Specify a network to announce via BGP\n" |
| 3932 | "IPv6 prefix <network>/<length>\n") |
| 3933 | { |
| 3934 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 3935 | } |
| 3936 | |
| 3937 | DEFUN (ipv6_bgp_network_route_map, |
| 3938 | ipv6_bgp_network_route_map_cmd, |
| 3939 | "network X:X::X:X/M route-map WORD", |
| 3940 | "Specify a network to announce via BGP\n" |
| 3941 | "IPv6 prefix <network>/<length>\n" |
| 3942 | "Route-map to modify the attributes\n" |
| 3943 | "Name of the route map\n") |
| 3944 | { |
| 3945 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
| 3946 | bgp_node_safi (vty), argv[1], 0); |
| 3947 | } |
| 3948 | |
| 3949 | DEFUN (no_ipv6_bgp_network, |
| 3950 | no_ipv6_bgp_network_cmd, |
| 3951 | "no network X:X::X:X/M", |
| 3952 | NO_STR |
| 3953 | "Specify a network to announce via BGP\n" |
| 3954 | "IPv6 prefix <network>/<length>\n") |
| 3955 | { |
| 3956 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); |
| 3957 | } |
| 3958 | |
| 3959 | ALIAS (no_ipv6_bgp_network, |
| 3960 | no_ipv6_bgp_network_route_map_cmd, |
| 3961 | "no network X:X::X:X/M route-map WORD", |
| 3962 | NO_STR |
| 3963 | "Specify a network to announce via BGP\n" |
| 3964 | "IPv6 prefix <network>/<length>\n" |
| 3965 | "Route-map to modify the attributes\n" |
| 3966 | "Name of the route map\n") |
| 3967 | |
| 3968 | ALIAS (ipv6_bgp_network, |
| 3969 | old_ipv6_bgp_network_cmd, |
| 3970 | "ipv6 bgp network X:X::X:X/M", |
| 3971 | IPV6_STR |
| 3972 | BGP_STR |
| 3973 | "Specify a network to announce via BGP\n" |
| 3974 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3975 | |
| 3976 | ALIAS (no_ipv6_bgp_network, |
| 3977 | old_no_ipv6_bgp_network_cmd, |
| 3978 | "no ipv6 bgp network X:X::X:X/M", |
| 3979 | NO_STR |
| 3980 | IPV6_STR |
| 3981 | BGP_STR |
| 3982 | "Specify a network to announce via BGP\n" |
| 3983 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3984 | #endif /* HAVE_IPV6 */ |
| 3985 | |
| 3986 | /* Aggreagete address: |
| 3987 | |
| 3988 | advertise-map Set condition to advertise attribute |
| 3989 | as-set Generate AS set path information |
| 3990 | attribute-map Set attributes of aggregate |
| 3991 | route-map Set parameters of aggregate |
| 3992 | summary-only Filter more specific routes from updates |
| 3993 | suppress-map Conditionally filter more specific routes from updates |
| 3994 | <cr> |
| 3995 | */ |
| 3996 | struct bgp_aggregate |
| 3997 | { |
| 3998 | /* Summary-only flag. */ |
| 3999 | u_char summary_only; |
| 4000 | |
| 4001 | /* AS set generation. */ |
| 4002 | u_char as_set; |
| 4003 | |
| 4004 | /* Route-map for aggregated route. */ |
| 4005 | struct route_map *map; |
| 4006 | |
| 4007 | /* Suppress-count. */ |
| 4008 | unsigned long count; |
| 4009 | |
| 4010 | /* SAFI configuration. */ |
| 4011 | safi_t safi; |
| 4012 | }; |
| 4013 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4014 | static struct bgp_aggregate * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4015 | bgp_aggregate_new () |
| 4016 | { |
| 4017 | struct bgp_aggregate *new; |
| 4018 | new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
| 4019 | memset (new, 0, sizeof (struct bgp_aggregate)); |
| 4020 | return new; |
| 4021 | } |
| 4022 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4023 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4024 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4025 | { |
| 4026 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4027 | } |
| 4028 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4029 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4030 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4031 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4032 | struct bgp_aggregate *aggregate) |
| 4033 | { |
| 4034 | struct bgp_table *table; |
| 4035 | struct bgp_node *top; |
| 4036 | struct bgp_node *rn; |
| 4037 | u_char origin; |
| 4038 | struct aspath *aspath = NULL; |
| 4039 | struct aspath *asmerge = NULL; |
| 4040 | struct community *community = NULL; |
| 4041 | struct community *commerge = NULL; |
| 4042 | struct in_addr nexthop; |
| 4043 | u_int32_t med = 0; |
| 4044 | struct bgp_info *ri; |
| 4045 | struct bgp_info *new; |
| 4046 | int first = 1; |
| 4047 | unsigned long match = 0; |
| 4048 | |
| 4049 | /* Record adding route's nexthop and med. */ |
| 4050 | if (rinew) |
| 4051 | { |
| 4052 | nexthop = rinew->attr->nexthop; |
| 4053 | med = rinew->attr->med; |
| 4054 | } |
| 4055 | |
| 4056 | /* ORIGIN attribute: If at least one route among routes that are |
| 4057 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4058 | aggregated route must have the ORIGIN attribute with the value |
| 4059 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4060 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4061 | route must have the origin attribute with the value EGP. In all |
| 4062 | other case the value of the ORIGIN attribute of the aggregated |
| 4063 | route is INTERNAL. */ |
| 4064 | origin = BGP_ORIGIN_IGP; |
| 4065 | |
| 4066 | table = bgp->rib[afi][safi]; |
| 4067 | |
| 4068 | top = bgp_node_get (table, p); |
| 4069 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4070 | if (rn->p.prefixlen > p->prefixlen) |
| 4071 | { |
| 4072 | match = 0; |
| 4073 | |
| 4074 | for (ri = rn->info; ri; ri = ri->next) |
| 4075 | { |
| 4076 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4077 | continue; |
| 4078 | |
| 4079 | if (del && ri == del) |
| 4080 | continue; |
| 4081 | |
| 4082 | if (! rinew && first) |
| 4083 | { |
| 4084 | nexthop = ri->attr->nexthop; |
| 4085 | med = ri->attr->med; |
| 4086 | first = 0; |
| 4087 | } |
| 4088 | |
| 4089 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4090 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4091 | || ri->attr->med != med) |
| 4092 | { |
| 4093 | if (aspath) |
| 4094 | aspath_free (aspath); |
| 4095 | if (community) |
| 4096 | community_free (community); |
| 4097 | bgp_unlock_node (rn); |
| 4098 | bgp_unlock_node (top); |
| 4099 | return; |
| 4100 | } |
| 4101 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4102 | |
| 4103 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4104 | { |
| 4105 | if (aggregate->summary_only) |
| 4106 | { |
| 4107 | ri->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4108 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4109 | match++; |
| 4110 | } |
| 4111 | |
| 4112 | aggregate->count++; |
| 4113 | |
| 4114 | if (aggregate->as_set) |
| 4115 | { |
| 4116 | if (origin < ri->attr->origin) |
| 4117 | origin = ri->attr->origin; |
| 4118 | |
| 4119 | if (aspath) |
| 4120 | { |
| 4121 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4122 | aspath_free (aspath); |
| 4123 | aspath = asmerge; |
| 4124 | } |
| 4125 | else |
| 4126 | aspath = aspath_dup (ri->attr->aspath); |
| 4127 | |
| 4128 | if (ri->attr->community) |
| 4129 | { |
| 4130 | if (community) |
| 4131 | { |
| 4132 | commerge = community_merge (community, |
| 4133 | ri->attr->community); |
| 4134 | community = community_uniq_sort (commerge); |
| 4135 | community_free (commerge); |
| 4136 | } |
| 4137 | else |
| 4138 | community = community_dup (ri->attr->community); |
| 4139 | } |
| 4140 | } |
| 4141 | } |
| 4142 | } |
| 4143 | if (match) |
| 4144 | bgp_process (bgp, rn, afi, safi); |
| 4145 | } |
| 4146 | bgp_unlock_node (top); |
| 4147 | |
| 4148 | if (rinew) |
| 4149 | { |
| 4150 | aggregate->count++; |
| 4151 | |
| 4152 | if (aggregate->summary_only) |
| 4153 | rinew->suppress++; |
| 4154 | |
| 4155 | if (aggregate->as_set) |
| 4156 | { |
| 4157 | if (origin < rinew->attr->origin) |
| 4158 | origin = rinew->attr->origin; |
| 4159 | |
| 4160 | if (aspath) |
| 4161 | { |
| 4162 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4163 | aspath_free (aspath); |
| 4164 | aspath = asmerge; |
| 4165 | } |
| 4166 | else |
| 4167 | aspath = aspath_dup (rinew->attr->aspath); |
| 4168 | |
| 4169 | if (rinew->attr->community) |
| 4170 | { |
| 4171 | if (community) |
| 4172 | { |
| 4173 | commerge = community_merge (community, |
| 4174 | rinew->attr->community); |
| 4175 | community = community_uniq_sort (commerge); |
| 4176 | community_free (commerge); |
| 4177 | } |
| 4178 | else |
| 4179 | community = community_dup (rinew->attr->community); |
| 4180 | } |
| 4181 | } |
| 4182 | } |
| 4183 | |
| 4184 | if (aggregate->count > 0) |
| 4185 | { |
| 4186 | rn = bgp_node_get (table, p); |
| 4187 | new = bgp_info_new (); |
| 4188 | new->type = ZEBRA_ROUTE_BGP; |
| 4189 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4190 | new->peer = bgp->peer_self; |
| 4191 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4192 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4193 | new->uptime = time (NULL); |
| 4194 | |
| 4195 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4196 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4197 | bgp_process (bgp, rn, afi, safi); |
| 4198 | } |
| 4199 | else |
| 4200 | { |
| 4201 | if (aspath) |
| 4202 | aspath_free (aspath); |
| 4203 | if (community) |
| 4204 | community_free (community); |
| 4205 | } |
| 4206 | } |
| 4207 | |
| 4208 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4209 | struct bgp_aggregate *); |
| 4210 | |
| 4211 | void |
| 4212 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4213 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4214 | { |
| 4215 | struct bgp_node *child; |
| 4216 | struct bgp_node *rn; |
| 4217 | struct bgp_aggregate *aggregate; |
| 4218 | |
| 4219 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4220 | if (safi == SAFI_MPLS_VPN) |
| 4221 | return; |
| 4222 | |
| 4223 | if (p->prefixlen == 0) |
| 4224 | return; |
| 4225 | |
| 4226 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4227 | return; |
| 4228 | |
| 4229 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4230 | |
| 4231 | /* Aggregate address configuration check. */ |
| 4232 | for (rn = child; rn; rn = rn->parent) |
| 4233 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4234 | { |
| 4235 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4236 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4237 | } |
| 4238 | bgp_unlock_node (child); |
| 4239 | } |
| 4240 | |
| 4241 | void |
| 4242 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4243 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4244 | { |
| 4245 | struct bgp_node *child; |
| 4246 | struct bgp_node *rn; |
| 4247 | struct bgp_aggregate *aggregate; |
| 4248 | |
| 4249 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4250 | if (safi == SAFI_MPLS_VPN) |
| 4251 | return; |
| 4252 | |
| 4253 | if (p->prefixlen == 0) |
| 4254 | return; |
| 4255 | |
| 4256 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4257 | |
| 4258 | /* Aggregate address configuration check. */ |
| 4259 | for (rn = child; rn; rn = rn->parent) |
| 4260 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4261 | { |
| 4262 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4263 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4264 | } |
| 4265 | bgp_unlock_node (child); |
| 4266 | } |
| 4267 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4268 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4269 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4270 | struct bgp_aggregate *aggregate) |
| 4271 | { |
| 4272 | struct bgp_table *table; |
| 4273 | struct bgp_node *top; |
| 4274 | struct bgp_node *rn; |
| 4275 | struct bgp_info *new; |
| 4276 | struct bgp_info *ri; |
| 4277 | unsigned long match; |
| 4278 | u_char origin = BGP_ORIGIN_IGP; |
| 4279 | struct aspath *aspath = NULL; |
| 4280 | struct aspath *asmerge = NULL; |
| 4281 | struct community *community = NULL; |
| 4282 | struct community *commerge = NULL; |
| 4283 | |
| 4284 | table = bgp->rib[afi][safi]; |
| 4285 | |
| 4286 | /* Sanity check. */ |
| 4287 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4288 | return; |
| 4289 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4290 | return; |
| 4291 | |
| 4292 | /* If routes exists below this node, generate aggregate routes. */ |
| 4293 | top = bgp_node_get (table, p); |
| 4294 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4295 | if (rn->p.prefixlen > p->prefixlen) |
| 4296 | { |
| 4297 | match = 0; |
| 4298 | |
| 4299 | for (ri = rn->info; ri; ri = ri->next) |
| 4300 | { |
| 4301 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4302 | continue; |
| 4303 | |
| 4304 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4305 | { |
| 4306 | /* summary-only aggregate route suppress aggregated |
| 4307 | route announcement. */ |
| 4308 | if (aggregate->summary_only) |
| 4309 | { |
| 4310 | ri->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4311 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4312 | match++; |
| 4313 | } |
| 4314 | /* as-set aggregate route generate origin, as path, |
| 4315 | community aggregation. */ |
| 4316 | if (aggregate->as_set) |
| 4317 | { |
| 4318 | if (origin < ri->attr->origin) |
| 4319 | origin = ri->attr->origin; |
| 4320 | |
| 4321 | if (aspath) |
| 4322 | { |
| 4323 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4324 | aspath_free (aspath); |
| 4325 | aspath = asmerge; |
| 4326 | } |
| 4327 | else |
| 4328 | aspath = aspath_dup (ri->attr->aspath); |
| 4329 | |
| 4330 | if (ri->attr->community) |
| 4331 | { |
| 4332 | if (community) |
| 4333 | { |
| 4334 | commerge = community_merge (community, |
| 4335 | ri->attr->community); |
| 4336 | community = community_uniq_sort (commerge); |
| 4337 | community_free (commerge); |
| 4338 | } |
| 4339 | else |
| 4340 | community = community_dup (ri->attr->community); |
| 4341 | } |
| 4342 | } |
| 4343 | aggregate->count++; |
| 4344 | } |
| 4345 | } |
| 4346 | |
| 4347 | /* If this node is suppressed, process the change. */ |
| 4348 | if (match) |
| 4349 | bgp_process (bgp, rn, afi, safi); |
| 4350 | } |
| 4351 | bgp_unlock_node (top); |
| 4352 | |
| 4353 | /* Add aggregate route to BGP table. */ |
| 4354 | if (aggregate->count) |
| 4355 | { |
| 4356 | rn = bgp_node_get (table, p); |
| 4357 | |
| 4358 | new = bgp_info_new (); |
| 4359 | new->type = ZEBRA_ROUTE_BGP; |
| 4360 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4361 | new->peer = bgp->peer_self; |
| 4362 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4363 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4364 | new->uptime = time (NULL); |
| 4365 | |
| 4366 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4367 | bgp_unlock_node (rn); |
| 4368 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4369 | /* Process change. */ |
| 4370 | bgp_process (bgp, rn, afi, safi); |
| 4371 | } |
| 4372 | } |
| 4373 | |
| 4374 | void |
| 4375 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4376 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4377 | { |
| 4378 | struct bgp_table *table; |
| 4379 | struct bgp_node *top; |
| 4380 | struct bgp_node *rn; |
| 4381 | struct bgp_info *ri; |
| 4382 | unsigned long match; |
| 4383 | |
| 4384 | table = bgp->rib[afi][safi]; |
| 4385 | |
| 4386 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4387 | return; |
| 4388 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4389 | return; |
| 4390 | |
| 4391 | /* If routes exists below this node, generate aggregate routes. */ |
| 4392 | top = bgp_node_get (table, p); |
| 4393 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4394 | if (rn->p.prefixlen > p->prefixlen) |
| 4395 | { |
| 4396 | match = 0; |
| 4397 | |
| 4398 | for (ri = rn->info; ri; ri = ri->next) |
| 4399 | { |
| 4400 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4401 | continue; |
| 4402 | |
| 4403 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4404 | { |
| 4405 | if (aggregate->summary_only) |
| 4406 | { |
| 4407 | ri->suppress--; |
| 4408 | |
| 4409 | if (ri->suppress == 0) |
| 4410 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4411 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4412 | match++; |
| 4413 | } |
| 4414 | } |
| 4415 | aggregate->count--; |
| 4416 | } |
| 4417 | } |
| 4418 | |
| 4419 | /* If this node is suppressed, process the change. */ |
| 4420 | if (match) |
| 4421 | bgp_process (bgp, rn, afi, safi); |
| 4422 | } |
| 4423 | bgp_unlock_node (top); |
| 4424 | |
| 4425 | /* Delete aggregate route from BGP table. */ |
| 4426 | rn = bgp_node_get (table, p); |
| 4427 | |
| 4428 | for (ri = rn->info; ri; ri = ri->next) |
| 4429 | if (ri->peer == bgp->peer_self |
| 4430 | && ri->type == ZEBRA_ROUTE_BGP |
| 4431 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4432 | break; |
| 4433 | |
| 4434 | /* Withdraw static BGP route from routing table. */ |
| 4435 | if (ri) |
| 4436 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4437 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4438 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4439 | } |
| 4440 | |
| 4441 | /* Unlock bgp_node_lookup. */ |
| 4442 | bgp_unlock_node (rn); |
| 4443 | } |
| 4444 | |
| 4445 | /* Aggregate route attribute. */ |
| 4446 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4447 | #define AGGREGATE_AS_SET 1 |
| 4448 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4449 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4450 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
| 4451 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4452 | u_char summary_only, u_char as_set) |
| 4453 | { |
| 4454 | int ret; |
| 4455 | struct prefix p; |
| 4456 | struct bgp_node *rn; |
| 4457 | struct bgp *bgp; |
| 4458 | struct bgp_aggregate *aggregate; |
| 4459 | |
| 4460 | /* Convert string to prefix structure. */ |
| 4461 | ret = str2prefix (prefix_str, &p); |
| 4462 | if (!ret) |
| 4463 | { |
| 4464 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4465 | return CMD_WARNING; |
| 4466 | } |
| 4467 | apply_mask (&p); |
| 4468 | |
| 4469 | /* Get BGP structure. */ |
| 4470 | bgp = vty->index; |
| 4471 | |
| 4472 | /* Old configuration check. */ |
| 4473 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4474 | |
| 4475 | if (rn->info) |
| 4476 | { |
| 4477 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
| 4478 | bgp_unlock_node (rn); |
| 4479 | return CMD_WARNING; |
| 4480 | } |
| 4481 | |
| 4482 | /* Make aggregate address structure. */ |
| 4483 | aggregate = bgp_aggregate_new (); |
| 4484 | aggregate->summary_only = summary_only; |
| 4485 | aggregate->as_set = as_set; |
| 4486 | aggregate->safi = safi; |
| 4487 | rn->info = aggregate; |
| 4488 | |
| 4489 | /* Aggregate address insert into BGP routing table. */ |
| 4490 | if (safi & SAFI_UNICAST) |
| 4491 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4492 | if (safi & SAFI_MULTICAST) |
| 4493 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4494 | |
| 4495 | return CMD_SUCCESS; |
| 4496 | } |
| 4497 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4498 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4499 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4500 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4501 | { |
| 4502 | int ret; |
| 4503 | struct prefix p; |
| 4504 | struct bgp_node *rn; |
| 4505 | struct bgp *bgp; |
| 4506 | struct bgp_aggregate *aggregate; |
| 4507 | |
| 4508 | /* Convert string to prefix structure. */ |
| 4509 | ret = str2prefix (prefix_str, &p); |
| 4510 | if (!ret) |
| 4511 | { |
| 4512 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4513 | return CMD_WARNING; |
| 4514 | } |
| 4515 | apply_mask (&p); |
| 4516 | |
| 4517 | /* Get BGP structure. */ |
| 4518 | bgp = vty->index; |
| 4519 | |
| 4520 | /* Old configuration check. */ |
| 4521 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4522 | if (! rn) |
| 4523 | { |
| 4524 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4525 | VTY_NEWLINE); |
| 4526 | return CMD_WARNING; |
| 4527 | } |
| 4528 | |
| 4529 | aggregate = rn->info; |
| 4530 | if (aggregate->safi & SAFI_UNICAST) |
| 4531 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4532 | if (aggregate->safi & SAFI_MULTICAST) |
| 4533 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4534 | |
| 4535 | /* Unlock aggregate address configuration. */ |
| 4536 | rn->info = NULL; |
| 4537 | bgp_aggregate_free (aggregate); |
| 4538 | bgp_unlock_node (rn); |
| 4539 | bgp_unlock_node (rn); |
| 4540 | |
| 4541 | return CMD_SUCCESS; |
| 4542 | } |
| 4543 | |
| 4544 | DEFUN (aggregate_address, |
| 4545 | aggregate_address_cmd, |
| 4546 | "aggregate-address A.B.C.D/M", |
| 4547 | "Configure BGP aggregate entries\n" |
| 4548 | "Aggregate prefix\n") |
| 4549 | { |
| 4550 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 4551 | } |
| 4552 | |
| 4553 | DEFUN (aggregate_address_mask, |
| 4554 | aggregate_address_mask_cmd, |
| 4555 | "aggregate-address A.B.C.D A.B.C.D", |
| 4556 | "Configure BGP aggregate entries\n" |
| 4557 | "Aggregate address\n" |
| 4558 | "Aggregate mask\n") |
| 4559 | { |
| 4560 | int ret; |
| 4561 | char prefix_str[BUFSIZ]; |
| 4562 | |
| 4563 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4564 | |
| 4565 | if (! ret) |
| 4566 | { |
| 4567 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4568 | return CMD_WARNING; |
| 4569 | } |
| 4570 | |
| 4571 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4572 | 0, 0); |
| 4573 | } |
| 4574 | |
| 4575 | DEFUN (aggregate_address_summary_only, |
| 4576 | aggregate_address_summary_only_cmd, |
| 4577 | "aggregate-address A.B.C.D/M summary-only", |
| 4578 | "Configure BGP aggregate entries\n" |
| 4579 | "Aggregate prefix\n" |
| 4580 | "Filter more specific routes from updates\n") |
| 4581 | { |
| 4582 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4583 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4584 | } |
| 4585 | |
| 4586 | DEFUN (aggregate_address_mask_summary_only, |
| 4587 | aggregate_address_mask_summary_only_cmd, |
| 4588 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4589 | "Configure BGP aggregate entries\n" |
| 4590 | "Aggregate address\n" |
| 4591 | "Aggregate mask\n" |
| 4592 | "Filter more specific routes from updates\n") |
| 4593 | { |
| 4594 | int ret; |
| 4595 | char prefix_str[BUFSIZ]; |
| 4596 | |
| 4597 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4598 | |
| 4599 | if (! ret) |
| 4600 | { |
| 4601 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4602 | return CMD_WARNING; |
| 4603 | } |
| 4604 | |
| 4605 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4606 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4607 | } |
| 4608 | |
| 4609 | DEFUN (aggregate_address_as_set, |
| 4610 | aggregate_address_as_set_cmd, |
| 4611 | "aggregate-address A.B.C.D/M as-set", |
| 4612 | "Configure BGP aggregate entries\n" |
| 4613 | "Aggregate prefix\n" |
| 4614 | "Generate AS set path information\n") |
| 4615 | { |
| 4616 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4617 | 0, AGGREGATE_AS_SET); |
| 4618 | } |
| 4619 | |
| 4620 | DEFUN (aggregate_address_mask_as_set, |
| 4621 | aggregate_address_mask_as_set_cmd, |
| 4622 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 4623 | "Configure BGP aggregate entries\n" |
| 4624 | "Aggregate address\n" |
| 4625 | "Aggregate mask\n" |
| 4626 | "Generate AS set path information\n") |
| 4627 | { |
| 4628 | int ret; |
| 4629 | char prefix_str[BUFSIZ]; |
| 4630 | |
| 4631 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4632 | |
| 4633 | if (! ret) |
| 4634 | { |
| 4635 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4636 | return CMD_WARNING; |
| 4637 | } |
| 4638 | |
| 4639 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4640 | 0, AGGREGATE_AS_SET); |
| 4641 | } |
| 4642 | |
| 4643 | |
| 4644 | DEFUN (aggregate_address_as_set_summary, |
| 4645 | aggregate_address_as_set_summary_cmd, |
| 4646 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 4647 | "Configure BGP aggregate entries\n" |
| 4648 | "Aggregate prefix\n" |
| 4649 | "Generate AS set path information\n" |
| 4650 | "Filter more specific routes from updates\n") |
| 4651 | { |
| 4652 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4653 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4654 | } |
| 4655 | |
| 4656 | ALIAS (aggregate_address_as_set_summary, |
| 4657 | aggregate_address_summary_as_set_cmd, |
| 4658 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 4659 | "Configure BGP aggregate entries\n" |
| 4660 | "Aggregate prefix\n" |
| 4661 | "Filter more specific routes from updates\n" |
| 4662 | "Generate AS set path information\n") |
| 4663 | |
| 4664 | DEFUN (aggregate_address_mask_as_set_summary, |
| 4665 | aggregate_address_mask_as_set_summary_cmd, |
| 4666 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4667 | "Configure BGP aggregate entries\n" |
| 4668 | "Aggregate address\n" |
| 4669 | "Aggregate mask\n" |
| 4670 | "Generate AS set path information\n" |
| 4671 | "Filter more specific routes from updates\n") |
| 4672 | { |
| 4673 | int ret; |
| 4674 | char prefix_str[BUFSIZ]; |
| 4675 | |
| 4676 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4677 | |
| 4678 | if (! ret) |
| 4679 | { |
| 4680 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4681 | return CMD_WARNING; |
| 4682 | } |
| 4683 | |
| 4684 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4685 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4686 | } |
| 4687 | |
| 4688 | ALIAS (aggregate_address_mask_as_set_summary, |
| 4689 | aggregate_address_mask_summary_as_set_cmd, |
| 4690 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4691 | "Configure BGP aggregate entries\n" |
| 4692 | "Aggregate address\n" |
| 4693 | "Aggregate mask\n" |
| 4694 | "Filter more specific routes from updates\n" |
| 4695 | "Generate AS set path information\n") |
| 4696 | |
| 4697 | DEFUN (no_aggregate_address, |
| 4698 | no_aggregate_address_cmd, |
| 4699 | "no aggregate-address A.B.C.D/M", |
| 4700 | NO_STR |
| 4701 | "Configure BGP aggregate entries\n" |
| 4702 | "Aggregate prefix\n") |
| 4703 | { |
| 4704 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 4705 | } |
| 4706 | |
| 4707 | ALIAS (no_aggregate_address, |
| 4708 | no_aggregate_address_summary_only_cmd, |
| 4709 | "no aggregate-address A.B.C.D/M summary-only", |
| 4710 | NO_STR |
| 4711 | "Configure BGP aggregate entries\n" |
| 4712 | "Aggregate prefix\n" |
| 4713 | "Filter more specific routes from updates\n") |
| 4714 | |
| 4715 | ALIAS (no_aggregate_address, |
| 4716 | no_aggregate_address_as_set_cmd, |
| 4717 | "no aggregate-address A.B.C.D/M as-set", |
| 4718 | NO_STR |
| 4719 | "Configure BGP aggregate entries\n" |
| 4720 | "Aggregate prefix\n" |
| 4721 | "Generate AS set path information\n") |
| 4722 | |
| 4723 | ALIAS (no_aggregate_address, |
| 4724 | no_aggregate_address_as_set_summary_cmd, |
| 4725 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 4726 | NO_STR |
| 4727 | "Configure BGP aggregate entries\n" |
| 4728 | "Aggregate prefix\n" |
| 4729 | "Generate AS set path information\n" |
| 4730 | "Filter more specific routes from updates\n") |
| 4731 | |
| 4732 | ALIAS (no_aggregate_address, |
| 4733 | no_aggregate_address_summary_as_set_cmd, |
| 4734 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 4735 | NO_STR |
| 4736 | "Configure BGP aggregate entries\n" |
| 4737 | "Aggregate prefix\n" |
| 4738 | "Filter more specific routes from updates\n" |
| 4739 | "Generate AS set path information\n") |
| 4740 | |
| 4741 | DEFUN (no_aggregate_address_mask, |
| 4742 | no_aggregate_address_mask_cmd, |
| 4743 | "no aggregate-address A.B.C.D A.B.C.D", |
| 4744 | NO_STR |
| 4745 | "Configure BGP aggregate entries\n" |
| 4746 | "Aggregate address\n" |
| 4747 | "Aggregate mask\n") |
| 4748 | { |
| 4749 | int ret; |
| 4750 | char prefix_str[BUFSIZ]; |
| 4751 | |
| 4752 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4753 | |
| 4754 | if (! ret) |
| 4755 | { |
| 4756 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4757 | return CMD_WARNING; |
| 4758 | } |
| 4759 | |
| 4760 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 4761 | } |
| 4762 | |
| 4763 | ALIAS (no_aggregate_address_mask, |
| 4764 | no_aggregate_address_mask_summary_only_cmd, |
| 4765 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4766 | NO_STR |
| 4767 | "Configure BGP aggregate entries\n" |
| 4768 | "Aggregate address\n" |
| 4769 | "Aggregate mask\n" |
| 4770 | "Filter more specific routes from updates\n") |
| 4771 | |
| 4772 | ALIAS (no_aggregate_address_mask, |
| 4773 | no_aggregate_address_mask_as_set_cmd, |
| 4774 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 4775 | NO_STR |
| 4776 | "Configure BGP aggregate entries\n" |
| 4777 | "Aggregate address\n" |
| 4778 | "Aggregate mask\n" |
| 4779 | "Generate AS set path information\n") |
| 4780 | |
| 4781 | ALIAS (no_aggregate_address_mask, |
| 4782 | no_aggregate_address_mask_as_set_summary_cmd, |
| 4783 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4784 | NO_STR |
| 4785 | "Configure BGP aggregate entries\n" |
| 4786 | "Aggregate address\n" |
| 4787 | "Aggregate mask\n" |
| 4788 | "Generate AS set path information\n" |
| 4789 | "Filter more specific routes from updates\n") |
| 4790 | |
| 4791 | ALIAS (no_aggregate_address_mask, |
| 4792 | no_aggregate_address_mask_summary_as_set_cmd, |
| 4793 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4794 | NO_STR |
| 4795 | "Configure BGP aggregate entries\n" |
| 4796 | "Aggregate address\n" |
| 4797 | "Aggregate mask\n" |
| 4798 | "Filter more specific routes from updates\n" |
| 4799 | "Generate AS set path information\n") |
| 4800 | |
| 4801 | #ifdef HAVE_IPV6 |
| 4802 | DEFUN (ipv6_aggregate_address, |
| 4803 | ipv6_aggregate_address_cmd, |
| 4804 | "aggregate-address X:X::X:X/M", |
| 4805 | "Configure BGP aggregate entries\n" |
| 4806 | "Aggregate prefix\n") |
| 4807 | { |
| 4808 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 4809 | } |
| 4810 | |
| 4811 | DEFUN (ipv6_aggregate_address_summary_only, |
| 4812 | ipv6_aggregate_address_summary_only_cmd, |
| 4813 | "aggregate-address X:X::X:X/M summary-only", |
| 4814 | "Configure BGP aggregate entries\n" |
| 4815 | "Aggregate prefix\n" |
| 4816 | "Filter more specific routes from updates\n") |
| 4817 | { |
| 4818 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 4819 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4820 | } |
| 4821 | |
| 4822 | DEFUN (no_ipv6_aggregate_address, |
| 4823 | no_ipv6_aggregate_address_cmd, |
| 4824 | "no aggregate-address X:X::X:X/M", |
| 4825 | NO_STR |
| 4826 | "Configure BGP aggregate entries\n" |
| 4827 | "Aggregate prefix\n") |
| 4828 | { |
| 4829 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4830 | } |
| 4831 | |
| 4832 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 4833 | no_ipv6_aggregate_address_summary_only_cmd, |
| 4834 | "no aggregate-address X:X::X:X/M summary-only", |
| 4835 | NO_STR |
| 4836 | "Configure BGP aggregate entries\n" |
| 4837 | "Aggregate prefix\n" |
| 4838 | "Filter more specific routes from updates\n") |
| 4839 | { |
| 4840 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4841 | } |
| 4842 | |
| 4843 | ALIAS (ipv6_aggregate_address, |
| 4844 | old_ipv6_aggregate_address_cmd, |
| 4845 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 4846 | IPV6_STR |
| 4847 | BGP_STR |
| 4848 | "Configure BGP aggregate entries\n" |
| 4849 | "Aggregate prefix\n") |
| 4850 | |
| 4851 | ALIAS (ipv6_aggregate_address_summary_only, |
| 4852 | old_ipv6_aggregate_address_summary_only_cmd, |
| 4853 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4854 | IPV6_STR |
| 4855 | BGP_STR |
| 4856 | "Configure BGP aggregate entries\n" |
| 4857 | "Aggregate prefix\n" |
| 4858 | "Filter more specific routes from updates\n") |
| 4859 | |
| 4860 | ALIAS (no_ipv6_aggregate_address, |
| 4861 | old_no_ipv6_aggregate_address_cmd, |
| 4862 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 4863 | NO_STR |
| 4864 | IPV6_STR |
| 4865 | BGP_STR |
| 4866 | "Configure BGP aggregate entries\n" |
| 4867 | "Aggregate prefix\n") |
| 4868 | |
| 4869 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 4870 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 4871 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4872 | NO_STR |
| 4873 | IPV6_STR |
| 4874 | BGP_STR |
| 4875 | "Configure BGP aggregate entries\n" |
| 4876 | "Aggregate prefix\n" |
| 4877 | "Filter more specific routes from updates\n") |
| 4878 | #endif /* HAVE_IPV6 */ |
| 4879 | |
| 4880 | /* Redistribute route treatment. */ |
| 4881 | void |
| 4882 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, |
| 4883 | u_int32_t metric, u_char type) |
| 4884 | { |
| 4885 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4886 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4887 | struct bgp_info *new; |
| 4888 | struct bgp_info *bi; |
| 4889 | struct bgp_info info; |
| 4890 | struct bgp_node *bn; |
| 4891 | struct attr attr; |
| 4892 | struct attr attr_new; |
| 4893 | struct attr *new_attr; |
| 4894 | afi_t afi; |
| 4895 | int ret; |
| 4896 | |
| 4897 | /* Make default attribute. */ |
| 4898 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 4899 | if (nexthop) |
| 4900 | attr.nexthop = *nexthop; |
| 4901 | |
| 4902 | attr.med = metric; |
| 4903 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 4904 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4905 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4906 | { |
| 4907 | afi = family2afi (p->family); |
| 4908 | |
| 4909 | if (bgp->redist[afi][type]) |
| 4910 | { |
| 4911 | /* Copy attribute for modification. */ |
| 4912 | attr_new = attr; |
| 4913 | |
| 4914 | if (bgp->redist_metric_flag[afi][type]) |
| 4915 | attr_new.med = bgp->redist_metric[afi][type]; |
| 4916 | |
| 4917 | /* Apply route-map. */ |
| 4918 | if (bgp->rmap[afi][type].map) |
| 4919 | { |
| 4920 | info.peer = bgp->peer_self; |
| 4921 | info.attr = &attr_new; |
| 4922 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4923 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 4924 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4925 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 4926 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4927 | |
| 4928 | bgp->peer_self->rmap_type = 0; |
| 4929 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4930 | if (ret == RMAP_DENYMATCH) |
| 4931 | { |
| 4932 | /* Free uninterned attribute. */ |
| 4933 | bgp_attr_flush (&attr_new); |
| 4934 | |
| 4935 | /* Unintern original. */ |
| 4936 | aspath_unintern (attr.aspath); |
| 4937 | bgp_redistribute_delete (p, type); |
| 4938 | return; |
| 4939 | } |
| 4940 | } |
| 4941 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4942 | 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] | 4943 | new_attr = bgp_attr_intern (&attr_new); |
| 4944 | |
| 4945 | for (bi = bn->info; bi; bi = bi->next) |
| 4946 | if (bi->peer == bgp->peer_self |
| 4947 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 4948 | break; |
| 4949 | |
| 4950 | if (bi) |
| 4951 | { |
| 4952 | if (attrhash_cmp (bi->attr, new_attr)) |
| 4953 | { |
| 4954 | bgp_attr_unintern (new_attr); |
| 4955 | aspath_unintern (attr.aspath); |
| 4956 | bgp_unlock_node (bn); |
| 4957 | return; |
| 4958 | } |
| 4959 | else |
| 4960 | { |
| 4961 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4962 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4963 | |
| 4964 | /* Rewrite BGP route information. */ |
| 4965 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
| 4966 | bgp_attr_unintern (bi->attr); |
| 4967 | bi->attr = new_attr; |
| 4968 | bi->uptime = time (NULL); |
| 4969 | |
| 4970 | /* Process change. */ |
| 4971 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 4972 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4973 | bgp_unlock_node (bn); |
| 4974 | aspath_unintern (attr.aspath); |
| 4975 | return; |
| 4976 | } |
| 4977 | } |
| 4978 | |
| 4979 | new = bgp_info_new (); |
| 4980 | new->type = type; |
| 4981 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 4982 | new->peer = bgp->peer_self; |
| 4983 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4984 | new->attr = new_attr; |
| 4985 | new->uptime = time (NULL); |
| 4986 | |
| 4987 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 4988 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4989 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4990 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4991 | } |
| 4992 | } |
| 4993 | |
| 4994 | /* Unintern original. */ |
| 4995 | aspath_unintern (attr.aspath); |
| 4996 | } |
| 4997 | |
| 4998 | void |
| 4999 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5000 | { |
| 5001 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5002 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5003 | afi_t afi; |
| 5004 | struct bgp_node *rn; |
| 5005 | struct bgp_info *ri; |
| 5006 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5007 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5008 | { |
| 5009 | afi = family2afi (p->family); |
| 5010 | |
| 5011 | if (bgp->redist[afi][type]) |
| 5012 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5013 | 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] | 5014 | |
| 5015 | for (ri = rn->info; ri; ri = ri->next) |
| 5016 | if (ri->peer == bgp->peer_self |
| 5017 | && ri->type == type) |
| 5018 | break; |
| 5019 | |
| 5020 | if (ri) |
| 5021 | { |
| 5022 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5023 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5024 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5025 | } |
| 5026 | bgp_unlock_node (rn); |
| 5027 | } |
| 5028 | } |
| 5029 | } |
| 5030 | |
| 5031 | /* Withdraw specified route type's route. */ |
| 5032 | void |
| 5033 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5034 | { |
| 5035 | struct bgp_node *rn; |
| 5036 | struct bgp_info *ri; |
| 5037 | struct bgp_table *table; |
| 5038 | |
| 5039 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5040 | |
| 5041 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5042 | { |
| 5043 | for (ri = rn->info; ri; ri = ri->next) |
| 5044 | if (ri->peer == bgp->peer_self |
| 5045 | && ri->type == type) |
| 5046 | break; |
| 5047 | |
| 5048 | if (ri) |
| 5049 | { |
| 5050 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5051 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5052 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5053 | } |
| 5054 | } |
| 5055 | } |
| 5056 | |
| 5057 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5058 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5059 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5060 | { |
| 5061 | int len; |
| 5062 | u_int32_t destination; |
| 5063 | char buf[BUFSIZ]; |
| 5064 | |
| 5065 | if (p->family == AF_INET) |
| 5066 | { |
| 5067 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5068 | destination = ntohl (p->u.prefix4.s_addr); |
| 5069 | |
| 5070 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5071 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5072 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5073 | || p->u.prefix4.s_addr == 0) |
| 5074 | { |
| 5075 | /* When mask is natural, mask is not displayed. */ |
| 5076 | } |
| 5077 | else |
| 5078 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5079 | } |
| 5080 | else |
| 5081 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5082 | p->prefixlen); |
| 5083 | |
| 5084 | len = 17 - len; |
| 5085 | if (len < 1) |
| 5086 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5087 | else |
| 5088 | vty_out (vty, "%*s", len, " "); |
| 5089 | } |
| 5090 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5091 | enum bgp_display_type |
| 5092 | { |
| 5093 | normal_list, |
| 5094 | }; |
| 5095 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5096 | /* Print the short form route status for a bgp_info */ |
| 5097 | static void |
| 5098 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5099 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5100 | /* Route status display. */ |
| 5101 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5102 | vty_out (vty, "R"); |
| 5103 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5104 | vty_out (vty, "S"); |
| 5105 | else if (binfo->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5106 | vty_out (vty, "s"); |
| 5107 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5108 | vty_out (vty, "*"); |
| 5109 | else |
| 5110 | vty_out (vty, " "); |
| 5111 | |
| 5112 | /* Selected */ |
| 5113 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5114 | vty_out (vty, "h"); |
| 5115 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5116 | vty_out (vty, "d"); |
| 5117 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5118 | vty_out (vty, ">"); |
| 5119 | else |
| 5120 | vty_out (vty, " "); |
| 5121 | |
| 5122 | /* Internal route. */ |
| 5123 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5124 | vty_out (vty, "i"); |
| 5125 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5126 | vty_out (vty, " "); |
| 5127 | } |
| 5128 | |
| 5129 | /* called from terminal list command */ |
| 5130 | void |
| 5131 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5132 | struct bgp_info *binfo, int display, safi_t safi) |
| 5133 | { |
| 5134 | struct attr *attr; |
| 5135 | |
| 5136 | /* short status lead text */ |
| 5137 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5138 | |
| 5139 | /* print prefix and mask */ |
| 5140 | if (! display) |
| 5141 | route_vty_out_route (p, vty); |
| 5142 | else |
| 5143 | vty_out (vty, "%*s", 17, " "); |
| 5144 | |
| 5145 | /* Print attribute */ |
| 5146 | attr = binfo->attr; |
| 5147 | if (attr) |
| 5148 | { |
| 5149 | if (p->family == AF_INET) |
| 5150 | { |
| 5151 | if (safi == SAFI_MPLS_VPN) |
| 5152 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5153 | else |
| 5154 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5155 | } |
| 5156 | #ifdef HAVE_IPV6 |
| 5157 | else if (p->family == AF_INET6) |
| 5158 | { |
| 5159 | int len; |
| 5160 | char buf[BUFSIZ]; |
| 5161 | |
| 5162 | len = vty_out (vty, "%s", |
| 5163 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5164 | len = 16 - len; |
| 5165 | if (len < 1) |
| 5166 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5167 | else |
| 5168 | vty_out (vty, "%*s", len, " "); |
| 5169 | } |
| 5170 | #endif /* HAVE_IPV6 */ |
| 5171 | |
| 5172 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 5173 | vty_out (vty, "%10d", attr->med); |
| 5174 | else |
| 5175 | vty_out (vty, " "); |
| 5176 | |
| 5177 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 5178 | vty_out (vty, "%7d", attr->local_pref); |
| 5179 | else |
| 5180 | vty_out (vty, " "); |
| 5181 | |
| 5182 | vty_out (vty, "%7u ",attr->weight); |
| 5183 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5184 | /* Print aspath */ |
| 5185 | if (attr->aspath) |
| 5186 | aspath_print_vty (vty, "%s ", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5187 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5188 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5189 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5190 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5191 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5192 | } |
| 5193 | |
| 5194 | /* called from terminal list command */ |
| 5195 | void |
| 5196 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5197 | struct attr *attr, safi_t safi) |
| 5198 | { |
| 5199 | /* Route status display. */ |
| 5200 | vty_out (vty, "*"); |
| 5201 | vty_out (vty, ">"); |
| 5202 | vty_out (vty, " "); |
| 5203 | |
| 5204 | /* print prefix and mask */ |
| 5205 | route_vty_out_route (p, vty); |
| 5206 | |
| 5207 | /* Print attribute */ |
| 5208 | if (attr) |
| 5209 | { |
| 5210 | if (p->family == AF_INET) |
| 5211 | { |
| 5212 | if (safi == SAFI_MPLS_VPN) |
| 5213 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5214 | else |
| 5215 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5216 | } |
| 5217 | #ifdef HAVE_IPV6 |
| 5218 | else if (p->family == AF_INET6) |
| 5219 | { |
| 5220 | int len; |
| 5221 | char buf[BUFSIZ]; |
| 5222 | |
| 5223 | len = vty_out (vty, "%s", |
| 5224 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5225 | len = 16 - len; |
| 5226 | if (len < 1) |
| 5227 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5228 | else |
| 5229 | vty_out (vty, "%*s", len, " "); |
| 5230 | } |
| 5231 | #endif /* HAVE_IPV6 */ |
| 5232 | |
| 5233 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 5234 | vty_out (vty, "%10d", attr->med); |
| 5235 | else |
| 5236 | vty_out (vty, " "); |
| 5237 | |
| 5238 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 5239 | vty_out (vty, "%7d", attr->local_pref); |
| 5240 | else |
| 5241 | vty_out (vty, " "); |
| 5242 | |
| 5243 | vty_out (vty, "%7d ",attr->weight); |
| 5244 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5245 | /* Print aspath */ |
| 5246 | if (attr->aspath) |
| 5247 | aspath_print_vty (vty, "%s ", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5248 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5249 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5250 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5251 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5252 | |
| 5253 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5254 | } |
| 5255 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5256 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5257 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5258 | struct bgp_info *binfo, int display, safi_t safi) |
| 5259 | { |
| 5260 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5261 | u_int32_t label = 0; |
| 5262 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5263 | /* short status lead text */ |
| 5264 | route_vty_short_status_out (vty, binfo); |
| 5265 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5266 | /* print prefix and mask */ |
| 5267 | if (! display) |
| 5268 | route_vty_out_route (p, vty); |
| 5269 | else |
| 5270 | vty_out (vty, "%*s", 17, " "); |
| 5271 | |
| 5272 | /* Print attribute */ |
| 5273 | attr = binfo->attr; |
| 5274 | if (attr) |
| 5275 | { |
| 5276 | if (p->family == AF_INET) |
| 5277 | { |
| 5278 | if (safi == SAFI_MPLS_VPN) |
| 5279 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5280 | else |
| 5281 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5282 | } |
| 5283 | #ifdef HAVE_IPV6 |
| 5284 | else if (p->family == AF_INET6) |
| 5285 | { |
| 5286 | char buf[BUFSIZ]; |
| 5287 | char buf1[BUFSIZ]; |
| 5288 | if (attr->mp_nexthop_len == 16) |
| 5289 | vty_out (vty, "%s", |
| 5290 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5291 | else if (attr->mp_nexthop_len == 32) |
| 5292 | vty_out (vty, "%s(%s)", |
| 5293 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ), |
| 5294 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ)); |
| 5295 | |
| 5296 | } |
| 5297 | #endif /* HAVE_IPV6 */ |
| 5298 | } |
| 5299 | |
| 5300 | label = decode_label (binfo->tag); |
| 5301 | |
| 5302 | vty_out (vty, "notag/%d", label); |
| 5303 | |
| 5304 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5305 | } |
| 5306 | |
| 5307 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5308 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5309 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5310 | struct bgp_info *binfo, int display, safi_t safi) |
| 5311 | { |
| 5312 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5313 | int len; |
| 5314 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5315 | /* short status lead text */ |
| 5316 | route_vty_short_status_out (vty, binfo); |
| 5317 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5318 | /* print prefix and mask */ |
| 5319 | if (! display) |
| 5320 | route_vty_out_route (p, vty); |
| 5321 | else |
| 5322 | vty_out (vty, "%*s", 17, " "); |
| 5323 | |
| 5324 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5325 | len = 17 - len; |
| 5326 | if (len < 1) |
| 5327 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5328 | else |
| 5329 | vty_out (vty, "%*s", len, " "); |
| 5330 | |
| 5331 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5332 | |
| 5333 | /* Print attribute */ |
| 5334 | attr = binfo->attr; |
| 5335 | if (attr) |
| 5336 | { |
| 5337 | /* Print aspath */ |
| 5338 | if (attr->aspath) |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5339 | aspath_print_vty (vty, "%s ", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5340 | |
| 5341 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5342 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5343 | } |
| 5344 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5345 | } |
| 5346 | |
| 5347 | #define BGP_UPTIME_LEN 25 |
| 5348 | |
| 5349 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5350 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5351 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5352 | struct bgp_info *binfo, int display, safi_t safi) |
| 5353 | { |
| 5354 | struct attr *attr; |
| 5355 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5356 | char timebuf[BGP_UPTIME_LEN]; |
| 5357 | int len; |
| 5358 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5359 | bdi = binfo->damp_info; |
| 5360 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5361 | /* short status lead text */ |
| 5362 | route_vty_short_status_out (vty, binfo); |
| 5363 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5364 | /* print prefix and mask */ |
| 5365 | if (! display) |
| 5366 | route_vty_out_route (p, vty); |
| 5367 | else |
| 5368 | vty_out (vty, "%*s", 17, " "); |
| 5369 | |
| 5370 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5371 | len = 16 - len; |
| 5372 | if (len < 1) |
| 5373 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5374 | else |
| 5375 | vty_out (vty, "%*s", len, " "); |
| 5376 | |
| 5377 | len = vty_out (vty, "%d", bdi->flap); |
| 5378 | len = 5 - len; |
| 5379 | if (len < 1) |
| 5380 | vty_out (vty, " "); |
| 5381 | else |
| 5382 | vty_out (vty, "%*s ", len, " "); |
| 5383 | |
| 5384 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5385 | timebuf, BGP_UPTIME_LEN)); |
| 5386 | |
| 5387 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5388 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5389 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5390 | else |
| 5391 | vty_out (vty, "%*s ", 8, " "); |
| 5392 | |
| 5393 | /* Print attribute */ |
| 5394 | attr = binfo->attr; |
| 5395 | if (attr) |
| 5396 | { |
| 5397 | /* Print aspath */ |
| 5398 | if (attr->aspath) |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5399 | aspath_print_vty (vty, "%s ", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5400 | |
| 5401 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5402 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5403 | } |
| 5404 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5405 | } |
| 5406 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5407 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5408 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5409 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5410 | { |
| 5411 | char buf[INET6_ADDRSTRLEN]; |
| 5412 | char buf1[BUFSIZ]; |
| 5413 | struct attr *attr; |
| 5414 | int sockunion_vty_out (struct vty *, union sockunion *); |
| 5415 | |
| 5416 | attr = binfo->attr; |
| 5417 | |
| 5418 | if (attr) |
| 5419 | { |
| 5420 | /* Line1 display AS-path, Aggregator */ |
| 5421 | if (attr->aspath) |
| 5422 | { |
| 5423 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5424 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5425 | vty_out (vty, "Local"); |
| 5426 | else |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5427 | aspath_print_vty (vty, "%s", attr->aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5428 | } |
| 5429 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5430 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5431 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5432 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5433 | vty_out (vty, ", (stale)"); |
| 5434 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
| 5435 | vty_out (vty, ", (aggregated by %d %s)", attr->aggregator_as, |
| 5436 | inet_ntoa (attr->aggregator_addr)); |
| 5437 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5438 | vty_out (vty, ", (Received from a RR-client)"); |
| 5439 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5440 | vty_out (vty, ", (Received from a RS-client)"); |
| 5441 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5442 | vty_out (vty, ", (history entry)"); |
| 5443 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5444 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5445 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5446 | |
| 5447 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5448 | if (p->family == AF_INET) |
| 5449 | { |
| 5450 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
| 5451 | inet_ntoa (attr->mp_nexthop_global_in) : |
| 5452 | inet_ntoa (attr->nexthop)); |
| 5453 | } |
| 5454 | #ifdef HAVE_IPV6 |
| 5455 | else |
| 5456 | { |
| 5457 | vty_out (vty, " %s", |
| 5458 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, |
| 5459 | buf, INET6_ADDRSTRLEN)); |
| 5460 | } |
| 5461 | #endif /* HAVE_IPV6 */ |
| 5462 | |
| 5463 | if (binfo->peer == bgp->peer_self) |
| 5464 | { |
| 5465 | vty_out (vty, " from %s ", |
| 5466 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5467 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5468 | } |
| 5469 | else |
| 5470 | { |
| 5471 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5472 | vty_out (vty, " (inaccessible)"); |
| 5473 | else if (binfo->igpmetric) |
| 5474 | vty_out (vty, " (metric %d)", binfo->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5475 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5476 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5477 | vty_out (vty, " (%s)", inet_ntoa (attr->originator_id)); |
| 5478 | else |
| 5479 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5480 | } |
| 5481 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5482 | |
| 5483 | #ifdef HAVE_IPV6 |
| 5484 | /* display nexthop local */ |
| 5485 | if (attr->mp_nexthop_len == 32) |
| 5486 | { |
| 5487 | vty_out (vty, " (%s)%s", |
| 5488 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, |
| 5489 | buf, INET6_ADDRSTRLEN), |
| 5490 | VTY_NEWLINE); |
| 5491 | } |
| 5492 | #endif /* HAVE_IPV6 */ |
| 5493 | |
| 5494 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5495 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5496 | |
| 5497 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
| 5498 | vty_out (vty, ", metric %d", attr->med); |
| 5499 | |
| 5500 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
| 5501 | vty_out (vty, ", localpref %d", attr->local_pref); |
| 5502 | else |
| 5503 | vty_out (vty, ", localpref %d", bgp->default_local_pref); |
| 5504 | |
| 5505 | if (attr->weight != 0) |
| 5506 | vty_out (vty, ", weight %d", attr->weight); |
| 5507 | |
| 5508 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5509 | vty_out (vty, ", valid"); |
| 5510 | |
| 5511 | if (binfo->peer != bgp->peer_self) |
| 5512 | { |
| 5513 | if (binfo->peer->as == binfo->peer->local_as) |
| 5514 | vty_out (vty, ", internal"); |
| 5515 | else |
| 5516 | vty_out (vty, ", %s", |
| 5517 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 5518 | } |
| 5519 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 5520 | vty_out (vty, ", aggregated, local"); |
| 5521 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 5522 | vty_out (vty, ", sourced"); |
| 5523 | else |
| 5524 | vty_out (vty, ", sourced, local"); |
| 5525 | |
| 5526 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5527 | vty_out (vty, ", atomic-aggregate"); |
| 5528 | |
| 5529 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5530 | vty_out (vty, ", best"); |
| 5531 | |
| 5532 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5533 | |
| 5534 | /* Line 4 display Community */ |
| 5535 | if (attr->community) |
| 5536 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 5537 | VTY_NEWLINE); |
| 5538 | |
| 5539 | /* Line 5 display Extended-community */ |
| 5540 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
| 5541 | vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str, |
| 5542 | VTY_NEWLINE); |
| 5543 | |
| 5544 | /* Line 6 display Originator, Cluster-id */ |
| 5545 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 5546 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 5547 | { |
| 5548 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5549 | vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id)); |
| 5550 | |
| 5551 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 5552 | { |
| 5553 | int i; |
| 5554 | vty_out (vty, ", Cluster list: "); |
| 5555 | for (i = 0; i < attr->cluster->length / 4; i++) |
| 5556 | vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i])); |
| 5557 | } |
| 5558 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5559 | } |
| 5560 | |
| 5561 | if (binfo->damp_info) |
| 5562 | bgp_damp_info_vty (vty, binfo); |
| 5563 | |
| 5564 | /* Line 7 display Uptime */ |
| 5565 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); |
| 5566 | } |
| 5567 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5568 | } |
| 5569 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5570 | #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] | 5571 | #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] | 5572 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 5573 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 5574 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 5575 | |
| 5576 | enum bgp_show_type |
| 5577 | { |
| 5578 | bgp_show_type_normal, |
| 5579 | bgp_show_type_regexp, |
| 5580 | bgp_show_type_prefix_list, |
| 5581 | bgp_show_type_filter_list, |
| 5582 | bgp_show_type_route_map, |
| 5583 | bgp_show_type_neighbor, |
| 5584 | bgp_show_type_cidr_only, |
| 5585 | bgp_show_type_prefix_longer, |
| 5586 | bgp_show_type_community_all, |
| 5587 | bgp_show_type_community, |
| 5588 | bgp_show_type_community_exact, |
| 5589 | bgp_show_type_community_list, |
| 5590 | bgp_show_type_community_list_exact, |
| 5591 | bgp_show_type_flap_statistics, |
| 5592 | bgp_show_type_flap_address, |
| 5593 | bgp_show_type_flap_prefix, |
| 5594 | bgp_show_type_flap_cidr_only, |
| 5595 | bgp_show_type_flap_regexp, |
| 5596 | bgp_show_type_flap_filter_list, |
| 5597 | bgp_show_type_flap_prefix_list, |
| 5598 | bgp_show_type_flap_prefix_longer, |
| 5599 | bgp_show_type_flap_route_map, |
| 5600 | bgp_show_type_flap_neighbor, |
| 5601 | bgp_show_type_dampend_paths, |
| 5602 | bgp_show_type_damp_neighbor |
| 5603 | }; |
| 5604 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5605 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5606 | 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] | 5607 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5608 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5609 | struct bgp_info *ri; |
| 5610 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5611 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5612 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5613 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5614 | |
| 5615 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5616 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5617 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5618 | /* Start processing of routes. */ |
| 5619 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5620 | if (rn->info != NULL) |
| 5621 | { |
| 5622 | display = 0; |
| 5623 | |
| 5624 | for (ri = rn->info; ri; ri = ri->next) |
| 5625 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5626 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5627 | || type == bgp_show_type_flap_address |
| 5628 | || type == bgp_show_type_flap_prefix |
| 5629 | || type == bgp_show_type_flap_cidr_only |
| 5630 | || type == bgp_show_type_flap_regexp |
| 5631 | || type == bgp_show_type_flap_filter_list |
| 5632 | || type == bgp_show_type_flap_prefix_list |
| 5633 | || type == bgp_show_type_flap_prefix_longer |
| 5634 | || type == bgp_show_type_flap_route_map |
| 5635 | || type == bgp_show_type_flap_neighbor |
| 5636 | || type == bgp_show_type_dampend_paths |
| 5637 | || type == bgp_show_type_damp_neighbor) |
| 5638 | { |
| 5639 | if (! ri->damp_info) |
| 5640 | continue; |
| 5641 | } |
| 5642 | if (type == bgp_show_type_regexp |
| 5643 | || type == bgp_show_type_flap_regexp) |
| 5644 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5645 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5646 | |
| 5647 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 5648 | continue; |
| 5649 | } |
| 5650 | if (type == bgp_show_type_prefix_list |
| 5651 | || type == bgp_show_type_flap_prefix_list) |
| 5652 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5653 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5654 | |
| 5655 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 5656 | continue; |
| 5657 | } |
| 5658 | if (type == bgp_show_type_filter_list |
| 5659 | || type == bgp_show_type_flap_filter_list) |
| 5660 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5661 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5662 | |
| 5663 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 5664 | continue; |
| 5665 | } |
| 5666 | if (type == bgp_show_type_route_map |
| 5667 | || type == bgp_show_type_flap_route_map) |
| 5668 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5669 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5670 | struct bgp_info binfo; |
| 5671 | struct attr dummy_attr; |
| 5672 | int ret; |
| 5673 | |
| 5674 | dummy_attr = *ri->attr; |
| 5675 | binfo.peer = ri->peer; |
| 5676 | binfo.attr = &dummy_attr; |
| 5677 | |
| 5678 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 5679 | |
| 5680 | if (ret == RMAP_DENYMATCH) |
| 5681 | continue; |
| 5682 | } |
| 5683 | if (type == bgp_show_type_neighbor |
| 5684 | || type == bgp_show_type_flap_neighbor |
| 5685 | || type == bgp_show_type_damp_neighbor) |
| 5686 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5687 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5688 | |
| 5689 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 5690 | continue; |
| 5691 | } |
| 5692 | if (type == bgp_show_type_cidr_only |
| 5693 | || type == bgp_show_type_flap_cidr_only) |
| 5694 | { |
| 5695 | u_int32_t destination; |
| 5696 | |
| 5697 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 5698 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 5699 | continue; |
| 5700 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 5701 | continue; |
| 5702 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 5703 | continue; |
| 5704 | } |
| 5705 | if (type == bgp_show_type_prefix_longer |
| 5706 | || type == bgp_show_type_flap_prefix_longer) |
| 5707 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5708 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5709 | |
| 5710 | if (! prefix_match (p, &rn->p)) |
| 5711 | continue; |
| 5712 | } |
| 5713 | if (type == bgp_show_type_community_all) |
| 5714 | { |
| 5715 | if (! ri->attr->community) |
| 5716 | continue; |
| 5717 | } |
| 5718 | if (type == bgp_show_type_community) |
| 5719 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5720 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5721 | |
| 5722 | if (! ri->attr->community || |
| 5723 | ! community_match (ri->attr->community, com)) |
| 5724 | continue; |
| 5725 | } |
| 5726 | if (type == bgp_show_type_community_exact) |
| 5727 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5728 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5729 | |
| 5730 | if (! ri->attr->community || |
| 5731 | ! community_cmp (ri->attr->community, com)) |
| 5732 | continue; |
| 5733 | } |
| 5734 | if (type == bgp_show_type_community_list) |
| 5735 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5736 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5737 | |
| 5738 | if (! community_list_match (ri->attr->community, list)) |
| 5739 | continue; |
| 5740 | } |
| 5741 | if (type == bgp_show_type_community_list_exact) |
| 5742 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5743 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5744 | |
| 5745 | if (! community_list_exact_match (ri->attr->community, list)) |
| 5746 | continue; |
| 5747 | } |
| 5748 | if (type == bgp_show_type_flap_address |
| 5749 | || type == bgp_show_type_flap_prefix) |
| 5750 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5751 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5752 | |
| 5753 | if (! prefix_match (&rn->p, p)) |
| 5754 | continue; |
| 5755 | |
| 5756 | if (type == bgp_show_type_flap_prefix) |
| 5757 | if (p->prefixlen != rn->p.prefixlen) |
| 5758 | continue; |
| 5759 | } |
| 5760 | if (type == bgp_show_type_dampend_paths |
| 5761 | || type == bgp_show_type_damp_neighbor) |
| 5762 | { |
| 5763 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 5764 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 5765 | continue; |
| 5766 | } |
| 5767 | |
| 5768 | if (header) |
| 5769 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5770 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 5771 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 5772 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5773 | if (type == bgp_show_type_dampend_paths |
| 5774 | || type == bgp_show_type_damp_neighbor) |
| 5775 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 5776 | else if (type == bgp_show_type_flap_statistics |
| 5777 | || type == bgp_show_type_flap_address |
| 5778 | || type == bgp_show_type_flap_prefix |
| 5779 | || type == bgp_show_type_flap_cidr_only |
| 5780 | || type == bgp_show_type_flap_regexp |
| 5781 | || type == bgp_show_type_flap_filter_list |
| 5782 | || type == bgp_show_type_flap_prefix_list |
| 5783 | || type == bgp_show_type_flap_prefix_longer |
| 5784 | || type == bgp_show_type_flap_route_map |
| 5785 | || type == bgp_show_type_flap_neighbor) |
| 5786 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 5787 | else |
| 5788 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5789 | header = 0; |
| 5790 | } |
| 5791 | |
| 5792 | if (type == bgp_show_type_dampend_paths |
| 5793 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5794 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5795 | else if (type == bgp_show_type_flap_statistics |
| 5796 | || type == bgp_show_type_flap_address |
| 5797 | || type == bgp_show_type_flap_prefix |
| 5798 | || type == bgp_show_type_flap_cidr_only |
| 5799 | || type == bgp_show_type_flap_regexp |
| 5800 | || type == bgp_show_type_flap_filter_list |
| 5801 | || type == bgp_show_type_flap_prefix_list |
| 5802 | || type == bgp_show_type_flap_prefix_longer |
| 5803 | || type == bgp_show_type_flap_route_map |
| 5804 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5805 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5806 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5807 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5808 | display++; |
| 5809 | } |
| 5810 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5811 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5812 | } |
| 5813 | |
| 5814 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5815 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5816 | { |
| 5817 | if (type == bgp_show_type_normal) |
| 5818 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 5819 | } |
| 5820 | else |
| 5821 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5822 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5823 | |
| 5824 | return CMD_SUCCESS; |
| 5825 | } |
| 5826 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5827 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5828 | 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] | 5829 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5830 | { |
| 5831 | struct bgp_table *table; |
| 5832 | |
| 5833 | if (bgp == NULL) { |
| 5834 | bgp = bgp_get_default (); |
| 5835 | } |
| 5836 | |
| 5837 | if (bgp == NULL) |
| 5838 | { |
| 5839 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5840 | return CMD_WARNING; |
| 5841 | } |
| 5842 | |
| 5843 | |
| 5844 | table = bgp->rib[afi][safi]; |
| 5845 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5846 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5847 | } |
| 5848 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5849 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5850 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5851 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 5852 | struct bgp_node *rn, |
| 5853 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 5854 | { |
| 5855 | struct bgp_info *ri; |
| 5856 | struct prefix *p; |
| 5857 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5858 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5859 | char buf1[INET6_ADDRSTRLEN]; |
| 5860 | char buf2[INET6_ADDRSTRLEN]; |
| 5861 | int count = 0; |
| 5862 | int best = 0; |
| 5863 | int suppress = 0; |
| 5864 | int no_export = 0; |
| 5865 | int no_advertise = 0; |
| 5866 | int local_as = 0; |
| 5867 | int first = 0; |
| 5868 | |
| 5869 | p = &rn->p; |
| 5870 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 5871 | (safi == SAFI_MPLS_VPN ? |
| 5872 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 5873 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 5874 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 5875 | p->prefixlen, VTY_NEWLINE); |
| 5876 | |
| 5877 | for (ri = rn->info; ri; ri = ri->next) |
| 5878 | { |
| 5879 | count++; |
| 5880 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 5881 | { |
| 5882 | best = count; |
| 5883 | if (ri->suppress) |
| 5884 | suppress = 1; |
| 5885 | if (ri->attr->community != NULL) |
| 5886 | { |
| 5887 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 5888 | no_advertise = 1; |
| 5889 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 5890 | no_export = 1; |
| 5891 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 5892 | local_as = 1; |
| 5893 | } |
| 5894 | } |
| 5895 | } |
| 5896 | |
| 5897 | vty_out (vty, "Paths: (%d available", count); |
| 5898 | if (best) |
| 5899 | { |
| 5900 | vty_out (vty, ", best #%d", best); |
| 5901 | if (safi == SAFI_UNICAST) |
| 5902 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 5903 | } |
| 5904 | else |
| 5905 | vty_out (vty, ", no best path"); |
| 5906 | if (no_advertise) |
| 5907 | vty_out (vty, ", not advertised to any peer"); |
| 5908 | else if (no_export) |
| 5909 | vty_out (vty, ", not advertised to EBGP peer"); |
| 5910 | else if (local_as) |
| 5911 | vty_out (vty, ", not advertised outside local AS"); |
| 5912 | if (suppress) |
| 5913 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 5914 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 5915 | |
| 5916 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5917 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5918 | { |
| 5919 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 5920 | { |
| 5921 | if (! first) |
| 5922 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 5923 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 5924 | first = 1; |
| 5925 | } |
| 5926 | } |
| 5927 | if (! first) |
| 5928 | vty_out (vty, " Not advertised to any peer"); |
| 5929 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5930 | } |
| 5931 | |
| 5932 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5933 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5934 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5935 | struct bgp_table *rib, const char *ip_str, |
| 5936 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5937 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5938 | { |
| 5939 | int ret; |
| 5940 | int header; |
| 5941 | int display = 0; |
| 5942 | struct prefix match; |
| 5943 | struct bgp_node *rn; |
| 5944 | struct bgp_node *rm; |
| 5945 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5946 | struct bgp_table *table; |
| 5947 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5948 | /* Check IP address argument. */ |
| 5949 | ret = str2prefix (ip_str, &match); |
| 5950 | if (! ret) |
| 5951 | { |
| 5952 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 5953 | return CMD_WARNING; |
| 5954 | } |
| 5955 | |
| 5956 | match.family = afi2family (afi); |
| 5957 | |
| 5958 | if (safi == SAFI_MPLS_VPN) |
| 5959 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5960 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | { |
| 5962 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 5963 | continue; |
| 5964 | |
| 5965 | if ((table = rn->info) != NULL) |
| 5966 | { |
| 5967 | header = 1; |
| 5968 | |
| 5969 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 5970 | { |
| 5971 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 5972 | continue; |
| 5973 | |
| 5974 | for (ri = rm->info; ri; ri = ri->next) |
| 5975 | { |
| 5976 | if (header) |
| 5977 | { |
| 5978 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 5979 | AFI_IP, SAFI_MPLS_VPN); |
| 5980 | |
| 5981 | header = 0; |
| 5982 | } |
| 5983 | display++; |
| 5984 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 5985 | } |
| 5986 | } |
| 5987 | } |
| 5988 | } |
| 5989 | } |
| 5990 | else |
| 5991 | { |
| 5992 | header = 1; |
| 5993 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5994 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5995 | { |
| 5996 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 5997 | { |
| 5998 | for (ri = rn->info; ri; ri = ri->next) |
| 5999 | { |
| 6000 | if (header) |
| 6001 | { |
| 6002 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6003 | header = 0; |
| 6004 | } |
| 6005 | display++; |
| 6006 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6007 | } |
| 6008 | } |
| 6009 | } |
| 6010 | } |
| 6011 | |
| 6012 | if (! display) |
| 6013 | { |
| 6014 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6015 | return CMD_WARNING; |
| 6016 | } |
| 6017 | |
| 6018 | return CMD_SUCCESS; |
| 6019 | } |
| 6020 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6021 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6022 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6023 | 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] | 6024 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6025 | int prefix_check) |
| 6026 | { |
| 6027 | struct bgp *bgp; |
| 6028 | |
| 6029 | /* BGP structure lookup. */ |
| 6030 | if (view_name) |
| 6031 | { |
| 6032 | bgp = bgp_lookup_by_name (view_name); |
| 6033 | if (bgp == NULL) |
| 6034 | { |
| 6035 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6036 | return CMD_WARNING; |
| 6037 | } |
| 6038 | } |
| 6039 | else |
| 6040 | { |
| 6041 | bgp = bgp_get_default (); |
| 6042 | if (bgp == NULL) |
| 6043 | { |
| 6044 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6045 | return CMD_WARNING; |
| 6046 | } |
| 6047 | } |
| 6048 | |
| 6049 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6050 | afi, safi, prd, prefix_check); |
| 6051 | } |
| 6052 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6053 | /* BGP route print out function. */ |
| 6054 | DEFUN (show_ip_bgp, |
| 6055 | show_ip_bgp_cmd, |
| 6056 | "show ip bgp", |
| 6057 | SHOW_STR |
| 6058 | IP_STR |
| 6059 | BGP_STR) |
| 6060 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6061 | 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] | 6062 | } |
| 6063 | |
| 6064 | DEFUN (show_ip_bgp_ipv4, |
| 6065 | show_ip_bgp_ipv4_cmd, |
| 6066 | "show ip bgp ipv4 (unicast|multicast)", |
| 6067 | SHOW_STR |
| 6068 | IP_STR |
| 6069 | BGP_STR |
| 6070 | "Address family\n" |
| 6071 | "Address Family modifier\n" |
| 6072 | "Address Family modifier\n") |
| 6073 | { |
| 6074 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6075 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6076 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6077 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6078 | 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] | 6079 | } |
| 6080 | |
| 6081 | DEFUN (show_ip_bgp_route, |
| 6082 | show_ip_bgp_route_cmd, |
| 6083 | "show ip bgp A.B.C.D", |
| 6084 | SHOW_STR |
| 6085 | IP_STR |
| 6086 | BGP_STR |
| 6087 | "Network in the BGP routing table to display\n") |
| 6088 | { |
| 6089 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6090 | } |
| 6091 | |
| 6092 | DEFUN (show_ip_bgp_ipv4_route, |
| 6093 | show_ip_bgp_ipv4_route_cmd, |
| 6094 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6095 | SHOW_STR |
| 6096 | IP_STR |
| 6097 | BGP_STR |
| 6098 | "Address family\n" |
| 6099 | "Address Family modifier\n" |
| 6100 | "Address Family modifier\n" |
| 6101 | "Network in the BGP routing table to display\n") |
| 6102 | { |
| 6103 | if (strncmp (argv[0], "m", 1) == 0) |
| 6104 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6105 | |
| 6106 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6107 | } |
| 6108 | |
| 6109 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6110 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6111 | "show ip bgp vpnv4 all A.B.C.D", |
| 6112 | SHOW_STR |
| 6113 | IP_STR |
| 6114 | BGP_STR |
| 6115 | "Display VPNv4 NLRI specific information\n" |
| 6116 | "Display information about all VPNv4 NLRIs\n" |
| 6117 | "Network in the BGP routing table to display\n") |
| 6118 | { |
| 6119 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6120 | } |
| 6121 | |
| 6122 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6123 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6124 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6125 | SHOW_STR |
| 6126 | IP_STR |
| 6127 | BGP_STR |
| 6128 | "Display VPNv4 NLRI specific information\n" |
| 6129 | "Display information for a route distinguisher\n" |
| 6130 | "VPN Route Distinguisher\n" |
| 6131 | "Network in the BGP routing table to display\n") |
| 6132 | { |
| 6133 | int ret; |
| 6134 | struct prefix_rd prd; |
| 6135 | |
| 6136 | ret = str2prefix_rd (argv[0], &prd); |
| 6137 | if (! ret) |
| 6138 | { |
| 6139 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6140 | return CMD_WARNING; |
| 6141 | } |
| 6142 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6143 | } |
| 6144 | |
| 6145 | DEFUN (show_ip_bgp_prefix, |
| 6146 | show_ip_bgp_prefix_cmd, |
| 6147 | "show ip bgp A.B.C.D/M", |
| 6148 | SHOW_STR |
| 6149 | IP_STR |
| 6150 | BGP_STR |
| 6151 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6152 | { |
| 6153 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6154 | } |
| 6155 | |
| 6156 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6157 | show_ip_bgp_ipv4_prefix_cmd, |
| 6158 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6159 | SHOW_STR |
| 6160 | IP_STR |
| 6161 | BGP_STR |
| 6162 | "Address family\n" |
| 6163 | "Address Family modifier\n" |
| 6164 | "Address Family modifier\n" |
| 6165 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6166 | { |
| 6167 | if (strncmp (argv[0], "m", 1) == 0) |
| 6168 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6169 | |
| 6170 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6171 | } |
| 6172 | |
| 6173 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6174 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6175 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6176 | SHOW_STR |
| 6177 | IP_STR |
| 6178 | BGP_STR |
| 6179 | "Display VPNv4 NLRI specific information\n" |
| 6180 | "Display information about all VPNv4 NLRIs\n" |
| 6181 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6182 | { |
| 6183 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6184 | } |
| 6185 | |
| 6186 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6187 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6188 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6189 | SHOW_STR |
| 6190 | IP_STR |
| 6191 | BGP_STR |
| 6192 | "Display VPNv4 NLRI specific information\n" |
| 6193 | "Display information for a route distinguisher\n" |
| 6194 | "VPN Route Distinguisher\n" |
| 6195 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6196 | { |
| 6197 | int ret; |
| 6198 | struct prefix_rd prd; |
| 6199 | |
| 6200 | ret = str2prefix_rd (argv[0], &prd); |
| 6201 | if (! ret) |
| 6202 | { |
| 6203 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6204 | return CMD_WARNING; |
| 6205 | } |
| 6206 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6207 | } |
| 6208 | |
| 6209 | DEFUN (show_ip_bgp_view, |
| 6210 | show_ip_bgp_view_cmd, |
| 6211 | "show ip bgp view WORD", |
| 6212 | SHOW_STR |
| 6213 | IP_STR |
| 6214 | BGP_STR |
| 6215 | "BGP view\n" |
| 6216 | "BGP view name\n") |
| 6217 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6218 | struct bgp *bgp; |
| 6219 | |
| 6220 | /* BGP structure lookup. */ |
| 6221 | bgp = bgp_lookup_by_name (argv[0]); |
| 6222 | if (bgp == NULL) |
| 6223 | { |
| 6224 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6225 | return CMD_WARNING; |
| 6226 | } |
| 6227 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6228 | 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] | 6229 | } |
| 6230 | |
| 6231 | DEFUN (show_ip_bgp_view_route, |
| 6232 | show_ip_bgp_view_route_cmd, |
| 6233 | "show ip bgp view WORD A.B.C.D", |
| 6234 | SHOW_STR |
| 6235 | IP_STR |
| 6236 | BGP_STR |
| 6237 | "BGP view\n" |
| 6238 | "BGP view name\n" |
| 6239 | "Network in the BGP routing table to display\n") |
| 6240 | { |
| 6241 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6242 | } |
| 6243 | |
| 6244 | DEFUN (show_ip_bgp_view_prefix, |
| 6245 | show_ip_bgp_view_prefix_cmd, |
| 6246 | "show ip bgp view WORD A.B.C.D/M", |
| 6247 | SHOW_STR |
| 6248 | IP_STR |
| 6249 | BGP_STR |
| 6250 | "BGP view\n" |
| 6251 | "BGP view name\n" |
| 6252 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6253 | { |
| 6254 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6255 | } |
| 6256 | |
| 6257 | #ifdef HAVE_IPV6 |
| 6258 | DEFUN (show_bgp, |
| 6259 | show_bgp_cmd, |
| 6260 | "show bgp", |
| 6261 | SHOW_STR |
| 6262 | BGP_STR) |
| 6263 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6264 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6265 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6266 | } |
| 6267 | |
| 6268 | ALIAS (show_bgp, |
| 6269 | show_bgp_ipv6_cmd, |
| 6270 | "show bgp ipv6", |
| 6271 | SHOW_STR |
| 6272 | BGP_STR |
| 6273 | "Address family\n") |
| 6274 | |
| 6275 | /* old command */ |
| 6276 | DEFUN (show_ipv6_bgp, |
| 6277 | show_ipv6_bgp_cmd, |
| 6278 | "show ipv6 bgp", |
| 6279 | SHOW_STR |
| 6280 | IP_STR |
| 6281 | BGP_STR) |
| 6282 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6283 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6284 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6285 | } |
| 6286 | |
| 6287 | DEFUN (show_bgp_route, |
| 6288 | show_bgp_route_cmd, |
| 6289 | "show bgp X:X::X:X", |
| 6290 | SHOW_STR |
| 6291 | BGP_STR |
| 6292 | "Network in the BGP routing table to display\n") |
| 6293 | { |
| 6294 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6295 | } |
| 6296 | |
| 6297 | ALIAS (show_bgp_route, |
| 6298 | show_bgp_ipv6_route_cmd, |
| 6299 | "show bgp ipv6 X:X::X:X", |
| 6300 | SHOW_STR |
| 6301 | BGP_STR |
| 6302 | "Address family\n" |
| 6303 | "Network in the BGP routing table to display\n") |
| 6304 | |
| 6305 | /* old command */ |
| 6306 | DEFUN (show_ipv6_bgp_route, |
| 6307 | show_ipv6_bgp_route_cmd, |
| 6308 | "show ipv6 bgp X:X::X:X", |
| 6309 | SHOW_STR |
| 6310 | IP_STR |
| 6311 | BGP_STR |
| 6312 | "Network in the BGP routing table to display\n") |
| 6313 | { |
| 6314 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6315 | } |
| 6316 | |
| 6317 | DEFUN (show_bgp_prefix, |
| 6318 | show_bgp_prefix_cmd, |
| 6319 | "show bgp X:X::X:X/M", |
| 6320 | SHOW_STR |
| 6321 | BGP_STR |
| 6322 | "IPv6 prefix <network>/<length>\n") |
| 6323 | { |
| 6324 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6325 | } |
| 6326 | |
| 6327 | ALIAS (show_bgp_prefix, |
| 6328 | show_bgp_ipv6_prefix_cmd, |
| 6329 | "show bgp ipv6 X:X::X:X/M", |
| 6330 | SHOW_STR |
| 6331 | BGP_STR |
| 6332 | "Address family\n" |
| 6333 | "IPv6 prefix <network>/<length>\n") |
| 6334 | |
| 6335 | /* old command */ |
| 6336 | DEFUN (show_ipv6_bgp_prefix, |
| 6337 | show_ipv6_bgp_prefix_cmd, |
| 6338 | "show ipv6 bgp X:X::X:X/M", |
| 6339 | SHOW_STR |
| 6340 | IP_STR |
| 6341 | BGP_STR |
| 6342 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6343 | { |
| 6344 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6345 | } |
| 6346 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6347 | DEFUN (show_bgp_view, |
| 6348 | show_bgp_view_cmd, |
| 6349 | "show bgp view WORD", |
| 6350 | SHOW_STR |
| 6351 | BGP_STR |
| 6352 | "BGP view\n" |
| 6353 | "View name\n") |
| 6354 | { |
| 6355 | struct bgp *bgp; |
| 6356 | |
| 6357 | /* BGP structure lookup. */ |
| 6358 | bgp = bgp_lookup_by_name (argv[0]); |
| 6359 | if (bgp == NULL) |
| 6360 | { |
| 6361 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6362 | return CMD_WARNING; |
| 6363 | } |
| 6364 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6365 | 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] | 6366 | } |
| 6367 | |
| 6368 | ALIAS (show_bgp_view, |
| 6369 | show_bgp_view_ipv6_cmd, |
| 6370 | "show bgp view WORD ipv6", |
| 6371 | SHOW_STR |
| 6372 | BGP_STR |
| 6373 | "BGP view\n" |
| 6374 | "View name\n" |
| 6375 | "Address family\n") |
| 6376 | |
| 6377 | DEFUN (show_bgp_view_route, |
| 6378 | show_bgp_view_route_cmd, |
| 6379 | "show bgp view WORD X:X::X:X", |
| 6380 | SHOW_STR |
| 6381 | BGP_STR |
| 6382 | "BGP view\n" |
| 6383 | "View name\n" |
| 6384 | "Network in the BGP routing table to display\n") |
| 6385 | { |
| 6386 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6387 | } |
| 6388 | |
| 6389 | ALIAS (show_bgp_view_route, |
| 6390 | show_bgp_view_ipv6_route_cmd, |
| 6391 | "show bgp view WORD ipv6 X:X::X:X", |
| 6392 | SHOW_STR |
| 6393 | BGP_STR |
| 6394 | "BGP view\n" |
| 6395 | "View name\n" |
| 6396 | "Address family\n" |
| 6397 | "Network in the BGP routing table to display\n") |
| 6398 | |
| 6399 | DEFUN (show_bgp_view_prefix, |
| 6400 | show_bgp_view_prefix_cmd, |
| 6401 | "show bgp view WORD X:X::X:X/M", |
| 6402 | SHOW_STR |
| 6403 | BGP_STR |
| 6404 | "BGP view\n" |
| 6405 | "View name\n" |
| 6406 | "IPv6 prefix <network>/<length>\n") |
| 6407 | { |
| 6408 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6409 | } |
| 6410 | |
| 6411 | ALIAS (show_bgp_view_prefix, |
| 6412 | show_bgp_view_ipv6_prefix_cmd, |
| 6413 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 6414 | SHOW_STR |
| 6415 | BGP_STR |
| 6416 | "BGP view\n" |
| 6417 | "View name\n" |
| 6418 | "Address family\n" |
| 6419 | "IPv6 prefix <network>/<length>\n") |
| 6420 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6421 | /* old command */ |
| 6422 | DEFUN (show_ipv6_mbgp, |
| 6423 | show_ipv6_mbgp_cmd, |
| 6424 | "show ipv6 mbgp", |
| 6425 | SHOW_STR |
| 6426 | IP_STR |
| 6427 | MBGP_STR) |
| 6428 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6429 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6430 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6431 | } |
| 6432 | |
| 6433 | /* old command */ |
| 6434 | DEFUN (show_ipv6_mbgp_route, |
| 6435 | show_ipv6_mbgp_route_cmd, |
| 6436 | "show ipv6 mbgp X:X::X:X", |
| 6437 | SHOW_STR |
| 6438 | IP_STR |
| 6439 | MBGP_STR |
| 6440 | "Network in the MBGP routing table to display\n") |
| 6441 | { |
| 6442 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6443 | } |
| 6444 | |
| 6445 | /* old command */ |
| 6446 | DEFUN (show_ipv6_mbgp_prefix, |
| 6447 | show_ipv6_mbgp_prefix_cmd, |
| 6448 | "show ipv6 mbgp X:X::X:X/M", |
| 6449 | SHOW_STR |
| 6450 | IP_STR |
| 6451 | MBGP_STR |
| 6452 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6453 | { |
| 6454 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6455 | } |
| 6456 | #endif |
| 6457 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6458 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6459 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6460 | 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] | 6461 | safi_t safi, enum bgp_show_type type) |
| 6462 | { |
| 6463 | int i; |
| 6464 | struct buffer *b; |
| 6465 | char *regstr; |
| 6466 | int first; |
| 6467 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6468 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6469 | |
| 6470 | first = 0; |
| 6471 | b = buffer_new (1024); |
| 6472 | for (i = 0; i < argc; i++) |
| 6473 | { |
| 6474 | if (first) |
| 6475 | buffer_putc (b, ' '); |
| 6476 | else |
| 6477 | { |
| 6478 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6479 | continue; |
| 6480 | first = 1; |
| 6481 | } |
| 6482 | |
| 6483 | buffer_putstr (b, argv[i]); |
| 6484 | } |
| 6485 | buffer_putc (b, '\0'); |
| 6486 | |
| 6487 | regstr = buffer_getstr (b); |
| 6488 | buffer_free (b); |
| 6489 | |
| 6490 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6491 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6492 | if (! regex) |
| 6493 | { |
| 6494 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 6495 | VTY_NEWLINE); |
| 6496 | return CMD_WARNING; |
| 6497 | } |
| 6498 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6499 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 6500 | bgp_regex_free (regex); |
| 6501 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6502 | } |
| 6503 | |
| 6504 | DEFUN (show_ip_bgp_regexp, |
| 6505 | show_ip_bgp_regexp_cmd, |
| 6506 | "show ip bgp regexp .LINE", |
| 6507 | SHOW_STR |
| 6508 | IP_STR |
| 6509 | BGP_STR |
| 6510 | "Display routes matching the AS path regular expression\n" |
| 6511 | "A regular-expression to match the BGP AS paths\n") |
| 6512 | { |
| 6513 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6514 | bgp_show_type_regexp); |
| 6515 | } |
| 6516 | |
| 6517 | DEFUN (show_ip_bgp_flap_regexp, |
| 6518 | show_ip_bgp_flap_regexp_cmd, |
| 6519 | "show ip bgp flap-statistics regexp .LINE", |
| 6520 | SHOW_STR |
| 6521 | IP_STR |
| 6522 | BGP_STR |
| 6523 | "Display flap statistics of routes\n" |
| 6524 | "Display routes matching the AS path regular expression\n" |
| 6525 | "A regular-expression to match the BGP AS paths\n") |
| 6526 | { |
| 6527 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6528 | bgp_show_type_flap_regexp); |
| 6529 | } |
| 6530 | |
| 6531 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 6532 | show_ip_bgp_ipv4_regexp_cmd, |
| 6533 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 6534 | SHOW_STR |
| 6535 | IP_STR |
| 6536 | BGP_STR |
| 6537 | "Address family\n" |
| 6538 | "Address Family modifier\n" |
| 6539 | "Address Family modifier\n" |
| 6540 | "Display routes matching the AS path regular expression\n" |
| 6541 | "A regular-expression to match the BGP AS paths\n") |
| 6542 | { |
| 6543 | if (strncmp (argv[0], "m", 1) == 0) |
| 6544 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 6545 | bgp_show_type_regexp); |
| 6546 | |
| 6547 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6548 | bgp_show_type_regexp); |
| 6549 | } |
| 6550 | |
| 6551 | #ifdef HAVE_IPV6 |
| 6552 | DEFUN (show_bgp_regexp, |
| 6553 | show_bgp_regexp_cmd, |
| 6554 | "show bgp regexp .LINE", |
| 6555 | SHOW_STR |
| 6556 | BGP_STR |
| 6557 | "Display routes matching the AS path regular expression\n" |
| 6558 | "A regular-expression to match the BGP AS paths\n") |
| 6559 | { |
| 6560 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6561 | bgp_show_type_regexp); |
| 6562 | } |
| 6563 | |
| 6564 | ALIAS (show_bgp_regexp, |
| 6565 | show_bgp_ipv6_regexp_cmd, |
| 6566 | "show bgp ipv6 regexp .LINE", |
| 6567 | SHOW_STR |
| 6568 | BGP_STR |
| 6569 | "Address family\n" |
| 6570 | "Display routes matching the AS path regular expression\n" |
| 6571 | "A regular-expression to match the BGP AS paths\n") |
| 6572 | |
| 6573 | /* old command */ |
| 6574 | DEFUN (show_ipv6_bgp_regexp, |
| 6575 | show_ipv6_bgp_regexp_cmd, |
| 6576 | "show ipv6 bgp regexp .LINE", |
| 6577 | SHOW_STR |
| 6578 | IP_STR |
| 6579 | BGP_STR |
| 6580 | "Display routes matching the AS path regular expression\n" |
| 6581 | "A regular-expression to match the BGP AS paths\n") |
| 6582 | { |
| 6583 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6584 | bgp_show_type_regexp); |
| 6585 | } |
| 6586 | |
| 6587 | /* old command */ |
| 6588 | DEFUN (show_ipv6_mbgp_regexp, |
| 6589 | show_ipv6_mbgp_regexp_cmd, |
| 6590 | "show ipv6 mbgp regexp .LINE", |
| 6591 | SHOW_STR |
| 6592 | IP_STR |
| 6593 | BGP_STR |
| 6594 | "Display routes matching the AS path regular expression\n" |
| 6595 | "A regular-expression to match the MBGP AS paths\n") |
| 6596 | { |
| 6597 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 6598 | bgp_show_type_regexp); |
| 6599 | } |
| 6600 | #endif /* HAVE_IPV6 */ |
| 6601 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6602 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6603 | 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] | 6604 | safi_t safi, enum bgp_show_type type) |
| 6605 | { |
| 6606 | struct prefix_list *plist; |
| 6607 | |
| 6608 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 6609 | if (plist == NULL) |
| 6610 | { |
| 6611 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 6612 | prefix_list_str, VTY_NEWLINE); |
| 6613 | return CMD_WARNING; |
| 6614 | } |
| 6615 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6616 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6617 | } |
| 6618 | |
| 6619 | DEFUN (show_ip_bgp_prefix_list, |
| 6620 | show_ip_bgp_prefix_list_cmd, |
| 6621 | "show ip bgp prefix-list WORD", |
| 6622 | SHOW_STR |
| 6623 | IP_STR |
| 6624 | BGP_STR |
| 6625 | "Display routes conforming to the prefix-list\n" |
| 6626 | "IP prefix-list name\n") |
| 6627 | { |
| 6628 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6629 | bgp_show_type_prefix_list); |
| 6630 | } |
| 6631 | |
| 6632 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 6633 | show_ip_bgp_flap_prefix_list_cmd, |
| 6634 | "show ip bgp flap-statistics prefix-list WORD", |
| 6635 | SHOW_STR |
| 6636 | IP_STR |
| 6637 | BGP_STR |
| 6638 | "Display flap statistics of routes\n" |
| 6639 | "Display routes conforming to the prefix-list\n" |
| 6640 | "IP prefix-list name\n") |
| 6641 | { |
| 6642 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6643 | bgp_show_type_flap_prefix_list); |
| 6644 | } |
| 6645 | |
| 6646 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 6647 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 6648 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 6649 | SHOW_STR |
| 6650 | IP_STR |
| 6651 | BGP_STR |
| 6652 | "Address family\n" |
| 6653 | "Address Family modifier\n" |
| 6654 | "Address Family modifier\n" |
| 6655 | "Display routes conforming to the prefix-list\n" |
| 6656 | "IP prefix-list name\n") |
| 6657 | { |
| 6658 | if (strncmp (argv[0], "m", 1) == 0) |
| 6659 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6660 | bgp_show_type_prefix_list); |
| 6661 | |
| 6662 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6663 | bgp_show_type_prefix_list); |
| 6664 | } |
| 6665 | |
| 6666 | #ifdef HAVE_IPV6 |
| 6667 | DEFUN (show_bgp_prefix_list, |
| 6668 | show_bgp_prefix_list_cmd, |
| 6669 | "show bgp prefix-list WORD", |
| 6670 | SHOW_STR |
| 6671 | BGP_STR |
| 6672 | "Display routes conforming to the prefix-list\n" |
| 6673 | "IPv6 prefix-list name\n") |
| 6674 | { |
| 6675 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6676 | bgp_show_type_prefix_list); |
| 6677 | } |
| 6678 | |
| 6679 | ALIAS (show_bgp_prefix_list, |
| 6680 | show_bgp_ipv6_prefix_list_cmd, |
| 6681 | "show bgp ipv6 prefix-list WORD", |
| 6682 | SHOW_STR |
| 6683 | BGP_STR |
| 6684 | "Address family\n" |
| 6685 | "Display routes conforming to the prefix-list\n" |
| 6686 | "IPv6 prefix-list name\n") |
| 6687 | |
| 6688 | /* old command */ |
| 6689 | DEFUN (show_ipv6_bgp_prefix_list, |
| 6690 | show_ipv6_bgp_prefix_list_cmd, |
| 6691 | "show ipv6 bgp prefix-list WORD", |
| 6692 | SHOW_STR |
| 6693 | IPV6_STR |
| 6694 | BGP_STR |
| 6695 | "Display routes matching the prefix-list\n" |
| 6696 | "IPv6 prefix-list name\n") |
| 6697 | { |
| 6698 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6699 | bgp_show_type_prefix_list); |
| 6700 | } |
| 6701 | |
| 6702 | /* old command */ |
| 6703 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 6704 | show_ipv6_mbgp_prefix_list_cmd, |
| 6705 | "show ipv6 mbgp prefix-list WORD", |
| 6706 | SHOW_STR |
| 6707 | IPV6_STR |
| 6708 | MBGP_STR |
| 6709 | "Display routes matching the prefix-list\n" |
| 6710 | "IPv6 prefix-list name\n") |
| 6711 | { |
| 6712 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6713 | bgp_show_type_prefix_list); |
| 6714 | } |
| 6715 | #endif /* HAVE_IPV6 */ |
| 6716 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6717 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6718 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6719 | safi_t safi, enum bgp_show_type type) |
| 6720 | { |
| 6721 | struct as_list *as_list; |
| 6722 | |
| 6723 | as_list = as_list_lookup (filter); |
| 6724 | if (as_list == NULL) |
| 6725 | { |
| 6726 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 6727 | return CMD_WARNING; |
| 6728 | } |
| 6729 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6730 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6731 | } |
| 6732 | |
| 6733 | DEFUN (show_ip_bgp_filter_list, |
| 6734 | show_ip_bgp_filter_list_cmd, |
| 6735 | "show ip bgp filter-list WORD", |
| 6736 | SHOW_STR |
| 6737 | IP_STR |
| 6738 | BGP_STR |
| 6739 | "Display routes conforming to the filter-list\n" |
| 6740 | "Regular expression access list name\n") |
| 6741 | { |
| 6742 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6743 | bgp_show_type_filter_list); |
| 6744 | } |
| 6745 | |
| 6746 | DEFUN (show_ip_bgp_flap_filter_list, |
| 6747 | show_ip_bgp_flap_filter_list_cmd, |
| 6748 | "show ip bgp flap-statistics filter-list WORD", |
| 6749 | SHOW_STR |
| 6750 | IP_STR |
| 6751 | BGP_STR |
| 6752 | "Display flap statistics of routes\n" |
| 6753 | "Display routes conforming to the filter-list\n" |
| 6754 | "Regular expression access list name\n") |
| 6755 | { |
| 6756 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6757 | bgp_show_type_flap_filter_list); |
| 6758 | } |
| 6759 | |
| 6760 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 6761 | show_ip_bgp_ipv4_filter_list_cmd, |
| 6762 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 6763 | SHOW_STR |
| 6764 | IP_STR |
| 6765 | BGP_STR |
| 6766 | "Address family\n" |
| 6767 | "Address Family modifier\n" |
| 6768 | "Address Family modifier\n" |
| 6769 | "Display routes conforming to the filter-list\n" |
| 6770 | "Regular expression access list name\n") |
| 6771 | { |
| 6772 | if (strncmp (argv[0], "m", 1) == 0) |
| 6773 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6774 | bgp_show_type_filter_list); |
| 6775 | |
| 6776 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6777 | bgp_show_type_filter_list); |
| 6778 | } |
| 6779 | |
| 6780 | #ifdef HAVE_IPV6 |
| 6781 | DEFUN (show_bgp_filter_list, |
| 6782 | show_bgp_filter_list_cmd, |
| 6783 | "show bgp filter-list WORD", |
| 6784 | SHOW_STR |
| 6785 | BGP_STR |
| 6786 | "Display routes conforming to the filter-list\n" |
| 6787 | "Regular expression access list name\n") |
| 6788 | { |
| 6789 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6790 | bgp_show_type_filter_list); |
| 6791 | } |
| 6792 | |
| 6793 | ALIAS (show_bgp_filter_list, |
| 6794 | show_bgp_ipv6_filter_list_cmd, |
| 6795 | "show bgp ipv6 filter-list WORD", |
| 6796 | SHOW_STR |
| 6797 | BGP_STR |
| 6798 | "Address family\n" |
| 6799 | "Display routes conforming to the filter-list\n" |
| 6800 | "Regular expression access list name\n") |
| 6801 | |
| 6802 | /* old command */ |
| 6803 | DEFUN (show_ipv6_bgp_filter_list, |
| 6804 | show_ipv6_bgp_filter_list_cmd, |
| 6805 | "show ipv6 bgp filter-list WORD", |
| 6806 | SHOW_STR |
| 6807 | IPV6_STR |
| 6808 | BGP_STR |
| 6809 | "Display routes conforming to the filter-list\n" |
| 6810 | "Regular expression access list name\n") |
| 6811 | { |
| 6812 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6813 | bgp_show_type_filter_list); |
| 6814 | } |
| 6815 | |
| 6816 | /* old command */ |
| 6817 | DEFUN (show_ipv6_mbgp_filter_list, |
| 6818 | show_ipv6_mbgp_filter_list_cmd, |
| 6819 | "show ipv6 mbgp filter-list WORD", |
| 6820 | SHOW_STR |
| 6821 | IPV6_STR |
| 6822 | MBGP_STR |
| 6823 | "Display routes conforming to the filter-list\n" |
| 6824 | "Regular expression access list name\n") |
| 6825 | { |
| 6826 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6827 | bgp_show_type_filter_list); |
| 6828 | } |
| 6829 | #endif /* HAVE_IPV6 */ |
| 6830 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6831 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6832 | 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] | 6833 | safi_t safi, enum bgp_show_type type) |
| 6834 | { |
| 6835 | struct route_map *rmap; |
| 6836 | |
| 6837 | rmap = route_map_lookup_by_name (rmap_str); |
| 6838 | if (! rmap) |
| 6839 | { |
| 6840 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 6841 | rmap_str, VTY_NEWLINE); |
| 6842 | return CMD_WARNING; |
| 6843 | } |
| 6844 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6845 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6846 | } |
| 6847 | |
| 6848 | DEFUN (show_ip_bgp_route_map, |
| 6849 | show_ip_bgp_route_map_cmd, |
| 6850 | "show ip bgp route-map WORD", |
| 6851 | SHOW_STR |
| 6852 | IP_STR |
| 6853 | BGP_STR |
| 6854 | "Display routes matching the route-map\n" |
| 6855 | "A route-map to match on\n") |
| 6856 | { |
| 6857 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6858 | bgp_show_type_route_map); |
| 6859 | } |
| 6860 | |
| 6861 | DEFUN (show_ip_bgp_flap_route_map, |
| 6862 | show_ip_bgp_flap_route_map_cmd, |
| 6863 | "show ip bgp flap-statistics route-map WORD", |
| 6864 | SHOW_STR |
| 6865 | IP_STR |
| 6866 | BGP_STR |
| 6867 | "Display flap statistics of routes\n" |
| 6868 | "Display routes matching the route-map\n" |
| 6869 | "A route-map to match on\n") |
| 6870 | { |
| 6871 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6872 | bgp_show_type_flap_route_map); |
| 6873 | } |
| 6874 | |
| 6875 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 6876 | show_ip_bgp_ipv4_route_map_cmd, |
| 6877 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 6878 | SHOW_STR |
| 6879 | IP_STR |
| 6880 | BGP_STR |
| 6881 | "Address family\n" |
| 6882 | "Address Family modifier\n" |
| 6883 | "Address Family modifier\n" |
| 6884 | "Display routes matching the route-map\n" |
| 6885 | "A route-map to match on\n") |
| 6886 | { |
| 6887 | if (strncmp (argv[0], "m", 1) == 0) |
| 6888 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6889 | bgp_show_type_route_map); |
| 6890 | |
| 6891 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6892 | bgp_show_type_route_map); |
| 6893 | } |
| 6894 | |
| 6895 | DEFUN (show_bgp_route_map, |
| 6896 | show_bgp_route_map_cmd, |
| 6897 | "show bgp route-map WORD", |
| 6898 | SHOW_STR |
| 6899 | BGP_STR |
| 6900 | "Display routes matching the route-map\n" |
| 6901 | "A route-map to match on\n") |
| 6902 | { |
| 6903 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6904 | bgp_show_type_route_map); |
| 6905 | } |
| 6906 | |
| 6907 | ALIAS (show_bgp_route_map, |
| 6908 | show_bgp_ipv6_route_map_cmd, |
| 6909 | "show bgp ipv6 route-map WORD", |
| 6910 | SHOW_STR |
| 6911 | BGP_STR |
| 6912 | "Address family\n" |
| 6913 | "Display routes matching the route-map\n" |
| 6914 | "A route-map to match on\n") |
| 6915 | |
| 6916 | DEFUN (show_ip_bgp_cidr_only, |
| 6917 | show_ip_bgp_cidr_only_cmd, |
| 6918 | "show ip bgp cidr-only", |
| 6919 | SHOW_STR |
| 6920 | IP_STR |
| 6921 | BGP_STR |
| 6922 | "Display only routes with non-natural netmasks\n") |
| 6923 | { |
| 6924 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6925 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6926 | } |
| 6927 | |
| 6928 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 6929 | show_ip_bgp_flap_cidr_only_cmd, |
| 6930 | "show ip bgp flap-statistics cidr-only", |
| 6931 | SHOW_STR |
| 6932 | IP_STR |
| 6933 | BGP_STR |
| 6934 | "Display flap statistics of routes\n" |
| 6935 | "Display only routes with non-natural netmasks\n") |
| 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_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6939 | } |
| 6940 | |
| 6941 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 6942 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 6943 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 6944 | SHOW_STR |
| 6945 | IP_STR |
| 6946 | BGP_STR |
| 6947 | "Address family\n" |
| 6948 | "Address Family modifier\n" |
| 6949 | "Address Family modifier\n" |
| 6950 | "Display only routes with non-natural netmasks\n") |
| 6951 | { |
| 6952 | if (strncmp (argv[0], "m", 1) == 0) |
| 6953 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6954 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6955 | |
| 6956 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6957 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6958 | } |
| 6959 | |
| 6960 | DEFUN (show_ip_bgp_community_all, |
| 6961 | show_ip_bgp_community_all_cmd, |
| 6962 | "show ip bgp community", |
| 6963 | SHOW_STR |
| 6964 | IP_STR |
| 6965 | BGP_STR |
| 6966 | "Display routes matching the communities\n") |
| 6967 | { |
| 6968 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6969 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6970 | } |
| 6971 | |
| 6972 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 6973 | show_ip_bgp_ipv4_community_all_cmd, |
| 6974 | "show ip bgp ipv4 (unicast|multicast) community", |
| 6975 | SHOW_STR |
| 6976 | IP_STR |
| 6977 | BGP_STR |
| 6978 | "Address family\n" |
| 6979 | "Address Family modifier\n" |
| 6980 | "Address Family modifier\n" |
| 6981 | "Display routes matching the communities\n") |
| 6982 | { |
| 6983 | if (strncmp (argv[0], "m", 1) == 0) |
| 6984 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6985 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6986 | |
| 6987 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6988 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6989 | } |
| 6990 | |
| 6991 | #ifdef HAVE_IPV6 |
| 6992 | DEFUN (show_bgp_community_all, |
| 6993 | show_bgp_community_all_cmd, |
| 6994 | "show bgp community", |
| 6995 | SHOW_STR |
| 6996 | BGP_STR |
| 6997 | "Display routes matching the communities\n") |
| 6998 | { |
| 6999 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7000 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7001 | } |
| 7002 | |
| 7003 | ALIAS (show_bgp_community_all, |
| 7004 | show_bgp_ipv6_community_all_cmd, |
| 7005 | "show bgp ipv6 community", |
| 7006 | SHOW_STR |
| 7007 | BGP_STR |
| 7008 | "Address family\n" |
| 7009 | "Display routes matching the communities\n") |
| 7010 | |
| 7011 | /* old command */ |
| 7012 | DEFUN (show_ipv6_bgp_community_all, |
| 7013 | show_ipv6_bgp_community_all_cmd, |
| 7014 | "show ipv6 bgp community", |
| 7015 | SHOW_STR |
| 7016 | IPV6_STR |
| 7017 | BGP_STR |
| 7018 | "Display routes matching the communities\n") |
| 7019 | { |
| 7020 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7021 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7022 | } |
| 7023 | |
| 7024 | /* old command */ |
| 7025 | DEFUN (show_ipv6_mbgp_community_all, |
| 7026 | show_ipv6_mbgp_community_all_cmd, |
| 7027 | "show ipv6 mbgp community", |
| 7028 | SHOW_STR |
| 7029 | IPV6_STR |
| 7030 | MBGP_STR |
| 7031 | "Display routes matching the communities\n") |
| 7032 | { |
| 7033 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7034 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7035 | } |
| 7036 | #endif /* HAVE_IPV6 */ |
| 7037 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7038 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7039 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
| 7040 | u_int16_t afi, u_char safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7041 | { |
| 7042 | struct community *com; |
| 7043 | struct buffer *b; |
| 7044 | int i; |
| 7045 | char *str; |
| 7046 | int first = 0; |
| 7047 | |
| 7048 | b = buffer_new (1024); |
| 7049 | for (i = 0; i < argc; i++) |
| 7050 | { |
| 7051 | if (first) |
| 7052 | buffer_putc (b, ' '); |
| 7053 | else |
| 7054 | { |
| 7055 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7056 | continue; |
| 7057 | first = 1; |
| 7058 | } |
| 7059 | |
| 7060 | buffer_putstr (b, argv[i]); |
| 7061 | } |
| 7062 | buffer_putc (b, '\0'); |
| 7063 | |
| 7064 | str = buffer_getstr (b); |
| 7065 | buffer_free (b); |
| 7066 | |
| 7067 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7068 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7069 | if (! com) |
| 7070 | { |
| 7071 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7072 | return CMD_WARNING; |
| 7073 | } |
| 7074 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7075 | return bgp_show (vty, NULL, afi, safi, |
| 7076 | (exact ? bgp_show_type_community_exact : |
| 7077 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7078 | } |
| 7079 | |
| 7080 | DEFUN (show_ip_bgp_community, |
| 7081 | show_ip_bgp_community_cmd, |
| 7082 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7083 | SHOW_STR |
| 7084 | IP_STR |
| 7085 | BGP_STR |
| 7086 | "Display routes matching the communities\n" |
| 7087 | "community number\n" |
| 7088 | "Do not send outside local AS (well-known community)\n" |
| 7089 | "Do not advertise to any peer (well-known community)\n" |
| 7090 | "Do not export to next AS (well-known community)\n") |
| 7091 | { |
| 7092 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 7093 | } |
| 7094 | |
| 7095 | ALIAS (show_ip_bgp_community, |
| 7096 | show_ip_bgp_community2_cmd, |
| 7097 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7098 | SHOW_STR |
| 7099 | IP_STR |
| 7100 | BGP_STR |
| 7101 | "Display routes matching the communities\n" |
| 7102 | "community number\n" |
| 7103 | "Do not send outside local AS (well-known community)\n" |
| 7104 | "Do not advertise to any peer (well-known community)\n" |
| 7105 | "Do not export to next AS (well-known community)\n" |
| 7106 | "community number\n" |
| 7107 | "Do not send outside local AS (well-known community)\n" |
| 7108 | "Do not advertise to any peer (well-known community)\n" |
| 7109 | "Do not export to next AS (well-known community)\n") |
| 7110 | |
| 7111 | ALIAS (show_ip_bgp_community, |
| 7112 | show_ip_bgp_community3_cmd, |
| 7113 | "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)", |
| 7114 | SHOW_STR |
| 7115 | IP_STR |
| 7116 | BGP_STR |
| 7117 | "Display routes matching the communities\n" |
| 7118 | "community number\n" |
| 7119 | "Do not send outside local AS (well-known community)\n" |
| 7120 | "Do not advertise to any peer (well-known community)\n" |
| 7121 | "Do not export to next AS (well-known community)\n" |
| 7122 | "community number\n" |
| 7123 | "Do not send outside local AS (well-known community)\n" |
| 7124 | "Do not advertise to any peer (well-known community)\n" |
| 7125 | "Do not export to next AS (well-known community)\n" |
| 7126 | "community number\n" |
| 7127 | "Do not send outside local AS (well-known community)\n" |
| 7128 | "Do not advertise to any peer (well-known community)\n" |
| 7129 | "Do not export to next AS (well-known community)\n") |
| 7130 | |
| 7131 | ALIAS (show_ip_bgp_community, |
| 7132 | show_ip_bgp_community4_cmd, |
| 7133 | "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)", |
| 7134 | SHOW_STR |
| 7135 | IP_STR |
| 7136 | BGP_STR |
| 7137 | "Display routes matching the communities\n" |
| 7138 | "community number\n" |
| 7139 | "Do not send outside local AS (well-known community)\n" |
| 7140 | "Do not advertise to any peer (well-known community)\n" |
| 7141 | "Do not export to next AS (well-known community)\n" |
| 7142 | "community number\n" |
| 7143 | "Do not send outside local AS (well-known community)\n" |
| 7144 | "Do not advertise to any peer (well-known community)\n" |
| 7145 | "Do not export to next AS (well-known community)\n" |
| 7146 | "community number\n" |
| 7147 | "Do not send outside local AS (well-known community)\n" |
| 7148 | "Do not advertise to any peer (well-known community)\n" |
| 7149 | "Do not export to next AS (well-known community)\n" |
| 7150 | "community number\n" |
| 7151 | "Do not send outside local AS (well-known community)\n" |
| 7152 | "Do not advertise to any peer (well-known community)\n" |
| 7153 | "Do not export to next AS (well-known community)\n") |
| 7154 | |
| 7155 | DEFUN (show_ip_bgp_ipv4_community, |
| 7156 | show_ip_bgp_ipv4_community_cmd, |
| 7157 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7158 | SHOW_STR |
| 7159 | IP_STR |
| 7160 | BGP_STR |
| 7161 | "Address family\n" |
| 7162 | "Address Family modifier\n" |
| 7163 | "Address Family modifier\n" |
| 7164 | "Display routes matching the communities\n" |
| 7165 | "community number\n" |
| 7166 | "Do not send outside local AS (well-known community)\n" |
| 7167 | "Do not advertise to any peer (well-known community)\n" |
| 7168 | "Do not export to next AS (well-known community)\n") |
| 7169 | { |
| 7170 | if (strncmp (argv[0], "m", 1) == 0) |
| 7171 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 7172 | |
| 7173 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 7174 | } |
| 7175 | |
| 7176 | ALIAS (show_ip_bgp_ipv4_community, |
| 7177 | show_ip_bgp_ipv4_community2_cmd, |
| 7178 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7179 | SHOW_STR |
| 7180 | IP_STR |
| 7181 | BGP_STR |
| 7182 | "Address family\n" |
| 7183 | "Address Family modifier\n" |
| 7184 | "Address Family modifier\n" |
| 7185 | "Display routes matching the communities\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 | ALIAS (show_ip_bgp_ipv4_community, |
| 7196 | show_ip_bgp_ipv4_community3_cmd, |
| 7197 | "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)", |
| 7198 | SHOW_STR |
| 7199 | IP_STR |
| 7200 | BGP_STR |
| 7201 | "Address family\n" |
| 7202 | "Address Family modifier\n" |
| 7203 | "Address Family modifier\n" |
| 7204 | "Display routes matching the communities\n" |
| 7205 | "community number\n" |
| 7206 | "Do not send outside local AS (well-known community)\n" |
| 7207 | "Do not advertise to any peer (well-known community)\n" |
| 7208 | "Do not export to next AS (well-known community)\n" |
| 7209 | "community number\n" |
| 7210 | "Do not send outside local AS (well-known community)\n" |
| 7211 | "Do not advertise to any peer (well-known community)\n" |
| 7212 | "Do not export to next AS (well-known community)\n" |
| 7213 | "community number\n" |
| 7214 | "Do not send outside local AS (well-known community)\n" |
| 7215 | "Do not advertise to any peer (well-known community)\n" |
| 7216 | "Do not export to next AS (well-known community)\n") |
| 7217 | |
| 7218 | ALIAS (show_ip_bgp_ipv4_community, |
| 7219 | show_ip_bgp_ipv4_community4_cmd, |
| 7220 | "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)", |
| 7221 | SHOW_STR |
| 7222 | IP_STR |
| 7223 | BGP_STR |
| 7224 | "Address family\n" |
| 7225 | "Address Family modifier\n" |
| 7226 | "Address Family modifier\n" |
| 7227 | "Display routes matching the communities\n" |
| 7228 | "community number\n" |
| 7229 | "Do not send outside local AS (well-known community)\n" |
| 7230 | "Do not advertise to any peer (well-known community)\n" |
| 7231 | "Do not export to next AS (well-known community)\n" |
| 7232 | "community number\n" |
| 7233 | "Do not send outside local AS (well-known community)\n" |
| 7234 | "Do not advertise to any peer (well-known community)\n" |
| 7235 | "Do not export to next AS (well-known community)\n" |
| 7236 | "community number\n" |
| 7237 | "Do not send outside local AS (well-known community)\n" |
| 7238 | "Do not advertise to any peer (well-known community)\n" |
| 7239 | "Do not export to next AS (well-known community)\n" |
| 7240 | "community number\n" |
| 7241 | "Do not send outside local AS (well-known community)\n" |
| 7242 | "Do not advertise to any peer (well-known community)\n" |
| 7243 | "Do not export to next AS (well-known community)\n") |
| 7244 | |
| 7245 | DEFUN (show_ip_bgp_community_exact, |
| 7246 | show_ip_bgp_community_exact_cmd, |
| 7247 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7248 | SHOW_STR |
| 7249 | IP_STR |
| 7250 | BGP_STR |
| 7251 | "Display routes matching the communities\n" |
| 7252 | "community number\n" |
| 7253 | "Do not send outside local AS (well-known community)\n" |
| 7254 | "Do not advertise to any peer (well-known community)\n" |
| 7255 | "Do not export to next AS (well-known community)\n" |
| 7256 | "Exact match of the communities") |
| 7257 | { |
| 7258 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7259 | } |
| 7260 | |
| 7261 | ALIAS (show_ip_bgp_community_exact, |
| 7262 | show_ip_bgp_community2_exact_cmd, |
| 7263 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7264 | SHOW_STR |
| 7265 | IP_STR |
| 7266 | BGP_STR |
| 7267 | "Display routes matching the communities\n" |
| 7268 | "community number\n" |
| 7269 | "Do not send outside local AS (well-known community)\n" |
| 7270 | "Do not advertise to any peer (well-known community)\n" |
| 7271 | "Do not export to next AS (well-known community)\n" |
| 7272 | "community number\n" |
| 7273 | "Do not send outside local AS (well-known community)\n" |
| 7274 | "Do not advertise to any peer (well-known community)\n" |
| 7275 | "Do not export to next AS (well-known community)\n" |
| 7276 | "Exact match of the communities") |
| 7277 | |
| 7278 | ALIAS (show_ip_bgp_community_exact, |
| 7279 | show_ip_bgp_community3_exact_cmd, |
| 7280 | "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", |
| 7281 | SHOW_STR |
| 7282 | IP_STR |
| 7283 | BGP_STR |
| 7284 | "Display routes matching the communities\n" |
| 7285 | "community number\n" |
| 7286 | "Do not send outside local AS (well-known community)\n" |
| 7287 | "Do not advertise to any peer (well-known community)\n" |
| 7288 | "Do not export to next AS (well-known community)\n" |
| 7289 | "community number\n" |
| 7290 | "Do not send outside local AS (well-known community)\n" |
| 7291 | "Do not advertise to any peer (well-known community)\n" |
| 7292 | "Do not export to next AS (well-known community)\n" |
| 7293 | "community number\n" |
| 7294 | "Do not send outside local AS (well-known community)\n" |
| 7295 | "Do not advertise to any peer (well-known community)\n" |
| 7296 | "Do not export to next AS (well-known community)\n" |
| 7297 | "Exact match of the communities") |
| 7298 | |
| 7299 | ALIAS (show_ip_bgp_community_exact, |
| 7300 | show_ip_bgp_community4_exact_cmd, |
| 7301 | "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", |
| 7302 | SHOW_STR |
| 7303 | IP_STR |
| 7304 | BGP_STR |
| 7305 | "Display routes matching the communities\n" |
| 7306 | "community number\n" |
| 7307 | "Do not send outside local AS (well-known community)\n" |
| 7308 | "Do not advertise to any peer (well-known community)\n" |
| 7309 | "Do not export to next AS (well-known community)\n" |
| 7310 | "community number\n" |
| 7311 | "Do not send outside local AS (well-known community)\n" |
| 7312 | "Do not advertise to any peer (well-known community)\n" |
| 7313 | "Do not export to next AS (well-known community)\n" |
| 7314 | "community number\n" |
| 7315 | "Do not send outside local AS (well-known community)\n" |
| 7316 | "Do not advertise to any peer (well-known community)\n" |
| 7317 | "Do not export to next AS (well-known community)\n" |
| 7318 | "community number\n" |
| 7319 | "Do not send outside local AS (well-known community)\n" |
| 7320 | "Do not advertise to any peer (well-known community)\n" |
| 7321 | "Do not export to next AS (well-known community)\n" |
| 7322 | "Exact match of the communities") |
| 7323 | |
| 7324 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 7325 | show_ip_bgp_ipv4_community_exact_cmd, |
| 7326 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7327 | SHOW_STR |
| 7328 | IP_STR |
| 7329 | BGP_STR |
| 7330 | "Address family\n" |
| 7331 | "Address Family modifier\n" |
| 7332 | "Address Family modifier\n" |
| 7333 | "Display routes matching the communities\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 | if (strncmp (argv[0], "m", 1) == 0) |
| 7341 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 7342 | |
| 7343 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7344 | } |
| 7345 | |
| 7346 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7347 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 7348 | "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", |
| 7349 | SHOW_STR |
| 7350 | IP_STR |
| 7351 | BGP_STR |
| 7352 | "Address family\n" |
| 7353 | "Address Family modifier\n" |
| 7354 | "Address Family modifier\n" |
| 7355 | "Display routes matching the communities\n" |
| 7356 | "community number\n" |
| 7357 | "Do not send outside local AS (well-known community)\n" |
| 7358 | "Do not advertise to any peer (well-known community)\n" |
| 7359 | "Do not export to next AS (well-known community)\n" |
| 7360 | "community number\n" |
| 7361 | "Do not send outside local AS (well-known community)\n" |
| 7362 | "Do not advertise to any peer (well-known community)\n" |
| 7363 | "Do not export to next AS (well-known community)\n" |
| 7364 | "Exact match of the communities") |
| 7365 | |
| 7366 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7367 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 7368 | "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", |
| 7369 | SHOW_STR |
| 7370 | IP_STR |
| 7371 | BGP_STR |
| 7372 | "Address family\n" |
| 7373 | "Address Family modifier\n" |
| 7374 | "Address Family modifier\n" |
| 7375 | "Display routes matching the communities\n" |
| 7376 | "community number\n" |
| 7377 | "Do not send outside local AS (well-known community)\n" |
| 7378 | "Do not advertise to any peer (well-known community)\n" |
| 7379 | "Do not export to next AS (well-known community)\n" |
| 7380 | "community number\n" |
| 7381 | "Do not send outside local AS (well-known community)\n" |
| 7382 | "Do not advertise to any peer (well-known community)\n" |
| 7383 | "Do not export to next AS (well-known community)\n" |
| 7384 | "community number\n" |
| 7385 | "Do not send outside local AS (well-known community)\n" |
| 7386 | "Do not advertise to any peer (well-known community)\n" |
| 7387 | "Do not export to next AS (well-known community)\n" |
| 7388 | "Exact match of the communities") |
| 7389 | |
| 7390 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7391 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 7392 | "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", |
| 7393 | SHOW_STR |
| 7394 | IP_STR |
| 7395 | BGP_STR |
| 7396 | "Address family\n" |
| 7397 | "Address Family modifier\n" |
| 7398 | "Address Family modifier\n" |
| 7399 | "Display routes matching the communities\n" |
| 7400 | "community number\n" |
| 7401 | "Do not send outside local AS (well-known community)\n" |
| 7402 | "Do not advertise to any peer (well-known community)\n" |
| 7403 | "Do not export to next AS (well-known community)\n" |
| 7404 | "community number\n" |
| 7405 | "Do not send outside local AS (well-known community)\n" |
| 7406 | "Do not advertise to any peer (well-known community)\n" |
| 7407 | "Do not export to next AS (well-known community)\n" |
| 7408 | "community number\n" |
| 7409 | "Do not send outside local AS (well-known community)\n" |
| 7410 | "Do not advertise to any peer (well-known community)\n" |
| 7411 | "Do not export to next AS (well-known community)\n" |
| 7412 | "community number\n" |
| 7413 | "Do not send outside local AS (well-known community)\n" |
| 7414 | "Do not advertise to any peer (well-known community)\n" |
| 7415 | "Do not export to next AS (well-known community)\n" |
| 7416 | "Exact match of the communities") |
| 7417 | |
| 7418 | #ifdef HAVE_IPV6 |
| 7419 | DEFUN (show_bgp_community, |
| 7420 | show_bgp_community_cmd, |
| 7421 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7422 | SHOW_STR |
| 7423 | BGP_STR |
| 7424 | "Display routes matching the communities\n" |
| 7425 | "community number\n" |
| 7426 | "Do not send outside local AS (well-known community)\n" |
| 7427 | "Do not advertise to any peer (well-known community)\n" |
| 7428 | "Do not export to next AS (well-known community)\n") |
| 7429 | { |
| 7430 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7431 | } |
| 7432 | |
| 7433 | ALIAS (show_bgp_community, |
| 7434 | show_bgp_ipv6_community_cmd, |
| 7435 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 7436 | SHOW_STR |
| 7437 | BGP_STR |
| 7438 | "Address family\n" |
| 7439 | "Display routes matching the communities\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_community2_cmd, |
| 7447 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7448 | SHOW_STR |
| 7449 | BGP_STR |
| 7450 | "Display routes matching the communities\n" |
| 7451 | "community number\n" |
| 7452 | "Do not send outside local AS (well-known community)\n" |
| 7453 | "Do not advertise to any peer (well-known community)\n" |
| 7454 | "Do not export to next AS (well-known community)\n" |
| 7455 | "community number\n" |
| 7456 | "Do not send outside local AS (well-known community)\n" |
| 7457 | "Do not advertise to any peer (well-known community)\n" |
| 7458 | "Do not export to next AS (well-known community)\n") |
| 7459 | |
| 7460 | ALIAS (show_bgp_community, |
| 7461 | show_bgp_ipv6_community2_cmd, |
| 7462 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7463 | SHOW_STR |
| 7464 | BGP_STR |
| 7465 | "Address family\n" |
| 7466 | "Display routes matching the communities\n" |
| 7467 | "community number\n" |
| 7468 | "Do not send outside local AS (well-known community)\n" |
| 7469 | "Do not advertise to any peer (well-known community)\n" |
| 7470 | "Do not export to next AS (well-known community)\n" |
| 7471 | "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 | |
| 7476 | ALIAS (show_bgp_community, |
| 7477 | show_bgp_community3_cmd, |
| 7478 | "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)", |
| 7479 | SHOW_STR |
| 7480 | BGP_STR |
| 7481 | "Display routes matching the communities\n" |
| 7482 | "community number\n" |
| 7483 | "Do not send outside local AS (well-known community)\n" |
| 7484 | "Do not advertise to any peer (well-known community)\n" |
| 7485 | "Do not export to next AS (well-known community)\n" |
| 7486 | "community number\n" |
| 7487 | "Do not send outside local AS (well-known community)\n" |
| 7488 | "Do not advertise to any peer (well-known community)\n" |
| 7489 | "Do not export to next AS (well-known community)\n" |
| 7490 | "community number\n" |
| 7491 | "Do not send outside local AS (well-known community)\n" |
| 7492 | "Do not advertise to any peer (well-known community)\n" |
| 7493 | "Do not export to next AS (well-known community)\n") |
| 7494 | |
| 7495 | ALIAS (show_bgp_community, |
| 7496 | show_bgp_ipv6_community3_cmd, |
| 7497 | "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)", |
| 7498 | SHOW_STR |
| 7499 | BGP_STR |
| 7500 | "Address family\n" |
| 7501 | "Display routes matching the communities\n" |
| 7502 | "community number\n" |
| 7503 | "Do not send outside local AS (well-known community)\n" |
| 7504 | "Do not advertise to any peer (well-known community)\n" |
| 7505 | "Do not export to next AS (well-known community)\n" |
| 7506 | "community number\n" |
| 7507 | "Do not send outside local AS (well-known community)\n" |
| 7508 | "Do not advertise to any peer (well-known community)\n" |
| 7509 | "Do not export to next AS (well-known community)\n" |
| 7510 | "community number\n" |
| 7511 | "Do not send outside local AS (well-known community)\n" |
| 7512 | "Do not advertise to any peer (well-known community)\n" |
| 7513 | "Do not export to next AS (well-known community)\n") |
| 7514 | |
| 7515 | ALIAS (show_bgp_community, |
| 7516 | show_bgp_community4_cmd, |
| 7517 | "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)", |
| 7518 | SHOW_STR |
| 7519 | BGP_STR |
| 7520 | "Display routes matching the communities\n" |
| 7521 | "community number\n" |
| 7522 | "Do not send outside local AS (well-known community)\n" |
| 7523 | "Do not advertise to any peer (well-known community)\n" |
| 7524 | "Do not export to next AS (well-known community)\n" |
| 7525 | "community number\n" |
| 7526 | "Do not send outside local AS (well-known community)\n" |
| 7527 | "Do not advertise to any peer (well-known community)\n" |
| 7528 | "Do not export to next AS (well-known community)\n" |
| 7529 | "community number\n" |
| 7530 | "Do not send outside local AS (well-known community)\n" |
| 7531 | "Do not advertise to any peer (well-known community)\n" |
| 7532 | "Do not export to next AS (well-known community)\n" |
| 7533 | "community number\n" |
| 7534 | "Do not send outside local AS (well-known community)\n" |
| 7535 | "Do not advertise to any peer (well-known community)\n" |
| 7536 | "Do not export to next AS (well-known community)\n") |
| 7537 | |
| 7538 | ALIAS (show_bgp_community, |
| 7539 | show_bgp_ipv6_community4_cmd, |
| 7540 | "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)", |
| 7541 | SHOW_STR |
| 7542 | BGP_STR |
| 7543 | "Address family\n" |
| 7544 | "Display routes matching the communities\n" |
| 7545 | "community number\n" |
| 7546 | "Do not send outside local AS (well-known community)\n" |
| 7547 | "Do not advertise to any peer (well-known community)\n" |
| 7548 | "Do not export to next AS (well-known community)\n" |
| 7549 | "community number\n" |
| 7550 | "Do not send outside local AS (well-known community)\n" |
| 7551 | "Do not advertise to any peer (well-known community)\n" |
| 7552 | "Do not export to next AS (well-known community)\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 | |
| 7562 | /* old command */ |
| 7563 | DEFUN (show_ipv6_bgp_community, |
| 7564 | show_ipv6_bgp_community_cmd, |
| 7565 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7566 | SHOW_STR |
| 7567 | IPV6_STR |
| 7568 | BGP_STR |
| 7569 | "Display routes matching the communities\n" |
| 7570 | "community number\n" |
| 7571 | "Do not send outside local AS (well-known community)\n" |
| 7572 | "Do not advertise to any peer (well-known community)\n" |
| 7573 | "Do not export to next AS (well-known community)\n") |
| 7574 | { |
| 7575 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7576 | } |
| 7577 | |
| 7578 | /* old command */ |
| 7579 | ALIAS (show_ipv6_bgp_community, |
| 7580 | show_ipv6_bgp_community2_cmd, |
| 7581 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7582 | SHOW_STR |
| 7583 | IPV6_STR |
| 7584 | BGP_STR |
| 7585 | "Display routes matching the communities\n" |
| 7586 | "community number\n" |
| 7587 | "Do not send outside local AS (well-known community)\n" |
| 7588 | "Do not advertise to any peer (well-known community)\n" |
| 7589 | "Do not export to next AS (well-known community)\n" |
| 7590 | "community number\n" |
| 7591 | "Do not send outside local AS (well-known community)\n" |
| 7592 | "Do not advertise to any peer (well-known community)\n" |
| 7593 | "Do not export to next AS (well-known community)\n") |
| 7594 | |
| 7595 | /* old command */ |
| 7596 | ALIAS (show_ipv6_bgp_community, |
| 7597 | show_ipv6_bgp_community3_cmd, |
| 7598 | "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)", |
| 7599 | SHOW_STR |
| 7600 | IPV6_STR |
| 7601 | BGP_STR |
| 7602 | "Display routes matching the communities\n" |
| 7603 | "community number\n" |
| 7604 | "Do not send outside local AS (well-known community)\n" |
| 7605 | "Do not advertise to any peer (well-known community)\n" |
| 7606 | "Do not export to next AS (well-known community)\n" |
| 7607 | "community number\n" |
| 7608 | "Do not send outside local AS (well-known community)\n" |
| 7609 | "Do not advertise to any peer (well-known community)\n" |
| 7610 | "Do not export to next AS (well-known community)\n" |
| 7611 | "community number\n" |
| 7612 | "Do not send outside local AS (well-known community)\n" |
| 7613 | "Do not advertise to any peer (well-known community)\n" |
| 7614 | "Do not export to next AS (well-known community)\n") |
| 7615 | |
| 7616 | /* old command */ |
| 7617 | ALIAS (show_ipv6_bgp_community, |
| 7618 | show_ipv6_bgp_community4_cmd, |
| 7619 | "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)", |
| 7620 | SHOW_STR |
| 7621 | IPV6_STR |
| 7622 | BGP_STR |
| 7623 | "Display routes matching the communities\n" |
| 7624 | "community number\n" |
| 7625 | "Do not send outside local AS (well-known community)\n" |
| 7626 | "Do not advertise to any peer (well-known community)\n" |
| 7627 | "Do not export to next AS (well-known community)\n" |
| 7628 | "community number\n" |
| 7629 | "Do not send outside local AS (well-known community)\n" |
| 7630 | "Do not advertise to any peer (well-known community)\n" |
| 7631 | "Do not export to next AS (well-known community)\n" |
| 7632 | "community number\n" |
| 7633 | "Do not send outside local AS (well-known community)\n" |
| 7634 | "Do not advertise to any peer (well-known community)\n" |
| 7635 | "Do not export to next AS (well-known community)\n" |
| 7636 | "community number\n" |
| 7637 | "Do not send outside local AS (well-known community)\n" |
| 7638 | "Do not advertise to any peer (well-known community)\n" |
| 7639 | "Do not export to next AS (well-known community)\n") |
| 7640 | |
| 7641 | DEFUN (show_bgp_community_exact, |
| 7642 | show_bgp_community_exact_cmd, |
| 7643 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7644 | SHOW_STR |
| 7645 | BGP_STR |
| 7646 | "Display routes matching the communities\n" |
| 7647 | "community number\n" |
| 7648 | "Do not send outside local AS (well-known community)\n" |
| 7649 | "Do not advertise to any peer (well-known community)\n" |
| 7650 | "Do not export to next AS (well-known community)\n" |
| 7651 | "Exact match of the communities") |
| 7652 | { |
| 7653 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7654 | } |
| 7655 | |
| 7656 | ALIAS (show_bgp_community_exact, |
| 7657 | show_bgp_ipv6_community_exact_cmd, |
| 7658 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7659 | SHOW_STR |
| 7660 | BGP_STR |
| 7661 | "Address family\n" |
| 7662 | "Display routes matching the communities\n" |
| 7663 | "community number\n" |
| 7664 | "Do not send outside local AS (well-known community)\n" |
| 7665 | "Do not advertise to any peer (well-known community)\n" |
| 7666 | "Do not export to next AS (well-known community)\n" |
| 7667 | "Exact match of the communities") |
| 7668 | |
| 7669 | ALIAS (show_bgp_community_exact, |
| 7670 | show_bgp_community2_exact_cmd, |
| 7671 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7672 | SHOW_STR |
| 7673 | BGP_STR |
| 7674 | "Display routes matching the communities\n" |
| 7675 | "community number\n" |
| 7676 | "Do not send outside local AS (well-known community)\n" |
| 7677 | "Do not advertise to any peer (well-known community)\n" |
| 7678 | "Do not export to next AS (well-known community)\n" |
| 7679 | "community number\n" |
| 7680 | "Do not send outside local AS (well-known community)\n" |
| 7681 | "Do not advertise to any peer (well-known community)\n" |
| 7682 | "Do not export to next AS (well-known community)\n" |
| 7683 | "Exact match of the communities") |
| 7684 | |
| 7685 | ALIAS (show_bgp_community_exact, |
| 7686 | show_bgp_ipv6_community2_exact_cmd, |
| 7687 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7688 | SHOW_STR |
| 7689 | BGP_STR |
| 7690 | "Address family\n" |
| 7691 | "Display routes matching the communities\n" |
| 7692 | "community number\n" |
| 7693 | "Do not send outside local AS (well-known community)\n" |
| 7694 | "Do not advertise to any peer (well-known community)\n" |
| 7695 | "Do not export to next AS (well-known community)\n" |
| 7696 | "community number\n" |
| 7697 | "Do not send outside local AS (well-known community)\n" |
| 7698 | "Do not advertise to any peer (well-known community)\n" |
| 7699 | "Do not export to next AS (well-known community)\n" |
| 7700 | "Exact match of the communities") |
| 7701 | |
| 7702 | ALIAS (show_bgp_community_exact, |
| 7703 | show_bgp_community3_exact_cmd, |
| 7704 | "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", |
| 7705 | SHOW_STR |
| 7706 | BGP_STR |
| 7707 | "Display routes matching the communities\n" |
| 7708 | "community number\n" |
| 7709 | "Do not send outside local AS (well-known community)\n" |
| 7710 | "Do not advertise to any peer (well-known community)\n" |
| 7711 | "Do not export to next AS (well-known community)\n" |
| 7712 | "community number\n" |
| 7713 | "Do not send outside local AS (well-known community)\n" |
| 7714 | "Do not advertise to any peer (well-known community)\n" |
| 7715 | "Do not export to next AS (well-known community)\n" |
| 7716 | "community number\n" |
| 7717 | "Do not send outside local AS (well-known community)\n" |
| 7718 | "Do not advertise to any peer (well-known community)\n" |
| 7719 | "Do not export to next AS (well-known community)\n" |
| 7720 | "Exact match of the communities") |
| 7721 | |
| 7722 | ALIAS (show_bgp_community_exact, |
| 7723 | show_bgp_ipv6_community3_exact_cmd, |
| 7724 | "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", |
| 7725 | SHOW_STR |
| 7726 | BGP_STR |
| 7727 | "Address family\n" |
| 7728 | "Display routes matching the communities\n" |
| 7729 | "community number\n" |
| 7730 | "Do not send outside local AS (well-known community)\n" |
| 7731 | "Do not advertise to any peer (well-known community)\n" |
| 7732 | "Do not export to next AS (well-known community)\n" |
| 7733 | "community number\n" |
| 7734 | "Do not send outside local AS (well-known community)\n" |
| 7735 | "Do not advertise to any peer (well-known community)\n" |
| 7736 | "Do not export to next AS (well-known community)\n" |
| 7737 | "community number\n" |
| 7738 | "Do not send outside local AS (well-known community)\n" |
| 7739 | "Do not advertise to any peer (well-known community)\n" |
| 7740 | "Do not export to next AS (well-known community)\n" |
| 7741 | "Exact match of the communities") |
| 7742 | |
| 7743 | ALIAS (show_bgp_community_exact, |
| 7744 | show_bgp_community4_exact_cmd, |
| 7745 | "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", |
| 7746 | SHOW_STR |
| 7747 | BGP_STR |
| 7748 | "Display routes matching the communities\n" |
| 7749 | "community number\n" |
| 7750 | "Do not send outside local AS (well-known community)\n" |
| 7751 | "Do not advertise to any peer (well-known community)\n" |
| 7752 | "Do not export to next AS (well-known community)\n" |
| 7753 | "community number\n" |
| 7754 | "Do not send outside local AS (well-known community)\n" |
| 7755 | "Do not advertise to any peer (well-known community)\n" |
| 7756 | "Do not export to next AS (well-known community)\n" |
| 7757 | "community number\n" |
| 7758 | "Do not send outside local AS (well-known community)\n" |
| 7759 | "Do not advertise to any peer (well-known community)\n" |
| 7760 | "Do not export to next AS (well-known community)\n" |
| 7761 | "community number\n" |
| 7762 | "Do not send outside local AS (well-known community)\n" |
| 7763 | "Do not advertise to any peer (well-known community)\n" |
| 7764 | "Do not export to next AS (well-known community)\n" |
| 7765 | "Exact match of the communities") |
| 7766 | |
| 7767 | ALIAS (show_bgp_community_exact, |
| 7768 | show_bgp_ipv6_community4_exact_cmd, |
| 7769 | "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", |
| 7770 | SHOW_STR |
| 7771 | BGP_STR |
| 7772 | "Address family\n" |
| 7773 | "Display routes matching the communities\n" |
| 7774 | "community number\n" |
| 7775 | "Do not send outside local AS (well-known community)\n" |
| 7776 | "Do not advertise to any peer (well-known community)\n" |
| 7777 | "Do not export to next AS (well-known community)\n" |
| 7778 | "community number\n" |
| 7779 | "Do not send outside local AS (well-known community)\n" |
| 7780 | "Do not advertise to any peer (well-known community)\n" |
| 7781 | "Do not export to next AS (well-known community)\n" |
| 7782 | "community number\n" |
| 7783 | "Do not send outside local AS (well-known community)\n" |
| 7784 | "Do not advertise to any peer (well-known community)\n" |
| 7785 | "Do not export to next AS (well-known community)\n" |
| 7786 | "community number\n" |
| 7787 | "Do not send outside local AS (well-known community)\n" |
| 7788 | "Do not advertise to any peer (well-known community)\n" |
| 7789 | "Do not export to next AS (well-known community)\n" |
| 7790 | "Exact match of the communities") |
| 7791 | |
| 7792 | /* old command */ |
| 7793 | DEFUN (show_ipv6_bgp_community_exact, |
| 7794 | show_ipv6_bgp_community_exact_cmd, |
| 7795 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7796 | SHOW_STR |
| 7797 | IPV6_STR |
| 7798 | BGP_STR |
| 7799 | "Display routes matching the communities\n" |
| 7800 | "community number\n" |
| 7801 | "Do not send outside local AS (well-known community)\n" |
| 7802 | "Do not advertise to any peer (well-known community)\n" |
| 7803 | "Do not export to next AS (well-known community)\n" |
| 7804 | "Exact match of the communities") |
| 7805 | { |
| 7806 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7807 | } |
| 7808 | |
| 7809 | /* old command */ |
| 7810 | ALIAS (show_ipv6_bgp_community_exact, |
| 7811 | show_ipv6_bgp_community2_exact_cmd, |
| 7812 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7813 | SHOW_STR |
| 7814 | IPV6_STR |
| 7815 | BGP_STR |
| 7816 | "Display routes matching the communities\n" |
| 7817 | "community number\n" |
| 7818 | "Do not send outside local AS (well-known community)\n" |
| 7819 | "Do not advertise to any peer (well-known community)\n" |
| 7820 | "Do not export to next AS (well-known community)\n" |
| 7821 | "community number\n" |
| 7822 | "Do not send outside local AS (well-known community)\n" |
| 7823 | "Do not advertise to any peer (well-known community)\n" |
| 7824 | "Do not export to next AS (well-known community)\n" |
| 7825 | "Exact match of the communities") |
| 7826 | |
| 7827 | /* old command */ |
| 7828 | ALIAS (show_ipv6_bgp_community_exact, |
| 7829 | show_ipv6_bgp_community3_exact_cmd, |
| 7830 | "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", |
| 7831 | SHOW_STR |
| 7832 | IPV6_STR |
| 7833 | BGP_STR |
| 7834 | "Display routes matching the communities\n" |
| 7835 | "community number\n" |
| 7836 | "Do not send outside local AS (well-known community)\n" |
| 7837 | "Do not advertise to any peer (well-known community)\n" |
| 7838 | "Do not export to next AS (well-known community)\n" |
| 7839 | "community number\n" |
| 7840 | "Do not send outside local AS (well-known community)\n" |
| 7841 | "Do not advertise to any peer (well-known community)\n" |
| 7842 | "Do not export to next AS (well-known community)\n" |
| 7843 | "community number\n" |
| 7844 | "Do not send outside local AS (well-known community)\n" |
| 7845 | "Do not advertise to any peer (well-known community)\n" |
| 7846 | "Do not export to next AS (well-known community)\n" |
| 7847 | "Exact match of the communities") |
| 7848 | |
| 7849 | /* old command */ |
| 7850 | ALIAS (show_ipv6_bgp_community_exact, |
| 7851 | show_ipv6_bgp_community4_exact_cmd, |
| 7852 | "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", |
| 7853 | SHOW_STR |
| 7854 | IPV6_STR |
| 7855 | BGP_STR |
| 7856 | "Display routes matching the communities\n" |
| 7857 | "community number\n" |
| 7858 | "Do not send outside local AS (well-known community)\n" |
| 7859 | "Do not advertise to any peer (well-known community)\n" |
| 7860 | "Do not export to next AS (well-known community)\n" |
| 7861 | "community number\n" |
| 7862 | "Do not send outside local AS (well-known community)\n" |
| 7863 | "Do not advertise to any peer (well-known community)\n" |
| 7864 | "Do not export to next AS (well-known community)\n" |
| 7865 | "community number\n" |
| 7866 | "Do not send outside local AS (well-known community)\n" |
| 7867 | "Do not advertise to any peer (well-known community)\n" |
| 7868 | "Do not export to next AS (well-known community)\n" |
| 7869 | "community number\n" |
| 7870 | "Do not send outside local AS (well-known community)\n" |
| 7871 | "Do not advertise to any peer (well-known community)\n" |
| 7872 | "Do not export to next AS (well-known community)\n" |
| 7873 | "Exact match of the communities") |
| 7874 | |
| 7875 | /* old command */ |
| 7876 | DEFUN (show_ipv6_mbgp_community, |
| 7877 | show_ipv6_mbgp_community_cmd, |
| 7878 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7879 | SHOW_STR |
| 7880 | IPV6_STR |
| 7881 | MBGP_STR |
| 7882 | "Display routes matching the communities\n" |
| 7883 | "community number\n" |
| 7884 | "Do not send outside local AS (well-known community)\n" |
| 7885 | "Do not advertise to any peer (well-known community)\n" |
| 7886 | "Do not export to next AS (well-known community)\n") |
| 7887 | { |
| 7888 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 7889 | } |
| 7890 | |
| 7891 | /* old command */ |
| 7892 | ALIAS (show_ipv6_mbgp_community, |
| 7893 | show_ipv6_mbgp_community2_cmd, |
| 7894 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7895 | SHOW_STR |
| 7896 | IPV6_STR |
| 7897 | MBGP_STR |
| 7898 | "Display routes matching the communities\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 | "community number\n" |
| 7904 | "Do not send outside local AS (well-known community)\n" |
| 7905 | "Do not advertise to any peer (well-known community)\n" |
| 7906 | "Do not export to next AS (well-known community)\n") |
| 7907 | |
| 7908 | /* old command */ |
| 7909 | ALIAS (show_ipv6_mbgp_community, |
| 7910 | show_ipv6_mbgp_community3_cmd, |
| 7911 | "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)", |
| 7912 | SHOW_STR |
| 7913 | IPV6_STR |
| 7914 | MBGP_STR |
| 7915 | "Display routes matching the communities\n" |
| 7916 | "community number\n" |
| 7917 | "Do not send outside local AS (well-known community)\n" |
| 7918 | "Do not advertise to any peer (well-known community)\n" |
| 7919 | "Do not export to next AS (well-known community)\n" |
| 7920 | "community number\n" |
| 7921 | "Do not send outside local AS (well-known community)\n" |
| 7922 | "Do not advertise to any peer (well-known community)\n" |
| 7923 | "Do not export to next AS (well-known community)\n" |
| 7924 | "community number\n" |
| 7925 | "Do not send outside local AS (well-known community)\n" |
| 7926 | "Do not advertise to any peer (well-known community)\n" |
| 7927 | "Do not export to next AS (well-known community)\n") |
| 7928 | |
| 7929 | /* old command */ |
| 7930 | ALIAS (show_ipv6_mbgp_community, |
| 7931 | show_ipv6_mbgp_community4_cmd, |
| 7932 | "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)", |
| 7933 | SHOW_STR |
| 7934 | IPV6_STR |
| 7935 | MBGP_STR |
| 7936 | "Display routes matching the communities\n" |
| 7937 | "community number\n" |
| 7938 | "Do not send outside local AS (well-known community)\n" |
| 7939 | "Do not advertise to any peer (well-known community)\n" |
| 7940 | "Do not export to next AS (well-known community)\n" |
| 7941 | "community number\n" |
| 7942 | "Do not send outside local AS (well-known community)\n" |
| 7943 | "Do not advertise to any peer (well-known community)\n" |
| 7944 | "Do not export to next AS (well-known community)\n" |
| 7945 | "community number\n" |
| 7946 | "Do not send outside local AS (well-known community)\n" |
| 7947 | "Do not advertise to any peer (well-known community)\n" |
| 7948 | "Do not export to next AS (well-known community)\n" |
| 7949 | "community number\n" |
| 7950 | "Do not send outside local AS (well-known community)\n" |
| 7951 | "Do not advertise to any peer (well-known community)\n" |
| 7952 | "Do not export to next AS (well-known community)\n") |
| 7953 | |
| 7954 | /* old command */ |
| 7955 | DEFUN (show_ipv6_mbgp_community_exact, |
| 7956 | show_ipv6_mbgp_community_exact_cmd, |
| 7957 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7958 | SHOW_STR |
| 7959 | IPV6_STR |
| 7960 | MBGP_STR |
| 7961 | "Display routes matching the communities\n" |
| 7962 | "community number\n" |
| 7963 | "Do not send outside local AS (well-known community)\n" |
| 7964 | "Do not advertise to any peer (well-known community)\n" |
| 7965 | "Do not export to next AS (well-known community)\n" |
| 7966 | "Exact match of the communities") |
| 7967 | { |
| 7968 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 7969 | } |
| 7970 | |
| 7971 | /* old command */ |
| 7972 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7973 | show_ipv6_mbgp_community2_exact_cmd, |
| 7974 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7975 | SHOW_STR |
| 7976 | IPV6_STR |
| 7977 | MBGP_STR |
| 7978 | "Display routes matching the communities\n" |
| 7979 | "community number\n" |
| 7980 | "Do not send outside local AS (well-known community)\n" |
| 7981 | "Do not advertise to any peer (well-known community)\n" |
| 7982 | "Do not export to next AS (well-known community)\n" |
| 7983 | "community number\n" |
| 7984 | "Do not send outside local AS (well-known community)\n" |
| 7985 | "Do not advertise to any peer (well-known community)\n" |
| 7986 | "Do not export to next AS (well-known community)\n" |
| 7987 | "Exact match of the communities") |
| 7988 | |
| 7989 | /* old command */ |
| 7990 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7991 | show_ipv6_mbgp_community3_exact_cmd, |
| 7992 | "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", |
| 7993 | SHOW_STR |
| 7994 | IPV6_STR |
| 7995 | MBGP_STR |
| 7996 | "Display routes matching the communities\n" |
| 7997 | "community number\n" |
| 7998 | "Do not send outside local AS (well-known community)\n" |
| 7999 | "Do not advertise to any peer (well-known community)\n" |
| 8000 | "Do not export to next AS (well-known community)\n" |
| 8001 | "community number\n" |
| 8002 | "Do not send outside local AS (well-known community)\n" |
| 8003 | "Do not advertise to any peer (well-known community)\n" |
| 8004 | "Do not export to next AS (well-known community)\n" |
| 8005 | "community number\n" |
| 8006 | "Do not send outside local AS (well-known community)\n" |
| 8007 | "Do not advertise to any peer (well-known community)\n" |
| 8008 | "Do not export to next AS (well-known community)\n" |
| 8009 | "Exact match of the communities") |
| 8010 | |
| 8011 | /* old command */ |
| 8012 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8013 | show_ipv6_mbgp_community4_exact_cmd, |
| 8014 | "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", |
| 8015 | SHOW_STR |
| 8016 | IPV6_STR |
| 8017 | MBGP_STR |
| 8018 | "Display routes matching the communities\n" |
| 8019 | "community number\n" |
| 8020 | "Do not send outside local AS (well-known community)\n" |
| 8021 | "Do not advertise to any peer (well-known community)\n" |
| 8022 | "Do not export to next AS (well-known community)\n" |
| 8023 | "community number\n" |
| 8024 | "Do not send outside local AS (well-known community)\n" |
| 8025 | "Do not advertise to any peer (well-known community)\n" |
| 8026 | "Do not export to next AS (well-known community)\n" |
| 8027 | "community number\n" |
| 8028 | "Do not send outside local AS (well-known community)\n" |
| 8029 | "Do not advertise to any peer (well-known community)\n" |
| 8030 | "Do not export to next AS (well-known community)\n" |
| 8031 | "community number\n" |
| 8032 | "Do not send outside local AS (well-known community)\n" |
| 8033 | "Do not advertise to any peer (well-known community)\n" |
| 8034 | "Do not export to next AS (well-known community)\n" |
| 8035 | "Exact match of the communities") |
| 8036 | #endif /* HAVE_IPV6 */ |
| 8037 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8038 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8039 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8040 | u_int16_t afi, u_char safi) |
| 8041 | { |
| 8042 | struct community_list *list; |
| 8043 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8044 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8045 | if (list == NULL) |
| 8046 | { |
| 8047 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8048 | VTY_NEWLINE); |
| 8049 | return CMD_WARNING; |
| 8050 | } |
| 8051 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8052 | return bgp_show (vty, NULL, afi, safi, |
| 8053 | (exact ? bgp_show_type_community_list_exact : |
| 8054 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8055 | } |
| 8056 | |
| 8057 | DEFUN (show_ip_bgp_community_list, |
| 8058 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8059 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8060 | SHOW_STR |
| 8061 | IP_STR |
| 8062 | BGP_STR |
| 8063 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8064 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8065 | "community-list name\n") |
| 8066 | { |
| 8067 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8068 | } |
| 8069 | |
| 8070 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8071 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8072 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8073 | SHOW_STR |
| 8074 | IP_STR |
| 8075 | BGP_STR |
| 8076 | "Address family\n" |
| 8077 | "Address Family modifier\n" |
| 8078 | "Address Family modifier\n" |
| 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 | if (strncmp (argv[0], "m", 1) == 0) |
| 8084 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8085 | |
| 8086 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8087 | } |
| 8088 | |
| 8089 | DEFUN (show_ip_bgp_community_list_exact, |
| 8090 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8091 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8092 | SHOW_STR |
| 8093 | IP_STR |
| 8094 | BGP_STR |
| 8095 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8096 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8097 | "community-list name\n" |
| 8098 | "Exact match of the communities\n") |
| 8099 | { |
| 8100 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8101 | } |
| 8102 | |
| 8103 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8104 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8105 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8106 | SHOW_STR |
| 8107 | IP_STR |
| 8108 | BGP_STR |
| 8109 | "Address family\n" |
| 8110 | "Address Family modifier\n" |
| 8111 | "Address Family modifier\n" |
| 8112 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8113 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8114 | "community-list name\n" |
| 8115 | "Exact match of the communities\n") |
| 8116 | { |
| 8117 | if (strncmp (argv[0], "m", 1) == 0) |
| 8118 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8119 | |
| 8120 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8121 | } |
| 8122 | |
| 8123 | #ifdef HAVE_IPV6 |
| 8124 | DEFUN (show_bgp_community_list, |
| 8125 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8126 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8127 | SHOW_STR |
| 8128 | BGP_STR |
| 8129 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8130 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8131 | "community-list name\n") |
| 8132 | { |
| 8133 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8134 | } |
| 8135 | |
| 8136 | ALIAS (show_bgp_community_list, |
| 8137 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8138 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8139 | SHOW_STR |
| 8140 | BGP_STR |
| 8141 | "Address family\n" |
| 8142 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8143 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8144 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8145 | |
| 8146 | /* old command */ |
| 8147 | DEFUN (show_ipv6_bgp_community_list, |
| 8148 | show_ipv6_bgp_community_list_cmd, |
| 8149 | "show ipv6 bgp community-list WORD", |
| 8150 | SHOW_STR |
| 8151 | IPV6_STR |
| 8152 | BGP_STR |
| 8153 | "Display routes matching the community-list\n" |
| 8154 | "community-list name\n") |
| 8155 | { |
| 8156 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8157 | } |
| 8158 | |
| 8159 | /* old command */ |
| 8160 | DEFUN (show_ipv6_mbgp_community_list, |
| 8161 | show_ipv6_mbgp_community_list_cmd, |
| 8162 | "show ipv6 mbgp community-list WORD", |
| 8163 | SHOW_STR |
| 8164 | IPV6_STR |
| 8165 | MBGP_STR |
| 8166 | "Display routes matching the community-list\n" |
| 8167 | "community-list name\n") |
| 8168 | { |
| 8169 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8170 | } |
| 8171 | |
| 8172 | DEFUN (show_bgp_community_list_exact, |
| 8173 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8174 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8175 | SHOW_STR |
| 8176 | BGP_STR |
| 8177 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8178 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8179 | "community-list name\n" |
| 8180 | "Exact match of the communities\n") |
| 8181 | { |
| 8182 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8183 | } |
| 8184 | |
| 8185 | ALIAS (show_bgp_community_list_exact, |
| 8186 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8187 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8188 | SHOW_STR |
| 8189 | BGP_STR |
| 8190 | "Address family\n" |
| 8191 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8192 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8193 | "community-list name\n" |
| 8194 | "Exact match of the communities\n") |
| 8195 | |
| 8196 | /* old command */ |
| 8197 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 8198 | show_ipv6_bgp_community_list_exact_cmd, |
| 8199 | "show ipv6 bgp community-list WORD exact-match", |
| 8200 | SHOW_STR |
| 8201 | IPV6_STR |
| 8202 | BGP_STR |
| 8203 | "Display routes matching the community-list\n" |
| 8204 | "community-list name\n" |
| 8205 | "Exact match of the communities\n") |
| 8206 | { |
| 8207 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8208 | } |
| 8209 | |
| 8210 | /* old command */ |
| 8211 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 8212 | show_ipv6_mbgp_community_list_exact_cmd, |
| 8213 | "show ipv6 mbgp community-list WORD exact-match", |
| 8214 | SHOW_STR |
| 8215 | IPV6_STR |
| 8216 | MBGP_STR |
| 8217 | "Display routes matching the community-list\n" |
| 8218 | "community-list name\n" |
| 8219 | "Exact match of the communities\n") |
| 8220 | { |
| 8221 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 8222 | } |
| 8223 | #endif /* HAVE_IPV6 */ |
| 8224 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8225 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8226 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8227 | safi_t safi, enum bgp_show_type type) |
| 8228 | { |
| 8229 | int ret; |
| 8230 | struct prefix *p; |
| 8231 | |
| 8232 | p = prefix_new(); |
| 8233 | |
| 8234 | ret = str2prefix (prefix, p); |
| 8235 | if (! ret) |
| 8236 | { |
| 8237 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 8238 | return CMD_WARNING; |
| 8239 | } |
| 8240 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8241 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 8242 | prefix_free(p); |
| 8243 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8244 | } |
| 8245 | |
| 8246 | DEFUN (show_ip_bgp_prefix_longer, |
| 8247 | show_ip_bgp_prefix_longer_cmd, |
| 8248 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 8249 | SHOW_STR |
| 8250 | IP_STR |
| 8251 | BGP_STR |
| 8252 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8253 | "Display route and more specific routes\n") |
| 8254 | { |
| 8255 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8256 | bgp_show_type_prefix_longer); |
| 8257 | } |
| 8258 | |
| 8259 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 8260 | show_ip_bgp_flap_prefix_longer_cmd, |
| 8261 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 8262 | SHOW_STR |
| 8263 | IP_STR |
| 8264 | BGP_STR |
| 8265 | "Display flap statistics of routes\n" |
| 8266 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8267 | "Display route and more specific routes\n") |
| 8268 | { |
| 8269 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8270 | bgp_show_type_flap_prefix_longer); |
| 8271 | } |
| 8272 | |
| 8273 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 8274 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 8275 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 8276 | SHOW_STR |
| 8277 | IP_STR |
| 8278 | BGP_STR |
| 8279 | "Address family\n" |
| 8280 | "Address Family modifier\n" |
| 8281 | "Address Family modifier\n" |
| 8282 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8283 | "Display route and more specific routes\n") |
| 8284 | { |
| 8285 | if (strncmp (argv[0], "m", 1) == 0) |
| 8286 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8287 | bgp_show_type_prefix_longer); |
| 8288 | |
| 8289 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8290 | bgp_show_type_prefix_longer); |
| 8291 | } |
| 8292 | |
| 8293 | DEFUN (show_ip_bgp_flap_address, |
| 8294 | show_ip_bgp_flap_address_cmd, |
| 8295 | "show ip bgp flap-statistics A.B.C.D", |
| 8296 | SHOW_STR |
| 8297 | IP_STR |
| 8298 | BGP_STR |
| 8299 | "Display flap statistics of routes\n" |
| 8300 | "Network in the BGP routing table to display\n") |
| 8301 | { |
| 8302 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8303 | bgp_show_type_flap_address); |
| 8304 | } |
| 8305 | |
| 8306 | DEFUN (show_ip_bgp_flap_prefix, |
| 8307 | show_ip_bgp_flap_prefix_cmd, |
| 8308 | "show ip bgp flap-statistics A.B.C.D/M", |
| 8309 | SHOW_STR |
| 8310 | IP_STR |
| 8311 | BGP_STR |
| 8312 | "Display flap statistics of routes\n" |
| 8313 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8314 | { |
| 8315 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8316 | bgp_show_type_flap_prefix); |
| 8317 | } |
| 8318 | #ifdef HAVE_IPV6 |
| 8319 | DEFUN (show_bgp_prefix_longer, |
| 8320 | show_bgp_prefix_longer_cmd, |
| 8321 | "show bgp X:X::X:X/M longer-prefixes", |
| 8322 | SHOW_STR |
| 8323 | BGP_STR |
| 8324 | "IPv6 prefix <network>/<length>\n" |
| 8325 | "Display route and more specific routes\n") |
| 8326 | { |
| 8327 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8328 | bgp_show_type_prefix_longer); |
| 8329 | } |
| 8330 | |
| 8331 | ALIAS (show_bgp_prefix_longer, |
| 8332 | show_bgp_ipv6_prefix_longer_cmd, |
| 8333 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 8334 | SHOW_STR |
| 8335 | BGP_STR |
| 8336 | "Address family\n" |
| 8337 | "IPv6 prefix <network>/<length>\n" |
| 8338 | "Display route and more specific routes\n") |
| 8339 | |
| 8340 | /* old command */ |
| 8341 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 8342 | show_ipv6_bgp_prefix_longer_cmd, |
| 8343 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 8344 | SHOW_STR |
| 8345 | IPV6_STR |
| 8346 | BGP_STR |
| 8347 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8348 | "Display route and more specific routes\n") |
| 8349 | { |
| 8350 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8351 | bgp_show_type_prefix_longer); |
| 8352 | } |
| 8353 | |
| 8354 | /* old command */ |
| 8355 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 8356 | show_ipv6_mbgp_prefix_longer_cmd, |
| 8357 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 8358 | SHOW_STR |
| 8359 | IPV6_STR |
| 8360 | MBGP_STR |
| 8361 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8362 | "Display route and more specific routes\n") |
| 8363 | { |
| 8364 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8365 | bgp_show_type_prefix_longer); |
| 8366 | } |
| 8367 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8368 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8369 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8370 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 8371 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8372 | { |
| 8373 | int ret; |
| 8374 | struct bgp *bgp; |
| 8375 | struct peer *peer; |
| 8376 | union sockunion su; |
| 8377 | |
| 8378 | /* BGP structure lookup. */ |
| 8379 | if (view_name) |
| 8380 | { |
| 8381 | bgp = bgp_lookup_by_name (view_name); |
| 8382 | if (! bgp) |
| 8383 | { |
| 8384 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8385 | return NULL; |
| 8386 | } |
| 8387 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 8388 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8389 | { |
| 8390 | bgp = bgp_get_default (); |
| 8391 | if (! bgp) |
| 8392 | { |
| 8393 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8394 | return NULL; |
| 8395 | } |
| 8396 | } |
| 8397 | |
| 8398 | /* Get peer sockunion. */ |
| 8399 | ret = str2sockunion (ip_str, &su); |
| 8400 | if (ret < 0) |
| 8401 | { |
| 8402 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 8403 | return NULL; |
| 8404 | } |
| 8405 | |
| 8406 | /* Peer structure lookup. */ |
| 8407 | peer = peer_lookup (bgp, &su); |
| 8408 | if (! peer) |
| 8409 | { |
| 8410 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 8411 | return NULL; |
| 8412 | } |
| 8413 | |
| 8414 | return peer; |
| 8415 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8416 | |
| 8417 | enum bgp_stats |
| 8418 | { |
| 8419 | BGP_STATS_MAXBITLEN = 0, |
| 8420 | BGP_STATS_RIB, |
| 8421 | BGP_STATS_PREFIXES, |
| 8422 | BGP_STATS_TOTPLEN, |
| 8423 | BGP_STATS_UNAGGREGATEABLE, |
| 8424 | BGP_STATS_MAX_AGGREGATEABLE, |
| 8425 | BGP_STATS_AGGREGATES, |
| 8426 | BGP_STATS_SPACE, |
| 8427 | BGP_STATS_ASPATH_COUNT, |
| 8428 | BGP_STATS_ASPATH_MAXHOPS, |
| 8429 | BGP_STATS_ASPATH_TOTHOPS, |
| 8430 | BGP_STATS_ASPATH_MAXSIZE, |
| 8431 | BGP_STATS_ASPATH_TOTSIZE, |
| 8432 | BGP_STATS_ASN_HIGHEST, |
| 8433 | BGP_STATS_MAX, |
| 8434 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8435 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8436 | static const char *table_stats_strs[] = |
| 8437 | { |
| 8438 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 8439 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 8440 | [BGP_STATS_RIB] = "Total Advertisements", |
| 8441 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 8442 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 8443 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 8444 | [BGP_STATS_SPACE] = "Address space advertised", |
| 8445 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 8446 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 8447 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 8448 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 8449 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 8450 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 8451 | [BGP_STATS_MAX] = NULL, |
| 8452 | }; |
| 8453 | |
| 8454 | struct bgp_table_stats |
| 8455 | { |
| 8456 | struct bgp_table *table; |
| 8457 | unsigned long long counts[BGP_STATS_MAX]; |
| 8458 | }; |
| 8459 | |
| 8460 | #if 0 |
| 8461 | #define TALLY_SIGFIG 100000 |
| 8462 | static unsigned long |
| 8463 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 8464 | { |
| 8465 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 8466 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 8467 | unsigned long ret = newtot / count; |
| 8468 | |
| 8469 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 8470 | return ret + 1; |
| 8471 | else |
| 8472 | return ret; |
| 8473 | } |
| 8474 | #endif |
| 8475 | |
| 8476 | static int |
| 8477 | bgp_table_stats_walker (struct thread *t) |
| 8478 | { |
| 8479 | struct bgp_node *rn; |
| 8480 | struct bgp_node *top; |
| 8481 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 8482 | unsigned int space = 0; |
| 8483 | |
| 8484 | top = bgp_table_top (ts->table); |
| 8485 | |
| 8486 | switch (top->p.family) |
| 8487 | { |
| 8488 | case AF_INET: |
| 8489 | space = IPV4_MAX_BITLEN; |
| 8490 | break; |
| 8491 | case AF_INET6: |
| 8492 | space = IPV6_MAX_BITLEN; |
| 8493 | break; |
| 8494 | } |
| 8495 | |
| 8496 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 8497 | |
| 8498 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 8499 | { |
| 8500 | struct bgp_info *ri; |
| 8501 | struct bgp_node *prn = rn->parent; |
| 8502 | unsigned int rinum = 0; |
| 8503 | |
| 8504 | if (rn == top) |
| 8505 | continue; |
| 8506 | |
| 8507 | if (!rn->info) |
| 8508 | continue; |
| 8509 | |
| 8510 | ts->counts[BGP_STATS_PREFIXES]++; |
| 8511 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 8512 | |
| 8513 | #if 0 |
| 8514 | ts->counts[BGP_STATS_AVGPLEN] |
| 8515 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 8516 | ts->counts[BGP_STATS_AVGPLEN], |
| 8517 | rn->p.prefixlen); |
| 8518 | #endif |
| 8519 | |
| 8520 | /* check if the prefix is included by any other announcements */ |
| 8521 | while (prn && !prn->info) |
| 8522 | prn = prn->parent; |
| 8523 | |
| 8524 | if (prn == NULL || prn == top) |
| 8525 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 8526 | else if (prn->info) |
| 8527 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 8528 | |
| 8529 | /* announced address space */ |
| 8530 | if (space) |
| 8531 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 8532 | |
| 8533 | for (ri = rn->info; ri; ri = ri->next) |
| 8534 | { |
| 8535 | rinum++; |
| 8536 | ts->counts[BGP_STATS_RIB]++; |
| 8537 | |
| 8538 | if (ri->attr && |
| 8539 | (CHECK_FLAG (ri->attr->flag, |
| 8540 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 8541 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 8542 | |
| 8543 | /* as-path stats */ |
| 8544 | if (ri->attr && ri->attr->aspath) |
| 8545 | { |
| 8546 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 8547 | unsigned int size = aspath_size (ri->attr->aspath); |
| 8548 | as_t highest = aspath_highest (ri->attr->aspath); |
| 8549 | |
| 8550 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 8551 | |
| 8552 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 8553 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 8554 | |
| 8555 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 8556 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 8557 | |
| 8558 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 8559 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 8560 | #if 0 |
| 8561 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 8562 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 8563 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 8564 | hops); |
| 8565 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 8566 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 8567 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 8568 | size); |
| 8569 | #endif |
| 8570 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 8571 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 8572 | } |
| 8573 | } |
| 8574 | } |
| 8575 | return 0; |
| 8576 | } |
| 8577 | |
| 8578 | static int |
| 8579 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 8580 | { |
| 8581 | struct bgp_table_stats ts; |
| 8582 | unsigned int i; |
| 8583 | |
| 8584 | if (!bgp->rib[afi][safi]) |
| 8585 | { |
| 8586 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 8587 | return CMD_WARNING; |
| 8588 | } |
| 8589 | |
| 8590 | memset (&ts, 0, sizeof (ts)); |
| 8591 | ts.table = bgp->rib[afi][safi]; |
| 8592 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 8593 | |
| 8594 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 8595 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 8596 | |
| 8597 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 8598 | { |
| 8599 | if (!table_stats_strs[i]) |
| 8600 | continue; |
| 8601 | |
| 8602 | switch (i) |
| 8603 | { |
| 8604 | #if 0 |
| 8605 | case BGP_STATS_ASPATH_AVGHOPS: |
| 8606 | case BGP_STATS_ASPATH_AVGSIZE: |
| 8607 | case BGP_STATS_AVGPLEN: |
| 8608 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8609 | vty_out (vty, "%12.2f", |
| 8610 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 8611 | break; |
| 8612 | #endif |
| 8613 | case BGP_STATS_ASPATH_TOTHOPS: |
| 8614 | case BGP_STATS_ASPATH_TOTSIZE: |
| 8615 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8616 | vty_out (vty, "%12.2f", |
| 8617 | ts.counts[i] ? |
| 8618 | (float)ts.counts[i] / |
| 8619 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 8620 | : 0); |
| 8621 | break; |
| 8622 | case BGP_STATS_TOTPLEN: |
| 8623 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8624 | vty_out (vty, "%12.2f", |
| 8625 | ts.counts[i] ? |
| 8626 | (float)ts.counts[i] / |
| 8627 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 8628 | : 0); |
| 8629 | break; |
| 8630 | case BGP_STATS_SPACE: |
| 8631 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8632 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 8633 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 8634 | break; |
| 8635 | vty_out (vty, "%30s: ", "\% announced "); |
| 8636 | vty_out (vty, "%12.2f%s", |
| 8637 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
| 8638 | (float)((u_int64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
| 8639 | VTY_NEWLINE); |
| 8640 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 8641 | vty_out (vty, "%12.2f%s", |
| 8642 | (float)ts.counts[BGP_STATS_SPACE] / |
| 8643 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 8644 | VTY_NEWLINE); |
| 8645 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 8646 | break; |
| 8647 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 8648 | vty_out (vty, "%12.2f", |
| 8649 | (float)ts.counts[BGP_STATS_SPACE] / |
| 8650 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 8651 | break; |
| 8652 | default: |
| 8653 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 8654 | vty_out (vty, "%12llu", ts.counts[i]); |
| 8655 | } |
| 8656 | |
| 8657 | vty_out (vty, "%s", VTY_NEWLINE); |
| 8658 | } |
| 8659 | return CMD_SUCCESS; |
| 8660 | } |
| 8661 | |
| 8662 | static int |
| 8663 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 8664 | const char *afi_str, const char *safi_str) |
| 8665 | { |
| 8666 | struct bgp *bgp; |
| 8667 | afi_t afi; |
| 8668 | safi_t safi; |
| 8669 | |
| 8670 | if (name) |
| 8671 | bgp = bgp_lookup_by_name (name); |
| 8672 | else |
| 8673 | bgp = bgp_get_default (); |
| 8674 | |
| 8675 | if (!bgp) |
| 8676 | { |
| 8677 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 8678 | return CMD_WARNING; |
| 8679 | } |
| 8680 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 8681 | { |
| 8682 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 8683 | afi = AFI_IP; |
| 8684 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 8685 | afi = AFI_IP6; |
| 8686 | else |
| 8687 | { |
| 8688 | vty_out (vty, "%% Invalid address family %s%s", |
| 8689 | afi_str, VTY_NEWLINE); |
| 8690 | return CMD_WARNING; |
| 8691 | } |
| 8692 | if (strncmp (safi_str, "m", 1) == 0) |
| 8693 | safi = SAFI_MULTICAST; |
| 8694 | else if (strncmp (safi_str, "u", 1) == 0) |
| 8695 | safi = SAFI_UNICAST; |
| 8696 | else if (strncmp (safi_str, "vpnv4", 5) == 0) |
| 8697 | safi = BGP_SAFI_VPNV4; |
| 8698 | else if (strncmp (safi_str, "vpnv6", 6) == 0) |
| 8699 | safi = BGP_SAFI_VPNV6; |
| 8700 | else |
| 8701 | { |
| 8702 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 8703 | safi_str, VTY_NEWLINE); |
| 8704 | return CMD_WARNING; |
| 8705 | } |
| 8706 | } |
| 8707 | else |
| 8708 | { |
| 8709 | vty_out (vty, "%% Invalid address family %s%s", |
| 8710 | afi_str, VTY_NEWLINE); |
| 8711 | return CMD_WARNING; |
| 8712 | } |
| 8713 | |
| 8714 | if ((afi == AFI_IP && safi == BGP_SAFI_VPNV6) |
| 8715 | || (afi == AFI_IP6 && safi == BGP_SAFI_VPNV4)) |
| 8716 | { |
| 8717 | vty_out (vty, "%% Invalid subsequent address family %s for %s%s", |
| 8718 | afi_str, safi_str, VTY_NEWLINE); |
| 8719 | return CMD_WARNING; |
| 8720 | } |
| 8721 | return bgp_table_stats (vty, bgp, afi, safi); |
| 8722 | } |
| 8723 | |
| 8724 | DEFUN (show_bgp_statistics, |
| 8725 | show_bgp_statistics_cmd, |
| 8726 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 8727 | SHOW_STR |
| 8728 | BGP_STR |
| 8729 | "Address family\n" |
| 8730 | "Address family\n" |
| 8731 | "Address Family modifier\n" |
| 8732 | "Address Family modifier\n" |
| 8733 | "BGP RIB advertisement statistics\n") |
| 8734 | { |
| 8735 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 8736 | } |
| 8737 | |
| 8738 | ALIAS (show_bgp_statistics, |
| 8739 | show_bgp_statistics_vpnv4_cmd, |
| 8740 | "show bgp (ipv4) (vpnv4) statistics", |
| 8741 | SHOW_STR |
| 8742 | BGP_STR |
| 8743 | "Address family\n" |
| 8744 | "Address Family modifier\n" |
| 8745 | "BGP RIB advertisement statistics\n") |
| 8746 | |
| 8747 | DEFUN (show_bgp_statistics_view, |
| 8748 | show_bgp_statistics_view_cmd, |
| 8749 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 8750 | SHOW_STR |
| 8751 | BGP_STR |
| 8752 | "BGP view\n" |
| 8753 | "Address family\n" |
| 8754 | "Address family\n" |
| 8755 | "Address Family modifier\n" |
| 8756 | "Address Family modifier\n" |
| 8757 | "BGP RIB advertisement statistics\n") |
| 8758 | { |
| 8759 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 8760 | } |
| 8761 | |
| 8762 | ALIAS (show_bgp_statistics_view, |
| 8763 | show_bgp_statistics_view_vpnv4_cmd, |
| 8764 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 8765 | SHOW_STR |
| 8766 | BGP_STR |
| 8767 | "BGP view\n" |
| 8768 | "Address family\n" |
| 8769 | "Address Family modifier\n" |
| 8770 | "BGP RIB advertisement statistics\n") |
| 8771 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8772 | enum bgp_pcounts |
| 8773 | { |
| 8774 | PCOUNT_ADJ_IN = 0, |
| 8775 | PCOUNT_DAMPED, |
| 8776 | PCOUNT_REMOVED, |
| 8777 | PCOUNT_HISTORY, |
| 8778 | PCOUNT_STALE, |
| 8779 | PCOUNT_VALID, |
| 8780 | PCOUNT_ALL, |
| 8781 | PCOUNT_COUNTED, |
| 8782 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 8783 | PCOUNT_MAX, |
| 8784 | }; |
| 8785 | |
| 8786 | static const char *pcount_strs[] = |
| 8787 | { |
| 8788 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 8789 | [PCOUNT_DAMPED] = "Damped", |
| 8790 | [PCOUNT_REMOVED] = "Removed", |
| 8791 | [PCOUNT_HISTORY] = "History", |
| 8792 | [PCOUNT_STALE] = "Stale", |
| 8793 | [PCOUNT_VALID] = "Valid", |
| 8794 | [PCOUNT_ALL] = "All RIB", |
| 8795 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 8796 | [PCOUNT_PFCNT] = "Useable", |
| 8797 | [PCOUNT_MAX] = NULL, |
| 8798 | }; |
| 8799 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8800 | struct peer_pcounts |
| 8801 | { |
| 8802 | unsigned int count[PCOUNT_MAX]; |
| 8803 | const struct peer *peer; |
| 8804 | const struct bgp_table *table; |
| 8805 | }; |
| 8806 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8807 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8808 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8809 | { |
| 8810 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8811 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 8812 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8813 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8814 | for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8815 | { |
| 8816 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8817 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8818 | |
| 8819 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 8820 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8821 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8822 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8823 | for (ri = rn->info; ri; ri = ri->next) |
| 8824 | { |
| 8825 | char buf[SU_ADDRSTRLEN]; |
| 8826 | |
| 8827 | if (ri->peer != peer) |
| 8828 | continue; |
| 8829 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8830 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8831 | |
| 8832 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8833 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8834 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8835 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8836 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8837 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8838 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8839 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8840 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8841 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 8842 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8843 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8844 | |
| 8845 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 8846 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8847 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 8848 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8849 | plog_warn (peer->log, |
| 8850 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 8851 | peer->host, |
| 8852 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 8853 | buf, SU_ADDRSTRLEN), |
| 8854 | rn->p.prefixlen, |
| 8855 | ri->flags); |
| 8856 | } |
| 8857 | else |
| 8858 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 8859 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8860 | plog_warn (peer->log, |
| 8861 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 8862 | peer->host, |
| 8863 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 8864 | buf, SU_ADDRSTRLEN), |
| 8865 | rn->p.prefixlen, |
| 8866 | ri->flags); |
| 8867 | } |
| 8868 | } |
| 8869 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8870 | return 0; |
| 8871 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8872 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8873 | static int |
| 8874 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 8875 | { |
| 8876 | struct peer_pcounts pcounts = { .peer = peer }; |
| 8877 | unsigned int i; |
| 8878 | |
| 8879 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 8880 | || !peer->bgp->rib[afi][safi]) |
| 8881 | { |
| 8882 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 8883 | return CMD_WARNING; |
| 8884 | } |
| 8885 | |
| 8886 | memset (&pcounts, 0, sizeof(pcounts)); |
| 8887 | pcounts.peer = peer; |
| 8888 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 8889 | |
| 8890 | /* in-place call via thread subsystem so as to record execution time |
| 8891 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 8892 | * on just vty_read()). |
| 8893 | */ |
| 8894 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 8895 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8896 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 8897 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 8898 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 8899 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 8900 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 8901 | |
| 8902 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8903 | vty_out (vty, "%20s: %-10d%s", |
| 8904 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8905 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 8906 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 8907 | { |
| 8908 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 8909 | peer->host, VTY_NEWLINE); |
| 8910 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 8911 | VTY_NEWLINE); |
| 8912 | } |
| 8913 | |
| 8914 | return CMD_SUCCESS; |
| 8915 | } |
| 8916 | |
| 8917 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 8918 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 8919 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 8920 | SHOW_STR |
| 8921 | IP_STR |
| 8922 | BGP_STR |
| 8923 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8924 | "Neighbor to display information about\n" |
| 8925 | "Neighbor to display information about\n" |
| 8926 | "Display detailed prefix count information\n") |
| 8927 | { |
| 8928 | struct peer *peer; |
| 8929 | |
| 8930 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8931 | if (! peer) |
| 8932 | return CMD_WARNING; |
| 8933 | |
| 8934 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 8935 | } |
| 8936 | |
| 8937 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 8938 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 8939 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 8940 | SHOW_STR |
| 8941 | BGP_STR |
| 8942 | "Address family\n" |
| 8943 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8944 | "Neighbor to display information about\n" |
| 8945 | "Neighbor to display information about\n" |
| 8946 | "Display detailed prefix count information\n") |
| 8947 | { |
| 8948 | struct peer *peer; |
| 8949 | |
| 8950 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8951 | if (! peer) |
| 8952 | return CMD_WARNING; |
| 8953 | |
| 8954 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 8955 | } |
| 8956 | |
| 8957 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 8958 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 8959 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 8960 | SHOW_STR |
| 8961 | IP_STR |
| 8962 | BGP_STR |
| 8963 | "Address family\n" |
| 8964 | "Address Family modifier\n" |
| 8965 | "Address Family modifier\n" |
| 8966 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8967 | "Neighbor to display information about\n" |
| 8968 | "Neighbor to display information about\n" |
| 8969 | "Display detailed prefix count information\n") |
| 8970 | { |
| 8971 | struct peer *peer; |
| 8972 | |
| 8973 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8974 | if (! peer) |
| 8975 | return CMD_WARNING; |
| 8976 | |
| 8977 | if (strncmp (argv[0], "m", 1) == 0) |
| 8978 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 8979 | |
| 8980 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 8981 | } |
| 8982 | |
| 8983 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 8984 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 8985 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 8986 | SHOW_STR |
| 8987 | IP_STR |
| 8988 | BGP_STR |
| 8989 | "Address family\n" |
| 8990 | "Address Family modifier\n" |
| 8991 | "Address Family modifier\n" |
| 8992 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8993 | "Neighbor to display information about\n" |
| 8994 | "Neighbor to display information about\n" |
| 8995 | "Display detailed prefix count information\n") |
| 8996 | { |
| 8997 | struct peer *peer; |
| 8998 | |
| 8999 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9000 | if (! peer) |
| 9001 | return CMD_WARNING; |
| 9002 | |
| 9003 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9004 | } |
| 9005 | |
| 9006 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9007 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9008 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9009 | int in) |
| 9010 | { |
| 9011 | struct bgp_table *table; |
| 9012 | struct bgp_adj_in *ain; |
| 9013 | struct bgp_adj_out *adj; |
| 9014 | unsigned long output_count; |
| 9015 | struct bgp_node *rn; |
| 9016 | int header1 = 1; |
| 9017 | struct bgp *bgp; |
| 9018 | int header2 = 1; |
| 9019 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9020 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9021 | |
| 9022 | if (! bgp) |
| 9023 | return; |
| 9024 | |
| 9025 | table = bgp->rib[afi][safi]; |
| 9026 | |
| 9027 | output_count = 0; |
| 9028 | |
| 9029 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9030 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9031 | { |
| 9032 | 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] | 9033 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9034 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9035 | |
| 9036 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9037 | VTY_NEWLINE, VTY_NEWLINE); |
| 9038 | header1 = 0; |
| 9039 | } |
| 9040 | |
| 9041 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9042 | if (in) |
| 9043 | { |
| 9044 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9045 | if (ain->peer == peer) |
| 9046 | { |
| 9047 | if (header1) |
| 9048 | { |
| 9049 | 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] | 9050 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9051 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9052 | header1 = 0; |
| 9053 | } |
| 9054 | if (header2) |
| 9055 | { |
| 9056 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9057 | header2 = 0; |
| 9058 | } |
| 9059 | if (ain->attr) |
| 9060 | { |
| 9061 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9062 | output_count++; |
| 9063 | } |
| 9064 | } |
| 9065 | } |
| 9066 | else |
| 9067 | { |
| 9068 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9069 | if (adj->peer == peer) |
| 9070 | { |
| 9071 | if (header1) |
| 9072 | { |
| 9073 | 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] | 9074 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9075 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9076 | header1 = 0; |
| 9077 | } |
| 9078 | if (header2) |
| 9079 | { |
| 9080 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9081 | header2 = 0; |
| 9082 | } |
| 9083 | if (adj->attr) |
| 9084 | { |
| 9085 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9086 | output_count++; |
| 9087 | } |
| 9088 | } |
| 9089 | } |
| 9090 | |
| 9091 | if (output_count != 0) |
| 9092 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9093 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9094 | } |
| 9095 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9096 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9097 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9098 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9099 | if (! peer || ! peer->afc[afi][safi]) |
| 9100 | { |
| 9101 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9102 | return CMD_WARNING; |
| 9103 | } |
| 9104 | |
| 9105 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9106 | { |
| 9107 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9108 | VTY_NEWLINE); |
| 9109 | return CMD_WARNING; |
| 9110 | } |
| 9111 | |
| 9112 | show_adj_route (vty, peer, afi, safi, in); |
| 9113 | |
| 9114 | return CMD_SUCCESS; |
| 9115 | } |
| 9116 | |
| 9117 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 9118 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9119 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9120 | SHOW_STR |
| 9121 | IP_STR |
| 9122 | BGP_STR |
| 9123 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9124 | "Neighbor to display information about\n" |
| 9125 | "Neighbor to display information about\n" |
| 9126 | "Display the routes advertised to a BGP neighbor\n") |
| 9127 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9128 | struct peer *peer; |
| 9129 | |
| 9130 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9131 | if (! peer) |
| 9132 | return CMD_WARNING; |
| 9133 | |
| 9134 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9135 | } |
| 9136 | |
| 9137 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9138 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9139 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9140 | SHOW_STR |
| 9141 | IP_STR |
| 9142 | BGP_STR |
| 9143 | "Address family\n" |
| 9144 | "Address Family modifier\n" |
| 9145 | "Address Family modifier\n" |
| 9146 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9147 | "Neighbor to display information about\n" |
| 9148 | "Neighbor to display information about\n" |
| 9149 | "Display the routes advertised to a BGP neighbor\n") |
| 9150 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9151 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9152 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9153 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9154 | if (! peer) |
| 9155 | return CMD_WARNING; |
| 9156 | |
| 9157 | if (strncmp (argv[0], "m", 1) == 0) |
| 9158 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 9159 | |
| 9160 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9161 | } |
| 9162 | |
| 9163 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9164 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 9165 | show_bgp_view_neighbor_advertised_route_cmd, |
| 9166 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9167 | SHOW_STR |
| 9168 | BGP_STR |
| 9169 | "BGP view\n" |
| 9170 | "View name\n" |
| 9171 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9172 | "Neighbor to display information about\n" |
| 9173 | "Neighbor to display information about\n" |
| 9174 | "Display the routes advertised to a BGP neighbor\n") |
| 9175 | { |
| 9176 | struct peer *peer; |
| 9177 | |
| 9178 | if (argc == 2) |
| 9179 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9180 | else |
| 9181 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9182 | |
| 9183 | if (! peer) |
| 9184 | return CMD_WARNING; |
| 9185 | |
| 9186 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 9187 | } |
| 9188 | |
| 9189 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 9190 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 9191 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9192 | SHOW_STR |
| 9193 | BGP_STR |
| 9194 | "BGP view\n" |
| 9195 | "View name\n" |
| 9196 | "Address family\n" |
| 9197 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9198 | "Neighbor to display information about\n" |
| 9199 | "Neighbor to display information about\n" |
| 9200 | "Display the routes advertised to a BGP neighbor\n") |
| 9201 | |
| 9202 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 9203 | show_bgp_view_neighbor_received_routes_cmd, |
| 9204 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9205 | SHOW_STR |
| 9206 | BGP_STR |
| 9207 | "BGP view\n" |
| 9208 | "View name\n" |
| 9209 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9210 | "Neighbor to display information about\n" |
| 9211 | "Neighbor to display information about\n" |
| 9212 | "Display the received routes from neighbor\n") |
| 9213 | { |
| 9214 | struct peer *peer; |
| 9215 | |
| 9216 | if (argc == 2) |
| 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 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 9225 | } |
| 9226 | |
| 9227 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 9228 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 9229 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9230 | SHOW_STR |
| 9231 | BGP_STR |
| 9232 | "BGP view\n" |
| 9233 | "View name\n" |
| 9234 | "Address family\n" |
| 9235 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9236 | "Neighbor to display information about\n" |
| 9237 | "Neighbor to display information about\n" |
| 9238 | "Display the received routes from neighbor\n") |
| 9239 | |
| 9240 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9241 | show_bgp_neighbor_advertised_route_cmd, |
| 9242 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9243 | SHOW_STR |
| 9244 | BGP_STR |
| 9245 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9246 | "Neighbor to display information about\n" |
| 9247 | "Neighbor to display information about\n" |
| 9248 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9249 | |
| 9250 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9251 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 9252 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9253 | SHOW_STR |
| 9254 | BGP_STR |
| 9255 | "Address family\n" |
| 9256 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9257 | "Neighbor to display information about\n" |
| 9258 | "Neighbor to display information about\n" |
| 9259 | "Display the routes advertised to a BGP neighbor\n") |
| 9260 | |
| 9261 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9262 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9263 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 9264 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9265 | SHOW_STR |
| 9266 | IPV6_STR |
| 9267 | BGP_STR |
| 9268 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9269 | "Neighbor to display information about\n" |
| 9270 | "Neighbor to display information about\n" |
| 9271 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9272 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9273 | /* old command */ |
| 9274 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 9275 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 9276 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9277 | SHOW_STR |
| 9278 | IPV6_STR |
| 9279 | MBGP_STR |
| 9280 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9281 | "Neighbor to display information about\n" |
| 9282 | "Neighbor to display information about\n" |
| 9283 | "Display the routes advertised to a BGP neighbor\n") |
| 9284 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9285 | struct peer *peer; |
| 9286 | |
| 9287 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9288 | if (! peer) |
| 9289 | return CMD_WARNING; |
| 9290 | |
| 9291 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9292 | } |
| 9293 | #endif /* HAVE_IPV6 */ |
| 9294 | |
| 9295 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 9296 | show_ip_bgp_neighbor_received_routes_cmd, |
| 9297 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9298 | SHOW_STR |
| 9299 | IP_STR |
| 9300 | BGP_STR |
| 9301 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9302 | "Neighbor to display information about\n" |
| 9303 | "Neighbor to display information about\n" |
| 9304 | "Display the received routes from neighbor\n") |
| 9305 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9306 | struct peer *peer; |
| 9307 | |
| 9308 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9309 | if (! peer) |
| 9310 | return CMD_WARNING; |
| 9311 | |
| 9312 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9313 | } |
| 9314 | |
| 9315 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 9316 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 9317 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9318 | SHOW_STR |
| 9319 | IP_STR |
| 9320 | BGP_STR |
| 9321 | "Address family\n" |
| 9322 | "Address Family modifier\n" |
| 9323 | "Address Family modifier\n" |
| 9324 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9325 | "Neighbor to display information about\n" |
| 9326 | "Neighbor to display information about\n" |
| 9327 | "Display the received routes from neighbor\n") |
| 9328 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9329 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9330 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9331 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9332 | if (! peer) |
| 9333 | return CMD_WARNING; |
| 9334 | |
| 9335 | if (strncmp (argv[0], "m", 1) == 0) |
| 9336 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 9337 | |
| 9338 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9339 | } |
| 9340 | |
| 9341 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 9342 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 9343 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9344 | SHOW_STR |
| 9345 | IP_STR |
| 9346 | BGP_STR |
| 9347 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9348 | "Neighbor to display information about\n" |
| 9349 | "Neighbor to display information about\n" |
| 9350 | "Display information received from a BGP neighbor\n" |
| 9351 | "Display the prefixlist filter\n") |
| 9352 | { |
| 9353 | char name[BUFSIZ]; |
| 9354 | union sockunion *su; |
| 9355 | struct peer *peer; |
| 9356 | int count; |
| 9357 | |
| 9358 | su = sockunion_str2su (argv[0]); |
| 9359 | if (su == NULL) |
| 9360 | return CMD_WARNING; |
| 9361 | |
| 9362 | peer = peer_lookup (NULL, su); |
| 9363 | if (! peer) |
| 9364 | return CMD_WARNING; |
| 9365 | |
| 9366 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 9367 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 9368 | if (count) |
| 9369 | { |
| 9370 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 9371 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 9372 | } |
| 9373 | |
| 9374 | return CMD_SUCCESS; |
| 9375 | } |
| 9376 | |
| 9377 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 9378 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 9379 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9380 | SHOW_STR |
| 9381 | IP_STR |
| 9382 | BGP_STR |
| 9383 | "Address family\n" |
| 9384 | "Address Family modifier\n" |
| 9385 | "Address Family modifier\n" |
| 9386 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9387 | "Neighbor to display information about\n" |
| 9388 | "Neighbor to display information about\n" |
| 9389 | "Display information received from a BGP neighbor\n" |
| 9390 | "Display the prefixlist filter\n") |
| 9391 | { |
| 9392 | char name[BUFSIZ]; |
| 9393 | union sockunion *su; |
| 9394 | struct peer *peer; |
| 9395 | int count; |
| 9396 | |
| 9397 | su = sockunion_str2su (argv[1]); |
| 9398 | if (su == NULL) |
| 9399 | return CMD_WARNING; |
| 9400 | |
| 9401 | peer = peer_lookup (NULL, su); |
| 9402 | if (! peer) |
| 9403 | return CMD_WARNING; |
| 9404 | |
| 9405 | if (strncmp (argv[0], "m", 1) == 0) |
| 9406 | { |
| 9407 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 9408 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 9409 | if (count) |
| 9410 | { |
| 9411 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 9412 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 9413 | } |
| 9414 | } |
| 9415 | else |
| 9416 | { |
| 9417 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 9418 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 9419 | if (count) |
| 9420 | { |
| 9421 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 9422 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 9423 | } |
| 9424 | } |
| 9425 | |
| 9426 | return CMD_SUCCESS; |
| 9427 | } |
| 9428 | |
| 9429 | |
| 9430 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9431 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9432 | show_bgp_neighbor_received_routes_cmd, |
| 9433 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9434 | SHOW_STR |
| 9435 | BGP_STR |
| 9436 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9437 | "Neighbor to display information about\n" |
| 9438 | "Neighbor to display information about\n" |
| 9439 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9440 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9441 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9442 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 9443 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9444 | SHOW_STR |
| 9445 | BGP_STR |
| 9446 | "Address family\n" |
| 9447 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9448 | "Neighbor to display information about\n" |
| 9449 | "Neighbor to display information about\n" |
| 9450 | "Display the received routes from neighbor\n") |
| 9451 | |
| 9452 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 9453 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 9454 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9455 | SHOW_STR |
| 9456 | BGP_STR |
| 9457 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9458 | "Neighbor to display information about\n" |
| 9459 | "Neighbor to display information about\n" |
| 9460 | "Display information received from a BGP neighbor\n" |
| 9461 | "Display the prefixlist filter\n") |
| 9462 | { |
| 9463 | char name[BUFSIZ]; |
| 9464 | union sockunion *su; |
| 9465 | struct peer *peer; |
| 9466 | int count; |
| 9467 | |
| 9468 | su = sockunion_str2su (argv[0]); |
| 9469 | if (su == NULL) |
| 9470 | return CMD_WARNING; |
| 9471 | |
| 9472 | peer = peer_lookup (NULL, su); |
| 9473 | if (! peer) |
| 9474 | return CMD_WARNING; |
| 9475 | |
| 9476 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 9477 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 9478 | if (count) |
| 9479 | { |
| 9480 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 9481 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 9482 | } |
| 9483 | |
| 9484 | return CMD_SUCCESS; |
| 9485 | } |
| 9486 | |
| 9487 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 9488 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 9489 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9490 | SHOW_STR |
| 9491 | BGP_STR |
| 9492 | "Address family\n" |
| 9493 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9494 | "Neighbor to display information about\n" |
| 9495 | "Neighbor to display information about\n" |
| 9496 | "Display information received from a BGP neighbor\n" |
| 9497 | "Display the prefixlist filter\n") |
| 9498 | |
| 9499 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9500 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9501 | ipv6_bgp_neighbor_received_routes_cmd, |
| 9502 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9503 | SHOW_STR |
| 9504 | IPV6_STR |
| 9505 | BGP_STR |
| 9506 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9507 | "Neighbor to display information about\n" |
| 9508 | "Neighbor to display information about\n" |
| 9509 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9510 | |
| 9511 | /* old command */ |
| 9512 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 9513 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 9514 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9515 | SHOW_STR |
| 9516 | IPV6_STR |
| 9517 | MBGP_STR |
| 9518 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9519 | "Neighbor to display information about\n" |
| 9520 | "Neighbor to display information about\n" |
| 9521 | "Display the received routes from neighbor\n") |
| 9522 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9523 | struct peer *peer; |
| 9524 | |
| 9525 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9526 | if (! peer) |
| 9527 | return CMD_WARNING; |
| 9528 | |
| 9529 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9530 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9531 | |
| 9532 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 9533 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 9534 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9535 | SHOW_STR |
| 9536 | BGP_STR |
| 9537 | "BGP view\n" |
| 9538 | "View name\n" |
| 9539 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9540 | "Neighbor to display information about\n" |
| 9541 | "Neighbor to display information about\n" |
| 9542 | "Display information received from a BGP neighbor\n" |
| 9543 | "Display the prefixlist filter\n") |
| 9544 | { |
| 9545 | char name[BUFSIZ]; |
| 9546 | union sockunion *su; |
| 9547 | struct peer *peer; |
| 9548 | struct bgp *bgp; |
| 9549 | int count; |
| 9550 | |
| 9551 | /* BGP structure lookup. */ |
| 9552 | bgp = bgp_lookup_by_name (argv[0]); |
| 9553 | if (bgp == NULL) |
| 9554 | { |
| 9555 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9556 | return CMD_WARNING; |
| 9557 | } |
| 9558 | |
| 9559 | su = sockunion_str2su (argv[1]); |
| 9560 | if (su == NULL) |
| 9561 | return CMD_WARNING; |
| 9562 | |
| 9563 | peer = peer_lookup (bgp, su); |
| 9564 | if (! peer) |
| 9565 | return CMD_WARNING; |
| 9566 | |
| 9567 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 9568 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 9569 | if (count) |
| 9570 | { |
| 9571 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 9572 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 9573 | } |
| 9574 | |
| 9575 | return CMD_SUCCESS; |
| 9576 | } |
| 9577 | |
| 9578 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 9579 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 9580 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 9581 | SHOW_STR |
| 9582 | BGP_STR |
| 9583 | "BGP view\n" |
| 9584 | "View name\n" |
| 9585 | "Address family\n" |
| 9586 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9587 | "Neighbor to display information about\n" |
| 9588 | "Neighbor to display information about\n" |
| 9589 | "Display information received from a BGP neighbor\n" |
| 9590 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9591 | #endif /* HAVE_IPV6 */ |
| 9592 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9593 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9594 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9595 | safi_t safi, enum bgp_show_type type) |
| 9596 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9597 | if (! peer || ! peer->afc[afi][safi]) |
| 9598 | { |
| 9599 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9600 | return CMD_WARNING; |
| 9601 | } |
| 9602 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9603 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9604 | } |
| 9605 | |
| 9606 | DEFUN (show_ip_bgp_neighbor_routes, |
| 9607 | show_ip_bgp_neighbor_routes_cmd, |
| 9608 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9609 | SHOW_STR |
| 9610 | IP_STR |
| 9611 | BGP_STR |
| 9612 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9613 | "Neighbor to display information about\n" |
| 9614 | "Neighbor to display information about\n" |
| 9615 | "Display routes learned from neighbor\n") |
| 9616 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9617 | struct peer *peer; |
| 9618 | |
| 9619 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9620 | if (! peer) |
| 9621 | return CMD_WARNING; |
| 9622 | |
| 9623 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9624 | bgp_show_type_neighbor); |
| 9625 | } |
| 9626 | |
| 9627 | DEFUN (show_ip_bgp_neighbor_flap, |
| 9628 | show_ip_bgp_neighbor_flap_cmd, |
| 9629 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9630 | SHOW_STR |
| 9631 | IP_STR |
| 9632 | BGP_STR |
| 9633 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9634 | "Neighbor to display information about\n" |
| 9635 | "Neighbor to display information about\n" |
| 9636 | "Display flap statistics of the routes learned from neighbor\n") |
| 9637 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9638 | struct peer *peer; |
| 9639 | |
| 9640 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9641 | if (! peer) |
| 9642 | return CMD_WARNING; |
| 9643 | |
| 9644 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9645 | bgp_show_type_flap_neighbor); |
| 9646 | } |
| 9647 | |
| 9648 | DEFUN (show_ip_bgp_neighbor_damp, |
| 9649 | show_ip_bgp_neighbor_damp_cmd, |
| 9650 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9651 | SHOW_STR |
| 9652 | IP_STR |
| 9653 | BGP_STR |
| 9654 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9655 | "Neighbor to display information about\n" |
| 9656 | "Neighbor to display information about\n" |
| 9657 | "Display the dampened routes received from neighbor\n") |
| 9658 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9659 | struct peer *peer; |
| 9660 | |
| 9661 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9662 | if (! peer) |
| 9663 | return CMD_WARNING; |
| 9664 | |
| 9665 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9666 | bgp_show_type_damp_neighbor); |
| 9667 | } |
| 9668 | |
| 9669 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 9670 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 9671 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 9672 | SHOW_STR |
| 9673 | IP_STR |
| 9674 | BGP_STR |
| 9675 | "Address family\n" |
| 9676 | "Address Family modifier\n" |
| 9677 | "Address Family modifier\n" |
| 9678 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9679 | "Neighbor to display information about\n" |
| 9680 | "Neighbor to display information about\n" |
| 9681 | "Display routes learned from neighbor\n") |
| 9682 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9683 | struct peer *peer; |
| 9684 | |
| 9685 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9686 | if (! peer) |
| 9687 | return CMD_WARNING; |
| 9688 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9689 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9690 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9691 | bgp_show_type_neighbor); |
| 9692 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9693 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9694 | bgp_show_type_neighbor); |
| 9695 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9696 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9697 | DEFUN (show_ip_bgp_view_rsclient, |
| 9698 | show_ip_bgp_view_rsclient_cmd, |
| 9699 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9700 | SHOW_STR |
| 9701 | IP_STR |
| 9702 | BGP_STR |
| 9703 | "BGP view\n" |
| 9704 | "BGP view name\n" |
| 9705 | "Information about Route Server Client\n" |
| 9706 | NEIGHBOR_ADDR_STR) |
| 9707 | { |
| 9708 | struct bgp_table *table; |
| 9709 | struct peer *peer; |
| 9710 | |
| 9711 | if (argc == 2) |
| 9712 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9713 | else |
| 9714 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9715 | |
| 9716 | if (! peer) |
| 9717 | return CMD_WARNING; |
| 9718 | |
| 9719 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9720 | { |
| 9721 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9722 | VTY_NEWLINE); |
| 9723 | return CMD_WARNING; |
| 9724 | } |
| 9725 | |
| 9726 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9727 | PEER_FLAG_RSERVER_CLIENT)) |
| 9728 | { |
| 9729 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9730 | VTY_NEWLINE); |
| 9731 | return CMD_WARNING; |
| 9732 | } |
| 9733 | |
| 9734 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 9735 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9736 | 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] | 9737 | } |
| 9738 | |
| 9739 | ALIAS (show_ip_bgp_view_rsclient, |
| 9740 | show_ip_bgp_rsclient_cmd, |
| 9741 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9742 | SHOW_STR |
| 9743 | IP_STR |
| 9744 | BGP_STR |
| 9745 | "Information about Route Server Client\n" |
| 9746 | NEIGHBOR_ADDR_STR) |
| 9747 | |
| 9748 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 9749 | show_ip_bgp_view_rsclient_route_cmd, |
| 9750 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 9751 | SHOW_STR |
| 9752 | IP_STR |
| 9753 | BGP_STR |
| 9754 | "BGP view\n" |
| 9755 | "BGP view name\n" |
| 9756 | "Information about Route Server Client\n" |
| 9757 | NEIGHBOR_ADDR_STR |
| 9758 | "Network in the BGP routing table to display\n") |
| 9759 | { |
| 9760 | struct bgp *bgp; |
| 9761 | struct peer *peer; |
| 9762 | |
| 9763 | /* BGP structure lookup. */ |
| 9764 | if (argc == 3) |
| 9765 | { |
| 9766 | bgp = bgp_lookup_by_name (argv[0]); |
| 9767 | if (bgp == NULL) |
| 9768 | { |
| 9769 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9770 | return CMD_WARNING; |
| 9771 | } |
| 9772 | } |
| 9773 | else |
| 9774 | { |
| 9775 | bgp = bgp_get_default (); |
| 9776 | if (bgp == NULL) |
| 9777 | { |
| 9778 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9779 | return CMD_WARNING; |
| 9780 | } |
| 9781 | } |
| 9782 | |
| 9783 | if (argc == 3) |
| 9784 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9785 | else |
| 9786 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9787 | |
| 9788 | if (! peer) |
| 9789 | return CMD_WARNING; |
| 9790 | |
| 9791 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9792 | { |
| 9793 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9794 | VTY_NEWLINE); |
| 9795 | return CMD_WARNING; |
| 9796 | } |
| 9797 | |
| 9798 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9799 | PEER_FLAG_RSERVER_CLIENT)) |
| 9800 | { |
| 9801 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9802 | VTY_NEWLINE); |
| 9803 | return CMD_WARNING; |
| 9804 | } |
| 9805 | |
| 9806 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 9807 | (argc == 3) ? argv[2] : argv[1], |
| 9808 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 9809 | } |
| 9810 | |
| 9811 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 9812 | show_ip_bgp_rsclient_route_cmd, |
| 9813 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 9814 | SHOW_STR |
| 9815 | IP_STR |
| 9816 | BGP_STR |
| 9817 | "Information about Route Server Client\n" |
| 9818 | NEIGHBOR_ADDR_STR |
| 9819 | "Network in the BGP routing table to display\n") |
| 9820 | |
| 9821 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 9822 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 9823 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 9824 | SHOW_STR |
| 9825 | IP_STR |
| 9826 | BGP_STR |
| 9827 | "BGP view\n" |
| 9828 | "BGP view name\n" |
| 9829 | "Information about Route Server Client\n" |
| 9830 | NEIGHBOR_ADDR_STR |
| 9831 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9832 | { |
| 9833 | struct bgp *bgp; |
| 9834 | struct peer *peer; |
| 9835 | |
| 9836 | /* BGP structure lookup. */ |
| 9837 | if (argc == 3) |
| 9838 | { |
| 9839 | bgp = bgp_lookup_by_name (argv[0]); |
| 9840 | if (bgp == NULL) |
| 9841 | { |
| 9842 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9843 | return CMD_WARNING; |
| 9844 | } |
| 9845 | } |
| 9846 | else |
| 9847 | { |
| 9848 | bgp = bgp_get_default (); |
| 9849 | if (bgp == NULL) |
| 9850 | { |
| 9851 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9852 | return CMD_WARNING; |
| 9853 | } |
| 9854 | } |
| 9855 | |
| 9856 | if (argc == 3) |
| 9857 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9858 | else |
| 9859 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9860 | |
| 9861 | if (! peer) |
| 9862 | return CMD_WARNING; |
| 9863 | |
| 9864 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9865 | { |
| 9866 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9867 | VTY_NEWLINE); |
| 9868 | return CMD_WARNING; |
| 9869 | } |
| 9870 | |
| 9871 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9872 | PEER_FLAG_RSERVER_CLIENT)) |
| 9873 | { |
| 9874 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9875 | VTY_NEWLINE); |
| 9876 | return CMD_WARNING; |
| 9877 | } |
| 9878 | |
| 9879 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 9880 | (argc == 3) ? argv[2] : argv[1], |
| 9881 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 9882 | } |
| 9883 | |
| 9884 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 9885 | show_ip_bgp_rsclient_prefix_cmd, |
| 9886 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 9887 | SHOW_STR |
| 9888 | IP_STR |
| 9889 | BGP_STR |
| 9890 | "Information about Route Server Client\n" |
| 9891 | NEIGHBOR_ADDR_STR |
| 9892 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9893 | |
| 9894 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9895 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9896 | DEFUN (show_bgp_view_neighbor_routes, |
| 9897 | show_bgp_view_neighbor_routes_cmd, |
| 9898 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 9899 | SHOW_STR |
| 9900 | BGP_STR |
| 9901 | "BGP view\n" |
| 9902 | "BGP view name\n" |
| 9903 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9904 | "Neighbor to display information about\n" |
| 9905 | "Neighbor to display information about\n" |
| 9906 | "Display routes learned from neighbor\n") |
| 9907 | { |
| 9908 | struct peer *peer; |
| 9909 | |
| 9910 | if (argc == 2) |
| 9911 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9912 | else |
| 9913 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9914 | |
| 9915 | if (! peer) |
| 9916 | return CMD_WARNING; |
| 9917 | |
| 9918 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9919 | bgp_show_type_neighbor); |
| 9920 | } |
| 9921 | |
| 9922 | ALIAS (show_bgp_view_neighbor_routes, |
| 9923 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 9924 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9925 | SHOW_STR |
| 9926 | BGP_STR |
| 9927 | "BGP view\n" |
| 9928 | "BGP view name\n" |
| 9929 | "Address family\n" |
| 9930 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9931 | "Neighbor to display information about\n" |
| 9932 | "Neighbor to display information about\n" |
| 9933 | "Display routes learned from neighbor\n") |
| 9934 | |
| 9935 | DEFUN (show_bgp_view_neighbor_damp, |
| 9936 | show_bgp_view_neighbor_damp_cmd, |
| 9937 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9938 | SHOW_STR |
| 9939 | BGP_STR |
| 9940 | "BGP view\n" |
| 9941 | "BGP view name\n" |
| 9942 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9943 | "Neighbor to display information about\n" |
| 9944 | "Neighbor to display information about\n" |
| 9945 | "Display the dampened routes received from neighbor\n") |
| 9946 | { |
| 9947 | struct peer *peer; |
| 9948 | |
| 9949 | if (argc == 2) |
| 9950 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9951 | else |
| 9952 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9953 | |
| 9954 | if (! peer) |
| 9955 | return CMD_WARNING; |
| 9956 | |
| 9957 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9958 | bgp_show_type_damp_neighbor); |
| 9959 | } |
| 9960 | |
| 9961 | ALIAS (show_bgp_view_neighbor_damp, |
| 9962 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 9963 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9964 | SHOW_STR |
| 9965 | BGP_STR |
| 9966 | "BGP view\n" |
| 9967 | "BGP view name\n" |
| 9968 | "Address family\n" |
| 9969 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9970 | "Neighbor to display information about\n" |
| 9971 | "Neighbor to display information about\n" |
| 9972 | "Display the dampened routes received from neighbor\n") |
| 9973 | |
| 9974 | DEFUN (show_bgp_view_neighbor_flap, |
| 9975 | show_bgp_view_neighbor_flap_cmd, |
| 9976 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9977 | SHOW_STR |
| 9978 | BGP_STR |
| 9979 | "BGP view\n" |
| 9980 | "BGP view name\n" |
| 9981 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9982 | "Neighbor to display information about\n" |
| 9983 | "Neighbor to display information about\n" |
| 9984 | "Display flap statistics of the routes learned from neighbor\n") |
| 9985 | { |
| 9986 | struct peer *peer; |
| 9987 | |
| 9988 | if (argc == 2) |
| 9989 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9990 | else |
| 9991 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9992 | |
| 9993 | if (! peer) |
| 9994 | return CMD_WARNING; |
| 9995 | |
| 9996 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9997 | bgp_show_type_flap_neighbor); |
| 9998 | } |
| 9999 | |
| 10000 | ALIAS (show_bgp_view_neighbor_flap, |
| 10001 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 10002 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10003 | SHOW_STR |
| 10004 | BGP_STR |
| 10005 | "BGP view\n" |
| 10006 | "BGP view name\n" |
| 10007 | "Address family\n" |
| 10008 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10009 | "Neighbor to display information about\n" |
| 10010 | "Neighbor to display information about\n" |
| 10011 | "Display flap statistics of the routes learned from neighbor\n") |
| 10012 | |
| 10013 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10014 | show_bgp_neighbor_routes_cmd, |
| 10015 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10016 | SHOW_STR |
| 10017 | BGP_STR |
| 10018 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10019 | "Neighbor to display information about\n" |
| 10020 | "Neighbor to display information about\n" |
| 10021 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10022 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10023 | |
| 10024 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10025 | show_bgp_ipv6_neighbor_routes_cmd, |
| 10026 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 10027 | SHOW_STR |
| 10028 | BGP_STR |
| 10029 | "Address family\n" |
| 10030 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10031 | "Neighbor to display information about\n" |
| 10032 | "Neighbor to display information about\n" |
| 10033 | "Display routes learned from neighbor\n") |
| 10034 | |
| 10035 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10036 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10037 | ipv6_bgp_neighbor_routes_cmd, |
| 10038 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10039 | SHOW_STR |
| 10040 | IPV6_STR |
| 10041 | BGP_STR |
| 10042 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10043 | "Neighbor to display information about\n" |
| 10044 | "Neighbor to display information about\n" |
| 10045 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10046 | |
| 10047 | /* old command */ |
| 10048 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 10049 | ipv6_mbgp_neighbor_routes_cmd, |
| 10050 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10051 | SHOW_STR |
| 10052 | IPV6_STR |
| 10053 | MBGP_STR |
| 10054 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10055 | "Neighbor to display information about\n" |
| 10056 | "Neighbor to display information about\n" |
| 10057 | "Display routes learned from neighbor\n") |
| 10058 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10059 | struct peer *peer; |
| 10060 | |
| 10061 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10062 | if (! peer) |
| 10063 | return CMD_WARNING; |
| 10064 | |
| 10065 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10066 | bgp_show_type_neighbor); |
| 10067 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10068 | |
| 10069 | ALIAS (show_bgp_view_neighbor_flap, |
| 10070 | show_bgp_neighbor_flap_cmd, |
| 10071 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10072 | SHOW_STR |
| 10073 | BGP_STR |
| 10074 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10075 | "Neighbor to display information about\n" |
| 10076 | "Neighbor to display information about\n" |
| 10077 | "Display flap statistics of the routes learned from neighbor\n") |
| 10078 | |
| 10079 | ALIAS (show_bgp_view_neighbor_flap, |
| 10080 | show_bgp_ipv6_neighbor_flap_cmd, |
| 10081 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10082 | SHOW_STR |
| 10083 | BGP_STR |
| 10084 | "Address family\n" |
| 10085 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10086 | "Neighbor to display information about\n" |
| 10087 | "Neighbor to display information about\n" |
| 10088 | "Display flap statistics of the routes learned from neighbor\n") |
| 10089 | |
| 10090 | ALIAS (show_bgp_view_neighbor_damp, |
| 10091 | show_bgp_neighbor_damp_cmd, |
| 10092 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10093 | SHOW_STR |
| 10094 | BGP_STR |
| 10095 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10096 | "Neighbor to display information about\n" |
| 10097 | "Neighbor to display information about\n" |
| 10098 | "Display the dampened routes received from neighbor\n") |
| 10099 | |
| 10100 | ALIAS (show_bgp_view_neighbor_damp, |
| 10101 | show_bgp_ipv6_neighbor_damp_cmd, |
| 10102 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10103 | SHOW_STR |
| 10104 | BGP_STR |
| 10105 | "Address family\n" |
| 10106 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10107 | "Neighbor to display information about\n" |
| 10108 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 10109 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10110 | |
| 10111 | DEFUN (show_bgp_view_rsclient, |
| 10112 | show_bgp_view_rsclient_cmd, |
| 10113 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10114 | SHOW_STR |
| 10115 | BGP_STR |
| 10116 | "BGP view\n" |
| 10117 | "BGP view name\n" |
| 10118 | "Information about Route Server Client\n" |
| 10119 | NEIGHBOR_ADDR_STR) |
| 10120 | { |
| 10121 | struct bgp_table *table; |
| 10122 | struct peer *peer; |
| 10123 | |
| 10124 | if (argc == 2) |
| 10125 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10126 | else |
| 10127 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10128 | |
| 10129 | if (! peer) |
| 10130 | return CMD_WARNING; |
| 10131 | |
| 10132 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 10133 | { |
| 10134 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10135 | VTY_NEWLINE); |
| 10136 | return CMD_WARNING; |
| 10137 | } |
| 10138 | |
| 10139 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 10140 | PEER_FLAG_RSERVER_CLIENT)) |
| 10141 | { |
| 10142 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10143 | VTY_NEWLINE); |
| 10144 | return CMD_WARNING; |
| 10145 | } |
| 10146 | |
| 10147 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 10148 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10149 | 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] | 10150 | } |
| 10151 | |
| 10152 | ALIAS (show_bgp_view_rsclient, |
| 10153 | show_bgp_rsclient_cmd, |
| 10154 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10155 | SHOW_STR |
| 10156 | BGP_STR |
| 10157 | "Information about Route Server Client\n" |
| 10158 | NEIGHBOR_ADDR_STR) |
| 10159 | |
| 10160 | DEFUN (show_bgp_view_rsclient_route, |
| 10161 | show_bgp_view_rsclient_route_cmd, |
| 10162 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 10163 | SHOW_STR |
| 10164 | BGP_STR |
| 10165 | "BGP view\n" |
| 10166 | "BGP view name\n" |
| 10167 | "Information about Route Server Client\n" |
| 10168 | NEIGHBOR_ADDR_STR |
| 10169 | "Network in the BGP routing table to display\n") |
| 10170 | { |
| 10171 | struct bgp *bgp; |
| 10172 | struct peer *peer; |
| 10173 | |
| 10174 | /* BGP structure lookup. */ |
| 10175 | if (argc == 3) |
| 10176 | { |
| 10177 | bgp = bgp_lookup_by_name (argv[0]); |
| 10178 | if (bgp == NULL) |
| 10179 | { |
| 10180 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10181 | return CMD_WARNING; |
| 10182 | } |
| 10183 | } |
| 10184 | else |
| 10185 | { |
| 10186 | bgp = bgp_get_default (); |
| 10187 | if (bgp == NULL) |
| 10188 | { |
| 10189 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10190 | return CMD_WARNING; |
| 10191 | } |
| 10192 | } |
| 10193 | |
| 10194 | if (argc == 3) |
| 10195 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10196 | else |
| 10197 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10198 | |
| 10199 | if (! peer) |
| 10200 | return CMD_WARNING; |
| 10201 | |
| 10202 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 10203 | { |
| 10204 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10205 | VTY_NEWLINE); |
| 10206 | return CMD_WARNING; |
| 10207 | } |
| 10208 | |
| 10209 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 10210 | PEER_FLAG_RSERVER_CLIENT)) |
| 10211 | { |
| 10212 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10213 | VTY_NEWLINE); |
| 10214 | return CMD_WARNING; |
| 10215 | } |
| 10216 | |
| 10217 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 10218 | (argc == 3) ? argv[2] : argv[1], |
| 10219 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 10220 | } |
| 10221 | |
| 10222 | ALIAS (show_bgp_view_rsclient_route, |
| 10223 | show_bgp_rsclient_route_cmd, |
| 10224 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 10225 | SHOW_STR |
| 10226 | BGP_STR |
| 10227 | "Information about Route Server Client\n" |
| 10228 | NEIGHBOR_ADDR_STR |
| 10229 | "Network in the BGP routing table to display\n") |
| 10230 | |
| 10231 | DEFUN (show_bgp_view_rsclient_prefix, |
| 10232 | show_bgp_view_rsclient_prefix_cmd, |
| 10233 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 10234 | SHOW_STR |
| 10235 | BGP_STR |
| 10236 | "BGP view\n" |
| 10237 | "BGP view name\n" |
| 10238 | "Information about Route Server Client\n" |
| 10239 | NEIGHBOR_ADDR_STR |
| 10240 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 10241 | { |
| 10242 | struct bgp *bgp; |
| 10243 | struct peer *peer; |
| 10244 | |
| 10245 | /* BGP structure lookup. */ |
| 10246 | if (argc == 3) |
| 10247 | { |
| 10248 | bgp = bgp_lookup_by_name (argv[0]); |
| 10249 | if (bgp == NULL) |
| 10250 | { |
| 10251 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10252 | return CMD_WARNING; |
| 10253 | } |
| 10254 | } |
| 10255 | else |
| 10256 | { |
| 10257 | bgp = bgp_get_default (); |
| 10258 | if (bgp == NULL) |
| 10259 | { |
| 10260 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10261 | return CMD_WARNING; |
| 10262 | } |
| 10263 | } |
| 10264 | |
| 10265 | if (argc == 3) |
| 10266 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10267 | else |
| 10268 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10269 | |
| 10270 | if (! peer) |
| 10271 | return CMD_WARNING; |
| 10272 | |
| 10273 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 10274 | { |
| 10275 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10276 | VTY_NEWLINE); |
| 10277 | return CMD_WARNING; |
| 10278 | } |
| 10279 | |
| 10280 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 10281 | PEER_FLAG_RSERVER_CLIENT)) |
| 10282 | { |
| 10283 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10284 | VTY_NEWLINE); |
| 10285 | return CMD_WARNING; |
| 10286 | } |
| 10287 | |
| 10288 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 10289 | (argc == 3) ? argv[2] : argv[1], |
| 10290 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 10291 | } |
| 10292 | |
| 10293 | ALIAS (show_bgp_view_rsclient_prefix, |
| 10294 | show_bgp_rsclient_prefix_cmd, |
| 10295 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 10296 | SHOW_STR |
| 10297 | BGP_STR |
| 10298 | "Information about Route Server Client\n" |
| 10299 | NEIGHBOR_ADDR_STR |
| 10300 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 10301 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10302 | #endif /* HAVE_IPV6 */ |
| 10303 | |
| 10304 | struct bgp_table *bgp_distance_table; |
| 10305 | |
| 10306 | struct bgp_distance |
| 10307 | { |
| 10308 | /* Distance value for the IP source prefix. */ |
| 10309 | u_char distance; |
| 10310 | |
| 10311 | /* Name of the access-list to be matched. */ |
| 10312 | char *access_list; |
| 10313 | }; |
| 10314 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10315 | static struct bgp_distance * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10316 | bgp_distance_new () |
| 10317 | { |
| 10318 | struct bgp_distance *new; |
| 10319 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 10320 | memset (new, 0, sizeof (struct bgp_distance)); |
| 10321 | return new; |
| 10322 | } |
| 10323 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10324 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10325 | bgp_distance_free (struct bgp_distance *bdistance) |
| 10326 | { |
| 10327 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 10328 | } |
| 10329 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10330 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10331 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 10332 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10333 | { |
| 10334 | int ret; |
| 10335 | struct prefix_ipv4 p; |
| 10336 | u_char distance; |
| 10337 | struct bgp_node *rn; |
| 10338 | struct bgp_distance *bdistance; |
| 10339 | |
| 10340 | ret = str2prefix_ipv4 (ip_str, &p); |
| 10341 | if (ret == 0) |
| 10342 | { |
| 10343 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 10344 | return CMD_WARNING; |
| 10345 | } |
| 10346 | |
| 10347 | distance = atoi (distance_str); |
| 10348 | |
| 10349 | /* Get BGP distance node. */ |
| 10350 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 10351 | if (rn->info) |
| 10352 | { |
| 10353 | bdistance = rn->info; |
| 10354 | bgp_unlock_node (rn); |
| 10355 | } |
| 10356 | else |
| 10357 | { |
| 10358 | bdistance = bgp_distance_new (); |
| 10359 | rn->info = bdistance; |
| 10360 | } |
| 10361 | |
| 10362 | /* Set distance value. */ |
| 10363 | bdistance->distance = distance; |
| 10364 | |
| 10365 | /* Reset access-list configuration. */ |
| 10366 | if (bdistance->access_list) |
| 10367 | { |
| 10368 | free (bdistance->access_list); |
| 10369 | bdistance->access_list = NULL; |
| 10370 | } |
| 10371 | if (access_list_str) |
| 10372 | bdistance->access_list = strdup (access_list_str); |
| 10373 | |
| 10374 | return CMD_SUCCESS; |
| 10375 | } |
| 10376 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10377 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10378 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 10379 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10380 | { |
| 10381 | int ret; |
| 10382 | struct prefix_ipv4 p; |
| 10383 | u_char distance; |
| 10384 | struct bgp_node *rn; |
| 10385 | struct bgp_distance *bdistance; |
| 10386 | |
| 10387 | ret = str2prefix_ipv4 (ip_str, &p); |
| 10388 | if (ret == 0) |
| 10389 | { |
| 10390 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 10391 | return CMD_WARNING; |
| 10392 | } |
| 10393 | |
| 10394 | distance = atoi (distance_str); |
| 10395 | |
| 10396 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 10397 | if (! rn) |
| 10398 | { |
| 10399 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 10400 | return CMD_WARNING; |
| 10401 | } |
| 10402 | |
| 10403 | bdistance = rn->info; |
| 10404 | |
| 10405 | if (bdistance->access_list) |
| 10406 | free (bdistance->access_list); |
| 10407 | bgp_distance_free (bdistance); |
| 10408 | |
| 10409 | rn->info = NULL; |
| 10410 | bgp_unlock_node (rn); |
| 10411 | bgp_unlock_node (rn); |
| 10412 | |
| 10413 | return CMD_SUCCESS; |
| 10414 | } |
| 10415 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10416 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10417 | bgp_distance_reset () |
| 10418 | { |
| 10419 | struct bgp_node *rn; |
| 10420 | struct bgp_distance *bdistance; |
| 10421 | |
| 10422 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 10423 | if ((bdistance = rn->info) != NULL) |
| 10424 | { |
| 10425 | if (bdistance->access_list) |
| 10426 | free (bdistance->access_list); |
| 10427 | bgp_distance_free (bdistance); |
| 10428 | rn->info = NULL; |
| 10429 | bgp_unlock_node (rn); |
| 10430 | } |
| 10431 | } |
| 10432 | |
| 10433 | /* Apply BGP information to distance method. */ |
| 10434 | u_char |
| 10435 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 10436 | { |
| 10437 | struct bgp_node *rn; |
| 10438 | struct prefix_ipv4 q; |
| 10439 | struct peer *peer; |
| 10440 | struct bgp_distance *bdistance; |
| 10441 | struct access_list *alist; |
| 10442 | struct bgp_static *bgp_static; |
| 10443 | |
| 10444 | if (! bgp) |
| 10445 | return 0; |
| 10446 | |
| 10447 | if (p->family != AF_INET) |
| 10448 | return 0; |
| 10449 | |
| 10450 | peer = rinfo->peer; |
| 10451 | |
| 10452 | if (peer->su.sa.sa_family != AF_INET) |
| 10453 | return 0; |
| 10454 | |
| 10455 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 10456 | q.family = AF_INET; |
| 10457 | q.prefix = peer->su.sin.sin_addr; |
| 10458 | q.prefixlen = IPV4_MAX_BITLEN; |
| 10459 | |
| 10460 | /* Check source address. */ |
| 10461 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 10462 | if (rn) |
| 10463 | { |
| 10464 | bdistance = rn->info; |
| 10465 | bgp_unlock_node (rn); |
| 10466 | |
| 10467 | if (bdistance->access_list) |
| 10468 | { |
| 10469 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 10470 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 10471 | return bdistance->distance; |
| 10472 | } |
| 10473 | else |
| 10474 | return bdistance->distance; |
| 10475 | } |
| 10476 | |
| 10477 | /* Backdoor check. */ |
| 10478 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 10479 | if (rn) |
| 10480 | { |
| 10481 | bgp_static = rn->info; |
| 10482 | bgp_unlock_node (rn); |
| 10483 | |
| 10484 | if (bgp_static->backdoor) |
| 10485 | { |
| 10486 | if (bgp->distance_local) |
| 10487 | return bgp->distance_local; |
| 10488 | else |
| 10489 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 10490 | } |
| 10491 | } |
| 10492 | |
| 10493 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 10494 | { |
| 10495 | if (bgp->distance_ebgp) |
| 10496 | return bgp->distance_ebgp; |
| 10497 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 10498 | } |
| 10499 | else |
| 10500 | { |
| 10501 | if (bgp->distance_ibgp) |
| 10502 | return bgp->distance_ibgp; |
| 10503 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 10504 | } |
| 10505 | } |
| 10506 | |
| 10507 | DEFUN (bgp_distance, |
| 10508 | bgp_distance_cmd, |
| 10509 | "distance bgp <1-255> <1-255> <1-255>", |
| 10510 | "Define an administrative distance\n" |
| 10511 | "BGP distance\n" |
| 10512 | "Distance for routes external to the AS\n" |
| 10513 | "Distance for routes internal to the AS\n" |
| 10514 | "Distance for local routes\n") |
| 10515 | { |
| 10516 | struct bgp *bgp; |
| 10517 | |
| 10518 | bgp = vty->index; |
| 10519 | |
| 10520 | bgp->distance_ebgp = atoi (argv[0]); |
| 10521 | bgp->distance_ibgp = atoi (argv[1]); |
| 10522 | bgp->distance_local = atoi (argv[2]); |
| 10523 | return CMD_SUCCESS; |
| 10524 | } |
| 10525 | |
| 10526 | DEFUN (no_bgp_distance, |
| 10527 | no_bgp_distance_cmd, |
| 10528 | "no distance bgp <1-255> <1-255> <1-255>", |
| 10529 | NO_STR |
| 10530 | "Define an administrative distance\n" |
| 10531 | "BGP distance\n" |
| 10532 | "Distance for routes external to the AS\n" |
| 10533 | "Distance for routes internal to the AS\n" |
| 10534 | "Distance for local routes\n") |
| 10535 | { |
| 10536 | struct bgp *bgp; |
| 10537 | |
| 10538 | bgp = vty->index; |
| 10539 | |
| 10540 | bgp->distance_ebgp= 0; |
| 10541 | bgp->distance_ibgp = 0; |
| 10542 | bgp->distance_local = 0; |
| 10543 | return CMD_SUCCESS; |
| 10544 | } |
| 10545 | |
| 10546 | ALIAS (no_bgp_distance, |
| 10547 | no_bgp_distance2_cmd, |
| 10548 | "no distance bgp", |
| 10549 | NO_STR |
| 10550 | "Define an administrative distance\n" |
| 10551 | "BGP distance\n") |
| 10552 | |
| 10553 | DEFUN (bgp_distance_source, |
| 10554 | bgp_distance_source_cmd, |
| 10555 | "distance <1-255> A.B.C.D/M", |
| 10556 | "Define an administrative distance\n" |
| 10557 | "Administrative distance\n" |
| 10558 | "IP source prefix\n") |
| 10559 | { |
| 10560 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 10561 | return CMD_SUCCESS; |
| 10562 | } |
| 10563 | |
| 10564 | DEFUN (no_bgp_distance_source, |
| 10565 | no_bgp_distance_source_cmd, |
| 10566 | "no distance <1-255> A.B.C.D/M", |
| 10567 | NO_STR |
| 10568 | "Define an administrative distance\n" |
| 10569 | "Administrative distance\n" |
| 10570 | "IP source prefix\n") |
| 10571 | { |
| 10572 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 10573 | return CMD_SUCCESS; |
| 10574 | } |
| 10575 | |
| 10576 | DEFUN (bgp_distance_source_access_list, |
| 10577 | bgp_distance_source_access_list_cmd, |
| 10578 | "distance <1-255> A.B.C.D/M WORD", |
| 10579 | "Define an administrative distance\n" |
| 10580 | "Administrative distance\n" |
| 10581 | "IP source prefix\n" |
| 10582 | "Access list name\n") |
| 10583 | { |
| 10584 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 10585 | return CMD_SUCCESS; |
| 10586 | } |
| 10587 | |
| 10588 | DEFUN (no_bgp_distance_source_access_list, |
| 10589 | no_bgp_distance_source_access_list_cmd, |
| 10590 | "no distance <1-255> A.B.C.D/M WORD", |
| 10591 | NO_STR |
| 10592 | "Define an administrative distance\n" |
| 10593 | "Administrative distance\n" |
| 10594 | "IP source prefix\n" |
| 10595 | "Access list name\n") |
| 10596 | { |
| 10597 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 10598 | return CMD_SUCCESS; |
| 10599 | } |
| 10600 | |
| 10601 | DEFUN (bgp_damp_set, |
| 10602 | bgp_damp_set_cmd, |
| 10603 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 10604 | "BGP Specific commands\n" |
| 10605 | "Enable route-flap dampening\n" |
| 10606 | "Half-life time for the penalty\n" |
| 10607 | "Value to start reusing a route\n" |
| 10608 | "Value to start suppressing a route\n" |
| 10609 | "Maximum duration to suppress a stable route\n") |
| 10610 | { |
| 10611 | struct bgp *bgp; |
| 10612 | int half = DEFAULT_HALF_LIFE * 60; |
| 10613 | int reuse = DEFAULT_REUSE; |
| 10614 | int suppress = DEFAULT_SUPPRESS; |
| 10615 | int max = 4 * half; |
| 10616 | |
| 10617 | if (argc == 4) |
| 10618 | { |
| 10619 | half = atoi (argv[0]) * 60; |
| 10620 | reuse = atoi (argv[1]); |
| 10621 | suppress = atoi (argv[2]); |
| 10622 | max = atoi (argv[3]) * 60; |
| 10623 | } |
| 10624 | else if (argc == 1) |
| 10625 | { |
| 10626 | half = atoi (argv[0]) * 60; |
| 10627 | max = 4 * half; |
| 10628 | } |
| 10629 | |
| 10630 | bgp = vty->index; |
| 10631 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 10632 | half, reuse, suppress, max); |
| 10633 | } |
| 10634 | |
| 10635 | ALIAS (bgp_damp_set, |
| 10636 | bgp_damp_set2_cmd, |
| 10637 | "bgp dampening <1-45>", |
| 10638 | "BGP Specific commands\n" |
| 10639 | "Enable route-flap dampening\n" |
| 10640 | "Half-life time for the penalty\n") |
| 10641 | |
| 10642 | ALIAS (bgp_damp_set, |
| 10643 | bgp_damp_set3_cmd, |
| 10644 | "bgp dampening", |
| 10645 | "BGP Specific commands\n" |
| 10646 | "Enable route-flap dampening\n") |
| 10647 | |
| 10648 | DEFUN (bgp_damp_unset, |
| 10649 | bgp_damp_unset_cmd, |
| 10650 | "no bgp dampening", |
| 10651 | NO_STR |
| 10652 | "BGP Specific commands\n" |
| 10653 | "Enable route-flap dampening\n") |
| 10654 | { |
| 10655 | struct bgp *bgp; |
| 10656 | |
| 10657 | bgp = vty->index; |
| 10658 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 10659 | } |
| 10660 | |
| 10661 | ALIAS (bgp_damp_unset, |
| 10662 | bgp_damp_unset2_cmd, |
| 10663 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 10664 | NO_STR |
| 10665 | "BGP Specific commands\n" |
| 10666 | "Enable route-flap dampening\n" |
| 10667 | "Half-life time for the penalty\n" |
| 10668 | "Value to start reusing a route\n" |
| 10669 | "Value to start suppressing a route\n" |
| 10670 | "Maximum duration to suppress a stable route\n") |
| 10671 | |
| 10672 | DEFUN (show_ip_bgp_dampened_paths, |
| 10673 | show_ip_bgp_dampened_paths_cmd, |
| 10674 | "show ip bgp dampened-paths", |
| 10675 | SHOW_STR |
| 10676 | IP_STR |
| 10677 | BGP_STR |
| 10678 | "Display paths suppressed due to dampening\n") |
| 10679 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10680 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 10681 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10682 | } |
| 10683 | |
| 10684 | DEFUN (show_ip_bgp_flap_statistics, |
| 10685 | show_ip_bgp_flap_statistics_cmd, |
| 10686 | "show ip bgp flap-statistics", |
| 10687 | SHOW_STR |
| 10688 | IP_STR |
| 10689 | BGP_STR |
| 10690 | "Display flap statistics of routes\n") |
| 10691 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10692 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 10693 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10694 | } |
| 10695 | |
| 10696 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10697 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10698 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 10699 | const char *ip_str, afi_t afi, safi_t safi, |
| 10700 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10701 | { |
| 10702 | int ret; |
| 10703 | struct prefix match; |
| 10704 | struct bgp_node *rn; |
| 10705 | struct bgp_node *rm; |
| 10706 | struct bgp_info *ri; |
| 10707 | struct bgp_info *ri_temp; |
| 10708 | struct bgp *bgp; |
| 10709 | struct bgp_table *table; |
| 10710 | |
| 10711 | /* BGP structure lookup. */ |
| 10712 | if (view_name) |
| 10713 | { |
| 10714 | bgp = bgp_lookup_by_name (view_name); |
| 10715 | if (bgp == NULL) |
| 10716 | { |
| 10717 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 10718 | return CMD_WARNING; |
| 10719 | } |
| 10720 | } |
| 10721 | else |
| 10722 | { |
| 10723 | bgp = bgp_get_default (); |
| 10724 | if (bgp == NULL) |
| 10725 | { |
| 10726 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 10727 | return CMD_WARNING; |
| 10728 | } |
| 10729 | } |
| 10730 | |
| 10731 | /* Check IP address argument. */ |
| 10732 | ret = str2prefix (ip_str, &match); |
| 10733 | if (! ret) |
| 10734 | { |
| 10735 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 10736 | return CMD_WARNING; |
| 10737 | } |
| 10738 | |
| 10739 | match.family = afi2family (afi); |
| 10740 | |
| 10741 | if (safi == SAFI_MPLS_VPN) |
| 10742 | { |
| 10743 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 10744 | { |
| 10745 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 10746 | continue; |
| 10747 | |
| 10748 | if ((table = rn->info) != NULL) |
| 10749 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 10750 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 10751 | { |
| 10752 | ri = rm->info; |
| 10753 | while (ri) |
| 10754 | { |
| 10755 | if (ri->damp_info) |
| 10756 | { |
| 10757 | ri_temp = ri->next; |
| 10758 | bgp_damp_info_free (ri->damp_info, 1); |
| 10759 | ri = ri_temp; |
| 10760 | } |
| 10761 | else |
| 10762 | ri = ri->next; |
| 10763 | } |
| 10764 | } |
| 10765 | } |
| 10766 | } |
| 10767 | else |
| 10768 | { |
| 10769 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 10770 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 10771 | { |
| 10772 | ri = rn->info; |
| 10773 | while (ri) |
| 10774 | { |
| 10775 | if (ri->damp_info) |
| 10776 | { |
| 10777 | ri_temp = ri->next; |
| 10778 | bgp_damp_info_free (ri->damp_info, 1); |
| 10779 | ri = ri_temp; |
| 10780 | } |
| 10781 | else |
| 10782 | ri = ri->next; |
| 10783 | } |
| 10784 | } |
| 10785 | } |
| 10786 | |
| 10787 | return CMD_SUCCESS; |
| 10788 | } |
| 10789 | |
| 10790 | DEFUN (clear_ip_bgp_dampening, |
| 10791 | clear_ip_bgp_dampening_cmd, |
| 10792 | "clear ip bgp dampening", |
| 10793 | CLEAR_STR |
| 10794 | IP_STR |
| 10795 | BGP_STR |
| 10796 | "Clear route flap dampening information\n") |
| 10797 | { |
| 10798 | bgp_damp_info_clean (); |
| 10799 | return CMD_SUCCESS; |
| 10800 | } |
| 10801 | |
| 10802 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 10803 | clear_ip_bgp_dampening_prefix_cmd, |
| 10804 | "clear ip bgp dampening A.B.C.D/M", |
| 10805 | CLEAR_STR |
| 10806 | IP_STR |
| 10807 | BGP_STR |
| 10808 | "Clear route flap dampening information\n" |
| 10809 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10810 | { |
| 10811 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 10812 | SAFI_UNICAST, NULL, 1); |
| 10813 | } |
| 10814 | |
| 10815 | DEFUN (clear_ip_bgp_dampening_address, |
| 10816 | clear_ip_bgp_dampening_address_cmd, |
| 10817 | "clear ip bgp dampening A.B.C.D", |
| 10818 | CLEAR_STR |
| 10819 | IP_STR |
| 10820 | BGP_STR |
| 10821 | "Clear route flap dampening information\n" |
| 10822 | "Network to clear damping information\n") |
| 10823 | { |
| 10824 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 10825 | SAFI_UNICAST, NULL, 0); |
| 10826 | } |
| 10827 | |
| 10828 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 10829 | clear_ip_bgp_dampening_address_mask_cmd, |
| 10830 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 10831 | CLEAR_STR |
| 10832 | IP_STR |
| 10833 | BGP_STR |
| 10834 | "Clear route flap dampening information\n" |
| 10835 | "Network to clear damping information\n" |
| 10836 | "Network mask\n") |
| 10837 | { |
| 10838 | int ret; |
| 10839 | char prefix_str[BUFSIZ]; |
| 10840 | |
| 10841 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 10842 | if (! ret) |
| 10843 | { |
| 10844 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 10845 | return CMD_WARNING; |
| 10846 | } |
| 10847 | |
| 10848 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 10849 | SAFI_UNICAST, NULL, 0); |
| 10850 | } |
| 10851 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10852 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10853 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 10854 | afi_t afi, safi_t safi, int *write) |
| 10855 | { |
| 10856 | struct bgp_node *prn; |
| 10857 | struct bgp_node *rn; |
| 10858 | struct bgp_table *table; |
| 10859 | struct prefix *p; |
| 10860 | struct prefix_rd *prd; |
| 10861 | struct bgp_static *bgp_static; |
| 10862 | u_int32_t label; |
| 10863 | char buf[SU_ADDRSTRLEN]; |
| 10864 | char rdbuf[RD_ADDRSTRLEN]; |
| 10865 | |
| 10866 | /* Network configuration. */ |
| 10867 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 10868 | if ((table = prn->info) != NULL) |
| 10869 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 10870 | if ((bgp_static = rn->info) != NULL) |
| 10871 | { |
| 10872 | p = &rn->p; |
| 10873 | prd = (struct prefix_rd *) &prn->p; |
| 10874 | |
| 10875 | /* "address-family" display. */ |
| 10876 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10877 | |
| 10878 | /* "network" configuration display. */ |
| 10879 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 10880 | label = decode_label (bgp_static->tag); |
| 10881 | |
| 10882 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 10883 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10884 | p->prefixlen, |
| 10885 | rdbuf, label); |
| 10886 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10887 | } |
| 10888 | return 0; |
| 10889 | } |
| 10890 | |
| 10891 | /* Configuration of static route announcement and aggregate |
| 10892 | information. */ |
| 10893 | int |
| 10894 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 10895 | afi_t afi, safi_t safi, int *write) |
| 10896 | { |
| 10897 | struct bgp_node *rn; |
| 10898 | struct prefix *p; |
| 10899 | struct bgp_static *bgp_static; |
| 10900 | struct bgp_aggregate *bgp_aggregate; |
| 10901 | char buf[SU_ADDRSTRLEN]; |
| 10902 | |
| 10903 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 10904 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 10905 | |
| 10906 | /* Network configuration. */ |
| 10907 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10908 | if ((bgp_static = rn->info) != NULL) |
| 10909 | { |
| 10910 | p = &rn->p; |
| 10911 | |
| 10912 | /* "address-family" display. */ |
| 10913 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10914 | |
| 10915 | /* "network" configuration display. */ |
| 10916 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10917 | { |
| 10918 | u_int32_t destination; |
| 10919 | struct in_addr netmask; |
| 10920 | |
| 10921 | destination = ntohl (p->u.prefix4.s_addr); |
| 10922 | masklen2ip (p->prefixlen, &netmask); |
| 10923 | vty_out (vty, " network %s", |
| 10924 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 10925 | |
| 10926 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 10927 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 10928 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 10929 | || p->u.prefix4.s_addr == 0) |
| 10930 | { |
| 10931 | /* Natural mask is not display. */ |
| 10932 | } |
| 10933 | else |
| 10934 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 10935 | } |
| 10936 | else |
| 10937 | { |
| 10938 | vty_out (vty, " network %s/%d", |
| 10939 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10940 | p->prefixlen); |
| 10941 | } |
| 10942 | |
| 10943 | if (bgp_static->rmap.name) |
| 10944 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 10945 | else if (bgp_static->backdoor) |
| 10946 | vty_out (vty, " backdoor"); |
| 10947 | |
| 10948 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10949 | } |
| 10950 | |
| 10951 | /* Aggregate-address configuration. */ |
| 10952 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10953 | if ((bgp_aggregate = rn->info) != NULL) |
| 10954 | { |
| 10955 | p = &rn->p; |
| 10956 | |
| 10957 | /* "address-family" display. */ |
| 10958 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10959 | |
| 10960 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10961 | { |
| 10962 | struct in_addr netmask; |
| 10963 | |
| 10964 | masklen2ip (p->prefixlen, &netmask); |
| 10965 | vty_out (vty, " aggregate-address %s %s", |
| 10966 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10967 | inet_ntoa (netmask)); |
| 10968 | } |
| 10969 | else |
| 10970 | { |
| 10971 | vty_out (vty, " aggregate-address %s/%d", |
| 10972 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10973 | p->prefixlen); |
| 10974 | } |
| 10975 | |
| 10976 | if (bgp_aggregate->as_set) |
| 10977 | vty_out (vty, " as-set"); |
| 10978 | |
| 10979 | if (bgp_aggregate->summary_only) |
| 10980 | vty_out (vty, " summary-only"); |
| 10981 | |
| 10982 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10983 | } |
| 10984 | |
| 10985 | return 0; |
| 10986 | } |
| 10987 | |
| 10988 | int |
| 10989 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 10990 | { |
| 10991 | struct bgp_node *rn; |
| 10992 | struct bgp_distance *bdistance; |
| 10993 | |
| 10994 | /* Distance configuration. */ |
| 10995 | if (bgp->distance_ebgp |
| 10996 | && bgp->distance_ibgp |
| 10997 | && bgp->distance_local |
| 10998 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 10999 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 11000 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 11001 | vty_out (vty, " distance bgp %d %d %d%s", |
| 11002 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 11003 | VTY_NEWLINE); |
| 11004 | |
| 11005 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 11006 | if ((bdistance = rn->info) != NULL) |
| 11007 | { |
| 11008 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 11009 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 11010 | bdistance->access_list ? bdistance->access_list : "", |
| 11011 | VTY_NEWLINE); |
| 11012 | } |
| 11013 | |
| 11014 | return 0; |
| 11015 | } |
| 11016 | |
| 11017 | /* Allocate routing table structure and install commands. */ |
| 11018 | void |
| 11019 | bgp_route_init () |
| 11020 | { |
| 11021 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 11022 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11023 | |
| 11024 | /* IPv4 BGP commands. */ |
| 11025 | install_element (BGP_NODE, &bgp_network_cmd); |
| 11026 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 11027 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 11028 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 11029 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 11030 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 11031 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 11032 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 11033 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 11034 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 11035 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 11036 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 11037 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 11038 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 11039 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 11040 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 11041 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 11042 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 11043 | |
| 11044 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 11045 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 11046 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 11047 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 11048 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 11049 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 11050 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 11051 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 11052 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 11053 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 11054 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 11055 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 11056 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 11057 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 11058 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 11059 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 11060 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 11061 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 11062 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 11063 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 11064 | |
| 11065 | /* IPv4 unicast configuration. */ |
| 11066 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 11067 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 11068 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 11069 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 11070 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 11071 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 11072 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 11073 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 11074 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 11075 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 11076 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 11077 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 11078 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 11079 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 11080 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 11081 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 11082 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 11083 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 11084 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 11085 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 11086 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 11087 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 11088 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 11089 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 11090 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 11091 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 11092 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 11093 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 11094 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 11095 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 11096 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 11097 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 11098 | |
| 11099 | /* IPv4 multicast configuration. */ |
| 11100 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 11101 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 11102 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 11103 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 11104 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 11105 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 11106 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 11107 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 11108 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 11109 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 11110 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 11111 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 11112 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 11113 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 11114 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 11115 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 11116 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 11117 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 11118 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 11119 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 11120 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 11121 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 11122 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 11123 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 11124 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 11125 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 11126 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 11127 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 11128 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 11129 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 11130 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 11131 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 11132 | |
| 11133 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 11134 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 11135 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 11136 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 11137 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 11138 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 11139 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 11140 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 11141 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 11142 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 11143 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 11144 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 11145 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 11146 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 11147 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 11148 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 11149 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 11150 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 11151 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 11152 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 11153 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 11154 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 11155 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 11156 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 11157 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 11158 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 11159 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 11160 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 11161 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 11162 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 11163 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 11164 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 11165 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 11166 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 11167 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 11168 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 11169 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 11170 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 11171 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 11172 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 11173 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 11174 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 11175 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 11176 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 11177 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 11178 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 11179 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 11180 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 11181 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 11182 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 11183 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 11184 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 11185 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 11186 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 11187 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 11188 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 11189 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 11190 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 11191 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 11192 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 11193 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 11194 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 11195 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 11196 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 11197 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 11198 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 11199 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11200 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 11201 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 11202 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 11203 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 11204 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 11205 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11206 | |
| 11207 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 11208 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 11209 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 11210 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 11211 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 11212 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 11213 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 11214 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 11215 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 11216 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 11217 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 11218 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 11219 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 11220 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 11221 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 11222 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 11223 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 11224 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 11225 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 11226 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 11227 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 11228 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 11229 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 11230 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 11231 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 11232 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 11233 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 11234 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 11235 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 11236 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 11237 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 11238 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 11239 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 11240 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 11241 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 11242 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 11243 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 11244 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 11245 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 11246 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 11247 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 11248 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 11249 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 11250 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 11251 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 11252 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 11253 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 11254 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 11255 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 11256 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 11257 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 11258 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 11259 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 11260 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 11261 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 11262 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 11263 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 11264 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 11265 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 11266 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 11267 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 11268 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 11269 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 11270 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 11271 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 11272 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 11273 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11274 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 11275 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 11276 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 11277 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 11278 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 11279 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11280 | |
| 11281 | /* BGP dampening clear commands */ |
| 11282 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 11283 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 11284 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 11285 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 11286 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11287 | /* prefix count */ |
| 11288 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 11289 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 11290 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11291 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 11292 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 11293 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11294 | /* New config IPv6 BGP commands. */ |
| 11295 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 11296 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 11297 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 11298 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 11299 | |
| 11300 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 11301 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 11302 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 11303 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 11304 | |
| 11305 | /* Old config IPv6 BGP commands. */ |
| 11306 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 11307 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 11308 | |
| 11309 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 11310 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 11311 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 11312 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 11313 | |
| 11314 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 11315 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 11316 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 11317 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 11318 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 11319 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 11320 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 11321 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 11322 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 11323 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 11324 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 11325 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 11326 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 11327 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 11328 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 11329 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 11330 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 11331 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 11332 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 11333 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 11334 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 11335 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 11336 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 11337 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 11338 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 11339 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 11340 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 11341 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 11342 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 11343 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 11344 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 11345 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 11346 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 11347 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 11348 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 11349 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 11350 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 11351 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 11352 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 11353 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 11354 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 11355 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 11356 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 11357 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 11358 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 11359 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11360 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 11361 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 11362 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 11363 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11364 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 11365 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 11366 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11367 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 11368 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 11369 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 11370 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 11371 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 11372 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 11373 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 11374 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 11375 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 11376 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 11377 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 11378 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 11379 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 11380 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 11381 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 11382 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 11383 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 11384 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11385 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 11386 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 11387 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11388 | |
| 11389 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 11390 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 11391 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 11392 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 11393 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 11394 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 11395 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 11396 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 11397 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 11398 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 11399 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 11400 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 11401 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 11402 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 11403 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 11404 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 11405 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 11406 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 11407 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 11408 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 11409 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 11410 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 11411 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 11412 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 11413 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 11414 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 11415 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 11416 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 11417 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 11418 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 11419 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 11420 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 11421 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 11422 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 11423 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 11424 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 11425 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 11426 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 11427 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 11428 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 11429 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 11430 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 11431 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 11432 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 11433 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 11434 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11435 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 11436 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 11437 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 11438 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11439 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 11440 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 11441 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11442 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 11443 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 11444 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 11445 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 11446 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 11447 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 11448 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 11449 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 11450 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 11451 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 11452 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 11453 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 11454 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 11455 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 11456 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 11457 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 11458 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 11459 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11460 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 11461 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 11462 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11463 | |
| 11464 | /* Statistics */ |
| 11465 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 11466 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 11467 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 11468 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 11469 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11470 | /* old command */ |
| 11471 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 11472 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 11473 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 11474 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 11475 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 11476 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 11477 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 11478 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 11479 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 11480 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 11481 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 11482 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 11483 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 11484 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 11485 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 11486 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 11487 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 11488 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 11489 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 11490 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 11491 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 11492 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 11493 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 11494 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 11495 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 11496 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 11497 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 11498 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 11499 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 11500 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 11501 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 11502 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 11503 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 11504 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 11505 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 11506 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11507 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11508 | /* old command */ |
| 11509 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 11510 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 11511 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 11512 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 11513 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 11514 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 11515 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 11516 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 11517 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 11518 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 11519 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 11520 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 11521 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 11522 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 11523 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 11524 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 11525 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 11526 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 11527 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 11528 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 11529 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 11530 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 11531 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 11532 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 11533 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 11534 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 11535 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 11536 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 11537 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 11538 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 11539 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 11540 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 11541 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 11542 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 11543 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 11544 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 11545 | |
| 11546 | /* old command */ |
| 11547 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 11548 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 11549 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 11550 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 11551 | |
| 11552 | /* old command */ |
| 11553 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 11554 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 11555 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 11556 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 11557 | |
| 11558 | /* old command */ |
| 11559 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 11560 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 11561 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 11562 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 11563 | #endif /* HAVE_IPV6 */ |
| 11564 | |
| 11565 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 11566 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 11567 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 11568 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 11569 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 11570 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 11571 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 11572 | |
| 11573 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 11574 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 11575 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 11576 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 11577 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 11578 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 11579 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 11580 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 11581 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 11582 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 11583 | } |