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" |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 57 | #include "bgpd/bgp_mpath.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | |
| 59 | /* Extern from bgp_dump.c */ |
Stephen Hemminger | dde7258 | 2009-05-08 15:19:07 -0700 | [diff] [blame] | 60 | extern const char *bgp_origin_str[]; |
| 61 | extern const char *bgp_origin_long_str[]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 62 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 63 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 64 | 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] | 65 | struct prefix_rd *prd) |
| 66 | { |
| 67 | struct bgp_node *rn; |
| 68 | struct bgp_node *prn = NULL; |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 69 | |
| 70 | assert (table); |
| 71 | if (!table) |
| 72 | return NULL; |
| 73 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 74 | if (safi == SAFI_MPLS_VPN) |
| 75 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 76 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 77 | |
| 78 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 79 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 80 | else |
| 81 | bgp_unlock_node (prn); |
| 82 | table = prn->info; |
| 83 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 84 | |
| 85 | rn = bgp_node_get (table, p); |
| 86 | |
| 87 | if (safi == SAFI_MPLS_VPN) |
| 88 | rn->prn = prn; |
| 89 | |
| 90 | return rn; |
| 91 | } |
| 92 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 93 | /* Allocate bgp_info_extra */ |
| 94 | static struct bgp_info_extra * |
| 95 | bgp_info_extra_new (void) |
| 96 | { |
| 97 | struct bgp_info_extra *new; |
| 98 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); |
| 99 | return new; |
| 100 | } |
| 101 | |
| 102 | static void |
| 103 | bgp_info_extra_free (struct bgp_info_extra **extra) |
| 104 | { |
| 105 | if (extra && *extra) |
| 106 | { |
| 107 | if ((*extra)->damp_info) |
| 108 | bgp_damp_info_free ((*extra)->damp_info, 0); |
| 109 | |
| 110 | (*extra)->damp_info = NULL; |
| 111 | |
| 112 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); |
| 113 | |
| 114 | *extra = NULL; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /* Get bgp_info extra information for the given bgp_info, lazy allocated |
| 119 | * if required. |
| 120 | */ |
| 121 | struct bgp_info_extra * |
| 122 | bgp_info_extra_get (struct bgp_info *ri) |
| 123 | { |
| 124 | if (!ri->extra) |
| 125 | ri->extra = bgp_info_extra_new(); |
| 126 | return ri->extra; |
| 127 | } |
| 128 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | /* Allocate new bgp info structure. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 130 | static struct bgp_info * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 131 | bgp_info_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 133 | return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 137 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 138 | bgp_info_free (struct bgp_info *binfo) |
| 139 | { |
| 140 | if (binfo->attr) |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 141 | bgp_attr_unintern (&binfo->attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 142 | |
| 143 | bgp_info_extra_free (&binfo->extra); |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 144 | bgp_info_mpath_free (&binfo->mpath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 145 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 146 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 147 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 149 | } |
| 150 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 151 | struct bgp_info * |
| 152 | bgp_info_lock (struct bgp_info *binfo) |
| 153 | { |
| 154 | binfo->lock++; |
| 155 | return binfo; |
| 156 | } |
| 157 | |
| 158 | struct bgp_info * |
| 159 | bgp_info_unlock (struct bgp_info *binfo) |
| 160 | { |
| 161 | assert (binfo && binfo->lock > 0); |
| 162 | binfo->lock--; |
| 163 | |
| 164 | if (binfo->lock == 0) |
| 165 | { |
| 166 | #if 0 |
| 167 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 168 | zlog_backtrace (LOG_DEBUG); |
| 169 | #endif |
| 170 | bgp_info_free (binfo); |
| 171 | return NULL; |
| 172 | } |
| 173 | |
| 174 | #if 0 |
| 175 | if (binfo->lock == 1) |
| 176 | { |
| 177 | zlog_debug ("%s: unlocked to 1", __func__); |
| 178 | zlog_backtrace (LOG_DEBUG); |
| 179 | } |
| 180 | #endif |
| 181 | |
| 182 | return binfo; |
| 183 | } |
| 184 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 185 | void |
| 186 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 187 | { |
| 188 | struct bgp_info *top; |
| 189 | |
| 190 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 191 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 192 | ri->next = rn->info; |
| 193 | ri->prev = NULL; |
| 194 | if (top) |
| 195 | top->prev = ri; |
| 196 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 197 | |
| 198 | bgp_info_lock (ri); |
| 199 | bgp_lock_node (rn); |
| 200 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 201 | } |
| 202 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 203 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 204 | completion callback *only* */ |
| 205 | static void |
| 206 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | { |
| 208 | if (ri->next) |
| 209 | ri->next->prev = ri->prev; |
| 210 | if (ri->prev) |
| 211 | ri->prev->next = ri->next; |
| 212 | else |
| 213 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 214 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 215 | bgp_info_mpath_dequeue (ri); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 216 | bgp_info_unlock (ri); |
| 217 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | } |
| 219 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 220 | void |
| 221 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 222 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 223 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
| 224 | /* set of previous already took care of pcount */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 225 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 226 | } |
| 227 | |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 228 | /* undo the effects of a previous call to bgp_info_delete; typically |
| 229 | called when a route is deleted and then quickly re-added before the |
| 230 | deletion has been processed */ |
| 231 | static void |
| 232 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) |
| 233 | { |
| 234 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); |
| 235 | /* unset of previous already took care of pcount */ |
| 236 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 237 | } |
| 238 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 239 | /* Adjust pcount as required */ |
| 240 | static void |
| 241 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) |
| 242 | { |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 243 | assert (rn && rn->table); |
| 244 | assert (ri && ri->peer && ri->peer->bgp); |
| 245 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 246 | /* Ignore 'pcount' for RS-client tables */ |
| 247 | if (rn->table->type != BGP_TABLE_MAIN |
| 248 | || ri->peer == ri->peer->bgp->peer_self) |
| 249 | return; |
| 250 | |
| 251 | if (BGP_INFO_HOLDDOWN (ri) |
| 252 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 253 | { |
| 254 | |
| 255 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 256 | |
| 257 | /* slight hack, but more robust against errors. */ |
| 258 | if (ri->peer->pcount[rn->table->afi][rn->table->safi]) |
| 259 | ri->peer->pcount[rn->table->afi][rn->table->safi]--; |
| 260 | else |
| 261 | { |
| 262 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 263 | __func__, ri->peer->host); |
| 264 | zlog_backtrace (LOG_WARNING); |
| 265 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 266 | } |
| 267 | } |
| 268 | else if (!BGP_INFO_HOLDDOWN (ri) |
| 269 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 270 | { |
| 271 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 272 | ri->peer->pcount[rn->table->afi][rn->table->safi]++; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | |
| 277 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 278 | * This is here primarily to keep prefix-count in check. |
| 279 | */ |
| 280 | void |
| 281 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 282 | { |
| 283 | SET_FLAG (ri->flags, flag); |
| 284 | |
| 285 | /* early bath if we know it's not a flag that changes useability state */ |
| 286 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 287 | return; |
| 288 | |
| 289 | bgp_pcount_adjust (rn, ri); |
| 290 | } |
| 291 | |
| 292 | void |
| 293 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 294 | { |
| 295 | UNSET_FLAG (ri->flags, flag); |
| 296 | |
| 297 | /* early bath if we know it's not a flag that changes useability state */ |
| 298 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 299 | return; |
| 300 | |
| 301 | bgp_pcount_adjust (rn, ri); |
| 302 | } |
| 303 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 304 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 305 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 306 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 307 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 308 | { |
| 309 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 310 | return attr->med; |
| 311 | else |
| 312 | { |
| 313 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 314 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 315 | else |
| 316 | return 0; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | /* Compare two bgp route entity. br is preferable then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 321 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 322 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
| 323 | int *paths_eq) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 324 | { |
| 325 | u_int32_t new_pref; |
| 326 | u_int32_t exist_pref; |
| 327 | u_int32_t new_med; |
| 328 | u_int32_t exist_med; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 329 | u_int32_t new_weight = 0; |
| 330 | u_int32_t exist_weight = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 331 | struct in_addr new_id; |
| 332 | struct in_addr exist_id; |
| 333 | int new_cluster; |
| 334 | int exist_cluster; |
| 335 | int internal_as_route = 0; |
| 336 | int confed_as_route = 0; |
| 337 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 338 | uint32_t newm, existm; |
| 339 | |
| 340 | *paths_eq = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 341 | |
| 342 | /* 0. Null check. */ |
| 343 | if (new == NULL) |
| 344 | return 0; |
| 345 | if (exist == NULL) |
| 346 | return 1; |
| 347 | |
| 348 | /* 1. Weight check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 349 | if (new->attr->extra) |
| 350 | new_weight = new->attr->extra->weight; |
| 351 | if (exist->attr->extra) |
| 352 | exist_weight = exist->attr->extra->weight; |
| 353 | if (new_weight > exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 354 | return 1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 355 | if (new_weight < exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 356 | return 0; |
| 357 | |
| 358 | /* 2. Local preference check. */ |
| 359 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 360 | new_pref = new->attr->local_pref; |
| 361 | else |
| 362 | new_pref = bgp->default_local_pref; |
| 363 | |
| 364 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 365 | exist_pref = exist->attr->local_pref; |
| 366 | else |
| 367 | exist_pref = bgp->default_local_pref; |
| 368 | |
| 369 | if (new_pref > exist_pref) |
| 370 | return 1; |
| 371 | if (new_pref < exist_pref) |
| 372 | return 0; |
| 373 | |
| 374 | /* 3. Local route check. */ |
| 375 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 376 | return 1; |
| 377 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 378 | return 0; |
| 379 | |
| 380 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 381 | return 1; |
| 382 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 383 | return 0; |
| 384 | |
| 385 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 386 | return 1; |
| 387 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 388 | return 0; |
| 389 | |
| 390 | /* 4. AS path length check. */ |
| 391 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 392 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 393 | int exist_hops = aspath_count_hops (exist->attr->aspath); |
| 394 | int exist_confeds = aspath_count_confeds (exist->attr->aspath); |
| 395 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 396 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 397 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 398 | int aspath_hops; |
| 399 | |
| 400 | aspath_hops = aspath_count_hops (new->attr->aspath); |
| 401 | aspath_hops += aspath_count_confeds (new->attr->aspath); |
| 402 | |
| 403 | if ( aspath_hops < (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 404 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 405 | if ( aspath_hops > (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 406 | return 0; |
| 407 | } |
| 408 | else |
| 409 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 410 | int newhops = aspath_count_hops (new->attr->aspath); |
| 411 | |
| 412 | if (newhops < exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 413 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 414 | if (newhops > exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 415 | return 0; |
| 416 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | /* 5. Origin check. */ |
| 420 | if (new->attr->origin < exist->attr->origin) |
| 421 | return 1; |
| 422 | if (new->attr->origin > exist->attr->origin) |
| 423 | return 0; |
| 424 | |
| 425 | /* 6. MED check. */ |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 426 | internal_as_route = (aspath_count_hops (new->attr->aspath) == 0 |
| 427 | && aspath_count_hops (exist->attr->aspath) == 0); |
| 428 | confed_as_route = (aspath_count_confeds (new->attr->aspath) > 0 |
| 429 | && aspath_count_confeds (exist->attr->aspath) > 0 |
| 430 | && aspath_count_hops (new->attr->aspath) == 0 |
| 431 | && aspath_count_hops (exist->attr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 432 | |
| 433 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 434 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 435 | && confed_as_route) |
| 436 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 437 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 438 | || internal_as_route) |
| 439 | { |
| 440 | new_med = bgp_med_value (new->attr, bgp); |
| 441 | exist_med = bgp_med_value (exist->attr, bgp); |
| 442 | |
| 443 | if (new_med < exist_med) |
| 444 | return 1; |
| 445 | if (new_med > exist_med) |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | /* 7. Peer type check. */ |
| 450 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 451 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 452 | return 1; |
| 453 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 454 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 455 | return 1; |
| 456 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 457 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 458 | return 0; |
| 459 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 460 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 461 | return 0; |
| 462 | |
| 463 | /* 8. IGP metric check. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 464 | newm = (new->extra ? new->extra->igpmetric : 0); |
| 465 | existm = (exist->extra ? exist->extra->igpmetric : 0); |
| 466 | if (newm < existm) |
| 467 | ret = 1; |
| 468 | if (newm > existm) |
| 469 | ret = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 470 | |
| 471 | /* 9. Maximum path check. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 472 | if (newm == existm) |
| 473 | { |
| 474 | if ((peer_sort (new->peer) == BGP_PEER_IBGP)) |
| 475 | { |
| 476 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 477 | *paths_eq = 1; |
| 478 | } |
| 479 | else if (new->peer->as == exist->peer->as) |
| 480 | *paths_eq = 1; |
| 481 | } |
| 482 | else |
| 483 | { |
| 484 | /* |
| 485 | * TODO: If unequal cost ibgp multipath is enabled we can |
| 486 | * mark the paths as equal here instead of returning |
| 487 | */ |
| 488 | return ret; |
| 489 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 490 | |
| 491 | /* 10. If both paths are external, prefer the path that was received |
| 492 | first (the oldest one). This step minimizes route-flap, since a |
| 493 | newer path won't displace an older one, even if it was the |
| 494 | preferred route based on the additional decision criteria below. */ |
| 495 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 496 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 497 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 498 | { |
| 499 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 500 | return 1; |
| 501 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 502 | return 0; |
| 503 | } |
| 504 | |
| 505 | /* 11. Rourter-ID comparision. */ |
| 506 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 507 | new_id.s_addr = new->attr->extra->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | else |
| 509 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 510 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 511 | exist_id.s_addr = exist->attr->extra->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 512 | else |
| 513 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 514 | |
| 515 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 516 | return 1; |
| 517 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 518 | return 0; |
| 519 | |
| 520 | /* 12. Cluster length comparision. */ |
| 521 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 522 | new_cluster = new->attr->extra->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 523 | else |
| 524 | new_cluster = 0; |
| 525 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 526 | exist_cluster = exist->attr->extra->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 527 | else |
| 528 | exist_cluster = 0; |
| 529 | |
| 530 | if (new_cluster < exist_cluster) |
| 531 | return 1; |
| 532 | if (new_cluster > exist_cluster) |
| 533 | return 0; |
| 534 | |
| 535 | /* 13. Neighbor address comparision. */ |
| 536 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 537 | |
| 538 | if (ret == 1) |
| 539 | return 0; |
| 540 | if (ret == -1) |
| 541 | return 1; |
| 542 | |
| 543 | return 1; |
| 544 | } |
| 545 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 546 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 547 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 548 | afi_t afi, safi_t safi) |
| 549 | { |
| 550 | struct bgp_filter *filter; |
| 551 | |
| 552 | filter = &peer->filter[afi][safi]; |
| 553 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 554 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 555 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 556 | && !(F ## _IN (filter))) \ |
| 557 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 558 | peer->host, #f, F ## _IN_NAME(filter)); |
| 559 | |
| 560 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 561 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 562 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 563 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 564 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 565 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 566 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 567 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 568 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 569 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 571 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 572 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 574 | if (FILTER_LIST_IN_NAME (filter)) { |
| 575 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 576 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 577 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 578 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 579 | } |
| 580 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 581 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 582 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 583 | } |
| 584 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 585 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 587 | afi_t afi, safi_t safi) |
| 588 | { |
| 589 | struct bgp_filter *filter; |
| 590 | |
| 591 | filter = &peer->filter[afi][safi]; |
| 592 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 593 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 594 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 595 | && !(F ## _OUT (filter))) \ |
| 596 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 597 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 598 | |
| 599 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 600 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 601 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 602 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 603 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 604 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 606 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 607 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 608 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 609 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 610 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 611 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 612 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 613 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 614 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 615 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 616 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 617 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 618 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 619 | |
| 620 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 621 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 625 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 626 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 627 | { |
| 628 | if (attr->community) |
| 629 | { |
| 630 | /* NO_ADVERTISE check. */ |
| 631 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 632 | return 1; |
| 633 | |
| 634 | /* NO_EXPORT check. */ |
| 635 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 636 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 637 | return 1; |
| 638 | |
| 639 | /* NO_EXPORT_SUBCONFED check. */ |
| 640 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 641 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 642 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 643 | return 1; |
| 644 | } |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | /* Route reflection loop check. */ |
| 649 | static int |
| 650 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 651 | { |
| 652 | struct in_addr cluster_id; |
| 653 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 654 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 655 | { |
| 656 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 657 | cluster_id = peer->bgp->cluster_id; |
| 658 | else |
| 659 | cluster_id = peer->bgp->router_id; |
| 660 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 661 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 662 | return 1; |
| 663 | } |
| 664 | return 0; |
| 665 | } |
| 666 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 667 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 668 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 669 | afi_t afi, safi_t safi) |
| 670 | { |
| 671 | struct bgp_filter *filter; |
| 672 | struct bgp_info info; |
| 673 | route_map_result_t ret; |
| 674 | |
| 675 | filter = &peer->filter[afi][safi]; |
| 676 | |
| 677 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 678 | if (peer->weight) |
| 679 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 680 | |
| 681 | /* Route map apply. */ |
| 682 | if (ROUTE_MAP_IN_NAME (filter)) |
| 683 | { |
| 684 | /* Duplicate current value to new strucutre for modification. */ |
| 685 | info.peer = peer; |
| 686 | info.attr = attr; |
| 687 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 688 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 689 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | /* Apply BGP route map to the attribute. */ |
| 691 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 692 | |
| 693 | peer->rmap_type = 0; |
| 694 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 695 | if (ret == RMAP_DENYMATCH) |
| 696 | { |
| 697 | /* Free newly generated AS path and community by route-map. */ |
| 698 | bgp_attr_flush (attr); |
| 699 | return RMAP_DENY; |
| 700 | } |
| 701 | } |
| 702 | return RMAP_PERMIT; |
| 703 | } |
| 704 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 705 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 706 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 707 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 708 | { |
| 709 | struct bgp_filter *filter; |
| 710 | struct bgp_info info; |
| 711 | route_map_result_t ret; |
| 712 | |
| 713 | filter = &peer->filter[afi][safi]; |
| 714 | |
| 715 | /* Route map apply. */ |
| 716 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 717 | { |
| 718 | /* Duplicate current value to new strucutre for modification. */ |
| 719 | info.peer = rsclient; |
| 720 | info.attr = attr; |
| 721 | |
| 722 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 723 | |
| 724 | /* Apply BGP route map to the attribute. */ |
| 725 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 726 | |
| 727 | rsclient->rmap_type = 0; |
| 728 | |
| 729 | if (ret == RMAP_DENYMATCH) |
| 730 | { |
| 731 | /* Free newly generated AS path and community by route-map. */ |
| 732 | bgp_attr_flush (attr); |
| 733 | return RMAP_DENY; |
| 734 | } |
| 735 | } |
| 736 | return RMAP_PERMIT; |
| 737 | } |
| 738 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 739 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 740 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 741 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 742 | { |
| 743 | struct bgp_filter *filter; |
| 744 | struct bgp_info info; |
| 745 | route_map_result_t ret; |
| 746 | |
| 747 | filter = &rsclient->filter[afi][safi]; |
| 748 | |
| 749 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 750 | if (peer->weight) |
| 751 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 752 | |
| 753 | /* Route map apply. */ |
| 754 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 755 | { |
| 756 | /* Duplicate current value to new strucutre for modification. */ |
| 757 | info.peer = peer; |
| 758 | info.attr = attr; |
| 759 | |
| 760 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 761 | |
| 762 | /* Apply BGP route map to the attribute. */ |
| 763 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 764 | |
| 765 | peer->rmap_type = 0; |
| 766 | |
| 767 | if (ret == RMAP_DENYMATCH) |
| 768 | { |
| 769 | /* Free newly generated AS path and community by route-map. */ |
| 770 | bgp_attr_flush (attr); |
| 771 | return RMAP_DENY; |
| 772 | } |
| 773 | } |
| 774 | return RMAP_PERMIT; |
| 775 | } |
| 776 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 777 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 778 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 779 | struct attr *attr, afi_t afi, safi_t safi) |
| 780 | { |
| 781 | int ret; |
| 782 | char buf[SU_ADDRSTRLEN]; |
| 783 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 784 | struct peer *from; |
| 785 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 786 | int transparent; |
| 787 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 788 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 789 | |
| 790 | from = ri->peer; |
| 791 | filter = &peer->filter[afi][safi]; |
| 792 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 793 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 794 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 795 | if (DISABLE_BGP_ANNOUNCE) |
| 796 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 797 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 798 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 799 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 800 | return 0; |
| 801 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 802 | /* Do not send back route to sender. */ |
| 803 | if (from == peer) |
| 804 | return 0; |
| 805 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 806 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 807 | if (p->family == AF_INET |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 808 | && IPV4_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 809 | return 0; |
| 810 | #ifdef HAVE_IPV6 |
| 811 | if (p->family == AF_INET6 |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 812 | && IPV6_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 813 | return 0; |
| 814 | #endif |
| 815 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 816 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 817 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 818 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 819 | return 0; |
| 820 | |
| 821 | /* Default route check. */ |
| 822 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 823 | { |
| 824 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 825 | return 0; |
| 826 | #ifdef HAVE_IPV6 |
| 827 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 828 | return 0; |
| 829 | #endif /* HAVE_IPV6 */ |
| 830 | } |
| 831 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 832 | /* Transparency check. */ |
| 833 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 834 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 835 | transparent = 1; |
| 836 | else |
| 837 | transparent = 0; |
| 838 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 839 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 840 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 841 | return 0; |
| 842 | |
| 843 | /* If the attribute has originator-id and it is same as remote |
| 844 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 845 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 846 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 847 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | { |
| 849 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 850 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 852 | peer->host, |
| 853 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 854 | p->prefixlen); |
| 855 | return 0; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | /* ORF prefix-list filter check */ |
| 860 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 861 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 862 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 863 | if (peer->orf_plist[afi][safi]) |
| 864 | { |
| 865 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 866 | return 0; |
| 867 | } |
| 868 | |
| 869 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 870 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 871 | { |
| 872 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 873 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 874 | "%s [Update:SEND] %s/%d is filtered", |
| 875 | peer->host, |
| 876 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 877 | p->prefixlen); |
| 878 | return 0; |
| 879 | } |
| 880 | |
| 881 | #ifdef BGP_SEND_ASPATH_CHECK |
| 882 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 883 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 884 | { |
| 885 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 886 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 887 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 888 | peer->host, peer->as); |
| 889 | return 0; |
| 890 | } |
| 891 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 892 | |
| 893 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 894 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 895 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 896 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 897 | { |
| 898 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 899 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 900 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 901 | peer->host, |
| 902 | bgp->confed_id); |
| 903 | return 0; |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | /* Route-Reflect check. */ |
| 908 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 909 | reflect = 1; |
| 910 | else |
| 911 | reflect = 0; |
| 912 | |
| 913 | /* IBGP reflection check. */ |
| 914 | if (reflect) |
| 915 | { |
| 916 | /* A route from a Client peer. */ |
| 917 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 918 | { |
| 919 | /* Reflect to all the Non-Client peers and also to the |
| 920 | Client peers other than the originator. Originator check |
| 921 | is already done. So there is noting to do. */ |
| 922 | /* no bgp client-to-client reflection check. */ |
| 923 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 924 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 925 | return 0; |
| 926 | } |
| 927 | else |
| 928 | { |
| 929 | /* A route from a Non-client peer. Reflect to all other |
| 930 | clients. */ |
| 931 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 932 | return 0; |
| 933 | } |
| 934 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 935 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 936 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 937 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 938 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 939 | /* If local-preference is not set. */ |
| 940 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 941 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 942 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 943 | { |
| 944 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 945 | attr->local_pref = bgp->default_local_pref; |
| 946 | } |
| 947 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 948 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 949 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 950 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 951 | { |
| 952 | if (ri->peer != bgp->peer_self && ! transparent |
| 953 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 954 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 955 | } |
| 956 | |
| 957 | /* next-hop-set */ |
| 958 | if (transparent || reflect |
| 959 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 960 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 961 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 962 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 963 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 964 | #endif /* HAVE_IPV6 */ |
| 965 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 966 | { |
| 967 | /* NEXT-HOP Unchanged. */ |
| 968 | } |
| 969 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 970 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 971 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 972 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 973 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 974 | #endif /* HAVE_IPV6 */ |
| 975 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 976 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 977 | { |
| 978 | /* Set IPv4 nexthop. */ |
| 979 | if (p->family == AF_INET) |
| 980 | { |
| 981 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 982 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 983 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 984 | else |
| 985 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 986 | } |
| 987 | #ifdef HAVE_IPV6 |
| 988 | /* Set IPv6 nexthop. */ |
| 989 | if (p->family == AF_INET6) |
| 990 | { |
| 991 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 992 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 993 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 994 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 995 | } |
| 996 | #endif /* HAVE_IPV6 */ |
| 997 | } |
| 998 | |
| 999 | #ifdef HAVE_IPV6 |
| 1000 | if (p->family == AF_INET6) |
| 1001 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1002 | /* Left nexthop_local unchanged if so configured. */ |
| 1003 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1004 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1005 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1006 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1007 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1008 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1009 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
| 1012 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1013 | else |
| 1014 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1015 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1016 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1017 | |
| 1018 | /* Set link-local address for shared network peer. */ |
| 1019 | if (peer->shared_network |
| 1020 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1021 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1022 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1023 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1024 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1028 | address.*/ |
| 1029 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1030 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1031 | |
| 1032 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1033 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1034 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1035 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1036 | |
| 1037 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1038 | #endif /* HAVE_IPV6 */ |
| 1039 | |
| 1040 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1041 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 1042 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1043 | && aspath_private_as_check (attr->aspath)) |
| 1044 | attr->aspath = aspath_empty_get (); |
| 1045 | |
| 1046 | /* Route map & unsuppress-map apply. */ |
| 1047 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1048 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1049 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1050 | struct bgp_info info; |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1051 | struct attr dummy_attr = { 0 }; |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1052 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1053 | info.peer = peer; |
| 1054 | info.attr = attr; |
| 1055 | |
| 1056 | /* The route reflector is not allowed to modify the attributes |
| 1057 | of the reflected IBGP routes. */ |
| 1058 | if (peer_sort (from) == BGP_PEER_IBGP |
| 1059 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 1060 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1061 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1062 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1063 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1064 | |
| 1065 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1066 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1067 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1068 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1069 | else |
| 1070 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1071 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1072 | peer->rmap_type = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1073 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1074 | if (dummy_attr.extra) |
| 1075 | bgp_attr_extra_free (&dummy_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1076 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1077 | if (ret == RMAP_DENYMATCH) |
| 1078 | { |
| 1079 | bgp_attr_flush (attr); |
| 1080 | return 0; |
| 1081 | } |
| 1082 | } |
| 1083 | return 1; |
| 1084 | } |
| 1085 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1086 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1087 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1088 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1089 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1090 | int ret; |
| 1091 | char buf[SU_ADDRSTRLEN]; |
| 1092 | struct bgp_filter *filter; |
| 1093 | struct bgp_info info; |
| 1094 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1095 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1096 | |
| 1097 | from = ri->peer; |
| 1098 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1099 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1100 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1101 | if (DISABLE_BGP_ANNOUNCE) |
| 1102 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1103 | |
| 1104 | /* Do not send back route to sender. */ |
| 1105 | if (from == rsclient) |
| 1106 | return 0; |
| 1107 | |
| 1108 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1109 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1110 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1111 | return 0; |
| 1112 | |
| 1113 | /* Default route check. */ |
| 1114 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1115 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1116 | { |
| 1117 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1118 | return 0; |
| 1119 | #ifdef HAVE_IPV6 |
| 1120 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1121 | return 0; |
| 1122 | #endif /* HAVE_IPV6 */ |
| 1123 | } |
| 1124 | |
| 1125 | /* If the attribute has originator-id and it is same as remote |
| 1126 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1127 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1128 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1129 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1130 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1131 | { |
| 1132 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1133 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1134 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1135 | rsclient->host, |
| 1136 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1137 | p->prefixlen); |
| 1138 | return 0; |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | /* ORF prefix-list filter check */ |
| 1143 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1144 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1145 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1146 | if (rsclient->orf_plist[afi][safi]) |
| 1147 | { |
| 1148 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1149 | return 0; |
| 1150 | } |
| 1151 | |
| 1152 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1153 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1154 | { |
| 1155 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1156 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1157 | "%s [Update:SEND] %s/%d is filtered", |
| 1158 | rsclient->host, |
| 1159 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1160 | p->prefixlen); |
| 1161 | return 0; |
| 1162 | } |
| 1163 | |
| 1164 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1165 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1166 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1167 | { |
| 1168 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1169 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1170 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1171 | rsclient->host, rsclient->as); |
| 1172 | return 0; |
| 1173 | } |
| 1174 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1175 | |
| 1176 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1177 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1178 | |
| 1179 | /* next-hop-set */ |
| 1180 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1181 | #ifdef HAVE_IPV6 |
| 1182 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1183 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1184 | #endif /* HAVE_IPV6 */ |
| 1185 | ) |
| 1186 | { |
| 1187 | /* Set IPv4 nexthop. */ |
| 1188 | if (p->family == AF_INET) |
| 1189 | { |
| 1190 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1191 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1192 | IPV4_MAX_BYTELEN); |
| 1193 | else |
| 1194 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1195 | } |
| 1196 | #ifdef HAVE_IPV6 |
| 1197 | /* Set IPv6 nexthop. */ |
| 1198 | if (p->family == AF_INET6) |
| 1199 | { |
| 1200 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1201 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1202 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1203 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1204 | } |
| 1205 | #endif /* HAVE_IPV6 */ |
| 1206 | } |
| 1207 | |
| 1208 | #ifdef HAVE_IPV6 |
| 1209 | if (p->family == AF_INET6) |
| 1210 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1211 | struct attr_extra *attre = attr->extra; |
| 1212 | |
| 1213 | assert (attr->extra); |
| 1214 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1215 | /* Left nexthop_local unchanged if so configured. */ |
| 1216 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1217 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1218 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1219 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1220 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1221 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1222 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | /* Default nexthop_local treatment for RS-Clients */ |
| 1226 | else |
| 1227 | { |
| 1228 | /* Announcer and RS-Client are both in the same network */ |
| 1229 | if (rsclient->shared_network && from->shared_network && |
| 1230 | (rsclient->ifindex == from->ifindex)) |
| 1231 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1232 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1233 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1234 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1235 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1236 | } |
| 1237 | |
| 1238 | /* Set link-local address for shared network peer. */ |
| 1239 | else if (rsclient->shared_network |
| 1240 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1241 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1242 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1243 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1244 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1245 | } |
| 1246 | |
| 1247 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1248 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | } |
| 1252 | #endif /* HAVE_IPV6 */ |
| 1253 | |
| 1254 | |
| 1255 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1256 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 1257 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1258 | && aspath_private_as_check (attr->aspath)) |
| 1259 | attr->aspath = aspath_empty_get (); |
| 1260 | |
| 1261 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1262 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1263 | { |
| 1264 | info.peer = rsclient; |
| 1265 | info.attr = attr; |
| 1266 | |
| 1267 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1268 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1269 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1270 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1271 | else |
| 1272 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1273 | |
| 1274 | rsclient->rmap_type = 0; |
| 1275 | |
| 1276 | if (ret == RMAP_DENYMATCH) |
| 1277 | { |
| 1278 | bgp_attr_flush (attr); |
| 1279 | return 0; |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | return 1; |
| 1284 | } |
| 1285 | |
| 1286 | struct bgp_info_pair |
| 1287 | { |
| 1288 | struct bgp_info *old; |
| 1289 | struct bgp_info *new; |
| 1290 | }; |
| 1291 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1292 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1293 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
| 1294 | struct bgp_maxpaths_cfg *mpath_cfg, |
| 1295 | struct bgp_info_pair *result) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1296 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1297 | struct bgp_info *new_select; |
| 1298 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1299 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1300 | struct bgp_info *ri1; |
| 1301 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1302 | struct bgp_info *nextri = NULL; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1303 | int paths_eq, do_mpath; |
| 1304 | struct list mp_list; |
| 1305 | |
| 1306 | bgp_mp_list_init (&mp_list); |
| 1307 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || |
| 1308 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); |
| 1309 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1310 | /* bgp deterministic-med */ |
| 1311 | new_select = NULL; |
| 1312 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1313 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1314 | { |
| 1315 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1316 | continue; |
| 1317 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1318 | continue; |
| 1319 | |
| 1320 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1321 | if (do_mpath) |
| 1322 | bgp_mp_list_add (&mp_list, ri1); |
| 1323 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1324 | if (ri1->next) |
| 1325 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1326 | { |
| 1327 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1328 | continue; |
| 1329 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1330 | continue; |
| 1331 | |
| 1332 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1333 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1334 | ri2->attr->aspath)) |
| 1335 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1336 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1337 | old_select = ri2; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1338 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1339 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1340 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1341 | new_select = ri2; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1342 | if (do_mpath && !paths_eq) |
| 1343 | { |
| 1344 | bgp_mp_list_clear (&mp_list); |
| 1345 | bgp_mp_list_add (&mp_list, ri2); |
| 1346 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1347 | } |
| 1348 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1349 | if (do_mpath && paths_eq) |
| 1350 | bgp_mp_list_add (&mp_list, ri2); |
| 1351 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1352 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1353 | } |
| 1354 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1355 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1356 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1357 | |
| 1358 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
| 1359 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1360 | } |
| 1361 | |
| 1362 | /* Check old selected route and new selected route. */ |
| 1363 | old_select = NULL; |
| 1364 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1365 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1366 | { |
| 1367 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1368 | old_select = ri; |
| 1369 | |
| 1370 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1371 | { |
| 1372 | /* reap REMOVED routes, if needs be |
| 1373 | * selected route must stay for a while longer though |
| 1374 | */ |
| 1375 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1376 | && (ri != old_select)) |
| 1377 | bgp_info_reap (rn, ri); |
| 1378 | |
| 1379 | continue; |
| 1380 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1381 | |
| 1382 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1383 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1384 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1385 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1386 | continue; |
| 1387 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1388 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1389 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1390 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1391 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
| 1392 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1393 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1394 | bgp_mp_dmed_deselect (new_select); |
| 1395 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1396 | new_select = ri; |
| 1397 | |
| 1398 | if (do_mpath && !paths_eq) |
| 1399 | { |
| 1400 | bgp_mp_list_clear (&mp_list); |
| 1401 | bgp_mp_list_add (&mp_list, ri); |
| 1402 | } |
| 1403 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1404 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1405 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1406 | |
| 1407 | if (do_mpath && paths_eq) |
| 1408 | bgp_mp_list_add (&mp_list, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1409 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1410 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1411 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1412 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1413 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1414 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1415 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1416 | bgp_mp_list_clear (&mp_list); |
| 1417 | |
| 1418 | result->old = old_select; |
| 1419 | result->new = new_select; |
| 1420 | |
| 1421 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1422 | } |
| 1423 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1424 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1425 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1426 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1427 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1428 | struct prefix *p; |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1429 | struct attr attr = { 0 }; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1430 | |
| 1431 | p = &rn->p; |
| 1432 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1433 | /* Announce route to Established peer. */ |
| 1434 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1435 | return 0; |
| 1436 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1437 | /* Address family configuration check. */ |
| 1438 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1439 | return 0; |
| 1440 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1441 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1442 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1443 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1444 | return 0; |
| 1445 | |
| 1446 | switch (rn->table->type) |
| 1447 | { |
| 1448 | case BGP_TABLE_MAIN: |
| 1449 | /* Announcement to peer->conf. If the route is filtered, |
| 1450 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1451 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1452 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1453 | else |
| 1454 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1455 | break; |
| 1456 | case BGP_TABLE_RSCLIENT: |
| 1457 | /* Announcement to peer->conf. If the route is filtered, |
| 1458 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1459 | if (selected && |
| 1460 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1461 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1462 | else |
| 1463 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1464 | break; |
| 1465 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1466 | |
| 1467 | bgp_attr_extra_free (&attr); |
| 1468 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1469 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1470 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1471 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1472 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1474 | struct bgp *bgp; |
| 1475 | struct bgp_node *rn; |
| 1476 | afi_t afi; |
| 1477 | safi_t safi; |
| 1478 | }; |
| 1479 | |
| 1480 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1481 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1482 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1483 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1484 | struct bgp *bgp = pq->bgp; |
| 1485 | struct bgp_node *rn = pq->rn; |
| 1486 | afi_t afi = pq->afi; |
| 1487 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1488 | struct bgp_info *new_select; |
| 1489 | struct bgp_info *old_select; |
| 1490 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1491 | struct listnode *node, *nnode; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1492 | struct peer *rsclient = rn->table->owner; |
| 1493 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1494 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1495 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1496 | new_select = old_and_new.new; |
| 1497 | old_select = old_and_new.old; |
| 1498 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1499 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1500 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1501 | if (rsclient->group) |
| 1502 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1503 | { |
| 1504 | /* Nothing to do. */ |
| 1505 | if (old_select && old_select == new_select) |
| 1506 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1507 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1508 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1509 | if (old_select) |
| 1510 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1511 | if (new_select) |
| 1512 | { |
| 1513 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1514 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1515 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1516 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1517 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1518 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1519 | afi, safi); |
| 1520 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1521 | } |
| 1522 | else |
| 1523 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1524 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1525 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1526 | if (new_select) |
| 1527 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1528 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1529 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1530 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1531 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1532 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1533 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1534 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1535 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1536 | bgp_info_reap (rn, old_select); |
| 1537 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1538 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1539 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1540 | } |
| 1541 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1542 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1543 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1544 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1545 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1546 | struct bgp *bgp = pq->bgp; |
| 1547 | struct bgp_node *rn = pq->rn; |
| 1548 | afi_t afi = pq->afi; |
| 1549 | safi_t safi = pq->safi; |
| 1550 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1551 | struct bgp_info *new_select; |
| 1552 | struct bgp_info *old_select; |
| 1553 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1554 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1555 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1556 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1557 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1558 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1559 | old_select = old_and_new.old; |
| 1560 | new_select = old_and_new.new; |
| 1561 | |
| 1562 | /* Nothing to do. */ |
| 1563 | if (old_select && old_select == new_select) |
| 1564 | { |
| 1565 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1566 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1567 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1568 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1569 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1570 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1571 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1572 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1573 | return WQ_SUCCESS; |
| 1574 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1575 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1576 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1577 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1578 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1579 | if (new_select) |
| 1580 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1581 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1582 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1583 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1584 | } |
| 1585 | |
| 1586 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1587 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1588 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1589 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1590 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1591 | } |
| 1592 | |
| 1593 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1594 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1595 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1596 | { |
| 1597 | if (new_select |
| 1598 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1599 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1600 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1601 | else |
| 1602 | { |
| 1603 | /* Withdraw the route from the kernel. */ |
| 1604 | if (old_select |
| 1605 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1606 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1607 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1608 | } |
| 1609 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1610 | |
| 1611 | /* Reap old select bgp_info, it it has been removed */ |
| 1612 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1613 | bgp_info_reap (rn, old_select); |
| 1614 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1615 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1616 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1617 | } |
| 1618 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1619 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1620 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1621 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1622 | struct bgp_process_queue *pq = data; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1623 | struct bgp_table *table = pq->rn->table; |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1624 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1625 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1626 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1627 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1628 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1629 | } |
| 1630 | |
| 1631 | static void |
| 1632 | bgp_process_queue_init (void) |
| 1633 | { |
| 1634 | bm->process_main_queue |
| 1635 | = work_queue_new (bm->master, "process_main_queue"); |
| 1636 | bm->process_rsclient_queue |
| 1637 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1638 | |
| 1639 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1640 | { |
| 1641 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1642 | exit (1); |
| 1643 | } |
| 1644 | |
| 1645 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1646 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1647 | bm->process_main_queue->spec.max_retries = 0; |
| 1648 | bm->process_main_queue->spec.hold = 50; |
| 1649 | |
| 1650 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, |
| 1651 | sizeof (struct work_queue *)); |
| 1652 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1653 | } |
| 1654 | |
| 1655 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1656 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1657 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1658 | struct bgp_process_queue *pqnode; |
| 1659 | |
| 1660 | /* already scheduled for processing? */ |
| 1661 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1662 | return; |
| 1663 | |
| 1664 | if ( (bm->process_main_queue == NULL) || |
| 1665 | (bm->process_rsclient_queue == NULL) ) |
| 1666 | bgp_process_queue_init (); |
| 1667 | |
| 1668 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1669 | sizeof (struct bgp_process_queue)); |
| 1670 | if (!pqnode) |
| 1671 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1672 | |
| 1673 | /* all unlocked in bgp_processq_del */ |
| 1674 | bgp_table_lock (rn->table); |
| 1675 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1676 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1677 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1678 | pqnode->afi = afi; |
| 1679 | pqnode->safi = safi; |
| 1680 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1681 | switch (rn->table->type) |
| 1682 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1683 | case BGP_TABLE_MAIN: |
| 1684 | work_queue_add (bm->process_main_queue, pqnode); |
| 1685 | break; |
| 1686 | case BGP_TABLE_RSCLIENT: |
| 1687 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1688 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1689 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1690 | |
| 1691 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1692 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1693 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1694 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1695 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1696 | { |
| 1697 | struct peer *peer; |
| 1698 | |
| 1699 | peer = THREAD_ARG (thread); |
| 1700 | peer->t_pmax_restart = NULL; |
| 1701 | |
| 1702 | if (BGP_DEBUG (events, EVENTS)) |
| 1703 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1704 | peer->host); |
| 1705 | |
| 1706 | peer_clear (peer); |
| 1707 | |
| 1708 | return 0; |
| 1709 | } |
| 1710 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1711 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1712 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1713 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1714 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1715 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1716 | return 0; |
| 1717 | |
| 1718 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1719 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1720 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1721 | && ! always) |
| 1722 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1723 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1724 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1725 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1726 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1727 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1728 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1729 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1730 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1731 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1732 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1733 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1734 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1735 | |
| 1736 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1737 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1738 | |
| 1739 | ndata[0] = (afi >> 8); |
| 1740 | ndata[1] = afi; |
| 1741 | ndata[2] = safi; |
| 1742 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1743 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1744 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1745 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1746 | |
| 1747 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1748 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1749 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1750 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1751 | |
| 1752 | /* restart timer start */ |
| 1753 | if (peer->pmax_restart[afi][safi]) |
| 1754 | { |
| 1755 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1756 | |
| 1757 | if (BGP_DEBUG (events, EVENTS)) |
| 1758 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1759 | peer->host, peer->v_pmax_restart); |
| 1760 | |
| 1761 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1762 | peer->v_pmax_restart); |
| 1763 | } |
| 1764 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1765 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1766 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1767 | else |
| 1768 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1769 | |
| 1770 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1771 | { |
| 1772 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1773 | && ! always) |
| 1774 | return 0; |
| 1775 | |
| 1776 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1777 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1778 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1779 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1780 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1781 | } |
| 1782 | else |
| 1783 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1784 | return 0; |
| 1785 | } |
| 1786 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1787 | /* Unconditionally remove the route from the RIB, without taking |
| 1788 | * damping into consideration (eg, because the session went down) |
| 1789 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1790 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1791 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1792 | afi_t afi, safi_t safi) |
| 1793 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1794 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1795 | |
| 1796 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1797 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1798 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1799 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1800 | } |
| 1801 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1802 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1803 | 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] | 1804 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1805 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1806 | int status = BGP_DAMP_NONE; |
| 1807 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1808 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1809 | * the bgp_info in the RIB for historical reference. |
| 1810 | */ |
| 1811 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1812 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1813 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1814 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1815 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1816 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1817 | return; |
| 1818 | } |
| 1819 | |
| 1820 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1821 | } |
| 1822 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1823 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1824 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1825 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1826 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1827 | { |
| 1828 | struct bgp_node *rn; |
| 1829 | struct bgp *bgp; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1830 | struct attr new_attr = { 0 }; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1831 | struct attr *attr_new; |
| 1832 | struct attr *attr_new2; |
| 1833 | struct bgp_info *ri; |
| 1834 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1835 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1836 | char buf[SU_ADDRSTRLEN]; |
| 1837 | |
| 1838 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1839 | if (peer == rsclient) |
| 1840 | return; |
| 1841 | |
| 1842 | bgp = peer->bgp; |
| 1843 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1844 | |
| 1845 | /* Check previously received route. */ |
| 1846 | for (ri = rn->info; ri; ri = ri->next) |
| 1847 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1848 | break; |
| 1849 | |
| 1850 | /* AS path loop check. */ |
| 1851 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1852 | { |
| 1853 | reason = "as-path contains our own AS;"; |
| 1854 | goto filtered; |
| 1855 | } |
| 1856 | |
| 1857 | /* Route reflector originator ID check. */ |
| 1858 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1859 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1860 | { |
| 1861 | reason = "originator is us;"; |
| 1862 | goto filtered; |
| 1863 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1864 | |
| 1865 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1866 | |
| 1867 | /* Apply export policy. */ |
| 1868 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1869 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1870 | { |
| 1871 | reason = "export-policy;"; |
| 1872 | goto filtered; |
| 1873 | } |
| 1874 | |
| 1875 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1876 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1877 | /* Apply import policy. */ |
| 1878 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1879 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1880 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1881 | |
| 1882 | reason = "import-policy;"; |
| 1883 | goto filtered; |
| 1884 | } |
| 1885 | |
| 1886 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1887 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1888 | |
| 1889 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1890 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1891 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1892 | /* Next hop must not be 0.0.0.0 nor Class D/E address. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1893 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1894 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1895 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1896 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1897 | |
| 1898 | reason = "martian next-hop;"; |
| 1899 | goto filtered; |
| 1900 | } |
| 1901 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1902 | |
| 1903 | /* new_attr isn't passed to any functions after here */ |
| 1904 | bgp_attr_extra_free (&new_attr); |
| 1905 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1906 | /* If the update is implicit withdraw. */ |
| 1907 | if (ri) |
| 1908 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1909 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1910 | |
| 1911 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1912 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1913 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1914 | { |
| 1915 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1916 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1917 | |
| 1918 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1919 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1920 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1921 | peer->host, |
| 1922 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1923 | p->prefixlen, rsclient->host); |
| 1924 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1925 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1926 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1927 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1928 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1929 | } |
| 1930 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1931 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1932 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1933 | bgp_info_restore (rn, ri); |
| 1934 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1935 | /* Received Logging. */ |
| 1936 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1937 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1938 | peer->host, |
| 1939 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1940 | p->prefixlen, rsclient->host); |
| 1941 | |
| 1942 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1943 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1944 | |
| 1945 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1946 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1947 | ri->attr = attr_new; |
| 1948 | |
| 1949 | /* Update MPLS tag. */ |
| 1950 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1951 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1952 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1953 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1954 | |
| 1955 | /* Process change. */ |
| 1956 | bgp_process (bgp, rn, afi, safi); |
| 1957 | bgp_unlock_node (rn); |
| 1958 | |
| 1959 | return; |
| 1960 | } |
| 1961 | |
| 1962 | /* Received Logging. */ |
| 1963 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1964 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1965 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1966 | peer->host, |
| 1967 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1968 | p->prefixlen, rsclient->host); |
| 1969 | } |
| 1970 | |
| 1971 | /* Make new BGP info. */ |
| 1972 | new = bgp_info_new (); |
| 1973 | new->type = type; |
| 1974 | new->sub_type = sub_type; |
| 1975 | new->peer = peer; |
| 1976 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1977 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1978 | |
| 1979 | /* Update MPLS tag. */ |
| 1980 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1981 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1982 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1983 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1984 | |
| 1985 | /* Register new BGP information. */ |
| 1986 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1987 | |
| 1988 | /* route_node_get lock */ |
| 1989 | bgp_unlock_node (rn); |
| 1990 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1991 | /* Process change. */ |
| 1992 | bgp_process (bgp, rn, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1993 | |
| 1994 | bgp_attr_extra_free (&new_attr); |
| 1995 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1996 | return; |
| 1997 | |
| 1998 | filtered: |
| 1999 | |
| 2000 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2001 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2002 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2003 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2004 | peer->host, |
| 2005 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2006 | p->prefixlen, rsclient->host, reason); |
| 2007 | |
| 2008 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2009 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2010 | |
| 2011 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2012 | |
| 2013 | if (new_attr.extra) |
| 2014 | bgp_attr_extra_free (&new_attr); |
| 2015 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2016 | return; |
| 2017 | } |
| 2018 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2019 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2020 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2021 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2022 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2023 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2024 | struct bgp_node *rn; |
| 2025 | struct bgp_info *ri; |
| 2026 | char buf[SU_ADDRSTRLEN]; |
| 2027 | |
| 2028 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2029 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2030 | |
| 2031 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2032 | |
| 2033 | /* Lookup withdrawn route. */ |
| 2034 | for (ri = rn->info; ri; ri = ri->next) |
| 2035 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2036 | break; |
| 2037 | |
| 2038 | /* Withdraw specified route from routing table. */ |
| 2039 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2040 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2041 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2042 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2043 | "%s Can't find the route %s/%d", peer->host, |
| 2044 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2045 | p->prefixlen); |
| 2046 | |
| 2047 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2048 | bgp_unlock_node (rn); |
| 2049 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2050 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2051 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2052 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2053 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2054 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2055 | { |
| 2056 | int ret; |
| 2057 | int aspath_loop_count = 0; |
| 2058 | struct bgp_node *rn; |
| 2059 | struct bgp *bgp; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2060 | struct attr new_attr = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2061 | struct attr *attr_new; |
| 2062 | struct bgp_info *ri; |
| 2063 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2064 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2065 | char buf[SU_ADDRSTRLEN]; |
| 2066 | |
| 2067 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2068 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2069 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2070 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2071 | Adj-RIBs-In. */ |
| 2072 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2073 | && peer != bgp->peer_self && ! soft_reconfig) |
| 2074 | bgp_adj_in_set (rn, peer, attr); |
| 2075 | |
| 2076 | /* Check previously received route. */ |
| 2077 | for (ri = rn->info; ri; ri = ri->next) |
| 2078 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2079 | break; |
| 2080 | |
| 2081 | /* AS path local-as loop check. */ |
| 2082 | if (peer->change_local_as) |
| 2083 | { |
| 2084 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2085 | aspath_loop_count = 1; |
| 2086 | |
| 2087 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2088 | { |
| 2089 | reason = "as-path contains our own AS;"; |
| 2090 | goto filtered; |
| 2091 | } |
| 2092 | } |
| 2093 | |
| 2094 | /* AS path loop check. */ |
| 2095 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2096 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2097 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2098 | > peer->allowas_in[afi][safi])) |
| 2099 | { |
| 2100 | reason = "as-path contains our own AS;"; |
| 2101 | goto filtered; |
| 2102 | } |
| 2103 | |
| 2104 | /* Route reflector originator ID check. */ |
| 2105 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2106 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2107 | { |
| 2108 | reason = "originator is us;"; |
| 2109 | goto filtered; |
| 2110 | } |
| 2111 | |
| 2112 | /* Route reflector cluster ID check. */ |
| 2113 | if (bgp_cluster_filter (peer, attr)) |
| 2114 | { |
| 2115 | reason = "reflected from the same cluster;"; |
| 2116 | goto filtered; |
| 2117 | } |
| 2118 | |
| 2119 | /* Apply incoming filter. */ |
| 2120 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2121 | { |
| 2122 | reason = "filter;"; |
| 2123 | goto filtered; |
| 2124 | } |
| 2125 | |
| 2126 | /* Apply incoming route-map. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2127 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | |
| 2129 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2130 | { |
| 2131 | reason = "route-map;"; |
| 2132 | goto filtered; |
| 2133 | } |
| 2134 | |
| 2135 | /* IPv4 unicast next hop check. */ |
| 2136 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2137 | { |
| 2138 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2139 | discard it. */ |
| 2140 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2141 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2142 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2143 | { |
| 2144 | reason = "non-connected next-hop;"; |
| 2145 | goto filtered; |
| 2146 | } |
| 2147 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2148 | /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2149 | must not be my own address. */ |
| 2150 | if (bgp_nexthop_self (afi, &new_attr) |
| 2151 | || new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2152 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2153 | { |
| 2154 | reason = "martian next-hop;"; |
| 2155 | goto filtered; |
| 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | attr_new = bgp_attr_intern (&new_attr); |
| 2160 | |
| 2161 | /* If the update is implicit withdraw. */ |
| 2162 | if (ri) |
| 2163 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2164 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2165 | |
| 2166 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2167 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2168 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2169 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2170 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2171 | |
| 2172 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2173 | && peer_sort (peer) == BGP_PEER_EBGP |
| 2174 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2175 | { |
| 2176 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2177 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2178 | peer->host, |
| 2179 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2180 | p->prefixlen); |
| 2181 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2182 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2183 | { |
| 2184 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2185 | bgp_process (bgp, rn, afi, safi); |
| 2186 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2187 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2188 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2189 | { |
| 2190 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2191 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2192 | "%s rcvd %s/%d...duplicate ignored", |
| 2193 | peer->host, |
| 2194 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2195 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2196 | |
| 2197 | /* graceful restart STALE flag unset. */ |
| 2198 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2199 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2200 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2201 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2202 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2203 | } |
| 2204 | |
| 2205 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2206 | bgp_attr_unintern (&attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2207 | bgp_attr_extra_free (&new_attr); |
| 2208 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2209 | return 0; |
| 2210 | } |
| 2211 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2212 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2213 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2214 | { |
| 2215 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2216 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2217 | peer->host, |
| 2218 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2219 | p->prefixlen); |
| 2220 | bgp_info_restore (rn, ri); |
| 2221 | } |
| 2222 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2223 | /* Received Logging. */ |
| 2224 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2225 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2226 | peer->host, |
| 2227 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2228 | p->prefixlen); |
| 2229 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2230 | /* graceful restart STALE flag unset. */ |
| 2231 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2232 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2233 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2234 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2235 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2236 | |
| 2237 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2238 | * only if update is accepted, they'll increment below. |
| 2239 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2240 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2241 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2242 | /* Update bgp route dampening information. */ |
| 2243 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2244 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2245 | { |
| 2246 | /* This is implicit withdraw so we should update dampening |
| 2247 | information. */ |
| 2248 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2249 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2250 | } |
| 2251 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2253 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | ri->attr = attr_new; |
| 2255 | |
| 2256 | /* Update MPLS tag. */ |
| 2257 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2258 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2259 | |
| 2260 | /* Update bgp route dampening information. */ |
| 2261 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2262 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2263 | { |
| 2264 | /* Now we do normal update dampening. */ |
| 2265 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2266 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2267 | { |
| 2268 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2269 | bgp_attr_extra_free (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2270 | return 0; |
| 2271 | } |
| 2272 | } |
| 2273 | |
| 2274 | /* Nexthop reachability check. */ |
| 2275 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2276 | && safi == SAFI_UNICAST |
| 2277 | && (peer_sort (peer) == BGP_PEER_IBGP |
Vasilis Tsiligiannis | 638b70b | 2009-07-20 01:25:16 +0300 | [diff] [blame] | 2278 | || peer_sort (peer) == BGP_PEER_CONFED |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2279 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2280 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2281 | { |
| 2282 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2283 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2284 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2285 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2286 | } |
| 2287 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2288 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2289 | |
| 2290 | /* Process change. */ |
| 2291 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2292 | |
| 2293 | bgp_process (bgp, rn, afi, safi); |
| 2294 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2295 | bgp_attr_extra_free (&new_attr); |
| 2296 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2297 | return 0; |
| 2298 | } |
| 2299 | |
| 2300 | /* Received Logging. */ |
| 2301 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2302 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2303 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2304 | peer->host, |
| 2305 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2306 | p->prefixlen); |
| 2307 | } |
| 2308 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2309 | /* Make new BGP info. */ |
| 2310 | new = bgp_info_new (); |
| 2311 | new->type = type; |
| 2312 | new->sub_type = sub_type; |
| 2313 | new->peer = peer; |
| 2314 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2315 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | |
| 2317 | /* Update MPLS tag. */ |
| 2318 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2319 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2320 | |
| 2321 | /* Nexthop reachability check. */ |
| 2322 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2323 | && safi == SAFI_UNICAST |
| 2324 | && (peer_sort (peer) == BGP_PEER_IBGP |
Vasilis Tsiligiannis | 638b70b | 2009-07-20 01:25:16 +0300 | [diff] [blame] | 2325 | || peer_sort (peer) == BGP_PEER_CONFED |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2326 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2327 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | { |
| 2329 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2330 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2331 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2332 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2333 | } |
| 2334 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2335 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2337 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2338 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2339 | |
| 2340 | /* Register new BGP information. */ |
| 2341 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2342 | |
| 2343 | /* route_node_get lock */ |
| 2344 | bgp_unlock_node (rn); |
| 2345 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2346 | bgp_attr_extra_free (&new_attr); |
| 2347 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2348 | /* If maximum prefix count is configured and current prefix |
| 2349 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2350 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2351 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2352 | |
| 2353 | /* Process change. */ |
| 2354 | bgp_process (bgp, rn, afi, safi); |
| 2355 | |
| 2356 | return 0; |
| 2357 | |
| 2358 | /* This BGP update is filtered. Log the reason then update BGP |
| 2359 | entry. */ |
| 2360 | filtered: |
| 2361 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2362 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2363 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2364 | peer->host, |
| 2365 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2366 | p->prefixlen, reason); |
| 2367 | |
| 2368 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2369 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2370 | |
| 2371 | bgp_unlock_node (rn); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2372 | |
| 2373 | bgp_attr_extra_free (&new_attr); |
| 2374 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2375 | return 0; |
| 2376 | } |
| 2377 | |
| 2378 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2379 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2380 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2381 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2382 | { |
| 2383 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2384 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2385 | struct bgp *bgp; |
| 2386 | int ret; |
| 2387 | |
| 2388 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2389 | soft_reconfig); |
| 2390 | |
| 2391 | bgp = peer->bgp; |
| 2392 | |
| 2393 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2394 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2395 | { |
| 2396 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2397 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2398 | sub_type, prd, tag); |
| 2399 | } |
| 2400 | |
| 2401 | return ret; |
| 2402 | } |
| 2403 | |
| 2404 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2405 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2406 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2407 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2408 | { |
| 2409 | struct bgp *bgp; |
| 2410 | char buf[SU_ADDRSTRLEN]; |
| 2411 | struct bgp_node *rn; |
| 2412 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2413 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2414 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2415 | |
| 2416 | bgp = peer->bgp; |
| 2417 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2418 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2419 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2420 | { |
| 2421 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2422 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2423 | } |
| 2424 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2425 | /* Logging. */ |
| 2426 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2427 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2428 | peer->host, |
| 2429 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2430 | p->prefixlen); |
| 2431 | |
| 2432 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2433 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2434 | |
| 2435 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2436 | further calculation. */ |
| 2437 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2438 | && peer != bgp->peer_self) |
| 2439 | bgp_adj_in_unset (rn, peer); |
| 2440 | |
| 2441 | /* Lookup withdrawn route. */ |
| 2442 | for (ri = rn->info; ri; ri = ri->next) |
| 2443 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2444 | break; |
| 2445 | |
| 2446 | /* Withdraw specified route from routing table. */ |
| 2447 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2448 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2449 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2450 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2451 | "%s Can't find the route %s/%d", peer->host, |
| 2452 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2453 | p->prefixlen); |
| 2454 | |
| 2455 | /* Unlock bgp_node_get() lock. */ |
| 2456 | bgp_unlock_node (rn); |
| 2457 | |
| 2458 | return 0; |
| 2459 | } |
| 2460 | |
| 2461 | void |
| 2462 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2463 | { |
| 2464 | struct bgp *bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2465 | struct attr attr = { 0 }; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2466 | struct aspath *aspath = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2467 | struct prefix p; |
| 2468 | struct bgp_info binfo; |
| 2469 | struct peer *from; |
| 2470 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2471 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2472 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2473 | return; |
| 2474 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2475 | bgp = peer->bgp; |
| 2476 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2477 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2479 | aspath = attr.aspath; |
| 2480 | attr.local_pref = bgp->default_local_pref; |
| 2481 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2482 | |
| 2483 | if (afi == AFI_IP) |
| 2484 | str2prefix ("0.0.0.0/0", &p); |
| 2485 | #ifdef HAVE_IPV6 |
| 2486 | else if (afi == AFI_IP6) |
| 2487 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2488 | struct attr_extra *ae; |
| 2489 | attr.extra = NULL; |
| 2490 | |
| 2491 | ae = bgp_attr_extra_get (&attr); |
| 2492 | attr.extra = ae; |
| 2493 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2494 | str2prefix ("::/0", &p); |
| 2495 | |
| 2496 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2497 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2498 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2499 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2500 | |
| 2501 | /* If the peer is on shared nextwork and we have link-local |
| 2502 | nexthop set it. */ |
| 2503 | if (peer->shared_network |
| 2504 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2505 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2506 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2507 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2508 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2509 | } |
| 2510 | } |
| 2511 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2512 | |
| 2513 | if (peer->default_rmap[afi][safi].name) |
| 2514 | { |
| 2515 | binfo.peer = bgp->peer_self; |
| 2516 | binfo.attr = &attr; |
| 2517 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2518 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2520 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2521 | RMAP_BGP, &binfo); |
| 2522 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2523 | bgp->peer_self->rmap_type = 0; |
| 2524 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2525 | if (ret == RMAP_DENYMATCH) |
| 2526 | { |
| 2527 | bgp_attr_flush (&attr); |
| 2528 | withdraw = 1; |
| 2529 | } |
| 2530 | } |
| 2531 | |
| 2532 | if (withdraw) |
| 2533 | { |
| 2534 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2535 | bgp_default_withdraw_send (peer, afi, safi); |
| 2536 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2537 | } |
| 2538 | else |
| 2539 | { |
| 2540 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2541 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2542 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2543 | |
| 2544 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2545 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2546 | } |
| 2547 | |
| 2548 | static void |
| 2549 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2550 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2551 | { |
| 2552 | struct bgp_node *rn; |
| 2553 | struct bgp_info *ri; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2554 | struct attr attr = { 0 }; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2555 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2556 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2557 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2558 | |
| 2559 | if (safi != SAFI_MPLS_VPN |
| 2560 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2561 | bgp_default_originate (peer, afi, safi, 0); |
| 2562 | |
| 2563 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2564 | for (ri = rn->info; ri; ri = ri->next) |
| 2565 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2566 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2567 | if ( (rsclient) ? |
| 2568 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2569 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2570 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2571 | else |
| 2572 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2573 | |
| 2574 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2575 | } |
| 2576 | } |
| 2577 | |
| 2578 | void |
| 2579 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2580 | { |
| 2581 | struct bgp_node *rn; |
| 2582 | struct bgp_table *table; |
| 2583 | |
| 2584 | if (peer->status != Established) |
| 2585 | return; |
| 2586 | |
| 2587 | if (! peer->afc_nego[afi][safi]) |
| 2588 | return; |
| 2589 | |
| 2590 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2591 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2592 | return; |
| 2593 | |
| 2594 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2595 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2596 | else |
| 2597 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2598 | rn = bgp_route_next(rn)) |
| 2599 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2600 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2601 | |
| 2602 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2603 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2604 | } |
| 2605 | |
| 2606 | void |
| 2607 | bgp_announce_route_all (struct peer *peer) |
| 2608 | { |
| 2609 | afi_t afi; |
| 2610 | safi_t safi; |
| 2611 | |
| 2612 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2613 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2614 | bgp_announce_route (peer, afi, safi); |
| 2615 | } |
| 2616 | |
| 2617 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2618 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
| 2619 | safi_t safi, struct bgp_table *table) |
| 2620 | { |
| 2621 | struct bgp_node *rn; |
| 2622 | struct bgp_adj_in *ain; |
| 2623 | |
| 2624 | if (! table) |
| 2625 | table = rsclient->bgp->rib[afi][safi]; |
| 2626 | |
| 2627 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2628 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2629 | { |
| 2630 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
| 2631 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2632 | } |
| 2633 | } |
| 2634 | |
| 2635 | void |
| 2636 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2637 | { |
| 2638 | struct bgp_table *table; |
| 2639 | struct bgp_node *rn; |
| 2640 | |
| 2641 | if (safi != SAFI_MPLS_VPN) |
| 2642 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); |
| 2643 | |
| 2644 | else |
| 2645 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2646 | rn = bgp_route_next (rn)) |
| 2647 | if ((table = rn->info) != NULL) |
| 2648 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); |
| 2649 | } |
| 2650 | |
| 2651 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2652 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 2653 | struct bgp_table *table) |
| 2654 | { |
| 2655 | int ret; |
| 2656 | struct bgp_node *rn; |
| 2657 | struct bgp_adj_in *ain; |
| 2658 | |
| 2659 | if (! table) |
| 2660 | table = peer->bgp->rib[afi][safi]; |
| 2661 | |
| 2662 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2663 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2664 | { |
| 2665 | if (ain->peer == peer) |
| 2666 | { |
| 2667 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2668 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 2669 | NULL, NULL, 1); |
| 2670 | if (ret < 0) |
| 2671 | { |
| 2672 | bgp_unlock_node (rn); |
| 2673 | return; |
| 2674 | } |
| 2675 | continue; |
| 2676 | } |
| 2677 | } |
| 2678 | } |
| 2679 | |
| 2680 | void |
| 2681 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2682 | { |
| 2683 | struct bgp_node *rn; |
| 2684 | struct bgp_table *table; |
| 2685 | |
| 2686 | if (peer->status != Established) |
| 2687 | return; |
| 2688 | |
| 2689 | if (safi != SAFI_MPLS_VPN) |
| 2690 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 2691 | else |
| 2692 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2693 | rn = bgp_route_next (rn)) |
| 2694 | if ((table = rn->info) != NULL) |
| 2695 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 2696 | } |
| 2697 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2698 | |
| 2699 | struct bgp_clear_node_queue |
| 2700 | { |
| 2701 | struct bgp_node *rn; |
| 2702 | enum bgp_clear_route_type purpose; |
| 2703 | }; |
| 2704 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2705 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2706 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2707 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2708 | struct bgp_clear_node_queue *cnq = data; |
| 2709 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2710 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2711 | struct bgp_info *ri; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2712 | afi_t afi = rn->table->afi; |
| 2713 | safi_t safi = rn->table->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2714 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2715 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2716 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2717 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2718 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2719 | { |
| 2720 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2721 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2722 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2723 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2724 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2725 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2726 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2727 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2728 | break; |
| 2729 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2730 | return WQ_SUCCESS; |
| 2731 | } |
| 2732 | |
| 2733 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2734 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2735 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2736 | struct bgp_clear_node_queue *cnq = data; |
| 2737 | struct bgp_node *rn = cnq->rn; |
| 2738 | struct bgp_table *table = rn->table; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2739 | |
| 2740 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2741 | bgp_table_unlock (table); |
| 2742 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2743 | } |
| 2744 | |
| 2745 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2746 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2747 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2748 | struct peer *peer = wq->spec.data; |
| 2749 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2750 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2751 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2752 | |
| 2753 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2754 | } |
| 2755 | |
| 2756 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2757 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2758 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2759 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2760 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2761 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2762 | #undef CLEAR_QUEUE_NAME_LEN |
| 2763 | |
| 2764 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2765 | { |
| 2766 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2767 | exit (1); |
| 2768 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2769 | peer->clear_node_queue->spec.hold = 10; |
| 2770 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2771 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2772 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2773 | peer->clear_node_queue->spec.max_retries = 0; |
| 2774 | |
| 2775 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2776 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2777 | } |
| 2778 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2779 | static void |
| 2780 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2781 | struct bgp_table *table, struct peer *rsclient, |
| 2782 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2783 | { |
| 2784 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2785 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2786 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2787 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2788 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2789 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2790 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2791 | if (! table) |
| 2792 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2793 | |
| 2794 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2795 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2796 | struct bgp_info *ri; |
| 2797 | struct bgp_adj_in *ain; |
| 2798 | struct bgp_adj_out *aout; |
| 2799 | |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2800 | if (rn->info == NULL) |
| 2801 | continue; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2802 | |
| 2803 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2804 | * queued for every clearing peer, regardless of whether it is |
| 2805 | * relevant to the peer at hand. |
| 2806 | * |
| 2807 | * Overview: There are 3 different indices which need to be |
| 2808 | * scrubbed, potentially, when a peer is removed: |
| 2809 | * |
| 2810 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2811 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2812 | * 3 other routes visible by the peer's adj-out index |
| 2813 | * |
| 2814 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2815 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2816 | * adj-outs at our leisure. |
| 2817 | * |
| 2818 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2819 | * invisible via RIB index before peer session is allowed to be |
| 2820 | * brought back up. So one needs to know when such a 'search' is |
| 2821 | * complete. |
| 2822 | * |
| 2823 | * Ideally: |
| 2824 | * |
| 2825 | * - there'd be a single global queue or a single RIB walker |
| 2826 | * - rather than tracking which route_nodes still need to be |
| 2827 | * examined on a peer basis, we'd track which peers still |
| 2828 | * aren't cleared |
| 2829 | * |
| 2830 | * Given that our per-peer prefix-counts now should be reliable, |
| 2831 | * this may actually be achievable. It doesn't seem to be a huge |
| 2832 | * problem at this time, |
| 2833 | */ |
| 2834 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2835 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2836 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2837 | struct bgp_clear_node_queue *cnq; |
| 2838 | |
| 2839 | /* both unlocked in bgp_clear_node_queue_del */ |
| 2840 | bgp_table_lock (rn->table); |
| 2841 | bgp_lock_node (rn); |
| 2842 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2843 | sizeof (struct bgp_clear_node_queue)); |
| 2844 | cnq->rn = rn; |
| 2845 | cnq->purpose = purpose; |
| 2846 | work_queue_add (peer->clear_node_queue, cnq); |
| 2847 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2848 | } |
| 2849 | |
| 2850 | for (ain = rn->adj_in; ain; ain = ain->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2851 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2852 | { |
| 2853 | bgp_adj_in_remove (rn, ain); |
| 2854 | bgp_unlock_node (rn); |
| 2855 | break; |
| 2856 | } |
| 2857 | for (aout = rn->adj_out; aout; aout = aout->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2858 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2859 | { |
| 2860 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2861 | bgp_unlock_node (rn); |
| 2862 | break; |
| 2863 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2864 | } |
| 2865 | return; |
| 2866 | } |
| 2867 | |
| 2868 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2869 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2870 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2871 | { |
| 2872 | struct bgp_node *rn; |
| 2873 | struct bgp_table *table; |
| 2874 | struct peer *rsclient; |
| 2875 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2876 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2877 | if (peer->clear_node_queue == NULL) |
| 2878 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2879 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2880 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2881 | * Idle until it receives a Clearing_Completed event. This protects |
| 2882 | * against peers which flap faster than we can we clear, which could |
| 2883 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2884 | * |
| 2885 | * a) race with routes from the new session being installed before |
| 2886 | * clear_route_node visits the node (to delete the route of that |
| 2887 | * peer) |
| 2888 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2889 | * on the process_main queue. Fast-flapping could cause that queue |
| 2890 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2891 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2892 | if (!peer->clear_node_queue->thread) |
| 2893 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2894 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2895 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2896 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2897 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2898 | if (safi != SAFI_MPLS_VPN) |
| 2899 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 2900 | else |
| 2901 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2902 | rn = bgp_route_next (rn)) |
| 2903 | if ((table = rn->info) != NULL) |
| 2904 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 2905 | |
| 2906 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 2907 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 2908 | PEER_FLAG_RSERVER_CLIENT)) |
| 2909 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 2910 | break; |
| 2911 | |
| 2912 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 2913 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 2914 | break; |
| 2915 | |
| 2916 | default: |
| 2917 | assert (0); |
| 2918 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2919 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2920 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2921 | /* If no routes were cleared, nothing was added to workqueue, the |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2922 | * completion function won't be run by workqueue code - call it here. |
| 2923 | * XXX: Actually, this assumption doesn't hold, see |
| 2924 | * bgp_clear_route_table(), we queue all non-empty nodes. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2925 | * |
| 2926 | * Additionally, there is a presumption in FSM that clearing is only |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2927 | * really needed if peer state is Established - peers in |
| 2928 | * pre-Established states shouldn't have any route-update state |
| 2929 | * associated with them (in or out). |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2930 | * |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2931 | * We still can get here in pre-Established though, through |
| 2932 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity |
| 2933 | * check to ensure the assumption above holds. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2934 | * |
| 2935 | * At some future point, this check could be move to the top of the |
| 2936 | * function, and do a quick early-return when state is |
| 2937 | * pre-Established, avoiding above list and table scans. Once we're |
| 2938 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2939 | */ |
| 2940 | if (!peer->clear_node_queue->thread) |
| 2941 | bgp_clear_node_complete (peer->clear_node_queue); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2942 | } |
| 2943 | |
| 2944 | void |
| 2945 | bgp_clear_route_all (struct peer *peer) |
| 2946 | { |
| 2947 | afi_t afi; |
| 2948 | safi_t safi; |
| 2949 | |
| 2950 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2951 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2952 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2953 | } |
| 2954 | |
| 2955 | void |
| 2956 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2957 | { |
| 2958 | struct bgp_table *table; |
| 2959 | struct bgp_node *rn; |
| 2960 | struct bgp_adj_in *ain; |
| 2961 | |
| 2962 | table = peer->bgp->rib[afi][safi]; |
| 2963 | |
| 2964 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2965 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2966 | if (ain->peer == peer) |
| 2967 | { |
| 2968 | bgp_adj_in_remove (rn, ain); |
| 2969 | bgp_unlock_node (rn); |
| 2970 | break; |
| 2971 | } |
| 2972 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2973 | |
| 2974 | void |
| 2975 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2976 | { |
| 2977 | struct bgp_node *rn; |
| 2978 | struct bgp_info *ri; |
| 2979 | struct bgp_table *table; |
| 2980 | |
| 2981 | table = peer->bgp->rib[afi][safi]; |
| 2982 | |
| 2983 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2984 | { |
| 2985 | for (ri = rn->info; ri; ri = ri->next) |
| 2986 | if (ri->peer == peer) |
| 2987 | { |
| 2988 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2989 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 2990 | break; |
| 2991 | } |
| 2992 | } |
| 2993 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2994 | |
| 2995 | /* Delete all kernel routes. */ |
| 2996 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 2997 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2998 | { |
| 2999 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3000 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3001 | struct bgp_node *rn; |
| 3002 | struct bgp_table *table; |
| 3003 | struct bgp_info *ri; |
| 3004 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3005 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3006 | { |
| 3007 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3008 | |
| 3009 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3010 | for (ri = rn->info; ri; ri = ri->next) |
| 3011 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3012 | && ri->type == ZEBRA_ROUTE_BGP |
| 3013 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3014 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3015 | |
| 3016 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3017 | |
| 3018 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3019 | for (ri = rn->info; ri; ri = ri->next) |
| 3020 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3021 | && ri->type == ZEBRA_ROUTE_BGP |
| 3022 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3023 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3024 | } |
| 3025 | } |
| 3026 | |
| 3027 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3028 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3029 | { |
| 3030 | vty_reset (); |
| 3031 | bgp_zclient_reset (); |
| 3032 | access_list_reset (); |
| 3033 | prefix_list_reset (); |
| 3034 | } |
| 3035 | |
| 3036 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3037 | value. */ |
| 3038 | int |
| 3039 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3040 | { |
| 3041 | u_char *pnt; |
| 3042 | u_char *lim; |
| 3043 | struct prefix p; |
| 3044 | int psize; |
| 3045 | int ret; |
| 3046 | |
| 3047 | /* Check peer status. */ |
| 3048 | if (peer->status != Established) |
| 3049 | return 0; |
| 3050 | |
| 3051 | pnt = packet->nlri; |
| 3052 | lim = pnt + packet->length; |
| 3053 | |
| 3054 | for (; pnt < lim; pnt += psize) |
| 3055 | { |
| 3056 | /* Clear prefix structure. */ |
| 3057 | memset (&p, 0, sizeof (struct prefix)); |
| 3058 | |
| 3059 | /* Fetch prefix length. */ |
| 3060 | p.prefixlen = *pnt++; |
| 3061 | p.family = afi2family (packet->afi); |
| 3062 | |
| 3063 | /* Already checked in nlri_sanity_check(). We do double check |
| 3064 | here. */ |
| 3065 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3066 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3067 | return -1; |
| 3068 | |
| 3069 | /* Packet size overflow check. */ |
| 3070 | psize = PSIZE (p.prefixlen); |
| 3071 | |
| 3072 | /* When packet overflow occur return immediately. */ |
| 3073 | if (pnt + psize > lim) |
| 3074 | return -1; |
| 3075 | |
| 3076 | /* Fetch prefix from NLRI packet. */ |
| 3077 | memcpy (&p.u.prefix, pnt, psize); |
| 3078 | |
| 3079 | /* Check address. */ |
| 3080 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3081 | { |
| 3082 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3083 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3084 | /* |
| 3085 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3086 | * If a BGP router receives an UPDATE message with a |
| 3087 | * semantically incorrect NLRI field, in which a prefix is |
| 3088 | * semantically incorrect (eg. an unexpected multicast IP |
| 3089 | * address), it should ignore the prefix. |
| 3090 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3091 | zlog (peer->log, LOG_ERR, |
| 3092 | "IPv4 unicast NLRI is multicast address %s", |
| 3093 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3094 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3095 | return -1; |
| 3096 | } |
| 3097 | } |
| 3098 | |
| 3099 | #ifdef HAVE_IPV6 |
| 3100 | /* Check address. */ |
| 3101 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3102 | { |
| 3103 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3104 | { |
| 3105 | char buf[BUFSIZ]; |
| 3106 | |
| 3107 | zlog (peer->log, LOG_WARNING, |
| 3108 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3109 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3110 | |
| 3111 | continue; |
| 3112 | } |
| 3113 | } |
| 3114 | #endif /* HAVE_IPV6 */ |
| 3115 | |
| 3116 | /* Normal process. */ |
| 3117 | if (attr) |
| 3118 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3119 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3120 | else |
| 3121 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3122 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3123 | |
| 3124 | /* Address family configuration mismatch or maximum-prefix count |
| 3125 | overflow. */ |
| 3126 | if (ret < 0) |
| 3127 | return -1; |
| 3128 | } |
| 3129 | |
| 3130 | /* Packet length consistency check. */ |
| 3131 | if (pnt != lim) |
| 3132 | return -1; |
| 3133 | |
| 3134 | return 0; |
| 3135 | } |
| 3136 | |
| 3137 | /* NLRI encode syntax check routine. */ |
| 3138 | int |
| 3139 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3140 | bgp_size_t length) |
| 3141 | { |
| 3142 | u_char *end; |
| 3143 | u_char prefixlen; |
| 3144 | int psize; |
| 3145 | |
| 3146 | end = pnt + length; |
| 3147 | |
| 3148 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3149 | syntactic validity. If the field is syntactically incorrect, |
| 3150 | then the Error Subcode is set to Invalid Network Field. */ |
| 3151 | |
| 3152 | while (pnt < end) |
| 3153 | { |
| 3154 | prefixlen = *pnt++; |
| 3155 | |
| 3156 | /* Prefix length check. */ |
| 3157 | if ((afi == AFI_IP && prefixlen > 32) |
| 3158 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3159 | { |
| 3160 | plog_err (peer->log, |
| 3161 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3162 | peer->host, prefixlen); |
| 3163 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3164 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3165 | return -1; |
| 3166 | } |
| 3167 | |
| 3168 | /* Packet size overflow check. */ |
| 3169 | psize = PSIZE (prefixlen); |
| 3170 | |
| 3171 | if (pnt + psize > end) |
| 3172 | { |
| 3173 | plog_err (peer->log, |
| 3174 | "%s [Error] Update packet error" |
| 3175 | " (prefix data overflow prefix size is %d)", |
| 3176 | peer->host, psize); |
| 3177 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3178 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3179 | return -1; |
| 3180 | } |
| 3181 | |
| 3182 | pnt += psize; |
| 3183 | } |
| 3184 | |
| 3185 | /* Packet length consistency check. */ |
| 3186 | if (pnt != end) |
| 3187 | { |
| 3188 | plog_err (peer->log, |
| 3189 | "%s [Error] Update packet error" |
| 3190 | " (prefix length mismatch with total length)", |
| 3191 | peer->host); |
| 3192 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3193 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3194 | return -1; |
| 3195 | } |
| 3196 | return 0; |
| 3197 | } |
| 3198 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3199 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3200 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3201 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3202 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3203 | } |
| 3204 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3205 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3206 | bgp_static_free (struct bgp_static *bgp_static) |
| 3207 | { |
| 3208 | if (bgp_static->rmap.name) |
| 3209 | free (bgp_static->rmap.name); |
| 3210 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3211 | } |
| 3212 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3213 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3214 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3215 | struct prefix *p, afi_t afi, safi_t safi) |
| 3216 | { |
| 3217 | struct bgp_node *rn; |
| 3218 | struct bgp_info *ri; |
| 3219 | |
| 3220 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3221 | |
| 3222 | /* Check selected route and self inserted route. */ |
| 3223 | for (ri = rn->info; ri; ri = ri->next) |
| 3224 | if (ri->peer == bgp->peer_self |
| 3225 | && ri->type == ZEBRA_ROUTE_BGP |
| 3226 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3227 | break; |
| 3228 | |
| 3229 | /* Withdraw static BGP route from routing table. */ |
| 3230 | if (ri) |
| 3231 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3232 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3233 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3234 | } |
| 3235 | |
| 3236 | /* Unlock bgp_node_lookup. */ |
| 3237 | bgp_unlock_node (rn); |
| 3238 | } |
| 3239 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3240 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3241 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3242 | struct bgp_static *bgp_static, |
| 3243 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3244 | { |
| 3245 | struct bgp_node *rn; |
| 3246 | struct bgp_info *ri; |
| 3247 | struct bgp_info *new; |
| 3248 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3249 | struct attr *attr_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3250 | struct attr attr = {0 }; |
| 3251 | struct attr new_attr = { .extra = 0 }; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3252 | struct bgp *bgp; |
| 3253 | int ret; |
| 3254 | char buf[SU_ADDRSTRLEN]; |
| 3255 | |
| 3256 | bgp = rsclient->bgp; |
| 3257 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3258 | assert (bgp_static); |
| 3259 | if (!bgp_static) |
| 3260 | return; |
| 3261 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3262 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3263 | |
| 3264 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3265 | |
| 3266 | attr.nexthop = bgp_static->igpnexthop; |
| 3267 | attr.med = bgp_static->igpmetric; |
| 3268 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3269 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3270 | if (bgp_static->atomic) |
| 3271 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3272 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3273 | /* Apply network route-map for export to this rsclient. */ |
| 3274 | if (bgp_static->rmap.name) |
| 3275 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3276 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3277 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3278 | info.attr = &attr_tmp; |
| 3279 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3280 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3281 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3282 | |
| 3283 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3284 | |
| 3285 | rsclient->rmap_type = 0; |
| 3286 | |
| 3287 | if (ret == RMAP_DENYMATCH) |
| 3288 | { |
| 3289 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3290 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3291 | |
| 3292 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3293 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3294 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3295 | bgp_attr_extra_free (&attr); |
| 3296 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3297 | return; |
| 3298 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3299 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3300 | } |
| 3301 | else |
| 3302 | attr_new = bgp_attr_intern (&attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3303 | |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3304 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3305 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3306 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3307 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3308 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3309 | == RMAP_DENY) |
| 3310 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3311 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3312 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3313 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3314 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3315 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3316 | p->prefixlen, rsclient->host); |
| 3317 | |
| 3318 | bgp->peer_self->rmap_type = 0; |
| 3319 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3320 | bgp_attr_unintern (&attr_new); |
| 3321 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3322 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3323 | |
| 3324 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3325 | |
| 3326 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3327 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3328 | |
| 3329 | bgp->peer_self->rmap_type = 0; |
| 3330 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3331 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3332 | attr_new = bgp_attr_intern (&new_attr); |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3333 | bgp_attr_extra_free (&new_attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3334 | |
| 3335 | for (ri = rn->info; ri; ri = ri->next) |
| 3336 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3337 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3338 | break; |
| 3339 | |
| 3340 | if (ri) |
| 3341 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3342 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3343 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3344 | { |
| 3345 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3346 | bgp_attr_unintern (&attr_new); |
| 3347 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3348 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3349 | return; |
| 3350 | } |
| 3351 | else |
| 3352 | { |
| 3353 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3354 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3355 | |
| 3356 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3357 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3358 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3359 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3360 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3361 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3362 | |
| 3363 | /* Process change. */ |
| 3364 | bgp_process (bgp, rn, afi, safi); |
| 3365 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3366 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3367 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3368 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3369 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3370 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3371 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3372 | /* Make new BGP info. */ |
| 3373 | new = bgp_info_new (); |
| 3374 | new->type = ZEBRA_ROUTE_BGP; |
| 3375 | new->sub_type = BGP_ROUTE_STATIC; |
| 3376 | new->peer = bgp->peer_self; |
| 3377 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3378 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3379 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3380 | |
| 3381 | /* Register new BGP information. */ |
| 3382 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3383 | |
| 3384 | /* route_node_get lock */ |
| 3385 | bgp_unlock_node (rn); |
| 3386 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3387 | /* Process change. */ |
| 3388 | bgp_process (bgp, rn, afi, safi); |
| 3389 | |
| 3390 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3391 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3392 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3393 | } |
| 3394 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3395 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3396 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3397 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3398 | { |
| 3399 | struct bgp_node *rn; |
| 3400 | struct bgp_info *ri; |
| 3401 | struct bgp_info *new; |
| 3402 | struct bgp_info info; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3403 | struct attr attr = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3404 | struct attr *attr_new; |
| 3405 | int ret; |
| 3406 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3407 | assert (bgp_static); |
| 3408 | if (!bgp_static) |
| 3409 | return; |
| 3410 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3411 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3412 | |
| 3413 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3414 | |
| 3415 | attr.nexthop = bgp_static->igpnexthop; |
| 3416 | attr.med = bgp_static->igpmetric; |
| 3417 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3418 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3419 | if (bgp_static->atomic) |
| 3420 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3421 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3422 | /* Apply route-map. */ |
| 3423 | if (bgp_static->rmap.name) |
| 3424 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3425 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3426 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3427 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3428 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3429 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3430 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3431 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3432 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3433 | bgp->peer_self->rmap_type = 0; |
| 3434 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3435 | if (ret == RMAP_DENYMATCH) |
| 3436 | { |
| 3437 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3438 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3439 | |
| 3440 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3441 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3442 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3443 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3444 | return; |
| 3445 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3446 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3447 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3448 | else |
| 3449 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3450 | |
| 3451 | for (ri = rn->info; ri; ri = ri->next) |
| 3452 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3453 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3454 | break; |
| 3455 | |
| 3456 | if (ri) |
| 3457 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3458 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3459 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3460 | { |
| 3461 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3462 | bgp_attr_unintern (&attr_new); |
| 3463 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3464 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3465 | return; |
| 3466 | } |
| 3467 | else |
| 3468 | { |
| 3469 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3470 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3471 | |
| 3472 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3473 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3474 | bgp_info_restore(rn, ri); |
| 3475 | else |
| 3476 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3477 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3478 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3479 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3480 | |
| 3481 | /* Process change. */ |
| 3482 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3483 | bgp_process (bgp, rn, afi, safi); |
| 3484 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3485 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3486 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3487 | return; |
| 3488 | } |
| 3489 | } |
| 3490 | |
| 3491 | /* Make new BGP info. */ |
| 3492 | new = bgp_info_new (); |
| 3493 | new->type = ZEBRA_ROUTE_BGP; |
| 3494 | new->sub_type = BGP_ROUTE_STATIC; |
| 3495 | new->peer = bgp->peer_self; |
| 3496 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3497 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3498 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3499 | |
| 3500 | /* Aggregate address increment. */ |
| 3501 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3502 | |
| 3503 | /* Register new BGP information. */ |
| 3504 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3505 | |
| 3506 | /* route_node_get lock */ |
| 3507 | bgp_unlock_node (rn); |
| 3508 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3509 | /* Process change. */ |
| 3510 | bgp_process (bgp, rn, afi, safi); |
| 3511 | |
| 3512 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3513 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3514 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3515 | } |
| 3516 | |
| 3517 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3518 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3519 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3520 | { |
| 3521 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3522 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3523 | |
| 3524 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3525 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3526 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3527 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3528 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3529 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3530 | } |
| 3531 | } |
| 3532 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3533 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3534 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3535 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3536 | { |
| 3537 | struct bgp_node *rn; |
| 3538 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3539 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3540 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3541 | |
| 3542 | /* Make new BGP info. */ |
| 3543 | new = bgp_info_new (); |
| 3544 | new->type = ZEBRA_ROUTE_BGP; |
| 3545 | new->sub_type = BGP_ROUTE_STATIC; |
| 3546 | new->peer = bgp->peer_self; |
| 3547 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3548 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3549 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3550 | new->extra = bgp_info_extra_new(); |
| 3551 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3552 | |
| 3553 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3554 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3555 | |
| 3556 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3557 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3558 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3559 | /* route_node_get lock */ |
| 3560 | bgp_unlock_node (rn); |
| 3561 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3562 | /* Process change. */ |
| 3563 | bgp_process (bgp, rn, afi, safi); |
| 3564 | } |
| 3565 | |
| 3566 | void |
| 3567 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3568 | safi_t safi) |
| 3569 | { |
| 3570 | struct bgp_node *rn; |
| 3571 | struct bgp_info *ri; |
| 3572 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3573 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3574 | |
| 3575 | /* Check selected route and self inserted route. */ |
| 3576 | for (ri = rn->info; ri; ri = ri->next) |
| 3577 | if (ri->peer == bgp->peer_self |
| 3578 | && ri->type == ZEBRA_ROUTE_BGP |
| 3579 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3580 | break; |
| 3581 | |
| 3582 | /* Withdraw static BGP route from routing table. */ |
| 3583 | if (ri) |
| 3584 | { |
| 3585 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3586 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3587 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3588 | } |
| 3589 | |
| 3590 | /* Unlock bgp_node_lookup. */ |
| 3591 | bgp_unlock_node (rn); |
| 3592 | } |
| 3593 | |
| 3594 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3595 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3596 | { |
| 3597 | struct bgp_static *bgp_static; |
| 3598 | struct bgp *bgp; |
| 3599 | struct bgp_node *rn; |
| 3600 | struct prefix *p; |
| 3601 | |
| 3602 | bgp = rsclient->bgp; |
| 3603 | |
| 3604 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3605 | if ((bgp_static = rn->info) != NULL) |
| 3606 | { |
| 3607 | p = &rn->p; |
| 3608 | |
| 3609 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3610 | afi, safi); |
| 3611 | } |
| 3612 | } |
| 3613 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3614 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3615 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3616 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3617 | { |
| 3618 | struct bgp_node *rn; |
| 3619 | struct bgp_info *ri; |
| 3620 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3621 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3622 | |
| 3623 | /* Check selected route and self inserted route. */ |
| 3624 | for (ri = rn->info; ri; ri = ri->next) |
| 3625 | if (ri->peer == bgp->peer_self |
| 3626 | && ri->type == ZEBRA_ROUTE_BGP |
| 3627 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3628 | break; |
| 3629 | |
| 3630 | /* Withdraw static BGP route from routing table. */ |
| 3631 | if (ri) |
| 3632 | { |
| 3633 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3634 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3635 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3636 | } |
| 3637 | |
| 3638 | /* Unlock bgp_node_lookup. */ |
| 3639 | bgp_unlock_node (rn); |
| 3640 | } |
| 3641 | |
| 3642 | /* Configure static BGP network. When user don't run zebra, static |
| 3643 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3644 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3645 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3646 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3647 | { |
| 3648 | int ret; |
| 3649 | struct prefix p; |
| 3650 | struct bgp_static *bgp_static; |
| 3651 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3652 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3653 | |
| 3654 | /* Convert IP prefix string to struct prefix. */ |
| 3655 | ret = str2prefix (ip_str, &p); |
| 3656 | if (! ret) |
| 3657 | { |
| 3658 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3659 | return CMD_WARNING; |
| 3660 | } |
| 3661 | #ifdef HAVE_IPV6 |
| 3662 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3663 | { |
| 3664 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3665 | VTY_NEWLINE); |
| 3666 | return CMD_WARNING; |
| 3667 | } |
| 3668 | #endif /* HAVE_IPV6 */ |
| 3669 | |
| 3670 | apply_mask (&p); |
| 3671 | |
| 3672 | /* Set BGP static route configuration. */ |
| 3673 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3674 | |
| 3675 | if (rn->info) |
| 3676 | { |
| 3677 | /* Configuration change. */ |
| 3678 | bgp_static = rn->info; |
| 3679 | |
| 3680 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3681 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3682 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3683 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3684 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3685 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3686 | if (rmap) |
| 3687 | { |
| 3688 | if (bgp_static->rmap.name) |
| 3689 | free (bgp_static->rmap.name); |
| 3690 | bgp_static->rmap.name = strdup (rmap); |
| 3691 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3692 | } |
| 3693 | else |
| 3694 | { |
| 3695 | if (bgp_static->rmap.name) |
| 3696 | free (bgp_static->rmap.name); |
| 3697 | bgp_static->rmap.name = NULL; |
| 3698 | bgp_static->rmap.map = NULL; |
| 3699 | bgp_static->valid = 0; |
| 3700 | } |
| 3701 | bgp_unlock_node (rn); |
| 3702 | } |
| 3703 | else |
| 3704 | { |
| 3705 | /* New configuration. */ |
| 3706 | bgp_static = bgp_static_new (); |
| 3707 | bgp_static->backdoor = backdoor; |
| 3708 | bgp_static->valid = 0; |
| 3709 | bgp_static->igpmetric = 0; |
| 3710 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3711 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3712 | if (rmap) |
| 3713 | { |
| 3714 | if (bgp_static->rmap.name) |
| 3715 | free (bgp_static->rmap.name); |
| 3716 | bgp_static->rmap.name = strdup (rmap); |
| 3717 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3718 | } |
| 3719 | rn->info = bgp_static; |
| 3720 | } |
| 3721 | |
| 3722 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3723 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3724 | { |
| 3725 | bgp_static->valid = 1; |
| 3726 | |
| 3727 | if (need_update) |
| 3728 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3729 | |
| 3730 | if (! bgp_static->backdoor) |
| 3731 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3732 | } |
| 3733 | |
| 3734 | return CMD_SUCCESS; |
| 3735 | } |
| 3736 | |
| 3737 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3738 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3739 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3740 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3741 | { |
| 3742 | int ret; |
| 3743 | struct prefix p; |
| 3744 | struct bgp_static *bgp_static; |
| 3745 | struct bgp_node *rn; |
| 3746 | |
| 3747 | /* Convert IP prefix string to struct prefix. */ |
| 3748 | ret = str2prefix (ip_str, &p); |
| 3749 | if (! ret) |
| 3750 | { |
| 3751 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3752 | return CMD_WARNING; |
| 3753 | } |
| 3754 | #ifdef HAVE_IPV6 |
| 3755 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3756 | { |
| 3757 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3758 | VTY_NEWLINE); |
| 3759 | return CMD_WARNING; |
| 3760 | } |
| 3761 | #endif /* HAVE_IPV6 */ |
| 3762 | |
| 3763 | apply_mask (&p); |
| 3764 | |
| 3765 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3766 | if (! rn) |
| 3767 | { |
| 3768 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3769 | VTY_NEWLINE); |
| 3770 | return CMD_WARNING; |
| 3771 | } |
| 3772 | |
| 3773 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3774 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3775 | /* Update BGP RIB. */ |
| 3776 | if (! bgp_static->backdoor) |
| 3777 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3778 | |
| 3779 | /* Clear configuration. */ |
| 3780 | bgp_static_free (bgp_static); |
| 3781 | rn->info = NULL; |
| 3782 | bgp_unlock_node (rn); |
| 3783 | bgp_unlock_node (rn); |
| 3784 | |
| 3785 | return CMD_SUCCESS; |
| 3786 | } |
| 3787 | |
| 3788 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3789 | instance. */ |
| 3790 | void |
| 3791 | bgp_static_delete (struct bgp *bgp) |
| 3792 | { |
| 3793 | afi_t afi; |
| 3794 | safi_t safi; |
| 3795 | struct bgp_node *rn; |
| 3796 | struct bgp_node *rm; |
| 3797 | struct bgp_table *table; |
| 3798 | struct bgp_static *bgp_static; |
| 3799 | |
| 3800 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3801 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3802 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3803 | if (rn->info != NULL) |
| 3804 | { |
| 3805 | if (safi == SAFI_MPLS_VPN) |
| 3806 | { |
| 3807 | table = rn->info; |
| 3808 | |
| 3809 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3810 | { |
| 3811 | bgp_static = rn->info; |
| 3812 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3813 | AFI_IP, SAFI_MPLS_VPN, |
| 3814 | (struct prefix_rd *)&rn->p, |
| 3815 | bgp_static->tag); |
| 3816 | bgp_static_free (bgp_static); |
| 3817 | rn->info = NULL; |
| 3818 | bgp_unlock_node (rn); |
| 3819 | } |
| 3820 | } |
| 3821 | else |
| 3822 | { |
| 3823 | bgp_static = rn->info; |
| 3824 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3825 | bgp_static_free (bgp_static); |
| 3826 | rn->info = NULL; |
| 3827 | bgp_unlock_node (rn); |
| 3828 | } |
| 3829 | } |
| 3830 | } |
| 3831 | |
| 3832 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3833 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3834 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3835 | { |
| 3836 | int ret; |
| 3837 | struct prefix p; |
| 3838 | struct prefix_rd prd; |
| 3839 | struct bgp *bgp; |
| 3840 | struct bgp_node *prn; |
| 3841 | struct bgp_node *rn; |
| 3842 | struct bgp_table *table; |
| 3843 | struct bgp_static *bgp_static; |
| 3844 | u_char tag[3]; |
| 3845 | |
| 3846 | bgp = vty->index; |
| 3847 | |
| 3848 | ret = str2prefix (ip_str, &p); |
| 3849 | if (! ret) |
| 3850 | { |
| 3851 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3852 | return CMD_WARNING; |
| 3853 | } |
| 3854 | apply_mask (&p); |
| 3855 | |
| 3856 | ret = str2prefix_rd (rd_str, &prd); |
| 3857 | if (! ret) |
| 3858 | { |
| 3859 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3860 | return CMD_WARNING; |
| 3861 | } |
| 3862 | |
| 3863 | ret = str2tag (tag_str, tag); |
| 3864 | if (! ret) |
| 3865 | { |
| 3866 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3867 | return CMD_WARNING; |
| 3868 | } |
| 3869 | |
| 3870 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3871 | (struct prefix *)&prd); |
| 3872 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3873 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3874 | else |
| 3875 | bgp_unlock_node (prn); |
| 3876 | table = prn->info; |
| 3877 | |
| 3878 | rn = bgp_node_get (table, &p); |
| 3879 | |
| 3880 | if (rn->info) |
| 3881 | { |
| 3882 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3883 | bgp_unlock_node (rn); |
| 3884 | } |
| 3885 | else |
| 3886 | { |
| 3887 | /* New configuration. */ |
| 3888 | bgp_static = bgp_static_new (); |
| 3889 | bgp_static->valid = 1; |
| 3890 | memcpy (bgp_static->tag, tag, 3); |
| 3891 | rn->info = bgp_static; |
| 3892 | |
| 3893 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3894 | } |
| 3895 | |
| 3896 | return CMD_SUCCESS; |
| 3897 | } |
| 3898 | |
| 3899 | /* Configure static BGP network. */ |
| 3900 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3901 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3902 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3903 | { |
| 3904 | int ret; |
| 3905 | struct bgp *bgp; |
| 3906 | struct prefix p; |
| 3907 | struct prefix_rd prd; |
| 3908 | struct bgp_node *prn; |
| 3909 | struct bgp_node *rn; |
| 3910 | struct bgp_table *table; |
| 3911 | struct bgp_static *bgp_static; |
| 3912 | u_char tag[3]; |
| 3913 | |
| 3914 | bgp = vty->index; |
| 3915 | |
| 3916 | /* Convert IP prefix string to struct prefix. */ |
| 3917 | ret = str2prefix (ip_str, &p); |
| 3918 | if (! ret) |
| 3919 | { |
| 3920 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3921 | return CMD_WARNING; |
| 3922 | } |
| 3923 | apply_mask (&p); |
| 3924 | |
| 3925 | ret = str2prefix_rd (rd_str, &prd); |
| 3926 | if (! ret) |
| 3927 | { |
| 3928 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3929 | return CMD_WARNING; |
| 3930 | } |
| 3931 | |
| 3932 | ret = str2tag (tag_str, tag); |
| 3933 | if (! ret) |
| 3934 | { |
| 3935 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3936 | return CMD_WARNING; |
| 3937 | } |
| 3938 | |
| 3939 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3940 | (struct prefix *)&prd); |
| 3941 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3942 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3943 | else |
| 3944 | bgp_unlock_node (prn); |
| 3945 | table = prn->info; |
| 3946 | |
| 3947 | rn = bgp_node_lookup (table, &p); |
| 3948 | |
| 3949 | if (rn) |
| 3950 | { |
| 3951 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3952 | |
| 3953 | bgp_static = rn->info; |
| 3954 | bgp_static_free (bgp_static); |
| 3955 | rn->info = NULL; |
| 3956 | bgp_unlock_node (rn); |
| 3957 | bgp_unlock_node (rn); |
| 3958 | } |
| 3959 | else |
| 3960 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3961 | |
| 3962 | return CMD_SUCCESS; |
| 3963 | } |
| 3964 | |
| 3965 | DEFUN (bgp_network, |
| 3966 | bgp_network_cmd, |
| 3967 | "network A.B.C.D/M", |
| 3968 | "Specify a network to announce via BGP\n" |
| 3969 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3970 | { |
| 3971 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3972 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3973 | } |
| 3974 | |
| 3975 | DEFUN (bgp_network_route_map, |
| 3976 | bgp_network_route_map_cmd, |
| 3977 | "network A.B.C.D/M route-map WORD", |
| 3978 | "Specify a network to announce via BGP\n" |
| 3979 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3980 | "Route-map to modify the attributes\n" |
| 3981 | "Name of the route map\n") |
| 3982 | { |
| 3983 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3984 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3985 | } |
| 3986 | |
| 3987 | DEFUN (bgp_network_backdoor, |
| 3988 | bgp_network_backdoor_cmd, |
| 3989 | "network A.B.C.D/M backdoor", |
| 3990 | "Specify a network to announce via BGP\n" |
| 3991 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3992 | "Specify a BGP backdoor route\n") |
| 3993 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3994 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3995 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3996 | } |
| 3997 | |
| 3998 | DEFUN (bgp_network_mask, |
| 3999 | bgp_network_mask_cmd, |
| 4000 | "network A.B.C.D mask A.B.C.D", |
| 4001 | "Specify a network to announce via BGP\n" |
| 4002 | "Network number\n" |
| 4003 | "Network mask\n" |
| 4004 | "Network mask\n") |
| 4005 | { |
| 4006 | int ret; |
| 4007 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4008 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4009 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4010 | if (! ret) |
| 4011 | { |
| 4012 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4013 | return CMD_WARNING; |
| 4014 | } |
| 4015 | |
| 4016 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4017 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4018 | } |
| 4019 | |
| 4020 | DEFUN (bgp_network_mask_route_map, |
| 4021 | bgp_network_mask_route_map_cmd, |
| 4022 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4023 | "Specify a network to announce via BGP\n" |
| 4024 | "Network number\n" |
| 4025 | "Network mask\n" |
| 4026 | "Network mask\n" |
| 4027 | "Route-map to modify the attributes\n" |
| 4028 | "Name of the route map\n") |
| 4029 | { |
| 4030 | int ret; |
| 4031 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4032 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4033 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4034 | if (! ret) |
| 4035 | { |
| 4036 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4037 | return CMD_WARNING; |
| 4038 | } |
| 4039 | |
| 4040 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4041 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4042 | } |
| 4043 | |
| 4044 | DEFUN (bgp_network_mask_backdoor, |
| 4045 | bgp_network_mask_backdoor_cmd, |
| 4046 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4047 | "Specify a network to announce via BGP\n" |
| 4048 | "Network number\n" |
| 4049 | "Network mask\n" |
| 4050 | "Network mask\n" |
| 4051 | "Specify a BGP backdoor route\n") |
| 4052 | { |
| 4053 | int ret; |
| 4054 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4055 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4056 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4057 | if (! ret) |
| 4058 | { |
| 4059 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4060 | return CMD_WARNING; |
| 4061 | } |
| 4062 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4063 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4064 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4065 | } |
| 4066 | |
| 4067 | DEFUN (bgp_network_mask_natural, |
| 4068 | bgp_network_mask_natural_cmd, |
| 4069 | "network A.B.C.D", |
| 4070 | "Specify a network to announce via BGP\n" |
| 4071 | "Network number\n") |
| 4072 | { |
| 4073 | int ret; |
| 4074 | char prefix_str[BUFSIZ]; |
| 4075 | |
| 4076 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4077 | if (! ret) |
| 4078 | { |
| 4079 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4080 | return CMD_WARNING; |
| 4081 | } |
| 4082 | |
| 4083 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4084 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | DEFUN (bgp_network_mask_natural_route_map, |
| 4088 | bgp_network_mask_natural_route_map_cmd, |
| 4089 | "network A.B.C.D route-map WORD", |
| 4090 | "Specify a network to announce via BGP\n" |
| 4091 | "Network number\n" |
| 4092 | "Route-map to modify the attributes\n" |
| 4093 | "Name of the route map\n") |
| 4094 | { |
| 4095 | int ret; |
| 4096 | char prefix_str[BUFSIZ]; |
| 4097 | |
| 4098 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4099 | if (! ret) |
| 4100 | { |
| 4101 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4102 | return CMD_WARNING; |
| 4103 | } |
| 4104 | |
| 4105 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4106 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4107 | } |
| 4108 | |
| 4109 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4110 | bgp_network_mask_natural_backdoor_cmd, |
| 4111 | "network A.B.C.D backdoor", |
| 4112 | "Specify a network to announce via BGP\n" |
| 4113 | "Network number\n" |
| 4114 | "Specify a BGP backdoor route\n") |
| 4115 | { |
| 4116 | int ret; |
| 4117 | char prefix_str[BUFSIZ]; |
| 4118 | |
| 4119 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4120 | if (! ret) |
| 4121 | { |
| 4122 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4123 | return CMD_WARNING; |
| 4124 | } |
| 4125 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4126 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4127 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4128 | } |
| 4129 | |
| 4130 | DEFUN (no_bgp_network, |
| 4131 | no_bgp_network_cmd, |
| 4132 | "no network A.B.C.D/M", |
| 4133 | NO_STR |
| 4134 | "Specify a network to announce via BGP\n" |
| 4135 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4136 | { |
| 4137 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4138 | bgp_node_safi (vty)); |
| 4139 | } |
| 4140 | |
| 4141 | ALIAS (no_bgp_network, |
| 4142 | no_bgp_network_route_map_cmd, |
| 4143 | "no network A.B.C.D/M route-map WORD", |
| 4144 | NO_STR |
| 4145 | "Specify a network to announce via BGP\n" |
| 4146 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4147 | "Route-map to modify the attributes\n" |
| 4148 | "Name of the route map\n") |
| 4149 | |
| 4150 | ALIAS (no_bgp_network, |
| 4151 | no_bgp_network_backdoor_cmd, |
| 4152 | "no network A.B.C.D/M backdoor", |
| 4153 | NO_STR |
| 4154 | "Specify a network to announce via BGP\n" |
| 4155 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4156 | "Specify a BGP backdoor route\n") |
| 4157 | |
| 4158 | DEFUN (no_bgp_network_mask, |
| 4159 | no_bgp_network_mask_cmd, |
| 4160 | "no network A.B.C.D mask A.B.C.D", |
| 4161 | NO_STR |
| 4162 | "Specify a network to announce via BGP\n" |
| 4163 | "Network number\n" |
| 4164 | "Network mask\n" |
| 4165 | "Network mask\n") |
| 4166 | { |
| 4167 | int ret; |
| 4168 | char prefix_str[BUFSIZ]; |
| 4169 | |
| 4170 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4171 | if (! ret) |
| 4172 | { |
| 4173 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4174 | return CMD_WARNING; |
| 4175 | } |
| 4176 | |
| 4177 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4178 | bgp_node_safi (vty)); |
| 4179 | } |
| 4180 | |
| 4181 | ALIAS (no_bgp_network_mask, |
| 4182 | no_bgp_network_mask_route_map_cmd, |
| 4183 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4184 | NO_STR |
| 4185 | "Specify a network to announce via BGP\n" |
| 4186 | "Network number\n" |
| 4187 | "Network mask\n" |
| 4188 | "Network mask\n" |
| 4189 | "Route-map to modify the attributes\n" |
| 4190 | "Name of the route map\n") |
| 4191 | |
| 4192 | ALIAS (no_bgp_network_mask, |
| 4193 | no_bgp_network_mask_backdoor_cmd, |
| 4194 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4195 | NO_STR |
| 4196 | "Specify a network to announce via BGP\n" |
| 4197 | "Network number\n" |
| 4198 | "Network mask\n" |
| 4199 | "Network mask\n" |
| 4200 | "Specify a BGP backdoor route\n") |
| 4201 | |
| 4202 | DEFUN (no_bgp_network_mask_natural, |
| 4203 | no_bgp_network_mask_natural_cmd, |
| 4204 | "no network A.B.C.D", |
| 4205 | NO_STR |
| 4206 | "Specify a network to announce via BGP\n" |
| 4207 | "Network number\n") |
| 4208 | { |
| 4209 | int ret; |
| 4210 | char prefix_str[BUFSIZ]; |
| 4211 | |
| 4212 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4213 | if (! ret) |
| 4214 | { |
| 4215 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4216 | return CMD_WARNING; |
| 4217 | } |
| 4218 | |
| 4219 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4220 | bgp_node_safi (vty)); |
| 4221 | } |
| 4222 | |
| 4223 | ALIAS (no_bgp_network_mask_natural, |
| 4224 | no_bgp_network_mask_natural_route_map_cmd, |
| 4225 | "no network A.B.C.D route-map WORD", |
| 4226 | NO_STR |
| 4227 | "Specify a network to announce via BGP\n" |
| 4228 | "Network number\n" |
| 4229 | "Route-map to modify the attributes\n" |
| 4230 | "Name of the route map\n") |
| 4231 | |
| 4232 | ALIAS (no_bgp_network_mask_natural, |
| 4233 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4234 | "no network A.B.C.D backdoor", |
| 4235 | NO_STR |
| 4236 | "Specify a network to announce via BGP\n" |
| 4237 | "Network number\n" |
| 4238 | "Specify a BGP backdoor route\n") |
| 4239 | |
| 4240 | #ifdef HAVE_IPV6 |
| 4241 | DEFUN (ipv6_bgp_network, |
| 4242 | ipv6_bgp_network_cmd, |
| 4243 | "network X:X::X:X/M", |
| 4244 | "Specify a network to announce via BGP\n" |
| 4245 | "IPv6 prefix <network>/<length>\n") |
| 4246 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4247 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty), |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4248 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4249 | } |
| 4250 | |
| 4251 | DEFUN (ipv6_bgp_network_route_map, |
| 4252 | ipv6_bgp_network_route_map_cmd, |
| 4253 | "network X:X::X:X/M route-map WORD", |
| 4254 | "Specify a network to announce via BGP\n" |
| 4255 | "IPv6 prefix <network>/<length>\n" |
| 4256 | "Route-map to modify the attributes\n" |
| 4257 | "Name of the route map\n") |
| 4258 | { |
| 4259 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4260 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4261 | } |
| 4262 | |
| 4263 | DEFUN (no_ipv6_bgp_network, |
| 4264 | no_ipv6_bgp_network_cmd, |
| 4265 | "no network X:X::X:X/M", |
| 4266 | NO_STR |
| 4267 | "Specify a network to announce via BGP\n" |
| 4268 | "IPv6 prefix <network>/<length>\n") |
| 4269 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4270 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4271 | } |
| 4272 | |
| 4273 | ALIAS (no_ipv6_bgp_network, |
| 4274 | no_ipv6_bgp_network_route_map_cmd, |
| 4275 | "no network X:X::X:X/M route-map WORD", |
| 4276 | NO_STR |
| 4277 | "Specify a network to announce via BGP\n" |
| 4278 | "IPv6 prefix <network>/<length>\n" |
| 4279 | "Route-map to modify the attributes\n" |
| 4280 | "Name of the route map\n") |
| 4281 | |
| 4282 | ALIAS (ipv6_bgp_network, |
| 4283 | old_ipv6_bgp_network_cmd, |
| 4284 | "ipv6 bgp network X:X::X:X/M", |
| 4285 | IPV6_STR |
| 4286 | BGP_STR |
| 4287 | "Specify a network to announce via BGP\n" |
| 4288 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4289 | |
| 4290 | ALIAS (no_ipv6_bgp_network, |
| 4291 | old_no_ipv6_bgp_network_cmd, |
| 4292 | "no ipv6 bgp network X:X::X:X/M", |
| 4293 | NO_STR |
| 4294 | IPV6_STR |
| 4295 | BGP_STR |
| 4296 | "Specify a network to announce via BGP\n" |
| 4297 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4298 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4299 | |
| 4300 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4301 | ALIAS_DEPRECATED (bgp_network, |
| 4302 | bgp_network_ttl_cmd, |
| 4303 | "network A.B.C.D/M pathlimit <0-255>", |
| 4304 | "Specify a network to announce via BGP\n" |
| 4305 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4306 | "AS-Path hopcount limit attribute\n" |
| 4307 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4308 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4309 | bgp_network_backdoor_ttl_cmd, |
| 4310 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4311 | "Specify a network to announce via BGP\n" |
| 4312 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4313 | "Specify a BGP backdoor route\n" |
| 4314 | "AS-Path hopcount limit attribute\n" |
| 4315 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4316 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4317 | bgp_network_mask_ttl_cmd, |
| 4318 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4319 | "Specify a network to announce via BGP\n" |
| 4320 | "Network number\n" |
| 4321 | "Network mask\n" |
| 4322 | "Network mask\n" |
| 4323 | "AS-Path hopcount limit attribute\n" |
| 4324 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4325 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4326 | bgp_network_mask_backdoor_ttl_cmd, |
| 4327 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4328 | "Specify a network to announce via BGP\n" |
| 4329 | "Network number\n" |
| 4330 | "Network mask\n" |
| 4331 | "Network mask\n" |
| 4332 | "Specify a BGP backdoor route\n" |
| 4333 | "AS-Path hopcount limit attribute\n" |
| 4334 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4335 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4336 | bgp_network_mask_natural_ttl_cmd, |
| 4337 | "network A.B.C.D pathlimit <0-255>", |
| 4338 | "Specify a network to announce via BGP\n" |
| 4339 | "Network number\n" |
| 4340 | "AS-Path hopcount limit attribute\n" |
| 4341 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4342 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4343 | bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4344 | "network A.B.C.D backdoor pathlimit (1-255>", |
| 4345 | "Specify a network to announce via BGP\n" |
| 4346 | "Network number\n" |
| 4347 | "Specify a BGP backdoor route\n" |
| 4348 | "AS-Path hopcount limit attribute\n" |
| 4349 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4350 | ALIAS_DEPRECATED (no_bgp_network, |
| 4351 | no_bgp_network_ttl_cmd, |
| 4352 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4353 | NO_STR |
| 4354 | "Specify a network to announce via BGP\n" |
| 4355 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4356 | "AS-Path hopcount limit attribute\n" |
| 4357 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4358 | ALIAS_DEPRECATED (no_bgp_network, |
| 4359 | no_bgp_network_backdoor_ttl_cmd, |
| 4360 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4361 | NO_STR |
| 4362 | "Specify a network to announce via BGP\n" |
| 4363 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4364 | "Specify a BGP backdoor route\n" |
| 4365 | "AS-Path hopcount limit attribute\n" |
| 4366 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4367 | ALIAS_DEPRECATED (no_bgp_network, |
| 4368 | no_bgp_network_mask_ttl_cmd, |
| 4369 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4370 | NO_STR |
| 4371 | "Specify a network to announce via BGP\n" |
| 4372 | "Network number\n" |
| 4373 | "Network mask\n" |
| 4374 | "Network mask\n" |
| 4375 | "AS-Path hopcount limit attribute\n" |
| 4376 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4377 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4378 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4379 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4380 | NO_STR |
| 4381 | "Specify a network to announce via BGP\n" |
| 4382 | "Network number\n" |
| 4383 | "Network mask\n" |
| 4384 | "Network mask\n" |
| 4385 | "Specify a BGP backdoor route\n" |
| 4386 | "AS-Path hopcount limit attribute\n" |
| 4387 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4388 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4389 | no_bgp_network_mask_natural_ttl_cmd, |
| 4390 | "no network A.B.C.D pathlimit <0-255>", |
| 4391 | NO_STR |
| 4392 | "Specify a network to announce via BGP\n" |
| 4393 | "Network number\n" |
| 4394 | "AS-Path hopcount limit attribute\n" |
| 4395 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4396 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4397 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4398 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4399 | NO_STR |
| 4400 | "Specify a network to announce via BGP\n" |
| 4401 | "Network number\n" |
| 4402 | "Specify a BGP backdoor route\n" |
| 4403 | "AS-Path hopcount limit attribute\n" |
| 4404 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4405 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4406 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4407 | ipv6_bgp_network_ttl_cmd, |
| 4408 | "network X:X::X:X/M pathlimit <0-255>", |
| 4409 | "Specify a network to announce via BGP\n" |
| 4410 | "IPv6 prefix <network>/<length>\n" |
| 4411 | "AS-Path hopcount limit attribute\n" |
| 4412 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4413 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4414 | no_ipv6_bgp_network_ttl_cmd, |
| 4415 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4416 | NO_STR |
| 4417 | "Specify a network to announce via BGP\n" |
| 4418 | "IPv6 prefix <network>/<length>\n" |
| 4419 | "AS-Path hopcount limit attribute\n" |
| 4420 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4421 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4422 | |
| 4423 | /* Aggreagete address: |
| 4424 | |
| 4425 | advertise-map Set condition to advertise attribute |
| 4426 | as-set Generate AS set path information |
| 4427 | attribute-map Set attributes of aggregate |
| 4428 | route-map Set parameters of aggregate |
| 4429 | summary-only Filter more specific routes from updates |
| 4430 | suppress-map Conditionally filter more specific routes from updates |
| 4431 | <cr> |
| 4432 | */ |
| 4433 | struct bgp_aggregate |
| 4434 | { |
| 4435 | /* Summary-only flag. */ |
| 4436 | u_char summary_only; |
| 4437 | |
| 4438 | /* AS set generation. */ |
| 4439 | u_char as_set; |
| 4440 | |
| 4441 | /* Route-map for aggregated route. */ |
| 4442 | struct route_map *map; |
| 4443 | |
| 4444 | /* Suppress-count. */ |
| 4445 | unsigned long count; |
| 4446 | |
| 4447 | /* SAFI configuration. */ |
| 4448 | safi_t safi; |
| 4449 | }; |
| 4450 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4451 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4452 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4453 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4454 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4455 | } |
| 4456 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4457 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4458 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4459 | { |
| 4460 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4461 | } |
| 4462 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4463 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4464 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4465 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4466 | struct bgp_aggregate *aggregate) |
| 4467 | { |
| 4468 | struct bgp_table *table; |
| 4469 | struct bgp_node *top; |
| 4470 | struct bgp_node *rn; |
| 4471 | u_char origin; |
| 4472 | struct aspath *aspath = NULL; |
| 4473 | struct aspath *asmerge = NULL; |
| 4474 | struct community *community = NULL; |
| 4475 | struct community *commerge = NULL; |
| 4476 | struct in_addr nexthop; |
| 4477 | u_int32_t med = 0; |
| 4478 | struct bgp_info *ri; |
| 4479 | struct bgp_info *new; |
| 4480 | int first = 1; |
| 4481 | unsigned long match = 0; |
| 4482 | |
| 4483 | /* Record adding route's nexthop and med. */ |
| 4484 | if (rinew) |
| 4485 | { |
| 4486 | nexthop = rinew->attr->nexthop; |
| 4487 | med = rinew->attr->med; |
| 4488 | } |
| 4489 | |
| 4490 | /* ORIGIN attribute: If at least one route among routes that are |
| 4491 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4492 | aggregated route must have the ORIGIN attribute with the value |
| 4493 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4494 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4495 | route must have the origin attribute with the value EGP. In all |
| 4496 | other case the value of the ORIGIN attribute of the aggregated |
| 4497 | route is INTERNAL. */ |
| 4498 | origin = BGP_ORIGIN_IGP; |
| 4499 | |
| 4500 | table = bgp->rib[afi][safi]; |
| 4501 | |
| 4502 | top = bgp_node_get (table, p); |
| 4503 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4504 | if (rn->p.prefixlen > p->prefixlen) |
| 4505 | { |
| 4506 | match = 0; |
| 4507 | |
| 4508 | for (ri = rn->info; ri; ri = ri->next) |
| 4509 | { |
| 4510 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4511 | continue; |
| 4512 | |
| 4513 | if (del && ri == del) |
| 4514 | continue; |
| 4515 | |
| 4516 | if (! rinew && first) |
| 4517 | { |
| 4518 | nexthop = ri->attr->nexthop; |
| 4519 | med = ri->attr->med; |
| 4520 | first = 0; |
| 4521 | } |
| 4522 | |
| 4523 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4524 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4525 | || ri->attr->med != med) |
| 4526 | { |
| 4527 | if (aspath) |
| 4528 | aspath_free (aspath); |
| 4529 | if (community) |
| 4530 | community_free (community); |
| 4531 | bgp_unlock_node (rn); |
| 4532 | bgp_unlock_node (top); |
| 4533 | return; |
| 4534 | } |
| 4535 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4536 | |
| 4537 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4538 | { |
| 4539 | if (aggregate->summary_only) |
| 4540 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4541 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4542 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4543 | match++; |
| 4544 | } |
| 4545 | |
| 4546 | aggregate->count++; |
| 4547 | |
| 4548 | if (aggregate->as_set) |
| 4549 | { |
| 4550 | if (origin < ri->attr->origin) |
| 4551 | origin = ri->attr->origin; |
| 4552 | |
| 4553 | if (aspath) |
| 4554 | { |
| 4555 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4556 | aspath_free (aspath); |
| 4557 | aspath = asmerge; |
| 4558 | } |
| 4559 | else |
| 4560 | aspath = aspath_dup (ri->attr->aspath); |
| 4561 | |
| 4562 | if (ri->attr->community) |
| 4563 | { |
| 4564 | if (community) |
| 4565 | { |
| 4566 | commerge = community_merge (community, |
| 4567 | ri->attr->community); |
| 4568 | community = community_uniq_sort (commerge); |
| 4569 | community_free (commerge); |
| 4570 | } |
| 4571 | else |
| 4572 | community = community_dup (ri->attr->community); |
| 4573 | } |
| 4574 | } |
| 4575 | } |
| 4576 | } |
| 4577 | if (match) |
| 4578 | bgp_process (bgp, rn, afi, safi); |
| 4579 | } |
| 4580 | bgp_unlock_node (top); |
| 4581 | |
| 4582 | if (rinew) |
| 4583 | { |
| 4584 | aggregate->count++; |
| 4585 | |
| 4586 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4587 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4588 | |
| 4589 | if (aggregate->as_set) |
| 4590 | { |
| 4591 | if (origin < rinew->attr->origin) |
| 4592 | origin = rinew->attr->origin; |
| 4593 | |
| 4594 | if (aspath) |
| 4595 | { |
| 4596 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4597 | aspath_free (aspath); |
| 4598 | aspath = asmerge; |
| 4599 | } |
| 4600 | else |
| 4601 | aspath = aspath_dup (rinew->attr->aspath); |
| 4602 | |
| 4603 | if (rinew->attr->community) |
| 4604 | { |
| 4605 | if (community) |
| 4606 | { |
| 4607 | commerge = community_merge (community, |
| 4608 | rinew->attr->community); |
| 4609 | community = community_uniq_sort (commerge); |
| 4610 | community_free (commerge); |
| 4611 | } |
| 4612 | else |
| 4613 | community = community_dup (rinew->attr->community); |
| 4614 | } |
| 4615 | } |
| 4616 | } |
| 4617 | |
| 4618 | if (aggregate->count > 0) |
| 4619 | { |
| 4620 | rn = bgp_node_get (table, p); |
| 4621 | new = bgp_info_new (); |
| 4622 | new->type = ZEBRA_ROUTE_BGP; |
| 4623 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4624 | new->peer = bgp->peer_self; |
| 4625 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4626 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 4627 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4628 | |
| 4629 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4630 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4631 | bgp_process (bgp, rn, afi, safi); |
| 4632 | } |
| 4633 | else |
| 4634 | { |
| 4635 | if (aspath) |
| 4636 | aspath_free (aspath); |
| 4637 | if (community) |
| 4638 | community_free (community); |
| 4639 | } |
| 4640 | } |
| 4641 | |
| 4642 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4643 | struct bgp_aggregate *); |
| 4644 | |
| 4645 | void |
| 4646 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4647 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4648 | { |
| 4649 | struct bgp_node *child; |
| 4650 | struct bgp_node *rn; |
| 4651 | struct bgp_aggregate *aggregate; |
| 4652 | |
| 4653 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4654 | if (safi == SAFI_MPLS_VPN) |
| 4655 | return; |
| 4656 | |
| 4657 | if (p->prefixlen == 0) |
| 4658 | return; |
| 4659 | |
| 4660 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4661 | return; |
| 4662 | |
| 4663 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4664 | |
| 4665 | /* Aggregate address configuration check. */ |
| 4666 | for (rn = child; rn; rn = rn->parent) |
| 4667 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4668 | { |
| 4669 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4670 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4671 | } |
| 4672 | bgp_unlock_node (child); |
| 4673 | } |
| 4674 | |
| 4675 | void |
| 4676 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4677 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4678 | { |
| 4679 | struct bgp_node *child; |
| 4680 | struct bgp_node *rn; |
| 4681 | struct bgp_aggregate *aggregate; |
| 4682 | |
| 4683 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4684 | if (safi == SAFI_MPLS_VPN) |
| 4685 | return; |
| 4686 | |
| 4687 | if (p->prefixlen == 0) |
| 4688 | return; |
| 4689 | |
| 4690 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4691 | |
| 4692 | /* Aggregate address configuration check. */ |
| 4693 | for (rn = child; rn; rn = rn->parent) |
| 4694 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4695 | { |
| 4696 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4697 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4698 | } |
| 4699 | bgp_unlock_node (child); |
| 4700 | } |
| 4701 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4702 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4703 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4704 | struct bgp_aggregate *aggregate) |
| 4705 | { |
| 4706 | struct bgp_table *table; |
| 4707 | struct bgp_node *top; |
| 4708 | struct bgp_node *rn; |
| 4709 | struct bgp_info *new; |
| 4710 | struct bgp_info *ri; |
| 4711 | unsigned long match; |
| 4712 | u_char origin = BGP_ORIGIN_IGP; |
| 4713 | struct aspath *aspath = NULL; |
| 4714 | struct aspath *asmerge = NULL; |
| 4715 | struct community *community = NULL; |
| 4716 | struct community *commerge = NULL; |
| 4717 | |
| 4718 | table = bgp->rib[afi][safi]; |
| 4719 | |
| 4720 | /* Sanity check. */ |
| 4721 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4722 | return; |
| 4723 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4724 | return; |
| 4725 | |
| 4726 | /* If routes exists below this node, generate aggregate routes. */ |
| 4727 | top = bgp_node_get (table, p); |
| 4728 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4729 | if (rn->p.prefixlen > p->prefixlen) |
| 4730 | { |
| 4731 | match = 0; |
| 4732 | |
| 4733 | for (ri = rn->info; ri; ri = ri->next) |
| 4734 | { |
| 4735 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4736 | continue; |
| 4737 | |
| 4738 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4739 | { |
| 4740 | /* summary-only aggregate route suppress aggregated |
| 4741 | route announcement. */ |
| 4742 | if (aggregate->summary_only) |
| 4743 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4744 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4745 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4746 | match++; |
| 4747 | } |
| 4748 | /* as-set aggregate route generate origin, as path, |
| 4749 | community aggregation. */ |
| 4750 | if (aggregate->as_set) |
| 4751 | { |
| 4752 | if (origin < ri->attr->origin) |
| 4753 | origin = ri->attr->origin; |
| 4754 | |
| 4755 | if (aspath) |
| 4756 | { |
| 4757 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4758 | aspath_free (aspath); |
| 4759 | aspath = asmerge; |
| 4760 | } |
| 4761 | else |
| 4762 | aspath = aspath_dup (ri->attr->aspath); |
| 4763 | |
| 4764 | if (ri->attr->community) |
| 4765 | { |
| 4766 | if (community) |
| 4767 | { |
| 4768 | commerge = community_merge (community, |
| 4769 | ri->attr->community); |
| 4770 | community = community_uniq_sort (commerge); |
| 4771 | community_free (commerge); |
| 4772 | } |
| 4773 | else |
| 4774 | community = community_dup (ri->attr->community); |
| 4775 | } |
| 4776 | } |
| 4777 | aggregate->count++; |
| 4778 | } |
| 4779 | } |
| 4780 | |
| 4781 | /* If this node is suppressed, process the change. */ |
| 4782 | if (match) |
| 4783 | bgp_process (bgp, rn, afi, safi); |
| 4784 | } |
| 4785 | bgp_unlock_node (top); |
| 4786 | |
| 4787 | /* Add aggregate route to BGP table. */ |
| 4788 | if (aggregate->count) |
| 4789 | { |
| 4790 | rn = bgp_node_get (table, p); |
| 4791 | |
| 4792 | new = bgp_info_new (); |
| 4793 | new->type = ZEBRA_ROUTE_BGP; |
| 4794 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4795 | new->peer = bgp->peer_self; |
| 4796 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4797 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 4798 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4799 | |
| 4800 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4801 | bgp_unlock_node (rn); |
| 4802 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4803 | /* Process change. */ |
| 4804 | bgp_process (bgp, rn, afi, safi); |
| 4805 | } |
| 4806 | } |
| 4807 | |
| 4808 | void |
| 4809 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4810 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4811 | { |
| 4812 | struct bgp_table *table; |
| 4813 | struct bgp_node *top; |
| 4814 | struct bgp_node *rn; |
| 4815 | struct bgp_info *ri; |
| 4816 | unsigned long match; |
| 4817 | |
| 4818 | table = bgp->rib[afi][safi]; |
| 4819 | |
| 4820 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4821 | return; |
| 4822 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4823 | return; |
| 4824 | |
| 4825 | /* If routes exists below this node, generate aggregate routes. */ |
| 4826 | top = bgp_node_get (table, p); |
| 4827 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4828 | if (rn->p.prefixlen > p->prefixlen) |
| 4829 | { |
| 4830 | match = 0; |
| 4831 | |
| 4832 | for (ri = rn->info; ri; ri = ri->next) |
| 4833 | { |
| 4834 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4835 | continue; |
| 4836 | |
| 4837 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4838 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4839 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4840 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4841 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4842 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4843 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4844 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4845 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4846 | match++; |
| 4847 | } |
| 4848 | } |
| 4849 | aggregate->count--; |
| 4850 | } |
| 4851 | } |
| 4852 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4853 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4854 | if (match) |
| 4855 | bgp_process (bgp, rn, afi, safi); |
| 4856 | } |
| 4857 | bgp_unlock_node (top); |
| 4858 | |
| 4859 | /* Delete aggregate route from BGP table. */ |
| 4860 | rn = bgp_node_get (table, p); |
| 4861 | |
| 4862 | for (ri = rn->info; ri; ri = ri->next) |
| 4863 | if (ri->peer == bgp->peer_self |
| 4864 | && ri->type == ZEBRA_ROUTE_BGP |
| 4865 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4866 | break; |
| 4867 | |
| 4868 | /* Withdraw static BGP route from routing table. */ |
| 4869 | if (ri) |
| 4870 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4871 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4872 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4873 | } |
| 4874 | |
| 4875 | /* Unlock bgp_node_lookup. */ |
| 4876 | bgp_unlock_node (rn); |
| 4877 | } |
| 4878 | |
| 4879 | /* Aggregate route attribute. */ |
| 4880 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4881 | #define AGGREGATE_AS_SET 1 |
| 4882 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4883 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4884 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4885 | afi_t afi, safi_t safi) |
| 4886 | { |
| 4887 | int ret; |
| 4888 | struct prefix p; |
| 4889 | struct bgp_node *rn; |
| 4890 | struct bgp *bgp; |
| 4891 | struct bgp_aggregate *aggregate; |
| 4892 | |
| 4893 | /* Convert string to prefix structure. */ |
| 4894 | ret = str2prefix (prefix_str, &p); |
| 4895 | if (!ret) |
| 4896 | { |
| 4897 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4898 | return CMD_WARNING; |
| 4899 | } |
| 4900 | apply_mask (&p); |
| 4901 | |
| 4902 | /* Get BGP structure. */ |
| 4903 | bgp = vty->index; |
| 4904 | |
| 4905 | /* Old configuration check. */ |
| 4906 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4907 | if (! rn) |
| 4908 | { |
| 4909 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4910 | VTY_NEWLINE); |
| 4911 | return CMD_WARNING; |
| 4912 | } |
| 4913 | |
| 4914 | aggregate = rn->info; |
| 4915 | if (aggregate->safi & SAFI_UNICAST) |
| 4916 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4917 | if (aggregate->safi & SAFI_MULTICAST) |
| 4918 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4919 | |
| 4920 | /* Unlock aggregate address configuration. */ |
| 4921 | rn->info = NULL; |
| 4922 | bgp_aggregate_free (aggregate); |
| 4923 | bgp_unlock_node (rn); |
| 4924 | bgp_unlock_node (rn); |
| 4925 | |
| 4926 | return CMD_SUCCESS; |
| 4927 | } |
| 4928 | |
| 4929 | static int |
| 4930 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4931 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4932 | u_char summary_only, u_char as_set) |
| 4933 | { |
| 4934 | int ret; |
| 4935 | struct prefix p; |
| 4936 | struct bgp_node *rn; |
| 4937 | struct bgp *bgp; |
| 4938 | struct bgp_aggregate *aggregate; |
| 4939 | |
| 4940 | /* Convert string to prefix structure. */ |
| 4941 | ret = str2prefix (prefix_str, &p); |
| 4942 | if (!ret) |
| 4943 | { |
| 4944 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4945 | return CMD_WARNING; |
| 4946 | } |
| 4947 | apply_mask (&p); |
| 4948 | |
| 4949 | /* Get BGP structure. */ |
| 4950 | bgp = vty->index; |
| 4951 | |
| 4952 | /* Old configuration check. */ |
| 4953 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4954 | |
| 4955 | if (rn->info) |
| 4956 | { |
| 4957 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4958 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4959 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 4960 | if (ret) |
| 4961 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4962 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 4963 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4964 | return CMD_WARNING; |
| 4965 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4966 | } |
| 4967 | |
| 4968 | /* Make aggregate address structure. */ |
| 4969 | aggregate = bgp_aggregate_new (); |
| 4970 | aggregate->summary_only = summary_only; |
| 4971 | aggregate->as_set = as_set; |
| 4972 | aggregate->safi = safi; |
| 4973 | rn->info = aggregate; |
| 4974 | |
| 4975 | /* Aggregate address insert into BGP routing table. */ |
| 4976 | if (safi & SAFI_UNICAST) |
| 4977 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4978 | if (safi & SAFI_MULTICAST) |
| 4979 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4980 | |
| 4981 | return CMD_SUCCESS; |
| 4982 | } |
| 4983 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4984 | DEFUN (aggregate_address, |
| 4985 | aggregate_address_cmd, |
| 4986 | "aggregate-address A.B.C.D/M", |
| 4987 | "Configure BGP aggregate entries\n" |
| 4988 | "Aggregate prefix\n") |
| 4989 | { |
| 4990 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 4991 | } |
| 4992 | |
| 4993 | DEFUN (aggregate_address_mask, |
| 4994 | aggregate_address_mask_cmd, |
| 4995 | "aggregate-address A.B.C.D A.B.C.D", |
| 4996 | "Configure BGP aggregate entries\n" |
| 4997 | "Aggregate address\n" |
| 4998 | "Aggregate mask\n") |
| 4999 | { |
| 5000 | int ret; |
| 5001 | char prefix_str[BUFSIZ]; |
| 5002 | |
| 5003 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5004 | |
| 5005 | if (! ret) |
| 5006 | { |
| 5007 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5008 | return CMD_WARNING; |
| 5009 | } |
| 5010 | |
| 5011 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5012 | 0, 0); |
| 5013 | } |
| 5014 | |
| 5015 | DEFUN (aggregate_address_summary_only, |
| 5016 | aggregate_address_summary_only_cmd, |
| 5017 | "aggregate-address A.B.C.D/M summary-only", |
| 5018 | "Configure BGP aggregate entries\n" |
| 5019 | "Aggregate prefix\n" |
| 5020 | "Filter more specific routes from updates\n") |
| 5021 | { |
| 5022 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5023 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5024 | } |
| 5025 | |
| 5026 | DEFUN (aggregate_address_mask_summary_only, |
| 5027 | aggregate_address_mask_summary_only_cmd, |
| 5028 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5029 | "Configure BGP aggregate entries\n" |
| 5030 | "Aggregate address\n" |
| 5031 | "Aggregate mask\n" |
| 5032 | "Filter more specific routes from updates\n") |
| 5033 | { |
| 5034 | int ret; |
| 5035 | char prefix_str[BUFSIZ]; |
| 5036 | |
| 5037 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5038 | |
| 5039 | if (! ret) |
| 5040 | { |
| 5041 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5042 | return CMD_WARNING; |
| 5043 | } |
| 5044 | |
| 5045 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5046 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5047 | } |
| 5048 | |
| 5049 | DEFUN (aggregate_address_as_set, |
| 5050 | aggregate_address_as_set_cmd, |
| 5051 | "aggregate-address A.B.C.D/M as-set", |
| 5052 | "Configure BGP aggregate entries\n" |
| 5053 | "Aggregate prefix\n" |
| 5054 | "Generate AS set path information\n") |
| 5055 | { |
| 5056 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5057 | 0, AGGREGATE_AS_SET); |
| 5058 | } |
| 5059 | |
| 5060 | DEFUN (aggregate_address_mask_as_set, |
| 5061 | aggregate_address_mask_as_set_cmd, |
| 5062 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5063 | "Configure BGP aggregate entries\n" |
| 5064 | "Aggregate address\n" |
| 5065 | "Aggregate mask\n" |
| 5066 | "Generate AS set path information\n") |
| 5067 | { |
| 5068 | int ret; |
| 5069 | char prefix_str[BUFSIZ]; |
| 5070 | |
| 5071 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5072 | |
| 5073 | if (! ret) |
| 5074 | { |
| 5075 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5076 | return CMD_WARNING; |
| 5077 | } |
| 5078 | |
| 5079 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5080 | 0, AGGREGATE_AS_SET); |
| 5081 | } |
| 5082 | |
| 5083 | |
| 5084 | DEFUN (aggregate_address_as_set_summary, |
| 5085 | aggregate_address_as_set_summary_cmd, |
| 5086 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5087 | "Configure BGP aggregate entries\n" |
| 5088 | "Aggregate prefix\n" |
| 5089 | "Generate AS set path information\n" |
| 5090 | "Filter more specific routes from updates\n") |
| 5091 | { |
| 5092 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5093 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5094 | } |
| 5095 | |
| 5096 | ALIAS (aggregate_address_as_set_summary, |
| 5097 | aggregate_address_summary_as_set_cmd, |
| 5098 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5099 | "Configure BGP aggregate entries\n" |
| 5100 | "Aggregate prefix\n" |
| 5101 | "Filter more specific routes from updates\n" |
| 5102 | "Generate AS set path information\n") |
| 5103 | |
| 5104 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5105 | aggregate_address_mask_as_set_summary_cmd, |
| 5106 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5107 | "Configure BGP aggregate entries\n" |
| 5108 | "Aggregate address\n" |
| 5109 | "Aggregate mask\n" |
| 5110 | "Generate AS set path information\n" |
| 5111 | "Filter more specific routes from updates\n") |
| 5112 | { |
| 5113 | int ret; |
| 5114 | char prefix_str[BUFSIZ]; |
| 5115 | |
| 5116 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5117 | |
| 5118 | if (! ret) |
| 5119 | { |
| 5120 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5121 | return CMD_WARNING; |
| 5122 | } |
| 5123 | |
| 5124 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5125 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5126 | } |
| 5127 | |
| 5128 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5129 | aggregate_address_mask_summary_as_set_cmd, |
| 5130 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5131 | "Configure BGP aggregate entries\n" |
| 5132 | "Aggregate address\n" |
| 5133 | "Aggregate mask\n" |
| 5134 | "Filter more specific routes from updates\n" |
| 5135 | "Generate AS set path information\n") |
| 5136 | |
| 5137 | DEFUN (no_aggregate_address, |
| 5138 | no_aggregate_address_cmd, |
| 5139 | "no aggregate-address A.B.C.D/M", |
| 5140 | NO_STR |
| 5141 | "Configure BGP aggregate entries\n" |
| 5142 | "Aggregate prefix\n") |
| 5143 | { |
| 5144 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5145 | } |
| 5146 | |
| 5147 | ALIAS (no_aggregate_address, |
| 5148 | no_aggregate_address_summary_only_cmd, |
| 5149 | "no aggregate-address A.B.C.D/M summary-only", |
| 5150 | NO_STR |
| 5151 | "Configure BGP aggregate entries\n" |
| 5152 | "Aggregate prefix\n" |
| 5153 | "Filter more specific routes from updates\n") |
| 5154 | |
| 5155 | ALIAS (no_aggregate_address, |
| 5156 | no_aggregate_address_as_set_cmd, |
| 5157 | "no aggregate-address A.B.C.D/M as-set", |
| 5158 | NO_STR |
| 5159 | "Configure BGP aggregate entries\n" |
| 5160 | "Aggregate prefix\n" |
| 5161 | "Generate AS set path information\n") |
| 5162 | |
| 5163 | ALIAS (no_aggregate_address, |
| 5164 | no_aggregate_address_as_set_summary_cmd, |
| 5165 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5166 | NO_STR |
| 5167 | "Configure BGP aggregate entries\n" |
| 5168 | "Aggregate prefix\n" |
| 5169 | "Generate AS set path information\n" |
| 5170 | "Filter more specific routes from updates\n") |
| 5171 | |
| 5172 | ALIAS (no_aggregate_address, |
| 5173 | no_aggregate_address_summary_as_set_cmd, |
| 5174 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5175 | NO_STR |
| 5176 | "Configure BGP aggregate entries\n" |
| 5177 | "Aggregate prefix\n" |
| 5178 | "Filter more specific routes from updates\n" |
| 5179 | "Generate AS set path information\n") |
| 5180 | |
| 5181 | DEFUN (no_aggregate_address_mask, |
| 5182 | no_aggregate_address_mask_cmd, |
| 5183 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5184 | NO_STR |
| 5185 | "Configure BGP aggregate entries\n" |
| 5186 | "Aggregate address\n" |
| 5187 | "Aggregate mask\n") |
| 5188 | { |
| 5189 | int ret; |
| 5190 | char prefix_str[BUFSIZ]; |
| 5191 | |
| 5192 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5193 | |
| 5194 | if (! ret) |
| 5195 | { |
| 5196 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5197 | return CMD_WARNING; |
| 5198 | } |
| 5199 | |
| 5200 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5201 | } |
| 5202 | |
| 5203 | ALIAS (no_aggregate_address_mask, |
| 5204 | no_aggregate_address_mask_summary_only_cmd, |
| 5205 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5206 | NO_STR |
| 5207 | "Configure BGP aggregate entries\n" |
| 5208 | "Aggregate address\n" |
| 5209 | "Aggregate mask\n" |
| 5210 | "Filter more specific routes from updates\n") |
| 5211 | |
| 5212 | ALIAS (no_aggregate_address_mask, |
| 5213 | no_aggregate_address_mask_as_set_cmd, |
| 5214 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5215 | NO_STR |
| 5216 | "Configure BGP aggregate entries\n" |
| 5217 | "Aggregate address\n" |
| 5218 | "Aggregate mask\n" |
| 5219 | "Generate AS set path information\n") |
| 5220 | |
| 5221 | ALIAS (no_aggregate_address_mask, |
| 5222 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5223 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5224 | NO_STR |
| 5225 | "Configure BGP aggregate entries\n" |
| 5226 | "Aggregate address\n" |
| 5227 | "Aggregate mask\n" |
| 5228 | "Generate AS set path information\n" |
| 5229 | "Filter more specific routes from updates\n") |
| 5230 | |
| 5231 | ALIAS (no_aggregate_address_mask, |
| 5232 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5233 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5234 | NO_STR |
| 5235 | "Configure BGP aggregate entries\n" |
| 5236 | "Aggregate address\n" |
| 5237 | "Aggregate mask\n" |
| 5238 | "Filter more specific routes from updates\n" |
| 5239 | "Generate AS set path information\n") |
| 5240 | |
| 5241 | #ifdef HAVE_IPV6 |
| 5242 | DEFUN (ipv6_aggregate_address, |
| 5243 | ipv6_aggregate_address_cmd, |
| 5244 | "aggregate-address X:X::X:X/M", |
| 5245 | "Configure BGP aggregate entries\n" |
| 5246 | "Aggregate prefix\n") |
| 5247 | { |
| 5248 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5249 | } |
| 5250 | |
| 5251 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5252 | ipv6_aggregate_address_summary_only_cmd, |
| 5253 | "aggregate-address X:X::X:X/M summary-only", |
| 5254 | "Configure BGP aggregate entries\n" |
| 5255 | "Aggregate prefix\n" |
| 5256 | "Filter more specific routes from updates\n") |
| 5257 | { |
| 5258 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5259 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5260 | } |
| 5261 | |
| 5262 | DEFUN (no_ipv6_aggregate_address, |
| 5263 | no_ipv6_aggregate_address_cmd, |
| 5264 | "no aggregate-address X:X::X:X/M", |
| 5265 | NO_STR |
| 5266 | "Configure BGP aggregate entries\n" |
| 5267 | "Aggregate prefix\n") |
| 5268 | { |
| 5269 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5270 | } |
| 5271 | |
| 5272 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5273 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5274 | "no aggregate-address X:X::X:X/M summary-only", |
| 5275 | NO_STR |
| 5276 | "Configure BGP aggregate entries\n" |
| 5277 | "Aggregate prefix\n" |
| 5278 | "Filter more specific routes from updates\n") |
| 5279 | { |
| 5280 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5281 | } |
| 5282 | |
| 5283 | ALIAS (ipv6_aggregate_address, |
| 5284 | old_ipv6_aggregate_address_cmd, |
| 5285 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5286 | IPV6_STR |
| 5287 | BGP_STR |
| 5288 | "Configure BGP aggregate entries\n" |
| 5289 | "Aggregate prefix\n") |
| 5290 | |
| 5291 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5292 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5293 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5294 | IPV6_STR |
| 5295 | BGP_STR |
| 5296 | "Configure BGP aggregate entries\n" |
| 5297 | "Aggregate prefix\n" |
| 5298 | "Filter more specific routes from updates\n") |
| 5299 | |
| 5300 | ALIAS (no_ipv6_aggregate_address, |
| 5301 | old_no_ipv6_aggregate_address_cmd, |
| 5302 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5303 | NO_STR |
| 5304 | IPV6_STR |
| 5305 | BGP_STR |
| 5306 | "Configure BGP aggregate entries\n" |
| 5307 | "Aggregate prefix\n") |
| 5308 | |
| 5309 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5310 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5311 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5312 | NO_STR |
| 5313 | IPV6_STR |
| 5314 | BGP_STR |
| 5315 | "Configure BGP aggregate entries\n" |
| 5316 | "Aggregate prefix\n" |
| 5317 | "Filter more specific routes from updates\n") |
| 5318 | #endif /* HAVE_IPV6 */ |
| 5319 | |
| 5320 | /* Redistribute route treatment. */ |
| 5321 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5322 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5323 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5324 | u_int32_t metric, u_char type) |
| 5325 | { |
| 5326 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5327 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5328 | struct bgp_info *new; |
| 5329 | struct bgp_info *bi; |
| 5330 | struct bgp_info info; |
| 5331 | struct bgp_node *bn; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5332 | struct attr attr = { 0 }; |
| 5333 | struct attr attr_new = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5334 | struct attr *new_attr; |
| 5335 | afi_t afi; |
| 5336 | int ret; |
| 5337 | |
| 5338 | /* Make default attribute. */ |
| 5339 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5340 | if (nexthop) |
| 5341 | attr.nexthop = *nexthop; |
| 5342 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5343 | #ifdef HAVE_IPV6 |
| 5344 | if (nexthop6) |
| 5345 | { |
| 5346 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5347 | extra->mp_nexthop_global = *nexthop6; |
| 5348 | extra->mp_nexthop_len = 16; |
| 5349 | } |
| 5350 | #endif |
| 5351 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5352 | attr.med = metric; |
| 5353 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5354 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5355 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5356 | { |
| 5357 | afi = family2afi (p->family); |
| 5358 | |
| 5359 | if (bgp->redist[afi][type]) |
| 5360 | { |
| 5361 | /* Copy attribute for modification. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5362 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5363 | |
| 5364 | if (bgp->redist_metric_flag[afi][type]) |
| 5365 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5366 | |
| 5367 | /* Apply route-map. */ |
| 5368 | if (bgp->rmap[afi][type].map) |
| 5369 | { |
| 5370 | info.peer = bgp->peer_self; |
| 5371 | info.attr = &attr_new; |
| 5372 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5373 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5374 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5375 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5376 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5377 | |
| 5378 | bgp->peer_self->rmap_type = 0; |
| 5379 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5380 | if (ret == RMAP_DENYMATCH) |
| 5381 | { |
| 5382 | /* Free uninterned attribute. */ |
| 5383 | bgp_attr_flush (&attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5384 | bgp_attr_extra_free (&attr_new); |
| 5385 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5386 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5387 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5388 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5389 | bgp_redistribute_delete (p, type); |
| 5390 | return; |
| 5391 | } |
| 5392 | } |
| 5393 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5394 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5395 | afi, SAFI_UNICAST, p, NULL); |
| 5396 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5397 | new_attr = bgp_attr_intern (&attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5398 | bgp_attr_extra_free (&attr_new); |
| 5399 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5400 | for (bi = bn->info; bi; bi = bi->next) |
| 5401 | if (bi->peer == bgp->peer_self |
| 5402 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5403 | break; |
| 5404 | |
| 5405 | if (bi) |
| 5406 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5407 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5408 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5409 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5410 | bgp_attr_unintern (&new_attr); |
| 5411 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5412 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5413 | bgp_unlock_node (bn); |
| 5414 | return; |
| 5415 | } |
| 5416 | else |
| 5417 | { |
| 5418 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5419 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5420 | |
| 5421 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5422 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5423 | bgp_info_restore(bn, bi); |
| 5424 | else |
| 5425 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5426 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5427 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5428 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5429 | |
| 5430 | /* Process change. */ |
| 5431 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5432 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5433 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5434 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5435 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5436 | return; |
| 5437 | } |
| 5438 | } |
| 5439 | |
| 5440 | new = bgp_info_new (); |
| 5441 | new->type = type; |
| 5442 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5443 | new->peer = bgp->peer_self; |
| 5444 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5445 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5446 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5447 | |
| 5448 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5449 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5450 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5451 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5452 | } |
| 5453 | } |
| 5454 | |
| 5455 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5456 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5457 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5458 | } |
| 5459 | |
| 5460 | void |
| 5461 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5462 | { |
| 5463 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5464 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5465 | afi_t afi; |
| 5466 | struct bgp_node *rn; |
| 5467 | struct bgp_info *ri; |
| 5468 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5469 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5470 | { |
| 5471 | afi = family2afi (p->family); |
| 5472 | |
| 5473 | if (bgp->redist[afi][type]) |
| 5474 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5475 | 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] | 5476 | |
| 5477 | for (ri = rn->info; ri; ri = ri->next) |
| 5478 | if (ri->peer == bgp->peer_self |
| 5479 | && ri->type == type) |
| 5480 | break; |
| 5481 | |
| 5482 | if (ri) |
| 5483 | { |
| 5484 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5485 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5486 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5487 | } |
| 5488 | bgp_unlock_node (rn); |
| 5489 | } |
| 5490 | } |
| 5491 | } |
| 5492 | |
| 5493 | /* Withdraw specified route type's route. */ |
| 5494 | void |
| 5495 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5496 | { |
| 5497 | struct bgp_node *rn; |
| 5498 | struct bgp_info *ri; |
| 5499 | struct bgp_table *table; |
| 5500 | |
| 5501 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5502 | |
| 5503 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5504 | { |
| 5505 | for (ri = rn->info; ri; ri = ri->next) |
| 5506 | if (ri->peer == bgp->peer_self |
| 5507 | && ri->type == type) |
| 5508 | break; |
| 5509 | |
| 5510 | if (ri) |
| 5511 | { |
| 5512 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5513 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5514 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5515 | } |
| 5516 | } |
| 5517 | } |
| 5518 | |
| 5519 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5520 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5521 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5522 | { |
| 5523 | int len; |
| 5524 | u_int32_t destination; |
| 5525 | char buf[BUFSIZ]; |
| 5526 | |
| 5527 | if (p->family == AF_INET) |
| 5528 | { |
| 5529 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5530 | destination = ntohl (p->u.prefix4.s_addr); |
| 5531 | |
| 5532 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5533 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5534 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5535 | || p->u.prefix4.s_addr == 0) |
| 5536 | { |
| 5537 | /* When mask is natural, mask is not displayed. */ |
| 5538 | } |
| 5539 | else |
| 5540 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5541 | } |
| 5542 | else |
| 5543 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5544 | p->prefixlen); |
| 5545 | |
| 5546 | len = 17 - len; |
| 5547 | if (len < 1) |
| 5548 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5549 | else |
| 5550 | vty_out (vty, "%*s", len, " "); |
| 5551 | } |
| 5552 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5553 | enum bgp_display_type |
| 5554 | { |
| 5555 | normal_list, |
| 5556 | }; |
| 5557 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5558 | /* Print the short form route status for a bgp_info */ |
| 5559 | static void |
| 5560 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5561 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5562 | /* Route status display. */ |
| 5563 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5564 | vty_out (vty, "R"); |
| 5565 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5566 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5567 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5568 | vty_out (vty, "s"); |
| 5569 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5570 | vty_out (vty, "*"); |
| 5571 | else |
| 5572 | vty_out (vty, " "); |
| 5573 | |
| 5574 | /* Selected */ |
| 5575 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5576 | vty_out (vty, "h"); |
| 5577 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5578 | vty_out (vty, "d"); |
| 5579 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5580 | vty_out (vty, ">"); |
| 5581 | else |
| 5582 | vty_out (vty, " "); |
| 5583 | |
| 5584 | /* Internal route. */ |
| 5585 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5586 | vty_out (vty, "i"); |
| 5587 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5588 | vty_out (vty, " "); |
| 5589 | } |
| 5590 | |
| 5591 | /* called from terminal list command */ |
| 5592 | void |
| 5593 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5594 | struct bgp_info *binfo, int display, safi_t safi) |
| 5595 | { |
| 5596 | struct attr *attr; |
| 5597 | |
| 5598 | /* short status lead text */ |
| 5599 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5600 | |
| 5601 | /* print prefix and mask */ |
| 5602 | if (! display) |
| 5603 | route_vty_out_route (p, vty); |
| 5604 | else |
| 5605 | vty_out (vty, "%*s", 17, " "); |
| 5606 | |
| 5607 | /* Print attribute */ |
| 5608 | attr = binfo->attr; |
| 5609 | if (attr) |
| 5610 | { |
| 5611 | if (p->family == AF_INET) |
| 5612 | { |
| 5613 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5614 | vty_out (vty, "%-16s", |
| 5615 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5616 | else |
| 5617 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5618 | } |
| 5619 | #ifdef HAVE_IPV6 |
| 5620 | else if (p->family == AF_INET6) |
| 5621 | { |
| 5622 | int len; |
| 5623 | char buf[BUFSIZ]; |
| 5624 | |
| 5625 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5626 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5627 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5628 | len = 16 - len; |
| 5629 | if (len < 1) |
| 5630 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5631 | else |
| 5632 | vty_out (vty, "%*s", len, " "); |
| 5633 | } |
| 5634 | #endif /* HAVE_IPV6 */ |
| 5635 | |
| 5636 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5637 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5638 | else |
| 5639 | vty_out (vty, " "); |
| 5640 | |
| 5641 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5642 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5643 | else |
| 5644 | vty_out (vty, " "); |
| 5645 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5646 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5647 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5648 | /* Print aspath */ |
| 5649 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5650 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5651 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5652 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5653 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5654 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5655 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5656 | } |
| 5657 | |
| 5658 | /* called from terminal list command */ |
| 5659 | void |
| 5660 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5661 | struct attr *attr, safi_t safi) |
| 5662 | { |
| 5663 | /* Route status display. */ |
| 5664 | vty_out (vty, "*"); |
| 5665 | vty_out (vty, ">"); |
| 5666 | vty_out (vty, " "); |
| 5667 | |
| 5668 | /* print prefix and mask */ |
| 5669 | route_vty_out_route (p, vty); |
| 5670 | |
| 5671 | /* Print attribute */ |
| 5672 | if (attr) |
| 5673 | { |
| 5674 | if (p->family == AF_INET) |
| 5675 | { |
| 5676 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5677 | vty_out (vty, "%-16s", |
| 5678 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5679 | else |
| 5680 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5681 | } |
| 5682 | #ifdef HAVE_IPV6 |
| 5683 | else if (p->family == AF_INET6) |
| 5684 | { |
| 5685 | int len; |
| 5686 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5687 | |
| 5688 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5689 | |
| 5690 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5691 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5692 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5693 | len = 16 - len; |
| 5694 | if (len < 1) |
| 5695 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5696 | else |
| 5697 | vty_out (vty, "%*s", len, " "); |
| 5698 | } |
| 5699 | #endif /* HAVE_IPV6 */ |
| 5700 | |
| 5701 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5702 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5703 | else |
| 5704 | vty_out (vty, " "); |
| 5705 | |
| 5706 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5707 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5708 | else |
| 5709 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5710 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5711 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5712 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5713 | /* Print aspath */ |
| 5714 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5715 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5716 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5717 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5718 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5719 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5720 | |
| 5721 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5722 | } |
| 5723 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5724 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5725 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5726 | struct bgp_info *binfo, int display, safi_t safi) |
| 5727 | { |
| 5728 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5729 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5730 | |
| 5731 | if (!binfo->extra) |
| 5732 | return; |
| 5733 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5734 | /* short status lead text */ |
| 5735 | route_vty_short_status_out (vty, binfo); |
| 5736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5737 | /* print prefix and mask */ |
| 5738 | if (! display) |
| 5739 | route_vty_out_route (p, vty); |
| 5740 | else |
| 5741 | vty_out (vty, "%*s", 17, " "); |
| 5742 | |
| 5743 | /* Print attribute */ |
| 5744 | attr = binfo->attr; |
| 5745 | if (attr) |
| 5746 | { |
| 5747 | if (p->family == AF_INET) |
| 5748 | { |
| 5749 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5750 | vty_out (vty, "%-16s", |
| 5751 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5752 | else |
| 5753 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5754 | } |
| 5755 | #ifdef HAVE_IPV6 |
| 5756 | else if (p->family == AF_INET6) |
| 5757 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5758 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5759 | char buf[BUFSIZ]; |
| 5760 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5761 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5762 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5763 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5764 | buf, BUFSIZ)); |
| 5765 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5766 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5767 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5768 | buf, BUFSIZ), |
| 5769 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5770 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5771 | |
| 5772 | } |
| 5773 | #endif /* HAVE_IPV6 */ |
| 5774 | } |
| 5775 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5776 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5777 | |
| 5778 | vty_out (vty, "notag/%d", label); |
| 5779 | |
| 5780 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5781 | } |
| 5782 | |
| 5783 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5784 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5785 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5786 | struct bgp_info *binfo, int display, safi_t safi) |
| 5787 | { |
| 5788 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5789 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5790 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5791 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5792 | /* short status lead text */ |
| 5793 | route_vty_short_status_out (vty, binfo); |
| 5794 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5795 | /* print prefix and mask */ |
| 5796 | if (! display) |
| 5797 | route_vty_out_route (p, vty); |
| 5798 | else |
| 5799 | vty_out (vty, "%*s", 17, " "); |
| 5800 | |
| 5801 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5802 | len = 17 - len; |
| 5803 | if (len < 1) |
| 5804 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5805 | else |
| 5806 | vty_out (vty, "%*s", len, " "); |
| 5807 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5808 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5809 | |
| 5810 | /* Print attribute */ |
| 5811 | attr = binfo->attr; |
| 5812 | if (attr) |
| 5813 | { |
| 5814 | /* Print aspath */ |
| 5815 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5816 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5817 | |
| 5818 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5819 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5820 | } |
| 5821 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5822 | } |
| 5823 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5824 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5825 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5826 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5827 | struct bgp_info *binfo, int display, safi_t safi) |
| 5828 | { |
| 5829 | struct attr *attr; |
| 5830 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5831 | char timebuf[BGP_UPTIME_LEN]; |
| 5832 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5833 | |
| 5834 | if (!binfo->extra) |
| 5835 | return; |
| 5836 | |
| 5837 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5838 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5839 | /* short status lead text */ |
| 5840 | route_vty_short_status_out (vty, binfo); |
| 5841 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5842 | /* print prefix and mask */ |
| 5843 | if (! display) |
| 5844 | route_vty_out_route (p, vty); |
| 5845 | else |
| 5846 | vty_out (vty, "%*s", 17, " "); |
| 5847 | |
| 5848 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5849 | len = 16 - len; |
| 5850 | if (len < 1) |
| 5851 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5852 | else |
| 5853 | vty_out (vty, "%*s", len, " "); |
| 5854 | |
| 5855 | len = vty_out (vty, "%d", bdi->flap); |
| 5856 | len = 5 - len; |
| 5857 | if (len < 1) |
| 5858 | vty_out (vty, " "); |
| 5859 | else |
| 5860 | vty_out (vty, "%*s ", len, " "); |
| 5861 | |
| 5862 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5863 | timebuf, BGP_UPTIME_LEN)); |
| 5864 | |
| 5865 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5866 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5867 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5868 | else |
| 5869 | vty_out (vty, "%*s ", 8, " "); |
| 5870 | |
| 5871 | /* Print attribute */ |
| 5872 | attr = binfo->attr; |
| 5873 | if (attr) |
| 5874 | { |
| 5875 | /* Print aspath */ |
| 5876 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5877 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5878 | |
| 5879 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5880 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5881 | } |
| 5882 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5883 | } |
| 5884 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5885 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5886 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5887 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5888 | { |
| 5889 | char buf[INET6_ADDRSTRLEN]; |
| 5890 | char buf1[BUFSIZ]; |
| 5891 | struct attr *attr; |
| 5892 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5893 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5894 | time_t tbuf; |
| 5895 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5896 | |
| 5897 | attr = binfo->attr; |
| 5898 | |
| 5899 | if (attr) |
| 5900 | { |
| 5901 | /* Line1 display AS-path, Aggregator */ |
| 5902 | if (attr->aspath) |
| 5903 | { |
| 5904 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5905 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5906 | vty_out (vty, "Local"); |
| 5907 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5908 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5909 | } |
| 5910 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5911 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5912 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5913 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5914 | vty_out (vty, ", (stale)"); |
| 5915 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 5916 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5917 | attr->extra->aggregator_as, |
| 5918 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5919 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5920 | vty_out (vty, ", (Received from a RR-client)"); |
| 5921 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5922 | vty_out (vty, ", (Received from a RS-client)"); |
| 5923 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5924 | vty_out (vty, ", (history entry)"); |
| 5925 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5926 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5927 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5928 | |
| 5929 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5930 | if (p->family == AF_INET) |
| 5931 | { |
| 5932 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5933 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5934 | inet_ntoa (attr->nexthop)); |
| 5935 | } |
| 5936 | #ifdef HAVE_IPV6 |
| 5937 | else |
| 5938 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5939 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5940 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5941 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5942 | buf, INET6_ADDRSTRLEN)); |
| 5943 | } |
| 5944 | #endif /* HAVE_IPV6 */ |
| 5945 | |
| 5946 | if (binfo->peer == bgp->peer_self) |
| 5947 | { |
| 5948 | vty_out (vty, " from %s ", |
| 5949 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5950 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5951 | } |
| 5952 | else |
| 5953 | { |
| 5954 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5955 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5956 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 5957 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5958 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5959 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5960 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | else |
| 5962 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5963 | } |
| 5964 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5965 | |
| 5966 | #ifdef HAVE_IPV6 |
| 5967 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5968 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5969 | { |
| 5970 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5971 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5972 | buf, INET6_ADDRSTRLEN), |
| 5973 | VTY_NEWLINE); |
| 5974 | } |
| 5975 | #endif /* HAVE_IPV6 */ |
| 5976 | |
| 5977 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5978 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5979 | |
| 5980 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5981 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5982 | |
| 5983 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5984 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5985 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5986 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5987 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5988 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5989 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5990 | |
| 5991 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5992 | vty_out (vty, ", valid"); |
| 5993 | |
| 5994 | if (binfo->peer != bgp->peer_self) |
| 5995 | { |
| 5996 | if (binfo->peer->as == binfo->peer->local_as) |
| 5997 | vty_out (vty, ", internal"); |
| 5998 | else |
| 5999 | vty_out (vty, ", %s", |
| 6000 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6001 | } |
| 6002 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6003 | vty_out (vty, ", aggregated, local"); |
| 6004 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6005 | vty_out (vty, ", sourced"); |
| 6006 | else |
| 6007 | vty_out (vty, ", sourced, local"); |
| 6008 | |
| 6009 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6010 | vty_out (vty, ", atomic-aggregate"); |
| 6011 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6012 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6013 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6014 | bgp_info_mpath_count (binfo))) |
| 6015 | vty_out (vty, ", multipath"); |
| 6016 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6018 | vty_out (vty, ", best"); |
| 6019 | |
| 6020 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6021 | |
| 6022 | /* Line 4 display Community */ |
| 6023 | if (attr->community) |
| 6024 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6025 | VTY_NEWLINE); |
| 6026 | |
| 6027 | /* Line 5 display Extended-community */ |
| 6028 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6029 | vty_out (vty, " Extended Community: %s%s", |
| 6030 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6031 | |
| 6032 | /* Line 6 display Originator, Cluster-id */ |
| 6033 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6034 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6035 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6036 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6038 | vty_out (vty, " Originator: %s", |
| 6039 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6040 | |
| 6041 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6042 | { |
| 6043 | int i; |
| 6044 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6045 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6046 | vty_out (vty, "%s ", |
| 6047 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6048 | } |
| 6049 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6050 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6051 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6052 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6053 | bgp_damp_info_vty (vty, binfo); |
| 6054 | |
| 6055 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6056 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6057 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6058 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6059 | #else |
| 6060 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6061 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6062 | } |
| 6063 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6064 | } |
| 6065 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6066 | #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] | 6067 | #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] | 6068 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6069 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6070 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6071 | |
| 6072 | enum bgp_show_type |
| 6073 | { |
| 6074 | bgp_show_type_normal, |
| 6075 | bgp_show_type_regexp, |
| 6076 | bgp_show_type_prefix_list, |
| 6077 | bgp_show_type_filter_list, |
| 6078 | bgp_show_type_route_map, |
| 6079 | bgp_show_type_neighbor, |
| 6080 | bgp_show_type_cidr_only, |
| 6081 | bgp_show_type_prefix_longer, |
| 6082 | bgp_show_type_community_all, |
| 6083 | bgp_show_type_community, |
| 6084 | bgp_show_type_community_exact, |
| 6085 | bgp_show_type_community_list, |
| 6086 | bgp_show_type_community_list_exact, |
| 6087 | bgp_show_type_flap_statistics, |
| 6088 | bgp_show_type_flap_address, |
| 6089 | bgp_show_type_flap_prefix, |
| 6090 | bgp_show_type_flap_cidr_only, |
| 6091 | bgp_show_type_flap_regexp, |
| 6092 | bgp_show_type_flap_filter_list, |
| 6093 | bgp_show_type_flap_prefix_list, |
| 6094 | bgp_show_type_flap_prefix_longer, |
| 6095 | bgp_show_type_flap_route_map, |
| 6096 | bgp_show_type_flap_neighbor, |
| 6097 | bgp_show_type_dampend_paths, |
| 6098 | bgp_show_type_damp_neighbor |
| 6099 | }; |
| 6100 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6101 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6102 | 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] | 6103 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6104 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6105 | struct bgp_info *ri; |
| 6106 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6107 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6108 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6109 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6110 | |
| 6111 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6112 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6113 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6114 | /* Start processing of routes. */ |
| 6115 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6116 | if (rn->info != NULL) |
| 6117 | { |
| 6118 | display = 0; |
| 6119 | |
| 6120 | for (ri = rn->info; ri; ri = ri->next) |
| 6121 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6122 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6123 | || type == bgp_show_type_flap_address |
| 6124 | || type == bgp_show_type_flap_prefix |
| 6125 | || type == bgp_show_type_flap_cidr_only |
| 6126 | || type == bgp_show_type_flap_regexp |
| 6127 | || type == bgp_show_type_flap_filter_list |
| 6128 | || type == bgp_show_type_flap_prefix_list |
| 6129 | || type == bgp_show_type_flap_prefix_longer |
| 6130 | || type == bgp_show_type_flap_route_map |
| 6131 | || type == bgp_show_type_flap_neighbor |
| 6132 | || type == bgp_show_type_dampend_paths |
| 6133 | || type == bgp_show_type_damp_neighbor) |
| 6134 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6135 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6136 | continue; |
| 6137 | } |
| 6138 | if (type == bgp_show_type_regexp |
| 6139 | || type == bgp_show_type_flap_regexp) |
| 6140 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6141 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6142 | |
| 6143 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6144 | continue; |
| 6145 | } |
| 6146 | if (type == bgp_show_type_prefix_list |
| 6147 | || type == bgp_show_type_flap_prefix_list) |
| 6148 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6149 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6150 | |
| 6151 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6152 | continue; |
| 6153 | } |
| 6154 | if (type == bgp_show_type_filter_list |
| 6155 | || type == bgp_show_type_flap_filter_list) |
| 6156 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6157 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6158 | |
| 6159 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6160 | continue; |
| 6161 | } |
| 6162 | if (type == bgp_show_type_route_map |
| 6163 | || type == bgp_show_type_flap_route_map) |
| 6164 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6165 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6166 | struct bgp_info binfo; |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 6167 | struct attr dummy_attr = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6168 | int ret; |
| 6169 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6170 | bgp_attr_dup (&dummy_attr, ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6171 | binfo.peer = ri->peer; |
| 6172 | binfo.attr = &dummy_attr; |
| 6173 | |
| 6174 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6175 | |
| 6176 | bgp_attr_extra_free (&dummy_attr); |
| 6177 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6178 | if (ret == RMAP_DENYMATCH) |
| 6179 | continue; |
| 6180 | } |
| 6181 | if (type == bgp_show_type_neighbor |
| 6182 | || type == bgp_show_type_flap_neighbor |
| 6183 | || type == bgp_show_type_damp_neighbor) |
| 6184 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6185 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6186 | |
| 6187 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6188 | continue; |
| 6189 | } |
| 6190 | if (type == bgp_show_type_cidr_only |
| 6191 | || type == bgp_show_type_flap_cidr_only) |
| 6192 | { |
| 6193 | u_int32_t destination; |
| 6194 | |
| 6195 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6196 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6197 | continue; |
| 6198 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6199 | continue; |
| 6200 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6201 | continue; |
| 6202 | } |
| 6203 | if (type == bgp_show_type_prefix_longer |
| 6204 | || type == bgp_show_type_flap_prefix_longer) |
| 6205 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6206 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6207 | |
| 6208 | if (! prefix_match (p, &rn->p)) |
| 6209 | continue; |
| 6210 | } |
| 6211 | if (type == bgp_show_type_community_all) |
| 6212 | { |
| 6213 | if (! ri->attr->community) |
| 6214 | continue; |
| 6215 | } |
| 6216 | if (type == bgp_show_type_community) |
| 6217 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6218 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6219 | |
| 6220 | if (! ri->attr->community || |
| 6221 | ! community_match (ri->attr->community, com)) |
| 6222 | continue; |
| 6223 | } |
| 6224 | if (type == bgp_show_type_community_exact) |
| 6225 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6226 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6227 | |
| 6228 | if (! ri->attr->community || |
| 6229 | ! community_cmp (ri->attr->community, com)) |
| 6230 | continue; |
| 6231 | } |
| 6232 | if (type == bgp_show_type_community_list) |
| 6233 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6234 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6235 | |
| 6236 | if (! community_list_match (ri->attr->community, list)) |
| 6237 | continue; |
| 6238 | } |
| 6239 | if (type == bgp_show_type_community_list_exact) |
| 6240 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6241 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6242 | |
| 6243 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6244 | continue; |
| 6245 | } |
| 6246 | if (type == bgp_show_type_flap_address |
| 6247 | || type == bgp_show_type_flap_prefix) |
| 6248 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6249 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6250 | |
| 6251 | if (! prefix_match (&rn->p, p)) |
| 6252 | continue; |
| 6253 | |
| 6254 | if (type == bgp_show_type_flap_prefix) |
| 6255 | if (p->prefixlen != rn->p.prefixlen) |
| 6256 | continue; |
| 6257 | } |
| 6258 | if (type == bgp_show_type_dampend_paths |
| 6259 | || type == bgp_show_type_damp_neighbor) |
| 6260 | { |
| 6261 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6262 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6263 | continue; |
| 6264 | } |
| 6265 | |
| 6266 | if (header) |
| 6267 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6268 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6269 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6270 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6271 | if (type == bgp_show_type_dampend_paths |
| 6272 | || type == bgp_show_type_damp_neighbor) |
| 6273 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6274 | else if (type == bgp_show_type_flap_statistics |
| 6275 | || type == bgp_show_type_flap_address |
| 6276 | || type == bgp_show_type_flap_prefix |
| 6277 | || type == bgp_show_type_flap_cidr_only |
| 6278 | || type == bgp_show_type_flap_regexp |
| 6279 | || type == bgp_show_type_flap_filter_list |
| 6280 | || type == bgp_show_type_flap_prefix_list |
| 6281 | || type == bgp_show_type_flap_prefix_longer |
| 6282 | || type == bgp_show_type_flap_route_map |
| 6283 | || type == bgp_show_type_flap_neighbor) |
| 6284 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6285 | else |
| 6286 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6287 | header = 0; |
| 6288 | } |
| 6289 | |
| 6290 | if (type == bgp_show_type_dampend_paths |
| 6291 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6292 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6293 | else if (type == bgp_show_type_flap_statistics |
| 6294 | || type == bgp_show_type_flap_address |
| 6295 | || type == bgp_show_type_flap_prefix |
| 6296 | || type == bgp_show_type_flap_cidr_only |
| 6297 | || type == bgp_show_type_flap_regexp |
| 6298 | || type == bgp_show_type_flap_filter_list |
| 6299 | || type == bgp_show_type_flap_prefix_list |
| 6300 | || type == bgp_show_type_flap_prefix_longer |
| 6301 | || type == bgp_show_type_flap_route_map |
| 6302 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6303 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6304 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6305 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6306 | display++; |
| 6307 | } |
| 6308 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6309 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6310 | } |
| 6311 | |
| 6312 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6313 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6314 | { |
| 6315 | if (type == bgp_show_type_normal) |
| 6316 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6317 | } |
| 6318 | else |
| 6319 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6320 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6321 | |
| 6322 | return CMD_SUCCESS; |
| 6323 | } |
| 6324 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6325 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6326 | 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] | 6327 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6328 | { |
| 6329 | struct bgp_table *table; |
| 6330 | |
| 6331 | if (bgp == NULL) { |
| 6332 | bgp = bgp_get_default (); |
| 6333 | } |
| 6334 | |
| 6335 | if (bgp == NULL) |
| 6336 | { |
| 6337 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6338 | return CMD_WARNING; |
| 6339 | } |
| 6340 | |
| 6341 | |
| 6342 | table = bgp->rib[afi][safi]; |
| 6343 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6344 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6345 | } |
| 6346 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6347 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6348 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6349 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6350 | struct bgp_node *rn, |
| 6351 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6352 | { |
| 6353 | struct bgp_info *ri; |
| 6354 | struct prefix *p; |
| 6355 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6356 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6357 | char buf1[INET6_ADDRSTRLEN]; |
| 6358 | char buf2[INET6_ADDRSTRLEN]; |
| 6359 | int count = 0; |
| 6360 | int best = 0; |
| 6361 | int suppress = 0; |
| 6362 | int no_export = 0; |
| 6363 | int no_advertise = 0; |
| 6364 | int local_as = 0; |
| 6365 | int first = 0; |
| 6366 | |
| 6367 | p = &rn->p; |
| 6368 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6369 | (safi == SAFI_MPLS_VPN ? |
| 6370 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6371 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6372 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6373 | p->prefixlen, VTY_NEWLINE); |
| 6374 | |
| 6375 | for (ri = rn->info; ri; ri = ri->next) |
| 6376 | { |
| 6377 | count++; |
| 6378 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6379 | { |
| 6380 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6381 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6382 | suppress = 1; |
| 6383 | if (ri->attr->community != NULL) |
| 6384 | { |
| 6385 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6386 | no_advertise = 1; |
| 6387 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6388 | no_export = 1; |
| 6389 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6390 | local_as = 1; |
| 6391 | } |
| 6392 | } |
| 6393 | } |
| 6394 | |
| 6395 | vty_out (vty, "Paths: (%d available", count); |
| 6396 | if (best) |
| 6397 | { |
| 6398 | vty_out (vty, ", best #%d", best); |
| 6399 | if (safi == SAFI_UNICAST) |
| 6400 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6401 | } |
| 6402 | else |
| 6403 | vty_out (vty, ", no best path"); |
| 6404 | if (no_advertise) |
| 6405 | vty_out (vty, ", not advertised to any peer"); |
| 6406 | else if (no_export) |
| 6407 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6408 | else if (local_as) |
| 6409 | vty_out (vty, ", not advertised outside local AS"); |
| 6410 | if (suppress) |
| 6411 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6412 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6413 | |
| 6414 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6415 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6416 | { |
| 6417 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6418 | { |
| 6419 | if (! first) |
| 6420 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6421 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6422 | first = 1; |
| 6423 | } |
| 6424 | } |
| 6425 | if (! first) |
| 6426 | vty_out (vty, " Not advertised to any peer"); |
| 6427 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6428 | } |
| 6429 | |
| 6430 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6431 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6432 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6433 | struct bgp_table *rib, const char *ip_str, |
| 6434 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6435 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6436 | { |
| 6437 | int ret; |
| 6438 | int header; |
| 6439 | int display = 0; |
| 6440 | struct prefix match; |
| 6441 | struct bgp_node *rn; |
| 6442 | struct bgp_node *rm; |
| 6443 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6444 | struct bgp_table *table; |
| 6445 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6446 | /* Check IP address argument. */ |
| 6447 | ret = str2prefix (ip_str, &match); |
| 6448 | if (! ret) |
| 6449 | { |
| 6450 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6451 | return CMD_WARNING; |
| 6452 | } |
| 6453 | |
| 6454 | match.family = afi2family (afi); |
| 6455 | |
| 6456 | if (safi == SAFI_MPLS_VPN) |
| 6457 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6458 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6459 | { |
| 6460 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6461 | continue; |
| 6462 | |
| 6463 | if ((table = rn->info) != NULL) |
| 6464 | { |
| 6465 | header = 1; |
| 6466 | |
| 6467 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6468 | { |
| 6469 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6470 | { |
| 6471 | bgp_unlock_node (rm); |
| 6472 | continue; |
| 6473 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6474 | |
| 6475 | for (ri = rm->info; ri; ri = ri->next) |
| 6476 | { |
| 6477 | if (header) |
| 6478 | { |
| 6479 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6480 | AFI_IP, SAFI_MPLS_VPN); |
| 6481 | |
| 6482 | header = 0; |
| 6483 | } |
| 6484 | display++; |
| 6485 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6486 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6487 | |
| 6488 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6489 | } |
| 6490 | } |
| 6491 | } |
| 6492 | } |
| 6493 | else |
| 6494 | { |
| 6495 | header = 1; |
| 6496 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6497 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6498 | { |
| 6499 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6500 | { |
| 6501 | for (ri = rn->info; ri; ri = ri->next) |
| 6502 | { |
| 6503 | if (header) |
| 6504 | { |
| 6505 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6506 | header = 0; |
| 6507 | } |
| 6508 | display++; |
| 6509 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6510 | } |
| 6511 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6512 | |
| 6513 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6514 | } |
| 6515 | } |
| 6516 | |
| 6517 | if (! display) |
| 6518 | { |
| 6519 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6520 | return CMD_WARNING; |
| 6521 | } |
| 6522 | |
| 6523 | return CMD_SUCCESS; |
| 6524 | } |
| 6525 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6526 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6527 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6528 | 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] | 6529 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6530 | int prefix_check) |
| 6531 | { |
| 6532 | struct bgp *bgp; |
| 6533 | |
| 6534 | /* BGP structure lookup. */ |
| 6535 | if (view_name) |
| 6536 | { |
| 6537 | bgp = bgp_lookup_by_name (view_name); |
| 6538 | if (bgp == NULL) |
| 6539 | { |
| 6540 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6541 | return CMD_WARNING; |
| 6542 | } |
| 6543 | } |
| 6544 | else |
| 6545 | { |
| 6546 | bgp = bgp_get_default (); |
| 6547 | if (bgp == NULL) |
| 6548 | { |
| 6549 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6550 | return CMD_WARNING; |
| 6551 | } |
| 6552 | } |
| 6553 | |
| 6554 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6555 | afi, safi, prd, prefix_check); |
| 6556 | } |
| 6557 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6558 | /* BGP route print out function. */ |
| 6559 | DEFUN (show_ip_bgp, |
| 6560 | show_ip_bgp_cmd, |
| 6561 | "show ip bgp", |
| 6562 | SHOW_STR |
| 6563 | IP_STR |
| 6564 | BGP_STR) |
| 6565 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6566 | 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] | 6567 | } |
| 6568 | |
| 6569 | DEFUN (show_ip_bgp_ipv4, |
| 6570 | show_ip_bgp_ipv4_cmd, |
| 6571 | "show ip bgp ipv4 (unicast|multicast)", |
| 6572 | SHOW_STR |
| 6573 | IP_STR |
| 6574 | BGP_STR |
| 6575 | "Address family\n" |
| 6576 | "Address Family modifier\n" |
| 6577 | "Address Family modifier\n") |
| 6578 | { |
| 6579 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6580 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6581 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6582 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6583 | 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] | 6584 | } |
| 6585 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6586 | ALIAS (show_ip_bgp_ipv4, |
| 6587 | show_bgp_ipv4_safi_cmd, |
| 6588 | "show bgp ipv4 (unicast|multicast)", |
| 6589 | SHOW_STR |
| 6590 | BGP_STR |
| 6591 | "Address family\n" |
| 6592 | "Address Family modifier\n" |
| 6593 | "Address Family modifier\n") |
| 6594 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6595 | DEFUN (show_ip_bgp_route, |
| 6596 | show_ip_bgp_route_cmd, |
| 6597 | "show ip bgp A.B.C.D", |
| 6598 | SHOW_STR |
| 6599 | IP_STR |
| 6600 | BGP_STR |
| 6601 | "Network in the BGP routing table to display\n") |
| 6602 | { |
| 6603 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6604 | } |
| 6605 | |
| 6606 | DEFUN (show_ip_bgp_ipv4_route, |
| 6607 | show_ip_bgp_ipv4_route_cmd, |
| 6608 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6609 | SHOW_STR |
| 6610 | IP_STR |
| 6611 | BGP_STR |
| 6612 | "Address family\n" |
| 6613 | "Address Family modifier\n" |
| 6614 | "Address Family modifier\n" |
| 6615 | "Network in the BGP routing table to display\n") |
| 6616 | { |
| 6617 | if (strncmp (argv[0], "m", 1) == 0) |
| 6618 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6619 | |
| 6620 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6621 | } |
| 6622 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6623 | ALIAS (show_ip_bgp_ipv4_route, |
| 6624 | show_bgp_ipv4_safi_route_cmd, |
| 6625 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6626 | SHOW_STR |
| 6627 | BGP_STR |
| 6628 | "Address family\n" |
| 6629 | "Address Family modifier\n" |
| 6630 | "Address Family modifier\n" |
| 6631 | "Network in the BGP routing table to display\n") |
| 6632 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6633 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6634 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6635 | "show ip bgp vpnv4 all A.B.C.D", |
| 6636 | SHOW_STR |
| 6637 | IP_STR |
| 6638 | BGP_STR |
| 6639 | "Display VPNv4 NLRI specific information\n" |
| 6640 | "Display information about all VPNv4 NLRIs\n" |
| 6641 | "Network in the BGP routing table to display\n") |
| 6642 | { |
| 6643 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6644 | } |
| 6645 | |
| 6646 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6647 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6648 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6649 | SHOW_STR |
| 6650 | IP_STR |
| 6651 | BGP_STR |
| 6652 | "Display VPNv4 NLRI specific information\n" |
| 6653 | "Display information for a route distinguisher\n" |
| 6654 | "VPN Route Distinguisher\n" |
| 6655 | "Network in the BGP routing table to display\n") |
| 6656 | { |
| 6657 | int ret; |
| 6658 | struct prefix_rd prd; |
| 6659 | |
| 6660 | ret = str2prefix_rd (argv[0], &prd); |
| 6661 | if (! ret) |
| 6662 | { |
| 6663 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6664 | return CMD_WARNING; |
| 6665 | } |
| 6666 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6667 | } |
| 6668 | |
| 6669 | DEFUN (show_ip_bgp_prefix, |
| 6670 | show_ip_bgp_prefix_cmd, |
| 6671 | "show ip bgp A.B.C.D/M", |
| 6672 | SHOW_STR |
| 6673 | IP_STR |
| 6674 | BGP_STR |
| 6675 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6676 | { |
| 6677 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6678 | } |
| 6679 | |
| 6680 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6681 | show_ip_bgp_ipv4_prefix_cmd, |
| 6682 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6683 | SHOW_STR |
| 6684 | IP_STR |
| 6685 | BGP_STR |
| 6686 | "Address family\n" |
| 6687 | "Address Family modifier\n" |
| 6688 | "Address Family modifier\n" |
| 6689 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6690 | { |
| 6691 | if (strncmp (argv[0], "m", 1) == 0) |
| 6692 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6693 | |
| 6694 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6695 | } |
| 6696 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6697 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6698 | show_bgp_ipv4_safi_prefix_cmd, |
| 6699 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6700 | SHOW_STR |
| 6701 | BGP_STR |
| 6702 | "Address family\n" |
| 6703 | "Address Family modifier\n" |
| 6704 | "Address Family modifier\n" |
| 6705 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6706 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6707 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6708 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6709 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6710 | SHOW_STR |
| 6711 | IP_STR |
| 6712 | BGP_STR |
| 6713 | "Display VPNv4 NLRI specific information\n" |
| 6714 | "Display information about all VPNv4 NLRIs\n" |
| 6715 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6716 | { |
| 6717 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6718 | } |
| 6719 | |
| 6720 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6721 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6722 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6723 | SHOW_STR |
| 6724 | IP_STR |
| 6725 | BGP_STR |
| 6726 | "Display VPNv4 NLRI specific information\n" |
| 6727 | "Display information for a route distinguisher\n" |
| 6728 | "VPN Route Distinguisher\n" |
| 6729 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6730 | { |
| 6731 | int ret; |
| 6732 | struct prefix_rd prd; |
| 6733 | |
| 6734 | ret = str2prefix_rd (argv[0], &prd); |
| 6735 | if (! ret) |
| 6736 | { |
| 6737 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6738 | return CMD_WARNING; |
| 6739 | } |
| 6740 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6741 | } |
| 6742 | |
| 6743 | DEFUN (show_ip_bgp_view, |
| 6744 | show_ip_bgp_view_cmd, |
| 6745 | "show ip bgp view WORD", |
| 6746 | SHOW_STR |
| 6747 | IP_STR |
| 6748 | BGP_STR |
| 6749 | "BGP view\n" |
| 6750 | "BGP view name\n") |
| 6751 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6752 | struct bgp *bgp; |
| 6753 | |
| 6754 | /* BGP structure lookup. */ |
| 6755 | bgp = bgp_lookup_by_name (argv[0]); |
| 6756 | if (bgp == NULL) |
| 6757 | { |
| 6758 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6759 | return CMD_WARNING; |
| 6760 | } |
| 6761 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6762 | 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] | 6763 | } |
| 6764 | |
| 6765 | DEFUN (show_ip_bgp_view_route, |
| 6766 | show_ip_bgp_view_route_cmd, |
| 6767 | "show ip bgp view WORD A.B.C.D", |
| 6768 | SHOW_STR |
| 6769 | IP_STR |
| 6770 | BGP_STR |
| 6771 | "BGP view\n" |
| 6772 | "BGP view name\n" |
| 6773 | "Network in the BGP routing table to display\n") |
| 6774 | { |
| 6775 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6776 | } |
| 6777 | |
| 6778 | DEFUN (show_ip_bgp_view_prefix, |
| 6779 | show_ip_bgp_view_prefix_cmd, |
| 6780 | "show ip bgp view WORD A.B.C.D/M", |
| 6781 | SHOW_STR |
| 6782 | IP_STR |
| 6783 | BGP_STR |
| 6784 | "BGP view\n" |
| 6785 | "BGP view name\n" |
| 6786 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6787 | { |
| 6788 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6789 | } |
| 6790 | |
| 6791 | #ifdef HAVE_IPV6 |
| 6792 | DEFUN (show_bgp, |
| 6793 | show_bgp_cmd, |
| 6794 | "show bgp", |
| 6795 | SHOW_STR |
| 6796 | BGP_STR) |
| 6797 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6798 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6799 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6800 | } |
| 6801 | |
| 6802 | ALIAS (show_bgp, |
| 6803 | show_bgp_ipv6_cmd, |
| 6804 | "show bgp ipv6", |
| 6805 | SHOW_STR |
| 6806 | BGP_STR |
| 6807 | "Address family\n") |
| 6808 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6809 | DEFUN (show_bgp_ipv6_safi, |
| 6810 | show_bgp_ipv6_safi_cmd, |
| 6811 | "show bgp ipv6 (unicast|multicast)", |
| 6812 | SHOW_STR |
| 6813 | BGP_STR |
| 6814 | "Address family\n" |
| 6815 | "Address Family modifier\n" |
| 6816 | "Address Family modifier\n") |
| 6817 | { |
| 6818 | if (strncmp (argv[0], "m", 1) == 0) |
| 6819 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6820 | NULL); |
| 6821 | |
| 6822 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6823 | } |
| 6824 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6825 | /* old command */ |
| 6826 | DEFUN (show_ipv6_bgp, |
| 6827 | show_ipv6_bgp_cmd, |
| 6828 | "show ipv6 bgp", |
| 6829 | SHOW_STR |
| 6830 | IP_STR |
| 6831 | BGP_STR) |
| 6832 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6833 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6834 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6835 | } |
| 6836 | |
| 6837 | DEFUN (show_bgp_route, |
| 6838 | show_bgp_route_cmd, |
| 6839 | "show bgp X:X::X:X", |
| 6840 | SHOW_STR |
| 6841 | BGP_STR |
| 6842 | "Network in the BGP routing table to display\n") |
| 6843 | { |
| 6844 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6845 | } |
| 6846 | |
| 6847 | ALIAS (show_bgp_route, |
| 6848 | show_bgp_ipv6_route_cmd, |
| 6849 | "show bgp ipv6 X:X::X:X", |
| 6850 | SHOW_STR |
| 6851 | BGP_STR |
| 6852 | "Address family\n" |
| 6853 | "Network in the BGP routing table to display\n") |
| 6854 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6855 | DEFUN (show_bgp_ipv6_safi_route, |
| 6856 | show_bgp_ipv6_safi_route_cmd, |
| 6857 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6858 | SHOW_STR |
| 6859 | BGP_STR |
| 6860 | "Address family\n" |
| 6861 | "Address Family modifier\n" |
| 6862 | "Address Family modifier\n" |
| 6863 | "Network in the BGP routing table to display\n") |
| 6864 | { |
| 6865 | if (strncmp (argv[0], "m", 1) == 0) |
| 6866 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6867 | |
| 6868 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6869 | } |
| 6870 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6871 | /* old command */ |
| 6872 | DEFUN (show_ipv6_bgp_route, |
| 6873 | show_ipv6_bgp_route_cmd, |
| 6874 | "show ipv6 bgp X:X::X:X", |
| 6875 | SHOW_STR |
| 6876 | IP_STR |
| 6877 | BGP_STR |
| 6878 | "Network in the BGP routing table to display\n") |
| 6879 | { |
| 6880 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6881 | } |
| 6882 | |
| 6883 | DEFUN (show_bgp_prefix, |
| 6884 | show_bgp_prefix_cmd, |
| 6885 | "show bgp X:X::X:X/M", |
| 6886 | SHOW_STR |
| 6887 | BGP_STR |
| 6888 | "IPv6 prefix <network>/<length>\n") |
| 6889 | { |
| 6890 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6891 | } |
| 6892 | |
| 6893 | ALIAS (show_bgp_prefix, |
| 6894 | show_bgp_ipv6_prefix_cmd, |
| 6895 | "show bgp ipv6 X:X::X:X/M", |
| 6896 | SHOW_STR |
| 6897 | BGP_STR |
| 6898 | "Address family\n" |
| 6899 | "IPv6 prefix <network>/<length>\n") |
| 6900 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6901 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6902 | show_bgp_ipv6_safi_prefix_cmd, |
| 6903 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 6904 | SHOW_STR |
| 6905 | BGP_STR |
| 6906 | "Address family\n" |
| 6907 | "Address Family modifier\n" |
| 6908 | "Address Family modifier\n" |
| 6909 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6910 | { |
| 6911 | if (strncmp (argv[0], "m", 1) == 0) |
| 6912 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6913 | |
| 6914 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6915 | } |
| 6916 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6917 | /* old command */ |
| 6918 | DEFUN (show_ipv6_bgp_prefix, |
| 6919 | show_ipv6_bgp_prefix_cmd, |
| 6920 | "show ipv6 bgp X:X::X:X/M", |
| 6921 | SHOW_STR |
| 6922 | IP_STR |
| 6923 | BGP_STR |
| 6924 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6925 | { |
| 6926 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6927 | } |
| 6928 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6929 | DEFUN (show_bgp_view, |
| 6930 | show_bgp_view_cmd, |
| 6931 | "show bgp view WORD", |
| 6932 | SHOW_STR |
| 6933 | BGP_STR |
| 6934 | "BGP view\n" |
| 6935 | "View name\n") |
| 6936 | { |
| 6937 | struct bgp *bgp; |
| 6938 | |
| 6939 | /* BGP structure lookup. */ |
| 6940 | bgp = bgp_lookup_by_name (argv[0]); |
| 6941 | if (bgp == NULL) |
| 6942 | { |
| 6943 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6944 | return CMD_WARNING; |
| 6945 | } |
| 6946 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6947 | 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] | 6948 | } |
| 6949 | |
| 6950 | ALIAS (show_bgp_view, |
| 6951 | show_bgp_view_ipv6_cmd, |
| 6952 | "show bgp view WORD ipv6", |
| 6953 | SHOW_STR |
| 6954 | BGP_STR |
| 6955 | "BGP view\n" |
| 6956 | "View name\n" |
| 6957 | "Address family\n") |
| 6958 | |
| 6959 | DEFUN (show_bgp_view_route, |
| 6960 | show_bgp_view_route_cmd, |
| 6961 | "show bgp view WORD X:X::X:X", |
| 6962 | SHOW_STR |
| 6963 | BGP_STR |
| 6964 | "BGP view\n" |
| 6965 | "View name\n" |
| 6966 | "Network in the BGP routing table to display\n") |
| 6967 | { |
| 6968 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6969 | } |
| 6970 | |
| 6971 | ALIAS (show_bgp_view_route, |
| 6972 | show_bgp_view_ipv6_route_cmd, |
| 6973 | "show bgp view WORD ipv6 X:X::X:X", |
| 6974 | SHOW_STR |
| 6975 | BGP_STR |
| 6976 | "BGP view\n" |
| 6977 | "View name\n" |
| 6978 | "Address family\n" |
| 6979 | "Network in the BGP routing table to display\n") |
| 6980 | |
| 6981 | DEFUN (show_bgp_view_prefix, |
| 6982 | show_bgp_view_prefix_cmd, |
| 6983 | "show bgp view WORD X:X::X:X/M", |
| 6984 | SHOW_STR |
| 6985 | BGP_STR |
| 6986 | "BGP view\n" |
| 6987 | "View name\n" |
| 6988 | "IPv6 prefix <network>/<length>\n") |
| 6989 | { |
| 6990 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6991 | } |
| 6992 | |
| 6993 | ALIAS (show_bgp_view_prefix, |
| 6994 | show_bgp_view_ipv6_prefix_cmd, |
| 6995 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 6996 | SHOW_STR |
| 6997 | BGP_STR |
| 6998 | "BGP view\n" |
| 6999 | "View name\n" |
| 7000 | "Address family\n" |
| 7001 | "IPv6 prefix <network>/<length>\n") |
| 7002 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7003 | /* old command */ |
| 7004 | DEFUN (show_ipv6_mbgp, |
| 7005 | show_ipv6_mbgp_cmd, |
| 7006 | "show ipv6 mbgp", |
| 7007 | SHOW_STR |
| 7008 | IP_STR |
| 7009 | MBGP_STR) |
| 7010 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7011 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7012 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7013 | } |
| 7014 | |
| 7015 | /* old command */ |
| 7016 | DEFUN (show_ipv6_mbgp_route, |
| 7017 | show_ipv6_mbgp_route_cmd, |
| 7018 | "show ipv6 mbgp X:X::X:X", |
| 7019 | SHOW_STR |
| 7020 | IP_STR |
| 7021 | MBGP_STR |
| 7022 | "Network in the MBGP routing table to display\n") |
| 7023 | { |
| 7024 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7025 | } |
| 7026 | |
| 7027 | /* old command */ |
| 7028 | DEFUN (show_ipv6_mbgp_prefix, |
| 7029 | show_ipv6_mbgp_prefix_cmd, |
| 7030 | "show ipv6 mbgp X:X::X:X/M", |
| 7031 | SHOW_STR |
| 7032 | IP_STR |
| 7033 | MBGP_STR |
| 7034 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7035 | { |
| 7036 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7037 | } |
| 7038 | #endif |
| 7039 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7040 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7041 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7042 | 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] | 7043 | safi_t safi, enum bgp_show_type type) |
| 7044 | { |
| 7045 | int i; |
| 7046 | struct buffer *b; |
| 7047 | char *regstr; |
| 7048 | int first; |
| 7049 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7050 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7051 | |
| 7052 | first = 0; |
| 7053 | b = buffer_new (1024); |
| 7054 | for (i = 0; i < argc; i++) |
| 7055 | { |
| 7056 | if (first) |
| 7057 | buffer_putc (b, ' '); |
| 7058 | else |
| 7059 | { |
| 7060 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7061 | continue; |
| 7062 | first = 1; |
| 7063 | } |
| 7064 | |
| 7065 | buffer_putstr (b, argv[i]); |
| 7066 | } |
| 7067 | buffer_putc (b, '\0'); |
| 7068 | |
| 7069 | regstr = buffer_getstr (b); |
| 7070 | buffer_free (b); |
| 7071 | |
| 7072 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7073 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7074 | if (! regex) |
| 7075 | { |
| 7076 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7077 | VTY_NEWLINE); |
| 7078 | return CMD_WARNING; |
| 7079 | } |
| 7080 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7081 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7082 | bgp_regex_free (regex); |
| 7083 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7084 | } |
| 7085 | |
| 7086 | DEFUN (show_ip_bgp_regexp, |
| 7087 | show_ip_bgp_regexp_cmd, |
| 7088 | "show ip bgp regexp .LINE", |
| 7089 | SHOW_STR |
| 7090 | IP_STR |
| 7091 | BGP_STR |
| 7092 | "Display routes matching the AS path regular expression\n" |
| 7093 | "A regular-expression to match the BGP AS paths\n") |
| 7094 | { |
| 7095 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7096 | bgp_show_type_regexp); |
| 7097 | } |
| 7098 | |
| 7099 | DEFUN (show_ip_bgp_flap_regexp, |
| 7100 | show_ip_bgp_flap_regexp_cmd, |
| 7101 | "show ip bgp flap-statistics regexp .LINE", |
| 7102 | SHOW_STR |
| 7103 | IP_STR |
| 7104 | BGP_STR |
| 7105 | "Display flap statistics of routes\n" |
| 7106 | "Display routes matching the AS path regular expression\n" |
| 7107 | "A regular-expression to match the BGP AS paths\n") |
| 7108 | { |
| 7109 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7110 | bgp_show_type_flap_regexp); |
| 7111 | } |
| 7112 | |
| 7113 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7114 | show_ip_bgp_ipv4_regexp_cmd, |
| 7115 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7116 | SHOW_STR |
| 7117 | IP_STR |
| 7118 | BGP_STR |
| 7119 | "Address family\n" |
| 7120 | "Address Family modifier\n" |
| 7121 | "Address Family modifier\n" |
| 7122 | "Display routes matching the AS path regular expression\n" |
| 7123 | "A regular-expression to match the BGP AS paths\n") |
| 7124 | { |
| 7125 | if (strncmp (argv[0], "m", 1) == 0) |
| 7126 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7127 | bgp_show_type_regexp); |
| 7128 | |
| 7129 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7130 | bgp_show_type_regexp); |
| 7131 | } |
| 7132 | |
| 7133 | #ifdef HAVE_IPV6 |
| 7134 | DEFUN (show_bgp_regexp, |
| 7135 | show_bgp_regexp_cmd, |
| 7136 | "show bgp regexp .LINE", |
| 7137 | SHOW_STR |
| 7138 | BGP_STR |
| 7139 | "Display routes matching the AS path regular expression\n" |
| 7140 | "A regular-expression to match the BGP AS paths\n") |
| 7141 | { |
| 7142 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7143 | bgp_show_type_regexp); |
| 7144 | } |
| 7145 | |
| 7146 | ALIAS (show_bgp_regexp, |
| 7147 | show_bgp_ipv6_regexp_cmd, |
| 7148 | "show bgp ipv6 regexp .LINE", |
| 7149 | SHOW_STR |
| 7150 | BGP_STR |
| 7151 | "Address family\n" |
| 7152 | "Display routes matching the AS path regular expression\n" |
| 7153 | "A regular-expression to match the BGP AS paths\n") |
| 7154 | |
| 7155 | /* old command */ |
| 7156 | DEFUN (show_ipv6_bgp_regexp, |
| 7157 | show_ipv6_bgp_regexp_cmd, |
| 7158 | "show ipv6 bgp regexp .LINE", |
| 7159 | SHOW_STR |
| 7160 | IP_STR |
| 7161 | BGP_STR |
| 7162 | "Display routes matching the AS path regular expression\n" |
| 7163 | "A regular-expression to match the BGP AS paths\n") |
| 7164 | { |
| 7165 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7166 | bgp_show_type_regexp); |
| 7167 | } |
| 7168 | |
| 7169 | /* old command */ |
| 7170 | DEFUN (show_ipv6_mbgp_regexp, |
| 7171 | show_ipv6_mbgp_regexp_cmd, |
| 7172 | "show ipv6 mbgp regexp .LINE", |
| 7173 | SHOW_STR |
| 7174 | IP_STR |
| 7175 | BGP_STR |
| 7176 | "Display routes matching the AS path regular expression\n" |
| 7177 | "A regular-expression to match the MBGP AS paths\n") |
| 7178 | { |
| 7179 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7180 | bgp_show_type_regexp); |
| 7181 | } |
| 7182 | #endif /* HAVE_IPV6 */ |
| 7183 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7184 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7185 | 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] | 7186 | safi_t safi, enum bgp_show_type type) |
| 7187 | { |
| 7188 | struct prefix_list *plist; |
| 7189 | |
| 7190 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7191 | if (plist == NULL) |
| 7192 | { |
| 7193 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7194 | prefix_list_str, VTY_NEWLINE); |
| 7195 | return CMD_WARNING; |
| 7196 | } |
| 7197 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7198 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7199 | } |
| 7200 | |
| 7201 | DEFUN (show_ip_bgp_prefix_list, |
| 7202 | show_ip_bgp_prefix_list_cmd, |
| 7203 | "show ip bgp prefix-list WORD", |
| 7204 | SHOW_STR |
| 7205 | IP_STR |
| 7206 | BGP_STR |
| 7207 | "Display routes conforming to the prefix-list\n" |
| 7208 | "IP prefix-list name\n") |
| 7209 | { |
| 7210 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7211 | bgp_show_type_prefix_list); |
| 7212 | } |
| 7213 | |
| 7214 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7215 | show_ip_bgp_flap_prefix_list_cmd, |
| 7216 | "show ip bgp flap-statistics prefix-list WORD", |
| 7217 | SHOW_STR |
| 7218 | IP_STR |
| 7219 | BGP_STR |
| 7220 | "Display flap statistics of routes\n" |
| 7221 | "Display routes conforming to the prefix-list\n" |
| 7222 | "IP prefix-list name\n") |
| 7223 | { |
| 7224 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7225 | bgp_show_type_flap_prefix_list); |
| 7226 | } |
| 7227 | |
| 7228 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7229 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7230 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7231 | SHOW_STR |
| 7232 | IP_STR |
| 7233 | BGP_STR |
| 7234 | "Address family\n" |
| 7235 | "Address Family modifier\n" |
| 7236 | "Address Family modifier\n" |
| 7237 | "Display routes conforming to the prefix-list\n" |
| 7238 | "IP prefix-list name\n") |
| 7239 | { |
| 7240 | if (strncmp (argv[0], "m", 1) == 0) |
| 7241 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7242 | bgp_show_type_prefix_list); |
| 7243 | |
| 7244 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7245 | bgp_show_type_prefix_list); |
| 7246 | } |
| 7247 | |
| 7248 | #ifdef HAVE_IPV6 |
| 7249 | DEFUN (show_bgp_prefix_list, |
| 7250 | show_bgp_prefix_list_cmd, |
| 7251 | "show bgp prefix-list WORD", |
| 7252 | SHOW_STR |
| 7253 | BGP_STR |
| 7254 | "Display routes conforming to the prefix-list\n" |
| 7255 | "IPv6 prefix-list name\n") |
| 7256 | { |
| 7257 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7258 | bgp_show_type_prefix_list); |
| 7259 | } |
| 7260 | |
| 7261 | ALIAS (show_bgp_prefix_list, |
| 7262 | show_bgp_ipv6_prefix_list_cmd, |
| 7263 | "show bgp ipv6 prefix-list WORD", |
| 7264 | SHOW_STR |
| 7265 | BGP_STR |
| 7266 | "Address family\n" |
| 7267 | "Display routes conforming to the prefix-list\n" |
| 7268 | "IPv6 prefix-list name\n") |
| 7269 | |
| 7270 | /* old command */ |
| 7271 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7272 | show_ipv6_bgp_prefix_list_cmd, |
| 7273 | "show ipv6 bgp prefix-list WORD", |
| 7274 | SHOW_STR |
| 7275 | IPV6_STR |
| 7276 | BGP_STR |
| 7277 | "Display routes matching the prefix-list\n" |
| 7278 | "IPv6 prefix-list name\n") |
| 7279 | { |
| 7280 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7281 | bgp_show_type_prefix_list); |
| 7282 | } |
| 7283 | |
| 7284 | /* old command */ |
| 7285 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7286 | show_ipv6_mbgp_prefix_list_cmd, |
| 7287 | "show ipv6 mbgp prefix-list WORD", |
| 7288 | SHOW_STR |
| 7289 | IPV6_STR |
| 7290 | MBGP_STR |
| 7291 | "Display routes matching the prefix-list\n" |
| 7292 | "IPv6 prefix-list name\n") |
| 7293 | { |
| 7294 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7295 | bgp_show_type_prefix_list); |
| 7296 | } |
| 7297 | #endif /* HAVE_IPV6 */ |
| 7298 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7299 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7300 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7301 | safi_t safi, enum bgp_show_type type) |
| 7302 | { |
| 7303 | struct as_list *as_list; |
| 7304 | |
| 7305 | as_list = as_list_lookup (filter); |
| 7306 | if (as_list == NULL) |
| 7307 | { |
| 7308 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7309 | return CMD_WARNING; |
| 7310 | } |
| 7311 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7312 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7313 | } |
| 7314 | |
| 7315 | DEFUN (show_ip_bgp_filter_list, |
| 7316 | show_ip_bgp_filter_list_cmd, |
| 7317 | "show ip bgp filter-list WORD", |
| 7318 | SHOW_STR |
| 7319 | IP_STR |
| 7320 | BGP_STR |
| 7321 | "Display routes conforming to the filter-list\n" |
| 7322 | "Regular expression access list name\n") |
| 7323 | { |
| 7324 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7325 | bgp_show_type_filter_list); |
| 7326 | } |
| 7327 | |
| 7328 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7329 | show_ip_bgp_flap_filter_list_cmd, |
| 7330 | "show ip bgp flap-statistics filter-list WORD", |
| 7331 | SHOW_STR |
| 7332 | IP_STR |
| 7333 | BGP_STR |
| 7334 | "Display flap statistics of routes\n" |
| 7335 | "Display routes conforming to the filter-list\n" |
| 7336 | "Regular expression access list name\n") |
| 7337 | { |
| 7338 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7339 | bgp_show_type_flap_filter_list); |
| 7340 | } |
| 7341 | |
| 7342 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7343 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7344 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7345 | SHOW_STR |
| 7346 | IP_STR |
| 7347 | BGP_STR |
| 7348 | "Address family\n" |
| 7349 | "Address Family modifier\n" |
| 7350 | "Address Family modifier\n" |
| 7351 | "Display routes conforming to the filter-list\n" |
| 7352 | "Regular expression access list name\n") |
| 7353 | { |
| 7354 | if (strncmp (argv[0], "m", 1) == 0) |
| 7355 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7356 | bgp_show_type_filter_list); |
| 7357 | |
| 7358 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7359 | bgp_show_type_filter_list); |
| 7360 | } |
| 7361 | |
| 7362 | #ifdef HAVE_IPV6 |
| 7363 | DEFUN (show_bgp_filter_list, |
| 7364 | show_bgp_filter_list_cmd, |
| 7365 | "show bgp filter-list WORD", |
| 7366 | SHOW_STR |
| 7367 | BGP_STR |
| 7368 | "Display routes conforming to the filter-list\n" |
| 7369 | "Regular expression access list name\n") |
| 7370 | { |
| 7371 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7372 | bgp_show_type_filter_list); |
| 7373 | } |
| 7374 | |
| 7375 | ALIAS (show_bgp_filter_list, |
| 7376 | show_bgp_ipv6_filter_list_cmd, |
| 7377 | "show bgp ipv6 filter-list WORD", |
| 7378 | SHOW_STR |
| 7379 | BGP_STR |
| 7380 | "Address family\n" |
| 7381 | "Display routes conforming to the filter-list\n" |
| 7382 | "Regular expression access list name\n") |
| 7383 | |
| 7384 | /* old command */ |
| 7385 | DEFUN (show_ipv6_bgp_filter_list, |
| 7386 | show_ipv6_bgp_filter_list_cmd, |
| 7387 | "show ipv6 bgp filter-list WORD", |
| 7388 | SHOW_STR |
| 7389 | IPV6_STR |
| 7390 | BGP_STR |
| 7391 | "Display routes conforming to the filter-list\n" |
| 7392 | "Regular expression access list name\n") |
| 7393 | { |
| 7394 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7395 | bgp_show_type_filter_list); |
| 7396 | } |
| 7397 | |
| 7398 | /* old command */ |
| 7399 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7400 | show_ipv6_mbgp_filter_list_cmd, |
| 7401 | "show ipv6 mbgp filter-list WORD", |
| 7402 | SHOW_STR |
| 7403 | IPV6_STR |
| 7404 | MBGP_STR |
| 7405 | "Display routes conforming to the filter-list\n" |
| 7406 | "Regular expression access list name\n") |
| 7407 | { |
| 7408 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7409 | bgp_show_type_filter_list); |
| 7410 | } |
| 7411 | #endif /* HAVE_IPV6 */ |
| 7412 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7413 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7414 | 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] | 7415 | safi_t safi, enum bgp_show_type type) |
| 7416 | { |
| 7417 | struct route_map *rmap; |
| 7418 | |
| 7419 | rmap = route_map_lookup_by_name (rmap_str); |
| 7420 | if (! rmap) |
| 7421 | { |
| 7422 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7423 | rmap_str, VTY_NEWLINE); |
| 7424 | return CMD_WARNING; |
| 7425 | } |
| 7426 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7427 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7428 | } |
| 7429 | |
| 7430 | DEFUN (show_ip_bgp_route_map, |
| 7431 | show_ip_bgp_route_map_cmd, |
| 7432 | "show ip bgp route-map WORD", |
| 7433 | SHOW_STR |
| 7434 | IP_STR |
| 7435 | BGP_STR |
| 7436 | "Display routes matching the route-map\n" |
| 7437 | "A route-map to match on\n") |
| 7438 | { |
| 7439 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7440 | bgp_show_type_route_map); |
| 7441 | } |
| 7442 | |
| 7443 | DEFUN (show_ip_bgp_flap_route_map, |
| 7444 | show_ip_bgp_flap_route_map_cmd, |
| 7445 | "show ip bgp flap-statistics route-map WORD", |
| 7446 | SHOW_STR |
| 7447 | IP_STR |
| 7448 | BGP_STR |
| 7449 | "Display flap statistics of routes\n" |
| 7450 | "Display routes matching the route-map\n" |
| 7451 | "A route-map to match on\n") |
| 7452 | { |
| 7453 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7454 | bgp_show_type_flap_route_map); |
| 7455 | } |
| 7456 | |
| 7457 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7458 | show_ip_bgp_ipv4_route_map_cmd, |
| 7459 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7460 | SHOW_STR |
| 7461 | IP_STR |
| 7462 | BGP_STR |
| 7463 | "Address family\n" |
| 7464 | "Address Family modifier\n" |
| 7465 | "Address Family modifier\n" |
| 7466 | "Display routes matching the route-map\n" |
| 7467 | "A route-map to match on\n") |
| 7468 | { |
| 7469 | if (strncmp (argv[0], "m", 1) == 0) |
| 7470 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7471 | bgp_show_type_route_map); |
| 7472 | |
| 7473 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7474 | bgp_show_type_route_map); |
| 7475 | } |
| 7476 | |
| 7477 | DEFUN (show_bgp_route_map, |
| 7478 | show_bgp_route_map_cmd, |
| 7479 | "show bgp route-map WORD", |
| 7480 | SHOW_STR |
| 7481 | BGP_STR |
| 7482 | "Display routes matching the route-map\n" |
| 7483 | "A route-map to match on\n") |
| 7484 | { |
| 7485 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7486 | bgp_show_type_route_map); |
| 7487 | } |
| 7488 | |
| 7489 | ALIAS (show_bgp_route_map, |
| 7490 | show_bgp_ipv6_route_map_cmd, |
| 7491 | "show bgp ipv6 route-map WORD", |
| 7492 | SHOW_STR |
| 7493 | BGP_STR |
| 7494 | "Address family\n" |
| 7495 | "Display routes matching the route-map\n" |
| 7496 | "A route-map to match on\n") |
| 7497 | |
| 7498 | DEFUN (show_ip_bgp_cidr_only, |
| 7499 | show_ip_bgp_cidr_only_cmd, |
| 7500 | "show ip bgp cidr-only", |
| 7501 | SHOW_STR |
| 7502 | IP_STR |
| 7503 | BGP_STR |
| 7504 | "Display only routes with non-natural netmasks\n") |
| 7505 | { |
| 7506 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7507 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7508 | } |
| 7509 | |
| 7510 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7511 | show_ip_bgp_flap_cidr_only_cmd, |
| 7512 | "show ip bgp flap-statistics cidr-only", |
| 7513 | SHOW_STR |
| 7514 | IP_STR |
| 7515 | BGP_STR |
| 7516 | "Display flap statistics of routes\n" |
| 7517 | "Display only routes with non-natural netmasks\n") |
| 7518 | { |
| 7519 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7520 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7521 | } |
| 7522 | |
| 7523 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7524 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7525 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7526 | SHOW_STR |
| 7527 | IP_STR |
| 7528 | BGP_STR |
| 7529 | "Address family\n" |
| 7530 | "Address Family modifier\n" |
| 7531 | "Address Family modifier\n" |
| 7532 | "Display only routes with non-natural netmasks\n") |
| 7533 | { |
| 7534 | if (strncmp (argv[0], "m", 1) == 0) |
| 7535 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7536 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7537 | |
| 7538 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7539 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7540 | } |
| 7541 | |
| 7542 | DEFUN (show_ip_bgp_community_all, |
| 7543 | show_ip_bgp_community_all_cmd, |
| 7544 | "show ip bgp community", |
| 7545 | SHOW_STR |
| 7546 | IP_STR |
| 7547 | BGP_STR |
| 7548 | "Display routes matching the communities\n") |
| 7549 | { |
| 7550 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7551 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7552 | } |
| 7553 | |
| 7554 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7555 | show_ip_bgp_ipv4_community_all_cmd, |
| 7556 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7557 | SHOW_STR |
| 7558 | IP_STR |
| 7559 | BGP_STR |
| 7560 | "Address family\n" |
| 7561 | "Address Family modifier\n" |
| 7562 | "Address Family modifier\n" |
| 7563 | "Display routes matching the communities\n") |
| 7564 | { |
| 7565 | if (strncmp (argv[0], "m", 1) == 0) |
| 7566 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7567 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7568 | |
| 7569 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7570 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7571 | } |
| 7572 | |
| 7573 | #ifdef HAVE_IPV6 |
| 7574 | DEFUN (show_bgp_community_all, |
| 7575 | show_bgp_community_all_cmd, |
| 7576 | "show bgp community", |
| 7577 | SHOW_STR |
| 7578 | BGP_STR |
| 7579 | "Display routes matching the communities\n") |
| 7580 | { |
| 7581 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7582 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7583 | } |
| 7584 | |
| 7585 | ALIAS (show_bgp_community_all, |
| 7586 | show_bgp_ipv6_community_all_cmd, |
| 7587 | "show bgp ipv6 community", |
| 7588 | SHOW_STR |
| 7589 | BGP_STR |
| 7590 | "Address family\n" |
| 7591 | "Display routes matching the communities\n") |
| 7592 | |
| 7593 | /* old command */ |
| 7594 | DEFUN (show_ipv6_bgp_community_all, |
| 7595 | show_ipv6_bgp_community_all_cmd, |
| 7596 | "show ipv6 bgp community", |
| 7597 | SHOW_STR |
| 7598 | IPV6_STR |
| 7599 | BGP_STR |
| 7600 | "Display routes matching the communities\n") |
| 7601 | { |
| 7602 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7603 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7604 | } |
| 7605 | |
| 7606 | /* old command */ |
| 7607 | DEFUN (show_ipv6_mbgp_community_all, |
| 7608 | show_ipv6_mbgp_community_all_cmd, |
| 7609 | "show ipv6 mbgp community", |
| 7610 | SHOW_STR |
| 7611 | IPV6_STR |
| 7612 | MBGP_STR |
| 7613 | "Display routes matching the communities\n") |
| 7614 | { |
| 7615 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7616 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7617 | } |
| 7618 | #endif /* HAVE_IPV6 */ |
| 7619 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7620 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7621 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7622 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7623 | { |
| 7624 | struct community *com; |
| 7625 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7626 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7627 | int i; |
| 7628 | char *str; |
| 7629 | int first = 0; |
| 7630 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7631 | /* BGP structure lookup */ |
| 7632 | if (view_name) |
| 7633 | { |
| 7634 | bgp = bgp_lookup_by_name (view_name); |
| 7635 | if (bgp == NULL) |
| 7636 | { |
| 7637 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7638 | return CMD_WARNING; |
| 7639 | } |
| 7640 | } |
| 7641 | else |
| 7642 | { |
| 7643 | bgp = bgp_get_default (); |
| 7644 | if (bgp == NULL) |
| 7645 | { |
| 7646 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7647 | return CMD_WARNING; |
| 7648 | } |
| 7649 | } |
| 7650 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7651 | b = buffer_new (1024); |
| 7652 | for (i = 0; i < argc; i++) |
| 7653 | { |
| 7654 | if (first) |
| 7655 | buffer_putc (b, ' '); |
| 7656 | else |
| 7657 | { |
| 7658 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7659 | continue; |
| 7660 | first = 1; |
| 7661 | } |
| 7662 | |
| 7663 | buffer_putstr (b, argv[i]); |
| 7664 | } |
| 7665 | buffer_putc (b, '\0'); |
| 7666 | |
| 7667 | str = buffer_getstr (b); |
| 7668 | buffer_free (b); |
| 7669 | |
| 7670 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7671 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7672 | if (! com) |
| 7673 | { |
| 7674 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7675 | return CMD_WARNING; |
| 7676 | } |
| 7677 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7678 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7679 | (exact ? bgp_show_type_community_exact : |
| 7680 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7681 | } |
| 7682 | |
| 7683 | DEFUN (show_ip_bgp_community, |
| 7684 | show_ip_bgp_community_cmd, |
| 7685 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7686 | SHOW_STR |
| 7687 | IP_STR |
| 7688 | BGP_STR |
| 7689 | "Display routes matching the communities\n" |
| 7690 | "community number\n" |
| 7691 | "Do not send outside local AS (well-known community)\n" |
| 7692 | "Do not advertise to any peer (well-known community)\n" |
| 7693 | "Do not export to next AS (well-known community)\n") |
| 7694 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7695 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7696 | } |
| 7697 | |
| 7698 | ALIAS (show_ip_bgp_community, |
| 7699 | show_ip_bgp_community2_cmd, |
| 7700 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7701 | SHOW_STR |
| 7702 | IP_STR |
| 7703 | BGP_STR |
| 7704 | "Display routes matching the communities\n" |
| 7705 | "community number\n" |
| 7706 | "Do not send outside local AS (well-known community)\n" |
| 7707 | "Do not advertise to any peer (well-known community)\n" |
| 7708 | "Do not export to next AS (well-known community)\n" |
| 7709 | "community number\n" |
| 7710 | "Do not send outside local AS (well-known community)\n" |
| 7711 | "Do not advertise to any peer (well-known community)\n" |
| 7712 | "Do not export to next AS (well-known community)\n") |
| 7713 | |
| 7714 | ALIAS (show_ip_bgp_community, |
| 7715 | show_ip_bgp_community3_cmd, |
| 7716 | "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)", |
| 7717 | SHOW_STR |
| 7718 | IP_STR |
| 7719 | BGP_STR |
| 7720 | "Display routes matching the communities\n" |
| 7721 | "community number\n" |
| 7722 | "Do not send outside local AS (well-known community)\n" |
| 7723 | "Do not advertise to any peer (well-known community)\n" |
| 7724 | "Do not export to next AS (well-known community)\n" |
| 7725 | "community number\n" |
| 7726 | "Do not send outside local AS (well-known community)\n" |
| 7727 | "Do not advertise to any peer (well-known community)\n" |
| 7728 | "Do not export to next AS (well-known community)\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 | |
| 7734 | ALIAS (show_ip_bgp_community, |
| 7735 | show_ip_bgp_community4_cmd, |
| 7736 | "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)", |
| 7737 | SHOW_STR |
| 7738 | IP_STR |
| 7739 | BGP_STR |
| 7740 | "Display routes matching the communities\n" |
| 7741 | "community number\n" |
| 7742 | "Do not send outside local AS (well-known community)\n" |
| 7743 | "Do not advertise to any peer (well-known community)\n" |
| 7744 | "Do not export to next AS (well-known community)\n" |
| 7745 | "community number\n" |
| 7746 | "Do not send outside local AS (well-known community)\n" |
| 7747 | "Do not advertise to any peer (well-known community)\n" |
| 7748 | "Do not export to next AS (well-known community)\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 | |
| 7758 | DEFUN (show_ip_bgp_ipv4_community, |
| 7759 | show_ip_bgp_ipv4_community_cmd, |
| 7760 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7761 | SHOW_STR |
| 7762 | IP_STR |
| 7763 | BGP_STR |
| 7764 | "Address family\n" |
| 7765 | "Address Family modifier\n" |
| 7766 | "Address Family modifier\n" |
| 7767 | "Display routes matching the communities\n" |
| 7768 | "community number\n" |
| 7769 | "Do not send outside local AS (well-known community)\n" |
| 7770 | "Do not advertise to any peer (well-known community)\n" |
| 7771 | "Do not export to next AS (well-known community)\n") |
| 7772 | { |
| 7773 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7774 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7775 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7776 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7777 | } |
| 7778 | |
| 7779 | ALIAS (show_ip_bgp_ipv4_community, |
| 7780 | show_ip_bgp_ipv4_community2_cmd, |
| 7781 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7782 | SHOW_STR |
| 7783 | IP_STR |
| 7784 | BGP_STR |
| 7785 | "Address family\n" |
| 7786 | "Address Family modifier\n" |
| 7787 | "Address Family modifier\n" |
| 7788 | "Display routes matching the communities\n" |
| 7789 | "community number\n" |
| 7790 | "Do not send outside local AS (well-known community)\n" |
| 7791 | "Do not advertise to any peer (well-known community)\n" |
| 7792 | "Do not export to next AS (well-known community)\n" |
| 7793 | "community number\n" |
| 7794 | "Do not send outside local AS (well-known community)\n" |
| 7795 | "Do not advertise to any peer (well-known community)\n" |
| 7796 | "Do not export to next AS (well-known community)\n") |
| 7797 | |
| 7798 | ALIAS (show_ip_bgp_ipv4_community, |
| 7799 | show_ip_bgp_ipv4_community3_cmd, |
| 7800 | "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)", |
| 7801 | SHOW_STR |
| 7802 | IP_STR |
| 7803 | BGP_STR |
| 7804 | "Address family\n" |
| 7805 | "Address Family modifier\n" |
| 7806 | "Address Family modifier\n" |
| 7807 | "Display routes matching the communities\n" |
| 7808 | "community number\n" |
| 7809 | "Do not send outside local AS (well-known community)\n" |
| 7810 | "Do not advertise to any peer (well-known community)\n" |
| 7811 | "Do not export to next AS (well-known community)\n" |
| 7812 | "community number\n" |
| 7813 | "Do not send outside local AS (well-known community)\n" |
| 7814 | "Do not advertise to any peer (well-known community)\n" |
| 7815 | "Do not export to next AS (well-known community)\n" |
| 7816 | "community number\n" |
| 7817 | "Do not send outside local AS (well-known community)\n" |
| 7818 | "Do not advertise to any peer (well-known community)\n" |
| 7819 | "Do not export to next AS (well-known community)\n") |
| 7820 | |
| 7821 | ALIAS (show_ip_bgp_ipv4_community, |
| 7822 | show_ip_bgp_ipv4_community4_cmd, |
| 7823 | "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)", |
| 7824 | SHOW_STR |
| 7825 | IP_STR |
| 7826 | BGP_STR |
| 7827 | "Address family\n" |
| 7828 | "Address Family modifier\n" |
| 7829 | "Address Family modifier\n" |
| 7830 | "Display routes matching the communities\n" |
| 7831 | "community number\n" |
| 7832 | "Do not send outside local AS (well-known community)\n" |
| 7833 | "Do not advertise to any peer (well-known community)\n" |
| 7834 | "Do not export to next AS (well-known community)\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 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7848 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 7849 | show_bgp_view_afi_safi_community_all_cmd, |
| 7850 | #ifdef HAVE_IPV6 |
| 7851 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
| 7852 | #else |
| 7853 | "show bgp view WORD ipv4 (unicast|multicast) community", |
| 7854 | #endif |
| 7855 | SHOW_STR |
| 7856 | BGP_STR |
| 7857 | "BGP view\n" |
| 7858 | "BGP view name\n" |
| 7859 | "Address family\n" |
| 7860 | #ifdef HAVE_IPV6 |
| 7861 | "Address family\n" |
| 7862 | #endif |
| 7863 | "Address Family modifier\n" |
| 7864 | "Address Family modifier\n" |
| 7865 | "Display routes containing communities\n") |
| 7866 | { |
| 7867 | int afi; |
| 7868 | int safi; |
| 7869 | struct bgp *bgp; |
| 7870 | |
| 7871 | /* BGP structure lookup. */ |
| 7872 | bgp = bgp_lookup_by_name (argv[0]); |
| 7873 | if (bgp == NULL) |
| 7874 | { |
| 7875 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7876 | return CMD_WARNING; |
| 7877 | } |
| 7878 | |
| 7879 | #ifdef HAVE_IPV6 |
| 7880 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7881 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7882 | #else |
| 7883 | afi = AFI_IP; |
| 7884 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7885 | #endif |
| 7886 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 7887 | } |
| 7888 | |
| 7889 | DEFUN (show_bgp_view_afi_safi_community, |
| 7890 | show_bgp_view_afi_safi_community_cmd, |
| 7891 | #ifdef HAVE_IPV6 |
| 7892 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7893 | #else |
| 7894 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7895 | #endif |
| 7896 | SHOW_STR |
| 7897 | BGP_STR |
| 7898 | "BGP view\n" |
| 7899 | "BGP view name\n" |
| 7900 | "Address family\n" |
| 7901 | #ifdef HAVE_IPV6 |
| 7902 | "Address family\n" |
| 7903 | #endif |
| 7904 | "Address family modifier\n" |
| 7905 | "Address family modifier\n" |
| 7906 | "Display routes matching the communities\n" |
| 7907 | "community number\n" |
| 7908 | "Do not send outside local AS (well-known community)\n" |
| 7909 | "Do not advertise to any peer (well-known community)\n" |
| 7910 | "Do not export to next AS (well-known community)\n") |
| 7911 | { |
| 7912 | int afi; |
| 7913 | int safi; |
| 7914 | |
| 7915 | #ifdef HAVE_IPV6 |
| 7916 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7917 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7918 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
| 7919 | #else |
| 7920 | afi = AFI_IP; |
| 7921 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7922 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); |
| 7923 | #endif |
| 7924 | } |
| 7925 | |
| 7926 | ALIAS (show_bgp_view_afi_safi_community, |
| 7927 | show_bgp_view_afi_safi_community2_cmd, |
| 7928 | #ifdef HAVE_IPV6 |
| 7929 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7930 | #else |
| 7931 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7932 | #endif |
| 7933 | SHOW_STR |
| 7934 | BGP_STR |
| 7935 | "BGP view\n" |
| 7936 | "BGP view name\n" |
| 7937 | "Address family\n" |
| 7938 | #ifdef HAVE_IPV6 |
| 7939 | "Address family\n" |
| 7940 | #endif |
| 7941 | "Address family modifier\n" |
| 7942 | "Address family modifier\n" |
| 7943 | "Display routes matching the communities\n" |
| 7944 | "community number\n" |
| 7945 | "Do not send outside local AS (well-known community)\n" |
| 7946 | "Do not advertise to any peer (well-known community)\n" |
| 7947 | "Do not export to next AS (well-known community)\n" |
| 7948 | "community number\n" |
| 7949 | "Do not send outside local AS (well-known community)\n" |
| 7950 | "Do not advertise to any peer (well-known community)\n" |
| 7951 | "Do not export to next AS (well-known community)\n") |
| 7952 | |
| 7953 | ALIAS (show_bgp_view_afi_safi_community, |
| 7954 | show_bgp_view_afi_safi_community3_cmd, |
| 7955 | #ifdef HAVE_IPV6 |
| 7956 | "show bgp view WORD (ipv4|ipv6) (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)", |
| 7957 | #else |
| 7958 | "show bgp view WORD 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)", |
| 7959 | #endif |
| 7960 | SHOW_STR |
| 7961 | BGP_STR |
| 7962 | "BGP view\n" |
| 7963 | "BGP view name\n" |
| 7964 | "Address family\n" |
| 7965 | #ifdef HAVE_IPV6 |
| 7966 | "Address family\n" |
| 7967 | #endif |
| 7968 | "Address family modifier\n" |
| 7969 | "Address family modifier\n" |
| 7970 | "Display routes matching the communities\n" |
| 7971 | "community number\n" |
| 7972 | "Do not send outside local AS (well-known community)\n" |
| 7973 | "Do not advertise to any peer (well-known community)\n" |
| 7974 | "Do not export to next AS (well-known community)\n" |
| 7975 | "community number\n" |
| 7976 | "Do not send outside local AS (well-known community)\n" |
| 7977 | "Do not advertise to any peer (well-known community)\n" |
| 7978 | "Do not export to next AS (well-known community)\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 | |
| 7984 | ALIAS (show_bgp_view_afi_safi_community, |
| 7985 | show_bgp_view_afi_safi_community4_cmd, |
| 7986 | #ifdef HAVE_IPV6 |
| 7987 | "show bgp view WORD (ipv4|ipv6) (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)", |
| 7988 | #else |
| 7989 | "show bgp view WORD 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)", |
| 7990 | #endif |
| 7991 | SHOW_STR |
| 7992 | BGP_STR |
| 7993 | "BGP view\n" |
| 7994 | "BGP view name\n" |
| 7995 | "Address family\n" |
| 7996 | #ifdef HAVE_IPV6 |
| 7997 | "Address family\n" |
| 7998 | #endif |
| 7999 | "Address family modifier\n" |
| 8000 | "Address family modifier\n" |
| 8001 | "Display routes matching the communities\n" |
| 8002 | "community number\n" |
| 8003 | "Do not send outside local AS (well-known community)\n" |
| 8004 | "Do not advertise to any peer (well-known community)\n" |
| 8005 | "Do not export to next AS (well-known community)\n" |
| 8006 | "community number\n" |
| 8007 | "Do not send outside local AS (well-known community)\n" |
| 8008 | "Do not advertise to any peer (well-known community)\n" |
| 8009 | "Do not export to next AS (well-known community)\n" |
| 8010 | "community number\n" |
| 8011 | "Do not send outside local AS (well-known community)\n" |
| 8012 | "Do not advertise to any peer (well-known community)\n" |
| 8013 | "Do not export to next AS (well-known community)\n" |
| 8014 | "community number\n" |
| 8015 | "Do not send outside local AS (well-known community)\n" |
| 8016 | "Do not advertise to any peer (well-known community)\n" |
| 8017 | "Do not export to next AS (well-known community)\n") |
| 8018 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8019 | DEFUN (show_ip_bgp_community_exact, |
| 8020 | show_ip_bgp_community_exact_cmd, |
| 8021 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8022 | SHOW_STR |
| 8023 | IP_STR |
| 8024 | BGP_STR |
| 8025 | "Display routes matching the communities\n" |
| 8026 | "community number\n" |
| 8027 | "Do not send outside local AS (well-known community)\n" |
| 8028 | "Do not advertise to any peer (well-known community)\n" |
| 8029 | "Do not export to next AS (well-known community)\n" |
| 8030 | "Exact match of the communities") |
| 8031 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8032 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8033 | } |
| 8034 | |
| 8035 | ALIAS (show_ip_bgp_community_exact, |
| 8036 | show_ip_bgp_community2_exact_cmd, |
| 8037 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8038 | SHOW_STR |
| 8039 | IP_STR |
| 8040 | BGP_STR |
| 8041 | "Display routes matching the communities\n" |
| 8042 | "community number\n" |
| 8043 | "Do not send outside local AS (well-known community)\n" |
| 8044 | "Do not advertise to any peer (well-known community)\n" |
| 8045 | "Do not export to next AS (well-known community)\n" |
| 8046 | "community number\n" |
| 8047 | "Do not send outside local AS (well-known community)\n" |
| 8048 | "Do not advertise to any peer (well-known community)\n" |
| 8049 | "Do not export to next AS (well-known community)\n" |
| 8050 | "Exact match of the communities") |
| 8051 | |
| 8052 | ALIAS (show_ip_bgp_community_exact, |
| 8053 | show_ip_bgp_community3_exact_cmd, |
| 8054 | "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", |
| 8055 | SHOW_STR |
| 8056 | IP_STR |
| 8057 | BGP_STR |
| 8058 | "Display routes matching the communities\n" |
| 8059 | "community number\n" |
| 8060 | "Do not send outside local AS (well-known community)\n" |
| 8061 | "Do not advertise to any peer (well-known community)\n" |
| 8062 | "Do not export to next AS (well-known community)\n" |
| 8063 | "community number\n" |
| 8064 | "Do not send outside local AS (well-known community)\n" |
| 8065 | "Do not advertise to any peer (well-known community)\n" |
| 8066 | "Do not export to next AS (well-known community)\n" |
| 8067 | "community number\n" |
| 8068 | "Do not send outside local AS (well-known community)\n" |
| 8069 | "Do not advertise to any peer (well-known community)\n" |
| 8070 | "Do not export to next AS (well-known community)\n" |
| 8071 | "Exact match of the communities") |
| 8072 | |
| 8073 | ALIAS (show_ip_bgp_community_exact, |
| 8074 | show_ip_bgp_community4_exact_cmd, |
| 8075 | "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", |
| 8076 | SHOW_STR |
| 8077 | IP_STR |
| 8078 | BGP_STR |
| 8079 | "Display routes matching the communities\n" |
| 8080 | "community number\n" |
| 8081 | "Do not send outside local AS (well-known community)\n" |
| 8082 | "Do not advertise to any peer (well-known community)\n" |
| 8083 | "Do not export to next AS (well-known community)\n" |
| 8084 | "community number\n" |
| 8085 | "Do not send outside local AS (well-known community)\n" |
| 8086 | "Do not advertise to any peer (well-known community)\n" |
| 8087 | "Do not export to next AS (well-known community)\n" |
| 8088 | "community number\n" |
| 8089 | "Do not send outside local AS (well-known community)\n" |
| 8090 | "Do not advertise to any peer (well-known community)\n" |
| 8091 | "Do not export to next AS (well-known community)\n" |
| 8092 | "community number\n" |
| 8093 | "Do not send outside local AS (well-known community)\n" |
| 8094 | "Do not advertise to any peer (well-known community)\n" |
| 8095 | "Do not export to next AS (well-known community)\n" |
| 8096 | "Exact match of the communities") |
| 8097 | |
| 8098 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8099 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8100 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8101 | SHOW_STR |
| 8102 | IP_STR |
| 8103 | BGP_STR |
| 8104 | "Address family\n" |
| 8105 | "Address Family modifier\n" |
| 8106 | "Address Family modifier\n" |
| 8107 | "Display routes matching the communities\n" |
| 8108 | "community number\n" |
| 8109 | "Do not send outside local AS (well-known community)\n" |
| 8110 | "Do not advertise to any peer (well-known community)\n" |
| 8111 | "Do not export to next AS (well-known community)\n" |
| 8112 | "Exact match of the communities") |
| 8113 | { |
| 8114 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8115 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8116 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8117 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8118 | } |
| 8119 | |
| 8120 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8121 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8122 | "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", |
| 8123 | SHOW_STR |
| 8124 | IP_STR |
| 8125 | BGP_STR |
| 8126 | "Address family\n" |
| 8127 | "Address Family modifier\n" |
| 8128 | "Address Family modifier\n" |
| 8129 | "Display routes matching the communities\n" |
| 8130 | "community number\n" |
| 8131 | "Do not send outside local AS (well-known community)\n" |
| 8132 | "Do not advertise to any peer (well-known community)\n" |
| 8133 | "Do not export to next AS (well-known community)\n" |
| 8134 | "community number\n" |
| 8135 | "Do not send outside local AS (well-known community)\n" |
| 8136 | "Do not advertise to any peer (well-known community)\n" |
| 8137 | "Do not export to next AS (well-known community)\n" |
| 8138 | "Exact match of the communities") |
| 8139 | |
| 8140 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8141 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8142 | "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", |
| 8143 | SHOW_STR |
| 8144 | IP_STR |
| 8145 | BGP_STR |
| 8146 | "Address family\n" |
| 8147 | "Address Family modifier\n" |
| 8148 | "Address Family modifier\n" |
| 8149 | "Display routes matching the communities\n" |
| 8150 | "community number\n" |
| 8151 | "Do not send outside local AS (well-known community)\n" |
| 8152 | "Do not advertise to any peer (well-known community)\n" |
| 8153 | "Do not export to next AS (well-known community)\n" |
| 8154 | "community number\n" |
| 8155 | "Do not send outside local AS (well-known community)\n" |
| 8156 | "Do not advertise to any peer (well-known community)\n" |
| 8157 | "Do not export to next AS (well-known community)\n" |
| 8158 | "community number\n" |
| 8159 | "Do not send outside local AS (well-known community)\n" |
| 8160 | "Do not advertise to any peer (well-known community)\n" |
| 8161 | "Do not export to next AS (well-known community)\n" |
| 8162 | "Exact match of the communities") |
| 8163 | |
| 8164 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8165 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8166 | "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", |
| 8167 | SHOW_STR |
| 8168 | IP_STR |
| 8169 | BGP_STR |
| 8170 | "Address family\n" |
| 8171 | "Address Family modifier\n" |
| 8172 | "Address Family modifier\n" |
| 8173 | "Display routes matching the communities\n" |
| 8174 | "community number\n" |
| 8175 | "Do not send outside local AS (well-known community)\n" |
| 8176 | "Do not advertise to any peer (well-known community)\n" |
| 8177 | "Do not export to next AS (well-known community)\n" |
| 8178 | "community number\n" |
| 8179 | "Do not send outside local AS (well-known community)\n" |
| 8180 | "Do not advertise to any peer (well-known community)\n" |
| 8181 | "Do not export to next AS (well-known community)\n" |
| 8182 | "community number\n" |
| 8183 | "Do not send outside local AS (well-known community)\n" |
| 8184 | "Do not advertise to any peer (well-known community)\n" |
| 8185 | "Do not export to next AS (well-known community)\n" |
| 8186 | "community number\n" |
| 8187 | "Do not send outside local AS (well-known community)\n" |
| 8188 | "Do not advertise to any peer (well-known community)\n" |
| 8189 | "Do not export to next AS (well-known community)\n" |
| 8190 | "Exact match of the communities") |
| 8191 | |
| 8192 | #ifdef HAVE_IPV6 |
| 8193 | DEFUN (show_bgp_community, |
| 8194 | show_bgp_community_cmd, |
| 8195 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8196 | SHOW_STR |
| 8197 | BGP_STR |
| 8198 | "Display routes matching the communities\n" |
| 8199 | "community number\n" |
| 8200 | "Do not send outside local AS (well-known community)\n" |
| 8201 | "Do not advertise to any peer (well-known community)\n" |
| 8202 | "Do not export to next AS (well-known community)\n") |
| 8203 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8204 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8205 | } |
| 8206 | |
| 8207 | ALIAS (show_bgp_community, |
| 8208 | show_bgp_ipv6_community_cmd, |
| 8209 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8210 | SHOW_STR |
| 8211 | BGP_STR |
| 8212 | "Address family\n" |
| 8213 | "Display routes matching the communities\n" |
| 8214 | "community number\n" |
| 8215 | "Do not send outside local AS (well-known community)\n" |
| 8216 | "Do not advertise to any peer (well-known community)\n" |
| 8217 | "Do not export to next AS (well-known community)\n") |
| 8218 | |
| 8219 | ALIAS (show_bgp_community, |
| 8220 | show_bgp_community2_cmd, |
| 8221 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8222 | SHOW_STR |
| 8223 | BGP_STR |
| 8224 | "Display routes matching the communities\n" |
| 8225 | "community number\n" |
| 8226 | "Do not send outside local AS (well-known community)\n" |
| 8227 | "Do not advertise to any peer (well-known community)\n" |
| 8228 | "Do not export to next AS (well-known community)\n" |
| 8229 | "community number\n" |
| 8230 | "Do not send outside local AS (well-known community)\n" |
| 8231 | "Do not advertise to any peer (well-known community)\n" |
| 8232 | "Do not export to next AS (well-known community)\n") |
| 8233 | |
| 8234 | ALIAS (show_bgp_community, |
| 8235 | show_bgp_ipv6_community2_cmd, |
| 8236 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8237 | SHOW_STR |
| 8238 | BGP_STR |
| 8239 | "Address family\n" |
| 8240 | "Display routes matching the communities\n" |
| 8241 | "community number\n" |
| 8242 | "Do not send outside local AS (well-known community)\n" |
| 8243 | "Do not advertise to any peer (well-known community)\n" |
| 8244 | "Do not export to next AS (well-known community)\n" |
| 8245 | "community number\n" |
| 8246 | "Do not send outside local AS (well-known community)\n" |
| 8247 | "Do not advertise to any peer (well-known community)\n" |
| 8248 | "Do not export to next AS (well-known community)\n") |
| 8249 | |
| 8250 | ALIAS (show_bgp_community, |
| 8251 | show_bgp_community3_cmd, |
| 8252 | "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)", |
| 8253 | SHOW_STR |
| 8254 | BGP_STR |
| 8255 | "Display routes matching the communities\n" |
| 8256 | "community number\n" |
| 8257 | "Do not send outside local AS (well-known community)\n" |
| 8258 | "Do not advertise to any peer (well-known community)\n" |
| 8259 | "Do not export to next AS (well-known community)\n" |
| 8260 | "community number\n" |
| 8261 | "Do not send outside local AS (well-known community)\n" |
| 8262 | "Do not advertise to any peer (well-known community)\n" |
| 8263 | "Do not export to next AS (well-known community)\n" |
| 8264 | "community number\n" |
| 8265 | "Do not send outside local AS (well-known community)\n" |
| 8266 | "Do not advertise to any peer (well-known community)\n" |
| 8267 | "Do not export to next AS (well-known community)\n") |
| 8268 | |
| 8269 | ALIAS (show_bgp_community, |
| 8270 | show_bgp_ipv6_community3_cmd, |
| 8271 | "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)", |
| 8272 | SHOW_STR |
| 8273 | BGP_STR |
| 8274 | "Address family\n" |
| 8275 | "Display routes matching the communities\n" |
| 8276 | "community number\n" |
| 8277 | "Do not send outside local AS (well-known community)\n" |
| 8278 | "Do not advertise to any peer (well-known community)\n" |
| 8279 | "Do not export to next AS (well-known community)\n" |
| 8280 | "community number\n" |
| 8281 | "Do not send outside local AS (well-known community)\n" |
| 8282 | "Do not advertise to any peer (well-known community)\n" |
| 8283 | "Do not export to next AS (well-known community)\n" |
| 8284 | "community number\n" |
| 8285 | "Do not send outside local AS (well-known community)\n" |
| 8286 | "Do not advertise to any peer (well-known community)\n" |
| 8287 | "Do not export to next AS (well-known community)\n") |
| 8288 | |
| 8289 | ALIAS (show_bgp_community, |
| 8290 | show_bgp_community4_cmd, |
| 8291 | "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)", |
| 8292 | SHOW_STR |
| 8293 | BGP_STR |
| 8294 | "Display routes matching the communities\n" |
| 8295 | "community number\n" |
| 8296 | "Do not send outside local AS (well-known community)\n" |
| 8297 | "Do not advertise to any peer (well-known community)\n" |
| 8298 | "Do not export to next AS (well-known community)\n" |
| 8299 | "community number\n" |
| 8300 | "Do not send outside local AS (well-known community)\n" |
| 8301 | "Do not advertise to any peer (well-known community)\n" |
| 8302 | "Do not export to next AS (well-known community)\n" |
| 8303 | "community number\n" |
| 8304 | "Do not send outside local AS (well-known community)\n" |
| 8305 | "Do not advertise to any peer (well-known community)\n" |
| 8306 | "Do not export to next AS (well-known community)\n" |
| 8307 | "community number\n" |
| 8308 | "Do not send outside local AS (well-known community)\n" |
| 8309 | "Do not advertise to any peer (well-known community)\n" |
| 8310 | "Do not export to next AS (well-known community)\n") |
| 8311 | |
| 8312 | ALIAS (show_bgp_community, |
| 8313 | show_bgp_ipv6_community4_cmd, |
| 8314 | "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)", |
| 8315 | SHOW_STR |
| 8316 | BGP_STR |
| 8317 | "Address family\n" |
| 8318 | "Display routes matching the communities\n" |
| 8319 | "community number\n" |
| 8320 | "Do not send outside local AS (well-known community)\n" |
| 8321 | "Do not advertise to any peer (well-known community)\n" |
| 8322 | "Do not export to next AS (well-known community)\n" |
| 8323 | "community number\n" |
| 8324 | "Do not send outside local AS (well-known community)\n" |
| 8325 | "Do not advertise to any peer (well-known community)\n" |
| 8326 | "Do not export to next AS (well-known community)\n" |
| 8327 | "community number\n" |
| 8328 | "Do not send outside local AS (well-known community)\n" |
| 8329 | "Do not advertise to any peer (well-known community)\n" |
| 8330 | "Do not export to next AS (well-known community)\n" |
| 8331 | "community number\n" |
| 8332 | "Do not send outside local AS (well-known community)\n" |
| 8333 | "Do not advertise to any peer (well-known community)\n" |
| 8334 | "Do not export to next AS (well-known community)\n") |
| 8335 | |
| 8336 | /* old command */ |
| 8337 | DEFUN (show_ipv6_bgp_community, |
| 8338 | show_ipv6_bgp_community_cmd, |
| 8339 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8340 | SHOW_STR |
| 8341 | IPV6_STR |
| 8342 | BGP_STR |
| 8343 | "Display routes matching the communities\n" |
| 8344 | "community number\n" |
| 8345 | "Do not send outside local AS (well-known community)\n" |
| 8346 | "Do not advertise to any peer (well-known community)\n" |
| 8347 | "Do not export to next AS (well-known community)\n") |
| 8348 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8349 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8350 | } |
| 8351 | |
| 8352 | /* old command */ |
| 8353 | ALIAS (show_ipv6_bgp_community, |
| 8354 | show_ipv6_bgp_community2_cmd, |
| 8355 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8356 | SHOW_STR |
| 8357 | IPV6_STR |
| 8358 | BGP_STR |
| 8359 | "Display routes matching the communities\n" |
| 8360 | "community number\n" |
| 8361 | "Do not send outside local AS (well-known community)\n" |
| 8362 | "Do not advertise to any peer (well-known community)\n" |
| 8363 | "Do not export to next AS (well-known community)\n" |
| 8364 | "community number\n" |
| 8365 | "Do not send outside local AS (well-known community)\n" |
| 8366 | "Do not advertise to any peer (well-known community)\n" |
| 8367 | "Do not export to next AS (well-known community)\n") |
| 8368 | |
| 8369 | /* old command */ |
| 8370 | ALIAS (show_ipv6_bgp_community, |
| 8371 | show_ipv6_bgp_community3_cmd, |
| 8372 | "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)", |
| 8373 | SHOW_STR |
| 8374 | IPV6_STR |
| 8375 | BGP_STR |
| 8376 | "Display routes matching the communities\n" |
| 8377 | "community number\n" |
| 8378 | "Do not send outside local AS (well-known community)\n" |
| 8379 | "Do not advertise to any peer (well-known community)\n" |
| 8380 | "Do not export to next AS (well-known community)\n" |
| 8381 | "community number\n" |
| 8382 | "Do not send outside local AS (well-known community)\n" |
| 8383 | "Do not advertise to any peer (well-known community)\n" |
| 8384 | "Do not export to next AS (well-known community)\n" |
| 8385 | "community number\n" |
| 8386 | "Do not send outside local AS (well-known community)\n" |
| 8387 | "Do not advertise to any peer (well-known community)\n" |
| 8388 | "Do not export to next AS (well-known community)\n") |
| 8389 | |
| 8390 | /* old command */ |
| 8391 | ALIAS (show_ipv6_bgp_community, |
| 8392 | show_ipv6_bgp_community4_cmd, |
| 8393 | "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)", |
| 8394 | SHOW_STR |
| 8395 | IPV6_STR |
| 8396 | BGP_STR |
| 8397 | "Display routes matching the communities\n" |
| 8398 | "community number\n" |
| 8399 | "Do not send outside local AS (well-known community)\n" |
| 8400 | "Do not advertise to any peer (well-known community)\n" |
| 8401 | "Do not export to next AS (well-known community)\n" |
| 8402 | "community number\n" |
| 8403 | "Do not send outside local AS (well-known community)\n" |
| 8404 | "Do not advertise to any peer (well-known community)\n" |
| 8405 | "Do not export to next AS (well-known community)\n" |
| 8406 | "community number\n" |
| 8407 | "Do not send outside local AS (well-known community)\n" |
| 8408 | "Do not advertise to any peer (well-known community)\n" |
| 8409 | "Do not export to next AS (well-known community)\n" |
| 8410 | "community number\n" |
| 8411 | "Do not send outside local AS (well-known community)\n" |
| 8412 | "Do not advertise to any peer (well-known community)\n" |
| 8413 | "Do not export to next AS (well-known community)\n") |
| 8414 | |
| 8415 | DEFUN (show_bgp_community_exact, |
| 8416 | show_bgp_community_exact_cmd, |
| 8417 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8418 | SHOW_STR |
| 8419 | BGP_STR |
| 8420 | "Display routes matching the communities\n" |
| 8421 | "community number\n" |
| 8422 | "Do not send outside local AS (well-known community)\n" |
| 8423 | "Do not advertise to any peer (well-known community)\n" |
| 8424 | "Do not export to next AS (well-known community)\n" |
| 8425 | "Exact match of the communities") |
| 8426 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8427 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8428 | } |
| 8429 | |
| 8430 | ALIAS (show_bgp_community_exact, |
| 8431 | show_bgp_ipv6_community_exact_cmd, |
| 8432 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8433 | SHOW_STR |
| 8434 | BGP_STR |
| 8435 | "Address family\n" |
| 8436 | "Display routes matching the communities\n" |
| 8437 | "community number\n" |
| 8438 | "Do not send outside local AS (well-known community)\n" |
| 8439 | "Do not advertise to any peer (well-known community)\n" |
| 8440 | "Do not export to next AS (well-known community)\n" |
| 8441 | "Exact match of the communities") |
| 8442 | |
| 8443 | ALIAS (show_bgp_community_exact, |
| 8444 | show_bgp_community2_exact_cmd, |
| 8445 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8446 | SHOW_STR |
| 8447 | BGP_STR |
| 8448 | "Display routes matching the communities\n" |
| 8449 | "community number\n" |
| 8450 | "Do not send outside local AS (well-known community)\n" |
| 8451 | "Do not advertise to any peer (well-known community)\n" |
| 8452 | "Do not export to next AS (well-known community)\n" |
| 8453 | "community number\n" |
| 8454 | "Do not send outside local AS (well-known community)\n" |
| 8455 | "Do not advertise to any peer (well-known community)\n" |
| 8456 | "Do not export to next AS (well-known community)\n" |
| 8457 | "Exact match of the communities") |
| 8458 | |
| 8459 | ALIAS (show_bgp_community_exact, |
| 8460 | show_bgp_ipv6_community2_exact_cmd, |
| 8461 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8462 | SHOW_STR |
| 8463 | BGP_STR |
| 8464 | "Address family\n" |
| 8465 | "Display routes matching the communities\n" |
| 8466 | "community number\n" |
| 8467 | "Do not send outside local AS (well-known community)\n" |
| 8468 | "Do not advertise to any peer (well-known community)\n" |
| 8469 | "Do not export to next AS (well-known community)\n" |
| 8470 | "community number\n" |
| 8471 | "Do not send outside local AS (well-known community)\n" |
| 8472 | "Do not advertise to any peer (well-known community)\n" |
| 8473 | "Do not export to next AS (well-known community)\n" |
| 8474 | "Exact match of the communities") |
| 8475 | |
| 8476 | ALIAS (show_bgp_community_exact, |
| 8477 | show_bgp_community3_exact_cmd, |
| 8478 | "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", |
| 8479 | SHOW_STR |
| 8480 | BGP_STR |
| 8481 | "Display routes matching the communities\n" |
| 8482 | "community number\n" |
| 8483 | "Do not send outside local AS (well-known community)\n" |
| 8484 | "Do not advertise to any peer (well-known community)\n" |
| 8485 | "Do not export to next AS (well-known community)\n" |
| 8486 | "community number\n" |
| 8487 | "Do not send outside local AS (well-known community)\n" |
| 8488 | "Do not advertise to any peer (well-known community)\n" |
| 8489 | "Do not export to next AS (well-known community)\n" |
| 8490 | "community number\n" |
| 8491 | "Do not send outside local AS (well-known community)\n" |
| 8492 | "Do not advertise to any peer (well-known community)\n" |
| 8493 | "Do not export to next AS (well-known community)\n" |
| 8494 | "Exact match of the communities") |
| 8495 | |
| 8496 | ALIAS (show_bgp_community_exact, |
| 8497 | show_bgp_ipv6_community3_exact_cmd, |
| 8498 | "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", |
| 8499 | SHOW_STR |
| 8500 | BGP_STR |
| 8501 | "Address family\n" |
| 8502 | "Display routes matching the communities\n" |
| 8503 | "community number\n" |
| 8504 | "Do not send outside local AS (well-known community)\n" |
| 8505 | "Do not advertise to any peer (well-known community)\n" |
| 8506 | "Do not export to next AS (well-known community)\n" |
| 8507 | "community number\n" |
| 8508 | "Do not send outside local AS (well-known community)\n" |
| 8509 | "Do not advertise to any peer (well-known community)\n" |
| 8510 | "Do not export to next AS (well-known community)\n" |
| 8511 | "community number\n" |
| 8512 | "Do not send outside local AS (well-known community)\n" |
| 8513 | "Do not advertise to any peer (well-known community)\n" |
| 8514 | "Do not export to next AS (well-known community)\n" |
| 8515 | "Exact match of the communities") |
| 8516 | |
| 8517 | ALIAS (show_bgp_community_exact, |
| 8518 | show_bgp_community4_exact_cmd, |
| 8519 | "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", |
| 8520 | SHOW_STR |
| 8521 | BGP_STR |
| 8522 | "Display routes matching the communities\n" |
| 8523 | "community number\n" |
| 8524 | "Do not send outside local AS (well-known community)\n" |
| 8525 | "Do not advertise to any peer (well-known community)\n" |
| 8526 | "Do not export to next AS (well-known community)\n" |
| 8527 | "community number\n" |
| 8528 | "Do not send outside local AS (well-known community)\n" |
| 8529 | "Do not advertise to any peer (well-known community)\n" |
| 8530 | "Do not export to next AS (well-known community)\n" |
| 8531 | "community number\n" |
| 8532 | "Do not send outside local AS (well-known community)\n" |
| 8533 | "Do not advertise to any peer (well-known community)\n" |
| 8534 | "Do not export to next AS (well-known community)\n" |
| 8535 | "community number\n" |
| 8536 | "Do not send outside local AS (well-known community)\n" |
| 8537 | "Do not advertise to any peer (well-known community)\n" |
| 8538 | "Do not export to next AS (well-known community)\n" |
| 8539 | "Exact match of the communities") |
| 8540 | |
| 8541 | ALIAS (show_bgp_community_exact, |
| 8542 | show_bgp_ipv6_community4_exact_cmd, |
| 8543 | "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", |
| 8544 | SHOW_STR |
| 8545 | BGP_STR |
| 8546 | "Address family\n" |
| 8547 | "Display routes matching the communities\n" |
| 8548 | "community number\n" |
| 8549 | "Do not send outside local AS (well-known community)\n" |
| 8550 | "Do not advertise to any peer (well-known community)\n" |
| 8551 | "Do not export to next AS (well-known community)\n" |
| 8552 | "community number\n" |
| 8553 | "Do not send outside local AS (well-known community)\n" |
| 8554 | "Do not advertise to any peer (well-known community)\n" |
| 8555 | "Do not export to next AS (well-known community)\n" |
| 8556 | "community number\n" |
| 8557 | "Do not send outside local AS (well-known community)\n" |
| 8558 | "Do not advertise to any peer (well-known community)\n" |
| 8559 | "Do not export to next AS (well-known community)\n" |
| 8560 | "community number\n" |
| 8561 | "Do not send outside local AS (well-known community)\n" |
| 8562 | "Do not advertise to any peer (well-known community)\n" |
| 8563 | "Do not export to next AS (well-known community)\n" |
| 8564 | "Exact match of the communities") |
| 8565 | |
| 8566 | /* old command */ |
| 8567 | DEFUN (show_ipv6_bgp_community_exact, |
| 8568 | show_ipv6_bgp_community_exact_cmd, |
| 8569 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8570 | SHOW_STR |
| 8571 | IPV6_STR |
| 8572 | BGP_STR |
| 8573 | "Display routes matching the communities\n" |
| 8574 | "community number\n" |
| 8575 | "Do not send outside local AS (well-known community)\n" |
| 8576 | "Do not advertise to any peer (well-known community)\n" |
| 8577 | "Do not export to next AS (well-known community)\n" |
| 8578 | "Exact match of the communities") |
| 8579 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8580 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8581 | } |
| 8582 | |
| 8583 | /* old command */ |
| 8584 | ALIAS (show_ipv6_bgp_community_exact, |
| 8585 | show_ipv6_bgp_community2_exact_cmd, |
| 8586 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8587 | SHOW_STR |
| 8588 | IPV6_STR |
| 8589 | BGP_STR |
| 8590 | "Display routes matching the communities\n" |
| 8591 | "community number\n" |
| 8592 | "Do not send outside local AS (well-known community)\n" |
| 8593 | "Do not advertise to any peer (well-known community)\n" |
| 8594 | "Do not export to next AS (well-known community)\n" |
| 8595 | "community number\n" |
| 8596 | "Do not send outside local AS (well-known community)\n" |
| 8597 | "Do not advertise to any peer (well-known community)\n" |
| 8598 | "Do not export to next AS (well-known community)\n" |
| 8599 | "Exact match of the communities") |
| 8600 | |
| 8601 | /* old command */ |
| 8602 | ALIAS (show_ipv6_bgp_community_exact, |
| 8603 | show_ipv6_bgp_community3_exact_cmd, |
| 8604 | "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", |
| 8605 | SHOW_STR |
| 8606 | IPV6_STR |
| 8607 | BGP_STR |
| 8608 | "Display routes matching the communities\n" |
| 8609 | "community number\n" |
| 8610 | "Do not send outside local AS (well-known community)\n" |
| 8611 | "Do not advertise to any peer (well-known community)\n" |
| 8612 | "Do not export to next AS (well-known community)\n" |
| 8613 | "community number\n" |
| 8614 | "Do not send outside local AS (well-known community)\n" |
| 8615 | "Do not advertise to any peer (well-known community)\n" |
| 8616 | "Do not export to next AS (well-known community)\n" |
| 8617 | "community number\n" |
| 8618 | "Do not send outside local AS (well-known community)\n" |
| 8619 | "Do not advertise to any peer (well-known community)\n" |
| 8620 | "Do not export to next AS (well-known community)\n" |
| 8621 | "Exact match of the communities") |
| 8622 | |
| 8623 | /* old command */ |
| 8624 | ALIAS (show_ipv6_bgp_community_exact, |
| 8625 | show_ipv6_bgp_community4_exact_cmd, |
| 8626 | "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", |
| 8627 | SHOW_STR |
| 8628 | IPV6_STR |
| 8629 | BGP_STR |
| 8630 | "Display routes matching the communities\n" |
| 8631 | "community number\n" |
| 8632 | "Do not send outside local AS (well-known community)\n" |
| 8633 | "Do not advertise to any peer (well-known community)\n" |
| 8634 | "Do not export to next AS (well-known community)\n" |
| 8635 | "community number\n" |
| 8636 | "Do not send outside local AS (well-known community)\n" |
| 8637 | "Do not advertise to any peer (well-known community)\n" |
| 8638 | "Do not export to next AS (well-known community)\n" |
| 8639 | "community number\n" |
| 8640 | "Do not send outside local AS (well-known community)\n" |
| 8641 | "Do not advertise to any peer (well-known community)\n" |
| 8642 | "Do not export to next AS (well-known community)\n" |
| 8643 | "community number\n" |
| 8644 | "Do not send outside local AS (well-known community)\n" |
| 8645 | "Do not advertise to any peer (well-known community)\n" |
| 8646 | "Do not export to next AS (well-known community)\n" |
| 8647 | "Exact match of the communities") |
| 8648 | |
| 8649 | /* old command */ |
| 8650 | DEFUN (show_ipv6_mbgp_community, |
| 8651 | show_ipv6_mbgp_community_cmd, |
| 8652 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8653 | SHOW_STR |
| 8654 | IPV6_STR |
| 8655 | MBGP_STR |
| 8656 | "Display routes matching the communities\n" |
| 8657 | "community number\n" |
| 8658 | "Do not send outside local AS (well-known community)\n" |
| 8659 | "Do not advertise to any peer (well-known community)\n" |
| 8660 | "Do not export to next AS (well-known community)\n") |
| 8661 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8662 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8663 | } |
| 8664 | |
| 8665 | /* old command */ |
| 8666 | ALIAS (show_ipv6_mbgp_community, |
| 8667 | show_ipv6_mbgp_community2_cmd, |
| 8668 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8669 | SHOW_STR |
| 8670 | IPV6_STR |
| 8671 | MBGP_STR |
| 8672 | "Display routes matching the communities\n" |
| 8673 | "community number\n" |
| 8674 | "Do not send outside local AS (well-known community)\n" |
| 8675 | "Do not advertise to any peer (well-known community)\n" |
| 8676 | "Do not export to next AS (well-known community)\n" |
| 8677 | "community number\n" |
| 8678 | "Do not send outside local AS (well-known community)\n" |
| 8679 | "Do not advertise to any peer (well-known community)\n" |
| 8680 | "Do not export to next AS (well-known community)\n") |
| 8681 | |
| 8682 | /* old command */ |
| 8683 | ALIAS (show_ipv6_mbgp_community, |
| 8684 | show_ipv6_mbgp_community3_cmd, |
| 8685 | "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)", |
| 8686 | SHOW_STR |
| 8687 | IPV6_STR |
| 8688 | MBGP_STR |
| 8689 | "Display routes matching the communities\n" |
| 8690 | "community number\n" |
| 8691 | "Do not send outside local AS (well-known community)\n" |
| 8692 | "Do not advertise to any peer (well-known community)\n" |
| 8693 | "Do not export to next AS (well-known community)\n" |
| 8694 | "community number\n" |
| 8695 | "Do not send outside local AS (well-known community)\n" |
| 8696 | "Do not advertise to any peer (well-known community)\n" |
| 8697 | "Do not export to next AS (well-known community)\n" |
| 8698 | "community number\n" |
| 8699 | "Do not send outside local AS (well-known community)\n" |
| 8700 | "Do not advertise to any peer (well-known community)\n" |
| 8701 | "Do not export to next AS (well-known community)\n") |
| 8702 | |
| 8703 | /* old command */ |
| 8704 | ALIAS (show_ipv6_mbgp_community, |
| 8705 | show_ipv6_mbgp_community4_cmd, |
| 8706 | "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)", |
| 8707 | SHOW_STR |
| 8708 | IPV6_STR |
| 8709 | MBGP_STR |
| 8710 | "Display routes matching the communities\n" |
| 8711 | "community number\n" |
| 8712 | "Do not send outside local AS (well-known community)\n" |
| 8713 | "Do not advertise to any peer (well-known community)\n" |
| 8714 | "Do not export to next AS (well-known community)\n" |
| 8715 | "community number\n" |
| 8716 | "Do not send outside local AS (well-known community)\n" |
| 8717 | "Do not advertise to any peer (well-known community)\n" |
| 8718 | "Do not export to next AS (well-known community)\n" |
| 8719 | "community number\n" |
| 8720 | "Do not send outside local AS (well-known community)\n" |
| 8721 | "Do not advertise to any peer (well-known community)\n" |
| 8722 | "Do not export to next AS (well-known community)\n" |
| 8723 | "community number\n" |
| 8724 | "Do not send outside local AS (well-known community)\n" |
| 8725 | "Do not advertise to any peer (well-known community)\n" |
| 8726 | "Do not export to next AS (well-known community)\n") |
| 8727 | |
| 8728 | /* old command */ |
| 8729 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8730 | show_ipv6_mbgp_community_exact_cmd, |
| 8731 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8732 | SHOW_STR |
| 8733 | IPV6_STR |
| 8734 | MBGP_STR |
| 8735 | "Display routes matching the communities\n" |
| 8736 | "community number\n" |
| 8737 | "Do not send outside local AS (well-known community)\n" |
| 8738 | "Do not advertise to any peer (well-known community)\n" |
| 8739 | "Do not export to next AS (well-known community)\n" |
| 8740 | "Exact match of the communities") |
| 8741 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8742 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8743 | } |
| 8744 | |
| 8745 | /* old command */ |
| 8746 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8747 | show_ipv6_mbgp_community2_exact_cmd, |
| 8748 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8749 | SHOW_STR |
| 8750 | IPV6_STR |
| 8751 | MBGP_STR |
| 8752 | "Display routes matching the communities\n" |
| 8753 | "community number\n" |
| 8754 | "Do not send outside local AS (well-known community)\n" |
| 8755 | "Do not advertise to any peer (well-known community)\n" |
| 8756 | "Do not export to next AS (well-known community)\n" |
| 8757 | "community number\n" |
| 8758 | "Do not send outside local AS (well-known community)\n" |
| 8759 | "Do not advertise to any peer (well-known community)\n" |
| 8760 | "Do not export to next AS (well-known community)\n" |
| 8761 | "Exact match of the communities") |
| 8762 | |
| 8763 | /* old command */ |
| 8764 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8765 | show_ipv6_mbgp_community3_exact_cmd, |
| 8766 | "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", |
| 8767 | SHOW_STR |
| 8768 | IPV6_STR |
| 8769 | MBGP_STR |
| 8770 | "Display routes matching the communities\n" |
| 8771 | "community number\n" |
| 8772 | "Do not send outside local AS (well-known community)\n" |
| 8773 | "Do not advertise to any peer (well-known community)\n" |
| 8774 | "Do not export to next AS (well-known community)\n" |
| 8775 | "community number\n" |
| 8776 | "Do not send outside local AS (well-known community)\n" |
| 8777 | "Do not advertise to any peer (well-known community)\n" |
| 8778 | "Do not export to next AS (well-known community)\n" |
| 8779 | "community number\n" |
| 8780 | "Do not send outside local AS (well-known community)\n" |
| 8781 | "Do not advertise to any peer (well-known community)\n" |
| 8782 | "Do not export to next AS (well-known community)\n" |
| 8783 | "Exact match of the communities") |
| 8784 | |
| 8785 | /* old command */ |
| 8786 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8787 | show_ipv6_mbgp_community4_exact_cmd, |
| 8788 | "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", |
| 8789 | SHOW_STR |
| 8790 | IPV6_STR |
| 8791 | MBGP_STR |
| 8792 | "Display routes matching the communities\n" |
| 8793 | "community number\n" |
| 8794 | "Do not send outside local AS (well-known community)\n" |
| 8795 | "Do not advertise to any peer (well-known community)\n" |
| 8796 | "Do not export to next AS (well-known community)\n" |
| 8797 | "community number\n" |
| 8798 | "Do not send outside local AS (well-known community)\n" |
| 8799 | "Do not advertise to any peer (well-known community)\n" |
| 8800 | "Do not export to next AS (well-known community)\n" |
| 8801 | "community number\n" |
| 8802 | "Do not send outside local AS (well-known community)\n" |
| 8803 | "Do not advertise to any peer (well-known community)\n" |
| 8804 | "Do not export to next AS (well-known community)\n" |
| 8805 | "community number\n" |
| 8806 | "Do not send outside local AS (well-known community)\n" |
| 8807 | "Do not advertise to any peer (well-known community)\n" |
| 8808 | "Do not export to next AS (well-known community)\n" |
| 8809 | "Exact match of the communities") |
| 8810 | #endif /* HAVE_IPV6 */ |
| 8811 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8812 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8813 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8814 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8815 | { |
| 8816 | struct community_list *list; |
| 8817 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8818 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8819 | if (list == NULL) |
| 8820 | { |
| 8821 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8822 | VTY_NEWLINE); |
| 8823 | return CMD_WARNING; |
| 8824 | } |
| 8825 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8826 | return bgp_show (vty, NULL, afi, safi, |
| 8827 | (exact ? bgp_show_type_community_list_exact : |
| 8828 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8829 | } |
| 8830 | |
| 8831 | DEFUN (show_ip_bgp_community_list, |
| 8832 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8833 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8834 | SHOW_STR |
| 8835 | IP_STR |
| 8836 | BGP_STR |
| 8837 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8838 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8839 | "community-list name\n") |
| 8840 | { |
| 8841 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8842 | } |
| 8843 | |
| 8844 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8845 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8846 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8847 | SHOW_STR |
| 8848 | IP_STR |
| 8849 | BGP_STR |
| 8850 | "Address family\n" |
| 8851 | "Address Family modifier\n" |
| 8852 | "Address Family modifier\n" |
| 8853 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8854 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8855 | "community-list name\n") |
| 8856 | { |
| 8857 | if (strncmp (argv[0], "m", 1) == 0) |
| 8858 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8859 | |
| 8860 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8861 | } |
| 8862 | |
| 8863 | DEFUN (show_ip_bgp_community_list_exact, |
| 8864 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8865 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8866 | SHOW_STR |
| 8867 | IP_STR |
| 8868 | BGP_STR |
| 8869 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8870 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8871 | "community-list name\n" |
| 8872 | "Exact match of the communities\n") |
| 8873 | { |
| 8874 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8875 | } |
| 8876 | |
| 8877 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8878 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8879 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8880 | SHOW_STR |
| 8881 | IP_STR |
| 8882 | BGP_STR |
| 8883 | "Address family\n" |
| 8884 | "Address Family modifier\n" |
| 8885 | "Address Family modifier\n" |
| 8886 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8887 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8888 | "community-list name\n" |
| 8889 | "Exact match of the communities\n") |
| 8890 | { |
| 8891 | if (strncmp (argv[0], "m", 1) == 0) |
| 8892 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8893 | |
| 8894 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8895 | } |
| 8896 | |
| 8897 | #ifdef HAVE_IPV6 |
| 8898 | DEFUN (show_bgp_community_list, |
| 8899 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8900 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8901 | SHOW_STR |
| 8902 | BGP_STR |
| 8903 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8904 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8905 | "community-list name\n") |
| 8906 | { |
| 8907 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8908 | } |
| 8909 | |
| 8910 | ALIAS (show_bgp_community_list, |
| 8911 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8912 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8913 | SHOW_STR |
| 8914 | BGP_STR |
| 8915 | "Address family\n" |
| 8916 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8917 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8918 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8919 | |
| 8920 | /* old command */ |
| 8921 | DEFUN (show_ipv6_bgp_community_list, |
| 8922 | show_ipv6_bgp_community_list_cmd, |
| 8923 | "show ipv6 bgp community-list WORD", |
| 8924 | SHOW_STR |
| 8925 | IPV6_STR |
| 8926 | BGP_STR |
| 8927 | "Display routes matching the community-list\n" |
| 8928 | "community-list name\n") |
| 8929 | { |
| 8930 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8931 | } |
| 8932 | |
| 8933 | /* old command */ |
| 8934 | DEFUN (show_ipv6_mbgp_community_list, |
| 8935 | show_ipv6_mbgp_community_list_cmd, |
| 8936 | "show ipv6 mbgp community-list WORD", |
| 8937 | SHOW_STR |
| 8938 | IPV6_STR |
| 8939 | MBGP_STR |
| 8940 | "Display routes matching the community-list\n" |
| 8941 | "community-list name\n") |
| 8942 | { |
| 8943 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8944 | } |
| 8945 | |
| 8946 | DEFUN (show_bgp_community_list_exact, |
| 8947 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8948 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8949 | SHOW_STR |
| 8950 | BGP_STR |
| 8951 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8952 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8953 | "community-list name\n" |
| 8954 | "Exact match of the communities\n") |
| 8955 | { |
| 8956 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8957 | } |
| 8958 | |
| 8959 | ALIAS (show_bgp_community_list_exact, |
| 8960 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8961 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8962 | SHOW_STR |
| 8963 | BGP_STR |
| 8964 | "Address family\n" |
| 8965 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8966 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8967 | "community-list name\n" |
| 8968 | "Exact match of the communities\n") |
| 8969 | |
| 8970 | /* old command */ |
| 8971 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 8972 | show_ipv6_bgp_community_list_exact_cmd, |
| 8973 | "show ipv6 bgp community-list WORD exact-match", |
| 8974 | SHOW_STR |
| 8975 | IPV6_STR |
| 8976 | BGP_STR |
| 8977 | "Display routes matching the community-list\n" |
| 8978 | "community-list name\n" |
| 8979 | "Exact match of the communities\n") |
| 8980 | { |
| 8981 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8982 | } |
| 8983 | |
| 8984 | /* old command */ |
| 8985 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 8986 | show_ipv6_mbgp_community_list_exact_cmd, |
| 8987 | "show ipv6 mbgp community-list WORD exact-match", |
| 8988 | SHOW_STR |
| 8989 | IPV6_STR |
| 8990 | MBGP_STR |
| 8991 | "Display routes matching the community-list\n" |
| 8992 | "community-list name\n" |
| 8993 | "Exact match of the communities\n") |
| 8994 | { |
| 8995 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 8996 | } |
| 8997 | #endif /* HAVE_IPV6 */ |
| 8998 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8999 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9000 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9001 | safi_t safi, enum bgp_show_type type) |
| 9002 | { |
| 9003 | int ret; |
| 9004 | struct prefix *p; |
| 9005 | |
| 9006 | p = prefix_new(); |
| 9007 | |
| 9008 | ret = str2prefix (prefix, p); |
| 9009 | if (! ret) |
| 9010 | { |
| 9011 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9012 | return CMD_WARNING; |
| 9013 | } |
| 9014 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9015 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9016 | prefix_free(p); |
| 9017 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9018 | } |
| 9019 | |
| 9020 | DEFUN (show_ip_bgp_prefix_longer, |
| 9021 | show_ip_bgp_prefix_longer_cmd, |
| 9022 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9023 | SHOW_STR |
| 9024 | IP_STR |
| 9025 | BGP_STR |
| 9026 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9027 | "Display route and more specific routes\n") |
| 9028 | { |
| 9029 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9030 | bgp_show_type_prefix_longer); |
| 9031 | } |
| 9032 | |
| 9033 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9034 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9035 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9036 | SHOW_STR |
| 9037 | IP_STR |
| 9038 | BGP_STR |
| 9039 | "Display flap statistics of routes\n" |
| 9040 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9041 | "Display route and more specific routes\n") |
| 9042 | { |
| 9043 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9044 | bgp_show_type_flap_prefix_longer); |
| 9045 | } |
| 9046 | |
| 9047 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9048 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9049 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9050 | SHOW_STR |
| 9051 | IP_STR |
| 9052 | BGP_STR |
| 9053 | "Address family\n" |
| 9054 | "Address Family modifier\n" |
| 9055 | "Address Family modifier\n" |
| 9056 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9057 | "Display route and more specific routes\n") |
| 9058 | { |
| 9059 | if (strncmp (argv[0], "m", 1) == 0) |
| 9060 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9061 | bgp_show_type_prefix_longer); |
| 9062 | |
| 9063 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9064 | bgp_show_type_prefix_longer); |
| 9065 | } |
| 9066 | |
| 9067 | DEFUN (show_ip_bgp_flap_address, |
| 9068 | show_ip_bgp_flap_address_cmd, |
| 9069 | "show ip bgp flap-statistics A.B.C.D", |
| 9070 | SHOW_STR |
| 9071 | IP_STR |
| 9072 | BGP_STR |
| 9073 | "Display flap statistics of routes\n" |
| 9074 | "Network in the BGP routing table to display\n") |
| 9075 | { |
| 9076 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9077 | bgp_show_type_flap_address); |
| 9078 | } |
| 9079 | |
| 9080 | DEFUN (show_ip_bgp_flap_prefix, |
| 9081 | show_ip_bgp_flap_prefix_cmd, |
| 9082 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9083 | SHOW_STR |
| 9084 | IP_STR |
| 9085 | BGP_STR |
| 9086 | "Display flap statistics of routes\n" |
| 9087 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9088 | { |
| 9089 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9090 | bgp_show_type_flap_prefix); |
| 9091 | } |
| 9092 | #ifdef HAVE_IPV6 |
| 9093 | DEFUN (show_bgp_prefix_longer, |
| 9094 | show_bgp_prefix_longer_cmd, |
| 9095 | "show bgp X:X::X:X/M longer-prefixes", |
| 9096 | SHOW_STR |
| 9097 | BGP_STR |
| 9098 | "IPv6 prefix <network>/<length>\n" |
| 9099 | "Display route and more specific routes\n") |
| 9100 | { |
| 9101 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9102 | bgp_show_type_prefix_longer); |
| 9103 | } |
| 9104 | |
| 9105 | ALIAS (show_bgp_prefix_longer, |
| 9106 | show_bgp_ipv6_prefix_longer_cmd, |
| 9107 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9108 | SHOW_STR |
| 9109 | BGP_STR |
| 9110 | "Address family\n" |
| 9111 | "IPv6 prefix <network>/<length>\n" |
| 9112 | "Display route and more specific routes\n") |
| 9113 | |
| 9114 | /* old command */ |
| 9115 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9116 | show_ipv6_bgp_prefix_longer_cmd, |
| 9117 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9118 | SHOW_STR |
| 9119 | IPV6_STR |
| 9120 | BGP_STR |
| 9121 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9122 | "Display route and more specific routes\n") |
| 9123 | { |
| 9124 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9125 | bgp_show_type_prefix_longer); |
| 9126 | } |
| 9127 | |
| 9128 | /* old command */ |
| 9129 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9130 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9131 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9132 | SHOW_STR |
| 9133 | IPV6_STR |
| 9134 | MBGP_STR |
| 9135 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9136 | "Display route and more specific routes\n") |
| 9137 | { |
| 9138 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9139 | bgp_show_type_prefix_longer); |
| 9140 | } |
| 9141 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9142 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9143 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9144 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9145 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9146 | { |
| 9147 | int ret; |
| 9148 | struct bgp *bgp; |
| 9149 | struct peer *peer; |
| 9150 | union sockunion su; |
| 9151 | |
| 9152 | /* BGP structure lookup. */ |
| 9153 | if (view_name) |
| 9154 | { |
| 9155 | bgp = bgp_lookup_by_name (view_name); |
| 9156 | if (! bgp) |
| 9157 | { |
| 9158 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9159 | return NULL; |
| 9160 | } |
| 9161 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9162 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9163 | { |
| 9164 | bgp = bgp_get_default (); |
| 9165 | if (! bgp) |
| 9166 | { |
| 9167 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9168 | return NULL; |
| 9169 | } |
| 9170 | } |
| 9171 | |
| 9172 | /* Get peer sockunion. */ |
| 9173 | ret = str2sockunion (ip_str, &su); |
| 9174 | if (ret < 0) |
| 9175 | { |
| 9176 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9177 | return NULL; |
| 9178 | } |
| 9179 | |
| 9180 | /* Peer structure lookup. */ |
| 9181 | peer = peer_lookup (bgp, &su); |
| 9182 | if (! peer) |
| 9183 | { |
| 9184 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9185 | return NULL; |
| 9186 | } |
| 9187 | |
| 9188 | return peer; |
| 9189 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9190 | |
| 9191 | enum bgp_stats |
| 9192 | { |
| 9193 | BGP_STATS_MAXBITLEN = 0, |
| 9194 | BGP_STATS_RIB, |
| 9195 | BGP_STATS_PREFIXES, |
| 9196 | BGP_STATS_TOTPLEN, |
| 9197 | BGP_STATS_UNAGGREGATEABLE, |
| 9198 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9199 | BGP_STATS_AGGREGATES, |
| 9200 | BGP_STATS_SPACE, |
| 9201 | BGP_STATS_ASPATH_COUNT, |
| 9202 | BGP_STATS_ASPATH_MAXHOPS, |
| 9203 | BGP_STATS_ASPATH_TOTHOPS, |
| 9204 | BGP_STATS_ASPATH_MAXSIZE, |
| 9205 | BGP_STATS_ASPATH_TOTSIZE, |
| 9206 | BGP_STATS_ASN_HIGHEST, |
| 9207 | BGP_STATS_MAX, |
| 9208 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9209 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9210 | static const char *table_stats_strs[] = |
| 9211 | { |
| 9212 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9213 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9214 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9215 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9216 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9217 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9218 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9219 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9220 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9221 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9222 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9223 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9224 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9225 | [BGP_STATS_MAX] = NULL, |
| 9226 | }; |
| 9227 | |
| 9228 | struct bgp_table_stats |
| 9229 | { |
| 9230 | struct bgp_table *table; |
| 9231 | unsigned long long counts[BGP_STATS_MAX]; |
| 9232 | }; |
| 9233 | |
| 9234 | #if 0 |
| 9235 | #define TALLY_SIGFIG 100000 |
| 9236 | static unsigned long |
| 9237 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9238 | { |
| 9239 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9240 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9241 | unsigned long ret = newtot / count; |
| 9242 | |
| 9243 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9244 | return ret + 1; |
| 9245 | else |
| 9246 | return ret; |
| 9247 | } |
| 9248 | #endif |
| 9249 | |
| 9250 | static int |
| 9251 | bgp_table_stats_walker (struct thread *t) |
| 9252 | { |
| 9253 | struct bgp_node *rn; |
| 9254 | struct bgp_node *top; |
| 9255 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9256 | unsigned int space = 0; |
| 9257 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9258 | if (!(top = bgp_table_top (ts->table))) |
| 9259 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9260 | |
| 9261 | switch (top->p.family) |
| 9262 | { |
| 9263 | case AF_INET: |
| 9264 | space = IPV4_MAX_BITLEN; |
| 9265 | break; |
| 9266 | case AF_INET6: |
| 9267 | space = IPV6_MAX_BITLEN; |
| 9268 | break; |
| 9269 | } |
| 9270 | |
| 9271 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9272 | |
| 9273 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9274 | { |
| 9275 | struct bgp_info *ri; |
| 9276 | struct bgp_node *prn = rn->parent; |
| 9277 | unsigned int rinum = 0; |
| 9278 | |
| 9279 | if (rn == top) |
| 9280 | continue; |
| 9281 | |
| 9282 | if (!rn->info) |
| 9283 | continue; |
| 9284 | |
| 9285 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9286 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9287 | |
| 9288 | #if 0 |
| 9289 | ts->counts[BGP_STATS_AVGPLEN] |
| 9290 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9291 | ts->counts[BGP_STATS_AVGPLEN], |
| 9292 | rn->p.prefixlen); |
| 9293 | #endif |
| 9294 | |
| 9295 | /* check if the prefix is included by any other announcements */ |
| 9296 | while (prn && !prn->info) |
| 9297 | prn = prn->parent; |
| 9298 | |
| 9299 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9300 | { |
| 9301 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9302 | /* announced address space */ |
| 9303 | if (space) |
| 9304 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9305 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9306 | else if (prn->info) |
| 9307 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9308 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9309 | for (ri = rn->info; ri; ri = ri->next) |
| 9310 | { |
| 9311 | rinum++; |
| 9312 | ts->counts[BGP_STATS_RIB]++; |
| 9313 | |
| 9314 | if (ri->attr && |
| 9315 | (CHECK_FLAG (ri->attr->flag, |
| 9316 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9317 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9318 | |
| 9319 | /* as-path stats */ |
| 9320 | if (ri->attr && ri->attr->aspath) |
| 9321 | { |
| 9322 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9323 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9324 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9325 | |
| 9326 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9327 | |
| 9328 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9329 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9330 | |
| 9331 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9332 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9333 | |
| 9334 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9335 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9336 | #if 0 |
| 9337 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9338 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9339 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9340 | hops); |
| 9341 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9342 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9343 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9344 | size); |
| 9345 | #endif |
| 9346 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9347 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9348 | } |
| 9349 | } |
| 9350 | } |
| 9351 | return 0; |
| 9352 | } |
| 9353 | |
| 9354 | static int |
| 9355 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9356 | { |
| 9357 | struct bgp_table_stats ts; |
| 9358 | unsigned int i; |
| 9359 | |
| 9360 | if (!bgp->rib[afi][safi]) |
| 9361 | { |
| 9362 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9363 | return CMD_WARNING; |
| 9364 | } |
| 9365 | |
| 9366 | memset (&ts, 0, sizeof (ts)); |
| 9367 | ts.table = bgp->rib[afi][safi]; |
| 9368 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9369 | |
| 9370 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9371 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9372 | |
| 9373 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9374 | { |
| 9375 | if (!table_stats_strs[i]) |
| 9376 | continue; |
| 9377 | |
| 9378 | switch (i) |
| 9379 | { |
| 9380 | #if 0 |
| 9381 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9382 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9383 | case BGP_STATS_AVGPLEN: |
| 9384 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9385 | vty_out (vty, "%12.2f", |
| 9386 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9387 | break; |
| 9388 | #endif |
| 9389 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9390 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9391 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9392 | vty_out (vty, "%12.2f", |
| 9393 | ts.counts[i] ? |
| 9394 | (float)ts.counts[i] / |
| 9395 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9396 | : 0); |
| 9397 | break; |
| 9398 | case BGP_STATS_TOTPLEN: |
| 9399 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9400 | vty_out (vty, "%12.2f", |
| 9401 | ts.counts[i] ? |
| 9402 | (float)ts.counts[i] / |
| 9403 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9404 | : 0); |
| 9405 | break; |
| 9406 | case BGP_STATS_SPACE: |
| 9407 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9408 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9409 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9410 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9411 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9412 | vty_out (vty, "%12.2f%s", |
| 9413 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9414 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9415 | VTY_NEWLINE); |
| 9416 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9417 | vty_out (vty, "%12.2f%s", |
| 9418 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9419 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9420 | VTY_NEWLINE); |
| 9421 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9422 | break; |
| 9423 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9424 | vty_out (vty, "%12.2f", |
| 9425 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9426 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9427 | break; |
| 9428 | default: |
| 9429 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9430 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9431 | } |
| 9432 | |
| 9433 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9434 | } |
| 9435 | return CMD_SUCCESS; |
| 9436 | } |
| 9437 | |
| 9438 | static int |
| 9439 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9440 | const char *afi_str, const char *safi_str) |
| 9441 | { |
| 9442 | struct bgp *bgp; |
| 9443 | afi_t afi; |
| 9444 | safi_t safi; |
| 9445 | |
| 9446 | if (name) |
| 9447 | bgp = bgp_lookup_by_name (name); |
| 9448 | else |
| 9449 | bgp = bgp_get_default (); |
| 9450 | |
| 9451 | if (!bgp) |
| 9452 | { |
| 9453 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9454 | return CMD_WARNING; |
| 9455 | } |
| 9456 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9457 | { |
| 9458 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9459 | afi = AFI_IP; |
| 9460 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9461 | afi = AFI_IP6; |
| 9462 | else |
| 9463 | { |
| 9464 | vty_out (vty, "%% Invalid address family %s%s", |
| 9465 | afi_str, VTY_NEWLINE); |
| 9466 | return CMD_WARNING; |
| 9467 | } |
| 9468 | if (strncmp (safi_str, "m", 1) == 0) |
| 9469 | safi = SAFI_MULTICAST; |
| 9470 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9471 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9472 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9473 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9474 | else |
| 9475 | { |
| 9476 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9477 | safi_str, VTY_NEWLINE); |
| 9478 | return CMD_WARNING; |
| 9479 | } |
| 9480 | } |
| 9481 | else |
| 9482 | { |
| 9483 | vty_out (vty, "%% Invalid address family %s%s", |
| 9484 | afi_str, VTY_NEWLINE); |
| 9485 | return CMD_WARNING; |
| 9486 | } |
| 9487 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9488 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9489 | } |
| 9490 | |
| 9491 | DEFUN (show_bgp_statistics, |
| 9492 | show_bgp_statistics_cmd, |
| 9493 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9494 | SHOW_STR |
| 9495 | BGP_STR |
| 9496 | "Address family\n" |
| 9497 | "Address family\n" |
| 9498 | "Address Family modifier\n" |
| 9499 | "Address Family modifier\n" |
| 9500 | "BGP RIB advertisement statistics\n") |
| 9501 | { |
| 9502 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9503 | } |
| 9504 | |
| 9505 | ALIAS (show_bgp_statistics, |
| 9506 | show_bgp_statistics_vpnv4_cmd, |
| 9507 | "show bgp (ipv4) (vpnv4) statistics", |
| 9508 | SHOW_STR |
| 9509 | BGP_STR |
| 9510 | "Address family\n" |
| 9511 | "Address Family modifier\n" |
| 9512 | "BGP RIB advertisement statistics\n") |
| 9513 | |
| 9514 | DEFUN (show_bgp_statistics_view, |
| 9515 | show_bgp_statistics_view_cmd, |
| 9516 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9517 | SHOW_STR |
| 9518 | BGP_STR |
| 9519 | "BGP view\n" |
| 9520 | "Address family\n" |
| 9521 | "Address family\n" |
| 9522 | "Address Family modifier\n" |
| 9523 | "Address Family modifier\n" |
| 9524 | "BGP RIB advertisement statistics\n") |
| 9525 | { |
| 9526 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9527 | } |
| 9528 | |
| 9529 | ALIAS (show_bgp_statistics_view, |
| 9530 | show_bgp_statistics_view_vpnv4_cmd, |
| 9531 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9532 | SHOW_STR |
| 9533 | BGP_STR |
| 9534 | "BGP view\n" |
| 9535 | "Address family\n" |
| 9536 | "Address Family modifier\n" |
| 9537 | "BGP RIB advertisement statistics\n") |
| 9538 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9539 | enum bgp_pcounts |
| 9540 | { |
| 9541 | PCOUNT_ADJ_IN = 0, |
| 9542 | PCOUNT_DAMPED, |
| 9543 | PCOUNT_REMOVED, |
| 9544 | PCOUNT_HISTORY, |
| 9545 | PCOUNT_STALE, |
| 9546 | PCOUNT_VALID, |
| 9547 | PCOUNT_ALL, |
| 9548 | PCOUNT_COUNTED, |
| 9549 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9550 | PCOUNT_MAX, |
| 9551 | }; |
| 9552 | |
| 9553 | static const char *pcount_strs[] = |
| 9554 | { |
| 9555 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9556 | [PCOUNT_DAMPED] = "Damped", |
| 9557 | [PCOUNT_REMOVED] = "Removed", |
| 9558 | [PCOUNT_HISTORY] = "History", |
| 9559 | [PCOUNT_STALE] = "Stale", |
| 9560 | [PCOUNT_VALID] = "Valid", |
| 9561 | [PCOUNT_ALL] = "All RIB", |
| 9562 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9563 | [PCOUNT_PFCNT] = "Useable", |
| 9564 | [PCOUNT_MAX] = NULL, |
| 9565 | }; |
| 9566 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9567 | struct peer_pcounts |
| 9568 | { |
| 9569 | unsigned int count[PCOUNT_MAX]; |
| 9570 | const struct peer *peer; |
| 9571 | const struct bgp_table *table; |
| 9572 | }; |
| 9573 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9574 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9575 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9576 | { |
| 9577 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9578 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9579 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9580 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9581 | 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] | 9582 | { |
| 9583 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9584 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9585 | |
| 9586 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9587 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9588 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9589 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9590 | for (ri = rn->info; ri; ri = ri->next) |
| 9591 | { |
| 9592 | char buf[SU_ADDRSTRLEN]; |
| 9593 | |
| 9594 | if (ri->peer != peer) |
| 9595 | continue; |
| 9596 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9597 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9598 | |
| 9599 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9600 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9601 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9602 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9603 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9604 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9605 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9606 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9607 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9608 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9609 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9610 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9611 | |
| 9612 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9613 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9614 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9615 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9616 | plog_warn (peer->log, |
| 9617 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9618 | peer->host, |
| 9619 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9620 | buf, SU_ADDRSTRLEN), |
| 9621 | rn->p.prefixlen, |
| 9622 | ri->flags); |
| 9623 | } |
| 9624 | else |
| 9625 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9626 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9627 | plog_warn (peer->log, |
| 9628 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9629 | peer->host, |
| 9630 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9631 | buf, SU_ADDRSTRLEN), |
| 9632 | rn->p.prefixlen, |
| 9633 | ri->flags); |
| 9634 | } |
| 9635 | } |
| 9636 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9637 | return 0; |
| 9638 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9639 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9640 | static int |
| 9641 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9642 | { |
| 9643 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9644 | unsigned int i; |
| 9645 | |
| 9646 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9647 | || !peer->bgp->rib[afi][safi]) |
| 9648 | { |
| 9649 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9650 | return CMD_WARNING; |
| 9651 | } |
| 9652 | |
| 9653 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9654 | pcounts.peer = peer; |
| 9655 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9656 | |
| 9657 | /* in-place call via thread subsystem so as to record execution time |
| 9658 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9659 | * on just vty_read()). |
| 9660 | */ |
| 9661 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9662 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9663 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9664 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9665 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9666 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9667 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9668 | |
| 9669 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9670 | vty_out (vty, "%20s: %-10d%s", |
| 9671 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9672 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9673 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9674 | { |
| 9675 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9676 | peer->host, VTY_NEWLINE); |
| 9677 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9678 | VTY_NEWLINE); |
| 9679 | } |
| 9680 | |
| 9681 | return CMD_SUCCESS; |
| 9682 | } |
| 9683 | |
| 9684 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9685 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9686 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9687 | SHOW_STR |
| 9688 | IP_STR |
| 9689 | BGP_STR |
| 9690 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9691 | "Neighbor to display information about\n" |
| 9692 | "Neighbor to display information about\n" |
| 9693 | "Display detailed prefix count information\n") |
| 9694 | { |
| 9695 | struct peer *peer; |
| 9696 | |
| 9697 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9698 | if (! peer) |
| 9699 | return CMD_WARNING; |
| 9700 | |
| 9701 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9702 | } |
| 9703 | |
| 9704 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9705 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9706 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9707 | SHOW_STR |
| 9708 | BGP_STR |
| 9709 | "Address family\n" |
| 9710 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9711 | "Neighbor to display information about\n" |
| 9712 | "Neighbor to display information about\n" |
| 9713 | "Display detailed prefix count information\n") |
| 9714 | { |
| 9715 | struct peer *peer; |
| 9716 | |
| 9717 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9718 | if (! peer) |
| 9719 | return CMD_WARNING; |
| 9720 | |
| 9721 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9722 | } |
| 9723 | |
| 9724 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9725 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9726 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9727 | SHOW_STR |
| 9728 | IP_STR |
| 9729 | BGP_STR |
| 9730 | "Address family\n" |
| 9731 | "Address Family modifier\n" |
| 9732 | "Address Family modifier\n" |
| 9733 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9734 | "Neighbor to display information about\n" |
| 9735 | "Neighbor to display information about\n" |
| 9736 | "Display detailed prefix count information\n") |
| 9737 | { |
| 9738 | struct peer *peer; |
| 9739 | |
| 9740 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9741 | if (! peer) |
| 9742 | return CMD_WARNING; |
| 9743 | |
| 9744 | if (strncmp (argv[0], "m", 1) == 0) |
| 9745 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9746 | |
| 9747 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9748 | } |
| 9749 | |
| 9750 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9751 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9752 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9753 | SHOW_STR |
| 9754 | IP_STR |
| 9755 | BGP_STR |
| 9756 | "Address family\n" |
| 9757 | "Address Family modifier\n" |
| 9758 | "Address Family modifier\n" |
| 9759 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9760 | "Neighbor to display information about\n" |
| 9761 | "Neighbor to display information about\n" |
| 9762 | "Display detailed prefix count information\n") |
| 9763 | { |
| 9764 | struct peer *peer; |
| 9765 | |
| 9766 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9767 | if (! peer) |
| 9768 | return CMD_WARNING; |
| 9769 | |
| 9770 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9771 | } |
| 9772 | |
| 9773 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9774 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9775 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9776 | int in) |
| 9777 | { |
| 9778 | struct bgp_table *table; |
| 9779 | struct bgp_adj_in *ain; |
| 9780 | struct bgp_adj_out *adj; |
| 9781 | unsigned long output_count; |
| 9782 | struct bgp_node *rn; |
| 9783 | int header1 = 1; |
| 9784 | struct bgp *bgp; |
| 9785 | int header2 = 1; |
| 9786 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9787 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9788 | |
| 9789 | if (! bgp) |
| 9790 | return; |
| 9791 | |
| 9792 | table = bgp->rib[afi][safi]; |
| 9793 | |
| 9794 | output_count = 0; |
| 9795 | |
| 9796 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9797 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9798 | { |
| 9799 | 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] | 9800 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9801 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9802 | |
| 9803 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9804 | VTY_NEWLINE, VTY_NEWLINE); |
| 9805 | header1 = 0; |
| 9806 | } |
| 9807 | |
| 9808 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9809 | if (in) |
| 9810 | { |
| 9811 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9812 | if (ain->peer == peer) |
| 9813 | { |
| 9814 | if (header1) |
| 9815 | { |
| 9816 | 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] | 9817 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9818 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9819 | header1 = 0; |
| 9820 | } |
| 9821 | if (header2) |
| 9822 | { |
| 9823 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9824 | header2 = 0; |
| 9825 | } |
| 9826 | if (ain->attr) |
| 9827 | { |
| 9828 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9829 | output_count++; |
| 9830 | } |
| 9831 | } |
| 9832 | } |
| 9833 | else |
| 9834 | { |
| 9835 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9836 | if (adj->peer == peer) |
| 9837 | { |
| 9838 | if (header1) |
| 9839 | { |
| 9840 | 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] | 9841 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9842 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9843 | header1 = 0; |
| 9844 | } |
| 9845 | if (header2) |
| 9846 | { |
| 9847 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9848 | header2 = 0; |
| 9849 | } |
| 9850 | if (adj->attr) |
| 9851 | { |
| 9852 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9853 | output_count++; |
| 9854 | } |
| 9855 | } |
| 9856 | } |
| 9857 | |
| 9858 | if (output_count != 0) |
| 9859 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9860 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9861 | } |
| 9862 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9863 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9864 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9865 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9866 | if (! peer || ! peer->afc[afi][safi]) |
| 9867 | { |
| 9868 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9869 | return CMD_WARNING; |
| 9870 | } |
| 9871 | |
| 9872 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9873 | { |
| 9874 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9875 | VTY_NEWLINE); |
| 9876 | return CMD_WARNING; |
| 9877 | } |
| 9878 | |
| 9879 | show_adj_route (vty, peer, afi, safi, in); |
| 9880 | |
| 9881 | return CMD_SUCCESS; |
| 9882 | } |
| 9883 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 9884 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 9885 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 9886 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9887 | SHOW_STR |
| 9888 | IP_STR |
| 9889 | BGP_STR |
| 9890 | "BGP view\n" |
| 9891 | "View name\n" |
| 9892 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9893 | "Neighbor to display information about\n" |
| 9894 | "Neighbor to display information about\n" |
| 9895 | "Display the routes advertised to a BGP neighbor\n") |
| 9896 | { |
| 9897 | struct peer *peer; |
| 9898 | |
| 9899 | if (argc == 2) |
| 9900 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9901 | else |
| 9902 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9903 | |
| 9904 | if (! peer) |
| 9905 | return CMD_WARNING; |
| 9906 | |
| 9907 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 9908 | } |
| 9909 | |
| 9910 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9911 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9912 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9913 | SHOW_STR |
| 9914 | IP_STR |
| 9915 | BGP_STR |
| 9916 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9917 | "Neighbor to display information about\n" |
| 9918 | "Neighbor to display information about\n" |
| 9919 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9920 | |
| 9921 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9922 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9923 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9924 | SHOW_STR |
| 9925 | IP_STR |
| 9926 | BGP_STR |
| 9927 | "Address family\n" |
| 9928 | "Address Family modifier\n" |
| 9929 | "Address Family modifier\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 the routes advertised to a BGP neighbor\n") |
| 9934 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9935 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9936 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9937 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9938 | if (! peer) |
| 9939 | return CMD_WARNING; |
| 9940 | |
| 9941 | if (strncmp (argv[0], "m", 1) == 0) |
| 9942 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 9943 | |
| 9944 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9945 | } |
| 9946 | |
| 9947 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9948 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 9949 | show_bgp_view_neighbor_advertised_route_cmd, |
| 9950 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9951 | SHOW_STR |
| 9952 | BGP_STR |
| 9953 | "BGP view\n" |
| 9954 | "View name\n" |
| 9955 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9956 | "Neighbor to display information about\n" |
| 9957 | "Neighbor to display information about\n" |
| 9958 | "Display the routes advertised to a BGP neighbor\n") |
| 9959 | { |
| 9960 | struct peer *peer; |
| 9961 | |
| 9962 | if (argc == 2) |
| 9963 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9964 | else |
| 9965 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9966 | |
| 9967 | if (! peer) |
| 9968 | return CMD_WARNING; |
| 9969 | |
| 9970 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 9971 | } |
| 9972 | |
| 9973 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 9974 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 9975 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9976 | SHOW_STR |
| 9977 | BGP_STR |
| 9978 | "BGP view\n" |
| 9979 | "View name\n" |
| 9980 | "Address family\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 the routes advertised to a BGP neighbor\n") |
| 9985 | |
| 9986 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 9987 | show_bgp_view_neighbor_received_routes_cmd, |
| 9988 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 9989 | SHOW_STR |
| 9990 | BGP_STR |
| 9991 | "BGP view\n" |
| 9992 | "View name\n" |
| 9993 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9994 | "Neighbor to display information about\n" |
| 9995 | "Neighbor to display information about\n" |
| 9996 | "Display the received routes from neighbor\n") |
| 9997 | { |
| 9998 | struct peer *peer; |
| 9999 | |
| 10000 | if (argc == 2) |
| 10001 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10002 | else |
| 10003 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10004 | |
| 10005 | if (! peer) |
| 10006 | return CMD_WARNING; |
| 10007 | |
| 10008 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10009 | } |
| 10010 | |
| 10011 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10012 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10013 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10014 | SHOW_STR |
| 10015 | BGP_STR |
| 10016 | "BGP view\n" |
| 10017 | "View name\n" |
| 10018 | "Address family\n" |
| 10019 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10020 | "Neighbor to display information about\n" |
| 10021 | "Neighbor to display information about\n" |
| 10022 | "Display the received routes from neighbor\n") |
| 10023 | |
| 10024 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10025 | show_bgp_neighbor_advertised_route_cmd, |
| 10026 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10027 | SHOW_STR |
| 10028 | BGP_STR |
| 10029 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10030 | "Neighbor to display information about\n" |
| 10031 | "Neighbor to display information about\n" |
| 10032 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10033 | |
| 10034 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10035 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10036 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10037 | SHOW_STR |
| 10038 | BGP_STR |
| 10039 | "Address family\n" |
| 10040 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10041 | "Neighbor to display information about\n" |
| 10042 | "Neighbor to display information about\n" |
| 10043 | "Display the routes advertised to a BGP neighbor\n") |
| 10044 | |
| 10045 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10046 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10047 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10048 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10049 | SHOW_STR |
| 10050 | IPV6_STR |
| 10051 | BGP_STR |
| 10052 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10053 | "Neighbor to display information about\n" |
| 10054 | "Neighbor to display information about\n" |
| 10055 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10056 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10057 | /* old command */ |
| 10058 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10059 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10060 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10061 | SHOW_STR |
| 10062 | IPV6_STR |
| 10063 | MBGP_STR |
| 10064 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10065 | "Neighbor to display information about\n" |
| 10066 | "Neighbor to display information about\n" |
| 10067 | "Display the routes advertised to a BGP neighbor\n") |
| 10068 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10069 | struct peer *peer; |
| 10070 | |
| 10071 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10072 | if (! peer) |
| 10073 | return CMD_WARNING; |
| 10074 | |
| 10075 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10076 | } |
| 10077 | #endif /* HAVE_IPV6 */ |
| 10078 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10079 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10080 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10081 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10082 | SHOW_STR |
| 10083 | IP_STR |
| 10084 | BGP_STR |
| 10085 | "BGP view\n" |
| 10086 | "View name\n" |
| 10087 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10088 | "Neighbor to display information about\n" |
| 10089 | "Neighbor to display information about\n" |
| 10090 | "Display the received routes from neighbor\n") |
| 10091 | { |
| 10092 | struct peer *peer; |
| 10093 | |
| 10094 | if (argc == 2) |
| 10095 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10096 | else |
| 10097 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10098 | |
| 10099 | if (! peer) |
| 10100 | return CMD_WARNING; |
| 10101 | |
| 10102 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10103 | } |
| 10104 | |
| 10105 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10106 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10107 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10108 | SHOW_STR |
| 10109 | IP_STR |
| 10110 | BGP_STR |
| 10111 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10112 | "Neighbor to display information about\n" |
| 10113 | "Neighbor to display information about\n" |
| 10114 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10115 | |
| 10116 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10117 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10118 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10119 | SHOW_STR |
| 10120 | IP_STR |
| 10121 | BGP_STR |
| 10122 | "Address family\n" |
| 10123 | "Address Family modifier\n" |
| 10124 | "Address Family modifier\n" |
| 10125 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10126 | "Neighbor to display information about\n" |
| 10127 | "Neighbor to display information about\n" |
| 10128 | "Display the received routes from neighbor\n") |
| 10129 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10130 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10131 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10132 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10133 | if (! peer) |
| 10134 | return CMD_WARNING; |
| 10135 | |
| 10136 | if (strncmp (argv[0], "m", 1) == 0) |
| 10137 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10138 | |
| 10139 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10140 | } |
| 10141 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10142 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10143 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
| 10144 | #ifdef HAVE_IPV6 |
| 10145 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10146 | #else |
| 10147 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10148 | #endif |
| 10149 | SHOW_STR |
| 10150 | BGP_STR |
| 10151 | "BGP view\n" |
| 10152 | "BGP view name\n" |
| 10153 | "Address family\n" |
| 10154 | #ifdef HAVE_IPV6 |
| 10155 | "Address family\n" |
| 10156 | #endif |
| 10157 | "Address family modifier\n" |
| 10158 | "Address family modifier\n" |
| 10159 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10160 | "Neighbor to display information about\n" |
| 10161 | "Neighbor to display information about\n" |
| 10162 | "Display the advertised routes to neighbor\n" |
| 10163 | "Display the received routes from neighbor\n") |
| 10164 | { |
| 10165 | int afi; |
| 10166 | int safi; |
| 10167 | int in; |
| 10168 | struct peer *peer; |
| 10169 | |
| 10170 | #ifdef HAVE_IPV6 |
| 10171 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
| 10172 | #else |
| 10173 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10174 | #endif |
| 10175 | |
| 10176 | if (! peer) |
| 10177 | return CMD_WARNING; |
| 10178 | |
| 10179 | #ifdef HAVE_IPV6 |
| 10180 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10181 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10182 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
| 10183 | #else |
| 10184 | afi = AFI_IP; |
| 10185 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10186 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; |
| 10187 | #endif |
| 10188 | |
| 10189 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10190 | } |
| 10191 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10192 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10193 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10194 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10195 | SHOW_STR |
| 10196 | IP_STR |
| 10197 | BGP_STR |
| 10198 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10199 | "Neighbor to display information about\n" |
| 10200 | "Neighbor to display information about\n" |
| 10201 | "Display information received from a BGP neighbor\n" |
| 10202 | "Display the prefixlist filter\n") |
| 10203 | { |
| 10204 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10205 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10206 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10207 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10208 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10209 | ret = str2sockunion (argv[0], &su); |
| 10210 | if (ret < 0) |
| 10211 | { |
| 10212 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10213 | return CMD_WARNING; |
| 10214 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10215 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10216 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10217 | if (! peer) |
| 10218 | return CMD_WARNING; |
| 10219 | |
| 10220 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10221 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10222 | if (count) |
| 10223 | { |
| 10224 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10225 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10226 | } |
| 10227 | |
| 10228 | return CMD_SUCCESS; |
| 10229 | } |
| 10230 | |
| 10231 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10232 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10233 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10234 | SHOW_STR |
| 10235 | IP_STR |
| 10236 | BGP_STR |
| 10237 | "Address family\n" |
| 10238 | "Address Family modifier\n" |
| 10239 | "Address Family modifier\n" |
| 10240 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10241 | "Neighbor to display information about\n" |
| 10242 | "Neighbor to display information about\n" |
| 10243 | "Display information received from a BGP neighbor\n" |
| 10244 | "Display the prefixlist filter\n") |
| 10245 | { |
| 10246 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10247 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10248 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10249 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10250 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10251 | ret = str2sockunion (argv[1], &su); |
| 10252 | if (ret < 0) |
| 10253 | { |
| 10254 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10255 | return CMD_WARNING; |
| 10256 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10257 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10258 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10259 | if (! peer) |
| 10260 | return CMD_WARNING; |
| 10261 | |
| 10262 | if (strncmp (argv[0], "m", 1) == 0) |
| 10263 | { |
| 10264 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10265 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10266 | if (count) |
| 10267 | { |
| 10268 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10269 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10270 | } |
| 10271 | } |
| 10272 | else |
| 10273 | { |
| 10274 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10275 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10276 | if (count) |
| 10277 | { |
| 10278 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10279 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10280 | } |
| 10281 | } |
| 10282 | |
| 10283 | return CMD_SUCCESS; |
| 10284 | } |
| 10285 | |
| 10286 | |
| 10287 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10288 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10289 | show_bgp_neighbor_received_routes_cmd, |
| 10290 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10291 | SHOW_STR |
| 10292 | BGP_STR |
| 10293 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10294 | "Neighbor to display information about\n" |
| 10295 | "Neighbor to display information about\n" |
| 10296 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10297 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10298 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10299 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10300 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10301 | SHOW_STR |
| 10302 | BGP_STR |
| 10303 | "Address family\n" |
| 10304 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10305 | "Neighbor to display information about\n" |
| 10306 | "Neighbor to display information about\n" |
| 10307 | "Display the received routes from neighbor\n") |
| 10308 | |
| 10309 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10310 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10311 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10312 | SHOW_STR |
| 10313 | BGP_STR |
| 10314 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10315 | "Neighbor to display information about\n" |
| 10316 | "Neighbor to display information about\n" |
| 10317 | "Display information received from a BGP neighbor\n" |
| 10318 | "Display the prefixlist filter\n") |
| 10319 | { |
| 10320 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10321 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10322 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10323 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10324 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10325 | ret = str2sockunion (argv[0], &su); |
| 10326 | if (ret < 0) |
| 10327 | { |
| 10328 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10329 | return CMD_WARNING; |
| 10330 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10331 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10332 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10333 | if (! peer) |
| 10334 | return CMD_WARNING; |
| 10335 | |
| 10336 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10337 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10338 | if (count) |
| 10339 | { |
| 10340 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10341 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10342 | } |
| 10343 | |
| 10344 | return CMD_SUCCESS; |
| 10345 | } |
| 10346 | |
| 10347 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10348 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10349 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10350 | SHOW_STR |
| 10351 | BGP_STR |
| 10352 | "Address family\n" |
| 10353 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10354 | "Neighbor to display information about\n" |
| 10355 | "Neighbor to display information about\n" |
| 10356 | "Display information received from a BGP neighbor\n" |
| 10357 | "Display the prefixlist filter\n") |
| 10358 | |
| 10359 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10360 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10361 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10362 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10363 | SHOW_STR |
| 10364 | IPV6_STR |
| 10365 | BGP_STR |
| 10366 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10367 | "Neighbor to display information about\n" |
| 10368 | "Neighbor to display information about\n" |
| 10369 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10370 | |
| 10371 | /* old command */ |
| 10372 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10373 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10374 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10375 | SHOW_STR |
| 10376 | IPV6_STR |
| 10377 | MBGP_STR |
| 10378 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10379 | "Neighbor to display information about\n" |
| 10380 | "Neighbor to display information about\n" |
| 10381 | "Display the received routes from neighbor\n") |
| 10382 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10383 | struct peer *peer; |
| 10384 | |
| 10385 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10386 | if (! peer) |
| 10387 | return CMD_WARNING; |
| 10388 | |
| 10389 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10390 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10391 | |
| 10392 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10393 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10394 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10395 | SHOW_STR |
| 10396 | BGP_STR |
| 10397 | "BGP view\n" |
| 10398 | "View name\n" |
| 10399 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10400 | "Neighbor to display information about\n" |
| 10401 | "Neighbor to display information about\n" |
| 10402 | "Display information received from a BGP neighbor\n" |
| 10403 | "Display the prefixlist filter\n") |
| 10404 | { |
| 10405 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10406 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10407 | struct peer *peer; |
| 10408 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10409 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10410 | |
| 10411 | /* BGP structure lookup. */ |
| 10412 | bgp = bgp_lookup_by_name (argv[0]); |
| 10413 | if (bgp == NULL) |
| 10414 | { |
| 10415 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10416 | return CMD_WARNING; |
| 10417 | } |
| 10418 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10419 | ret = str2sockunion (argv[1], &su); |
| 10420 | if (ret < 0) |
| 10421 | { |
| 10422 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10423 | return CMD_WARNING; |
| 10424 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10425 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10426 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10427 | if (! peer) |
| 10428 | return CMD_WARNING; |
| 10429 | |
| 10430 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10431 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10432 | if (count) |
| 10433 | { |
| 10434 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10435 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10436 | } |
| 10437 | |
| 10438 | return CMD_SUCCESS; |
| 10439 | } |
| 10440 | |
| 10441 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10442 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10443 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10444 | SHOW_STR |
| 10445 | BGP_STR |
| 10446 | "BGP view\n" |
| 10447 | "View name\n" |
| 10448 | "Address family\n" |
| 10449 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10450 | "Neighbor to display information about\n" |
| 10451 | "Neighbor to display information about\n" |
| 10452 | "Display information received from a BGP neighbor\n" |
| 10453 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10454 | #endif /* HAVE_IPV6 */ |
| 10455 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10456 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10457 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10458 | safi_t safi, enum bgp_show_type type) |
| 10459 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10460 | if (! peer || ! peer->afc[afi][safi]) |
| 10461 | { |
| 10462 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10463 | return CMD_WARNING; |
| 10464 | } |
| 10465 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10466 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10467 | } |
| 10468 | |
| 10469 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10470 | show_ip_bgp_neighbor_routes_cmd, |
| 10471 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10472 | SHOW_STR |
| 10473 | IP_STR |
| 10474 | BGP_STR |
| 10475 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10476 | "Neighbor to display information about\n" |
| 10477 | "Neighbor to display information about\n" |
| 10478 | "Display routes learned from neighbor\n") |
| 10479 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10480 | struct peer *peer; |
| 10481 | |
| 10482 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10483 | if (! peer) |
| 10484 | return CMD_WARNING; |
| 10485 | |
| 10486 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10487 | bgp_show_type_neighbor); |
| 10488 | } |
| 10489 | |
| 10490 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10491 | show_ip_bgp_neighbor_flap_cmd, |
| 10492 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10493 | SHOW_STR |
| 10494 | IP_STR |
| 10495 | BGP_STR |
| 10496 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10497 | "Neighbor to display information about\n" |
| 10498 | "Neighbor to display information about\n" |
| 10499 | "Display flap statistics of the routes learned from neighbor\n") |
| 10500 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10501 | struct peer *peer; |
| 10502 | |
| 10503 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10504 | if (! peer) |
| 10505 | return CMD_WARNING; |
| 10506 | |
| 10507 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10508 | bgp_show_type_flap_neighbor); |
| 10509 | } |
| 10510 | |
| 10511 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10512 | show_ip_bgp_neighbor_damp_cmd, |
| 10513 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10514 | SHOW_STR |
| 10515 | IP_STR |
| 10516 | BGP_STR |
| 10517 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10518 | "Neighbor to display information about\n" |
| 10519 | "Neighbor to display information about\n" |
| 10520 | "Display the dampened routes received from neighbor\n") |
| 10521 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10522 | struct peer *peer; |
| 10523 | |
| 10524 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10525 | if (! peer) |
| 10526 | return CMD_WARNING; |
| 10527 | |
| 10528 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10529 | bgp_show_type_damp_neighbor); |
| 10530 | } |
| 10531 | |
| 10532 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10533 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10534 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10535 | SHOW_STR |
| 10536 | IP_STR |
| 10537 | BGP_STR |
| 10538 | "Address family\n" |
| 10539 | "Address Family modifier\n" |
| 10540 | "Address Family modifier\n" |
| 10541 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10542 | "Neighbor to display information about\n" |
| 10543 | "Neighbor to display information about\n" |
| 10544 | "Display routes learned from neighbor\n") |
| 10545 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10546 | struct peer *peer; |
| 10547 | |
| 10548 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10549 | if (! peer) |
| 10550 | return CMD_WARNING; |
| 10551 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10552 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10553 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10554 | bgp_show_type_neighbor); |
| 10555 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10556 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10557 | bgp_show_type_neighbor); |
| 10558 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10559 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10560 | DEFUN (show_ip_bgp_view_rsclient, |
| 10561 | show_ip_bgp_view_rsclient_cmd, |
| 10562 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10563 | SHOW_STR |
| 10564 | IP_STR |
| 10565 | BGP_STR |
| 10566 | "BGP view\n" |
| 10567 | "BGP view name\n" |
| 10568 | "Information about Route Server Client\n" |
| 10569 | NEIGHBOR_ADDR_STR) |
| 10570 | { |
| 10571 | struct bgp_table *table; |
| 10572 | struct peer *peer; |
| 10573 | |
| 10574 | if (argc == 2) |
| 10575 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10576 | else |
| 10577 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10578 | |
| 10579 | if (! peer) |
| 10580 | return CMD_WARNING; |
| 10581 | |
| 10582 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10583 | { |
| 10584 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10585 | VTY_NEWLINE); |
| 10586 | return CMD_WARNING; |
| 10587 | } |
| 10588 | |
| 10589 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10590 | PEER_FLAG_RSERVER_CLIENT)) |
| 10591 | { |
| 10592 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10593 | VTY_NEWLINE); |
| 10594 | return CMD_WARNING; |
| 10595 | } |
| 10596 | |
| 10597 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10598 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10599 | 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] | 10600 | } |
| 10601 | |
| 10602 | ALIAS (show_ip_bgp_view_rsclient, |
| 10603 | show_ip_bgp_rsclient_cmd, |
| 10604 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10605 | SHOW_STR |
| 10606 | IP_STR |
| 10607 | BGP_STR |
| 10608 | "Information about Route Server Client\n" |
| 10609 | NEIGHBOR_ADDR_STR) |
| 10610 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10611 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10612 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10613 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10614 | SHOW_STR |
| 10615 | BGP_STR |
| 10616 | "BGP view\n" |
| 10617 | "BGP view name\n" |
| 10618 | "Address family\n" |
| 10619 | "Address Family modifier\n" |
| 10620 | "Address Family modifier\n" |
| 10621 | "Information about Route Server Client\n" |
| 10622 | NEIGHBOR_ADDR_STR) |
| 10623 | { |
| 10624 | struct bgp_table *table; |
| 10625 | struct peer *peer; |
| 10626 | safi_t safi; |
| 10627 | |
| 10628 | if (argc == 3) { |
| 10629 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10630 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10631 | } else { |
| 10632 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10633 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10634 | } |
| 10635 | |
| 10636 | if (! peer) |
| 10637 | return CMD_WARNING; |
| 10638 | |
| 10639 | if (! peer->afc[AFI_IP][safi]) |
| 10640 | { |
| 10641 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10642 | VTY_NEWLINE); |
| 10643 | return CMD_WARNING; |
| 10644 | } |
| 10645 | |
| 10646 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10647 | PEER_FLAG_RSERVER_CLIENT)) |
| 10648 | { |
| 10649 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10650 | VTY_NEWLINE); |
| 10651 | return CMD_WARNING; |
| 10652 | } |
| 10653 | |
| 10654 | table = peer->rib[AFI_IP][safi]; |
| 10655 | |
| 10656 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10657 | } |
| 10658 | |
| 10659 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10660 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10661 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10662 | SHOW_STR |
| 10663 | BGP_STR |
| 10664 | "Address family\n" |
| 10665 | "Address Family modifier\n" |
| 10666 | "Address Family modifier\n" |
| 10667 | "Information about Route Server Client\n" |
| 10668 | NEIGHBOR_ADDR_STR) |
| 10669 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10670 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10671 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10672 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10673 | SHOW_STR |
| 10674 | IP_STR |
| 10675 | BGP_STR |
| 10676 | "BGP view\n" |
| 10677 | "BGP view name\n" |
| 10678 | "Information about Route Server Client\n" |
| 10679 | NEIGHBOR_ADDR_STR |
| 10680 | "Network in the BGP routing table to display\n") |
| 10681 | { |
| 10682 | struct bgp *bgp; |
| 10683 | struct peer *peer; |
| 10684 | |
| 10685 | /* BGP structure lookup. */ |
| 10686 | if (argc == 3) |
| 10687 | { |
| 10688 | bgp = bgp_lookup_by_name (argv[0]); |
| 10689 | if (bgp == NULL) |
| 10690 | { |
| 10691 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10692 | return CMD_WARNING; |
| 10693 | } |
| 10694 | } |
| 10695 | else |
| 10696 | { |
| 10697 | bgp = bgp_get_default (); |
| 10698 | if (bgp == NULL) |
| 10699 | { |
| 10700 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10701 | return CMD_WARNING; |
| 10702 | } |
| 10703 | } |
| 10704 | |
| 10705 | if (argc == 3) |
| 10706 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10707 | else |
| 10708 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10709 | |
| 10710 | if (! peer) |
| 10711 | return CMD_WARNING; |
| 10712 | |
| 10713 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10714 | { |
| 10715 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10716 | VTY_NEWLINE); |
| 10717 | return CMD_WARNING; |
| 10718 | } |
| 10719 | |
| 10720 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10721 | PEER_FLAG_RSERVER_CLIENT)) |
| 10722 | { |
| 10723 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10724 | VTY_NEWLINE); |
| 10725 | return CMD_WARNING; |
| 10726 | } |
| 10727 | |
| 10728 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10729 | (argc == 3) ? argv[2] : argv[1], |
| 10730 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10731 | } |
| 10732 | |
| 10733 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10734 | show_ip_bgp_rsclient_route_cmd, |
| 10735 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10736 | SHOW_STR |
| 10737 | IP_STR |
| 10738 | BGP_STR |
| 10739 | "Information about Route Server Client\n" |
| 10740 | NEIGHBOR_ADDR_STR |
| 10741 | "Network in the BGP routing table to display\n") |
| 10742 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10743 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10744 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10745 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10746 | SHOW_STR |
| 10747 | BGP_STR |
| 10748 | "BGP view\n" |
| 10749 | "BGP view name\n" |
| 10750 | "Address family\n" |
| 10751 | "Address Family modifier\n" |
| 10752 | "Address Family modifier\n" |
| 10753 | "Information about Route Server Client\n" |
| 10754 | NEIGHBOR_ADDR_STR |
| 10755 | "Network in the BGP routing table to display\n") |
| 10756 | { |
| 10757 | struct bgp *bgp; |
| 10758 | struct peer *peer; |
| 10759 | safi_t safi; |
| 10760 | |
| 10761 | /* BGP structure lookup. */ |
| 10762 | if (argc == 4) |
| 10763 | { |
| 10764 | bgp = bgp_lookup_by_name (argv[0]); |
| 10765 | if (bgp == NULL) |
| 10766 | { |
| 10767 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10768 | return CMD_WARNING; |
| 10769 | } |
| 10770 | } |
| 10771 | else |
| 10772 | { |
| 10773 | bgp = bgp_get_default (); |
| 10774 | if (bgp == NULL) |
| 10775 | { |
| 10776 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10777 | return CMD_WARNING; |
| 10778 | } |
| 10779 | } |
| 10780 | |
| 10781 | if (argc == 4) { |
| 10782 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10783 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10784 | } else { |
| 10785 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10786 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10787 | } |
| 10788 | |
| 10789 | if (! peer) |
| 10790 | return CMD_WARNING; |
| 10791 | |
| 10792 | if (! peer->afc[AFI_IP][safi]) |
| 10793 | { |
| 10794 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10795 | VTY_NEWLINE); |
| 10796 | return CMD_WARNING; |
| 10797 | } |
| 10798 | |
| 10799 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10800 | PEER_FLAG_RSERVER_CLIENT)) |
| 10801 | { |
| 10802 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10803 | VTY_NEWLINE); |
| 10804 | return CMD_WARNING; |
| 10805 | } |
| 10806 | |
| 10807 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10808 | (argc == 4) ? argv[3] : argv[2], |
| 10809 | AFI_IP, safi, NULL, 0); |
| 10810 | } |
| 10811 | |
| 10812 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10813 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10814 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10815 | SHOW_STR |
| 10816 | BGP_STR |
| 10817 | "Address family\n" |
| 10818 | "Address Family modifier\n" |
| 10819 | "Address Family modifier\n" |
| 10820 | "Information about Route Server Client\n" |
| 10821 | NEIGHBOR_ADDR_STR |
| 10822 | "Network in the BGP routing table to display\n") |
| 10823 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10824 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10825 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10826 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10827 | SHOW_STR |
| 10828 | IP_STR |
| 10829 | BGP_STR |
| 10830 | "BGP view\n" |
| 10831 | "BGP view name\n" |
| 10832 | "Information about Route Server Client\n" |
| 10833 | NEIGHBOR_ADDR_STR |
| 10834 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10835 | { |
| 10836 | struct bgp *bgp; |
| 10837 | struct peer *peer; |
| 10838 | |
| 10839 | /* BGP structure lookup. */ |
| 10840 | if (argc == 3) |
| 10841 | { |
| 10842 | bgp = bgp_lookup_by_name (argv[0]); |
| 10843 | if (bgp == NULL) |
| 10844 | { |
| 10845 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10846 | return CMD_WARNING; |
| 10847 | } |
| 10848 | } |
| 10849 | else |
| 10850 | { |
| 10851 | bgp = bgp_get_default (); |
| 10852 | if (bgp == NULL) |
| 10853 | { |
| 10854 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10855 | return CMD_WARNING; |
| 10856 | } |
| 10857 | } |
| 10858 | |
| 10859 | if (argc == 3) |
| 10860 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10861 | else |
| 10862 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10863 | |
| 10864 | if (! peer) |
| 10865 | return CMD_WARNING; |
| 10866 | |
| 10867 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10868 | { |
| 10869 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10870 | VTY_NEWLINE); |
| 10871 | return CMD_WARNING; |
| 10872 | } |
| 10873 | |
| 10874 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10875 | PEER_FLAG_RSERVER_CLIENT)) |
| 10876 | { |
| 10877 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10878 | VTY_NEWLINE); |
| 10879 | return CMD_WARNING; |
| 10880 | } |
| 10881 | |
| 10882 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10883 | (argc == 3) ? argv[2] : argv[1], |
| 10884 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 10885 | } |
| 10886 | |
| 10887 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 10888 | show_ip_bgp_rsclient_prefix_cmd, |
| 10889 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10890 | SHOW_STR |
| 10891 | IP_STR |
| 10892 | BGP_STR |
| 10893 | "Information about Route Server Client\n" |
| 10894 | NEIGHBOR_ADDR_STR |
| 10895 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10896 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10897 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10898 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 10899 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10900 | SHOW_STR |
| 10901 | BGP_STR |
| 10902 | "BGP view\n" |
| 10903 | "BGP view name\n" |
| 10904 | "Address family\n" |
| 10905 | "Address Family modifier\n" |
| 10906 | "Address Family modifier\n" |
| 10907 | "Information about Route Server Client\n" |
| 10908 | NEIGHBOR_ADDR_STR |
| 10909 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10910 | { |
| 10911 | struct bgp *bgp; |
| 10912 | struct peer *peer; |
| 10913 | safi_t safi; |
| 10914 | |
| 10915 | /* BGP structure lookup. */ |
| 10916 | if (argc == 4) |
| 10917 | { |
| 10918 | bgp = bgp_lookup_by_name (argv[0]); |
| 10919 | if (bgp == NULL) |
| 10920 | { |
| 10921 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10922 | return CMD_WARNING; |
| 10923 | } |
| 10924 | } |
| 10925 | else |
| 10926 | { |
| 10927 | bgp = bgp_get_default (); |
| 10928 | if (bgp == NULL) |
| 10929 | { |
| 10930 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10931 | return CMD_WARNING; |
| 10932 | } |
| 10933 | } |
| 10934 | |
| 10935 | if (argc == 4) { |
| 10936 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10937 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10938 | } else { |
| 10939 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10940 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10941 | } |
| 10942 | |
| 10943 | if (! peer) |
| 10944 | return CMD_WARNING; |
| 10945 | |
| 10946 | if (! peer->afc[AFI_IP][safi]) |
| 10947 | { |
| 10948 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10949 | VTY_NEWLINE); |
| 10950 | return CMD_WARNING; |
| 10951 | } |
| 10952 | |
| 10953 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10954 | PEER_FLAG_RSERVER_CLIENT)) |
| 10955 | { |
| 10956 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10957 | VTY_NEWLINE); |
| 10958 | return CMD_WARNING; |
| 10959 | } |
| 10960 | |
| 10961 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10962 | (argc == 4) ? argv[3] : argv[2], |
| 10963 | AFI_IP, safi, NULL, 1); |
| 10964 | } |
| 10965 | |
| 10966 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10967 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 10968 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10969 | SHOW_STR |
| 10970 | BGP_STR |
| 10971 | "Address family\n" |
| 10972 | "Address Family modifier\n" |
| 10973 | "Address Family modifier\n" |
| 10974 | "Information about Route Server Client\n" |
| 10975 | NEIGHBOR_ADDR_STR |
| 10976 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10977 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10978 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10979 | DEFUN (show_bgp_view_neighbor_routes, |
| 10980 | show_bgp_view_neighbor_routes_cmd, |
| 10981 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 10982 | SHOW_STR |
| 10983 | BGP_STR |
| 10984 | "BGP view\n" |
| 10985 | "BGP view name\n" |
| 10986 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10987 | "Neighbor to display information about\n" |
| 10988 | "Neighbor to display information about\n" |
| 10989 | "Display routes learned from neighbor\n") |
| 10990 | { |
| 10991 | struct peer *peer; |
| 10992 | |
| 10993 | if (argc == 2) |
| 10994 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10995 | else |
| 10996 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10997 | |
| 10998 | if (! peer) |
| 10999 | return CMD_WARNING; |
| 11000 | |
| 11001 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11002 | bgp_show_type_neighbor); |
| 11003 | } |
| 11004 | |
| 11005 | ALIAS (show_bgp_view_neighbor_routes, |
| 11006 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11007 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11008 | SHOW_STR |
| 11009 | BGP_STR |
| 11010 | "BGP view\n" |
| 11011 | "BGP view name\n" |
| 11012 | "Address family\n" |
| 11013 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11014 | "Neighbor to display information about\n" |
| 11015 | "Neighbor to display information about\n" |
| 11016 | "Display routes learned from neighbor\n") |
| 11017 | |
| 11018 | DEFUN (show_bgp_view_neighbor_damp, |
| 11019 | show_bgp_view_neighbor_damp_cmd, |
| 11020 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11021 | SHOW_STR |
| 11022 | BGP_STR |
| 11023 | "BGP view\n" |
| 11024 | "BGP view name\n" |
| 11025 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11026 | "Neighbor to display information about\n" |
| 11027 | "Neighbor to display information about\n" |
| 11028 | "Display the dampened routes received from neighbor\n") |
| 11029 | { |
| 11030 | struct peer *peer; |
| 11031 | |
| 11032 | if (argc == 2) |
| 11033 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11034 | else |
| 11035 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11036 | |
| 11037 | if (! peer) |
| 11038 | return CMD_WARNING; |
| 11039 | |
| 11040 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11041 | bgp_show_type_damp_neighbor); |
| 11042 | } |
| 11043 | |
| 11044 | ALIAS (show_bgp_view_neighbor_damp, |
| 11045 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11046 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11047 | SHOW_STR |
| 11048 | BGP_STR |
| 11049 | "BGP view\n" |
| 11050 | "BGP view name\n" |
| 11051 | "Address family\n" |
| 11052 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11053 | "Neighbor to display information about\n" |
| 11054 | "Neighbor to display information about\n" |
| 11055 | "Display the dampened routes received from neighbor\n") |
| 11056 | |
| 11057 | DEFUN (show_bgp_view_neighbor_flap, |
| 11058 | show_bgp_view_neighbor_flap_cmd, |
| 11059 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11060 | SHOW_STR |
| 11061 | BGP_STR |
| 11062 | "BGP view\n" |
| 11063 | "BGP view name\n" |
| 11064 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11065 | "Neighbor to display information about\n" |
| 11066 | "Neighbor to display information about\n" |
| 11067 | "Display flap statistics of the routes learned from neighbor\n") |
| 11068 | { |
| 11069 | struct peer *peer; |
| 11070 | |
| 11071 | if (argc == 2) |
| 11072 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11073 | else |
| 11074 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11075 | |
| 11076 | if (! peer) |
| 11077 | return CMD_WARNING; |
| 11078 | |
| 11079 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11080 | bgp_show_type_flap_neighbor); |
| 11081 | } |
| 11082 | |
| 11083 | ALIAS (show_bgp_view_neighbor_flap, |
| 11084 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11085 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11086 | SHOW_STR |
| 11087 | BGP_STR |
| 11088 | "BGP view\n" |
| 11089 | "BGP view name\n" |
| 11090 | "Address family\n" |
| 11091 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11092 | "Neighbor to display information about\n" |
| 11093 | "Neighbor to display information about\n" |
| 11094 | "Display flap statistics of the routes learned from neighbor\n") |
| 11095 | |
| 11096 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11097 | show_bgp_neighbor_routes_cmd, |
| 11098 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11099 | SHOW_STR |
| 11100 | BGP_STR |
| 11101 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11102 | "Neighbor to display information about\n" |
| 11103 | "Neighbor to display information about\n" |
| 11104 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11105 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11106 | |
| 11107 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11108 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11109 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11110 | SHOW_STR |
| 11111 | BGP_STR |
| 11112 | "Address family\n" |
| 11113 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11114 | "Neighbor to display information about\n" |
| 11115 | "Neighbor to display information about\n" |
| 11116 | "Display routes learned from neighbor\n") |
| 11117 | |
| 11118 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11119 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11120 | ipv6_bgp_neighbor_routes_cmd, |
| 11121 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11122 | SHOW_STR |
| 11123 | IPV6_STR |
| 11124 | BGP_STR |
| 11125 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11126 | "Neighbor to display information about\n" |
| 11127 | "Neighbor to display information about\n" |
| 11128 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11129 | |
| 11130 | /* old command */ |
| 11131 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11132 | ipv6_mbgp_neighbor_routes_cmd, |
| 11133 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11134 | SHOW_STR |
| 11135 | IPV6_STR |
| 11136 | MBGP_STR |
| 11137 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11138 | "Neighbor to display information about\n" |
| 11139 | "Neighbor to display information about\n" |
| 11140 | "Display routes learned from neighbor\n") |
| 11141 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11142 | struct peer *peer; |
| 11143 | |
| 11144 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11145 | if (! peer) |
| 11146 | return CMD_WARNING; |
| 11147 | |
| 11148 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11149 | bgp_show_type_neighbor); |
| 11150 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11151 | |
| 11152 | ALIAS (show_bgp_view_neighbor_flap, |
| 11153 | show_bgp_neighbor_flap_cmd, |
| 11154 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11155 | SHOW_STR |
| 11156 | BGP_STR |
| 11157 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11158 | "Neighbor to display information about\n" |
| 11159 | "Neighbor to display information about\n" |
| 11160 | "Display flap statistics of the routes learned from neighbor\n") |
| 11161 | |
| 11162 | ALIAS (show_bgp_view_neighbor_flap, |
| 11163 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11164 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11165 | SHOW_STR |
| 11166 | BGP_STR |
| 11167 | "Address family\n" |
| 11168 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11169 | "Neighbor to display information about\n" |
| 11170 | "Neighbor to display information about\n" |
| 11171 | "Display flap statistics of the routes learned from neighbor\n") |
| 11172 | |
| 11173 | ALIAS (show_bgp_view_neighbor_damp, |
| 11174 | show_bgp_neighbor_damp_cmd, |
| 11175 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11176 | SHOW_STR |
| 11177 | BGP_STR |
| 11178 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11179 | "Neighbor to display information about\n" |
| 11180 | "Neighbor to display information about\n" |
| 11181 | "Display the dampened routes received from neighbor\n") |
| 11182 | |
| 11183 | ALIAS (show_bgp_view_neighbor_damp, |
| 11184 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11185 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11186 | SHOW_STR |
| 11187 | BGP_STR |
| 11188 | "Address family\n" |
| 11189 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11190 | "Neighbor to display information about\n" |
| 11191 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11192 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11193 | |
| 11194 | DEFUN (show_bgp_view_rsclient, |
| 11195 | show_bgp_view_rsclient_cmd, |
| 11196 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11197 | SHOW_STR |
| 11198 | BGP_STR |
| 11199 | "BGP view\n" |
| 11200 | "BGP view name\n" |
| 11201 | "Information about Route Server Client\n" |
| 11202 | NEIGHBOR_ADDR_STR) |
| 11203 | { |
| 11204 | struct bgp_table *table; |
| 11205 | struct peer *peer; |
| 11206 | |
| 11207 | if (argc == 2) |
| 11208 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11209 | else |
| 11210 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11211 | |
| 11212 | if (! peer) |
| 11213 | return CMD_WARNING; |
| 11214 | |
| 11215 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11216 | { |
| 11217 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11218 | VTY_NEWLINE); |
| 11219 | return CMD_WARNING; |
| 11220 | } |
| 11221 | |
| 11222 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11223 | PEER_FLAG_RSERVER_CLIENT)) |
| 11224 | { |
| 11225 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11226 | VTY_NEWLINE); |
| 11227 | return CMD_WARNING; |
| 11228 | } |
| 11229 | |
| 11230 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11231 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11232 | 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] | 11233 | } |
| 11234 | |
| 11235 | ALIAS (show_bgp_view_rsclient, |
| 11236 | show_bgp_rsclient_cmd, |
| 11237 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11238 | SHOW_STR |
| 11239 | BGP_STR |
| 11240 | "Information about Route Server Client\n" |
| 11241 | NEIGHBOR_ADDR_STR) |
| 11242 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11243 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11244 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11245 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11246 | SHOW_STR |
| 11247 | BGP_STR |
| 11248 | "BGP view\n" |
| 11249 | "BGP view name\n" |
| 11250 | "Address family\n" |
| 11251 | "Address Family modifier\n" |
| 11252 | "Address Family modifier\n" |
| 11253 | "Information about Route Server Client\n" |
| 11254 | NEIGHBOR_ADDR_STR) |
| 11255 | { |
| 11256 | struct bgp_table *table; |
| 11257 | struct peer *peer; |
| 11258 | safi_t safi; |
| 11259 | |
| 11260 | if (argc == 3) { |
| 11261 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11262 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11263 | } else { |
| 11264 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11265 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11266 | } |
| 11267 | |
| 11268 | if (! peer) |
| 11269 | return CMD_WARNING; |
| 11270 | |
| 11271 | if (! peer->afc[AFI_IP6][safi]) |
| 11272 | { |
| 11273 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11274 | VTY_NEWLINE); |
| 11275 | return CMD_WARNING; |
| 11276 | } |
| 11277 | |
| 11278 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11279 | PEER_FLAG_RSERVER_CLIENT)) |
| 11280 | { |
| 11281 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11282 | VTY_NEWLINE); |
| 11283 | return CMD_WARNING; |
| 11284 | } |
| 11285 | |
| 11286 | table = peer->rib[AFI_IP6][safi]; |
| 11287 | |
| 11288 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11289 | } |
| 11290 | |
| 11291 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11292 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11293 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11294 | SHOW_STR |
| 11295 | BGP_STR |
| 11296 | "Address family\n" |
| 11297 | "Address Family modifier\n" |
| 11298 | "Address Family modifier\n" |
| 11299 | "Information about Route Server Client\n" |
| 11300 | NEIGHBOR_ADDR_STR) |
| 11301 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11302 | DEFUN (show_bgp_view_rsclient_route, |
| 11303 | show_bgp_view_rsclient_route_cmd, |
| 11304 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11305 | SHOW_STR |
| 11306 | BGP_STR |
| 11307 | "BGP view\n" |
| 11308 | "BGP view name\n" |
| 11309 | "Information about Route Server Client\n" |
| 11310 | NEIGHBOR_ADDR_STR |
| 11311 | "Network in the BGP routing table to display\n") |
| 11312 | { |
| 11313 | struct bgp *bgp; |
| 11314 | struct peer *peer; |
| 11315 | |
| 11316 | /* BGP structure lookup. */ |
| 11317 | if (argc == 3) |
| 11318 | { |
| 11319 | bgp = bgp_lookup_by_name (argv[0]); |
| 11320 | if (bgp == NULL) |
| 11321 | { |
| 11322 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11323 | return CMD_WARNING; |
| 11324 | } |
| 11325 | } |
| 11326 | else |
| 11327 | { |
| 11328 | bgp = bgp_get_default (); |
| 11329 | if (bgp == NULL) |
| 11330 | { |
| 11331 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11332 | return CMD_WARNING; |
| 11333 | } |
| 11334 | } |
| 11335 | |
| 11336 | if (argc == 3) |
| 11337 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11338 | else |
| 11339 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11340 | |
| 11341 | if (! peer) |
| 11342 | return CMD_WARNING; |
| 11343 | |
| 11344 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11345 | { |
| 11346 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11347 | VTY_NEWLINE); |
| 11348 | return CMD_WARNING; |
| 11349 | } |
| 11350 | |
| 11351 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11352 | PEER_FLAG_RSERVER_CLIENT)) |
| 11353 | { |
| 11354 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11355 | VTY_NEWLINE); |
| 11356 | return CMD_WARNING; |
| 11357 | } |
| 11358 | |
| 11359 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11360 | (argc == 3) ? argv[2] : argv[1], |
| 11361 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11362 | } |
| 11363 | |
| 11364 | ALIAS (show_bgp_view_rsclient_route, |
| 11365 | show_bgp_rsclient_route_cmd, |
| 11366 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11367 | SHOW_STR |
| 11368 | BGP_STR |
| 11369 | "Information about Route Server Client\n" |
| 11370 | NEIGHBOR_ADDR_STR |
| 11371 | "Network in the BGP routing table to display\n") |
| 11372 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11373 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11374 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11375 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11376 | SHOW_STR |
| 11377 | BGP_STR |
| 11378 | "BGP view\n" |
| 11379 | "BGP view name\n" |
| 11380 | "Address family\n" |
| 11381 | "Address Family modifier\n" |
| 11382 | "Address Family modifier\n" |
| 11383 | "Information about Route Server Client\n" |
| 11384 | NEIGHBOR_ADDR_STR |
| 11385 | "Network in the BGP routing table to display\n") |
| 11386 | { |
| 11387 | struct bgp *bgp; |
| 11388 | struct peer *peer; |
| 11389 | safi_t safi; |
| 11390 | |
| 11391 | /* BGP structure lookup. */ |
| 11392 | if (argc == 4) |
| 11393 | { |
| 11394 | bgp = bgp_lookup_by_name (argv[0]); |
| 11395 | if (bgp == NULL) |
| 11396 | { |
| 11397 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11398 | return CMD_WARNING; |
| 11399 | } |
| 11400 | } |
| 11401 | else |
| 11402 | { |
| 11403 | bgp = bgp_get_default (); |
| 11404 | if (bgp == NULL) |
| 11405 | { |
| 11406 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11407 | return CMD_WARNING; |
| 11408 | } |
| 11409 | } |
| 11410 | |
| 11411 | if (argc == 4) { |
| 11412 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11413 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11414 | } else { |
| 11415 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11416 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11417 | } |
| 11418 | |
| 11419 | if (! peer) |
| 11420 | return CMD_WARNING; |
| 11421 | |
| 11422 | if (! peer->afc[AFI_IP6][safi]) |
| 11423 | { |
| 11424 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11425 | VTY_NEWLINE); |
| 11426 | return CMD_WARNING; |
| 11427 | } |
| 11428 | |
| 11429 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11430 | PEER_FLAG_RSERVER_CLIENT)) |
| 11431 | { |
| 11432 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11433 | VTY_NEWLINE); |
| 11434 | return CMD_WARNING; |
| 11435 | } |
| 11436 | |
| 11437 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11438 | (argc == 4) ? argv[3] : argv[2], |
| 11439 | AFI_IP6, safi, NULL, 0); |
| 11440 | } |
| 11441 | |
| 11442 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11443 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11444 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11445 | SHOW_STR |
| 11446 | BGP_STR |
| 11447 | "Address family\n" |
| 11448 | "Address Family modifier\n" |
| 11449 | "Address Family modifier\n" |
| 11450 | "Information about Route Server Client\n" |
| 11451 | NEIGHBOR_ADDR_STR |
| 11452 | "Network in the BGP routing table to display\n") |
| 11453 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11454 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11455 | show_bgp_view_rsclient_prefix_cmd, |
| 11456 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11457 | SHOW_STR |
| 11458 | BGP_STR |
| 11459 | "BGP view\n" |
| 11460 | "BGP view name\n" |
| 11461 | "Information about Route Server Client\n" |
| 11462 | NEIGHBOR_ADDR_STR |
| 11463 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11464 | { |
| 11465 | struct bgp *bgp; |
| 11466 | struct peer *peer; |
| 11467 | |
| 11468 | /* BGP structure lookup. */ |
| 11469 | if (argc == 3) |
| 11470 | { |
| 11471 | bgp = bgp_lookup_by_name (argv[0]); |
| 11472 | if (bgp == NULL) |
| 11473 | { |
| 11474 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11475 | return CMD_WARNING; |
| 11476 | } |
| 11477 | } |
| 11478 | else |
| 11479 | { |
| 11480 | bgp = bgp_get_default (); |
| 11481 | if (bgp == NULL) |
| 11482 | { |
| 11483 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11484 | return CMD_WARNING; |
| 11485 | } |
| 11486 | } |
| 11487 | |
| 11488 | if (argc == 3) |
| 11489 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11490 | else |
| 11491 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11492 | |
| 11493 | if (! peer) |
| 11494 | return CMD_WARNING; |
| 11495 | |
| 11496 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11497 | { |
| 11498 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11499 | VTY_NEWLINE); |
| 11500 | return CMD_WARNING; |
| 11501 | } |
| 11502 | |
| 11503 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11504 | PEER_FLAG_RSERVER_CLIENT)) |
| 11505 | { |
| 11506 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11507 | VTY_NEWLINE); |
| 11508 | return CMD_WARNING; |
| 11509 | } |
| 11510 | |
| 11511 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11512 | (argc == 3) ? argv[2] : argv[1], |
| 11513 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11514 | } |
| 11515 | |
| 11516 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11517 | show_bgp_rsclient_prefix_cmd, |
| 11518 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11519 | SHOW_STR |
| 11520 | BGP_STR |
| 11521 | "Information about Route Server Client\n" |
| 11522 | NEIGHBOR_ADDR_STR |
| 11523 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11524 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11525 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11526 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11527 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11528 | SHOW_STR |
| 11529 | BGP_STR |
| 11530 | "BGP view\n" |
| 11531 | "BGP view name\n" |
| 11532 | "Address family\n" |
| 11533 | "Address Family modifier\n" |
| 11534 | "Address Family modifier\n" |
| 11535 | "Information about Route Server Client\n" |
| 11536 | NEIGHBOR_ADDR_STR |
| 11537 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11538 | { |
| 11539 | struct bgp *bgp; |
| 11540 | struct peer *peer; |
| 11541 | safi_t safi; |
| 11542 | |
| 11543 | /* BGP structure lookup. */ |
| 11544 | if (argc == 4) |
| 11545 | { |
| 11546 | bgp = bgp_lookup_by_name (argv[0]); |
| 11547 | if (bgp == NULL) |
| 11548 | { |
| 11549 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11550 | return CMD_WARNING; |
| 11551 | } |
| 11552 | } |
| 11553 | else |
| 11554 | { |
| 11555 | bgp = bgp_get_default (); |
| 11556 | if (bgp == NULL) |
| 11557 | { |
| 11558 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11559 | return CMD_WARNING; |
| 11560 | } |
| 11561 | } |
| 11562 | |
| 11563 | if (argc == 4) { |
| 11564 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11565 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11566 | } else { |
| 11567 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11568 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11569 | } |
| 11570 | |
| 11571 | if (! peer) |
| 11572 | return CMD_WARNING; |
| 11573 | |
| 11574 | if (! peer->afc[AFI_IP6][safi]) |
| 11575 | { |
| 11576 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11577 | VTY_NEWLINE); |
| 11578 | return CMD_WARNING; |
| 11579 | } |
| 11580 | |
| 11581 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11582 | PEER_FLAG_RSERVER_CLIENT)) |
| 11583 | { |
| 11584 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11585 | VTY_NEWLINE); |
| 11586 | return CMD_WARNING; |
| 11587 | } |
| 11588 | |
| 11589 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11590 | (argc == 4) ? argv[3] : argv[2], |
| 11591 | AFI_IP6, safi, NULL, 1); |
| 11592 | } |
| 11593 | |
| 11594 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11595 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11596 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11597 | SHOW_STR |
| 11598 | BGP_STR |
| 11599 | "Address family\n" |
| 11600 | "Address Family modifier\n" |
| 11601 | "Address Family modifier\n" |
| 11602 | "Information about Route Server Client\n" |
| 11603 | NEIGHBOR_ADDR_STR |
| 11604 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11605 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11606 | #endif /* HAVE_IPV6 */ |
| 11607 | |
| 11608 | struct bgp_table *bgp_distance_table; |
| 11609 | |
| 11610 | struct bgp_distance |
| 11611 | { |
| 11612 | /* Distance value for the IP source prefix. */ |
| 11613 | u_char distance; |
| 11614 | |
| 11615 | /* Name of the access-list to be matched. */ |
| 11616 | char *access_list; |
| 11617 | }; |
| 11618 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11619 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11620 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11621 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11622 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11623 | } |
| 11624 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11625 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11626 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11627 | { |
| 11628 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11629 | } |
| 11630 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11631 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11632 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11633 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11634 | { |
| 11635 | int ret; |
| 11636 | struct prefix_ipv4 p; |
| 11637 | u_char distance; |
| 11638 | struct bgp_node *rn; |
| 11639 | struct bgp_distance *bdistance; |
| 11640 | |
| 11641 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11642 | if (ret == 0) |
| 11643 | { |
| 11644 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11645 | return CMD_WARNING; |
| 11646 | } |
| 11647 | |
| 11648 | distance = atoi (distance_str); |
| 11649 | |
| 11650 | /* Get BGP distance node. */ |
| 11651 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11652 | if (rn->info) |
| 11653 | { |
| 11654 | bdistance = rn->info; |
| 11655 | bgp_unlock_node (rn); |
| 11656 | } |
| 11657 | else |
| 11658 | { |
| 11659 | bdistance = bgp_distance_new (); |
| 11660 | rn->info = bdistance; |
| 11661 | } |
| 11662 | |
| 11663 | /* Set distance value. */ |
| 11664 | bdistance->distance = distance; |
| 11665 | |
| 11666 | /* Reset access-list configuration. */ |
| 11667 | if (bdistance->access_list) |
| 11668 | { |
| 11669 | free (bdistance->access_list); |
| 11670 | bdistance->access_list = NULL; |
| 11671 | } |
| 11672 | if (access_list_str) |
| 11673 | bdistance->access_list = strdup (access_list_str); |
| 11674 | |
| 11675 | return CMD_SUCCESS; |
| 11676 | } |
| 11677 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11678 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11679 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11680 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11681 | { |
| 11682 | int ret; |
| 11683 | struct prefix_ipv4 p; |
| 11684 | u_char distance; |
| 11685 | struct bgp_node *rn; |
| 11686 | struct bgp_distance *bdistance; |
| 11687 | |
| 11688 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11689 | if (ret == 0) |
| 11690 | { |
| 11691 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11692 | return CMD_WARNING; |
| 11693 | } |
| 11694 | |
| 11695 | distance = atoi (distance_str); |
| 11696 | |
| 11697 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11698 | if (! rn) |
| 11699 | { |
| 11700 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11701 | return CMD_WARNING; |
| 11702 | } |
| 11703 | |
| 11704 | bdistance = rn->info; |
| 11705 | |
| 11706 | if (bdistance->access_list) |
| 11707 | free (bdistance->access_list); |
| 11708 | bgp_distance_free (bdistance); |
| 11709 | |
| 11710 | rn->info = NULL; |
| 11711 | bgp_unlock_node (rn); |
| 11712 | bgp_unlock_node (rn); |
| 11713 | |
| 11714 | return CMD_SUCCESS; |
| 11715 | } |
| 11716 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11717 | /* Apply BGP information to distance method. */ |
| 11718 | u_char |
| 11719 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11720 | { |
| 11721 | struct bgp_node *rn; |
| 11722 | struct prefix_ipv4 q; |
| 11723 | struct peer *peer; |
| 11724 | struct bgp_distance *bdistance; |
| 11725 | struct access_list *alist; |
| 11726 | struct bgp_static *bgp_static; |
| 11727 | |
| 11728 | if (! bgp) |
| 11729 | return 0; |
| 11730 | |
| 11731 | if (p->family != AF_INET) |
| 11732 | return 0; |
| 11733 | |
| 11734 | peer = rinfo->peer; |
| 11735 | |
| 11736 | if (peer->su.sa.sa_family != AF_INET) |
| 11737 | return 0; |
| 11738 | |
| 11739 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11740 | q.family = AF_INET; |
| 11741 | q.prefix = peer->su.sin.sin_addr; |
| 11742 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11743 | |
| 11744 | /* Check source address. */ |
| 11745 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11746 | if (rn) |
| 11747 | { |
| 11748 | bdistance = rn->info; |
| 11749 | bgp_unlock_node (rn); |
| 11750 | |
| 11751 | if (bdistance->access_list) |
| 11752 | { |
| 11753 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11754 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11755 | return bdistance->distance; |
| 11756 | } |
| 11757 | else |
| 11758 | return bdistance->distance; |
| 11759 | } |
| 11760 | |
| 11761 | /* Backdoor check. */ |
| 11762 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11763 | if (rn) |
| 11764 | { |
| 11765 | bgp_static = rn->info; |
| 11766 | bgp_unlock_node (rn); |
| 11767 | |
| 11768 | if (bgp_static->backdoor) |
| 11769 | { |
| 11770 | if (bgp->distance_local) |
| 11771 | return bgp->distance_local; |
| 11772 | else |
| 11773 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11774 | } |
| 11775 | } |
| 11776 | |
| 11777 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 11778 | { |
| 11779 | if (bgp->distance_ebgp) |
| 11780 | return bgp->distance_ebgp; |
| 11781 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11782 | } |
| 11783 | else |
| 11784 | { |
| 11785 | if (bgp->distance_ibgp) |
| 11786 | return bgp->distance_ibgp; |
| 11787 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11788 | } |
| 11789 | } |
| 11790 | |
| 11791 | DEFUN (bgp_distance, |
| 11792 | bgp_distance_cmd, |
| 11793 | "distance bgp <1-255> <1-255> <1-255>", |
| 11794 | "Define an administrative distance\n" |
| 11795 | "BGP distance\n" |
| 11796 | "Distance for routes external to the AS\n" |
| 11797 | "Distance for routes internal to the AS\n" |
| 11798 | "Distance for local routes\n") |
| 11799 | { |
| 11800 | struct bgp *bgp; |
| 11801 | |
| 11802 | bgp = vty->index; |
| 11803 | |
| 11804 | bgp->distance_ebgp = atoi (argv[0]); |
| 11805 | bgp->distance_ibgp = atoi (argv[1]); |
| 11806 | bgp->distance_local = atoi (argv[2]); |
| 11807 | return CMD_SUCCESS; |
| 11808 | } |
| 11809 | |
| 11810 | DEFUN (no_bgp_distance, |
| 11811 | no_bgp_distance_cmd, |
| 11812 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11813 | NO_STR |
| 11814 | "Define an administrative distance\n" |
| 11815 | "BGP distance\n" |
| 11816 | "Distance for routes external to the AS\n" |
| 11817 | "Distance for routes internal to the AS\n" |
| 11818 | "Distance for local routes\n") |
| 11819 | { |
| 11820 | struct bgp *bgp; |
| 11821 | |
| 11822 | bgp = vty->index; |
| 11823 | |
| 11824 | bgp->distance_ebgp= 0; |
| 11825 | bgp->distance_ibgp = 0; |
| 11826 | bgp->distance_local = 0; |
| 11827 | return CMD_SUCCESS; |
| 11828 | } |
| 11829 | |
| 11830 | ALIAS (no_bgp_distance, |
| 11831 | no_bgp_distance2_cmd, |
| 11832 | "no distance bgp", |
| 11833 | NO_STR |
| 11834 | "Define an administrative distance\n" |
| 11835 | "BGP distance\n") |
| 11836 | |
| 11837 | DEFUN (bgp_distance_source, |
| 11838 | bgp_distance_source_cmd, |
| 11839 | "distance <1-255> A.B.C.D/M", |
| 11840 | "Define an administrative distance\n" |
| 11841 | "Administrative distance\n" |
| 11842 | "IP source prefix\n") |
| 11843 | { |
| 11844 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11845 | return CMD_SUCCESS; |
| 11846 | } |
| 11847 | |
| 11848 | DEFUN (no_bgp_distance_source, |
| 11849 | no_bgp_distance_source_cmd, |
| 11850 | "no distance <1-255> A.B.C.D/M", |
| 11851 | NO_STR |
| 11852 | "Define an administrative distance\n" |
| 11853 | "Administrative distance\n" |
| 11854 | "IP source prefix\n") |
| 11855 | { |
| 11856 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 11857 | return CMD_SUCCESS; |
| 11858 | } |
| 11859 | |
| 11860 | DEFUN (bgp_distance_source_access_list, |
| 11861 | bgp_distance_source_access_list_cmd, |
| 11862 | "distance <1-255> A.B.C.D/M WORD", |
| 11863 | "Define an administrative distance\n" |
| 11864 | "Administrative distance\n" |
| 11865 | "IP source prefix\n" |
| 11866 | "Access list name\n") |
| 11867 | { |
| 11868 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 11869 | return CMD_SUCCESS; |
| 11870 | } |
| 11871 | |
| 11872 | DEFUN (no_bgp_distance_source_access_list, |
| 11873 | no_bgp_distance_source_access_list_cmd, |
| 11874 | "no distance <1-255> A.B.C.D/M WORD", |
| 11875 | NO_STR |
| 11876 | "Define an administrative distance\n" |
| 11877 | "Administrative distance\n" |
| 11878 | "IP source prefix\n" |
| 11879 | "Access list name\n") |
| 11880 | { |
| 11881 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 11882 | return CMD_SUCCESS; |
| 11883 | } |
| 11884 | |
| 11885 | DEFUN (bgp_damp_set, |
| 11886 | bgp_damp_set_cmd, |
| 11887 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11888 | "BGP Specific commands\n" |
| 11889 | "Enable route-flap dampening\n" |
| 11890 | "Half-life time for the penalty\n" |
| 11891 | "Value to start reusing a route\n" |
| 11892 | "Value to start suppressing a route\n" |
| 11893 | "Maximum duration to suppress a stable route\n") |
| 11894 | { |
| 11895 | struct bgp *bgp; |
| 11896 | int half = DEFAULT_HALF_LIFE * 60; |
| 11897 | int reuse = DEFAULT_REUSE; |
| 11898 | int suppress = DEFAULT_SUPPRESS; |
| 11899 | int max = 4 * half; |
| 11900 | |
| 11901 | if (argc == 4) |
| 11902 | { |
| 11903 | half = atoi (argv[0]) * 60; |
| 11904 | reuse = atoi (argv[1]); |
| 11905 | suppress = atoi (argv[2]); |
| 11906 | max = atoi (argv[3]) * 60; |
| 11907 | } |
| 11908 | else if (argc == 1) |
| 11909 | { |
| 11910 | half = atoi (argv[0]) * 60; |
| 11911 | max = 4 * half; |
| 11912 | } |
| 11913 | |
| 11914 | bgp = vty->index; |
| 11915 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 11916 | half, reuse, suppress, max); |
| 11917 | } |
| 11918 | |
| 11919 | ALIAS (bgp_damp_set, |
| 11920 | bgp_damp_set2_cmd, |
| 11921 | "bgp dampening <1-45>", |
| 11922 | "BGP Specific commands\n" |
| 11923 | "Enable route-flap dampening\n" |
| 11924 | "Half-life time for the penalty\n") |
| 11925 | |
| 11926 | ALIAS (bgp_damp_set, |
| 11927 | bgp_damp_set3_cmd, |
| 11928 | "bgp dampening", |
| 11929 | "BGP Specific commands\n" |
| 11930 | "Enable route-flap dampening\n") |
| 11931 | |
| 11932 | DEFUN (bgp_damp_unset, |
| 11933 | bgp_damp_unset_cmd, |
| 11934 | "no bgp dampening", |
| 11935 | NO_STR |
| 11936 | "BGP Specific commands\n" |
| 11937 | "Enable route-flap dampening\n") |
| 11938 | { |
| 11939 | struct bgp *bgp; |
| 11940 | |
| 11941 | bgp = vty->index; |
| 11942 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 11943 | } |
| 11944 | |
| 11945 | ALIAS (bgp_damp_unset, |
| 11946 | bgp_damp_unset2_cmd, |
| 11947 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11948 | NO_STR |
| 11949 | "BGP Specific commands\n" |
| 11950 | "Enable route-flap dampening\n" |
| 11951 | "Half-life time for the penalty\n" |
| 11952 | "Value to start reusing a route\n" |
| 11953 | "Value to start suppressing a route\n" |
| 11954 | "Maximum duration to suppress a stable route\n") |
| 11955 | |
| 11956 | DEFUN (show_ip_bgp_dampened_paths, |
| 11957 | show_ip_bgp_dampened_paths_cmd, |
| 11958 | "show ip bgp dampened-paths", |
| 11959 | SHOW_STR |
| 11960 | IP_STR |
| 11961 | BGP_STR |
| 11962 | "Display paths suppressed due to dampening\n") |
| 11963 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11964 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 11965 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11966 | } |
| 11967 | |
| 11968 | DEFUN (show_ip_bgp_flap_statistics, |
| 11969 | show_ip_bgp_flap_statistics_cmd, |
| 11970 | "show ip bgp flap-statistics", |
| 11971 | SHOW_STR |
| 11972 | IP_STR |
| 11973 | BGP_STR |
| 11974 | "Display flap statistics of routes\n") |
| 11975 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11976 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 11977 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11978 | } |
| 11979 | |
| 11980 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11981 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11982 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 11983 | const char *ip_str, afi_t afi, safi_t safi, |
| 11984 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11985 | { |
| 11986 | int ret; |
| 11987 | struct prefix match; |
| 11988 | struct bgp_node *rn; |
| 11989 | struct bgp_node *rm; |
| 11990 | struct bgp_info *ri; |
| 11991 | struct bgp_info *ri_temp; |
| 11992 | struct bgp *bgp; |
| 11993 | struct bgp_table *table; |
| 11994 | |
| 11995 | /* BGP structure lookup. */ |
| 11996 | if (view_name) |
| 11997 | { |
| 11998 | bgp = bgp_lookup_by_name (view_name); |
| 11999 | if (bgp == NULL) |
| 12000 | { |
| 12001 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12002 | return CMD_WARNING; |
| 12003 | } |
| 12004 | } |
| 12005 | else |
| 12006 | { |
| 12007 | bgp = bgp_get_default (); |
| 12008 | if (bgp == NULL) |
| 12009 | { |
| 12010 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12011 | return CMD_WARNING; |
| 12012 | } |
| 12013 | } |
| 12014 | |
| 12015 | /* Check IP address argument. */ |
| 12016 | ret = str2prefix (ip_str, &match); |
| 12017 | if (! ret) |
| 12018 | { |
| 12019 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12020 | return CMD_WARNING; |
| 12021 | } |
| 12022 | |
| 12023 | match.family = afi2family (afi); |
| 12024 | |
| 12025 | if (safi == SAFI_MPLS_VPN) |
| 12026 | { |
| 12027 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12028 | { |
| 12029 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12030 | continue; |
| 12031 | |
| 12032 | if ((table = rn->info) != NULL) |
| 12033 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12034 | { |
| 12035 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12036 | { |
| 12037 | ri = rm->info; |
| 12038 | while (ri) |
| 12039 | { |
| 12040 | if (ri->extra && ri->extra->damp_info) |
| 12041 | { |
| 12042 | ri_temp = ri->next; |
| 12043 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12044 | ri = ri_temp; |
| 12045 | } |
| 12046 | else |
| 12047 | ri = ri->next; |
| 12048 | } |
| 12049 | } |
| 12050 | |
| 12051 | bgp_unlock_node (rm); |
| 12052 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12053 | } |
| 12054 | } |
| 12055 | else |
| 12056 | { |
| 12057 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12058 | { |
| 12059 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12060 | { |
| 12061 | ri = rn->info; |
| 12062 | while (ri) |
| 12063 | { |
| 12064 | if (ri->extra && ri->extra->damp_info) |
| 12065 | { |
| 12066 | ri_temp = ri->next; |
| 12067 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12068 | ri = ri_temp; |
| 12069 | } |
| 12070 | else |
| 12071 | ri = ri->next; |
| 12072 | } |
| 12073 | } |
| 12074 | |
| 12075 | bgp_unlock_node (rn); |
| 12076 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12077 | } |
| 12078 | |
| 12079 | return CMD_SUCCESS; |
| 12080 | } |
| 12081 | |
| 12082 | DEFUN (clear_ip_bgp_dampening, |
| 12083 | clear_ip_bgp_dampening_cmd, |
| 12084 | "clear ip bgp dampening", |
| 12085 | CLEAR_STR |
| 12086 | IP_STR |
| 12087 | BGP_STR |
| 12088 | "Clear route flap dampening information\n") |
| 12089 | { |
| 12090 | bgp_damp_info_clean (); |
| 12091 | return CMD_SUCCESS; |
| 12092 | } |
| 12093 | |
| 12094 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12095 | clear_ip_bgp_dampening_prefix_cmd, |
| 12096 | "clear ip bgp dampening A.B.C.D/M", |
| 12097 | CLEAR_STR |
| 12098 | IP_STR |
| 12099 | BGP_STR |
| 12100 | "Clear route flap dampening information\n" |
| 12101 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12102 | { |
| 12103 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12104 | SAFI_UNICAST, NULL, 1); |
| 12105 | } |
| 12106 | |
| 12107 | DEFUN (clear_ip_bgp_dampening_address, |
| 12108 | clear_ip_bgp_dampening_address_cmd, |
| 12109 | "clear ip bgp dampening A.B.C.D", |
| 12110 | CLEAR_STR |
| 12111 | IP_STR |
| 12112 | BGP_STR |
| 12113 | "Clear route flap dampening information\n" |
| 12114 | "Network to clear damping information\n") |
| 12115 | { |
| 12116 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12117 | SAFI_UNICAST, NULL, 0); |
| 12118 | } |
| 12119 | |
| 12120 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12121 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12122 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12123 | CLEAR_STR |
| 12124 | IP_STR |
| 12125 | BGP_STR |
| 12126 | "Clear route flap dampening information\n" |
| 12127 | "Network to clear damping information\n" |
| 12128 | "Network mask\n") |
| 12129 | { |
| 12130 | int ret; |
| 12131 | char prefix_str[BUFSIZ]; |
| 12132 | |
| 12133 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12134 | if (! ret) |
| 12135 | { |
| 12136 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12137 | return CMD_WARNING; |
| 12138 | } |
| 12139 | |
| 12140 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12141 | SAFI_UNICAST, NULL, 0); |
| 12142 | } |
| 12143 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12144 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12145 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12146 | afi_t afi, safi_t safi, int *write) |
| 12147 | { |
| 12148 | struct bgp_node *prn; |
| 12149 | struct bgp_node *rn; |
| 12150 | struct bgp_table *table; |
| 12151 | struct prefix *p; |
| 12152 | struct prefix_rd *prd; |
| 12153 | struct bgp_static *bgp_static; |
| 12154 | u_int32_t label; |
| 12155 | char buf[SU_ADDRSTRLEN]; |
| 12156 | char rdbuf[RD_ADDRSTRLEN]; |
| 12157 | |
| 12158 | /* Network configuration. */ |
| 12159 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12160 | if ((table = prn->info) != NULL) |
| 12161 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12162 | if ((bgp_static = rn->info) != NULL) |
| 12163 | { |
| 12164 | p = &rn->p; |
| 12165 | prd = (struct prefix_rd *) &prn->p; |
| 12166 | |
| 12167 | /* "address-family" display. */ |
| 12168 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12169 | |
| 12170 | /* "network" configuration display. */ |
| 12171 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12172 | label = decode_label (bgp_static->tag); |
| 12173 | |
| 12174 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12175 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12176 | p->prefixlen, |
| 12177 | rdbuf, label); |
| 12178 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12179 | } |
| 12180 | return 0; |
| 12181 | } |
| 12182 | |
| 12183 | /* Configuration of static route announcement and aggregate |
| 12184 | information. */ |
| 12185 | int |
| 12186 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12187 | afi_t afi, safi_t safi, int *write) |
| 12188 | { |
| 12189 | struct bgp_node *rn; |
| 12190 | struct prefix *p; |
| 12191 | struct bgp_static *bgp_static; |
| 12192 | struct bgp_aggregate *bgp_aggregate; |
| 12193 | char buf[SU_ADDRSTRLEN]; |
| 12194 | |
| 12195 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12196 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12197 | |
| 12198 | /* Network configuration. */ |
| 12199 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12200 | if ((bgp_static = rn->info) != NULL) |
| 12201 | { |
| 12202 | p = &rn->p; |
| 12203 | |
| 12204 | /* "address-family" display. */ |
| 12205 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12206 | |
| 12207 | /* "network" configuration display. */ |
| 12208 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12209 | { |
| 12210 | u_int32_t destination; |
| 12211 | struct in_addr netmask; |
| 12212 | |
| 12213 | destination = ntohl (p->u.prefix4.s_addr); |
| 12214 | masklen2ip (p->prefixlen, &netmask); |
| 12215 | vty_out (vty, " network %s", |
| 12216 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12217 | |
| 12218 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12219 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12220 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12221 | || p->u.prefix4.s_addr == 0) |
| 12222 | { |
| 12223 | /* Natural mask is not display. */ |
| 12224 | } |
| 12225 | else |
| 12226 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12227 | } |
| 12228 | else |
| 12229 | { |
| 12230 | vty_out (vty, " network %s/%d", |
| 12231 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12232 | p->prefixlen); |
| 12233 | } |
| 12234 | |
| 12235 | if (bgp_static->rmap.name) |
| 12236 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12237 | else |
| 12238 | { |
| 12239 | if (bgp_static->backdoor) |
| 12240 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12241 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12242 | |
| 12243 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12244 | } |
| 12245 | |
| 12246 | /* Aggregate-address configuration. */ |
| 12247 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12248 | if ((bgp_aggregate = rn->info) != NULL) |
| 12249 | { |
| 12250 | p = &rn->p; |
| 12251 | |
| 12252 | /* "address-family" display. */ |
| 12253 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12254 | |
| 12255 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12256 | { |
| 12257 | struct in_addr netmask; |
| 12258 | |
| 12259 | masklen2ip (p->prefixlen, &netmask); |
| 12260 | vty_out (vty, " aggregate-address %s %s", |
| 12261 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12262 | inet_ntoa (netmask)); |
| 12263 | } |
| 12264 | else |
| 12265 | { |
| 12266 | vty_out (vty, " aggregate-address %s/%d", |
| 12267 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12268 | p->prefixlen); |
| 12269 | } |
| 12270 | |
| 12271 | if (bgp_aggregate->as_set) |
| 12272 | vty_out (vty, " as-set"); |
| 12273 | |
| 12274 | if (bgp_aggregate->summary_only) |
| 12275 | vty_out (vty, " summary-only"); |
| 12276 | |
| 12277 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12278 | } |
| 12279 | |
| 12280 | return 0; |
| 12281 | } |
| 12282 | |
| 12283 | int |
| 12284 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12285 | { |
| 12286 | struct bgp_node *rn; |
| 12287 | struct bgp_distance *bdistance; |
| 12288 | |
| 12289 | /* Distance configuration. */ |
| 12290 | if (bgp->distance_ebgp |
| 12291 | && bgp->distance_ibgp |
| 12292 | && bgp->distance_local |
| 12293 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12294 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12295 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12296 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12297 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12298 | VTY_NEWLINE); |
| 12299 | |
| 12300 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12301 | if ((bdistance = rn->info) != NULL) |
| 12302 | { |
| 12303 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12304 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12305 | bdistance->access_list ? bdistance->access_list : "", |
| 12306 | VTY_NEWLINE); |
| 12307 | } |
| 12308 | |
| 12309 | return 0; |
| 12310 | } |
| 12311 | |
| 12312 | /* Allocate routing table structure and install commands. */ |
| 12313 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12314 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12315 | { |
| 12316 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12317 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12318 | |
| 12319 | /* IPv4 BGP commands. */ |
| 12320 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12321 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12322 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12323 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12324 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12325 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12326 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12327 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12328 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12329 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12330 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12331 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12332 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12333 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12334 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12335 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12336 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12337 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12338 | |
| 12339 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12340 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12341 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12342 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12343 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12344 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12345 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12346 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12347 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12348 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12349 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12350 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12351 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12352 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12353 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12354 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12355 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12356 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12357 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12358 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12359 | |
| 12360 | /* IPv4 unicast configuration. */ |
| 12361 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12362 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12363 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12364 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12365 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12366 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12367 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12368 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12369 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12370 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12371 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12372 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12373 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12374 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12375 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12376 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12377 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12378 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12379 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12380 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12381 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12382 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12383 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12384 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12385 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12386 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12387 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12388 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12389 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12390 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12391 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12392 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12393 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12394 | |
| 12395 | /* IPv4 multicast configuration. */ |
| 12396 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12397 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12398 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12399 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12400 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12401 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12402 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12403 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12404 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12405 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12406 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12407 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12408 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12409 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12410 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12411 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12412 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12413 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12414 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12415 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12416 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12417 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12418 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12419 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12420 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12421 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12422 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12423 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12424 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12425 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12426 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12427 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12428 | |
| 12429 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12430 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12431 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12432 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12433 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12434 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12435 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12436 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12437 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12438 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12439 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12440 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12441 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12442 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12443 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12444 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12445 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12446 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12447 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12448 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12449 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12450 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12451 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12452 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12453 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12454 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12455 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12456 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12457 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12458 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12459 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12460 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12461 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12462 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12463 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12464 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12465 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12466 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12467 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12468 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12469 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12470 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12471 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12472 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12473 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12474 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12475 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12476 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12477 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12478 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12479 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12480 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12481 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12482 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12483 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12484 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12485 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12486 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12487 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12488 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12489 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12490 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12491 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12492 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12493 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12494 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12495 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 12496 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12497 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12498 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12499 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12500 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12501 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12502 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12503 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12504 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12505 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12506 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12507 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12508 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12509 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12510 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12511 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12512 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12513 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12514 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12515 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12516 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12517 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12518 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12519 | |
| 12520 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12521 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12522 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12523 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12524 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12525 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12526 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12527 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12528 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12529 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12530 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12531 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12532 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12533 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12534 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12535 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12536 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12537 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12538 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12539 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12540 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12541 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12542 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12543 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12544 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12545 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12546 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12547 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12548 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12549 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12550 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12551 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12552 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12553 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12554 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12555 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12556 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12557 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12558 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12559 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12560 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12561 | |
| 12562 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12563 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12564 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12565 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12566 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12567 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12568 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12569 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12570 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12571 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12572 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12573 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12574 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12575 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12576 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12577 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12578 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12579 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12580 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12581 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12582 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12583 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12584 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12585 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12586 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12587 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12588 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12589 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12590 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12591 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12592 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12593 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12594 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12595 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12596 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12597 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12598 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12599 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12600 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12601 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12602 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12603 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12604 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12605 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12606 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12607 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12608 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12609 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12610 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12611 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12612 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12613 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12614 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12615 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12616 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12617 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12618 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12619 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12620 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12621 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12622 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12623 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12624 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12625 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12626 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12627 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12628 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 12629 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12630 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12631 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12632 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12633 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12634 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12635 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12636 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12637 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12638 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12639 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12640 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12641 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12642 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12643 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12644 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12645 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12646 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12647 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12648 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12649 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12650 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12651 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12652 | |
| 12653 | /* BGP dampening clear commands */ |
| 12654 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12655 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12656 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12657 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12658 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12659 | /* prefix count */ |
| 12660 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12661 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12662 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12663 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12664 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12665 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12666 | /* New config IPv6 BGP commands. */ |
| 12667 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12668 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12669 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12670 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12671 | |
| 12672 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12673 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12674 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12675 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12676 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12677 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12678 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12679 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12680 | /* Old config IPv6 BGP commands. */ |
| 12681 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12682 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12683 | |
| 12684 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12685 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12686 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12687 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12688 | |
| 12689 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12690 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12691 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12692 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12693 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12694 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12695 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12696 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12697 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12698 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12699 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12700 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12701 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12702 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12703 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12704 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12705 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12706 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12707 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12708 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12709 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12710 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12711 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12712 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12713 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12714 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12715 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12716 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12717 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12718 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12719 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12720 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12721 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12722 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12723 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12724 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12725 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12726 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12727 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12728 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12729 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12730 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12731 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12732 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12733 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12734 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12735 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12736 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12737 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12738 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12739 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12740 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12741 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12742 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12743 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12744 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12745 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12746 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12747 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12748 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12749 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12750 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12751 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12752 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12753 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12754 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12755 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12756 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12757 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12758 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12759 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12760 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12761 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12762 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12763 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12764 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12765 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12766 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12767 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12768 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12769 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12770 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12771 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12772 | |
| 12773 | /* Restricted: |
| 12774 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12775 | */ |
| 12776 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12777 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12778 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12779 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12780 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12781 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12782 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12783 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12784 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12785 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12786 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12787 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12788 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12789 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12790 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12791 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12792 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12793 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12794 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12795 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12796 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12797 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12798 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12799 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12800 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12801 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12802 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12803 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12804 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12805 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12806 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12807 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12808 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12809 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12810 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12811 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12812 | |
| 12813 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 12814 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12815 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12816 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 12817 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12818 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12819 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 12820 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12821 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12822 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 12823 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12824 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 12825 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12826 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 12827 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12828 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 12829 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12830 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 12831 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12832 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 12833 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 12834 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 12835 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 12836 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 12837 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 12838 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 12839 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 12840 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 12841 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12842 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 12843 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12844 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 12845 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12846 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 12847 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12848 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 12849 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12850 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 12851 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12852 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 12853 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12854 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12855 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12856 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12857 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12858 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 12859 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12860 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12861 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12862 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 12863 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12864 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 12865 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12866 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12867 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12868 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12869 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12870 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12871 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12872 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 12873 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 12874 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 12875 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12876 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 12877 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12878 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12879 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12880 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12881 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12882 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12883 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12884 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12885 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12886 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12887 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12888 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12889 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12890 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12891 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12892 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12893 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12894 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12895 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12896 | |
| 12897 | /* Statistics */ |
| 12898 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 12899 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 12900 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 12901 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 12902 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12903 | /* old command */ |
| 12904 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 12905 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 12906 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12907 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12908 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12909 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12910 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12911 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 12912 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 12913 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 12914 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 12915 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12916 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12917 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12918 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12919 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12920 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12921 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12922 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 12923 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 12924 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12925 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12926 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12927 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12928 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12929 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 12930 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12931 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12932 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12933 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12934 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 12935 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 12936 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 12937 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 12938 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 12939 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12940 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12941 | /* old command */ |
| 12942 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 12943 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 12944 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12945 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12946 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12947 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12948 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12949 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 12950 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 12951 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 12952 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 12953 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12954 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12955 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12956 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12957 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12958 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12959 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12960 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 12961 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 12962 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12963 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12964 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12965 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12966 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12967 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 12968 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12969 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12970 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12971 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12972 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 12973 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 12974 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 12975 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 12976 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 12977 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 12978 | |
| 12979 | /* old command */ |
| 12980 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 12981 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 12982 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 12983 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 12984 | |
| 12985 | /* old command */ |
| 12986 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 12987 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 12988 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 12989 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 12990 | |
| 12991 | /* old command */ |
| 12992 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 12993 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 12994 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 12995 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 12996 | #endif /* HAVE_IPV6 */ |
| 12997 | |
| 12998 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 12999 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13000 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13001 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13002 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13003 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13004 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13005 | |
| 13006 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13007 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13008 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13009 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13010 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13011 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13012 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13013 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13014 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13015 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13016 | |
| 13017 | /* Deprecated AS-Pathlimit commands */ |
| 13018 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13019 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13020 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13021 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13022 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13023 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13024 | |
| 13025 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13026 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13027 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13028 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13029 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13030 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13031 | |
| 13032 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13033 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13034 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13035 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13036 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13037 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13038 | |
| 13039 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13040 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13041 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13042 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13043 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13044 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13045 | |
| 13046 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13047 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13048 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13049 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13050 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13051 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13052 | |
| 13053 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13054 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13055 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13056 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13057 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13058 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13059 | |
| 13060 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13061 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13062 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13063 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13064 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13065 | |
| 13066 | void |
| 13067 | bgp_route_finish (void) |
| 13068 | { |
| 13069 | bgp_table_unlock (bgp_distance_table); |
| 13070 | bgp_distance_table = NULL; |
| 13071 | } |